Skip to content

Commit

Permalink
chore: Merge branch 'release/v9.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuthor committed Jul 17, 2023
2 parents 0313c1c + 2e74f1a commit e37da43
Show file tree
Hide file tree
Showing 43 changed files with 378 additions and 156 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
subcommands: |
python3 scripts/download_wasm.py
npm install
kms-version: 4.3.3
kms-version: 4.4.3
findex-cloud-version: 0.1.0

lint:
Expand All @@ -33,7 +33,7 @@ jobs:
with:
subcommands: |
npm test
kms-version: 4.3.3
kms-version: 4.4.3
findex-cloud-version: 0.1.0
regression_files: |
./node_modules/non_regression_vector.json
Expand All @@ -48,7 +48,7 @@ jobs:
extension: so
destination: linux-x86-64
os: ubuntu-20.04
kms-version: 4.3.3
kms-version: 4.4.3
findex-cloud-version: 0.1.0
copy_fresh_build: false
copy_regression_files: |
Expand All @@ -60,9 +60,9 @@ jobs:
- test
uses: Cosmian/reusable_workflows/.github/workflows/cloudproof_python.yml@develop
with:
branch: v4.0.0
branch: v4.0.2
target: x86_64-unknown-linux-gnu
kms-version: 4.3.3
kms-version: 4.4.3
copy_fresh_build: false
copy_regression_files: |
cp ./cloudproof_js/non_regression_vector.json tests/data/cover_crypt/non_regression/js_non_regression_vector.json
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
sleep 5
cd ../test
node chrome.mjs http://localhost:8090 http://kms:9998
kms-version: 4.3.3
kms-version: 4.4.3
findex-cloud-version: 0.1.0

example_reactjs:
Expand All @@ -108,7 +108,7 @@ jobs:
sleep 5
cd ../test
node chrome.mjs http://localhost:8090 http://kms:9998
kms-version: 4.3.3
kms-version: 4.4.3
findex-cloud-version: 0.1.0

example_browser:
Expand All @@ -121,7 +121,7 @@ jobs:
python3 -m http.server &
sleep 3
node test.mjs
kms-version: 4.3.3
kms-version: 4.4.3
findex-cloud-version: 0.1.0

example_webpack:
Expand All @@ -141,7 +141,7 @@ jobs:
cd examples/nodejs
npm install
node test.mjs 10
kms-version: 4.3.3
kms-version: 4.4.3
findex-cloud-version: 0.1.0

example_imdb:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/js_in_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

services:
kms:
image: cosmian/kms:${{ inputs.kms-version }}
image: ghcr.io/cosmian/kms:${{ inputs.kms-version }}
env:
COSMIAN_SERVER_URL: http://localhost:9998
KMS_PUBLIC_PATH: /tmp
Expand Down
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
exclude: dist|tests/data|tests/findex.test.ts|src/pkg|examples/full_text_search/data
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.1.1
rev: v2.3.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: [] # optional: list of Conventional Commits types to allow e.g. [feat, fix, ci, chore, test]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
rev: v3.0.0
hooks:
- id: prettier
stages: [commit]
Expand All @@ -26,7 +26,7 @@ repos:
- markdown

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.32.2
rev: v0.35.0
hooks:
- id: markdownlint-fix
args: [--disable=MD004, --disable=MD013, --disable=MD024, --disable=MD041]
Expand All @@ -39,32 +39,32 @@ repos:
- id: markdown-toc

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.2
rev: 0.2.3
hooks:
- id: yamlfmt
args: [--mapping, '2', --sequence, '4', --offset, '2']

- repo: https://github.com/crate-ci/typos
rev: v1.12.14
rev: v1.16.1
hooks:
- id: typos

- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.27.0
rev: v8.40.0
hooks:
- id: eslint
args: [src, --fix]

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.3.1
rev: v1.5.1
hooks:
- id: forbid-crlf
- id: remove-crlf
- id: forbid-tabs
- id: remove-tabs

- repo: https://github.com/sirosen/texthooks
rev: 0.4.0
rev: 0.5.0
hooks:
- id: fix-smartquotes
- id: fix-ligatures
Expand All @@ -79,12 +79,12 @@ repos:
- id: shellcheck

- repo: https://github.com/Cretezy/flutter-format-pre-commit
rev: 4a1df675bb74dea371c17934933e257e46f8dd98
rev: 35be2187259c39889e2ac1936399b8a1ae6a5a00
hooks:
- id: flutter-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file.

## [9.1.0] - 2023-07-12

### Features

- Add verbosity on Findex callbacks
- Add ECIES Salsa seal box bindings
- Add AES256GCM bindings

## [9.0.0] - 2023-06-01

