@wireapp/core-crypto 1.0.0-rc.56-hotfix.1 → 1.0.0-rc.58

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wireapp/core-crypto",
3
- "version": "1.0.0-rc.56-hotfix.1",
3
+ "version": "1.0.0-rc.58",
4
4
  "description": "CoreCrypto bindings for the Web",
5
5
  "type": "module",
6
6
  "module": "platforms/web/corecrypto.js",
@@ -43,4 +43,4 @@
43
43
  "ts-loader": "^9.5.1",
44
44
  "typescript": "^5.3.3"
45
45
  }
46
- }
46
+ }
@@ -351,10 +351,6 @@ export interface CoreCryptoDeferredParams {
351
351
  * This should be appropriately stored in a secure location (i.e. WebCrypto private key storage)
352
352
  */
353
353
  key: string;
354
- /**
355
- * All the ciphersuites this MLS client can support
356
- */
357
- ciphersuites: Ciphersuite[];
358
354
  /**
359
355
  * External PRNG entropy pool seed.
360
356
  * This **must** be exactly 32 bytes
@@ -364,10 +360,6 @@ export interface CoreCryptoDeferredParams {
364
360
  * .wasm file path, this will be useful in case your bundling system likes to relocate files (i.e. what webpack does)
365
361
  */
366
362
  wasmFilePath?: string;
367
- /**
368
- * Number of initial KeyPackage to create when initializing the client
369
- */
370
- nbKeyPackage?: number;
371
363
  }
372
364
  /**
373
365
  * Params for CoreCrypto initialization
@@ -379,6 +371,14 @@ export interface CoreCryptoParams extends CoreCryptoDeferredParams {
379
371
  * This should stay consistent as it will be verified against the stored signature & identity to validate the persisted credential
380
372
  */
381
373
  clientId: ClientId;
374
+ /**
375
+ * All the ciphersuites this MLS client can support
376
+ */
377
+ ciphersuites: Ciphersuite[];
378
+ /**
379
+ * Number of initial KeyPackage to create when initializing the client
380
+ */
381
+ nbKeyPackage?: number;
382
382
  }
