@sparkvault/sdk-js 11.1.14 → 11.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.cjs CHANGED
@@ -15194,6 +15194,7 @@ class VaultsModule {
15194
15194
  createdAt: v.created_at,
15195
15195
  ingotCount: v.ingot_count,
15196
15196
  storageBytes: v.storage_bytes,
15197
+ ...mapLifecycle(v),
15197
15198
  })),
15198
15199
  nextCursor: response.data.next_cursor,
15199
15200
  };
@@ -15208,18 +15209,7 @@ class VaultsModule {
15208
15209
  async get(vaultId) {
15209
15210
  const id = requireResourceId(vaultId, 'vaultId');
15210
15211
  const response = await this.http.get(apiPath `/v1/vaults/${id}`);
15211
- const v = response.data;
15212
- return {
15213
- id: v.vault_id,
15214
- name: v.name,
15215
- description: v.description ?? null,
15216
- status: v.status,
15217
- ingotCount: v.ingot_count ?? 0,
15218
- storageBytes: v.storage_bytes ?? 0,
15219
- createdAt: v.created_at,
15220
- lastUnsealedAt: v.last_unsealed_at ?? null,
15221
- unsealCount: v.unseal_count ?? 0,
15222
- };
15212
+ return mapVaultDetail(response.data);
15223
15213
  }
15224
15214
  /**
15225
15215
  * Rename a vault.
@@ -15254,7 +15244,8 @@ class VaultsModule {
15254
15244
  await this.http.post(apiPath `/v1/vaults/${id}/seal`);
15255
15245
  }
15256
15246
  /**
15257
- * Delete a vault and all its ingots. This action is irreversible!
15247
+ * Schedule permanent deletion in seven days and immediately lock all vault access.
15248
+ * Company admins only; cancelDeletion can abort this schedule before its deadline.
15258
15249
  *
15259
15250
  * Requires the vault's exact name as confirmation, matched case-sensitively.
15260
15251
  * The name is sent base64(UTF-8) as the `X-Confirm-Name-B64` header so a vault
@@ -15269,9 +15260,32 @@ class VaultsModule {
15269
15260
  if (!name) {
15270
15261
  throw new ValidationError('Vault name is required to confirm deletion');
15271
15262
  }
15272
- await this.http.delete(apiPath `/v1/vaults/${id}`, {
15273
- headers: { 'X-Confirm-Name-B64': base64EncodeUtf8(name) },
15263
+ const response = await this.http.delete(apiPath `/v1/vaults/${id}`, {
15264
+ headers: {
15265
+ 'X-Confirm-Name-B64': base64EncodeUtf8(name),
15266
+ 'X-Vault-Deletion-Mode': 'schedule',
15267
+ },
15268
+ });
15269
+ const scheduled = response.data;
15270
+ return {
15271
+ id: scheduled.vault_id,
15272
+ status: scheduled.status,
15273
+ deletionRequestedAt: scheduled.deletion_requested_at,
15274
+ deletionScheduledFor: scheduled.deletion_scheduled_for,
15275
+ deletionRequestedBy: scheduled.deletion_requested_by,
15276
+ deletionScheduleId: scheduled.deletion_schedule_id,
15277
+ };
15278
+ }
15279
+ /** Cancel this exact deletion schedule before its deadline; company admins only. */
15280
+ async cancelDeletion(vaultId, deletionScheduleId) {
15281
+ const id = requireResourceId(vaultId, 'vaultId');
15282
+ if (!deletionScheduleId?.trim()) {
15283
+ throw new ValidationError('Deletion schedule is required to cancel deletion');
15284
+ }
15285
+ const response = await this.http.post(apiPath `/v1/vaults/${id}/deletion/cancel`, {
15286
+ deletion_schedule_id: deletionScheduleId,
15274
15287
  });
15288
+ return mapVaultDetail(response.data);
15275
15289
  }
15276
15290
  /**
15277
15291
  * Get a vault's public-sharing configuration.
@@ -15452,6 +15466,28 @@ class VaultsModule {
15452
15466
  }
15453
15467
  }
15454
15468
  }
15469
+ function mapLifecycle(v) {
15470
+ return {
15471
+ status: v.status,
15472
+ deletionRequestedAt: v.deletion_requested_at,
15473
+ deletionScheduledFor: v.deletion_scheduled_for,
15474
+ deletionRequestedBy: v.deletion_requested_by,
15475
+ deletionScheduleId: v.deletion_schedule_id,
15476
+ };
15477
+ }
15478
+ function mapVaultDetail(v) {
15479
+ return {
15480
+ id: v.vault_id,
15481
+ name: v.name,
15482
+ description: v.description ?? null,
15483
+ ...mapLifecycle(v),
15484
+ ingotCount: v.ingot_count ?? 0,
15485
+ storageBytes: v.storage_bytes ?? 0,
15486
+ createdAt: v.created_at,
15487
+ lastUnsealedAt: v.last_unsealed_at ?? null,
15488
+ unsealCount: v.unseal_count ?? 0,
15489
+ };
15490
+ }
15455
15491
  function mapSharingConfig$1(wire) {
15456
15492
  return {
15457
15493
  vaultId: wire.vault_id,
@@ -16282,10 +16318,9 @@ class IngotsModule {
16282
16318
  throw new ValidationError('Provide folder or folderId, not both');
16283
16319
  }
16284
16320
  const name = options.name ?? getBlobName(options.file);
16285
- const contentType = options.contentType ?? options.file.type ?? 'application/octet-stream';
16286
16321
  const created = await this.requestUploadSession(vault, {
16287
16322
  name,
16288
- content_type: contentType,
16323
+ content_type: sentContentType(options),
16289
16324
  size_bytes: options.file.size,
16290
16325
  contentHmac: options.contentHmac,
16291
16326
  folder: options.folder,
@@ -16307,10 +16342,11 @@ class IngotsModule {
16307
16342
  const vaultId = requireVaultId(vault);
16308
16343
  const id = requireResourceId(ingotId, 'ingotId');
16309
16344
  const name = options.name ?? getBlobName(options.file);
16310
- const contentType = options.contentType ?? options.file.type ?? 'application/octet-stream';
16345
+ const contentType = sentContentType(options);
16311
16346
  const response = await this.http.put(apiPath `/v1/vaults/${vaultId}/ingots/${id}`, {
16312
16347
  name,
16313
- content_type: contentType,
16348
+ // Omitted, Core keeps the ingot's stored type (ReplaceIngotOptions.contentType).
16349
+ ...(contentType !== undefined && { content_type: contentType }),
16314
16350
  size_bytes: options.file.size,
16315
16351
  ...(options.contentHmac && { content_hmac: options.contentHmac }),
16316
16352
  }, { vat: vault.vatToken }).catch((error) => {
@@ -16590,7 +16626,8 @@ class IngotsModule {
16590
16626
  async requestUploadSession(vault, body) {
16591
16627
  const payload = {
16592
16628
  name: body.name,
16593
- content_type: body.content_type ?? 'application/octet-stream',
16629
+ // Omitted, Core types the file by its name's extension.
16630
+ ...(body.content_type !== undefined && { content_type: body.content_type }),
16594
16631
  size_bytes: body.size_bytes,
16595
16632
  };
16596
16633
  // folder_path (find-or-create) and folder_id (existing folder) are
@@ -16648,6 +16685,15 @@ function getBlobName(file) {
16648
16685
  }
16649
16686
  return 'unnamed';
16650
16687
  }
16688
+ /**
16689
+ * The type an upload or replacement sends: the caller's, else the file's own.
16690
+ * A Blob of no type reports '', so such a file is sent with none, which Core
16691
+ * reads as a create typed by its name and a replacement that keeps the
16692
+ * ingot's stored type.
16693
+ */
16694
+ function sentContentType(options) {
16695
+ return options.contentType ?? (options.file.type || undefined);
16696
+ }
16651
16697
  function mapIngot(wire) {
16652
16698
  return {
16653
16699
  id: wire.ingot_id,
@@ -17384,7 +17430,7 @@ class SparkVault {
17384
17430
  }
17385
17431
  /** Get the SDK version */
17386
17432
  static get version() {
17387
- return '11.1.14';
17433
+ return '11.2.1';
17388
17434
  }
17389
17435
  }
17390
17436
  if (typeof window !== 'undefined') {