@sparkvault/sdk-js 15.9.1 → 15.10.0

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
@@ -1084,7 +1084,9 @@ interface VaultSummary extends VaultLifecycle {
1084
1084
  ingotCount: number;
1085
1085
  /** Total storage used in bytes */
1086
1086
  storageBytes: number;
1087
- /** Previous versions retained per structured object; absent on older servers. */
1087
+ /** Previous versions retained per file or structured object (0–50); absent on older servers. */
1088
+ ingotVersionLimit?: number;
1089
+ /** @deprecated Use ingotVersionLimit. */
1088
1090
  structuredIngotVersionLimit?: number;
1089
1091
  /** Whether this vault uses the Structured Ingots browser, including when empty. */
1090
1092
  structuredIngotsEnabled?: boolean;
@@ -1115,7 +1117,9 @@ interface VaultDetail extends VaultLifecycle {
1115
1117
  ingotCount: number;
1116
1118
  /** Total storage used in bytes */
1117
1119
  storageBytes: number;
1118
- /** Previous versions retained per structured object, in addition to current content. */
1120
+ /** Previous versions retained per file or structured object, in addition to current content (default 0). */
1121
+ ingotVersionLimit?: number;
1122
+ /** @deprecated Use ingotVersionLimit. */
1119
1123
  structuredIngotVersionLimit?: number;
1120
1124
  /** Whether this vault is enabled for Structured Ingots, independent of record count. */
1121
1125
  structuredIngotsEnabled?: boolean;
@@ -3089,6 +3093,32 @@ interface IngotDownload {
3089
3093
  blob: Blob;
3090
3094
  revision: string;
3091
3095
  }
3096
+ /** One retained publication; current content is not included in version history. */
3097
+ interface IngotVersion {
3098
+ versionId: string;
3099
+ publishedAt: number;
3100
+ sizeBytes: number;
3101
+ /** Absent for publications retained before MIME metadata was recorded. */
3102
+ contentType?: string;
3103
+ }
3104
+ interface IngotHistory {
3105
+ id: string;
3106
+ /** Maximum previous versions retained on the next successful content change. */
3107
+ versionLimit: number;
3108
+ /** Retained publications, newest first. */
3109
+ versions: IngotVersion[];
3110
+ }
3111
+ /** A one-use download link bound to a retained publication. */
3112
+ interface IngotVersionDownloadLink {
3113
+ id: string;
3114
+ downloadUrl: string;
3115
+ size: number;
3116
+ contentVersion: string;
3117
+ revision?: string;
3118
+ expiresAt: number;
3119
+ name?: string;
3120
+ contentType?: string;
3121
+ }
3092
3122
  interface DeleteIngotOptions {
3093
3123
  /** Delete only this object publication. Omitted preserves unconditional deletion. */
3094
3124
  expectedRevision?: string;
@@ -3960,16 +3990,8 @@ interface DeleteStructuredIngotOptions {
3960
3990
  /** Delete only this object publication. Omitted preserves unconditional deletion. */
3961
3991
  expectedRevision?: string;
3962
3992
  }
3963
- interface StructuredIngotVersion {
3964
- versionId: string;
3965
- publishedAt: number;
3966
- sizeBytes: number;
3967
- }
3968
- interface StructuredIngotHistory {
3969
- id: string;
3970
- versionLimit: number;
3971
- versions: StructuredIngotVersion[];
3972
- }
3993
+ type StructuredIngotVersion = IngotVersion;
3994
+ type StructuredIngotHistory = IngotHistory;
3973
3995
  type StructuredActivityPeriod = '24h' | '7d';
3974
3996
  interface StructuredActivityOptions {
3975
3997
  period?: StructuredActivityPeriod;
@@ -4487,10 +4509,17 @@ declare class VaultsModule {
4487
4509
  */
4488
4510
  updateResealSettings(vaultId: string, settings: VaultResealSettings): Promise<VaultResealSettingsResult>;
4489
4511
  /**
4490
- * Retain this many previous versions of each structured object (0–50).
4491
- * Interactive company administrators only. Applies on each object's next
4492
- * successful change; retained versions count toward storage usage.
4512
+ * Retain this many previous versions of each file or structured object (0–50,
4513
+ * default 0). Interactive company administrators only. Applies on each ingot's
4514
+ * next successful content change; retained versions count toward storage usage.
4493
4515
  */
4516
+ updateVersionHistory(vaultId: string, settings: {
4517
+ versionLimit: number;
4518
+ }): Promise<{
4519
+ vaultId: string;
4520
+ versionLimit: number;
4521
+ }>;
4522
+ /** @deprecated Use updateVersionHistory; retention applies to files and structured objects. */
4494
4523
  updateStructuredIngotSettings(vaultId: string, settings: {
4495
4524
  versionLimit: number;
4496
4525
  }): Promise<{
@@ -5092,6 +5121,12 @@ declare class IngotsModule {
5092
5121
  * } while (pageToken);
5093
5122
  */
5094
5123
  listContents(vault: UnsealedVault, options?: ListContentsOptions): Promise<FolderContents>;
5124
+ /** List previous publications of a file, newest first. Structured objects use their product's history method. */
5125
+ listVersions(vault: UnsealedVault, ingotId: string): Promise<IngotHistory>;
5126
+ /** Mint a one-use link to a retained file publication; use downloadVersion to verify the served bytes. */
5127
+ createVersionDownloadLink(vault: UnsealedVault, ingotId: string, versionId: string): Promise<IngotVersionDownloadLink>;
5128
+ /** Download a retained file publication; never substitutes the current bytes if history is unavailable. */
5129
+ downloadVersion(vault: UnsealedVault, ingotId: string, versionId: string): Promise<Blob>;
5095
5130
  /**
5096
5131
  * Create a signed download link for an ingot (discrete primitive).
5097
5132
  *
@@ -5975,4 +6010,4 @@ declare global {
5975
6010
  }
5976
6011
 
5977
6012
  export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, HelpDeskClient, HelpDeskModule, IdentityModule, IdentityProviderError, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifyProjectsModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, StructuredIngotTypesModule, StructuredIngotsModule, TimeoutError, UnauthorizedError, UsageCreditFundingReviewError, UsageCreditsExhaustedError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, isReceivedUploadFailure, logger, setDebugMode };
5978
- export type { AccessLogRetention, AccessLogsOptions, BatchGetStructuredIngotsOptions, CreateFolderOptions, CreateNotifyProjectOptions, CreateNotifySendOptions, CreateSparkOptions, CreateStructuredIngotOptions, CreateStructuredTypeOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, DeleteIngotOptions, DeleteStructuredIngotOptions, DownloadIngotOptions, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, FolderPage, GenerateEntropyOptions, GetStructuredIngotOptions, HealthCheckOptions, HealthCheckResult, HelpDeskAttachmentDownload, HelpDeskAttachmentInput, HelpDeskAttachmentUpload, HelpDeskConnectOptions, HelpDeskCreateTicketOptions, HelpDeskCustomer, HelpDeskCustomerPatch, HelpDeskDesk, HelpDeskDraft, HelpDeskEvent, HelpDeskExternalChallenge, HelpDeskExternalIdentity, HelpDeskFormHandle, HelpDeskFormOptions, HelpDeskFormState, HelpDeskIdentityRequest, HelpDeskListTicketsOptions, HelpDeskMountFormOptions, HelpDeskOpenFormOptions, HelpDeskPinChallenge, HelpDeskReplyCreated, HelpDeskReplyOptions, HelpDeskRequestContext, HelpDeskSession, HelpDeskSessionChange, HelpDeskSupportHandle, HelpDeskSupportLauncherOptions, HelpDeskSupportOpenOptions, HelpDeskSupportOptions, HelpDeskSupportStage, HelpDeskSupportState, HelpDeskTicket, HelpDeskTicketCreated, HelpDeskTicketDetail, HelpDeskTicketList, HelpDeskTimeline, HelpDeskVerifyPinOptions, HelpDeskWidgetFormIdentity, HelpDeskWidgetIdentityChallenge, HelpDeskWidgetIdentityOptions, HelpDeskWidgetIdentitySession, AttachOptions as IdentityAttachOptions, ImportStructuredIngotsOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownload, IngotDownloadLink, IngotInvitation, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListFoldersOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyProjectsResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotificationSender, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigDeliveryPatch, NotifyConfigDestinations, NotifyConfigDestinationsPatch, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyDestinationFailureReason, NotifyDestinationKind, NotifyDestinationReason, NotifyDestinationSkipReason, NotifyDestinationState, NotifyDestinationTestReason, NotifyDestinationTestResult, NotifyDestinationTransportReason, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyProject, NotifyProjectBilling, NotifyProjectStatus, NotifyProjectSubscriptionPreview, NotifyProjectSubscriptionResponse, NotifyProjectUsage, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifyRecipientState, NotifyReportableVerificationLevel, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusDestination, NotifySendStatusRecipient, NotifySendSummary, NotifySendSummaryDestination, NotifySlackDestination, NotifySuppressionReason, NotifyTeamsDestination, NotifyTeamsDestinationRead, NotifyVerificationLevel, NotifyWebhookDestination, NotifyWebhookDestinationRead, PatchStructuredIngotOptions, PortableStructuredIngot, PortableStructuredType, PreviewNotifyProjectSubscriptionOptions, PublishStructuredTypeOptions, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, RestoreStructuredIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, SignInOptions, SignInResult, Spark, SparkInviteResend, SparkLinkActionOptions, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StartedVaultDeletion, StructuredAccountActivity, StructuredActivity, StructuredActivityOptions, StructuredActivityPeriod, StructuredActivityTotals, StructuredActivityTotalsWire, StructuredActivityWire, StructuredBinaryPath, StructuredExportOutcome, StructuredImportOutcome, StructuredIngot, StructuredIngotHistory, StructuredIngotMutation, StructuredIngotPrecondition, StructuredIngotSummary, StructuredIngotSummaryWire, StructuredIngotVersion, StructuredIngotWire, StructuredIterateOptions, StructuredJsonValue, StructuredMutationWire, StructuredOutcome, StructuredPage, StructuredPageOptions, StructuredPageWire, StructuredReadOutcome, StructuredTypeCreation, StructuredTypeDefinition, StructuredTypeDefinitionWire, StructuredTypePin, StructuredTypePinWire, StructuredTypeSummary, StructuredTypeSummaryWire, StructuredTypeTransform, StructuredValues, StructuredVaultActivity, SubscribeNotifyProjectOptions, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreachedAdmin, UnreadCountResponse, UnsealVaultOptions, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateNotifyProjectOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadEnd, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultLifecycle, VaultResealDefaults, VaultResealSettings, VaultResealSettingsResult, VaultSessionExtension, VaultSessionTiming, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, WebPushSubscriptionInput };
6013
+ export type { AccessLogRetention, AccessLogsOptions, BatchGetStructuredIngotsOptions, CreateFolderOptions, CreateNotifyProjectOptions, CreateNotifySendOptions, CreateSparkOptions, CreateStructuredIngotOptions, CreateStructuredTypeOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, DeleteIngotOptions, DeleteStructuredIngotOptions, DownloadIngotOptions, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, FolderPage, GenerateEntropyOptions, GetStructuredIngotOptions, HealthCheckOptions, HealthCheckResult, HelpDeskAttachmentDownload, HelpDeskAttachmentInput, HelpDeskAttachmentUpload, HelpDeskConnectOptions, HelpDeskCreateTicketOptions, HelpDeskCustomer, HelpDeskCustomerPatch, HelpDeskDesk, HelpDeskDraft, HelpDeskEvent, HelpDeskExternalChallenge, HelpDeskExternalIdentity, HelpDeskFormHandle, HelpDeskFormOptions, HelpDeskFormState, HelpDeskIdentityRequest, HelpDeskListTicketsOptions, HelpDeskMountFormOptions, HelpDeskOpenFormOptions, HelpDeskPinChallenge, HelpDeskReplyCreated, HelpDeskReplyOptions, HelpDeskRequestContext, HelpDeskSession, HelpDeskSessionChange, HelpDeskSupportHandle, HelpDeskSupportLauncherOptions, HelpDeskSupportOpenOptions, HelpDeskSupportOptions, HelpDeskSupportStage, HelpDeskSupportState, HelpDeskTicket, HelpDeskTicketCreated, HelpDeskTicketDetail, HelpDeskTicketList, HelpDeskTimeline, HelpDeskVerifyPinOptions, HelpDeskWidgetFormIdentity, HelpDeskWidgetIdentityChallenge, HelpDeskWidgetIdentityOptions, HelpDeskWidgetIdentitySession, AttachOptions as IdentityAttachOptions, ImportStructuredIngotsOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownload, IngotDownloadLink, IngotHistory, IngotInvitation, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, IngotVersion, IngotVersionDownloadLink, ListContentsOptions, ListFoldersOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyProjectsResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotificationSender, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigDeliveryPatch, NotifyConfigDestinations, NotifyConfigDestinationsPatch, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyDestinationFailureReason, NotifyDestinationKind, NotifyDestinationReason, NotifyDestinationSkipReason, NotifyDestinationState, NotifyDestinationTestReason, NotifyDestinationTestResult, NotifyDestinationTransportReason, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyProject, NotifyProjectBilling, NotifyProjectStatus, NotifyProjectSubscriptionPreview, NotifyProjectSubscriptionResponse, NotifyProjectUsage, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifyRecipientState, NotifyReportableVerificationLevel, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusDestination, NotifySendStatusRecipient, NotifySendSummary, NotifySendSummaryDestination, NotifySlackDestination, NotifySuppressionReason, NotifyTeamsDestination, NotifyTeamsDestinationRead, NotifyVerificationLevel, NotifyWebhookDestination, NotifyWebhookDestinationRead, PatchStructuredIngotOptions, PortableStructuredIngot, PortableStructuredType, PreviewNotifyProjectSubscriptionOptions, PublishStructuredTypeOptions, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, RestoreStructuredIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, SignInOptions, SignInResult, Spark, SparkInviteResend, SparkLinkActionOptions, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StartedVaultDeletion, StructuredAccountActivity, StructuredActivity, StructuredActivityOptions, StructuredActivityPeriod, StructuredActivityTotals, StructuredActivityTotalsWire, StructuredActivityWire, StructuredBinaryPath, StructuredExportOutcome, StructuredImportOutcome, StructuredIngot, StructuredIngotHistory, StructuredIngotMutation, StructuredIngotPrecondition, StructuredIngotSummary, StructuredIngotSummaryWire, StructuredIngotVersion, StructuredIngotWire, StructuredIterateOptions, StructuredJsonValue, StructuredMutationWire, StructuredOutcome, StructuredPage, StructuredPageOptions, StructuredPageWire, StructuredReadOutcome, StructuredTypeCreation, StructuredTypeDefinition, StructuredTypeDefinitionWire, StructuredTypePin, StructuredTypePinWire, StructuredTypeSummary, StructuredTypeSummaryWire, StructuredTypeTransform, StructuredValues, StructuredVaultActivity, SubscribeNotifyProjectOptions, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreachedAdmin, UnreadCountResponse, UnsealVaultOptions, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateNotifyProjectOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadEnd, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultLifecycle, VaultResealDefaults, VaultResealSettings, VaultResealSettingsResult, VaultSessionExtension, VaultSessionTiming, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, WebPushSubscriptionInput };
package/dist/index.mjs CHANGED
@@ -13710,6 +13710,11 @@ async function attemptWith(source, state, options) {
13710
13710
  assertDownloadUrl(link, options.isAllowedHost);
13711
13711
  }
13712
13712
  catch (error) {
13713
+ // A successful HTTP response that failed local validation is an answer,
13714
+ // not a lost connection. Retrying cannot make its publication safe to use.
13715
+ if (error instanceof SparkVaultError && error.code === 'invalid_response') {
13716
+ return { ok: false, error, outcome: FINAL };
13717
+ }
13713
13718
  if (!(error instanceof SparkVaultError) || typeof error.statusCode !== 'number') {
13714
13719
  return { ok: false, error, outcome: UNANSWERED };
13715
13720
  }
@@ -13776,6 +13781,12 @@ async function attemptDownload(link, state, options) {
13776
13781
  const outcome = classifyTransferResponse({ status: response.status, headers: (name) => response.headers.get(name) });
13777
13782
  return { ok: false, error: await refusedDownloadError(response, outcome, controller), outcome };
13778
13783
  }
13784
+ // Every response contributes bytes, including a 206 continuation. Never
13785
+ // let a resumed response bypass the caller's publication precondition.
13786
+ const contentVersion = response.headers.get('x-content-version') || null;
13787
+ if (expectedContentVersion && contentVersion && contentVersion !== expectedContentVersion) {
13788
+ return { ok: false, error: new SparkVaultError(CONTENT_CHANGED_MESSAGE, 'content_changed'), outcome: FINAL };
13789
+ }
13779
13790
  if (resume && response.status === 206) {
13780
13791
  const continued = continuation(response, resume);
13781
13792
  if (continued instanceof SparkVaultError)
@@ -13784,10 +13795,6 @@ async function attemptDownload(link, state, options) {
13784
13795
  }
13785
13796
  else {
13786
13797
  received.discard();
13787
- const contentVersion = response.headers.get('x-content-version') || null;
13788
- if (expectedContentVersion && contentVersion && contentVersion !== expectedContentVersion) {
13789
- return { ok: false, error: new SparkVaultError(CONTENT_CHANGED_MESSAGE, 'content_changed'), outcome: FINAL };
13790
- }
13791
13798
  held = {
13792
13799
  contentType: response.headers.get('content-type') ?? '',
13793
13800
  contentVersion,
@@ -13894,7 +13901,9 @@ function resumeValidator(headers) {
13894
13901
  */
13895
13902
  function continuation(response, resume) {
13896
13903
  const etag = response.headers.get('etag');
13897
- if (etag !== null && etag.replace(/^W\//, '') !== resume.validator) {
13904
+ const contentVersion = response.headers.get('x-content-version');
13905
+ if ((etag !== null && etag.replace(/^W\//, '') !== resume.validator) ||
13906
+ (contentVersion && resume.held.contentVersion && contentVersion !== resume.held.contentVersion)) {
13898
13907
  return new SparkVaultError(CONTENT_CHANGED_MESSAGE, 'content_changed');
13899
13908
  }
13900
13909
  const range = CONTENT_RANGE.exec(response.headers.get('content-range') ?? '');
@@ -14055,6 +14064,26 @@ function readRevision(value) {
14055
14064
  }
14056
14065
  }
14057
14066
 
14067
+ /** Core files and Structured Ingots expose the same retained publication metadata. */
14068
+ function mapIngotHistory(data) {
14069
+ return {
14070
+ id: data.ingot_id,
14071
+ versionLimit: data.version_limit,
14072
+ versions: data.versions.map(version => ({
14073
+ versionId: version.version_id,
14074
+ publishedAt: version.published_at,
14075
+ sizeBytes: version.size_bytes,
14076
+ ...(version.content_type === undefined ? {} : { contentType: version.content_type }),
14077
+ })),
14078
+ };
14079
+ }
14080
+ function requireVersionId(value) {
14081
+ if (typeof value !== 'string' || !/^[A-Za-z0-9:_-]{1,128}$/.test(value)) {
14082
+ throw new ValidationError('versionId must name a retained publication');
14083
+ }
14084
+ return value;
14085
+ }
14086
+
14058
14087
  /**
14059
14088
  * Folders Module
14060
14089
  *
@@ -15761,6 +15790,49 @@ class IngotsModule {
15761
15790
  });
15762
15791
  return mapFolderContents(response.data);
15763
15792
  }
15793
+ /** List previous publications of a file, newest first. Structured objects use their product's history method. */
15794
+ async listVersions(vault, ingotId) {
15795
+ const vaultId = requireVaultId(vault);
15796
+ const id = requireResourceId(ingotId, 'ingotId');
15797
+ const { data } = await this.http.get(apiPath `/v1/vaults/${vaultId}/ingots/${id}/versions`, { vat: vault.vatToken });
15798
+ return mapIngotHistory(data);
15799
+ }
15800
+ /** Mint a one-use link to a retained file publication; use downloadVersion to verify the served bytes. */
15801
+ async createVersionDownloadLink(vault, ingotId, versionId) {
15802
+ const vaultId = requireVaultId(vault);
15803
+ const id = requireResourceId(ingotId, 'ingotId');
15804
+ const version = requireVersionId(versionId);
15805
+ const { data } = await this.http.post(apiPath `/v1/vaults/${vaultId}/ingots/${id}/versions/${version}/download`, undefined, { vat: vault.vatToken });
15806
+ if (data.ingot_id !== id || data.content_version !== version) {
15807
+ throw new SparkVaultError('The server returned a different retained publication', 'invalid_response');
15808
+ }
15809
+ assertDownloadUrl(data.download_url, this.allowsTransferHost);
15810
+ return {
15811
+ id: data.ingot_id,
15812
+ downloadUrl: data.download_url,
15813
+ size: data.size_bytes,
15814
+ contentVersion: data.content_version,
15815
+ expiresAt: data.expires_at,
15816
+ ...(data.revision === undefined ? {} : { revision: readRevision(data.revision) }),
15817
+ ...(data.name === undefined ? {} : { name: data.name }),
15818
+ ...(data.content_type === undefined ? {} : { contentType: data.content_type }),
15819
+ };
15820
+ }
15821
+ /** Download a retained file publication; never substitutes the current bytes if history is unavailable. */
15822
+ async downloadVersion(vault, ingotId, versionId) {
15823
+ requireVaultId(vault);
15824
+ requireResourceId(ingotId, 'ingotId');
15825
+ const version = requireVersionId(versionId);
15826
+ const mint = async () => (await this.createVersionDownloadLink(vault, ingotId, version)).downloadUrl;
15827
+ const download = await fetchMintedDownload(mint, {
15828
+ isAllowedHost: this.allowsTransferHost, expectedContentVersion: version,
15829
+ });
15830
+ // Older transfer servers can omit the header; metadata from the mint is not proof of the bytes served.
15831
+ if (download.contentVersion !== version) {
15832
+ throw new SparkVaultError('The download did not identify the requested retained publication', 'invalid_response');
15833
+ }
15834
+ return download.blob;
15835
+ }
15764
15836
  /**
15765
15837
  * Create a signed download link for an ingot (discrete primitive).
15766
15838
  *
@@ -21710,16 +21782,13 @@ class StructuredIngotsModule {
21710
21782
  const id = requireVault(vault);
21711
21783
  const record = requireRef(ref);
21712
21784
  const { data } = await this.http.get(apiPath `/v1/products/structured-ingots/${id}/${record}/versions`, { vat: vault.vatToken });
21713
- return { id: data.ingot_id, versionLimit: data.version_limit, versions: data.versions.map((version) => ({
21714
- versionId: version.version_id, publishedAt: version.published_at, sizeBytes: version.size_bytes,
21715
- })) };
21785
+ return mapIngotHistory(data);
21716
21786
  }
21717
21787
  async restore(vault, ref, versionId, options) {
21718
21788
  const id = requireVault(vault);
21719
21789
  const record = requireRef(ref);
21720
21790
  const precondition = mutationPrecondition(options);
21721
- if (typeof versionId !== 'string' || !/^[A-Za-z0-9:_-]{1,128}$/.test(versionId))
21722
- throw new ValidationError('versionId must name a retained publication');
21791
+ requireVersionId(versionId);
21723
21792
  const { data } = await this.http.post(apiPath `/v1/products/structured-ingots/${id}/${record}/versions/${versionId}/restore`, precondition, { vat: vault.vatToken });
21724
21793
  return mutation(data);
21725
21794
  }
@@ -21888,8 +21957,70 @@ function unsealRequestBody(key, ttlSeconds) {
21888
21957
  return ttlSeconds === undefined ? { [field]: trimmed } : { [field]: trimmed, ttl_seconds: ttlSeconds };
21889
21958
  }
21890
21959
 
21891
- /** Maximum previous publications retained for each structured object. */
21892
- const MAX_STRUCTURED_INGOT_VERSIONS = 50;
21960
+ /**
21961
+ * The apps that manage ingots, each by the id its ingots carry as `managed_by`:
21962
+ * the one statement of those ids, of the name each app goes by, of whether an
21963
+ * app manages a row (isManagedIngot), and of whose rows Core seals server-side
21964
+ * (isServerSealedIngot). Each app marks every ingot it creates
21965
+ * with its own (Structured Ingots also calls Core as it, since Core lets only
21966
+ * the internal invoker an ingot's `managed_by` names create or touch one);
21967
+ * Core, the console, the mobile app and the Slack app ask isManagedIngot of a
21968
+ * row, and the mobile app names the app on the row's sheet. An app's ingot is
21969
+ * the app's: Core's file routes act on it only for the app, the vault shares
21970
+ * it with no one, the app included, and no request files it in a folder
21971
+ * (docs/APPS.md → Managed Ingots).
21972
+ *
21973
+ * A value is stored on every ingot its app creates and never changes on the
21974
+ * row (`managed_by` is immutable), so an id here is never renamed: a new
21975
+ * value would leave every existing ingot naming one no app answers to.
21976
+ *
21977
+ * BROWSER-SAFE: data and pure functions, no imports.
21978
+ */
21979
+
21980
+ const MANAGED_BY = Object.freeze({
21981
+ /** A Structured Ingots record, Identity's directory profiles among them. */
21982
+ STRUCTURED_INGOTS: 'structured-ingots',
21983
+ /** An encrypted catalog of a Structured Ingots type's immutable definitions. */
21984
+ STRUCTURED_INGOT_TYPES: 'structured-ingot-types',
21985
+ /** A help desk message body, email original, attachment or requester export part. */
21986
+ HELP_DESK: 'product-help-desk',
21987
+ /** A Messaging message, compacted page or attachment. */
21988
+ MESSAGING: 'product-messaging'
21989
+ });
21990
+
21991
+ /** Each app's name, as UI copy names the product (docs/DESIGN.md → Voice & copy). */
21992
+ new Map([
21993
+ [MANAGED_BY.STRUCTURED_INGOTS, 'Structured Ingots'],
21994
+ [MANAGED_BY.STRUCTURED_INGOT_TYPES, 'Structured Ingots'],
21995
+ [MANAGED_BY.HELP_DESK, 'Secure Help Desk'],
21996
+ [MANAGED_BY.MESSAGING, 'Messaging']
21997
+ ]);
21998
+
21999
+ /**
22000
+ * The apps inside Core whose ingots Core writes server-side, sealing content
22001
+ * it is handed in one call (apps/api UnifiedIngotService.sealIngotContent):
22002
+ * each such ingot lies at the vault root, at an id its app derives from its
22003
+ * own keys, and holds no name claim. Every other ingot, a Structured Ingots
22004
+ * record's included, is created through Core's upload path and holds its name
22005
+ * by a claim.
22006
+ */
22007
+ new Set([MANAGED_BY.HELP_DESK, MANAGED_BY.MESSAGING]);
22008
+
22009
+ /** Maximum previous publications retained for each user file or object. */
22010
+ const MAX_INGOT_VERSIONS = 50;
22011
+
22012
+ /** Existing vaults retain only current content until retention is enabled. */
22013
+ function ingotVersionLimit(vault) {
22014
+ const limit = vault?.ingot_version_limit === undefined
22015
+ ? (vault?.structured_ingot_version_limit === undefined ? 0 : vault.structured_ingot_version_limit)
22016
+ : vault.ingot_version_limit;
22017
+ // Malformed stored settings must never silently disable retention and purge
22018
+ // history. Every writer uses the same bounded integer contract.
22019
+ if (!Number.isSafeInteger(limit) || limit < 0 || limit > MAX_INGOT_VERSIONS) {
22020
+ throw new RangeError('Invalid ingot version limit');
22021
+ }
22022
+ return limit;
22023
+ }
21893
22024
 
21894
22025
  /**
21895
22026
  * Upload Widget Chrome
@@ -24635,7 +24766,7 @@ class VaultsModule {
24635
24766
  createdAt: v.created_at,
24636
24767
  ingotCount: v.ingot_count,
24637
24768
  storageBytes: v.storage_bytes,
24638
- ...(v.structured_ingot_version_limit === undefined ? {} : { structuredIngotVersionLimit: v.structured_ingot_version_limit }),
24769
+ ...mapVersionHistory(v),
24639
24770
  ...(v.structured_ingots_enabled === undefined ? {} : { structuredIngotsEnabled: v.structured_ingots_enabled }),
24640
24771
  ...mapLifecycle(v),
24641
24772
  })),
@@ -24674,19 +24805,23 @@ class VaultsModule {
24674
24805
  };
24675
24806
  }
24676
24807
  /**
24677
- * Retain this many previous versions of each structured object (0–50).
24678
- * Interactive company administrators only. Applies on each object's next
24679
- * successful change; retained versions count toward storage usage.
24808
+ * Retain this many previous versions of each file or structured object (0–50,
24809
+ * default 0). Interactive company administrators only. Applies on each ingot's
24810
+ * next successful content change; retained versions count toward storage usage.
24680
24811
  */
24681
- async updateStructuredIngotSettings(vaultId, settings) {
24812
+ async updateVersionHistory(vaultId, settings) {
24682
24813
  const id = requireResourceId(vaultId, 'vaultId');
24683
24814
  const limit = settings?.versionLimit;
24684
- if (!Number.isSafeInteger(limit) || limit < 0 || limit > MAX_STRUCTURED_INGOT_VERSIONS) {
24685
- throw new ValidationError(`versionLimit must be a whole number from 0 to ${MAX_STRUCTURED_INGOT_VERSIONS}`);
24815
+ if (!Number.isSafeInteger(limit) || limit < 0 || limit > MAX_INGOT_VERSIONS) {
24816
+ throw new ValidationError(`versionLimit must be a whole number from 0 to ${MAX_INGOT_VERSIONS}`);
24686
24817
  }
24687
- const response = await this.http.put(apiPath `/v1/vaults/${id}/structured-ingot-settings`, { version_limit: limit });
24818
+ const response = await this.http.put(apiPath `/v1/vaults/${id}/version-history`, { version_limit: limit });
24688
24819
  return { vaultId: response.data.vault_id, versionLimit: response.data.version_limit };
24689
24820
  }
24821
+ /** @deprecated Use updateVersionHistory; retention applies to files and structured objects. */
24822
+ async updateStructuredIngotSettings(vaultId, settings) {
24823
+ return this.updateVersionHistory(vaultId, settings);
24824
+ }
24690
24825
  /**
24691
24826
  * Rename a vault.
24692
24827
  *
@@ -24950,6 +25085,12 @@ function mapLifecycle(v) {
24950
25085
  deletionScheduleId: v.deletion_schedule_id,
24951
25086
  };
24952
25087
  }
25088
+ function mapVersionHistory(v) {
25089
+ if (v.ingot_version_limit === undefined && v.structured_ingot_version_limit === undefined)
25090
+ return {};
25091
+ const limit = ingotVersionLimit(v);
25092
+ return { ingotVersionLimit: limit, structuredIngotVersionLimit: limit };
25093
+ }
24953
25094
  function mapVaultDetail(v) {
24954
25095
  return {
24955
25096
  id: v.vault_id,
@@ -24958,7 +25099,7 @@ function mapVaultDetail(v) {
24958
25099
  ...mapLifecycle(v),
24959
25100
  ingotCount: v.ingot_count ?? 0,
24960
25101
  storageBytes: v.storage_bytes ?? 0,
24961
- ...(v.structured_ingot_version_limit === undefined ? {} : { structuredIngotVersionLimit: v.structured_ingot_version_limit }),
25102
+ ...mapVersionHistory(v),
24962
25103
  ...(v.structured_ingots_enabled === undefined ? {} : { structuredIngotsEnabled: v.structured_ingots_enabled }),
24963
25104
  createdAt: v.created_at,
24964
25105
  lastUnsealedAt: v.last_unsealed_at ?? null,
@@ -25752,7 +25893,7 @@ class SparkVault {
25752
25893
  }
25753
25894
  /** Get the SDK version */
25754
25895
  static get version() {
25755
- return '15.9.1';
25896
+ return '15.10.0';
25756
25897
  }
25757
25898
  }
25758
25899
  if (typeof window !== 'undefined') {