@sparkvault/sdk-js 8.10.1 → 8.10.3
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/entropy/index.d.ts +9 -1
- package/dist/index.d.ts +38 -7
- package/dist/sparkvault.cjs.js +50 -16
- package/dist/sparkvault.cjs.js.map +1 -1
- package/dist/sparkvault.esm.js +50 -16
- package/dist/sparkvault.esm.js.map +1 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/dist/vaults/index.d.ts +17 -8
- package/dist/vaults/types.d.ts +15 -0
- package/package.json +1 -1
package/dist/sparkvault.esm.js
CHANGED
|
@@ -12367,21 +12367,30 @@ class VaultsModule {
|
|
|
12367
12367
|
};
|
|
12368
12368
|
}
|
|
12369
12369
|
/**
|
|
12370
|
-
* List
|
|
12370
|
+
* List vaults for the account. Results are paginated (server default 100 per
|
|
12371
|
+
* page, max 500); follow `nextCursor` to fetch subsequent pages.
|
|
12371
12372
|
*
|
|
12372
12373
|
* @example
|
|
12373
|
-
*
|
|
12374
|
-
*
|
|
12374
|
+
* let cursor: string | undefined;
|
|
12375
|
+
* do {
|
|
12376
|
+
* const page = await sv.vaults.list({ cursor });
|
|
12377
|
+
* page.vaults.forEach((v) => console.log(v.name));
|
|
12378
|
+
* cursor = page.nextCursor;
|
|
12379
|
+
* } while (cursor);
|
|
12375
12380
|
*/
|
|
12376
|
-
async list() {
|
|
12377
|
-
const
|
|
12378
|
-
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
|
|
12382
|
-
|
|
12383
|
-
|
|
12384
|
-
|
|
12381
|
+
async list(options = {}) {
|
|
12382
|
+
const query = buildQuery$2({ limit: options.limit, cursor: options.cursor });
|
|
12383
|
+
const response = await this.http.get(`/v1/vaults${query}`);
|
|
12384
|
+
return {
|
|
12385
|
+
vaults: response.data.vaults.map((v) => ({
|
|
12386
|
+
id: v.vault_id,
|
|
12387
|
+
name: v.name,
|
|
12388
|
+
createdAt: v.created_at,
|
|
12389
|
+
ingotCount: v.ingot_count,
|
|
12390
|
+
storageBytes: v.storage_bytes,
|
|
12391
|
+
})),
|
|
12392
|
+
nextCursor: response.data.next_cursor,
|
|
12393
|
+
};
|
|
12385
12394
|
}
|
|
12386
12395
|
/**
|
|
12387
12396
|
* Get a single vault's detail.
|
|
@@ -12441,13 +12450,20 @@ class VaultsModule {
|
|
|
12441
12450
|
/**
|
|
12442
12451
|
* Delete a vault and all its ingots. This action is irreversible!
|
|
12443
12452
|
*
|
|
12453
|
+
* Requires the vault's exact name as confirmation. It is sent as the
|
|
12454
|
+
* `X-Confirm-Name` header and must match the vault name exactly
|
|
12455
|
+
* (case-sensitive).
|
|
12456
|
+
*
|
|
12444
12457
|
* @example
|
|
12445
|
-
* await sv.vaults.delete('vlt_abc',
|
|
12458
|
+
* await sv.vaults.delete('vlt_abc', 'My Vault');
|
|
12446
12459
|
*/
|
|
12447
|
-
async delete(vaultId,
|
|
12460
|
+
async delete(vaultId, name) {
|
|
12448
12461
|
const cleanId = this.normalizeVaultId(vaultId);
|
|
12462
|
+
if (!name) {
|
|
12463
|
+
throw new ValidationError('Vault name is required to confirm deletion');
|
|
12464
|
+
}
|
|
12449
12465
|
await this.http.delete(`/v1/vaults/${cleanId}`, {
|
|
12450
|
-
headers: { 'X-
|
|
12466
|
+
headers: { 'X-Confirm-Name': name },
|
|
12451
12467
|
});
|
|
12452
12468
|
}
|
|
12453
12469
|
/**
|
|
@@ -12628,6 +12644,16 @@ class VaultsModule {
|
|
|
12628
12644
|
}
|
|
12629
12645
|
}
|
|
12630
12646
|
}
|
|
12647
|
+
function buildQuery$2(params) {
|
|
12648
|
+
const search = new URLSearchParams();
|
|
12649
|
+
for (const [key, value] of Object.entries(params)) {
|
|
12650
|
+
if (value === undefined || value === '')
|
|
12651
|
+
continue;
|
|
12652
|
+
search.append(key, String(value));
|
|
12653
|
+
}
|
|
12654
|
+
const query = search.toString();
|
|
12655
|
+
return query ? `?${query}` : '';
|
|
12656
|
+
}
|
|
12631
12657
|
function mapSharingConfig$1(wire) {
|
|
12632
12658
|
return {
|
|
12633
12659
|
vaultId: wire.vault_id,
|
|
@@ -13495,8 +13521,16 @@ class EntropyModule {
|
|
|
13495
13521
|
/**
|
|
13496
13522
|
* Generate `n` random bytes as a Uint8Array.
|
|
13497
13523
|
*
|
|
13524
|
+
* SECURITY: this returns raw *server* entropy — it is NOT finished key
|
|
13525
|
+
* material. Client secret keys MUST hybrid-mix it: XOR the returned bytes with
|
|
13526
|
+
* a local CSPRNG (`crypto.getRandomValues`) before use, so the server share
|
|
13527
|
+
* alone can never determine the key.
|
|
13528
|
+
*
|
|
13498
13529
|
* @example
|
|
13499
|
-
* const
|
|
13530
|
+
* const serverEntropy = await sv.entropy.generateBytes(32);
|
|
13531
|
+
* const localEntropy = crypto.getRandomValues(new Uint8Array(32));
|
|
13532
|
+
* // Hybrid-mixed key material — safe to use as a secret key.
|
|
13533
|
+
* const key = serverEntropy.map((b, i) => b ^ localEntropy[i]);
|
|
13500
13534
|
*/
|
|
13501
13535
|
async generateBytes(n) {
|
|
13502
13536
|
this.validateByteCount(n);
|