@wireapp/core-crypto 0.6.0-rc.5 → 0.6.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wireapp/core-crypto",
3
- "version": "0.6.0-rc.5",
3
+ "version": "0.6.0-rc.7",
4
4
  "description": "CoreCrypto bindings for the Web",
5
5
  "type": "module",
6
6
  "module": "platforms/web/corecrypto.js",
@@ -11,9 +11,10 @@
11
11
  "build:test": "npm run clean && rollup -c crypto-ffi/bindings/js/rollup.config.test.js",
12
12
  "clean": "rm -f ./platforms/web/*.{js,ts,wasm,html} && rm -rf ./platforms/web/assets",
13
13
  "package": "npm run build && npm pack",
14
- "test:raw": "jest -c crypto-ffi/bindings/js/jest.config.js --no-cache --runInBand --verbose",
14
+ "test:raw": "jest -c crypto-ffi/bindings/js/jest.config.js --runInBand",
15
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"
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"
17
18
  },
18
19
  "publishConfig": {
19
20
  "access": "public"
@@ -39,25 +40,26 @@
39
40
  "url": "https://github.com/wireapp/core-crypto/issues"
40
41
  },
41
42
  "devDependencies": {
42
- "@rollup/plugin-html": "^0.2.4",
43
- "@types/jest": "^29.0.1",
43
+ "@rollup/plugin-html": "^1.0.2",
44
+ "@types/jest": "^29.4.0",
44
45
  "@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",
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",
51
52
  "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"
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"
62
64
  }
63
65
  }