### Features
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ From the version 8.0.0, `cloudproof_js` depends on [cloudproof_rust](https://git
| 8.0.0 | 1.0.0 |
| 8.1.0 | 1.1.0 |
| 9.0.0 | 2.0.1 |
| 9.1.0 | 2.1.0 |
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: '3'
services:
kms:
container_name: kms
image: cosmian/kms:4.3.3
image: ghcr.io/cosmian/kms:4.4.3
environment:
- KMS_HOSTNAME=0.0.0.0
- KMS_PUBLIC_PATH=/tmp
Expand Down
2 changes: 1 addition & 1 deletion examples/test/chrome.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async function runTest(name, withGraphs, withKms) {
)

await page.click("#encrypt_user")
await page.waitForSelector("#table_encrypted_users", { timeout: 5000 })
await page.waitForSelector("#table_encrypted_users", { timeout: 10000 })
await assertCountSelector(page, "#table_encrypted_users tbody tr", 10)

await page.click("#index")
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cloudproof_js",
"version": "9.0.0",
"version": "9.1.0",
"license": "MIT",
"description": "Cosmian Cloudproof javascript client library",
"author": "Bruno Grieder<bruno.grieder@cosmian.com>, Pauline Hochard<pauline.hochard@cosmian.com>, Emmanuel Coste<emmanuel.coste@cosmian.com>, Thibaud Dauce<thibaud.dauce@cosmian.com>",
Expand Down Expand Up @@ -57,7 +57,7 @@
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard-with-typescript": "^22.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsdoc": "^39.3.6",
"eslint-plugin-jsdoc": "^46.4.3",
"eslint-plugin-n": "^15.2.5",
"eslint-plugin-promise": "^6.0.1",
"prettier": "2.7.1",
Expand Down
21 changes: 13 additions & 8 deletions scripts/download_wasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ def download_wasm(version: str) -> bool:

ssl._create_default_https_context = ssl._create_unverified_context

to_be_copied = files_to_be_copied('findex')
to_be_copied = files_to_be_copied('aesgcm')
to_be_copied.update(files_to_be_copied('anonymization'))
to_be_copied.update(files_to_be_copied('cover_crypt'))
to_be_copied.update(files_to_be_copied('fpe'))
to_be_copied.update(files_to_be_copied('anonymization'))
to_be_copied.update(files_to_be_copied('findex'))
to_be_copied.update(files_to_be_copied('ecies'))

missing_files = False
for key, value in to_be_copied.items():
Expand All @@ -41,17 +43,19 @@ def download_wasm(version: str) -> bool:

url = f'https://package.cosmian.com/cloudproof_rust/{version}/wasm.zip'
try:
r = urllib.request.urlopen(url)
if r.getcode() != 200:
print(f'Cannot get cloudproof_rust {version} ({r.getcode()})')
response = urllib.request.urlopen(url)
if response.getcode() != 200:
print(
f'Cannot get cloudproof_rust {version} ({response.getcode()})'
)
else:
print(f'Copying new files from cloudproof_rust {version}')
if path.exists('tmp'):
shutil.rmtree('tmp')
if path.exists('wasm.zip'):
remove('wasm.zip')

open('wasm.zip', 'wb').write(r.read())
open('wasm.zip', 'wb').write(response.read())
with zipfile.ZipFile('wasm.zip', 'r') as zip_ref:
zip_ref.extractall('tmp')
for key, value in to_be_copied.items():
Expand All @@ -68,7 +72,8 @@ def download_wasm(version: str) -> bool:
print(f'Cannot get cloudproof_rust {version} ({exception})')
return False


if __name__ == '__main__':
RET = download_wasm('v2.0.1')
RET = download_wasm('v2.1.0')
if RET is False and getenv('GITHUB_ACTIONS'):
download_wasm('last_build/release/v2.0.1')
download_wasm('last_build/update_cover_crypt_12')
41 changes: 41 additions & 0 deletions src/aesgcm/aes256gcm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { toBytes } from "utils/utils"
import {
webassembly_aes256gcm_encrypt,
webassembly_aes256gcm_decrypt,
} from "../pkg/aesgcm/cloudproof_aesgcm"

/**
* Represents a class that applies AES256GCM to data.
*
*/
export class Aes256Gcm {
SYMMETRIC_KEY_LENGTH: number = 32

public static encrypt(
plaintext: string | Uint8Array,
key: string | Uint8Array,
nonce: string | Uint8Array,
authenticatedData: string | Uint8Array,
): Uint8Array {
return webassembly_aes256gcm_encrypt(
toBytes(plaintext),
toBytes(key),
toBytes(nonce),
toBytes(authenticatedData),
)
}

public static decrypt(
plaintext: string | Uint8Array,
key: string | Uint8Array,
nonce: string | Uint8Array,
authenticatedData: string | Uint8Array,
): Uint8Array {
return webassembly_aes256gcm_decrypt(
toBytes(plaintext),
toBytes(key),
toBytes(nonce),
toBytes(authenticatedData),
)
}
}
30 changes: 30 additions & 0 deletions src/aesgcm/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import init from "../pkg/aesgcm/cloudproof_aesgcm"
import { Aes256Gcm } from "./aes256gcm"

let initialized: Promise<void> | undefined

let wasmInit: (() => any) | undefined
export const setAesGcmInit = (arg: () => any): void => {
wasmInit = arg
}

/**
* This is the main function for reusing webassembly code
*/
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export async function AesGcm() {
if (initialized === undefined) {
if (wasmInit === undefined) {
throw new Error("Please provide a WASM init function")
}

const loadModule = wasmInit()
initialized = init(loadModule).then(() => undefined)
}

await initialized

return {
Aes256Gcm,
}
}
2 changes: 0 additions & 2 deletions src/anonymization/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export class Hasher {

/**
* Creates a Hasher instance with the specified hash function and salt.
*
* @param {string} hasherMethod - The name of the hash function to use.
* @param {Iterable<number>|undefined} [salt] - The optional salt to use in the hash function.
*/
Expand Down Expand Up @@ -37,7 +36,6 @@ export class Hasher {

/**
* Applies the hash function to the specified elements and returns the resulting hash value.
*
* @param {string|Iterable<number>} data - The elements to apply the hash function to.
* @returns {string} The resulting hash value as a string.
*/
Expand Down
File renamed without changes.
Loading

0 comments on commit e37da43

Please sign in to comment.