@wireapp/core-crypto 0.5.0 → 0.5.1

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": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "CoreCrypto bindings for the Web",
5
5
  "type": "module",
6
6
  "module": "platforms/web/corecrypto.js",
@@ -189,7 +189,10 @@ export interface DecryptedMessage {
189
189
  */
190
190
  message?: Uint8Array;
191
191
  /**
192
- * List of proposals that were retrieved from the decrypted message, in addition to the pending local proposals
192
+ * Only when decrypted message is a commit, CoreCrypto will renew local proposal which could not make it in the commit.
193
+ * This will contain either:
194
+ * * local pending proposal not in the accepted commit
195
+ * * If there is a pending commit, its proposals which are not in the accepted commit
193
196
  */
194
197
  proposals: ProposalBundle[];
195
198
  /**
@@ -74,6 +74,28 @@ function getStringFromWasm0(ptr, len) {
74
74
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
75
75
  }
76
76
 
77
+ function isLikeNone(x) {
78
+ return x === undefined || x === null;
79
+ }
80
+
81
+ let cachedFloat64Memory0 = new Float64Array();
82
+
83
+ function getFloat64Memory0() {
84
+ if (cachedFloat64Memory0.byteLength === 0) {
85
+ cachedFloat64Memory0 = new Float64Array(wasm$1.memory.buffer);
86
+ }
87
+ return cachedFloat64Memory0;
88
+ }
89
+
90
+ let cachedInt32Memory0 = new Int32Array();
91
+
92
+ function getInt32Memory0() {
93
+ if (cachedInt32Memory0.byteLength === 0) {
94
+ cachedInt32Memory0 = new Int32Array(wasm$1.memory.buffer);
95
+ }
96
+ return cachedInt32Memory0;
97
+ }
98
+
77
99
  let WASM_VECTOR_LEN = 0;
78
100
 
79
101
  const cachedTextEncoder = new TextEncoder('utf-8');
@@ -129,28 +151,6 @@ function passStringToWasm0(arg, malloc, realloc) {
129
151
  return ptr;
130
152
  }
131
153
 
132
- function isLikeNone(x) {
133
- return x === undefined || x === null;
134
- }
135
-
136
- let cachedInt32Memory0 = new Int32Array();
137
-
138
- function getInt32Memory0() {
139
- if (cachedInt32Memory0.byteLength === 0) {
140
- cachedInt32Memory0 = new Int32Array(wasm$1.memory.buffer);
141
- }
142
- return cachedInt32Memory0;
143
- }
144
-
145
- let cachedFloat64Memory0 = new Float64Array();
146
-
147
- function getFloat64Memory0() {
148
- if (cachedFloat64Memory0.byteLength === 0) {
149
- cachedFloat64Memory0 = new Float64Array(wasm$1.memory.buffer);
150
- }
151
- return cachedFloat64Memory0;
152
- }
153
-
154
154
  function debugString(val) {
155
155
  // primitive types
156
156
  const type = typeof val;
@@ -243,7 +243,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
243
243
  function __wbg_adapter_40(arg0, arg1, arg2) {
244
244
  try {
245
245
  const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
246
- wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h9a15da7f71febc51(retptr, arg0, arg1, addHeapObject(arg2));
246
+ wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h4ef8a84fbdc05598(retptr, arg0, arg1, addHeapObject(arg2));
247
247
  var r0 = getInt32Memory0()[retptr / 4 + 0];
248
248
  var r1 = getInt32Memory0()[retptr / 4 + 1];
249
249
  if (r1) {
@@ -255,7 +255,7 @@ function __wbg_adapter_40(arg0, arg1, arg2) {
255
255
  }
256
256
 
257
257
  function __wbg_adapter_43(arg0, arg1, arg2) {
258
- wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hef97d77a2199c9e8(arg0, arg1, addHeapObject(arg2));
258
+ wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hb3da4d47c0d5214a(arg0, arg1, addHeapObject(arg2));
259
259
  }
260
260
 
261
261
  /**
@@ -318,8 +318,8 @@ function handleError(f, args) {
318
318
  function getArrayU8FromWasm0(ptr, len) {
319
319
  return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
320
320
  }
321
- function __wbg_adapter_176(arg0, arg1, arg2, arg3) {
322
- wasm$1.wasm_bindgen__convert__closures__invoke2_mut__hc9af8652362195d0(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
321
+ function __wbg_adapter_175(arg0, arg1, arg2, arg3) {
322
+ wasm$1.wasm_bindgen__convert__closures__invoke2_mut__hdd7aeb05a0912a93(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
323
323
  }
324
324
 
325
325
  /**
@@ -968,13 +968,6 @@ class CoreCryptoWasmCallbacks {
968
968
  */
969
969
  class DecryptedMessage {
970
970
 
971
- static __wrap(ptr) {
972
- const obj = Object.create(DecryptedMessage.prototype);
973
- obj.ptr = ptr;
974
-
975
- return obj;
976
- }
977
-
978
971
  __destroy_into_raw() {
979
972
  const ptr = this.ptr;
980
973
  this.ptr = 0;
@@ -1021,6 +1014,13 @@ class DecryptedMessage {
1021
1014
  wasm$1.__wbindgen_add_to_stack_pointer(16);
1022
1015
  }
1023
1016
  }
1017
+ /**
1018
+ * @returns {Uint8Array | undefined}
1019
+ */
1020
+ get sender_client_id() {
1021
+ const ret = wasm$1.decryptedmessage_sender_client_id(this.ptr);
1022
+ return takeObject(ret);
1023
+ }
1024
1024
  }
1025
1025
  /**
1026
1026
  * see [core_crypto::prelude::ConversationMember]
@@ -1236,10 +1236,6 @@ function getImports() {
1236
1236
  const ret = typeof(val) === 'object' && val !== null;
1237
1237
  return ret;
1238
1238
  };
1239
- imports.wbg.__wbg_new_0b9bfdd97583284e = function() {
1240
- const ret = new Object();
1241
- return addHeapObject(ret);
1242
- };
1243
1239
  imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
1244
1240
  const ret = new Error(getStringFromWasm0(arg0, arg1));
1245
1241
  return addHeapObject(ret);
@@ -1252,33 +1248,39 @@ function getImports() {
1252
1248
  const ret = getObject(arg0).getTime();
1253
1249
  return ret;
1254
1250
  };
1251
+ imports.wbg.__wbg_set_c943d600fa71e4dd = function(arg0, arg1, arg2) {
1252
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1253
+ };
1255
1254
  imports.wbg.__wbg_new_8c3f0052272a457a = function(arg0) {
1256
1255
  const ret = new Uint8Array(getObject(arg0));
1257
1256
  return addHeapObject(ret);
1258
1257
  };
1259
- imports.wbg.__wbg_corecrypto_new = function(arg0) {
1260
- const ret = CoreCrypto$1.__wrap(arg0);
1258
+ imports.wbg.__wbg_new_1d9a920c6bfc44a8 = function() {
1259
+ const ret = new Array();
1261
1260
  return addHeapObject(ret);
1262
1261
  };
1263
- imports.wbg.__wbindgen_number_new = function(arg0) {
1264
- const ret = arg0;
1265
- return addHeapObject(ret);
1262
+ imports.wbg.__wbg_push_740e4b286702d964 = function(arg0, arg1) {
1263
+ const ret = getObject(arg0).push(getObject(arg1));
1264
+ return ret;
1266
1265
  };
1267
- imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
1268
- const ret = BigInt.asUintN(64, arg0);
1266
+ imports.wbg.__wbg_new_0b9bfdd97583284e = function() {
1267
+ const ret = new Object();
1269
1268
  return addHeapObject(ret);
1270
1269
  };
1271
- imports.wbg.__wbg_decryptedmessage_new = function(arg0) {
1272
- const ret = DecryptedMessage.__wrap(arg0);
1270
+ imports.wbg.__wbg_set_a68214f35c417fa9 = function(arg0, arg1, arg2) {
1271
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1272
+ };
1273
+ imports.wbg.__wbindgen_number_new = function(arg0) {
1274
+ const ret = arg0;
1273
1275
  return addHeapObject(ret);
1274
1276
  };
1275
- imports.wbg.__wbg_new_1d9a920c6bfc44a8 = function() {
1276
- const ret = new Array();
1277
+ imports.wbg.__wbg_corecrypto_new = function(arg0) {
1278
+ const ret = CoreCrypto$1.__wrap(arg0);
1277
1279
  return addHeapObject(ret);
1278
1280
  };
1279
- imports.wbg.__wbg_push_740e4b286702d964 = function(arg0, arg1) {
1280
- const ret = getObject(arg0).push(getObject(arg1));
1281
- return ret;
1281
+ imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
1282
+ const ret = BigInt.asUintN(64, arg0);
1283
+ return addHeapObject(ret);
1282
1284
  };
1283
1285
  imports.wbg.__wbindgen_boolean_get = function(arg0) {
1284
1286
  const v = getObject(arg0);
@@ -1292,7 +1294,7 @@ function getImports() {
1292
1294
  const a = state0.a;
1293
1295
  state0.a = 0;
1294
1296
  try {
1295
- return __wbg_adapter_176(a, state0.b, arg0, arg1);
1297
+ return __wbg_adapter_175(a, state0.b, arg0, arg1);
1296
1298
  } finally {
1297
1299
  state0.a = a;
1298
1300
  }
@@ -1307,21 +1309,10 @@ function getImports() {
1307
1309
  const ret = ProposalBundle.__wrap(arg0);
1308
1310
  return addHeapObject(ret);
1309
1311
  };
1310
- imports.wbg.__wbg_set_c943d600fa71e4dd = function(arg0, arg1, arg2) {
1311
- getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1312
- };
1313
1312
  imports.wbg.__wbg_get_2268d91a19a98b92 = function(arg0, arg1) {
1314
1313
  const ret = getObject(arg0)[takeObject(arg1)];
1315
1314
  return addHeapObject(ret);
1316
1315
  };
1317
- imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
1318
- const obj = getObject(arg1);
1319
- const ret = typeof(obj) === 'string' ? obj : undefined;
1320
- var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1321
- var len0 = WASM_VECTOR_LEN;
1322
- getInt32Memory0()[arg0 / 4 + 1] = len0;
1323
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1324
- };
1325
1316
  imports.wbg.__wbg_isArray_27c46c67f498e15d = function(arg0) {
1326
1317
  const ret = Array.isArray(getObject(arg0));
1327
1318
  return ret;
@@ -1376,6 +1367,14 @@ function getImports() {
1376
1367
  const ret = getObject(arg0)[arg1 >>> 0];
1377
1368
  return addHeapObject(ret);
1378
1369
  };
1370
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
1371
+ const obj = getObject(arg1);
1372
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1373
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1374
+ var len0 = WASM_VECTOR_LEN;
1375
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
1376
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1377
+ };
1379
1378
  imports.wbg.__wbindgen_is_null = function(arg0) {
1380
1379
  const ret = getObject(arg0) === null;
1381
1380
  return ret;
@@ -1399,9 +1398,6 @@ function getImports() {
1399
1398
  const ret = getObject(arg0).transaction(getObject(arg1), takeObject(arg2));
1400
1399
  return addHeapObject(ret);
1401
1400
  }, arguments) };
1402
- imports.wbg.__wbg_set_a68214f35c417fa9 = function(arg0, arg1, arg2) {
1403
- getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1404
- };
1405
1401
  imports.wbg.__wbindgen_cb_drop = function(arg0) {
1406
1402
  const obj = takeObject(arg0).original;
1407
1403
  if (obj.cnt-- == 1) {
@@ -1411,21 +1407,13 @@ function getImports() {
1411
1407
  const ret = false;
1412
1408
  return ret;
1413
1409
  };
1414
- imports.wbg.__wbg_openCursor_e036069f0e326708 = function() { return handleError(function (arg0, arg1) {
1415
- const ret = getObject(arg0).openCursor(getObject(arg1));
1416
- return addHeapObject(ret);
1417
- }, arguments) };
1418
- imports.wbg.__wbg_openCursor_f055654a98eeab7f = function() { return handleError(function (arg0) {
1419
- const ret = getObject(arg0).openCursor();
1410
+ imports.wbg.__wbg_get_6285bf458a1ee758 = function() { return handleError(function (arg0, arg1) {
1411
+ const ret = getObject(arg0).get(getObject(arg1));
1420
1412
  return addHeapObject(ret);
1421
1413
  }, arguments) };
1422
1414
  imports.wbg.__wbg_setonsuccess_5f71593bc51653a3 = function(arg0, arg1) {
1423
1415
  getObject(arg0).onsuccess = getObject(arg1);
1424
1416
  };
1425
- imports.wbg.__wbg_delete_8abedd1043b4105d = function() { return handleError(function (arg0, arg1) {
1426
- const ret = getObject(arg0).delete(getObject(arg1));
1427
- return addHeapObject(ret);
1428
- }, arguments) };
1429
1417
  imports.wbg.__wbg_setonerror_d5771cc5bf9ea74c = function(arg0, arg1) {
1430
1418
  getObject(arg0).onerror = getObject(arg1);
1431
1419
  };
@@ -1438,12 +1426,8 @@ function getImports() {
1438
1426
  imports.wbg.__wbg_setonerror_00051c0213f27b2c = function(arg0, arg1) {
1439
1427
  getObject(arg0).onerror = getObject(arg1);
1440
1428
  };
1441
- imports.wbg.__wbg_put_84e7fc93eee27b28 = function() { return handleError(function (arg0, arg1, arg2) {
1442
- const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
1443
- return addHeapObject(ret);
1444
- }, arguments) };
1445
- imports.wbg.__wbg_put_f2763b05a07f3233 = function() { return handleError(function (arg0, arg1) {
1446
- const ret = getObject(arg0).put(getObject(arg1));
1429
+ imports.wbg.__wbg_delete_8abedd1043b4105d = function() { return handleError(function (arg0, arg1) {
1430
+ const ret = getObject(arg0).delete(getObject(arg1));
1447
1431
  return addHeapObject(ret);
1448
1432
  }, arguments) };
1449
1433
  imports.wbg.__wbg_get_3c3e41997e95952c = function() { return handleError(function (arg0, arg1) {
@@ -1458,6 +1442,14 @@ function getImports() {
1458
1442
  const ret = getObject(arg0).openCursor(getObject(arg1));
1459
1443
  return addHeapObject(ret);
1460
1444
  }, arguments) };
1445
+ imports.wbg.__wbg_put_84e7fc93eee27b28 = function() { return handleError(function (arg0, arg1, arg2) {
1446
+ const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
1447
+ return addHeapObject(ret);
1448
+ }, arguments) };
1449
+ imports.wbg.__wbg_put_f2763b05a07f3233 = function() { return handleError(function (arg0, arg1) {
1450
+ const ret = getObject(arg0).put(getObject(arg1));
1451
+ return addHeapObject(ret);
1452
+ }, arguments) };
1461
1453
  imports.wbg.__wbg_count_b0e88953a0ea909c = function() { return handleError(function (arg0) {
1462
1454
  const ret = getObject(arg0).count();
1463
1455
  return addHeapObject(ret);
@@ -1466,15 +1458,12 @@ function getImports() {
1466
1458
  const ret = getObject(arg0).count(getObject(arg1));
1467
1459
  return addHeapObject(ret);
1468
1460
  }, arguments) };
1469
- imports.wbg.__wbg_get_6285bf458a1ee758 = function() { return handleError(function (arg0, arg1) {
1470
- const ret = getObject(arg0).get(getObject(arg1));
1461
+ imports.wbg.__wbg_openCursor_e036069f0e326708 = function() { return handleError(function (arg0, arg1) {
1462
+ const ret = getObject(arg0).openCursor(getObject(arg1));
1471
1463
  return addHeapObject(ret);
1472
1464
  }, arguments) };
1473
- imports.wbg.__wbg_close_5a04b9ce11dade22 = function(arg0) {
1474
- getObject(arg0).close();
1475
- };
1476
- imports.wbg.__wbg_deleteDatabase_f6454de6a88aebde = function() { return handleError(function (arg0, arg1, arg2) {
1477
- const ret = getObject(arg0).deleteDatabase(getStringFromWasm0(arg1, arg2));
1465
+ imports.wbg.__wbg_openCursor_f055654a98eeab7f = function() { return handleError(function (arg0) {
1466
+ const ret = getObject(arg0).openCursor();
1478
1467
  return addHeapObject(ret);
1479
1468
  }, arguments) };
1480
1469
  imports.wbg.__wbg_open_a31c3fe1fdc244eb = function() { return handleError(function (arg0, arg1, arg2) {
@@ -1488,6 +1477,13 @@ function getImports() {
1488
1477
  imports.wbg.__wbg_setonupgradeneeded_17d0b9530f1e0cac = function(arg0, arg1) {
1489
1478
  getObject(arg0).onupgradeneeded = getObject(arg1);
1490
1479
  };
1480
+ imports.wbg.__wbg_deleteDatabase_f6454de6a88aebde = function() { return handleError(function (arg0, arg1, arg2) {
1481
+ const ret = getObject(arg0).deleteDatabase(getStringFromWasm0(arg1, arg2));
1482
+ return addHeapObject(ret);
1483
+ }, arguments) };
1484
+ imports.wbg.__wbg_close_5a04b9ce11dade22 = function(arg0) {
1485
+ getObject(arg0).close();
1486
+ };
1491
1487
  imports.wbg.__wbg_randomFillSync_065afffde01daa66 = function() { return handleError(function (arg0, arg1, arg2) {
1492
1488
  getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
1493
1489
  }, arguments) };
@@ -1593,10 +1589,6 @@ function getImports() {
1593
1589
  const ret = getObject(arg0).target;
1594
1590
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
1595
1591
  };
1596
- imports.wbg.__wbg_error_aacf5ac191e54ed0 = function() { return handleError(function (arg0) {
1597
- const ret = getObject(arg0).error;
1598
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
1599
- }, arguments) };
1600
1592
  imports.wbg.__wbg_objectStoreNames_8c06c40d2b05141c = function(arg0) {
1601
1593
  const ret = getObject(arg0).objectStoreNames;
1602
1594
  return addHeapObject(ret);
@@ -1631,6 +1623,10 @@ function getImports() {
1631
1623
  imports.wbg.__wbg_deleteObjectStore_1b698c5fd1bc077d = function() { return handleError(function (arg0, arg1, arg2) {
1632
1624
  getObject(arg0).deleteObjectStore(getStringFromWasm0(arg1, arg2));
1633
1625
  }, arguments) };
1626
+ imports.wbg.__wbg_error_aacf5ac191e54ed0 = function() { return handleError(function (arg0) {
1627
+ const ret = getObject(arg0).error;
1628
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1629
+ }, arguments) };
1634
1630
  imports.wbg.__wbindgen_is_falsy = function(arg0) {
1635
1631
  const ret = !getObject(arg0);
1636
1632
  return ret;
@@ -1739,11 +1735,11 @@ function getImports() {
1739
1735
  const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
1740
1736
  return addHeapObject(ret);
1741
1737
  }, arguments) };
1742
- imports.wbg.__wbindgen_closure_wrapper2438 = function(arg0, arg1, arg2) {
1738
+ imports.wbg.__wbindgen_closure_wrapper2465 = function(arg0, arg1, arg2) {
1743
1739
  const ret = makeMutClosure(arg0, arg1, 106, __wbg_adapter_40);
1744
1740
  return addHeapObject(ret);
1745
1741
  };
1746
- imports.wbg.__wbindgen_closure_wrapper4416 = function(arg0, arg1, arg2) {
1742
+ imports.wbg.__wbindgen_closure_wrapper4407 = function(arg0, arg1, arg2) {
1747
1743
  const ret = makeMutClosure(arg0, arg1, 114, __wbg_adapter_43);
1748
1744
  return addHeapObject(ret);
1749
1745
  };
@@ -1810,7 +1806,7 @@ var exports = /*#__PURE__*/Object.freeze({
1810
1806
  var wasm = async (opt = {}) => {
1811
1807
  let {importHook, serverPath} = opt;
1812
1808
 
1813
- let path = "assets/core_crypto_ffi-9e5ae25f.wasm";
1809
+ let path = "assets/core_crypto_ffi-ec1f65ea.wasm";
1814
1810
 
1815
1811
  if (serverPath != null) {
1816
1812
  path = serverPath + /[^\/\\]*$/.exec(path)[0];
@@ -2011,6 +2007,7 @@ class CoreCrypto {
2011
2007
  message: ffiDecryptedMessage.message,
2012
2008
  proposals: ffiDecryptedMessage.proposals,
2013
2009
  isActive: ffiDecryptedMessage.is_active,
2010
+ senderClientId: ffiDecryptedMessage.sender_client_id,
2014
2011
  commitDelay,
2015
2012
  };
2016
2013
  return ret;
@@ -2134,12 +2131,11 @@ class CoreCrypto {
2134
2131
  */
2135
2132
  async commitPendingProposals(conversationId) {
2136
2133
  const ffiCommitBundle = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").commit_pending_proposals(conversationId);
2137
- const ret = {
2134
+ return ffiCommitBundle ? {
2138
2135
  welcome: ffiCommitBundle.welcome,
2139
2136
  commit: ffiCommitBundle.commit,
2140
2137
  publicGroupState: ffiCommitBundle.public_group_state,
2141
- };
2142
- return ret;
2138
+ } : undefined;
2143
2139
  }
2144
2140
  /**
2145
2141
  * Adds new clients to a conversation, assuming the current client has the right to add new clients to the conversation.