@@ -1,123 +1,20 @@
1
- declare class WireE2eIdentity {
2
- free(): void;
3
- /**
4
- * See [core_crypto::e2e_identity::WireE2eIdentity::directory_response]
5
- * @param {Uint8Array} directory
6
- * @returns {any}
7
- */
8
- directory_response(directory: Uint8Array): any;
9
- /**
10
- * See [core_crypto::e2e_identity::WireE2eIdentity::new_account_request]
11
- * @param {any} directory
12
- * @param {string} previous_nonce
13
- * @returns {Uint8Array}
14
- */
15
- new_account_request(directory: any, previous_nonce: string): Uint8Array;
16
- /**
17
- * See [core_crypto::e2e_identity::WireE2eIdentity::new_account_response]
18
- * @param {Uint8Array} account
19
- * @returns {Uint8Array}
20
- */
21
- new_account_response(account: Uint8Array): Uint8Array;
22
- /**
23
- * See [core_crypto::e2e_identity::WireE2eIdentity::new_order_request]
24
- * @param {string} handle
25
- * @param {string} client_id
26
- * @param {number} expiry_days
27
- * @param {any} directory
28
- * @param {Uint8Array} account
29
- * @param {string} previous_nonce
30
- * @returns {Uint8Array}
31
- */
32
- new_order_request(handle: string, client_id: string, expiry_days: number, directory: any, account: Uint8Array, previous_nonce: string): Uint8Array;
33
- /**
34
- * See [core_crypto::e2e_identity::WireE2eIdentity::new_order_response]
35
- * @param {Uint8Array} order
36
- * @returns {any}
37
- */
38
- new_order_response(order: Uint8Array): any;
39
- /**
40
- * See [core_crypto::e2e_identity::WireE2eIdentity::new_authz_request]
41
- * @param {string} url
42
- * @param {Uint8Array} account
43
- * @param {string} previous_nonce
44
- * @returns {Uint8Array}
45
- */
46
- new_authz_request(url: string, account: Uint8Array, previous_nonce: string): Uint8Array;
47
- /**
48
- * See [core_crypto::e2e_identity::WireE2eIdentity::new_authz_response]
49
- * @param {Uint8Array} authz
50
- * @returns {any}
51
- */
52
- new_authz_response(authz: Uint8Array): any;
53
- /**
54
- * See [core_crypto::e2e_identity::WireE2eIdentity::create_dpop_token]
55
- * @param {string} access_token_url
56
- * @param {string} user_id
57
- * @param {bigint} client_id
58
- * @param {string} domain
59
- * @param {any} client_id_challenge
60
- * @param {string} backend_nonce
61
- * @param {number} expiry_days
62
- * @returns {string}
63
- */
64
- create_dpop_token(access_token_url: string, user_id: string, client_id: bigint, domain: string, client_id_challenge: any, backend_nonce: string, expiry_days: number): string;
65
- /**
66
- * See [core_crypto::e2e_identity::WireE2eIdentity::new_challenge_request]
67
- * @param {any} handle_challenge
68
- * @param {Uint8Array} account
69
- * @param {string} previous_nonce
70
- * @returns {Uint8Array}
71
- */
72
- new_challenge_request(handle_challenge: any, account: Uint8Array, previous_nonce: string): Uint8Array;
73
- /**
74
- * See [core_crypto::e2e_identity::WireE2eIdentity::new_challenge_response]
75
- * @param {Uint8Array} challenge
76
- */
77
- new_challenge_response(challenge: Uint8Array): void;
78
- /**
79
- * See [core_crypto::e2e_identity::WireE2eIdentity::check_order_request]
80
- * @param {string} order_url
81
- * @param {Uint8Array} account
82
- * @param {string} previous_nonce
83
- * @returns {Uint8Array}
84
- */
85
- check_order_request(order_url: string, account: Uint8Array, previous_nonce: string): Uint8Array;
86
- /**
87
- * See [core_crypto::e2e_identity::WireE2eIdentity::check_order_response]
88
- * @param {Uint8Array} order
89
- * @returns {Uint8Array}
90
- */
91
- check_order_response(order: Uint8Array): Uint8Array;
92
- /**
93
- * See [core_crypto::e2e_identity::WireE2eIdentity::finalize_request]
94
- * @param {(Uint8Array)[]} domains
95
- * @param {Uint8Array} order
96
- * @param {Uint8Array} account
97
- * @param {string} previous_nonce
98
- * @returns {Uint8Array}
99
- */
100
- finalize_request(domains: (Uint8Array)[], order: Uint8Array, account: Uint8Array, previous_nonce: string): Uint8Array;
101
- /**
102
- * See [core_crypto::e2e_identity::WireE2eIdentity::finalize_response]
103
- * @param {Uint8Array} finalize
104
- * @returns {any}
105
- */
106
- finalize_response(finalize: Uint8Array): any;
107
- /**
108
- * See [core_crypto::e2e_identity::WireE2eIdentity::certificate_request]
109
- * @param {any} finalize
110
- * @param {Uint8Array} account
111
- * @param {string} previous_nonce
112
- * @returns {Uint8Array}
113
- */
114
- certificate_request(finalize: any, account: Uint8Array, previous_nonce: string): Uint8Array;
115
- /**
116
- * See [core_crypto::e2e_identity::WireE2eIdentity::certificate_response]
117
- * @param {string} certificate_chain
118
- * @returns {(Uint8Array)[]}
119
- */
120
- certificate_response(certificate_chain: string): (Uint8Array)[];
1
+ /**
2
+ * Error wrapper that takes care of extracting rich error details across the FFI (through JSON parsing)
3
+ *
4
+ * Whenever you're supposed to get this class (that extends `Error`) you might end up with a base `Error`
5
+ * in case the parsing of the message structure fails. This is unlikely but the case is still covered and fall backs automatically.
6
+ * More information will be found in the base `Error.cause` to inform you why the parsing has failed.
7
+ *
8
+ * Please note that in this case the extra properties will not be available.
9
+ */
10
+ export declare class CoreCryptoError extends Error {
11
+ rustStackTrace: string;
12
+ proteusErrorCode: number;
13
+ private constructor();
14
+ private static fallback;
15
+ static build(msg: string, ...params: any[]): CoreCryptoError | Error;
16
+ static fromStdError(e: Error): CoreCryptoError | Error;
17
+ static asyncMapErr<T>(p: Promise<T>): Promise<T>;
121
18
  }
122
19
  /**
123
20
  * see [core_crypto::prelude::CiphersuiteName]
@@ -308,10 +205,10 @@ export declare enum RatchetTreeType {
308
205
  ByRef = 3
309
206
  }
310
207
  /**
311
- * Params for CoreCrypto initialization
208
+ * Params for CoreCrypto deferred initialization
312
209
  * Please note that the `entropySeed` parameter MUST be exactly 32 bytes
313
210
  */
314
- export interface CoreCryptoParams {
211
+ export interface CoreCryptoDeferredParams {
315
212
  /**
316
213
  * Name of the IndexedDB database
317
214
  */
@@ -321,11 +218,6 @@ export interface CoreCryptoParams {
321
218
  * This should be appropriately stored in a secure location (i.e. WebCrypto private key storage)
322
219
  */
323
220
  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
221
  /**
330
222
  * External PRNG entropy pool seed.
331
223
  * This **must** be exactly 32 bytes
@@ -336,6 +228,17 @@ export interface CoreCryptoParams {
336
228
  */
337
229
  wasmFilePath?: string;
338
230
  }
231
+ /**
232
+ * Params for CoreCrypto initialization
233
+ * Please note that the `entropySeed` parameter MUST be exactly 32 bytes
234
+ */
235
+ export interface CoreCryptoParams extends CoreCryptoDeferredParams {
236
+ /**
237
+ * MLS Client ID.
238
+ * This should stay consistent as it will be verified against the stored signature & identity to validate the persisted credential
239
+ */
240
+ clientId: ClientId;
241
+ }
339
242
  /**
340
243
  * Data shape for adding clients to a conversation
341
244
  */
@@ -572,8 +475,9 @@ export declare class CoreCrypto {
572
475
  * First, calling this will set up the keystore and will allow generating proteus prekeys.
573
476
  * Then, those keys can be traded for a clientId.
574
477
  * Use this clientId to initialize MLS with {@link CoreCrypto.mlsInit}.
478
+ * @param params - {@link CoreCryptoDeferredParams}
575
479
  */
576
- static deferredInit(databaseName: string, key: string, entropySeed?: Uint8Array, wasmFilePath?: string): Promise<CoreCrypto>;
480
+ static deferredInit({ databaseName, key, entropySeed, wasmFilePath }: CoreCryptoDeferredParams): Promise<CoreCrypto>;
577
481
  /**
578
482
  * Use this after {@link CoreCrypto.deferredInit} when you have a clientId. It initializes MLS.
579
483
  *
@@ -964,6 +868,11 @@ export declare class CoreCrypto {
964
868
  * @param storeName - The name of the IndexedDB store where the data is stored
965
869
  */
966
870
  proteusCryptoboxMigrate(storeName: string): Promise<void>;
871
+ /**
872
+ * Note: this call clears out the code and resets it to 0 (aka no error)
873
+ * @returns the last proteus error code that occured.
874
+ */
875
+ proteusLastErrorCode(): Promise<number>;
967
876
  /**
968
877
  * Creates an enrollment instance with private key material you can use in order to fetch
969
878
  * a new x509 certificate from the acme server.
@@ -986,7 +895,7 @@ type AcmeOrder = Uint8Array;
986
895
  export declare class WireE2eIdentity {
987
896
  #private;
988
897
  /** @hidden */
989
- constructor(e2ei: CoreCryptoFfiTypes.WireE2eIdentity, module: typeof CoreCryptoFfiTypes);
898
+ constructor(e2ei: unknown);
990
899
  /**
991
900
  * Parses the response from `GET /acme/{provisioner-name}/directory`.
992
901
  * Use this {@link AcmeDirectory} in the next step to fetch the first nonce from the acme server. Use
@@ -1103,13 +1012,13 @@ export declare class WireE2eIdentity {
1103
1012
  /**
1104
1013
  * Final step before fetching the certificate.
1105
1014
  *
1106
- * @param domains you want to generate a certificate for e.g. `["wire.com"]`
1107
- * @param order you got from {@link checkOrderResponse}
1108
- * @param account you found after {@link newAccountResponse}
1109
- * @param previousNonce `replay-nonce` response header from `POST /acme/{provisioner-name}/order/{order-id}`
1015
+ * @param domains - domains you want to generate a certificate for e.g. `["wire.com"]`
1016
+ * @param order - order you got from {@link checkOrderResponse}
1017
+ * @param account - account you found after {@link newAccountResponse}
1018
+ * @param previousNonce - `replay-nonce` response header from `POST /acme/{provisioner-name}/order/{order-id}`
1110
1019
  * @see https://www.rfc-editor.org/rfc/rfc8555.html#section-7.4
1111
1020
  */
1112
- finalizeRequest(domains: Uint8Array[], order: AcmeOrder, account: AcmeAccount, previousNonce: string): JsonRawData;
1021
+ finalizeRequest(domains: string[], order: AcmeOrder, account: AcmeAccount, previousNonce: string): JsonRawData;
1113
1022
  /**
1114
1023
  * Parses the response from `POST /acme/{provisioner-name}/order/{order-id}/finalize`.
1115
1024
  *