@wireapp/core-crypto 11.0.2 → 11.0.3-pre.1

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.
@@ -924,7 +924,7 @@ export const sqlite3_os_init: () => number;
924
924
  export const __wbg_jspi_task_poll: (a: number) => void;
925
925
  export const _RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtB8_7JsValueINtNtCs4NIexwV1FGX_4core6result6ResultuNtB8_7JsErrorEKb1_ECs6OPVFd5KbZe_6js_sys: (a: number, b: number, c: any) => [number, number];
926
926
  export const _RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress4_1__6invokeINtCs6OPVFd5KbZe_6js_sys8FunctionFNtB8_7JsValueENtNtB8_3sys9UndefinedEB14_uKb1_EB17_: (a: number, b: number, c: any, d: any) => void;
927
- export const _RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtNtNtCs4g1QEnyMkXh_7web_sys8features25gen_IdbVersionChangeEvent21IdbVersionChangeEventuKb1_ECsl3EkdlbQ3RX_20core_crypto_keystore: (a: number, b: number, c: any) => void;
927
+ export const _RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtNtNtCs4g1QEnyMkXh_7web_sys8features25gen_IdbVersionChangeEvent21IdbVersionChangeEventuKb1_ECs7Sp0DWqkN97_20core_crypto_keystore: (a: number, b: number, c: any) => void;
928
928
  export const _RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtNtNtCs4g1QEnyMkXh_7web_sys8features9gen_Event5EventuKb1_ECsbZGnklYUYj7_3idb: (a: number, b: number, c: any) => void;
929
929
  export const __wbindgen_malloc: (a: number, b: number) => number;
930
930
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
@@ -477,7 +477,7 @@ __export(exports_wasm_bindgen, {
477
477
  ForeignFutureCompleteF32: () => ForeignFutureCompleteF32
478
478
  });
479
479
 
480
- // packages/browser/src/autogenerated/wasm-bindgen/snippets/core-crypto-keystore-7fe48724e8e174ed/src/connection/opfs_vfs.js
480
+ // packages/browser/src/autogenerated/wasm-bindgen/snippets/core-crypto-keystore-e943b0ffabf6d59f/src/connection/opfs_vfs.js
481
481
  var exports_opfs_vfs = {};
