@waaskey/sdk 0.1.0 → 0.2.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
@@ -559,12 +559,12 @@ declare class WasmMpcCore implements MpcCore {
559
559
  * lockstep with the `@waaskey/client-wasm` entry in `package.json` and with
560
560
  * {@link CLIENT_WASM_SHA384}.
561
561
  *
562
- * **`0.2.0` adds the ed25519 (FROST) exports** (`keygenEddsa` / `signEddsa`, waas-core #110) the SDK's
563
- * ed25519 wallet path drives. It is **published on npm** (`client-wasm-v0.2.0`) and pinned as the SDK's
562
+ * **`0.2.x` adds the ed25519 (FROST) exports** (`keygenEddsa` / `signEddsa`, waas-core #110) the SDK's
563
+ * ed25519 wallet path drives. It is **published on npm** (`client-wasm-v0.2.1`) and pinned as the SDK's
564
564
  * exact, optional peer dependency in `package.json` — so an app that installs `@waaskey/client-wasm`
565
565
  * alongside the SDK runs the real ed25519 create/send path end to end.
566
566
  */
567
- declare const CLIENT_WASM_VERSION = "0.2.0";
567
+ declare const CLIENT_WASM_VERSION = "0.2.1";
568
568
  /**
569
569
  * Verify the integrity of raw wasm bytes against an expected **SHA-384** hash, in
570
570
  * Subresource-Integrity (`sha384-<base64>`) form (issue #40).
@@ -658,11 +658,21 @@ interface PrimePoolOptions {
658
658
  targetSize?: number;
659
659
  /** Persistence for the pool. Defaults to an in-memory store. */
660
660
  store?: PrimePoolStore;
661
+ /**
662
+ * Kick off a refill automatically after every {@link PrimePool.take}. Default `false`:
663
+ * unless the core generates primes in a Web Worker, wasm prime generation is a
664
+ * synchronous CPU burn on the calling thread — a "background" refill starves the event
665
+ * loop and stalls the very keygen ceremony the take() was for (it also freezes a
666
+ * browser UI). Refill explicitly via {@link PrimePool.ensure} (`wallets.prewarm`) at
667
+ * boot/idle, or set `true` only when the core is worker-backed.
668
+ */
669
+ autoRefill?: boolean;
661
670
  }
662
671
  declare class PrimePool {
663
672
  private readonly core;
664
673
  private readonly store;
665
674
  private readonly targetSize;
675
+ private readonly autoRefill;
666
676
  /** Per-curve in-flight refill, so concurrent calls don't over-generate. */
667
677
  private readonly refilling;
668
678
  constructor(core: PrimeGenerator, options?: PrimePoolOptions);
@@ -674,8 +684,9 @@ declare class PrimePool {
674
684
  private refill;
675
685
  /**
676
686
  * Claim a prime for a keygen. Returns a cached one instantly when the pool is warm; otherwise
677
- * generates one inline (the slow fallback) so keygen never fails on an empty pool. Either way it
678
- * kicks off a background refill so the next wallet is instant.
687
+ * generates one inline (the slow fallback) so keygen never fails on an empty pool. Refill the
688
+ * pool for the next wallet via {@link ensure} at idle (or opt into `autoRefill` when the core
689
+ * is worker-backed).
679
690
  */
680
691
  take(curve: MpcCurve): Promise<string>;
681
692
  }
@@ -880,6 +891,12 @@ interface WaaskeyOptions {
880
891
  * `EncryptedShareStore.browser(secret)`). Required to create a wallet.
881
892
  */
882
893
  shareStore?: ShareStore;
894
+ /**
895
+ * Optional pool of pre-generated Paillier primes (`new PrimePool(mpc)`). When set,
896
+ * `wallets.prewarm(chain)` fills it off the hot path and `wallets.create` claims from
897
+ * it instead of generating inline — turning minutes of keygen into seconds.
898
+ */
899
+ primePool?: PrimePool;
883
900
  /**
884
901
  * Per-chain provider config for client-side balance reads (RPC URL or a custom
885
902
  * provider). EVM chains have built-in public-RPC defaults; override them here.
@@ -2193,6 +2210,13 @@ declare class Wallets {
2193
2210
  * No-op when no prime pool is configured.
2194
2211
  */
2195
2212
  prewarm(chain: CreateWalletParams['chain']): Promise<void>;
2213
+ /**
2214
+ * List the tenant's wallets, newest first (paginated). Returns plain {@link WalletData}
2215
+ * rows — pass an `id` to {@link get} to obtain a signing-capable {@link Wallet}.
2216
+ */
2217
+ list(query?: PageQuery, options?: {
2218
+ signal?: AbortSignal;
2219
+ }): Promise<Page<WalletData>>;
2196
2220
  /** Load an existing wallet by id. */
2197
2221
  get(id: string, options?: {
2198
2222
  signal?: AbortSignal;
package/dist/index.d.ts CHANGED
@@ -559,12 +559,12 @@ declare class WasmMpcCore implements MpcCore {
559
559
  * lockstep with the `@waaskey/client-wasm` entry in `package.json` and with
560
560
  * {@link CLIENT_WASM_SHA384}.
561
561
  *
562
- * **`0.2.0` adds the ed25519 (FROST) exports** (`keygenEddsa` / `signEddsa`, waas-core #110) the SDK's
563
- * ed25519 wallet path drives. It is **published on npm** (`client-wasm-v0.2.0`) and pinned as the SDK's
562
+ * **`0.2.x` adds the ed25519 (FROST) exports** (`keygenEddsa` / `signEddsa`, waas-core #110) the SDK's
563
+ * ed25519 wallet path drives. It is **published on npm** (`client-wasm-v0.2.1`) and pinned as the SDK's
564
564
  * exact, optional peer dependency in `package.json` — so an app that installs `@waaskey/client-wasm`
565
565
  * alongside the SDK runs the real ed25519 create/send path end to end.
566
566
  */
567
- declare const CLIENT_WASM_VERSION = "0.2.0";
567
+ declare const CLIENT_WASM_VERSION = "0.2.1";
568
568
  /**
569
569
  * Verify the integrity of raw wasm bytes against an expected **SHA-384** hash, in
570
570
  * Subresource-Integrity (`sha384-<base64>`) form (issue #40).
@@ -658,11 +658,21 @@ interface PrimePoolOptions {
658
658
  targetSize?: number;
659
659
  /** Persistence for the pool. Defaults to an in-memory store. */
660
660
  store?: PrimePoolStore;
661
+ /**
662
+ * Kick off a refill automatically after every {@link PrimePool.take}. Default `false`:
663
+ * unless the core generates primes in a Web Worker, wasm prime generation is a
664
+ * synchronous CPU burn on the calling thread — a "background" refill starves the event
665
+ * loop and stalls the very keygen ceremony the take() was for (it also freezes a
666
+ * browser UI). Refill explicitly via {@link PrimePool.ensure} (`wallets.prewarm`) at
667
+ * boot/idle, or set `true` only when the core is worker-backed.
668
+ */
669
+ autoRefill?: boolean;
661
670
  }
662
671
  declare class PrimePool {
663
672
  private readonly core;
664
673
  private readonly store;
665
674
  private readonly targetSize;
675
+ private readonly autoRefill;
666
676
  /** Per-curve in-flight refill, so concurrent calls don't over-generate. */
667
677
  private readonly refilling;
668
678
  constructor(core: PrimeGenerator, options?: PrimePoolOptions);
@@ -674,8 +684,9 @@ declare class PrimePool {
674
684
  private refill;
675
685
  /**
676
686
  * Claim a prime for a keygen. Returns a cached one instantly when the pool is warm; otherwise
677
- * generates one inline (the slow fallback) so keygen never fails on an empty pool. Either way it
678
- * kicks off a background refill so the next wallet is instant.
687
+ * generates one inline (the slow fallback) so keygen never fails on an empty pool. Refill the
688
+ * pool for the next wallet via {@link ensure} at idle (or opt into `autoRefill` when the core
689
+ * is worker-backed).
679
690
  */
680
691
  take(curve: MpcCurve): Promise<string>;
681
692
  }
@@ -880,6 +891,12 @@ interface WaaskeyOptions {
880
891
  * `EncryptedShareStore.browser(secret)`). Required to create a wallet.
881
892
  */
882
893
  shareStore?: ShareStore;
894
+ /**
895
+ * Optional pool of pre-generated Paillier primes (`new PrimePool(mpc)`). When set,
896
+ * `wallets.prewarm(chain)` fills it off the hot path and `wallets.create` claims from
897
+ * it instead of generating inline — turning minutes of keygen into seconds.
898
+ */
899
+ primePool?: PrimePool;
883
900
  /**
884
901
  * Per-chain provider config for client-side balance reads (RPC URL or a custom
885
902
  * provider). EVM chains have built-in public-RPC defaults; override them here.
@@ -2193,6 +2210,13 @@ declare class Wallets {
2193
2210
  * No-op when no prime pool is configured.
2194
2211
  */
2195
2212
  prewarm(chain: CreateWalletParams['chain']): Promise<void>;
2213
+ /**
2214
+ * List the tenant's wallets, newest first (paginated). Returns plain {@link WalletData}
2215
+ * rows — pass an `id` to {@link get} to obtain a signing-capable {@link Wallet}.
2216
+ */
2217
+ list(query?: PageQuery, options?: {
2218
+ signal?: AbortSignal;
2219
+ }): Promise<Page<WalletData>>;
2196
2220
  /** Load an existing wallet by id. */
2197
2221
  get(id: string, options?: {
2198
2222
  signal?: AbortSignal;
package/dist/index.js CHANGED
@@ -1284,6 +1284,17 @@ var Wallets = class {
1284
1284
  if (curve === "ed25519") return;
1285
1285
  await this.deps.primePool?.ensure(curve);
1286
1286
  }
1287
+ /**
1288
+ * List the tenant's wallets, newest first (paginated). Returns plain {@link WalletData}
1289
+ * rows — pass an `id` to {@link get} to obtain a signing-capable {@link Wallet}.
1290
+ */
1291
+ async list(query = {}, options = {}) {
1292
+ const qs = new URLSearchParams();
1293
+ if (query.page !== void 0) qs.set("page", String(query.page));
1294
+ if (query.limit !== void 0) qs.set("limit", String(query.limit));
1295
+ const suffix = qs.toString() ? `?${qs}` : "";
1296
+ return this.http.request("GET", `/v1/wallets${suffix}`, void 0, options.signal);
1297
+ }
1287
1298
  /** Load an existing wallet by id. */
1288
1299
  async get(id, options = {}) {
1289
1300
  const data = await this.http.request("GET", `/v1/wallets/${id}`, void 0, options.signal);
@@ -1866,7 +1877,7 @@ var Waaskey = class {
1866
1877
  this.auth = new Auth(http);
1867
1878
  this.members = new Members(http);
1868
1879
  http.useMemberAccessToken(() => this.members.accessToken);
1869
- this.wallets = new Wallets(http, { mpc: options.mpc, shareStore: options.shareStore, analytics });
1880
+ this.wallets = new Wallets(http, { mpc: options.mpc, shareStore: options.shareStore, primePool: options.primePool, analytics });
1870
1881
  this.recovery = new Recovery(http, { shareStore: options.shareStore, analytics });
1871
1882
  this.reshare = new Reshare(http, { mpc: options.mpc, shareStore: options.shareStore, analytics });
1872
1883
  this.balances = new Balances(options.chains, options.fetch);
@@ -2204,7 +2215,7 @@ function decodePublicKey(sharedPublicKeyJson) {
2204
2215
 
2205
2216
  // src/mpc/load-wasm.ts
2206
2217
  var CLIENT_WASM_PACKAGE = "@waaskey/client-wasm";
2207
- var CLIENT_WASM_VERSION = "0.2.0";
2218
+ var CLIENT_WASM_VERSION = "0.2.1";
2208
2219
  async function verifyWasmIntegrity(bytes, expectedSha384) {
2209
2220
  if (!expectedSha384 || !expectedSha384.startsWith("sha384-")) {
2210
2221
  throw new Error("Waaskey: an expected SHA-384 integrity hash (sha384-<base64>) is required to load the wasm MPC core.");
@@ -2287,10 +2298,12 @@ var PrimePool = class {
2287
2298
  this.core = core;
2288
2299
  this.store = options.store ?? new MemoryPrimeStore();
2289
2300
  this.targetSize = Math.max(1, options.targetSize ?? 2);
2301
+ this.autoRefill = options.autoRefill ?? false;
2290
2302
  }
2291
2303
  core;
2292
2304
  store;
2293
2305
  targetSize;
2306
+ autoRefill;
2294
2307
  /** Per-curve in-flight refill, so concurrent calls don't over-generate. */
2295
2308
  refilling = /* @__PURE__ */ new Map();
2296
2309
  /**
@@ -2311,13 +2324,14 @@ var PrimePool = class {
2311
2324
  }
2312
2325
  /**
2313
2326
  * Claim a prime for a keygen. Returns a cached one instantly when the pool is warm; otherwise
2314
- * generates one inline (the slow fallback) so keygen never fails on an empty pool. Either way it
2315
- * kicks off a background refill so the next wallet is instant.
2327
+ * generates one inline (the slow fallback) so keygen never fails on an empty pool. Refill the
2328
+ * pool for the next wallet via {@link ensure} at idle (or opt into `autoRefill` when the core
2329
+ * is worker-backed).
2316
2330
  */
2317
2331
  async take(curve) {
2318
2332
  const cached = await this.store.take(curve);
2319
2333
  const primes = cached ?? await this.core.pregeneratePrimes(curve);
2320
- void this.ensure(curve).catch(() => void 0);
2334
+ if (this.autoRefill) void this.ensure(curve).catch(() => void 0);
2321
2335
  return primes;
2322
2336
  }
2323
2337
  };