ping-openmls-sdk 0.6.5 → 0.6.6

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.
@@ -195,6 +195,28 @@ export function _start(): void;
195
195
  */
196
196
  export function decodeCatchupSnapshot(snapshot_bytes: Uint8Array): any;
197
197
 
198
+ /**
199
+ * Decrypt a recovery blob. Returns `{ v, account_id, identity_export, device_group_snapshot,
200
+ * created_at_ms }`. A wrong mnemonic or tampered blob throws a generic error.
201
+ */
202
+ export function decryptBackup(blob: Uint8Array, mnemonic_phrase: string): any;
203
+
204
+ /**
205
+ * Encrypt an IdentityBackup blob for `POST /v1/recovery/blobs`. `account_id` is 16 bytes,
206
+ * `identity_export` is `generateIdentity()` output, `device_group_snapshot` may be empty.
207
+ */
208
+ export function encryptBackup(mnemonic_phrase: string, account_id: Uint8Array, identity_export: Uint8Array, device_group_snapshot: Uint8Array, created_at_ms: number): Uint8Array;
209
+
210
+ /**
211
+ * Generate a fresh 12-word BIP39 mnemonic, returned as its canonical phrase string.
212
+ */
213
+ export function generateMnemonicPhrase(): string;
214
+
215
+ /**
216
+ * Validate + canonicalise a user-entered phrase (BIP39 wordlist + checksum).
217
+ */
218
+ export function normalizeMnemonicPhrase(phrase: string): string;
219
+
198
220
  export function openLinkingTicket(sealed: Uint8Array, new_device_priv: Uint8Array): any;
199
221
 
