@ping-app/ping-openmls-sdk 0.10.1 → 0.10.3

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/wasm/ping_wasm.js CHANGED
@@ -432,6 +432,46 @@ export class PingClient {
432
432
  wasm.__wbindgen_add_to_stack_pointer(16);
433
433
  }
434
434
  }
435
+ /**
436
+ * `exportConversationSecret` together with the MLS epoch the secret was
437
+ * exported at, from one read under one lock in the core
438
+ * (`MessagingClient::export_conversation_secret_with_epoch`): resolves
439
+ * `{ epoch: number, secret: Uint8Array }`, and the pair can never disagree
440
+ * across a Commit.
441
+ *
442
+ * Same derivation, same arguments and the same errors as
443
+ * `exportConversationSecret`; at one epoch both return the same bytes. The
444
+ * same boundary rule too: the core's `Zeroizing` copy is wiped when it
445
+ * drops here, the `Uint8Array` is the caller's to clear (`u8.fill(0)`).
446
+ * `epoch` is a plain number (an epoch beyond `Number.MAX_SAFE_INTEGER` is
447
+ * refused, never rounded).
448
+ * @param {Uint8Array} conv_id
449
+ * @param {string} label
450
+ * @param {Uint8Array} context
451
+ * @param {number} length
452
+ * @returns {any}
453
+ */
454
+ exportConversationSecretWithEpoch(conv_id, label, context, length) {
455
+ try {
456
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
457
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
458
+ const len0 = WASM_VECTOR_LEN;
459
+ const ptr1 = passStringToWasm0(label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
460
+ const len1 = WASM_VECTOR_LEN;
461
+ const ptr2 = passArray8ToWasm0(context, wasm.__wbindgen_export);
462
+ const len2 = WASM_VECTOR_LEN;
463
+ wasm.pingclient_exportConversationSecretWithEpoch(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, length);
464
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
465
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
466
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
467
+ if (r2) {
468
+ throw takeObject(r1);
469
+ }
470
+ return takeObject(r0);
471
+ } finally {
472
+ wasm.__wbindgen_add_to_stack_pointer(16);
473
+ }
474
+ }
435
475
  /**
436
476
  * [CR-7] Export the MLS state snapshot for one conversation.
437
477
  * @param {Uint8Array} conv_id
@@ -1384,6 +1424,44 @@ export function _start() {
1384
1424
  wasm._start();
1385
1425
  }
1386
1426
 
1427
+ /**
1428
+ * Whether `mnemonicPhrase` opens `blob`, with THREE answers
1429
+ * (`ping_recovery::check_backup_phrase`). Resolves
1430
+ * `{ outcome: "opens" | "authenticationFailed" | "couldNotCheck", reason? }`,
1431
+ * where `reason` is set exactly for `couldNotCheck`: `"invalidPhrase"`,
1432
+ * `"unsupportedVersion"`, `"malformed"`, `"undecodable"` or `"internal"`. The
1433
+ * codes are the core's (`outcome_code`, `BackupCheckFailure::code`), pinned
1434
+ * there and replayed from one table by `sdk/js`
1435
+ * (`backup-phrase-check.test.ts`).
1436
+ *
1437
+ * `authenticationFailed` is the only proof that the phrase does not open
1438
+ * these bytes; every `couldNotCheck` is a doubt. Never throws for an answer
1439
+ * of the check, returns nothing of the backup, logs nothing. `decryptBackup`
1440
+ * is unchanged and still rejects with its one message.
1441
+ * @param {Uint8Array} blob
1442
+ * @param {string} mnemonic_phrase
1443
+ * @returns {any}
1444
+ */
1445
+ export function checkBackupPhrase(blob, mnemonic_phrase) {
1446
+ try {
1447
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1448
+ const ptr0 = passArray8ToWasm0(blob, wasm.__wbindgen_export);
1449
+ const len0 = WASM_VECTOR_LEN;
1450
+ const ptr1 = passStringToWasm0(mnemonic_phrase, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1451
+ const len1 = WASM_VECTOR_LEN;
1452
+ wasm.checkBackupPhrase(retptr, ptr0, len0, ptr1, len1);
1453
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1454
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1455
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1456
+ if (r2) {
1457
+ throw takeObject(r1);
1458
+ }
1459
+ return takeObject(r0);
1460
+ } finally {
1461
+ wasm.__wbindgen_add_to_stack_pointer(16);
1462
+ }
1463
+ }
1464
+
1387
1465
  /**
1388
1466
  * HPKE-open a sealed `LinkingTicket` ([CR-3]). Pure function — usable without an
1389
1467
  * initialized `PingClient`, which is exactly the situation the receiving device is in
@@ -2343,7 +2421,7 @@ function __wbg_get_imports() {
2343
2421
  __wbg__wbg_cb_unref_be22cc64ae6946a0: function(arg0) {
2344
2422
  getObject(arg0)._wbg_cb_unref();
2345
2423
  },
2346
- __wbg_applyBatch_406d7dbd1084b3f8: function(arg0, arg1, arg2, arg3, arg4) {
2424
+ __wbg_applyBatch_de14959bc7389069: function(arg0, arg1, arg2, arg3, arg4) {
2347
2425
  const ret = getObject(arg0).applyBatch(getStringFromWasm0(arg1, arg2), takeObject(arg3), takeObject(arg4));
2348
2426
  return addHeapObject(ret);
2349
2427
  },
@@ -2359,11 +2437,11 @@ function __wbg_get_imports() {
2359
2437
  const ret = getObject(arg0).crypto;
2360
2438
  return addHeapObject(ret);
2361
2439
  },
2362
- __wbg_del_77ee30f11147a08a: function(arg0, arg1, arg2, arg3, arg4) {
2440
+ __wbg_del_c3b129e21a741c9d: function(arg0, arg1, arg2, arg3, arg4) {
2363
2441
  const ret = getObject(arg0).del(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
2364
2442
  return addHeapObject(ret);
2365
2443
  },
2366
- __wbg_discoverDevices_48997fecdd635ffe: function(arg0, arg1) {
2444
+ __wbg_discoverDevices_8ca6166b2842dbe2: function(arg0, arg1) {
2367
2445
  const ret = getObject(arg0).discoverDevices(takeObject(arg1));
2368
2446
  return addHeapObject(ret);
2369
2447
  },
@@ -2386,15 +2464,15 @@ function __wbg_get_imports() {
2386
2464
  wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
2387
2465
  }
2388
2466
  },
2389
- __wbg_fetchLogHeads_e78f7b7086790e4e: function(arg0) {
2467
+ __wbg_fetchLogHeads_20d58ba96250ab8e: function(arg0) {
2390
2468
  const ret = getObject(arg0).fetchLogHeads();
2391
2469
  return addHeapObject(ret);
2392
2470
  },
2393
- __wbg_fetchLogSince_9160c59aa2abdb21: function(arg0, arg1, arg2) {
2471
+ __wbg_fetchLogSince_a8f2ff64d0fc895c: function(arg0, arg1, arg2) {
2394
2472
  const ret = getObject(arg0).fetchLogSince(takeObject(arg1), arg2 >>> 0);
2395
2473
  return addHeapObject(ret);
2396
2474
  },
2397
- __wbg_fetchSince_b12814c52b08f8cf: function(arg0, arg1, arg2, arg3) {
2475
+ __wbg_fetchSince_ff2315684811363f: function(arg0, arg1, arg2, arg3) {
2398
2476
  const ret = getObject(arg0).fetchSince(takeObject(arg1), takeObject(arg2), arg3 >>> 0);
2399
2477
  return addHeapObject(ret);
2400
2478
  },
@@ -2411,14 +2489,14 @@ function __wbg_get_imports() {
2411
2489
  __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
2412
2490
  getObject(arg0).getRandomValues(getObject(arg1));
2413
2491
  }, arguments); },
2492
+ __wbg_get_05ecab9f9d0da0cb: function(arg0, arg1, arg2, arg3, arg4) {
2493
+ const ret = getObject(arg0).get(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
2494
+ return addHeapObject(ret);
2495
+ },
2414
2496
  __wbg_get_971a0c45d172643f: function() { return handleError(function (arg0, arg1) {
2415
2497
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
2416
2498
  return addHeapObject(ret);
2417
2499
  }, arguments); },
2418
- __wbg_get_aa5df4f67a22a0ad: function(arg0, arg1, arg2, arg3, arg4) {
2419
- const ret = getObject(arg0).get(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
2420
- return addHeapObject(ret);
2421
- },
2422
2500
  __wbg_get_c0c8f8d7da0c03dd: function(arg0, arg1) {
2423
2501
  const ret = getObject(arg0)[arg1 >>> 0];
2424
2502
  return addHeapObject(ret);
@@ -2475,11 +2553,11 @@ function __wbg_get_imports() {
2475
2553
  const ret = getObject(arg0).length;
2476
2554
  return ret;
2477
2555
  },
2478
- __wbg_listEntries_7b924b3e7ff2b526: function(arg0, arg1, arg2, arg3, arg4) {
2556
+ __wbg_listEntries_3a4c3185f2cb86ca: function(arg0, arg1, arg2, arg3, arg4) {
2479
2557
  const ret = getObject(arg0).listEntries(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
2480
2558
  return addHeapObject(ret);
2481
2559
  },
2482
- __wbg_listKeys_ffe3a9798e88abde: function(arg0, arg1, arg2, arg3, arg4) {
2560
+ __wbg_listKeys_f114996c3760f96e: function(arg0, arg1, arg2, arg3, arg4) {
2483
2561
  const ret = getObject(arg0).listKeys(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
2484
2562
  return addHeapObject(ret);
2485
2563
  },
@@ -2514,7 +2592,7 @@ function __wbg_get_imports() {
2514
2592
  const a = state0.a;
2515
2593
  state0.a = 0;
2516
2594
  try {
2517
- return __wasm_bindgen_func_elem_4230(a, state0.b, arg0, arg1);
2595
+ return __wasm_bindgen_func_elem_4238(a, state0.b, arg0, arg1);
2518
2596
  } finally {
2519
2597
  state0.a = a;
2520
2598
  }
@@ -2560,7 +2638,7 @@ function __wbg_get_imports() {
2560
2638
  const ret = getObject(arg0).push(getObject(arg1));
2561
2639
  return ret;
2562
2640
  },
2563
- __wbg_put_053c25b07020914f: function(arg0, arg1, arg2, arg3, arg4, arg5) {
2641
+ __wbg_put_975419b1499979f6: function(arg0, arg1, arg2, arg3, arg4, arg5) {
2564
2642
  const ret = getObject(arg0).put(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), takeObject(arg5));
2565
2643
  return addHeapObject(ret);
2566
2644
  },
@@ -2582,21 +2660,25 @@ function __wbg_get_imports() {
2582
2660
  const ret = Promise.resolve(getObject(arg0));
2583
2661
  return addHeapObject(ret);
2584
2662
  },
2585
- __wbg_sendBatch_642a94f23a738334: function(arg0, arg1) {
2663
+ __wbg_sendBatch_880a500001e45ea8: function(arg0, arg1) {
2586
2664
  const ret = getObject(arg0).sendBatch(takeObject(arg1));
2587
2665
  return addHeapObject(ret);
2588
2666
  },
2589
- __wbg_send_50a83d84aca86680: function(arg0, arg1) {
2667
+ __wbg_send_60a6ce072d4fd782: function(arg0, arg1) {
2590
2668
  const ret = getObject(arg0).send(takeObject(arg1));
2591
2669
  return addHeapObject(ret);
2592
2670
  },
2593
- __wbg_setNextWelcomeRecipients_a3c6e79d35538d0d: function(arg0, arg1, arg2) {
2671
+ __wbg_setNextWelcomeRecipients_0ef5b85f2041b914: function(arg0, arg1, arg2) {
2594
2672
  const ret = getObject(arg0).setNextWelcomeRecipients(takeObject(arg1), takeObject(arg2));
2595
2673
  return addHeapObject(ret);
2596
2674
  },
2597
2675
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
2598
2676
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2599
2677
  },
2678
+ __wbg_set_8155bb79a948541b: function() { return handleError(function (arg0, arg1, arg2) {
2679
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
2680
+ return ret;
2681
+ }, arguments); },
2600
2682
  __wbg_set_a80955eb93b145c6: function(arg0, arg1, arg2) {
2601
2683
  getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
2602
2684
  },
@@ -2645,7 +2727,7 @@ function __wbg_get_imports() {
2645
2727
  },
2646
2728
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2647
2729
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1048, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2648
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_4215);
2730
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_4223);
2649
2731
  return addHeapObject(ret);
2650
2732
  },
2651
2733
  __wbindgen_cast_0000000000000002: function(arg0) {
@@ -2689,10 +2771,10 @@ function __wbg_get_imports() {
2689
2771
  };
2690
2772
  }
2691
2773
 
2692
- function __wasm_bindgen_func_elem_4215(arg0, arg1, arg2) {
2774
+ function __wasm_bindgen_func_elem_4223(arg0, arg1, arg2) {
2693
2775
  try {
2694
2776
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2695
- wasm.__wasm_bindgen_func_elem_4215(retptr, arg0, arg1, addHeapObject(arg2));
2777
+ wasm.__wasm_bindgen_func_elem_4223(retptr, arg0, arg1, addHeapObject(arg2));
2696
2778
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2697
2779
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2698
2780
  if (r1) {
@@ -2703,8 +2785,8 @@ function __wasm_bindgen_func_elem_4215(arg0, arg1, arg2) {
2703
2785
  }
2704
2786
  }
2705
2787
 
2706
- function __wasm_bindgen_func_elem_4230(arg0, arg1, arg2, arg3) {
2707
- wasm.__wasm_bindgen_func_elem_4230(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2788
+ function __wasm_bindgen_func_elem_4238(arg0, arg1, arg2, arg3) {
2789
+ wasm.__wasm_bindgen_func_elem_4238(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2708
2790
  }
2709
2791
 
2710
2792
  const PingClientFinalization = (typeof FinalizationRegistry === 'undefined')
Binary file
@@ -2,6 +2,7 @@
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_pingclient_free: (a: number, b: number) => void;
5
+ export const checkBackupPhrase: (a: number, b: number, c: number, d: number, e: number) => void;
5
6
  export const decodeCatchupSnapshot: (a: number, b: number, c: number) => void;
6
7
  export const decryptBackup: (a: number, b: number, c: number, d: number, e: number) => void;
7
8
  export const deviceGroupIdFor: (a: number, b: number) => number;
@@ -46,6 +47,7 @@ export const pingclient_createConversation: (a: number, b: number, c: number, d:
46
47
  export const pingclient_deviceId: (a: number, b: number) => void;
47
48
  export const pingclient_dropConversationLocal: (a: number, b: number, c: number) => number;
48
49
  export const pingclient_exportConversationSecret: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
50
+ export const pingclient_exportConversationSecretWithEpoch: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
49
51
  export const pingclient_exportConversationStateSnapshot: (a: number, b: number, c: number, d: number, e: number) => void;
50
52
  export const pingclient_exportIdentity: (a: number, b: number) => void;
51
53
  export const pingclient_freshKeyPackage: (a: number) => number;
@@ -102,8 +104,8 @@ export const signDeviceLinkApproval: (a: number, b: number, c: number, d: number
102
104
  export const signDeviceLinkPossession: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
103
105
  export const signDeviceReauth: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
104
106
  export const _start: () => void;
105
- export const __wasm_bindgen_func_elem_4215: (a: number, b: number, c: number, d: number) => void;
106
- export const __wasm_bindgen_func_elem_4230: (a: number, b: number, c: number, d: number) => void;
107
+ export const __wasm_bindgen_func_elem_4223: (a: number, b: number, c: number, d: number) => void;
108
+ export const __wasm_bindgen_func_elem_4238: (a: number, b: number, c: number, d: number) => void;
107
109
  export const __wbindgen_export: (a: number, b: number) => number;
108
110
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
109
111
  export const __wbindgen_export3: (a: number) => void;