@wireapp/core-crypto 0.6.0-rc.4 → 0.6.0-rc.6

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,63 +1,65 @@
1
1
  {
2
- "name": "@wireapp/core-crypto",
3
- "version": "0.6.0-rc.4",
4
- "description": "CoreCrypto bindings for the Web",
5
- "type": "module",
6
- "module": "platforms/web/corecrypto.js",
7
- "types": "platforms/web/corecrypto.d.js",
8
- "scripts": {
9
- "prepare": "npm run build",
10
- "build": "npm run clean && rollup -c crypto-ffi/bindings/js/rollup.config.js",
11
- "build:test": "npm run clean && rollup -c crypto-ffi/bindings/js/rollup.config.test.js",
12
- "clean": "rm -f ./platforms/web/*.{js,ts,wasm,html} && rm -rf ./platforms/web/assets",
13
- "package": "npm run build && npm pack",
14
- "test:raw": "jest -c crypto-ffi/bindings/js/jest.config.js --no-cache --runInBand --verbose",
15
- "test": "npm run build:test && npm run test:raw",
16
- "test:cov": "npm run build:test && jest -c crypto-ffi/bindings/js/jest.config.js --coverage --no-cache --runInBand --verbose"
17
- },
18
- "publishConfig": {
19
- "access": "public"
20
- },
21
- "files": [
22
- "platforms/web"
23
- ],
24
- "keywords": [
25
- "wire",
26
- "e2ee",
27
- "corecrypto",
28
- "mls",
29
- "proteus"
30
- ],
31
- "author": "Mathieu Amiot <amiot.mathieu@gmail.com>",
32
- "license": "GPL-3.0",
33
- "homepage": "https://github.com/wireapp/core-crypto",
34
- "repository": {
35
- "type": "git",
36
- "url": "git@github.com:wireapp/core-crypto.git"
37
- },
38
- "bugs": {
39
- "url": "https://github.com/wireapp/core-crypto/issues"
40
- },
41
- "devDependencies": {
42
- "@rollup/plugin-html": "^0.2.4",
43
- "@types/jest": "^29.0.1",
44
- "@types/jest-dev-server": "^5.0.0",
45
- "@typescript-eslint/eslint-plugin": "^5.36.2",
46
- "@typescript-eslint/parser": "^5.36.2",
47
- "@wasm-tool/rollup-plugin-rust": "^2.3.1",
48
- "dts-bundle-generator": "^6.13.0",
49
- "eslint": "^8.23.1",
50
- "eslint-config-prettier": "^8.5.0",
51
- "eslint-plugin-prettier": "^4.2.1",
52
- "jest": "^29.0.3",
53
- "jest-dev-server": "^6.1.1",
54
- "prettier": "^2.7.1",
55
- "puppeteer": "^17.1.3",
56
- "rollup": "^2.79.0",
57
- "rollup-jest": "^3.0.0",
58
- "rollup-plugin-ts": "^3.0.2",
59
- "ts-jest": "^29.0.0",
60
- "ts-loader": "^9.3.1",
61
- "typescript": "^4.8.3"
62
- }
63
- }
2
+ "name": "@wireapp/core-crypto",
3
+ "version": "0.6.0-rc.6",
4
+ "description": "CoreCrypto bindings for the Web",
5
+ "type": "module",
6
+ "module": "platforms/web/corecrypto.js",
7
+ "types": "platforms/web/corecrypto.d.js",
8
+ "scripts": {
9
+ "prepare": "npm run build",
10
+ "build": "npm run clean && rollup -c crypto-ffi/bindings/js/rollup.config.js",
11
+ "build:test": "npm run clean && rollup -c crypto-ffi/bindings/js/rollup.config.test.js",
12
+ "clean": "rm -f ./platforms/web/*.{js,ts,wasm,html} && rm -rf ./platforms/web/assets",
13
+ "package": "npm run build && npm pack",
14
+ "test:raw": "jest -c crypto-ffi/bindings/js/jest.config.js --runInBand",
15
+ "test": "npm run build:test && npm run test:raw",
16
+ "test:cov": "npm run build:test && jest -c crypto-ffi/bindings/js/jest.config.js --coverage --runInBand",
17
+ "test:http-server": "http-server platforms/web -g -p 3000"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "files": [
23
+ "platforms/web"
24
+ ],
25
+ "keywords": [
26
+ "wire",
27
+ "e2ee",
28
+ "corecrypto",
29
+ "mls",
30
+ "proteus"
31
+ ],
32
+ "author": "Mathieu Amiot <amiot.mathieu@gmail.com>",
33
+ "license": "GPL-3.0",
34
+ "homepage": "https://github.com/wireapp/core-crypto",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git@github.com:wireapp/core-crypto.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/wireapp/core-crypto/issues"
41
+ },
42
+ "devDependencies": {
43
+ "@rollup/plugin-html": "^1.0.2",
44
+ "@types/jest": "^29.4.0",
45
+ "@types/jest-dev-server": "^5.0.0",
46
+ "@typescript-eslint/eslint-plugin": "^5.50.0",
47
+ "@typescript-eslint/parser": "^5.50.0",
48
+ "@wasm-tool/rollup-plugin-rust": "^2.3.3",
49
+ "dts-bundle-generator": "^7.2.0",
50
+ "eslint": "^8.33.0",
51
+ "eslint-config-prettier": "^8.6.0",
52
+ "eslint-plugin-prettier": "^4.2.1",
53
+ "http-server": "^14.1.1",
54
+ "jest": "^29.4.1",
55
+ "jest-dev-server": "^6.2.0",
56
+ "prettier": "^2.8.3",
57
+ "puppeteer": "^19.6.2",
58
+ "rollup": "^3.12.0",
59
+ "rollup-jest": "^3.1.0",
60
+ "rollup-plugin-ts": "^3.2.0",
61
+ "ts-jest": "^29.0.5",
62
+ "ts-loader": "^9.4.2",
63
+ "typescript": "^4.9.5"
64
+ }
65
+ }
@@ -1,4 +1,4 @@
1
- declare class WireE2eIdentity {
1
+ declare class FfiWireE2EIdentity {
2
2
  free(): void;
3
3
  /**
4
4
  * See [core_crypto::e2e_identity::WireE2eIdentity::directory_response]
@@ -119,6 +119,24 @@ declare class WireE2eIdentity {
119
119
  */
120
120
  certificate_response(certificate_chain: string): (Uint8Array)[];
121
121
  }
122
+ /**
123
+ * Error wrapper that takes care of extracting rich error details across the FFI (through JSON parsing)
124
+ *
125
+ * Whenever you're supposed to get this class (that extends `Error`) you might end up with a base `Error`
126
+ * in case the parsing of the message structure fails. This is unlikely but the case is still covered and fall backs automatically.
127
+ * More information will be found in the base `Error.cause` to inform you why the parsing has failed.
128
+ *
129
+ * Please note that in this case the extra properties will not be available.
130
+ */
131
+ export declare class CoreCryptoError extends Error {
132
+ rustStackTrace: string;
133
+ proteusErrorCode: number;
134
+ private constructor();
135
+ private static fallback;
136
+ static build(msg: string, ...params: any[]): CoreCryptoError | Error;
137
+ static fromStdError(e: Error): CoreCryptoError | Error;
138
+ static asyncMapErr<T>(p: Promise<T>): Promise<T>;
139
+ }
122
140
  /**
123
141
  * see [core_crypto::prelude::CiphersuiteName]
124
142
  */
@@ -308,10 +326,10 @@ export declare enum RatchetTreeType {
308
326
  ByRef = 3
309
327
  }
310
328
  /**
311
- * Params for CoreCrypto initialization
329
+ * Params for CoreCrypto deferred initialization
312
330
  * Please note that the `entropySeed` parameter MUST be exactly 32 bytes
313
331
  */
314
- export interface CoreCryptoParams {
332
+ export interface CoreCryptoDeferredParams {
315
333
  /**
316
334
  * Name of the IndexedDB database
317
335
  */
@@ -321,11 +339,6 @@ export interface CoreCryptoParams {
321
339
  * This should be appropriately stored in a secure location (i.e. WebCrypto private key storage)
322
340
  */
323
341
  key: string;
324
- /**
325
- * MLS Client ID.
326
- * This should stay consistent as it will be verified against the stored signature & identity to validate the persisted credential
327
- */
328
- clientId: ClientId;
329
342
  /**
330
343
  * External PRNG entropy pool seed.
331
344
  * This **must** be exactly 32 bytes
@@ -336,6 +349,17 @@ export interface CoreCryptoParams {
336
349
  */
337
350
  wasmFilePath?: string;
338
351
  }
352
+ /**
353
+ * Params for CoreCrypto initialization
354
+ * Please note that the `entropySeed` parameter MUST be exactly 32 bytes
355
+ */
356
+ export interface CoreCryptoParams extends CoreCryptoDeferredParams {
357
+ /**
358
+ * MLS Client ID.
359
+ * This should stay consistent as it will be verified against the stored signature & identity to validate the persisted credential
360
+ */
361
+ clientId: ClientId;
362
+ }
339
363
  /**
340
364
  * Data shape for adding clients to a conversation
341
365
  */
@@ -522,10 +546,11 @@ export interface CoreCryptoCallbacks {
522
546
  * Callback to ensure that the given `clientId` belongs to one of the provided `existingClients`
523
547
  * This basically allows to defer the client ID parsing logic to the caller - because CoreCrypto is oblivious to such things
524
548
  *
549
+ * @param conversationId - id of the group/conversation
525
550
  * @param clientId - id of a client
526
551
  * @param existingClients - all the clients currently within the MLS group
527
552
  */
528
- clientIsExistingGroupUser: (clientId: Uint8Array, existingClients: Uint8Array[]) => boolean;
553
+ clientIsExistingGroupUser: (conversationId: Uint8Array, clientId: Uint8Array, existingClients: Uint8Array[]) => boolean;
529
554
  }
530
555
  /**
531
556
  * Wrapper for the WASM-compiled version of CoreCrypto
@@ -571,8 +596,9 @@ export declare class CoreCrypto {
571
596
  * First, calling this will set up the keystore and will allow generating proteus prekeys.
572
597
  * Then, those keys can be traded for a clientId.
573
598
  * Use this clientId to initialize MLS with {@link CoreCrypto.mlsInit}.
599
+ * @param params - {@link CoreCryptoDeferredParams}
574
600
  */
575
- static deferredInit(databaseName: string, key: string, entropySeed?: Uint8Array, wasmFilePath?: string): Promise<CoreCrypto>;
601
+ static deferredInit({ databaseName, key, entropySeed, wasmFilePath }: CoreCryptoDeferredParams): Promise<CoreCrypto>;
576
602
  /**
577
603
  * Use this after {@link CoreCrypto.deferredInit} when you have a clientId. It initializes MLS.
578
604
  *
@@ -963,6 +989,11 @@ export declare class CoreCrypto {
963
989
  * @param storeName - The name of the IndexedDB store where the data is stored
964
990
  */
965
991
  proteusCryptoboxMigrate(storeName: string): Promise<void>;
992
+ /**
993
+ * Note: this call clears out the code and resets it to 0 (aka no error)
994
+ * @returns the last proteus error code that occured.
995
+ */
996
+ proteusLastErrorCode(): Promise<number>;
966
997
  /**
967
998
  * Creates an enrollment instance with private key material you can use in order to fetch
968
999
  * a new x509 certificate from the acme server.
@@ -985,7 +1016,7 @@ type AcmeOrder = Uint8Array;
985
1016
  export declare class WireE2eIdentity {
986
1017
  #private;
987
1018
  /** @hidden */
988
- constructor(e2ei: CoreCryptoFfiTypes.WireE2eIdentity, module: typeof CoreCryptoFfiTypes);
1019
+ constructor(e2ei: CoreCryptoFfiTypes.FfiWireE2EIdentity);
989
1020
  /**
990
1021
  * Parses the response from `GET /acme/{provisioner-name}/directory`.
991
1022
  * Use this {@link AcmeDirectory} in the next step to fetch the first nonce from the acme server. Use