@waaskey/sdk 0.3.0 → 0.3.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.
package/dist/index.cjs CHANGED
@@ -2375,14 +2375,30 @@ function createVerifiedClientWasmLoader(options) {
2375
2375
  return mod;
2376
2376
  };
2377
2377
  }
2378
+ var clientWasm;
2378
2379
  var loadClientWasm = async () => {
2380
+ return clientWasm ??= importAndInit();
2381
+ };
2382
+ async function importAndInit() {
2383
+ let mod;
2379
2384
  try {
2380
- const mod = await import(CLIENT_WASM_PACKAGE);
2381
- return mod;
2385
+ mod = await import(CLIENT_WASM_PACKAGE);
2382
2386
  } catch (cause) {
2383
2387
  throw new Error("Waaskey: creating a wallet needs the wasm engine \u2014 install '@waaskey/client-wasm' alongside '@waaskey/sdk'.", { cause });
2384
2388
  }
2385
- };
2389
+ const init = mod["default"] ?? mod["init"];
2390
+ if (typeof init === "function") {
2391
+ try {
2392
+ await init();
2393
+ } catch (cause) {
2394
+ throw new Error(
2395
+ "Waaskey: the wasm engine failed to initialize. In the browser this loader fetches the `.wasm` next to the module \u2014 serve it, or pass a loader built with `createVerifiedClientWasmLoader({ wasmUrl, expectedSha384 })`. On Node use `NodeWorkerMpcCore` from `@waaskey/sdk/node`, which loads the binary from disk in a worker thread.",
2396
+ { cause }
2397
+ );
2398
+ }
2399
+ }
2400
+ return mod;
2401
+ }
2386
2402
  function toBase64(bytes) {
2387
2403
  let binary = "";
2388
2404
  for (const byte of bytes) binary += String.fromCharCode(byte);