@sparkvault/sdk-js 8.10.1 → 8.10.2

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.
@@ -19,8 +19,16 @@ export declare class EntropyModule {
19
19
  /**
20
20
  * Generate `n` random bytes as a Uint8Array.
21
21
  *
22
+ * SECURITY: this returns raw *server* entropy — it is NOT finished key
23
+ * material. Client secret keys MUST hybrid-mix it: XOR the returned bytes with
24
+ * a local CSPRNG (`crypto.getRandomValues`) before use, so the server share
25
+ * alone can never determine the key.
26
+ *
22
27
  * @example
23
- * const key = await sv.entropy.generateBytes(32);
28
+ * const serverEntropy = await sv.entropy.generateBytes(32);
29
+ * const localEntropy = crypto.getRandomValues(new Uint8Array(32));
30
+ * // Hybrid-mixed key material — safe to use as a secret key.
31
+ * const key = serverEntropy.map((b, i) => b ^ localEntropy[i]);
24
32
  */
25
33
  generateBytes(n: number): Promise<Uint8Array>;
26
34
  private validateByteCount;
package/dist/index.d.ts CHANGED
@@ -634,6 +634,20 @@ interface VaultSummary {
634
634
  /** Total storage used in bytes */
635
635
  storageBytes: number;
636
636
  }
637
+ /** Options for list. */
638
+ interface ListVaultsOptions {
639
+ /** Page size (1–500; server default 100) */
640
+ limit?: number;
641
+ /** Pagination cursor from a prior page's `nextCursor` */
642
+ cursor?: string;
643
+ }
644
+ /** A page of vaults. */
645
+ interface VaultPage {
646
+ /** Vaults on this page */
647
+ vaults: VaultSummary[];
648
+ /** Cursor for the next page, when more results exist */
649
+ nextCursor?: string;
650
+ }
637
651
  /** A single vault's detail, as returned by get. */
638
652
  interface VaultDetail {
639
653
  /** Vault ID */
@@ -914,13 +928,18 @@ declare class VaultsModule {
914
928
  */
915
929
  unseal(vaultId: string, vmk: string): Promise<UnsealedVault>;
916
930
  /**
917
- * List all vaults for the account.
931
+ * List vaults for the account. Results are paginated (server default 100 per
932
+ * page, max 500); follow `nextCursor` to fetch subsequent pages.
918
933
  *
919
934
  * @example
920
- * const vaults = await sv.vaults.list();
921
- * vaults.forEach(v => console.log(v.name));
935
+ * let cursor: string | undefined;
936
+ * do {
937
+ * const page = await sv.vaults.list({ cursor });
938
+ * page.vaults.forEach((v) => console.log(v.name));
939
+ * cursor = page.nextCursor;
940
+ * } while (cursor);
922
941
  */
923
- list(): Promise<VaultSummary[]>;
942
+ list(options?: ListVaultsOptions): Promise<VaultPage>;
924
943
  /**
925
944
  * Get a single vault's detail.
926
945
  *
@@ -948,10 +967,14 @@ declare class VaultsModule {
948
967
  /**
949
968
  * Delete a vault and all its ingots. This action is irreversible!
950
969
  *
970
+ * Requires the vault's exact name as confirmation. It is sent as the
971
+ * `X-Confirm-Name` header and must match the vault name exactly
972
+ * (case-sensitive).
973
+ *
951
974
  * @example
952
- * await sv.vaults.delete('vlt_abc', vmk);
975
+ * await sv.vaults.delete('vlt_abc', 'My Vault');
953
976
  */
954
- delete(vaultId: string, vmk: string): Promise<void>;
977
+ delete(vaultId: string, name: string): Promise<void>;
955
978
  /**
956
979
  * Get a vault's public-sharing configuration.
957
980
  *
@@ -1801,8 +1824,16 @@ declare class EntropyModule {
1801
1824
  /**
1802
1825
  * Generate `n` random bytes as a Uint8Array.
1803
1826
  *
1827
+ * SECURITY: this returns raw *server* entropy — it is NOT finished key
1828
+ * material. Client secret keys MUST hybrid-mix it: XOR the returned bytes with
1829
+ * a local CSPRNG (`crypto.getRandomValues`) before use, so the server share
1830
+ * alone can never determine the key.
1831
+ *
1804
1832
  * @example
1805
- * const key = await sv.entropy.generateBytes(32);
1833
+ * const serverEntropy = await sv.entropy.generateBytes(32);
1834
+ * const localEntropy = crypto.getRandomValues(new Uint8Array(32));
1835
+ * // Hybrid-mixed key material — safe to use as a secret key.
1836
+ * const key = serverEntropy.map((b, i) => b ^ localEntropy[i]);
1806
1837
  */
1807
1838
  generateBytes(n: number): Promise<Uint8Array>;
1808
1839
  private validateByteCount;
@@ -12371,21 +12371,30 @@ class VaultsModule {
12371
12371
  };
12372
12372
  }
12373
12373
  /**
12374
- * List all vaults for the account.
12374
+ * List vaults for the account. Results are paginated (server default 100 per
12375
+ * page, max 500); follow `nextCursor` to fetch subsequent pages.
12375
12376
  *
12376
12377
  * @example
12377
- * const vaults = await sv.vaults.list();
12378
- * vaults.forEach(v => console.log(v.name));
12378
+ * let cursor: string | undefined;
12379
+ * do {
12380
+ * const page = await sv.vaults.list({ cursor });
12381
+ * page.vaults.forEach((v) => console.log(v.name));
12382
+ * cursor = page.nextCursor;
12383
+ * } while (cursor);
12379
12384
  */
12380
- async list() {
12381
- const response = await this.http.get('/v1/vaults');
12382
- return response.data.vaults.map((v) => ({
12383
- id: v.vault_id,
12384
- name: v.name,
12385
- createdAt: v.created_at,
12386
- ingotCount: v.ingot_count,
12387
- storageBytes: v.storage_bytes,
12388
- }));
12385
+ async list(options = {}) {
12386
+ const query = buildQuery$2({ limit: options.limit, cursor: options.cursor });
12387
+ const response = await this.http.get(`/v1/vaults${query}`);
12388
+ return {
12389
+ vaults: response.data.vaults.map((v) => ({
12390
+ id: v.vault_id,
12391
+ name: v.name,
12392
+ createdAt: v.created_at,
12393
+ ingotCount: v.ingot_count,
12394
+ storageBytes: v.storage_bytes,
12395
+ })),
12396
+ nextCursor: response.data.next_cursor,
12397
+ };
12389
12398
  }
12390
12399
  /**
12391
12400
  * Get a single vault's detail.
@@ -12445,13 +12454,20 @@ class VaultsModule {
12445
12454
  /**
12446
12455
  * Delete a vault and all its ingots. This action is irreversible!
12447
12456
  *
12457
+ * Requires the vault's exact name as confirmation. It is sent as the
12458
+ * `X-Confirm-Name` header and must match the vault name exactly
12459
+ * (case-sensitive).
12460
+ *
12448
12461
  * @example
12449
- * await sv.vaults.delete('vlt_abc', vmk);
12462
+ * await sv.vaults.delete('vlt_abc', 'My Vault');
12450
12463
  */
12451
- async delete(vaultId, vmk) {
12464
+ async delete(vaultId, name) {
12452
12465
  const cleanId = this.normalizeVaultId(vaultId);
12466
+ if (!name) {
12467
+ throw new ValidationError('Vault name is required to confirm deletion');
12468
+ }
12453
12469
  await this.http.delete(`/v1/vaults/${cleanId}`, {
12454
- headers: { 'X-VMK': vmk },
12470
+ headers: { 'X-Confirm-Name': name },
12455
12471
  });
12456
12472
  }
12457
12473
  /**
@@ -12632,6 +12648,16 @@ class VaultsModule {
12632
12648
  }
12633
12649
  }
12634
12650
  }
12651
+ function buildQuery$2(params) {
12652
+ const search = new URLSearchParams();
12653
+ for (const [key, value] of Object.entries(params)) {
12654
+ if (value === undefined || value === '')
12655
+ continue;
12656
+ search.append(key, String(value));
12657
+ }
12658
+ const query = search.toString();
12659
+ return query ? `?${query}` : '';
12660
+ }
12635
12661
  function mapSharingConfig$1(wire) {
12636
12662
  return {
12637
12663
  vaultId: wire.vault_id,
@@ -13499,8 +13525,16 @@ class EntropyModule {
13499
13525
  /**
13500
13526
  * Generate `n` random bytes as a Uint8Array.
13501
13527
  *
13528
+ * SECURITY: this returns raw *server* entropy — it is NOT finished key
13529
+ * material. Client secret keys MUST hybrid-mix it: XOR the returned bytes with
13530
+ * a local CSPRNG (`crypto.getRandomValues`) before use, so the server share
13531
+ * alone can never determine the key.
13532
+ *
13502
13533
  * @example
13503
- * const key = await sv.entropy.generateBytes(32);
13534
+ * const serverEntropy = await sv.entropy.generateBytes(32);
13535
+ * const localEntropy = crypto.getRandomValues(new Uint8Array(32));
13536
+ * // Hybrid-mixed key material — safe to use as a secret key.
13537
+ * const key = serverEntropy.map((b, i) => b ^ localEntropy[i]);
13504
13538
  */
13505
13539
  async generateBytes(n) {
13506
13540
  this.validateByteCount(n);