ping-openmls-sdk 0.6.5 → 0.6.8

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,31 @@ 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
+ * conversation_snapshots, created_at_ms }`. A wrong mnemonic or tampered blob throws.
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
+ * `conversation_snapshots` is a JS array of `{ conversation_id, group_state_bytes }`
208
+ * (both Uint8Array). Pass `[]` for the legacy identity+DeviceGroup-only backup, or
209
+ * populate it (from `exportConversationStateSnapshot`) to restore group chats offline.
210
+ */
211
+ export function encryptBackup(mnemonic_phrase: string, account_id: Uint8Array, identity_export: Uint8Array, device_group_snapshot: Uint8Array, conversation_snapshots: any, created_at_ms: number): Uint8Array;
212
+
213
+ /**
214
+ * Generate a fresh 12-word BIP39 mnemonic, returned as its canonical phrase string.
215
+ */
216
+ export function generateMnemonicPhrase(): string;
217
+
218
+ /**
219
+ * Validate + canonicalise a user-entered phrase (BIP39 wordlist + checksum).
220
+ */
221
+ export function normalizeMnemonicPhrase(phrase: string): string;
222
+
198
223
  export function openLinkingTicket(sealed: Uint8Array, new_device_priv: Uint8Array): any;
199
224
 
200
225
  /**
@@ -212,6 +237,10 @@ export interface InitOutput {
212
237
  readonly memory: WebAssembly.Memory;
213
238
  readonly __wbg_pingclient_free: (a: number, b: number) => void;
214
239
  readonly decodeCatchupSnapshot: (a: number, b: number, c: number) => void;
240
+ readonly decryptBackup: (a: number, b: number, c: number, d: number, e: number) => void;
241
+ readonly encryptBackup: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
242
+ readonly generateMnemonicPhrase: (a: number) => void;
243
+ readonly normalizeMnemonicPhrase: (a: number, b: number, c: number) => void;
215
244
  readonly openLinkingTicket: (a: number, b: number, c: number, d: number, e: number) => void;
216
245
  readonly pingclient_addMembers: (a: number, b: number, c: number, d: number, e: number) => number;
217
246
  readonly pingclient_admitDeviceToChats: (a: number, b: number, c: number, d: number, e: number) => number;
@@ -251,9 +280,9 @@ export interface InitOutput {
251
280
  readonly wasmbindgentestcontext_include_ignored: (a: number, b: number) => void;
252
281
  readonly wasmbindgentestcontext_new: (a: number) => number;
253
282
  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;
283
+ readonly __wasm_bindgen_func_elem_2773: (a: number, b: number, c: number, d: number, e: number) => void;
284
+ readonly __wasm_bindgen_func_elem_2759: (a: number, b: number, c: number, d: number) => void;
285
+ readonly __wasm_bindgen_func_elem_2783: (a: number, b: number, c: number, d: number) => void;
257
286
  readonly __wbindgen_export: (a: number, b: number) => number;
258
287
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
259
288
  readonly __wbindgen_export3: (a: number) => void;
package/wasm/ping_wasm.js CHANGED
@@ -625,6 +625,132 @@ 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
+ * conversation_snapshots, created_at_ms }`. A wrong mnemonic or tampered blob throws.
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
+ * `conversation_snapshots` is a JS array of `{ conversation_id, group_state_bytes }`
659
+ * (both Uint8Array). Pass `[]` for the legacy identity+DeviceGroup-only backup, or
660
+ * populate it (from `exportConversationStateSnapshot`) to restore group chats offline.
661
+ * @param {string} mnemonic_phrase
662
+ * @param {Uint8Array} account_id
663
+ * @param {Uint8Array} identity_export
664
+ * @param {Uint8Array} device_group_snapshot
665
+ * @param {any} conversation_snapshots
666
+ * @param {number} created_at_ms
667
+ * @returns {Uint8Array}
668
+ */
669
+ export function encryptBackup(mnemonic_phrase, account_id, identity_export, device_group_snapshot, conversation_snapshots, created_at_ms) {
670
+ try {
671
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
672
+ const ptr0 = passStringToWasm0(mnemonic_phrase, wasm.__wbindgen_export, wasm.__wbindgen_export2);
673
+ const len0 = WASM_VECTOR_LEN;
674
+ const ptr1 = passArray8ToWasm0(account_id, wasm.__wbindgen_export);
675
+ const len1 = WASM_VECTOR_LEN;
676
+ const ptr2 = passArray8ToWasm0(identity_export, wasm.__wbindgen_export);
677
+ const len2 = WASM_VECTOR_LEN;
678
+ const ptr3 = passArray8ToWasm0(device_group_snapshot, wasm.__wbindgen_export);
679
+ const len3 = WASM_VECTOR_LEN;
680
+ wasm.encryptBackup(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, addHeapObject(conversation_snapshots), created_at_ms);
681
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
682
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
683
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
684
+ if (r2) {
685
+ throw takeObject(r1);
686
+ }
687
+ return takeObject(r0);
688
+ } finally {
689
+ wasm.__wbindgen_add_to_stack_pointer(16);
690
+ }
691
+ }
692
+
693
+ /**
694
+ * Generate a fresh 12-word BIP39 mnemonic, returned as its canonical phrase string.
695
+ * @returns {string}
696
+ */
697
+ export function generateMnemonicPhrase() {
698
+ let deferred2_0;
699
+ let deferred2_1;
700
+ try {
701
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
702
+ wasm.generateMnemonicPhrase(retptr);
703
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
704
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
705
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
706
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
707
+ var ptr1 = r0;
708
+ var len1 = r1;
709
+ if (r3) {
710
+ ptr1 = 0; len1 = 0;
711
+ throw takeObject(r2);
712
+ }
713
+ deferred2_0 = ptr1;
714
+ deferred2_1 = len1;
715
+ return getStringFromWasm0(ptr1, len1);
716
+ } finally {
717
+ wasm.__wbindgen_add_to_stack_pointer(16);
718
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
719
+ }
720
+ }
721
+
722
+ /**
723
+ * Validate + canonicalise a user-entered phrase (BIP39 wordlist + checksum).
724
+ * @param {string} phrase
725
+ * @returns {string}
726
+ */
727
+ export function normalizeMnemonicPhrase(phrase) {
728
+ let deferred3_0;
729
+ let deferred3_1;
730
+ try {
731
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
732
+ const ptr0 = passStringToWasm0(phrase, wasm.__wbindgen_export, wasm.__wbindgen_export2);
733
+ const len0 = WASM_VECTOR_LEN;
734
+ wasm.normalizeMnemonicPhrase(retptr, ptr0, len0);
735
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
736
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
737
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
738
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
739
+ var ptr2 = r0;
740
+ var len2 = r1;
741
+ if (r3) {
742
+ ptr2 = 0; len2 = 0;
743
+ throw takeObject(r2);
744
+ }
745
+ deferred3_0 = ptr2;
746
+ deferred3_1 = len2;
747
+ return getStringFromWasm0(ptr2, len2);
748
+ } finally {
749
+ wasm.__wbindgen_add_to_stack_pointer(16);
750
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
751
+ }
752
+ }
753
+
628
754
  /**
629
755
  * @param {Uint8Array} sealed
630
756
  * @param {Uint8Array} new_device_priv
@@ -803,11 +929,11 @@ function __wbg_get_imports() {
803
929
  const ret = getObject(arg0).crypto;
804
930
  return addHeapObject(ret);
805
931
  },
806
- __wbg_del_0c23259b4f1e1a35: function(arg0, arg1, arg2, arg3, arg4) {
932
+ __wbg_del_dd892521518399ee: function(arg0, arg1, arg2, arg3, arg4) {
807
933
  const ret = getObject(arg0).del(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
808
934
  return addHeapObject(ret);
809
935
  },
810
- __wbg_discoverDevices_6602e7a0e4eb5dca: function(arg0, arg1) {
936
+ __wbg_discoverDevices_71844b4a7278884f: function(arg0, arg1) {
811
937
  const ret = getObject(arg0).discoverDevices(takeObject(arg1));
812
938
  return addHeapObject(ret);
813
939
  },
@@ -833,7 +959,7 @@ function __wbg_get_imports() {
833
959
  wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
834
960
  }
835
961
  },
836
- __wbg_fetchSince_9ab9ab87545120a6: function(arg0, arg1, arg2, arg3) {
962
+ __wbg_fetchSince_26646a05d0087e09: function(arg0, arg1, arg2, arg3) {
837
963
  const ret = getObject(arg0).fetchSince(takeObject(arg1), takeObject(arg2), arg3 >>> 0);
838
964
  return addHeapObject(ret);
839
965
  },
@@ -844,7 +970,7 @@ function __wbg_get_imports() {
844
970
  const a = state0.a;
845
971
  state0.a = 0;
846
972
  try {
847
- return __wasm_bindgen_func_elem_2676(a, state0.b, arg0, arg1, arg2);
973
+ return __wasm_bindgen_func_elem_2773(a, state0.b, arg0, arg1, arg2);
848
974
  } finally {
849
975
  state0.a = a;
850
976
  }
@@ -868,10 +994,6 @@ function __wbg_get_imports() {
868
994
  __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
869
995
  getObject(arg0).getRandomValues(getObject(arg1));
870
996
  }, 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
997
  __wbg_get_652f640b3b0b6e3e: function(arg0, arg1) {
876
998
  const ret = getObject(arg0)[arg1 >>> 0];
877
999
  return addHeapObject(ret);
@@ -880,6 +1002,10 @@ function __wbg_get_imports() {
880
1002
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
881
1003
  return addHeapObject(ret);
882
1004
  }, arguments); },
1005
+ __wbg_get_e22763f546129c48: function(arg0, arg1, arg2, arg3, arg4) {
1006
+ const ret = getObject(arg0).get(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
1007
+ return addHeapObject(ret);
1008
+ },
883
1009
  __wbg_get_unchecked_be562b1421656321: function(arg0, arg1) {
884
1010
  const ret = getObject(arg0)[arg1 >>> 0];
885
1011
  return addHeapObject(ret);
@@ -928,7 +1054,7 @@ function __wbg_get_imports() {
928
1054
  const ret = getObject(arg0).length;
929
1055
  return ret;
930
1056
  },
931
- __wbg_listKeys_22139ea835278f2e: function(arg0, arg1, arg2, arg3, arg4) {
1057
+ __wbg_listKeys_43d7d522a7f24fe2: function(arg0, arg1, arg2, arg3, arg4) {
932
1058
  const ret = getObject(arg0).listKeys(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
933
1059
  return addHeapObject(ret);
934
1060
  },
@@ -985,7 +1111,7 @@ function __wbg_get_imports() {
985
1111
  const a = state0.a;
986
1112
  state0.a = 0;
987
1113
  try {
988
- return __wasm_bindgen_func_elem_2675(a, state0.b, arg0, arg1);
1114
+ return __wasm_bindgen_func_elem_2783(a, state0.b, arg0, arg1);
989
1115
  } finally {
990
1116
  state0.a = a;
991
1117
  }
@@ -1035,7 +1161,7 @@ function __wbg_get_imports() {
1035
1161
  __wbg_prototypesetcall_fd4050e806e1d519: function(arg0, arg1, arg2) {
1036
1162
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
1037
1163
  },
1038
- __wbg_put_ebb52697bcf9189a: function(arg0, arg1, arg2, arg3, arg4, arg5) {
1164
+ __wbg_put_74e12966d856a853: function(arg0, arg1, arg2, arg3, arg4, arg5) {
1039
1165
  const ret = getObject(arg0).put(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), takeObject(arg5));
1040
1166
  return addHeapObject(ret);
1041
1167
  },
@@ -1061,11 +1187,11 @@ function __wbg_get_imports() {
1061
1187
  const ret = getObject(arg0).self;
1062
1188
  return isLikeNone(ret) ? 0 : addHeapObject(ret);
1063
1189
  },
1064
- __wbg_send_a5e0c4c86eab668f: function(arg0, arg1) {
1190
+ __wbg_send_c848975ec4aa009e: function(arg0, arg1) {
1065
1191
  const ret = getObject(arg0).send(takeObject(arg1));
1066
1192
  return addHeapObject(ret);
1067
1193
  },
1068
- __wbg_setNextWelcomeRecipients_7d5369b904c404dd: function(arg0, arg1, arg2) {
1194
+ __wbg_setNextWelcomeRecipients_a4fdc30ee7a97d64: function(arg0, arg1, arg2) {
1069
1195
  const ret = getObject(arg0).setNextWelcomeRecipients(takeObject(arg1), takeObject(arg2));
1070
1196
  return addHeapObject(ret);
1071
1197
  },
@@ -1162,8 +1288,8 @@ function __wbg_get_imports() {
1162
1288
  return addHeapObject(ret);
1163
1289
  },
1164
1290
  __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);
1291
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 776, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1292
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2759);
1167
1293
  return addHeapObject(ret);
1168
1294
  },
1169
1295
  __wbindgen_cast_0000000000000002: function(arg0) {
@@ -1207,10 +1333,10 @@ function __wbg_get_imports() {
1207
1333
  };
1208
1334
  }
1209
1335
 
1210
- function __wasm_bindgen_func_elem_2666(arg0, arg1, arg2) {
1336
+ function __wasm_bindgen_func_elem_2759(arg0, arg1, arg2) {
1211
1337
  try {
1212
1338
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1213
- wasm.__wasm_bindgen_func_elem_2666(retptr, arg0, arg1, addHeapObject(arg2));
1339
+ wasm.__wasm_bindgen_func_elem_2759(retptr, arg0, arg1, addHeapObject(arg2));
1214
1340
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1215
1341
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1216
1342
  if (r1) {
@@ -1221,12 +1347,12 @@ function __wasm_bindgen_func_elem_2666(arg0, arg1, arg2) {
1221
1347
  }
1222
1348
  }
1223
1349
 
1224
- function __wasm_bindgen_func_elem_2675(arg0, arg1, arg2, arg3) {
1225
- wasm.__wasm_bindgen_func_elem_2675(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1350
+ function __wasm_bindgen_func_elem_2783(arg0, arg1, arg2, arg3) {
1351
+ wasm.__wasm_bindgen_func_elem_2783(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1226
1352
  }
1227
1353
 
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));
1354
+ function __wasm_bindgen_func_elem_2773(arg0, arg1, arg2, arg3, arg4) {
1355
+ wasm.__wasm_bindgen_func_elem_2773(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
1230
1356
  }
1231
1357
 
1232
1358
  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, k: 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_2773: (a: number, b: number, c: number, d: number, e: number) => void;
50
+ export const __wasm_bindgen_func_elem_2759: (a: number, b: number, c: number, d: number) => void;
51
+ export const __wasm_bindgen_func_elem_2783: (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;