482
482
  __export(exports_opfs_vfs, {
483
483
  write: () => write,
@@ -637,34 +637,81 @@ function fail(error) {
637
637
  inflight?.reject(error);
638
638
  inflight = undefined;
639
639
  }
640
- async function start(directory) {
640
+ async function start(directory, timeoutMilliseconds) {
641
641
  if (!globalThis.navigator?.storage?.getDirectory || !Wasm.Suspending || !Wasm.promising) {
642
642
  throw new Error("OPFS and JSPI are required");
643
643
  }
644
+ const firstTimeoutError = createStartupTimeoutError(timeoutMilliseconds);
645
+ try {
646
+ await startWorker({ directory, timeoutMilliseconds, timeoutError: firstTimeoutError });
647
+ } catch (firstFailure) {
648
+ if (firstFailure !== firstTimeoutError) {
649
+ throw firstFailure;
650
+ }
651
+ const retryTimeoutError = createStartupTimeoutError(timeoutMilliseconds);
652
+ try {
653
+ await startWorker({ directory, timeoutMilliseconds, timeoutError: retryTimeoutError });
654
+ } catch (retryFailure) {
655
+ const retryMessage = retryFailure instanceof Error ? `${retryFailure.name}: ${retryFailure.message}` : String(retryFailure);
656
+ throw new Error(`${firstTimeoutError.message}; retry failed: ${retryMessage}`, { cause: retryFailure });
657
+ }
658
+ }
659
+ }
660
+ function createStartupTimeoutError(timeoutMilliseconds) {
661
+ const timeoutError = new Error(`OPFS worker initialization timed out after ${timeoutMilliseconds} ms`);
662
+ timeoutError.name = "OpfsWorkerStartupTimeout";
663
+ return timeoutError;
664
+ }
665
+ async function startWorker({ directory, timeoutMilliseconds, timeoutError }) {
644
666
  const url = URL.createObjectURL(new Blob([`(${workerMain})();`], { type: "text/javascript" }));
667
+ let attemptWorker;
645
668
  try {
646
- worker = new Worker(url);
669
+ attemptWorker = new Worker(url);
647
670
  } finally {
648
671
  URL.revokeObjectURL(url);
649
672
  }
650
- worker.onmessage = ({ data: { seq, value, error } }) => {
651
- if (inflight?.seq !== seq)
673
+ worker = attemptWorker;
674
+ attemptWorker.onmessage = function handleWorkerMessage({ data: { seq, value, error } }) {
675
+ if (worker !== attemptWorker || inflight?.seq !== seq) {
652
676
  return;
677
+ }
653
678
  const call = inflight;
654
679
  inflight = undefined;
655
- if (error)
680
+ if (error) {
656
681
  call.reject(new DOMException(error.message, error.name));
657
- else
682
+ } else {
658
683
  call.resolve(value);
684
+ }
659
685
  };
660
- worker.onerror = (event) => fail(new Error(event.message || "OPFS worker failed"));
661
- worker.onmessageerror = () => fail(new Error("OPFS worker message could not be decoded"));
686
+ attemptWorker.onerror = function handleWorkerError(event) {
687
+ if (worker !== attemptWorker) {
688
+ return;
689
+ }
690
+ fail(new Error(event.message || "OPFS worker failed"));
691
+ };
692
+ attemptWorker.onmessageerror = function handleWorkerMessageError() {
693
+ if (worker !== attemptWorker) {
694
+ return;
695
+ }
696
+ fail(new Error("OPFS worker message could not be decoded"));
697
+ };
698
+ const initPromise = rpc("init", [directory]);
699
+ const initSequence = inflight?.seq;
700
+ const timer = setTimeout(function handleStartupTimeout() {
701
+ if (worker === attemptWorker && inflight?.seq === initSequence) {
702
+ fail(timeoutError);
703
+ }
704
+ }, timeoutMilliseconds);
662
705
  try {
663
- await rpc("init", [directory]);
664
- } catch (error) {
665
- worker.terminate();
666
- worker = undefined;
667
- throw error;
706
+ await initPromise;
707
+ } catch (failure) {
708
+ attemptWorker.terminate();
709
+ if (worker === attemptWorker) {
710
+ worker = undefined;
711
+ }
712
+ throw failure;
713
+ } finally {
714
+ clearTimeout(timer);
668
715
  }
669
716
  }
670
717
  function abandon() {
@@ -3296,7 +3343,7 @@ function __wbg_get_imports() {
3296
3343
  var ptr1 = ret.__destroy_into_raw();
3297
3344
  return ptr1;
3298
3345
  },
3299
- __wbg_clearTimeout_6db2c7091cc66280: function(arg0) {
3346
+ __wbg_clearTimeout_0b80e73d6538aa01: function(arg0) {
3300
3347
  clearTimeout(arg0);
3301
3348
  },
3302
3349
  __wbg_close_39a0adee471336e2: function(arg0) {
@@ -3411,7 +3458,7 @@ function __wbg_get_imports() {
3411
3458
  const ret = arg0.execute;
3412
3459
  return ret;
3413
3460
  },
3414
- __wbg_exists_389a4c01e8b3531f: function(arg0, arg1) {
3461
+ __wbg_exists_b056056c61e4b726: function(arg0, arg1) {
3415
3462
  const ret = exists(getStringFromWasm0(arg0, arg1));
3416
3463
  return ret;
3417
3464
  },
@@ -3793,7 +3840,7 @@ function __wbg_get_imports() {
3793
3840
  return ret;
3794
3841
  }, arguments);
3795
3842
  },
3796
- __wbg_open_5a607260231fba95: function(arg0, arg1, arg2) {
3843
+ __wbg_open_98a596871edb5d46: function(arg0, arg1, arg2) {
3797
3844
  const ret = open(getStringFromWasm0(arg0, arg1), arg2 !== 0);
3798
3845
  return ret;
3799
3846
  },
@@ -3850,7 +3897,7 @@ function __wbg_get_imports() {
3850
3897
  const ret = Math.random();
3851
3898
  return ret;
3852
3899
  },
3853
- __wbg_remove_e5a149a356da1a1c: function(arg0, arg1) {
3900
+ __wbg_remove_76208baeab113958: function(arg0, arg1) {
3854
3901
  const ret = remove(getStringFromWasm0(arg0, arg1));
3855
3902
  return ret;
3856
3903
  },
@@ -3921,7 +3968,7 @@ function __wbg_get_imports() {
3921
3968
  const ret = arg0.send_commit_bundle;
3922
3969
  return ret;
3923
3970
  },
3924
- __wbg_setTimeout_425a75b085da4e10: function(arg0, arg1) {
3971
+ __wbg_setTimeout_243de2a790c76eb8: function(arg0, arg1) {
3925
3972
  const ret = setTimeout(arg0, arg1);
3926
3973
  return ret;
3927
3974
  },
@@ -3977,8 +4024,8 @@ function __wbg_get_imports() {
3977
4024
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
3978
4025
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3979
4026
  },
3980
- __wbg_start_b3eef0d78e5310b2: function(arg0, arg1) {
3981
- const ret = start(getStringFromWasm0(arg0, arg1));
4027
+ __wbg_start_4e876c7c65d7a647: function(arg0, arg1, arg2) {
4028
+ const ret = start(getStringFromWasm0(arg0, arg1), arg2 >>> 0);
3982
4029
  return ret;
3983
4030
  },
3984
4031
  __wbg_static_accessor_GLOBAL_8eb4cd83130a11a0: function() {
@@ -4102,7 +4149,7 @@ function __wbg_get_imports() {
4102
4149
  return ret;
4103
4150
  },
4104
4151
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
4105
- const ret = makeMutClosure(arg0, arg1, _RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtNtNtCs4g1QEnyMkXh_7web_sys8features25gen_IdbVersionChangeEvent21IdbVersionChangeEventuKb1_ECsl3EkdlbQ3RX_20core_crypto_keystore);
4152
+ const ret = makeMutClosure(arg0, arg1, _RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtNtNtCs4g1QEnyMkXh_7web_sys8features25gen_IdbVersionChangeEvent21IdbVersionChangeEventuKb1_ECs7Sp0DWqkN97_20core_crypto_keystore);
4106
4153
  return ret;
4107
4154
  },
4108
4155
  __wbindgen_generic_0000000000000004: function(arg0) {
@@ -4145,21 +4192,21 @@ function __wbg_get_imports() {
4145
4192
  return {
4146
4193
  __proto__: null,
4147
4194
  "./index_bg.js": import0,
4148
- "./snippets/core-crypto-keystore-7fe48724e8e174ed/src/connection/opfs_vfs.js": exports_opfs_vfs,
4149
- "./snippets/core-crypto-keystore-7fe48724e8e174ed/src/connection/opfs_vfs.js": exports_opfs_vfs,
4150
- "./snippets/core-crypto-keystore-7fe48724e8e174ed/src/connection/opfs_vfs.js": exports_opfs_vfs,
4151
- "./snippets/core-crypto-keystore-7fe48724e8e174ed/src/connection/opfs_vfs.js": exports_opfs_vfs,
4152
- "./snippets/core-crypto-keystore-7fe48724e8e174ed/src/connection/opfs_vfs.js": exports_opfs_vfs,
4153
- "./snippets/core-crypto-keystore-7fe48724e8e174ed/src/connection/opfs_vfs.js": exports_opfs_vfs,
4154
- "./snippets/core-crypto-keystore-7fe48724e8e174ed/src/connection/opfs_vfs.js": exports_opfs_vfs,
4155
- "./snippets/core-crypto-keystore-7fe48724e8e174ed/src/connection/opfs_vfs.js": exports_opfs_vfs
4195
+ "./snippets/core-crypto-keystore-e943b0ffabf6d59f/src/connection/opfs_vfs.js": exports_opfs_vfs,
4196
+ "./snippets/core-crypto-keystore-e943b0ffabf6d59f/src/connection/opfs_vfs.js": exports_opfs_vfs,
4197
+ "./snippets/core-crypto-keystore-e943b0ffabf6d59f/src/connection/opfs_vfs.js": exports_opfs_vfs,
4198
+ "./snippets/core-crypto-keystore-e943b0ffabf6d59f/src/connection/opfs_vfs.js": exports_opfs_vfs,
4199
+ "./snippets/core-crypto-keystore-e943b0ffabf6d59f/src/connection/opfs_vfs.js": exports_opfs_vfs,
4200
+ "./snippets/core-crypto-keystore-e943b0ffabf6d59f/src/connection/opfs_vfs.js": exports_opfs_vfs,
4201
+ "./snippets/core-crypto-keystore-e943b0ffabf6d59f/src/connection/opfs_vfs.js": exports_opfs_vfs,
4202
+ "./snippets/core-crypto-keystore-e943b0ffabf6d59f/src/connection/opfs_vfs.js": exports_opfs_vfs
4156
4203
  };
4157
4204
  }
4158
4205
  function _RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtNtNtCs4g1QEnyMkXh_7web_sys8features9gen_Event5EventuKb1_ECsbZGnklYUYj7_3idb(arg0, arg1, arg2) {
4159
4206
  wasm2._RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtNtNtCs4g1QEnyMkXh_7web_sys8features9gen_Event5EventuKb1_ECsbZGnklYUYj7_3idb(arg0, arg1, arg2);
4160
4207
  }
4161
- function _RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtNtNtCs4g1QEnyMkXh_7web_sys8features25gen_IdbVersionChangeEvent21IdbVersionChangeEventuKb1_ECsl3EkdlbQ3RX_20core_crypto_keystore(arg0, arg1, arg2) {
4162
- wasm2._RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtNtNtCs4g1QEnyMkXh_7web_sys8features25gen_IdbVersionChangeEvent21IdbVersionChangeEventuKb1_ECsl3EkdlbQ3RX_20core_crypto_keystore(arg0, arg1, arg2);
4208
+ function _RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtNtNtCs4g1QEnyMkXh_7web_sys8features25gen_IdbVersionChangeEvent21IdbVersionChangeEventuKb1_ECs7Sp0DWqkN97_20core_crypto_keystore(arg0, arg1, arg2) {
4209
+ wasm2._RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtNtNtCs4g1QEnyMkXh_7web_sys8features25gen_IdbVersionChangeEvent21IdbVersionChangeEventuKb1_ECs7Sp0DWqkN97_20core_crypto_keystore(arg0, arg1, arg2);
4163
4210
  }
4164
4211
  function _RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtB8_7JsValueINtNtCs4NIexwV1FGX_4core6result6ResultuNtB8_7JsErrorEKb1_ECs6OPVFd5KbZe_6js_sys(arg0, arg1, arg2) {
4165
4212
  const ret = wasm2._RINvNvNtNtCseJanozDyQMl_12wasm_bindgen7convert8closuress2_1__6invokeNtB8_7JsValueINtNtCs4NIexwV1FGX_4core6result6ResultuNtB8_7JsErrorEKb1_ECs6OPVFd5KbZe_6js_sys(arg0, arg1, arg2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wireapp/core-crypto",
3
- "version": "11.0.2",
3
+ "version": "11.0.3-pre.1",
4
4
  "description": "CoreCrypto bindings for browser JavaScript runtimes",
5
5
  "keywords": [
6
6
  "corecrypto",