@wireapp/core-crypto 0.6.0-pre.3 → 0.6.0-pre.5

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/README.md CHANGED
@@ -101,7 +101,7 @@ cargo make wasm
101
101
 
102
102
  ### Versioning
103
103
 
104
- * Run `cargo xtask bump [major|minor|patch|rc|pre]`
104
+ * Run `cargo xtask release bump [major|minor|patch|rc|pre]`
105
105
  * Update the internal dependencies of the updated crates to use the new version
106
106
  * Update the version in the `package.json`
107
107
  * Update the version in the `build.gradle.kts` inside `./kotlin/android` and `./kotlin/jvm`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wireapp/core-crypto",
3
- "version": "0.6.0-pre.3",
3
+ "version": "0.6.0-pre.5",
4
4
  "description": "CoreCrypto bindings for the Web",
5
5
  "type": "module",
6
6
  "module": "platforms/web/corecrypto.js",
@@ -423,6 +423,19 @@ export declare class CoreCrypto {
423
423
  * ````
424
424
  */
425
425
  static init({ databaseName, key, clientId, wasmFilePath, entropySeed }: CoreCryptoParams): Promise<CoreCrypto>;
426
+ /**
427
+ * Almost identical to {@link CoreCrypto.init} but allows a 2 phase initialization of MLS.
428
+ * First, calling this will set up the keystore and will allow generating proteus prekeys.
429
+ * Then, those keys can be traded for a clientId.
430
+ * Use this clientId to initialize MLS with {@link CoreCrypto.mlsInit}.
431
+ */
432
+ static deferredInit(databaseName: string, key: string, entropySeed?: Uint8Array, wasmFilePath?: string): Promise<CoreCrypto>;
433
+ /**
434
+ * Use this after {@link CoreCrypto.deferredInit} when you have a clientId. It initializes MLS.
435
+ *
436
+ * @param clientId - {@link CoreCryptoParams#clientId} but required
437
+ */
438
+ mlsInit(clientId: string): Promise<void>;
426
439
  /** @hidden */
427
440
  private constructor();
428
441
  /**
@@ -722,6 +735,12 @@ export declare class CoreCrypto {
722
735
  * @param sessionId - ID of the Proteus session
723
736
  */
724
737
  proteusSessionDelete(sessionId: string): Promise<void>;
738
+ /**
739
+ * Checks if a session exists
740
+ *
741
+ * @param sessionId - ID of the Proteus session
742
+ */
743
+ proteusSessionExists(sessionId: string): Promise<void>;
725
744
  /**
726
745
  * Decrypt an incoming message for an existing Proteus session
727
746
  *
@@ -761,6 +780,18 @@ export declare class CoreCrypto {
761
780
  * @returns Hex-encoded public key string
762
781
  */
763
782
  proteusFingerprint(): Promise<string>;
783
+ /**
784
+ * Proteus session local fingerprint
785
+ *
786
+ * @returns Hex-encoded public key string
787
+ */
788
+ proteusFingerprintLocal(sessionId: string): Promise<string>;
789
+ /**
790
+ * Proteus session remote fingerprint
791
+ *
792
+ * @returns Hex-encoded public key string
793
+ */
794
+ proteusFingerprintRemote(sessionId: string): Promise<string>;
764
795
  /**
765
796
  * Imports all the data stored by Cryptobox into the CoreCrypto keystore
766
797
  *
@@ -36,15 +36,6 @@ function getObject(idx) { return heap[idx]; }
36
36
 
37
37
  let heap_next = heap.length;
38
38
 
39
- function addHeapObject(obj) {
40
- if (heap_next === heap.length) heap.push(heap.length + 1);
41
- const idx = heap_next;
42
- heap_next = heap[idx];
43
-
44
- heap[idx] = obj;
45
- return idx;
46
- }
47
-
48
39
  function dropObject(idx) {
49
40
  if (idx < 36) return;
50
41
  heap[idx] = heap_next;
@@ -57,6 +48,15 @@ function takeObject(idx) {
57
48
  return ret;
58
49
  }
59
50
 
51
+ function addHeapObject(obj) {
52
+ if (heap_next === heap.length) heap.push(heap.length + 1);
53
+ const idx = heap_next;
54
+ heap_next = heap[idx];
55
+
56
+ heap[idx] = obj;
57
+ return idx;
58
+ }
59
+
60
60
  const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
61
61
 
62
62
  cachedTextDecoder.decode();
@@ -252,7 +252,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
252
252
  function __wbg_adapter_52(arg0, arg1, arg2) {
253
253
  try {
254
254
  const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
255
- wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h4b8933be611c74ec(retptr, arg0, arg1, addHeapObject(arg2));
255
+ wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h700a51df4dcb59a1(retptr, arg0, arg1, addHeapObject(arg2));
256
256
  var r0 = getInt32Memory0()[retptr / 4 + 0];
257
257
  var r1 = getInt32Memory0()[retptr / 4 + 1];
258
258
  if (r1) {
@@ -264,7 +264,7 @@ function __wbg_adapter_52(arg0, arg1, arg2) {
264
264
  }
265
265
 
266
266
  function __wbg_adapter_55(arg0, arg1, arg2) {
267
- wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf134d073b748780a(arg0, arg1, addHeapObject(arg2));
267
+ wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__he9e5ec6c41a75df4(arg0, arg1, addHeapObject(arg2));
268
268
  }
269
269
 
270
270
  /**
@@ -328,18 +328,10 @@ function handleError(f, args) {
328
328
  function getArrayU8FromWasm0(ptr, len) {
329
329
  return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
330
330
  }
331
- function __wbg_adapter_212(arg0, arg1, arg2, arg3) {
332
- wasm$1.wasm_bindgen__convert__closures__invoke2_mut__h36fd127c91f164e3(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
331
+ function __wbg_adapter_217(arg0, arg1, arg2, arg3) {
332
+ wasm$1.wasm_bindgen__convert__closures__invoke2_mut__h880776ea65aca59d(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
333
333
  }
334
334
 
335
- /**
336
- * see [core_crypto::prelude::mls::conversation::public_group_state::MlsRatchetTreeType]
337
- */
338
- const RatchetTreeType$1 = Object.freeze({ Full:1,"1":"Full",Delta:2,"2":"Delta",ByRef:3,"3":"ByRef", });
339
- /**
340
- * see [core_crypto::prelude::mls::conversation::public_group_state::MlsPublicGroupStateEncryptionType]
341
- */
342
- const PublicGroupStateEncryptionType$1 = Object.freeze({ Plaintext:1,"1":"Plaintext",JweEncrypted:2,"2":"JweEncrypted", });
343
335
  /**
344
336
  * see [core_crypto::prelude::CiphersuiteName]
345
337
  */
@@ -466,7 +458,7 @@ class ConversationInitBundle {
466
458
  * @returns {Uint8Array}
467
459
  */
468
460
  get conversation_id() {
469
- const ret = wasm$1.conversationinitbundle_conversation_id(this.ptr);
461
+ const ret = wasm$1.commitbundle_commit(this.ptr);
470
462
  return takeObject(ret);
471
463
  }
472
464
  /**
@@ -480,7 +472,7 @@ class ConversationInitBundle {
480
472
  * @returns {PublicGroupStateBundle}
481
473
  */
482
474
  get public_group_state() {
483
- const ret = wasm$1.conversationinitbundle_public_group_state(this.ptr);
475
+ const ret = wasm$1.commitbundle_public_group_state(this.ptr);
484
476
  return PublicGroupStateBundle.__wrap(ret);
485
477
  }
486
478
  }
@@ -527,6 +519,34 @@ class CoreCrypto$1 {
527
519
  return takeObject(ret);
528
520
  }
529
521
  /**
522
+ * see [core_crypto::MlsCentral::try_new]
523
+ * @param {string} path
524
+ * @param {string} key
525
+ * @param {Uint8Array | undefined} entropy_seed
526
+ * @returns {Promise<CoreCrypto>}
527
+ */
528
+ static deferred_init(path, key, entropy_seed) {
529
+ const ptr0 = passStringToWasm0(path, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
530
+ const len0 = WASM_VECTOR_LEN;
531
+ const ptr1 = passStringToWasm0(key, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
532
+ const len1 = WASM_VECTOR_LEN;
533
+ var ptr2 = isLikeNone(entropy_seed) ? 0 : passArray8ToWasm0(entropy_seed, wasm$1.__wbindgen_malloc);
534
+ var len2 = WASM_VECTOR_LEN;
535
+ const ret = wasm$1.corecrypto_deferred_init(ptr0, len0, ptr1, len1, ptr2, len2);
536
+ return takeObject(ret);
537
+ }
538
+ /**
539
+ * see [core_crypto::MlsCentral::mls_init]
540
+ * @param {string} client_id
541
+ * @returns {Promise<Promise<any>>}
542
+ */
543
+ mls_init(client_id) {
544
+ const ptr0 = passStringToWasm0(client_id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
545
+ const len0 = WASM_VECTOR_LEN;
546
+ const ret = wasm$1.corecrypto_mls_init(this.ptr, ptr0, len0);
547
+ return takeObject(ret);
548
+ }
549
+ /**
530
550
  * Returns: [`WasmCryptoResult<()>`]
531
551
  *
532
552
  * see [core_crypto::MlsCentral::close]
@@ -1011,6 +1031,19 @@ class CoreCrypto$1 {
1011
1031
  return takeObject(ret);
1012
1032
  }
1013
1033
  /**
1034
+ * Returns: [`WasmCryptoResult<bool>`]
1035
+ *
1036
+ * see [core_crypto::proteus::ProteusCentral::session_exists]
1037
+ * @param {string} session_id
1038
+ * @returns {Promise<any>}
1039
+ */
1040
+ proteus_session_exists(session_id) {
1041
+ const ptr0 = passStringToWasm0(session_id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1042
+ const len0 = WASM_VECTOR_LEN;
1043
+ const ret = wasm$1.corecrypto_proteus_session_exists(this.ptr, ptr0, len0);
1044
+ return takeObject(ret);
1045
+ }
1046
+ /**
1014
1047
  * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
1015
1048
  *
1016
1049
  * see [core_crypto::proteus::ProteusCentral::decrypt]
@@ -1080,6 +1113,32 @@ class CoreCrypto$1 {
1080
1113
  return takeObject(ret);
1081
1114
  }
1082
1115
  /**
1116
+ * Returns: [`WasmCryptoResult<String>`]
1117
+ *
1118
+ * see [core_crypto::proteus::ProteusCentral::fingerprint_local]
1119
+ * @param {string} session_id
1120
+ * @returns {Promise<string>}
1121
+ */
1122
+ proteus_fingerprint_local(session_id) {
1123
+ const ptr0 = passStringToWasm0(session_id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1124
+ const len0 = WASM_VECTOR_LEN;
1125
+ const ret = wasm$1.corecrypto_proteus_fingerprint_local(this.ptr, ptr0, len0);
1126
+ return takeObject(ret);
1127
+ }
1128
+ /**
1129
+ * Returns: [`WasmCryptoResult<String>`]
1130
+ *
1131
+ * see [core_crypto::proteus::ProteusCentral::fingerprint_remote]
1132
+ * @param {string} session_id
1133
+ * @returns {Promise<string>}
1134
+ */
1135
+ proteus_fingerprint_remote(session_id) {
1136
+ const ptr0 = passStringToWasm0(session_id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1137
+ const len0 = WASM_VECTOR_LEN;
1138
+ const ret = wasm$1.corecrypto_proteus_fingerprint_remote(this.ptr, ptr0, len0);
1139
+ return takeObject(ret);
1140
+ }
1141
+ /**
1083
1142
  * Returns: [`WasmCryptoResult<()>`]
1084
1143
  *
1085
1144
  * see [core_crypto::proteus::ProteusCentral::cryptobox_migrate]
@@ -1170,7 +1229,7 @@ class DecryptedMessage {
1170
1229
  wasm$1.__wbg_decryptedmessage_free(ptr);
1171
1230
  }
1172
1231
  /**
1173
- * @returns {Uint8Array | undefined}
1232
+ * @returns {any}
1174
1233
  */
1175
1234
  get message() {
1176
1235
  const ret = wasm$1.decryptedmessage_message(this.ptr);
@@ -1205,7 +1264,7 @@ class DecryptedMessage {
1205
1264
  }
1206
1265
  }
1207
1266
  /**
1208
- * @returns {Uint8Array | undefined}
1267
+ * @returns {any}
1209
1268
  */
1210
1269
  get sender_client_id() {
1211
1270
  const ret = wasm$1.decryptedmessage_sender_client_id(this.ptr);
@@ -1254,14 +1313,14 @@ class Invitee {
1254
1313
  * @returns {Uint8Array}
1255
1314
  */
1256
1315
  get id() {
1257
- const ret = wasm$1.invitee_id(this.ptr);
1316
+ const ret = wasm$1.commitbundle_commit(this.ptr);
1258
1317
  return takeObject(ret);
1259
1318
  }
1260
1319
  /**
1261
1320
  * @returns {Uint8Array}
1262
1321
  */
1263
1322
  get kp() {
1264
- const ret = wasm$1.invitee_kp(this.ptr);
1323
+ const ret = wasm$1.conversationinitbundle_commit(this.ptr);
1265
1324
  return takeObject(ret);
1266
1325
  }
1267
1326
  }
@@ -1304,21 +1363,21 @@ class MemberAddedMessages {
1304
1363
  * @returns {Uint8Array}
1305
1364
  */
1306
1365
  get welcome() {
1307
- const ret = wasm$1.memberaddedmessages_welcome(this.ptr);
1366
+ const ret = wasm$1.commitbundle_commit(this.ptr);
1308
1367
  return takeObject(ret);
1309
1368
  }
1310
1369
  /**
1311
1370
  * @returns {Uint8Array}
1312
1371
  */
1313
1372
  get commit() {
1314
- const ret = wasm$1.memberaddedmessages_commit(this.ptr);
1373
+ const ret = wasm$1.conversationinitbundle_commit(this.ptr);
1315
1374
  return takeObject(ret);
1316
1375
  }
1317
1376
  /**
1318
1377
  * @returns {PublicGroupStateBundle}
1319
1378
  */
1320
1379
  get public_group_state() {
1321
- const ret = wasm$1.memberaddedmessages_public_group_state(this.ptr);
1380
+ const ret = wasm$1.commitbundle_public_group_state(this.ptr);
1322
1381
  return PublicGroupStateBundle.__wrap(ret);
1323
1382
  }
1324
1383
  }
@@ -1348,14 +1407,14 @@ class ProposalBundle {
1348
1407
  * @returns {Uint8Array}
1349
1408
  */
1350
1409
  get proposal() {
1351
- const ret = wasm$1.proposalbundle_proposal(this.ptr);
1410
+ const ret = wasm$1.commitbundle_commit(this.ptr);
1352
1411
  return takeObject(ret);
1353
1412
  }
1354
1413
  /**
1355
1414
  * @returns {Uint8Array}
1356
1415
  */
1357
1416
  get proposal_ref() {
1358
- const ret = wasm$1.proposalbundle_proposal_ref(this.ptr);
1417
+ const ret = wasm$1.conversationinitbundle_commit(this.ptr);
1359
1418
  return takeObject(ret);
1360
1419
  }
1361
1420
  }
@@ -1386,20 +1445,20 @@ class PublicGroupStateBundle {
1386
1445
  */
1387
1446
  get encryption_type() {
1388
1447
  const ret = wasm$1.publicgroupstatebundle_encryption_type(this.ptr);
1389
- return ret >>> 0;
1448
+ return ret;
1390
1449
  }
1391
1450
  /**
1392
1451
  * @returns {number}
1393
1452
  */
1394
1453
  get ratchet_tree_type() {
1395
1454
  const ret = wasm$1.publicgroupstatebundle_ratchet_tree_type(this.ptr);
1396
- return ret >>> 0;
1455
+ return ret;
1397
1456
  }
1398
1457
  /**
1399
1458
  * @returns {Uint8Array}
1400
1459
  */
1401
1460
  get payload() {
1402
- const ret = wasm$1.publicgroupstatebundle_payload(this.ptr);
1461
+ const ret = wasm$1.commitbundle_commit(this.ptr);
1403
1462
  return takeObject(ret);
1404
1463
  }
1405
1464
  }
@@ -1438,13 +1497,13 @@ async function load(module, imports) {
1438
1497
  function getImports() {
1439
1498
  const imports = {};
1440
1499
  imports.wbg = {};
1500
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1501
+ takeObject(arg0);
1502
+ };
1441
1503
  imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
1442
1504
  const ret = getObject(arg0);
1443
1505
  return addHeapObject(ret);
1444
1506
  };
1445
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1446
- takeObject(arg0);
1447
- };
1448
1507
  imports.wbg.__wbindgen_is_object = function(arg0) {
1449
1508
  const val = getObject(arg0);
1450
1509
  const ret = typeof(val) === 'object' && val !== null;
@@ -1496,14 +1555,14 @@ function getImports() {
1496
1555
  imports.wbg.__wbg_set_20cbc34131e76824 = function(arg0, arg1, arg2) {
1497
1556
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1498
1557
  };
1499
- imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
1500
- const ret = arg0;
1501
- return addHeapObject(ret);
1502
- };
1503
1558
  imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
1504
1559
  const ret = BigInt.asUintN(64, arg0);
1505
1560
  return addHeapObject(ret);
1506
1561
  };
1562
+ imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
1563
+ const ret = arg0;
1564
+ return addHeapObject(ret);
1565
+ };
1507
1566
  imports.wbg.__wbg_objectStoreNames_8c06c40d2b05141c = function(arg0) {
1508
1567
  const ret = getObject(arg0).objectStoreNames;
1509
1568
  return addHeapObject(ret);
@@ -1581,22 +1640,22 @@ function getImports() {
1581
1640
  const ret = getObject(arg0)[arg1 >>> 0];
1582
1641
  return addHeapObject(ret);
1583
1642
  };
1584
- imports.wbg.__wbg_new_8c3f0052272a457a = function(arg0) {
1585
- const ret = new Uint8Array(getObject(arg0));
1586
- return addHeapObject(ret);
1587
- };
1588
1643
  imports.wbg.__wbg_corecrypto_new = function(arg0) {
1589
1644
  const ret = CoreCrypto$1.__wrap(arg0);
1590
1645
  return addHeapObject(ret);
1591
1646
  };
1647
+ imports.wbg.__wbg_call_168da88779e35f61 = function() { return handleError(function (arg0, arg1, arg2) {
1648
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1649
+ return addHeapObject(ret);
1650
+ }, arguments) };
1651
+ imports.wbg.__wbg_new_8c3f0052272a457a = function(arg0) {
1652
+ const ret = new Uint8Array(getObject(arg0));
1653
+ return addHeapObject(ret);
1654
+ };
1592
1655
  imports.wbg.__wbg_push_740e4b286702d964 = function(arg0, arg1) {
1593
1656
  const ret = getObject(arg0).push(getObject(arg1));
1594
1657
  return ret;
1595
1658
  };
1596
- imports.wbg.__wbg_call_e1f72c051cdab859 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1597
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3), getObject(arg4));
1598
- return addHeapObject(ret);
1599
- }, arguments) };
1600
1659
  imports.wbg.__wbg_new_9962f939219f1820 = function(arg0, arg1) {
1601
1660
  try {
1602
1661
  var state0 = {a: arg0, b: arg1};
@@ -1604,7 +1663,7 @@ function getImports() {
1604
1663
  const a = state0.a;
1605
1664
  state0.a = 0;
1606
1665
  try {
1607
- return __wbg_adapter_212(a, state0.b, arg0, arg1);
1666
+ return __wbg_adapter_217(a, state0.b, arg0, arg1);
1608
1667
  } finally {
1609
1668
  state0.a = a;
1610
1669
  }
@@ -1615,6 +1674,14 @@ function getImports() {
1615
1674
  state0.a = state0.b = 0;
1616
1675
  }
1617
1676
  };
1677
+ imports.wbg.__wbg_call_3999bee59e9f7719 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1678
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3));
1679
+ return addHeapObject(ret);
1680
+ }, arguments) };
1681
+ imports.wbg.__wbg_call_e1f72c051cdab859 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1682
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3), getObject(arg4));
1683
+ return addHeapObject(ret);
1684
+ }, arguments) };
1618
1685
  imports.wbg.__wbg_reject_72477563edad55b7 = function(arg0) {
1619
1686
  const ret = Promise.reject(getObject(arg0));
1620
1687
  return addHeapObject(ret);
@@ -1677,18 +1744,6 @@ function getImports() {
1677
1744
  imports.wbg.__wbg_setonsuccess_5f71593bc51653a3 = function(arg0, arg1) {
1678
1745
  getObject(arg0).onsuccess = getObject(arg1);
1679
1746
  };
1680
- imports.wbg.__wbg_openCursor_e036069f0e326708 = function() { return handleError(function (arg0, arg1) {
1681
- const ret = getObject(arg0).openCursor(getObject(arg1));
1682
- return addHeapObject(ret);
1683
- }, arguments) };
1684
- imports.wbg.__wbg_openCursor_f055654a98eeab7f = function() { return handleError(function (arg0) {
1685
- const ret = getObject(arg0).openCursor();
1686
- return addHeapObject(ret);
1687
- }, arguments) };
1688
- imports.wbg.__wbg_get_6285bf458a1ee758 = function() { return handleError(function (arg0, arg1) {
1689
- const ret = getObject(arg0).get(getObject(arg1));
1690
- return addHeapObject(ret);
1691
- }, arguments) };
1692
1747
  imports.wbg.__wbg_setonerror_d5771cc5bf9ea74c = function(arg0, arg1) {
1693
1748
  getObject(arg0).onerror = getObject(arg1);
1694
1749
  };
@@ -1700,6 +1755,14 @@ function getImports() {
1700
1755
  const ret = getObject(arg0).put(getObject(arg1));
1701
1756
  return addHeapObject(ret);
1702
1757
  }, arguments) };