200
222
  /**
@@ -212,6 +234,10 @@ export interface InitOutput {
212
234
  readonly memory: WebAssembly.Memory;
213
235
  readonly __wbg_pingclient_free: (a: number, b: number) => void;
214
236
  readonly decodeCatchupSnapshot: (a: number, b: number, c: number) => void;
237
+ readonly decryptBackup: (a: number, b: number, c: number, d: number, e: number) => void;
238
+ readonly encryptBackup: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
239
+ readonly generateMnemonicPhrase: (a: number) => void;
240
+ readonly normalizeMnemonicPhrase: (a: number, b: number, c: number) => void;
215
241
  readonly openLinkingTicket: (a: number, b: number, c: number, d: number, e: number) => void;
216
242
  readonly pingclient_addMembers: (a: number, b: number, c: number, d: number, e: number) => number;
217
243
  readonly pingclient_admitDeviceToChats: (a: number, b: number, c: number, d: number, e: number) => number;
@@ -251,9 +277,9 @@ export interface InitOutput {
251
277
  readonly wasmbindgentestcontext_include_ignored: (a: number, b: number) => void;
252
278
  readonly wasmbindgentestcontext_new: (a: number) => number;
253
279
  readonly wasmbindgentestcontext_run: (a: number, b: number, c: number) => number;
254
- readonly __wasm_bindgen_func_elem_2676: (a: number, b: number, c: number, d: number, e: number) => void;
255
- readonly __wasm_bindgen_func_elem_2666: (a: number, b: number, c: number, d: number) => void;
256
- readonly __wasm_bindgen_func_elem_2675: (a: number, b: number, c: number, d: number) => void;
280
+ readonly __wasm_bindgen_func_elem_2766: (a: number, b: number, c: number, d: number, e: number) => void;
281
+ readonly __wasm_bindgen_func_elem_2752: (a: number, b: number, c: number, d: number) => void;
282
+ readonly __wasm_bindgen_func_elem_2776: (a: number, b: number, c: number, d: number) => void;
257
283
  readonly __wbindgen_export: (a: number, b: number) => number;
258
284
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
259
285
  readonly __wbindgen_export3: (a: number) => void;
package/wasm/ping_wasm.js CHANGED
@@ -625,6 +625,128 @@ export function decodeCatchupSnapshot(snapshot_bytes) {
625
625
  }
626
626
  }
627
627
 
628
+ /**
629
+ * Decrypt a recovery blob. Returns `{ v, account_id, identity_export, device_group_snapshot,
630
+ * created_at_ms }`. A wrong mnemonic or tampered blob throws a generic error.
631
+ * @param {Uint8Array} blob
632
+ * @param {string} mnemonic_phrase
633
+ * @returns {any}
634
+ */
635
+ export function decryptBackup(blob, mnemonic_phrase) {
636
+ try {
637
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
638
+ const ptr0 = passArray8ToWasm0(blob, wasm.__wbindgen_export);
639
+ const len0 = WASM_VECTOR_LEN;
640
+ const ptr1 = passStringToWasm0(mnemonic_phrase, wasm.__wbindgen_export, wasm.__wbindgen_export2);
641
+ const len1 = WASM_VECTOR_LEN;
642
+ wasm.decryptBackup(retptr, ptr0, len0, ptr1, len1);
643
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
644
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
645
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
646
+ if (r2) {
647
+ throw takeObject(r1);
648
+ }
649
+ return takeObject(r0);
650
+ } finally {
651
+ wasm.__wbindgen_add_to_stack_pointer(16);
652
+ }
653
+ }
654
+
655
+ /**
656
+ * Encrypt an IdentityBackup blob for `POST /v1/recovery/blobs`. `account_id` is 16 bytes,
657
+ * `identity_export` is `generateIdentity()` output, `device_group_snapshot` may be empty.
658
+ * @param {string} mnemonic_phrase
659
+ * @param {Uint8Array} account_id
660
+ * @param {Uint8Array} identity_export
661
+ * @param {Uint8Array} device_group_snapshot
662
+ * @param {number} created_at_ms
663
+ * @returns {Uint8Array}
664
+ */
665
+ export function encryptBackup(mnemonic_phrase, account_id, identity_export, device_group_snapshot, created_at_ms) {
666
+ try {
667
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
668
+ const ptr0 = passStringToWasm0(mnemonic_phrase, wasm.__wbindgen_export, wasm.__wbindgen_export2);
669
+ const len0 = WASM_VECTOR_LEN;
670
+ const ptr1 = passArray8ToWasm0(account_id, wasm.__wbindgen_export);
671
+ const len1 = WASM_VECTOR_LEN;
672
+ const ptr2 = passArray8ToWasm0(identity_export, wasm.__wbindgen_export);
673
+ const len2 = WASM_VECTOR_LEN;
674
+ const ptr3 = passArray8ToWasm0(device_group_snapshot, wasm.__wbindgen_export);
675
+ const len3 = WASM_VECTOR_LEN;
676
+ wasm.encryptBackup(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, created_at_ms);
677
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
678
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
679
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
680
+ if (r2) {
681
+ throw takeObject(r1);
682
+ }
683
+ return takeObject(r0);
684
+ } finally {
685
+ wasm.__wbindgen_add_to_stack_pointer(16);
686
+ }
687
+ }
688
+
689
+ /**
690
+ * Generate a fresh 12-word BIP39 mnemonic, returned as its canonical phrase string.
691
+ * @returns {string}
692
+ */
693
+ export function generateMnemonicPhrase() {
694
+ let deferred2_0;
695
+ let deferred2_1;
696
+ try {
697
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
698
+ wasm.generateMnemonicPhrase(retptr);
699
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
700
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
701
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
702
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
703
+ var ptr1 = r0;
704
+ var len1 = r1;
705
+ if (r3) {
706
+ ptr1 = 0; len1 = 0;
707
+ throw takeObject(r2);
708
+ }
709
+ deferred2_0 = ptr1;
710
+ deferred2_1 = len1;
711
+ return getStringFromWasm0(ptr1, len1);
712
+ } finally {
713
+ wasm.__wbindgen_add_to_stack_pointer(16);
714
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
715
+ }
716
+ }
717
+
718
+ /**
719
+ * Validate + canonicalise a user-entered phrase (BIP39 wordlist + checksum).
720
+ * @param {string} phrase
721
+ * @returns {string}
722
+ */
723
+ export function normalizeMnemonicPhrase(phrase) {
724
+ let deferred3_0;
725
+ let deferred3_1;
726
+ try {
727
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
728
+ const ptr0 = passStringToWasm0(phrase, wasm.__wbindgen_export, wasm.__wbindgen_export2);
729
+ const len0 = WASM_VECTOR_LEN;
730
+ wasm.normalizeMnemonicPhrase(retptr, ptr0, len0);
731
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
732
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
733
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
734
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
735
+ var ptr2 = r0;
736
+ var len2 = r1;
737
+ if (r3) {
738
+ ptr2 = 0; len2 = 0;
739
+ throw takeObject(r2);
740
+ }
741
+ deferred3_0 = ptr2;
742
+ deferred3_1 = len2;
743
+ return getStringFromWasm0(ptr2, len2);
744
+ } finally {
745
+ wasm.__wbindgen_add_to_stack_pointer(16);
746
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
747
+ }
748
+ }
749
+
628
750
  /**
629
751
  * @param {Uint8Array} sealed
630
752
  * @param {Uint8Array} new_device_priv
@@ -803,11 +925,11 @@ function __wbg_get_imports() {
803
925
  const ret = getObject(arg0).crypto;
804
926
  return addHeapObject(ret);
805
927
  },
806
- __wbg_del_0c23259b4f1e1a35: function(arg0, arg1, arg2, arg3, arg4) {
928
+ __wbg_del_eafff9965c23bbac: function(arg0, arg1, arg2, arg3, arg4) {
807
929
  const ret = getObject(arg0).del(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
808
930
  return addHeapObject(ret);
809
931
  },
810
- __wbg_discoverDevices_6602e7a0e4eb5dca: function(arg0, arg1) {
932
+ __wbg_discoverDevices_edb837429e2af7b3: function(arg0, arg1) {
811
933
  const ret = getObject(arg0).discoverDevices(takeObject(arg1));
812
934
  return addHeapObject(ret);
813
935
  },
@@ -833,7 +955,7 @@ function __wbg_get_imports() {
833
955
  wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
834
956
  }
835
957
  },
836
- __wbg_fetchSince_9ab9ab87545120a6: function(arg0, arg1, arg2, arg3) {
958
+ __wbg_fetchSince_a4a945f4063994a7: function(arg0, arg1, arg2, arg3) {
837
959
  const ret = getObject(arg0).fetchSince(takeObject(arg1), takeObject(arg2), arg3 >>> 0);
838
960
  return addHeapObject(ret);
839
961
  },
@@ -844,7 +966,7 @@ function __wbg_get_imports() {
844
966
  const a = state0.a;
845
967
  state0.a = 0;
846
968
  try {
847
- return __wasm_bindgen_func_elem_2676(a, state0.b, arg0, arg1, arg2);
969
+ return __wasm_bindgen_func_elem_2766(a, state0.b, arg0, arg1, arg2);
848
970
  } finally {
849
971
  state0.a = a;
850
972
  }
@@ -868,10 +990,6 @@ function __wbg_get_imports() {
868
990
  __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
869
991
  getObject(arg0).getRandomValues(getObject(arg1));
870
992
  }, arguments); },
871
- __wbg_get_42b374e8c2a74c5e: function(arg0, arg1, arg2, arg3, arg4) {
872
- const ret = getObject(arg0).get(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
873
- return addHeapObject(ret);
874
- },
875
993
  __wbg_get_652f640b3b0b6e3e: function(arg0, arg1) {
876
994
  const ret = getObject(arg0)[arg1 >>> 0];
877
995
  return addHeapObject(ret);
@@ -880,6 +998,10 @@ function __wbg_get_imports() {
880
998
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
881
999
  return addHeapObject(ret);
882
1000
  }, arguments); },
1001
+ __wbg_get_cb2eaaeb44a2843d: function(arg0, arg1, arg2, arg3, arg4) {
1002
+ const ret = getObject(arg0).get(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
1003
+ return addHeapObject(ret);
1004
+ },
883
1005
  __wbg_get_unchecked_be562b1421656321: function(arg0, arg1) {
884
1006
  const ret = getObject(arg0)[arg1 >>> 0];
885
1007
  return addHeapObject(ret);
@@ -928,7 +1050,7 @@ function __wbg_get_imports() {
928
1050
  const ret = getObject(arg0).length;
929
1051
  return ret;
930
1052
  },
931
- __wbg_listKeys_22139ea835278f2e: function(arg0, arg1, arg2, arg3, arg4) {
1053
+ __wbg_listKeys_8ea9db09d145e5f2: function(arg0, arg1, arg2, arg3, arg4) {
932
1054
  const ret = getObject(arg0).listKeys(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
933
1055
  return addHeapObject(ret);
934
1056
  },
@@ -985,7 +1107,7 @@ function __wbg_get_imports() {
985
1107
  const a = state0.a;
986
1108
  state0.a = 0;
987
1109
  try {
988
- return __wasm_bindgen_func_elem_2675(a, state0.b, arg0, arg1);
1110
+ return __wasm_bindgen_func_elem_2776(a, state0.b, arg0, arg1);
989
1111
  } finally {
990
1112
  state0.a = a;
991
1113
  }
@@ -1035,7 +1157,7 @@ function __wbg_get_imports() {
1035
1157
  __wbg_prototypesetcall_fd4050e806e1d519: function(arg0, arg1, arg2) {
1036
1158
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
1037
1159
  },
1038
- __wbg_put_ebb52697bcf9189a: function(arg0, arg1, arg2, arg3, arg4, arg5) {
1160
+ __wbg_put_92ce60d3b8bc7b85: function(arg0, arg1, arg2, arg3, arg4, arg5) {
1039
1161
  const ret = getObject(arg0).put(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), takeObject(arg5));
1040
1162
  return addHeapObject(ret);
1041
1163
  },
@@ -1061,11 +1183,11 @@ function __wbg_get_imports() {
1061
1183
  const ret = getObject(arg0).self;
1062
1184
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
1063
1185
  },
1064
- __wbg_send_a5e0c4c86eab668f: function(arg0, arg1) {
1186
+ __wbg_send_491ff43c78019f2d: function(arg0, arg1) {
1065
1187
  const ret = getObject(arg0).send(takeObject(arg1));
1066
1188
  return addHeapObject(ret);
1067
1189
  },
1068
- __wbg_setNextWelcomeRecipients_7d5369b904c404dd: function(arg0, arg1, arg2) {
1190
+ __wbg_setNextWelcomeRecipients_837f72290c599dcc: function(arg0, arg1, arg2) {
1069
1191
  const ret = getObject(arg0).setNextWelcomeRecipients(takeObject(arg1), takeObject(arg2));
1070
1192
  return addHeapObject(ret);
1071
1193
  },
@@ -1162,8 +1284,8 @@ function __wbg_get_imports() {
1162
1284
  return addHeapObject(ret);
1163
1285
  },
1164
1286
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1165
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 749, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1166
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2666);
1287
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 774, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1288
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2752);
1167
1289
  return addHeapObject(ret);
1168
1290
  },
1169
1291
  __wbindgen_cast_0000000000000002: function(arg0) {
@@ -1207,10 +1329,10 @@ function __wbg_get_imports() {
1207
1329
  };
1208
1330
  }
1209
1331
 
1210
- function __wasm_bindgen_func_elem_2666(arg0, arg1, arg2) {
1332
+ function __wasm_bindgen_func_elem_2752(arg0, arg1, arg2) {
1211
1333
  try {
1212
1334
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1213
- wasm.__wasm_bindgen_func_elem_2666(retptr, arg0, arg1, addHeapObject(arg2));
1335
+ wasm.__wasm_bindgen_func_elem_2752(retptr, arg0, arg1, addHeapObject(arg2));
1214
1336
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1215
1337
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1216
1338
  if (r1) {
@@ -1221,12 +1343,12 @@ function __wasm_bindgen_func_elem_2666(arg0, arg1, arg2) {
1221
1343
  }
1222
1344
  }
1223
1345
 
1224
- function __wasm_bindgen_func_elem_2675(arg0, arg1, arg2, arg3) {
1225
- wasm.__wasm_bindgen_func_elem_2675(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1346
+ function __wasm_bindgen_func_elem_2776(arg0, arg1, arg2, arg3) {
1347
+ wasm.__wasm_bindgen_func_elem_2776(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1226
1348
  }
1227
1349
 
1228
- function __wasm_bindgen_func_elem_2676(arg0, arg1, arg2, arg3, arg4) {
1229
- wasm.__wasm_bindgen_func_elem_2676(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
1350
+ function __wasm_bindgen_func_elem_2766(arg0, arg1, arg2, arg3, arg4) {
1351
+ wasm.__wasm_bindgen_func_elem_2766(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
1230
1352
  }
1231
1353
 
1232
1354
  const WasmBindgenTestContextFinalization = (typeof FinalizationRegistry === 'undefined')
Binary file
@@ -3,6 +3,10 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_pingclient_free: (a: number, b: number) => void;
5
5
  export const decodeCatchupSnapshot: (a: number, b: number, c: number) => void;
6
+ export const decryptBackup: (a: number, b: number, c: number, d: number, e: number) => void;
7
+ export const encryptBackup: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
8
+ export const generateMnemonicPhrase: (a: number) => void;
9
+ export const normalizeMnemonicPhrase: (a: number, b: number, c: number) => void;
6
10
  export const openLinkingTicket: (a: number, b: number, c: number, d: number, e: number) => void;
7
11
  export const pingclient_addMembers: (a: number, b: number, c: number, d: number, e: number) => number;
8
12
  export const pingclient_admitDeviceToChats: (a: number, b: number, c: number, d: number, e: number) => number;
@@ -42,9 +46,9 @@ export const wasmbindgentestcontext_filtered_count: (a: number, b: number) => vo
42
46
  export const wasmbindgentestcontext_include_ignored: (a: number, b: number) => void;
43
47
  export const wasmbindgentestcontext_new: (a: number) => number;
44
48
  export const wasmbindgentestcontext_run: (a: number, b: number, c: number) => number;
45
- export const __wasm_bindgen_func_elem_2676: (a: number, b: number, c: number, d: number, e: number) => void;
46
- export const __wasm_bindgen_func_elem_2666: (a: number, b: number, c: number, d: number) => void;
47
- export const __wasm_bindgen_func_elem_2675: (a: number, b: number, c: number, d: number) => void;
49
+ export const __wasm_bindgen_func_elem_2766: (a: number, b: number, c: number, d: number, e: number) => void;
50
+ export const __wasm_bindgen_func_elem_2752: (a: number, b: number, c: number, d: number) => void;
51
+ export const __wasm_bindgen_func_elem_2776: (a: number, b: number, c: number, d: number) => void;
48
52
  export const __wbindgen_export: (a: number, b: number) => number;
49
53
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
50
54
  export const __wbindgen_export3: (a: number) => void;