@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.d.cts CHANGED
@@ -609,24 +609,6 @@ interface VerifiedWasmLoaderOptions {
609
609
  * ```
610
610
  */
611
611
  declare function createVerifiedClientWasmLoader(options: VerifiedWasmLoaderOptions): ClientWasmLoader;
612
- /**
613
- * Convenience loader for the Waaskey client-wasm engine — dynamically imports `@waaskey/client-wasm`
614
- * (the wasm-pack/bundler build, auto-initialized on import) and returns it as a {@link ClientWasmModule}:
615
- *
616
- * ```ts
617
- * import { Waaskey, WasmMpcCore, loadClientWasm } from '@waaskey/sdk';
618
- * const waaskey = new Waaskey({ apiKey, mpc: new WasmMpcCore(loadClientWasm), shareStore });
619
- * ```
620
- *
621
- * ⚠️ **No integrity verification (issue #40).** A bundler-target build instantiates the wasm on
622
- * import, so its bytes cannot be checked first. For production — where a registry compromise or
623
- * dependency-confusion attack on `@waaskey/client-wasm` could exfiltrate the plaintext device share
624
- * — use {@link createVerifiedClientWasmLoader} with a vendored `.wasm` and the pinned SHA-384 instead.
625
- *
626
- * `@waaskey/client-wasm` is an OPTIONAL peer dependency pinned to {@link CLIENT_WASM_VERSION}: install
627
- * it alongside the SDK in apps that create wallets. The indirect import specifier keeps it out of
628
- * static module resolution — so a missing install fails here with an actionable message, not at build.
629
- */
630
612
  declare const loadClientWasm: ClientWasmLoader;
631
613
 
632
614
  /**
package/dist/index.d.ts CHANGED
@@ -609,24 +609,6 @@ interface VerifiedWasmLoaderOptions {
609
609
  * ```
610
610
  */
611
611
  declare function createVerifiedClientWasmLoader(options: VerifiedWasmLoaderOptions): ClientWasmLoader;
612
- /**
613
- * Convenience loader for the Waaskey client-wasm engine — dynamically imports `@waaskey/client-wasm`
614
- * (the wasm-pack/bundler build, auto-initialized on import) and returns it as a {@link ClientWasmModule}:
615
- *
616
- * ```ts
617
- * import { Waaskey, WasmMpcCore, loadClientWasm } from '@waaskey/sdk';
618
- * const waaskey = new Waaskey({ apiKey, mpc: new WasmMpcCore(loadClientWasm), shareStore });
619
- * ```
620
- *
621
- * ⚠️ **No integrity verification (issue #40).** A bundler-target build instantiates the wasm on
622
- * import, so its bytes cannot be checked first. For production — where a registry compromise or
623
- * dependency-confusion attack on `@waaskey/client-wasm` could exfiltrate the plaintext device share
624
- * — use {@link createVerifiedClientWasmLoader} with a vendored `.wasm` and the pinned SHA-384 instead.
625
- *
626
- * `@waaskey/client-wasm` is an OPTIONAL peer dependency pinned to {@link CLIENT_WASM_VERSION}: install
627
- * it alongside the SDK in apps that create wallets. The indirect import specifier keeps it out of
628
- * static module resolution — so a missing install fails here with an actionable message, not at build.
629
- */
630
612
  declare const loadClientWasm: ClientWasmLoader;
631
613
 
632
614
  /**
package/dist/index.js CHANGED
@@ -2373,14 +2373,30 @@ function createVerifiedClientWasmLoader(options) {
2373
2373
  return mod;
2374
2374
  };
2375
2375
  }
2376
+ var clientWasm;
2376
2377
  var loadClientWasm = async () => {
2378
+ return clientWasm ??= importAndInit();
2379
+ };
2380
+ async function importAndInit() {
2381
+ let mod;
2377
2382
  try {
2378
- const mod = await import(CLIENT_WASM_PACKAGE);
2379
- return mod;
2383
+ mod = await import(CLIENT_WASM_PACKAGE);
2380
2384
  } catch (cause) {
2381
2385
  throw new Error("Waaskey: creating a wallet needs the wasm engine \u2014 install '@waaskey/client-wasm' alongside '@waaskey/sdk'.", { cause });
2382
2386
  }
2383
- };
2387
+ const init = mod["default"] ?? mod["init"];
2388
+ if (typeof init === "function") {
2389
+ try {
2390
+ await init();
2391
+ } catch (cause) {
2392
+ throw new Error(
2393
+ "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.",
2394
+ { cause }
2395
+ );
2396
+ }
2397
+ }
2398
+ return mod;
2399
+ }
2384
2400
  function toBase64(bytes) {
2385
2401
  let binary = "";
2386
2402
  for (const byte of bytes) binary += String.fromCharCode(byte);