1758
+ imports.wbg.__wbg_openCursor_e036069f0e326708 = function() { return handleError(function (arg0, arg1) {
1759
+ const ret = getObject(arg0).openCursor(getObject(arg1));
1760
+ return addHeapObject(ret);
1761
+ }, arguments) };
1762
+ imports.wbg.__wbg_openCursor_f055654a98eeab7f = function() { return handleError(function (arg0) {
1763
+ const ret = getObject(arg0).openCursor();
1764
+ return addHeapObject(ret);
1765
+ }, arguments) };
1703
1766
  imports.wbg.__wbg_count_b0e88953a0ea909c = function() { return handleError(function (arg0) {
1704
1767
  const ret = getObject(arg0).count();
1705
1768
  return addHeapObject(ret);
@@ -1708,17 +1771,18 @@ function getImports() {
1708
1771
  const ret = getObject(arg0).count(getObject(arg1));
1709
1772
  return addHeapObject(ret);
1710
1773
  }, arguments) };
1711
- imports.wbg.__wbg_deleteDatabase_f6454de6a88aebde = function() { return handleError(function (arg0, arg1, arg2) {
1712
- const ret = getObject(arg0).deleteDatabase(getStringFromWasm0(arg1, arg2));
1713
- return addHeapObject(ret);
1714
- }, arguments) };
1715
- imports.wbg.__wbg_close_5a04b9ce11dade22 = function(arg0) {
1716
- getObject(arg0).close();
1717
- };
1718
1774
  imports.wbg.__wbg_delete_8abedd1043b4105d = function() { return handleError(function (arg0, arg1) {
1719
1775
  const ret = getObject(arg0).delete(getObject(arg1));
1720
1776
  return addHeapObject(ret);
1721
1777
  }, arguments) };
1778
+ imports.wbg.__wbg_get_6285bf458a1ee758 = function() { return handleError(function (arg0, arg1) {
1779
+ const ret = getObject(arg0).get(getObject(arg1));
1780
+ return addHeapObject(ret);
1781
+ }, arguments) };
1782
+ imports.wbg.__wbg_index_86861edf1478f49c = function() { return handleError(function (arg0, arg1, arg2) {
1783
+ const ret = getObject(arg0).index(getStringFromWasm0(arg1, arg2));
1784
+ return addHeapObject(ret);
1785
+ }, arguments) };
1722
1786
  imports.wbg.__wbg_get_765201544a2b6869 = function() { return handleError(function (arg0, arg1) {
1723
1787
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
1724
1788
  return addHeapObject(ret);
@@ -1735,6 +1799,13 @@ function getImports() {
1735
1799
  const ret = getObject(arg0).openCursor(getObject(arg1));
1736
1800
  return addHeapObject(ret);
1737
1801
  }, arguments) };
1802
+ imports.wbg.__wbg_deleteDatabase_f6454de6a88aebde = function() { return handleError(function (arg0, arg1, arg2) {
1803
+ const ret = getObject(arg0).deleteDatabase(getStringFromWasm0(arg1, arg2));
1804
+ return addHeapObject(ret);
1805
+ }, arguments) };
1806
+ imports.wbg.__wbg_close_5a04b9ce11dade22 = function(arg0) {
1807
+ getObject(arg0).close();
1808
+ };
1738
1809
  imports.wbg.__wbg_open_a31c3fe1fdc244eb = function() { return handleError(function (arg0, arg1, arg2) {
1739
1810
  const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2));
1740
1811
  return addHeapObject(ret);
@@ -1784,10 +1855,6 @@ function getImports() {
1784
1855
  const ret = typeof(getObject(arg0)) === 'function';
1785
1856
  return ret;
1786
1857
  };
1787
- imports.wbg.__wbg_call_168da88779e35f61 = function() { return handleError(function (arg0, arg1, arg2) {
1788
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1789
- return addHeapObject(ret);
1790
- }, arguments) };
1791
1858
  imports.wbg.__wbg_msCrypto_6e7d3e1f92610cbb = function(arg0) {
1792
1859
  const ret = getObject(arg0).msCrypto;
1793
1860
  return addHeapObject(ret);
@@ -1836,10 +1903,6 @@ function getImports() {
1836
1903
  const ret = new Function(getStringFromWasm0(arg0, arg1));
1837
1904
  return addHeapObject(ret);
1838
1905
  };
1839
- imports.wbg.__wbg_call_3999bee59e9f7719 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1840
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3));
1841
- return addHeapObject(ret);
1842
- }, arguments) };
1843
1906
  imports.wbg.__wbg_set_bf3f89b92d5a34bf = function() { return handleError(function (arg0, arg1, arg2) {
1844
1907
  const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1845
1908
  return ret;
@@ -1867,6 +1930,10 @@ function getImports() {
1867
1930
  const ret = getObject(arg0).target;
1868
1931
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
1869
1932
  };
1933
+ imports.wbg.__wbg_result_9e399c14676970d9 = function() { return handleError(function (arg0) {
1934
+ const ret = getObject(arg0).result;
1935
+ return addHeapObject(ret);
1936
+ }, arguments) };
1870
1937
  imports.wbg.__wbg_error_aacf5ac191e54ed0 = function() { return handleError(function (arg0) {
1871
1938
  const ret = getObject(arg0).error;
1872
1939
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
@@ -1918,10 +1985,6 @@ function getImports() {
1918
1985
  const ret = result;
1919
1986
  return ret;
1920
1987
  };
1921
- imports.wbg.__wbg_index_86861edf1478f49c = function() { return handleError(function (arg0, arg1, arg2) {
1922
- const ret = getObject(arg0).index(getStringFromWasm0(arg1, arg2));
1923
- return addHeapObject(ret);
1924
- }, arguments) };
1925
1988
  imports.wbg.__wbg_toString_73c9b562dccf34bd = function(arg0) {
1926
1989
  const ret = getObject(arg0).toString();
1927
1990
  return addHeapObject(ret);
@@ -1997,20 +2060,16 @@ function getImports() {
1997
2060
  const ret = getObject(arg0).openCursor(getObject(arg1), takeObject(arg2));
1998
2061
  return addHeapObject(ret);
1999
2062
  }, arguments) };
2000
- imports.wbg.__wbg_result_9e399c14676970d9 = function() { return handleError(function (arg0) {
2001
- const ret = getObject(arg0).result;
2002
- return addHeapObject(ret);
2003
- }, arguments) };
2004
2063
  imports.wbg.__wbg_objectStore_f17976b0e6377830 = function() { return handleError(function (arg0, arg1, arg2) {
2005
2064
  const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
2006
2065
  return addHeapObject(ret);
2007
2066
  }, arguments) };
2008
- imports.wbg.__wbindgen_closure_wrapper2859 = function(arg0, arg1, arg2) {
2009
- const ret = makeMutClosure(arg0, arg1, 130, __wbg_adapter_52);
2067
+ imports.wbg.__wbindgen_closure_wrapper2358 = function(arg0, arg1, arg2) {
2068
+ const ret = makeMutClosure(arg0, arg1, 123, __wbg_adapter_52);
2010
2069
  return addHeapObject(ret);
2011
2070
  };
2012
- imports.wbg.__wbindgen_closure_wrapper4965 = function(arg0, arg1, arg2) {
2013
- const ret = makeMutClosure(arg0, arg1, 137, __wbg_adapter_55);
2071
+ imports.wbg.__wbindgen_closure_wrapper3780 = function(arg0, arg1, arg2) {
2072
+ const ret = makeMutClosure(arg0, arg1, 123, __wbg_adapter_55);
2014
2073
  return addHeapObject(ret);
2015
2074
  };
2016
2075
 
@@ -2060,8 +2119,6 @@ async function init(input) {
2060
2119
  var exports = /*#__PURE__*/Object.freeze({
2061
2120
  __proto__: null,
2062
2121
  version: version,
2063
- RatchetTreeType: RatchetTreeType$1,
2064
- PublicGroupStateEncryptionType: PublicGroupStateEncryptionType$1,
2065
2122
  Ciphersuite: Ciphersuite$1,
2066
2123
  CommitBundle: CommitBundle,
2067
2124
  ConversationConfiguration: ConversationConfiguration,
@@ -2080,7 +2137,7 @@ var exports = /*#__PURE__*/Object.freeze({
2080
2137
  var wasm = async (opt = {}) => {
2081
2138
  let {importHook, serverPath} = opt;
2082
2139
 
2083
- let path = "assets/core_crypto_ffi-922b14ab.wasm";
2140
+ let path = "assets/core_crypto_ffi-bf5877ee.wasm";
2084
2141
 
2085
2142
  if (serverPath != null) {
2086
2143
  path = serverPath + /[^\/\\]*$/.exec(path)[0];
@@ -2249,6 +2306,29 @@ class CoreCrypto {
2249
2306
  const cc = await __classPrivateFieldGet(this, _a, "f", _CoreCrypto_module).CoreCrypto._internal_new(databaseName, key, clientId, entropySeed);
2250
2307
  return new this(cc);
2251
2308
  }
2309
+ /**
2310
+ * Almost identical to {@link CoreCrypto.init} but allows a 2 phase initialization of MLS.
2311
+ * First, calling this will set up the keystore and will allow generating proteus prekeys.
2312
+ * Then, those keys can be traded for a clientId.
2313
+ * Use this clientId to initialize MLS with {@link CoreCrypto.mlsInit}.
2314
+ */
2315
+ static async deferredInit(databaseName, key, entropySeed, wasmFilePath) {
2316
+ if (!__classPrivateFieldGet(this, _a, "f", _CoreCrypto_module)) {
2317
+ const wasmImportArgs = wasmFilePath ? { importHook: () => wasmFilePath } : undefined;
2318
+ const exports = (await wasm(wasmImportArgs));
2319
+ __classPrivateFieldSet(this, _a, exports, "f", _CoreCrypto_module);
2320
+ }
2321
+ const cc = await __classPrivateFieldGet(this, _a, "f", _CoreCrypto_module).CoreCrypto.deferred_init(databaseName, key, entropySeed);
2322
+ return new this(cc);
2323
+ }
2324
+ /**
2325
+ * Use this after {@link CoreCrypto.deferredInit} when you have a clientId. It initializes MLS.
2326
+ *
2327
+ * @param clientId - {@link CoreCryptoParams#clientId} but required
2328
+ */
2329
+ async mlsInit(clientId) {
2330
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").mls_init(clientId);
2331
+ }
2252
2332
  /**
2253
2333
  * Wipes the {@link CoreCrypto} backing storage (i.e. {@link https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API | IndexedDB} database)
2254
2334
  *
@@ -2412,13 +2492,14 @@ class CoreCrypto {
2412
2492
  const ffiClients = clients.map((invitee) => new (__classPrivateFieldGet(CoreCrypto, _a, "f", _CoreCrypto_module).Invitee)(invitee.id, invitee.kp));
2413
2493
  const ffiRet = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").add_clients_to_conversation(conversationId, ffiClients);
2414
2494
  ffiClients.forEach(c => c.free());
2495
+ const pgs = ffiRet.public_group_state;
2415
2496
  const ret = {
2416
2497
  welcome: ffiRet.welcome,
2417
2498
  commit: ffiRet.commit,
2418
2499
  publicGroupState: {
2419
- encryptionType: ffiRet.public_group_state.encryption_type,
2420
- ratchetTreeType: ffiRet.public_group_state.ratchet_tree_type,
2421
- payload: ffiRet.public_group_state.payload
2500
+ encryptionType: pgs.encryption_type,
2501
+ ratchetTreeType: pgs.ratchet_tree_type,
2502
+ payload: pgs.payload
2422
2503
  },
2423
2504
  };
2424
2505
  return ret;
@@ -2438,13 +2519,14 @@ class CoreCrypto {
2438
2519
  */
2439
2520
  async removeClientsFromConversation(conversationId, clientIds) {
2440
2521
  const ffiRet = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").remove_clients_from_conversation(conversationId, clientIds);
2522
+ const pgs = ffiRet.public_group_state;
2441
2523
  const ret = {
2442
2524
  welcome: ffiRet.welcome,
2443
2525
  commit: ffiRet.commit,
2444
2526
  publicGroupState: {
2445
- encryptionType: ffiRet.public_group_state.encryption_type,
2446
- ratchetTreeType: ffiRet.public_group_state.ratchet_tree_type,
2447
- payload: ffiRet.public_group_state.payload
2527
+ encryptionType: pgs.encryption_type,
2528
+ ratchetTreeType: pgs.ratchet_tree_type,
2529
+ payload: pgs.payload
2448
2530
  },
2449
2531
  };
2450
2532
  return ret;
@@ -2462,13 +2544,14 @@ class CoreCrypto {
2462
2544
  */
2463
2545
  async updateKeyingMaterial(conversationId) {
2464
2546
  const ffiRet = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").update_keying_material(conversationId);
2547
+ const pgs = ffiRet.public_group_state;
2465
2548
  const ret = {
2466
2549
  welcome: ffiRet.welcome,
2467
2550
  commit: ffiRet.commit,
2468
2551
  publicGroupState: {
2469
- encryptionType: ffiRet.public_group_state.encryption_type,
2470
- ratchetTreeType: ffiRet.public_group_state.ratchet_tree_type,
2471
- payload: ffiRet.public_group_state.payload
2552
+ encryptionType: pgs.encryption_type,
2553
+ ratchetTreeType: pgs.ratchet_tree_type,
2554
+ payload: pgs.payload
2472
2555
  },
2473
2556
  };
2474
2557
  return ret;
@@ -2486,15 +2569,19 @@ class CoreCrypto {
2486
2569
  */
2487
2570
  async commitPendingProposals(conversationId) {
2488
2571
  const ffiCommitBundle = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").commit_pending_proposals(conversationId);
2489
- return ffiCommitBundle ? {
2572
+ if (!ffiCommitBundle) {
2573
+ return undefined;
2574
+ }
2575
+ const pgs = ffiCommitBundle.public_group_state;
2576
+ return {
2490
2577
  welcome: ffiCommitBundle.welcome,
2491
2578
  commit: ffiCommitBundle.commit,
2492
2579
  publicGroupState: {
2493
- encryptionType: ffiCommitBundle.public_group_state.encryption_type,
2494
- ratchetTreeType: ffiCommitBundle.public_group_state.ratchet_tree_type,
2495
- payload: ffiCommitBundle.public_group_state.payload
2580
+ encryptionType: pgs.encryption_type,
2581
+ ratchetTreeType: pgs.ratchet_tree_type,
2582
+ payload: pgs.payload
2496
2583
  },
2497
- } : undefined;
2584
+ };
2498
2585
  }
2499
2586
  /**
2500
2587
  * Creates a new proposal for the provided Conversation ID
@@ -2564,13 +2651,14 @@ class CoreCrypto {
2564
2651
  */
2565
2652
  async joinByExternalCommit(publicGroupState) {
2566
2653
  const ffiInitMessage = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").join_by_external_commit(publicGroupState);
2654
+ const pgs = ffiInitMessage.public_group_state;
2567
2655
  const ret = {
2568
2656
  conversationId: ffiInitMessage.conversation_id,
2569
2657
  commit: ffiInitMessage.commit,
2570
2658
  publicGroupState: {
2571
- encryptionType: ffiInitMessage.public_group_state.encryption_type,
2572
- ratchetTreeType: ffiInitMessage.public_group_state.ratchet_tree_type,
2573
- payload: ffiInitMessage.public_group_state.payload
2659
+ encryptionType: pgs.encryption_type,
2660
+ ratchetTreeType: pgs.ratchet_tree_type,
2661
+ payload: pgs.payload
2574
2662
  },
2575
2663
  };
2576
2664
  return ret;
@@ -2718,6 +2806,14 @@ class CoreCrypto {
2718
2806
  async proteusSessionDelete(sessionId) {
2719
2807
  return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").proteus_session_delete(sessionId);
2720
2808
  }
2809
+ /**
2810
+ * Checks if a session exists
2811
+ *
2812
+ * @param sessionId - ID of the Proteus session
2813
+ */
2814
+ async proteusSessionExists(sessionId) {
2815
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").proteus_session_exists(sessionId);
2816
+ }
2721
2817
  /**
2722
2818
  * Decrypt an incoming message for an existing Proteus session
2723
2819
  *
@@ -2767,6 +2863,22 @@ class CoreCrypto {
2767
2863
  async proteusFingerprint() {
2768
2864
  return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").proteus_fingerprint();
2769
2865
  }
2866
+ /**
2867
+ * Proteus session local fingerprint
2868
+ *
2869
+ * @returns Hex-encoded public key string
2870
+ */
2871
+ async proteusFingerprintLocal(sessionId) {
2872
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").proteus_fingerprint_local(sessionId);
2873
+ }
2874
+ /**
2875
+ * Proteus session remote fingerprint
2876
+ *
2877
+ * @returns Hex-encoded public key string
2878
+ */
2879
+ async proteusFingerprintRemote(sessionId) {
2880
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").proteus_fingerprint_remote(sessionId);
2881
+ }
2770
2882
  /**
2771
2883
  * Imports all the data stored by Cryptobox into the CoreCrypto keystore
2772
2884
  *