383
383
  export interface ConversationInitBundle {
384
384
  /**
@@ -799,7 +799,7 @@ export declare class CoreCrypto {
799
799
  * Use this clientId to initialize MLS with {@link CoreCrypto.mlsInit}.
800
800
  * @param params - {@link CoreCryptoDeferredParams}
801
801
  */
802
- static deferredInit({ databaseName, key, ciphersuites, entropySeed, wasmFilePath, nbKeyPackage, }: CoreCryptoDeferredParams): Promise<CoreCrypto>;
802
+ static deferredInit({ databaseName, key, entropySeed, wasmFilePath, }: CoreCryptoDeferredParams): Promise<CoreCrypto>;
803
803
  /**
804
804
  * Use this after {@link CoreCrypto.deferredInit} when you have a clientId. It initializes MLS.
805
805
  *
@@ -1,12 +1,4 @@
1
1
  // bindings/js/wasm/core-crypto-ffi.js
2
- var addHeapObject = function(obj) {
3
- if (heap_next === heap.length)
4
- heap.push(heap.length + 1);
5
- const idx = heap_next;
6
- heap_next = heap[idx];
7
- heap[idx] = obj;
8
- return idx;
9
- };
10
2
  var getObject = function(idx) {
11
3
  return heap[idx];
12
4
  };
@@ -21,6 +13,14 @@ var takeObject = function(idx) {
21
13
  dropObject(idx);
22
14
  return ret;
23
15
  };
16
+ var addHeapObject = function(obj) {
17
+ if (heap_next === heap.length)
18
+ heap.push(heap.length + 1);
19
+ const idx = heap_next;
20
+ heap_next = heap[idx];
21
+ heap[idx] = obj;
22
+ return idx;
23
+ };
24
24
  var getUint8Memory0 = function() {
25
25
  if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
26
26
  cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
@@ -265,18 +265,21 @@ async function __wbg_load(module, imports) {
265
265
  var __wbg_get_imports = function() {
266
266
  const imports = {};
267
267
  imports.wbg = {};
268
- imports.wbg.__wbg_commitbundle_new = function(arg0) {
269
- const ret = CommitBundle.__wrap(arg0);
270
- return addHeapObject(ret);
268
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
269
+ takeObject(arg0);
271
270
  };
272
- imports.wbg.__wbg_proteusautoprekeybundle_new = function(arg0) {
273
- const ret = ProteusAutoPrekeyBundle.__wrap(arg0);
271
+ imports.wbg.__wbg_corecrypto_new = function(arg0) {
272
+ const ret = CoreCrypto.__wrap(arg0);
274
273
  return addHeapObject(ret);
275
274
  };
276
275
  imports.wbg.__wbg_buffereddecryptedmessage_new = function(arg0) {
277
276
  const ret = BufferedDecryptedMessage.__wrap(arg0);
278
277
  return addHeapObject(ret);
279
278
  };
279
+ imports.wbg.__wbindgen_number_new = function(arg0) {
280
+ const ret = arg0;
281
+ return addHeapObject(ret);
282
+ };
280
283
  imports.wbg.__wbg_proposalbundle_new = function(arg0) {
281
284
  const ret = ProposalBundle.__wrap(arg0);
282
285
  return addHeapObject(ret);
@@ -285,27 +288,24 @@ var __wbg_get_imports = function() {
285
288
  const ret = NewAcmeAuthz.__wrap(arg0);
286
289
  return addHeapObject(ret);
287
290
  };
288
- imports.wbg.__wbindgen_number_new = function(arg0) {
289
- const ret = arg0;
290
- return addHeapObject(ret);
291
- };
292
- imports.wbg.__wbg_newacmeorder_new = function(arg0) {
293
- const ret = NewAcmeOrder.__wrap(arg0);
291
+ imports.wbg.__wbg_ffiwiree2eidentity_new = function(arg0) {
292
+ const ret = FfiWireE2EIdentity.__wrap(arg0);
294
293
  return addHeapObject(ret);
295
294
  };
296
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
297
- takeObject(arg0);
298
- };
299
- imports.wbg.__wbg_corecrypto_new = function(arg0) {
300
- const ret = CoreCrypto.__wrap(arg0);
295
+ imports.wbg.__wbg_commitbundle_new = function(arg0) {
296
+ const ret = CommitBundle.__wrap(arg0);
301
297
  return addHeapObject(ret);
302
298
  };
303
299
  imports.wbg.__wbg_acmedirectory_new = function(arg0) {
304
300
  const ret = AcmeDirectory.__wrap(arg0);
305
301
  return addHeapObject(ret);
306
302
  };
307
- imports.wbg.__wbg_ffiwiree2eidentity_new = function(arg0) {
308
- const ret = FfiWireE2EIdentity.__wrap(arg0);
303
+ imports.wbg.__wbg_proteusautoprekeybundle_new = function(arg0) {
304
+ const ret = ProteusAutoPrekeyBundle.__wrap(arg0);
305
+ return addHeapObject(ret);
306
+ };
307
+ imports.wbg.__wbg_newacmeorder_new = function(arg0) {
308
+ const ret = NewAcmeOrder.__wrap(arg0);
309
309
  return addHeapObject(ret);
310
310
  };
311
311
  imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
@@ -316,6 +316,10 @@ var __wbg_get_imports = function() {
316
316
  const ret = getStringFromWasm0(arg0, arg1);
317
317
  return addHeapObject(ret);
318
318
  };
319
+ imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
320
+ const ret = BigInt.asUintN(64, arg0);
321
+ return addHeapObject(ret);
322
+ };
319
323
  imports.wbg.__wbindgen_is_undefined = function(arg0) {
320
324
  const ret = getObject(arg0) === undefined;
321
325
  return ret;
@@ -324,10 +328,6 @@ var __wbg_get_imports = function() {
324
328
  const ret = getObject(arg0) === null;
325
329
  return ret;
326
330
  };
327
- imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
328
- const ret = BigInt.asUintN(64, arg0);
329
- return addHeapObject(ret);
330
- };
331
331
  imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
332
332
  const obj = getObject(arg1);
333
333
  const ret = typeof obj === "string" ? obj : undefined;
@@ -979,12 +979,12 @@ var __wbg_get_imports = function() {
979
979
  const ret = wasm.memory;
980
980
  return addHeapObject(ret);
981
981
  };
982
- imports.wbg.__wbindgen_closure_wrapper2676 = function(arg0, arg1, arg2) {
982
+ imports.wbg.__wbindgen_closure_wrapper2675 = function(arg0, arg1, arg2) {
983
983
  const ret = makeMutClosure(arg0, arg1, 667, __wbg_adapter_54);
984
984
  return addHeapObject(ret);
985
985
  };
986
- imports.wbg.__wbindgen_closure_wrapper13241 = function(arg0, arg1, arg2) {
987
- const ret = makeMutClosure(arg0, arg1, 2143, __wbg_adapter_57);
986
+ imports.wbg.__wbindgen_closure_wrapper13251 = function(arg0, arg1, arg2) {
987
+ const ret = makeMutClosure(arg0, arg1, 2142, __wbg_adapter_57);
988
988
  return addHeapObject(ret);
989
989
  };
990
990
  return imports;
@@ -1051,20 +1051,6 @@ var CLOSURE_DTORS = typeof FinalizationRegistry === "undefined" ? { register: ()
1051
1051
  });
1052
1052
  var cachedUint32Memory0 = null;
1053
1053
  var cachedUint16Memory0 = null;
1054
- var DeviceStatus = Object.freeze({
1055
- Valid: 1,
1056
- "1": "Valid",
1057
- Expired: 2,
1058
- "2": "Expired",
1059
- Revoked: 3,
1060
- "3": "Revoked"
1061
- });
1062
- var WirePolicy = Object.freeze({
1063
- Plaintext: 1,
1064
- "1": "Plaintext",
1065
- Ciphertext: 2,
1066
- "2": "Ciphertext"
1067
- });
1068
1054
  var Ciphersuite = Object.freeze({
1069
1055
  MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519: 1,
1070
1056
  "1": "MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519",
@@ -1083,6 +1069,20 @@ var Ciphersuite = Object.freeze({
1083
1069
  MLS_128_X25519KYBER768DRAFT00_AES128GCM_SHA256_Ed25519: 61489,
1084
1070
  "61489": "MLS_128_X25519KYBER768DRAFT00_AES128GCM_SHA256_Ed25519"
1085
1071
  });
1072
+ var WirePolicy = Object.freeze({
1073
+ Plaintext: 1,
1074
+ "1": "Plaintext",
1075
+ Ciphertext: 2,
1076
+ "2": "Ciphertext"
1077
+ });
1078
+ var DeviceStatus = Object.freeze({
1079
+ Valid: 1,
1080
+ "1": "Valid",
1081
+ Expired: 2,
1082
+ "2": "Expired",
1083
+ Revoked: 3,
1084
+ "3": "Revoked"
1085
+ });
1086
1086
  var CredentialType = Object.freeze({
1087
1087
  Basic: 1,
1088
1088
  "1": "Basic",
@@ -1550,16 +1550,14 @@ class CoreCrypto {
1550
1550
  const ret = wasm.corecrypto__internal_new(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, !isLikeNone(nb_key_package), isLikeNone(nb_key_package) ? 0 : nb_key_package);
1551
1551
  return takeObject(ret);
1552
1552
  }
1553
- static deferred_init(path, key, ciphersuites, entropy_seed, nb_key_package) {
1553
+ static deferred_init(path, key, entropy_seed) {
1554
1554
  const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1555
1555
  const len0 = WASM_VECTOR_LEN;
1556
1556
  const ptr1 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1557
1557
  const len1 = WASM_VECTOR_LEN;
1558
- const ptr2 = passArray16ToWasm0(ciphersuites, wasm.__wbindgen_malloc);
1559
- const len2 = WASM_VECTOR_LEN;
1560
- var ptr3 = isLikeNone(entropy_seed) ? 0 : passArray8ToWasm0(entropy_seed, wasm.__wbindgen_malloc);
1561
- var len3 = WASM_VECTOR_LEN;
1562
- const ret = wasm.corecrypto_deferred_init(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, !isLikeNone(nb_key_package), isLikeNone(nb_key_package) ? 0 : nb_key_package);
1558
+ var ptr2 = isLikeNone(entropy_seed) ? 0 : passArray8ToWasm0(entropy_seed, wasm.__wbindgen_malloc);
1559
+ var len2 = WASM_VECTOR_LEN;
1560
+ const ret = wasm.corecrypto_deferred_init(ptr0, len0, ptr1, len1, ptr2, len2);
1563
1561
  return takeObject(ret);
1564
1562
  }
1565
1563
  mls_init(client_id, ciphersuites, nb_key_package) {
@@ -2590,6 +2588,11 @@ class X509Identity {
2590
2588
  var core_crypto_ffi_default = __wbg_init;
2591
2589
 
2592
2590
  // bindings/js/CoreCrypto.ts
2591
+ var normalizeEnum = function(enumType, value) {
2592
+ const enumAsString = enumType[value];
2593
+ const enumAsDiscriminant = enumType[enumAsString];
2594
+ return enumAsDiscriminant;
2595
+ };
2593
2596
  class CoreCryptoError extends Error {
2594
2597
  rustStackTrace;
2595
2598
  proteusErrorCode;
@@ -2674,9 +2677,9 @@ var mapWireIdentity = (ffiIdentity) => {
2674
2677
  }
2675
2678
  return {
2676
2679
  clientId: ffiIdentity.client_id,
2677
- status: DeviceStatus2[ffiIdentity.status],
2680
+ status: normalizeEnum(DeviceStatus2, ffiIdentity.status),
2678
2681
  thumbprint: ffiIdentity.thumbprint,
2679
- credentialType: CredentialType2[ffiIdentity.credential_type],
2682
+ credentialType: normalizeEnum(CredentialType2, ffiIdentity.credential_type),
2680
2683
  x509Identity: mapX509Identity(ffiIdentity.x509_identity)
2681
2684
  };
2682
2685
  };
@@ -2744,14 +2747,11 @@ class CoreCrypto2 {
2744
2747
  static async deferredInit({
2745
2748
  databaseName,
2746
2749
  key,
2747
- ciphersuites,
2748
2750
  entropySeed,
2749
- wasmFilePath,
2750
- nbKeyPackage
2751
+ wasmFilePath
2751
2752
  }) {
2752
2753
  await this.#loadModule(wasmFilePath);
2753
- let cs = ciphersuites.map((cs2) => cs2.valueOf());
2754
- const cc = await CoreCryptoError.asyncMapErr(CoreCrypto.deferred_init(databaseName, key, Uint16Array.of(...cs), entropySeed, nbKeyPackage));
2754
+ const cc = await CoreCryptoError.asyncMapErr(CoreCrypto.deferred_init(databaseName, key, entropySeed));
2755
2755
  return new this(cc);
2756
2756
  }
2757
2757
  async mlsInit(clientId, ciphersuites, nbKeyPackage) {
@@ -3149,7 +3149,7 @@ class CoreCrypto2 {
3149
3149
  }
3150
3150
  async e2eiConversationState(conversationId) {
3151
3151
  let state = await CoreCryptoError.asyncMapErr(this.#cc.e2ei_conversation_state(conversationId));
3152
- return E2eiConversationState[state];
3152
+ return normalizeEnum(E2eiConversationState, state);
3153
3153
  }
3154
3154
  async e2eiIsEnabled(ciphersuite) {
3155
3155
  return await CoreCryptoError.asyncMapErr(this.#cc.e2ei_is_enabled(ciphersuite));
@@ -3171,7 +3171,7 @@ class CoreCrypto2 {
3171
3171
  }
3172
3172
  async getCredentialInUse(groupInfo, credentialType = CredentialType2.X509) {
3173
3173
  let state = await CoreCryptoError.asyncMapErr(this.#cc.get_credential_in_use(groupInfo, credentialType));
3174
- return E2eiConversationState[state];
3174
+ return normalizeEnum(E2eiConversationState, state);
3175
3175
  }
3176
3176
  static version() {
3177
3177
  this.#assertModuleLoaded();