@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.d.ts CHANGED
@@ -765,7 +765,27 @@ interface UnsealedVault {
765
765
  /** VAT lifetime in seconds */
766
766
  ttlSeconds: number;
767
767
  }
768
- interface VaultSummary {
768
+ /** Lifecycle metadata, including the lockout and seven-day cancellation window. */
769
+ interface VaultLifecycle {
770
+ /** sealed, unsealed, deletion_scheduled, or deleting */
771
+ status: string;
772
+ /** Unix seconds when deletion was requested */
773
+ deletionRequestedAt?: number;
774
+ /** Unix seconds after which deletion cannot be cancelled */
775
+ deletionScheduledFor?: number;
776
+ deletionRequestedBy?: string;
777
+ /** Pass this exact schedule to cancelDeletion. */
778
+ deletionScheduleId?: string;
779
+ }
780
+ interface ScheduledVaultDeletion {
781
+ id: string;
782
+ status: 'deletion_scheduled';
783
+ deletionRequestedAt: number;
784
+ deletionScheduledFor: number;
785
+ deletionRequestedBy: string;
786
+ deletionScheduleId: string;
787
+ }
788
+ interface VaultSummary extends VaultLifecycle {
769
789
  /** Vault ID */
770
790
  id: string;
771
791
  /** Vault name */
@@ -792,15 +812,13 @@ interface VaultPage {
792
812
  nextCursor?: string;
793
813
  }
794
814
  /** A single vault's detail, as returned by get. */
795
- interface VaultDetail {
815
+ interface VaultDetail extends VaultLifecycle {
796
816
  /** Vault ID */
797
817
  id: string;
798
818
  /** Vault name */
799
819
  name: string;
800
820
  /** Optional description */
801
821
  description: string | null;
802
- /** Sealed/unsealed status */
803
- status: string;
804
822
  /** Number of ingots */
805
823
  ingotCount: number;
806
824
  /** Total storage used in bytes */
@@ -2069,7 +2087,8 @@ declare class VaultsModule {
2069
2087
  */
2070
2088
  seal(vaultId: string): Promise<void>;
2071
2089
  /**
2072
- * Delete a vault and all its ingots. This action is irreversible!
2090
+ * Schedule permanent deletion in seven days and immediately lock all vault access.
2091
+ * Company admins only; cancelDeletion can abort this schedule before its deadline.
2073
2092
  *
2074
2093
  * Requires the vault's exact name as confirmation, matched case-sensitively.
2075
2094
  * The name is sent base64(UTF-8) as the `X-Confirm-Name-B64` header so a vault
@@ -2079,7 +2098,9 @@ declare class VaultsModule {
2079
2098
  * @example
2080
2099
  * await sv.vaults.delete('vlt_abc', 'My Vault');
2081
2100
  */
2082
- delete(vaultId: string, name: string): Promise<void>;
2101
+ delete(vaultId: string, name: string): Promise<ScheduledVaultDeletion>;
2102
+ /** Cancel this exact deletion schedule before its deadline; company admins only. */
2103
+ cancelDeletion(vaultId: string, deletionScheduleId: string): Promise<VaultDetail>;
2083
2104
  /**
2084
2105
  * Get a vault's public-sharing configuration.
2085
2106
  *
@@ -2349,7 +2370,11 @@ interface UploadIngotOptions {
2349
2370
  file: File | Blob;
2350
2371
  /** Optional name (defaults to file name) */
2351
2372
  name?: string;
2352
- /** Content type (auto-detected from the file if not provided) */
2373
+ /**
2374
+ * Content type (the file's own `type` if not provided). A file of no type is
2375
+ * sent with none, and Core stores the type the registry lists for the name's
2376
+ * extension, else `application/octet-stream`.
2377
+ */
2353
2378
  contentType?: string;
2354
2379
  /** Slash-delimited folder path (find-or-created from root). */
2355
2380
  folder?: string;
@@ -2397,7 +2422,11 @@ interface ReplaceIngotOptions {
2397
2422
  name?: string;
2398
2423
  /** Vault-keyed plaintext HMAC (43-char base64url) for the NEW content. */
2399
2424
  contentHmac?: string;
2400
- /** Content type (auto-detected from the file if not provided) */
2425
+ /**
2426
+ * Content type (the file's own `type` if not provided). A file of no type
2427
+ * keeps the type the ingot stores, which Core reads from the name by its
2428
+ * extension only when it is `application/octet-stream` or unparsable.
2429
+ */
2401
2430
  contentType?: string;
2402
2431
  /** Progress callback for the Forge/TUS transfer */
2403
2432
  onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
@@ -2443,9 +2472,15 @@ interface FolderContents {
2443
2472
  }
2444
2473
  /** Options for search. */
2445
2474
  interface SearchIngotsOptions {
2446
- /** Free-text query */
2475
+ /** The beginning of the ingot's name, in any case: a prefix, never a substring or a fuzzy match. */
2447
2476
  q?: string;
2448
- /** File type filter */
2477
+ /**
2478
+ * The MIME type to match, in lowercase: a family (`image`, `video`,
2479
+ * `audio`, `text`, `application`, ...), which every type under it matches,
2480
+ * or an exact type (`application/pdf`), which matches that type whatever
2481
+ * its parameters. A well-formed value no ingot carries matches none; the
2482
+ * server refuses a value that is neither.
2483
+ */
2449
2484
  fileType?: string;
2450
2485
  /** Scope the search to one folder (whole vault when omitted) */
2451
2486
  folderId?: string;
@@ -3507,4 +3542,4 @@ declare global {
3507
3542
  }
3508
3543
 
3509
3544
  export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, logger, setDebugMode };
3510
- export type { AccessLogRetention, AccessLogsOptions, CreateFolderOptions, CreateNotifySendOptions, CreateSparkOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, GenerateEntropyOptions, HealthCheckOptions, HealthCheckResult, AttachOptions as IdentityAttachOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusRecipient, NotifySendSummary, NotifyVerificationLevel, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, ResumeUploadOptions, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, Spark, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreadCountResponse, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushSubscriptionInput };
3545
+ export type { AccessLogRetention, AccessLogsOptions, CreateFolderOptions, CreateNotifySendOptions, CreateSparkOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, GenerateEntropyOptions, HealthCheckOptions, HealthCheckResult, AttachOptions as IdentityAttachOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusRecipient, NotifySendSummary, NotifyVerificationLevel, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, Spark, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreadCountResponse, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultLifecycle, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushSubscriptionInput };
package/dist/index.mjs CHANGED
@@ -15190,6 +15190,7 @@ class VaultsModule {
15190
15190
  createdAt: v.created_at,
15191
15191
  ingotCount: v.ingot_count,
15192
15192
  storageBytes: v.storage_bytes,
15193
+ ...mapLifecycle(v),
15193
15194
  })),
15194
15195
  nextCursor: response.data.next_cursor,
15195
15196
  };
@@ -15204,18 +15205,7 @@ class VaultsModule {
15204
15205
  async get(vaultId) {
15205
15206
  const id = requireResourceId(vaultId, 'vaultId');
15206
15207
  const response = await this.http.get(apiPath `/v1/vaults/${id}`);
15207
- const v = response.data;
15208
- return {
15209
- id: v.vault_id,
15210
- name: v.name,
15211
- description: v.description ?? null,
15212
- status: v.status,
15213
- ingotCount: v.ingot_count ?? 0,
15214
- storageBytes: v.storage_bytes ?? 0,
15215
- createdAt: v.created_at,
15216
- lastUnsealedAt: v.last_unsealed_at ?? null,
15217
- unsealCount: v.unseal_count ?? 0,
15218
- };
15208
+ return mapVaultDetail(response.data);
15219
15209
  }
15220
15210
  /**
15221
15211
  * Rename a vault.
@@ -15250,7 +15240,8 @@ class VaultsModule {
15250
15240
  await this.http.post(apiPath `/v1/vaults/${id}/seal`);
15251
15241
  }
15252
15242
  /**
15253
- * Delete a vault and all its ingots. This action is irreversible!
15243
+ * Schedule permanent deletion in seven days and immediately lock all vault access.
15244
+ * Company admins only; cancelDeletion can abort this schedule before its deadline.
15254
15245
  *
15255
15246
  * Requires the vault's exact name as confirmation, matched case-sensitively.
15256
15247
  * The name is sent base64(UTF-8) as the `X-Confirm-Name-B64` header so a vault
@@ -15265,9 +15256,32 @@ class VaultsModule {
15265
15256
  if (!name) {
15266
15257
  throw new ValidationError('Vault name is required to confirm deletion');
15267
15258
  }
15268
- await this.http.delete(apiPath `/v1/vaults/${id}`, {
15269
- headers: { 'X-Confirm-Name-B64': base64EncodeUtf8(name) },
15259
+ const response = await this.http.delete(apiPath `/v1/vaults/${id}`, {
15260
+ headers: {
15261
+ 'X-Confirm-Name-B64': base64EncodeUtf8(name),
15262
+ 'X-Vault-Deletion-Mode': 'schedule',
15263
+ },
15264
+ });
15265
+ const scheduled = response.data;
15266
+ return {
15267
+ id: scheduled.vault_id,
15268
+ status: scheduled.status,
15269
+ deletionRequestedAt: scheduled.deletion_requested_at,
15270
+ deletionScheduledFor: scheduled.deletion_scheduled_for,
15271
+ deletionRequestedBy: scheduled.deletion_requested_by,
15272
+ deletionScheduleId: scheduled.deletion_schedule_id,
15273
+ };
15274
+ }
15275
+ /** Cancel this exact deletion schedule before its deadline; company admins only. */
15276
+ async cancelDeletion(vaultId, deletionScheduleId) {
15277
+ const id = requireResourceId(vaultId, 'vaultId');
15278
+ if (!deletionScheduleId?.trim()) {
15279
+ throw new ValidationError('Deletion schedule is required to cancel deletion');
15280
+ }
15281
+ const response = await this.http.post(apiPath `/v1/vaults/${id}/deletion/cancel`, {
15282
+ deletion_schedule_id: deletionScheduleId,
15270
15283
  });
15284
+ return mapVaultDetail(response.data);
15271
15285
  }
15272
15286
  /**
15273
15287
  * Get a vault's public-sharing configuration.
@@ -15448,6 +15462,28 @@ class VaultsModule {
15448
15462
  }
15449
15463
  }
15450
15464
  }
15465
+ function mapLifecycle(v) {
15466
+ return {
15467
+ status: v.status,
15468
+ deletionRequestedAt: v.deletion_requested_at,
15469
+ deletionScheduledFor: v.deletion_scheduled_for,
15470
+ deletionRequestedBy: v.deletion_requested_by,
15471
+ deletionScheduleId: v.deletion_schedule_id,
15472
+ };
15473
+ }
15474
+ function mapVaultDetail(v) {
15475
+ return {
15476
+ id: v.vault_id,
15477
+ name: v.name,
15478
+ description: v.description ?? null,
15479
+ ...mapLifecycle(v),
15480
+ ingotCount: v.ingot_count ?? 0,
15481
+ storageBytes: v.storage_bytes ?? 0,
15482
+ createdAt: v.created_at,
15483
+ lastUnsealedAt: v.last_unsealed_at ?? null,
15484
+ unsealCount: v.unseal_count ?? 0,
15485
+ };
15486
+ }
15451
15487
  function mapSharingConfig$1(wire) {
15452
15488
  return {
15453
15489
  vaultId: wire.vault_id,
@@ -16278,10 +16314,9 @@ class IngotsModule {
16278
16314
  throw new ValidationError('Provide folder or folderId, not both');
16279
16315
  }
16280
16316
  const name = options.name ?? getBlobName(options.file);
16281
- const contentType = options.contentType ?? options.file.type ?? 'application/octet-stream';
16282
16317
  const created = await this.requestUploadSession(vault, {
16283
16318
  name,
16284
- content_type: contentType,
16319
+ content_type: sentContentType(options),
16285
16320
  size_bytes: options.file.size,
16286
16321
  contentHmac: options.contentHmac,
16287
16322
  folder: options.folder,
@@ -16303,10 +16338,11 @@ class IngotsModule {
16303
16338
  const vaultId = requireVaultId(vault);
16304
16339
  const id = requireResourceId(ingotId, 'ingotId');
16305
16340
  const name = options.name ?? getBlobName(options.file);
16306
- const contentType = options.contentType ?? options.file.type ?? 'application/octet-stream';
16341
+ const contentType = sentContentType(options);
16307
16342
  const response = await this.http.put(apiPath `/v1/vaults/${vaultId}/ingots/${id}`, {
16308
16343
  name,
16309
- content_type: contentType,
16344
+ // Omitted, Core keeps the ingot's stored type (ReplaceIngotOptions.contentType).
16345
+ ...(contentType !== undefined && { content_type: contentType }),
16310
16346
  size_bytes: options.file.size,
16311
16347
  ...(options.contentHmac && { content_hmac: options.contentHmac }),
16312
16348
  }, { vat: vault.vatToken }).catch((error) => {
@@ -16586,7 +16622,8 @@ class IngotsModule {
16586
16622
  async requestUploadSession(vault, body) {
16587
16623
  const payload = {
16588
16624
  name: body.name,
16589
- content_type: body.content_type ?? 'application/octet-stream',
16625
+ // Omitted, Core types the file by its name's extension.
16626
+ ...(body.content_type !== undefined && { content_type: body.content_type }),
16590
16627
  size_bytes: body.size_bytes,
16591
16628
  };
16592
16629
  // folder_path (find-or-create) and folder_id (existing folder) are
@@ -16644,6 +16681,15 @@ function getBlobName(file) {
16644
16681
  }
16645
16682
  return 'unnamed';
16646
16683
  }
16684
+ /**
16685
+ * The type an upload or replacement sends: the caller's, else the file's own.
16686
+ * A Blob of no type reports '', so such a file is sent with none, which Core
16687
+ * reads as a create typed by its name and a replacement that keeps the
16688
+ * ingot's stored type.
16689
+ */
16690
+ function sentContentType(options) {
16691
+ return options.contentType ?? (options.file.type || undefined);
16692
+ }
16647
16693
  function mapIngot(wire) {
16648
16694
  return {
16649
16695
  id: wire.ingot_id,
@@ -17380,7 +17426,7 @@ class SparkVault {
17380
17426
  }
17381
17427
  /** Get the SDK version */
17382
17428
  static get version() {
17383
- return '11.1.14';
17429
+ return '11.2.1';
17384
17430
  }
17385
17431
  }
17386
17432
  if (typeof window !== 'undefined') {