@sparkvault/sdk-js 14.1.0 → 14.2.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
@@ -1,6 +1,21 @@
1
1
  /**
2
2
  * SparkVault SDK Configuration
3
3
  */
4
+ /** Server-confirmed timing for the exact vault session a request presented. */
5
+ interface VaultSessionTiming {
6
+ vat: string;
7
+ /** Current reseal deadline in server Unix seconds. */
8
+ expiresAt: number;
9
+ /** Fixed maximum deadline from the original unseal, in server Unix seconds. */
10
+ hardExpiresAt: number;
11
+ /** Seconds remaining on the server, suitable for a device-local countdown. */
12
+ remainingSeconds: number;
13
+ hardRemainingSeconds: number;
14
+ /** Zero for a fixed session; absent when talking to an older Core version. */
15
+ idleTimeoutSeconds?: number;
16
+ /** Device clock before the Core request, for conservative local countdowns. */
17
+ requestStartedAtMs?: number;
18
+ }
4
19
  interface SparkVaultConfig {
5
20
  /** Account ID for Identity operations */
6
21
  accountId: string;
@@ -14,6 +29,8 @@ interface SparkVaultConfig {
14
29
  accessToken?: string;
15
30
  /** Dynamic SparkVault Core access token provider for authenticated API calls. */
16
31
  getAccessToken?: () => string | null | Promise<string | null>;
32
+ /** Observe server-confirmed vault-session timing after an authorized Core response. */
33
+ onVaultSessionTiming?: (timing: VaultSessionTiming) => void;
17
34
  /** Optional API key for server-side SDK use. */
18
35
  apiKey?: string;
19
36
  /**
@@ -49,6 +66,7 @@ interface ResolvedConfig {
49
66
  portalBaseUrl: string;
50
67
  accessToken?: string;
51
68
  getAccessToken?: () => string | null | Promise<string | null>;
69
+ onVaultSessionTiming?: (timing: VaultSessionTiming) => void;
52
70
  apiKey?: string;
53
71
  clientId?: string;
54
72
  preloadConfig: boolean;
@@ -844,10 +862,42 @@ interface UnsealedVault {
844
862
  vatToken: string;
845
863
  /** VAT issued-at timestamp (Unix seconds) */
846
864
  issuedAt: number;
847
- /** VAT expiry timestamp (Unix seconds) */
865
+ /** Current reseal deadline (Unix seconds); server activity responses may extend it. */
866
+ expiresAt: number;
867
+ /** Seconds until the initial reseal deadline. */
868
+ ttlSeconds: number;
869
+ /** Fixed maximum deadline from this unseal (Unix seconds). */
870
+ hardExpiresAt?: number;
871
+ /** Inactivity window in seconds; zero means a fixed maximum with no extensions. */
872
+ idleTimeoutSeconds?: number;
873
+ }
874
+ /** A shorter hard lifetime for this unseal; omitted to follow the vault settings. */
875
+ interface UnsealVaultOptions {
876
+ ttlSeconds?: number;
877
+ }
878
+ /** The existing VAT session after an explicit activity extension. */
879
+ interface VaultSessionExtension {
880
+ vaultId: string;
848
881
  expiresAt: number;
849
- /** VAT lifetime in seconds */
882
+ hardExpiresAt: number;
883
+ idleTimeoutSeconds: number;
850
884
  ttlSeconds: number;
885
+ /** False once the fixed maximum has been reached; another unseal is needed. */
886
+ canExtend: boolean;
887
+ }
888
+ /** Null inherits the system default; zero idle seconds disables activity extensions. */
889
+ interface VaultResealSettings {
890
+ idleSeconds: number | null;
891
+ maxSeconds: number | null;
892
+ }
893
+ /** Current system defaults, in seconds. */
894
+ interface VaultResealDefaults {
895
+ idleSeconds: number;
896
+ maxSeconds: number;
897
+ }
898
+ interface VaultResealSettingsResult extends VaultResealSettings {
899
+ vaultId: string;
900
+ defaults: VaultResealDefaults;
851
901
  }
852
902
  /** Lifecycle metadata, including the lockout and seven-day cancellation window. */
853
903
  interface VaultLifecycle {
@@ -942,6 +992,11 @@ interface VaultDetail extends VaultLifecycle {
942
992
  lastUnsealedAt: number | null;
943
993
  /** Lifetime unseal count */
944
994
  unsealCount: number;
995
+ /** Explicit inactivity setting, or null to inherit the system default. */
996
+ resealIdleSeconds?: number | null;
997
+ /** Explicit maximum unsealed lifetime, or null to inherit the system default. */
998
+ resealMaxSeconds?: number | null;
999
+ resealDefaults?: VaultResealDefaults;
945
1000
  /**
946
1001
  * With `deletion_scheduled`, read in a company admin's signed-in session:
947
1002
  * each administrator the schedule's notice could not reach, empty when it
@@ -2756,6 +2811,11 @@ interface CreatedIngot {
2756
2811
  */
2757
2812
  created: boolean;
2758
2813
  }
2814
+ /** Options shared by download and createDownloadLink. */
2815
+ interface DownloadIngotOptions {
2816
+ /** False for automatic display/prefetch: fetching bytes will not extend vault inactivity. */
2817
+ countAsActivity?: boolean;
2818
+ }
2759
2819
  /** The discrete primitive returned by createDownloadLink. */
2760
2820
  interface IngotDownloadLink {
2761
2821
  /** Opaque published-content revision; null for legacy content. */
@@ -3627,7 +3687,14 @@ declare class VaultsModule {
3627
3687
  * const delegated = await sv.vaults.unseal('vlt_abc', 'dvak_...');
3628
3688
  * console.log('Token:', unsealed.vatToken);
3629
3689
  */
3630
- unseal(vaultId: string, key: string): Promise<UnsealedVault>;
3690
+ unseal(vaultId: string, key: string, options?: UnsealVaultOptions): Promise<UnsealedVault>;
3691
+ /**
3692
+ * Explicitly extend this live session's inactivity window, up to the
3693
+ * original unseal's fixed maximum. No key is needed and no new VAT is minted.
3694
+ * A fixed-duration session or one at its maximum is refused by Core; another
3695
+ * unseal is required. The normal timing observer receives the new deadline.
3696
+ */
3697
+ extendSession(vaultId: string, vat: string): Promise<VaultSessionExtension>;
3631
3698
  /**
3632
3699
  * List vaults for the account. Results are paginated (server default 100 per
3633
3700
  * page, max 500); follow `nextCursor` to fetch subsequent pages.
@@ -3649,6 +3716,12 @@ declare class VaultsModule {
3649
3716
  * console.log(vault.status, vault.ingotCount);
3650
3717
  */
3651
3718
  get(vaultId: string): Promise<VaultDetail>;
3719
+ /**
3720
+ * Set when this vault reseals after inactivity and after an unseal.
3721
+ * Company administrators only. Changes apply on the next unseal.
3722
+ * Null values inherit system defaults; zero idle seconds disables extensions.
3723
+ */
3724
+ updateResealSettings(vaultId: string, settings: VaultResealSettings): Promise<VaultResealSettingsResult>;
3652
3725
  /**
3653
3726
  * Rename a vault.
3654
3727
  *
@@ -3852,11 +3925,11 @@ declare class SparkVaultError extends Error {
3852
3925
  readonly statusCode?: number;
3853
3926
  readonly details?: Record<string, unknown>;
3854
3927
  /**
3855
- * The answer's `Retry-After`, in ms from the answer, read as the platform's
3856
- * transfer policy reads it (RFC 9110 §10.2.3: delay-seconds or an
3928
+ * The answer's `Retry-After`, in ms from the answer, read by the platform's
3929
+ * one parser (`parseRetryAfterMs`; RFC 9110 §10.2.3: delay-seconds or an
3857
3930
  * HTTP-date): the earliest a next attempt can expect another answer, which
3858
3931
  * every retry the SDK makes waits out as a floor. Null when the answer
3859
- * carried none the policy could read, or no answer arrived.
3932
+ * carried none the parser could read, or no answer arrived.
3860
3933
  */
3861
3934
  readonly retryAfterMs: number | null;
3862
3935
  /**
@@ -4234,6 +4307,8 @@ declare class IngotsModule {
4234
4307
  * when you want the URL itself; otherwise prefer {@link download}. The link
4235
4308
  * is single-use: Forge claims it the moment a request arrives, so a retry or
4236
4309
  * a resume needs a link of its own (`fetchDownload`'s `remint`).
4310
+ * Automatic display/prefetch should pass `{ countAsActivity: false }` so
4311
+ * loading visible content does not extend the vault's inactivity deadline.
4237
4312
  *
4238
4313
  * @example
4239
4314
  * const link = await sv.ingots.createDownloadLink(unsealed, 'ing_abc');
@@ -4241,7 +4316,7 @@ declare class IngotsModule {
4241
4316
  * remint: async () => (await sv.ingots.createDownloadLink(unsealed, 'ing_abc')).downloadUrl,
4242
4317
  * });
4243
4318
  */
4244
- createDownloadLink(vault: UnsealedVault, ingotId: string): Promise<IngotDownloadLink>;
4319
+ createDownloadLink(vault: UnsealedVault, ingotId: string, options?: DownloadIngotOptions): Promise<IngotDownloadLink>;
4245
4320
  /**
4246
4321
  * Download an ingot as a Blob (high-level flow).
4247
4322
  *
@@ -4268,7 +4343,7 @@ declare class IngotsModule {
4268
4343
  * link.download = ingot.downloadFilename;
4269
4344
  * link.click();
4270
4345
  */
4271
- download(vault: UnsealedVault, ingotId: string): Promise<Blob>;
4346
+ download(vault: UnsealedVault, ingotId: string, options?: DownloadIngotOptions): Promise<Blob>;
4272
4347
  /**
4273
4348
  * Get an ingot's sharing configuration.
4274
4349
  *
@@ -5022,4 +5097,4 @@ declare global {
5022
5097
  }
5023
5098
 
5024
5099
  export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, HelpDeskClient, HelpDeskModule, IdentityModule, IdentityProviderError, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UnauthorizedError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, isReceivedUploadFailure, logger, setDebugMode };
5025
- export type { AccessLogRetention, AccessLogsOptions, CreateFolderOptions, CreateNotifySendOptions, CreateSparkOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, FolderPage, GenerateEntropyOptions, 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, HelpDeskTicket, HelpDeskTicketCreated, HelpDeskTicketDetail, HelpDeskTicketList, HelpDeskTimeline, HelpDeskVerifyPinOptions, AttachOptions as IdentityAttachOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvitation, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListFoldersOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, 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, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, 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, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, SignInOptions, SignInResult, Spark, SparkInviteResend, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StartedVaultDeletion, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreachedAdmin, UnreadCountResponse, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadEnd, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultLifecycle, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, WebPushSubscriptionInput };
5100
+ export type { AccessLogRetention, AccessLogsOptions, CreateFolderOptions, CreateNotifySendOptions, CreateSparkOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, DownloadIngotOptions, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, FolderPage, GenerateEntropyOptions, 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, HelpDeskTicket, HelpDeskTicketCreated, HelpDeskTicketDetail, HelpDeskTicketList, HelpDeskTimeline, HelpDeskVerifyPinOptions, AttachOptions as IdentityAttachOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvitation, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListFoldersOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, 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, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, 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, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, SignInOptions, SignInResult, Spark, SparkInviteResend, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StartedVaultDeletion, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreachedAdmin, UnreadCountResponse, UnsealVaultOptions, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, 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
@@ -187,6 +187,12 @@ const UPLOAD_REFUSAL_HEADER = 'X-Upload-Refusal';
187
187
  * (forge-tus), the browser SDK (sdk-js bundles this module) and the mobile SDK
188
188
  * (sdk-mobile carries a generated copy) read every answer the same way.
189
189
  *
190
+ * It also holds the one reading of `Retry-After` every JavaScript client
191
+ * applies to any answer, a transfer's or not (parseRetryAfterMs), and the one
192
+ * wait a thumbnail fetch gives a busy Forge before its single retry
193
+ * (thumbnailBusyWaitMs), so no client keeps a parser of its own that drifts
194
+ * in what it accepts.
195
+ *
190
196
  * It encodes what Google Drive, Google Cloud Storage, OneDrive, Dropbox and
191
197
  * AWS document for resumable transfers:
192
198
  * - only a request that got no answer, 408, 425, 429 or a 5xx is retried;
@@ -307,6 +313,8 @@ const CORE_CODE = /^[A-Z][A-Z0-9_]{0,63}$/;
307
313
 
308
314
 
309
315
  const UPLOAD_OFFSET_HEADER = 'Upload-Offset';
316
+
317
+ /** The header every client reads an answer's wait from (parseRetryAfterMs). */
310
318
  const RETRY_AFTER_HEADER = 'Retry-After';
311
319
 
312
320
  /**
@@ -391,7 +399,7 @@ function classifyTransferResponse({ status, headers = null, details = null, rece
391
399
  const coreCode = mayNameCoreCode(status, offset)
392
400
  ? coreCodeIn(details) ?? coreCodeOf(header(UPLOAD_REFUSAL_HEADER))
393
401
  : null;
394
- const retryAfterMs = readRetryAfterMs(header(RETRY_AFTER_HEADER), now);
402
+ const retryAfterMs = parseRetryAfterMs(header(RETRY_AFTER_HEADER), now);
395
403
  return {
396
404
  verdict: verdictFor(status, { offset, coreCode, deferral: receipt && retryAfterMs !== null }),
397
405
  retryAfterMs,
@@ -450,14 +458,26 @@ function readCount(value) {
450
458
  return Number.isSafeInteger(count) ? count : null;
451
459
  }
452
460
 
453
- /** RFC 9110 §10.2.3: `Retry-After` is delay-seconds or an HTTP-date. */
454
- function readRetryAfterMs(value, now) {
455
- const seconds = readCount(value);
461
+ /**
462
+ * An answer's `Retry-After` (RFC 9110 §10.2.3: delay-seconds or an
463
+ * HTTP-date), as every JavaScript client reads it from any answer: whole
464
+ * seconds, or the time until the date, an HTTP-date already past reading as 0.
465
+ *
466
+ * @param {unknown} headerValue - The header as received (null when absent)
467
+ * @param {number} [now] - When the answer arrived (epoch ms), which an
468
+ * HTTP-date counts from and an obsolete two-digit year is placed by
469
+ * @returns {number|null} ms from the answer, or null when absent or
470
+ * unreadable: not text, a delay other than whole seconds in decimal digits,
471
+ * words, a date that names no real moment, or seconds too large to count
472
+ * in ms
473
+ */
474
+ function parseRetryAfterMs(headerValue, now = Date.now()) {
475
+ const seconds = readCount(headerValue);
456
476
  if (seconds !== null) {
457
477
  const ms = seconds * 1000;
458
478
  return Number.isSafeInteger(ms) ? ms : null;
459
479
  }
460
- const at = typeof value === 'string' ? parseHttpDate(value.trim(), now) : null;
480
+ const at = typeof headerValue === 'string' ? parseHttpDate(headerValue.trim(), now) : null;
461
481
  return at === null ? null : Math.max(0, at - now);
462
482
  }
463
483
 
@@ -938,10 +958,8 @@ function parseJson(text) {
938
958
  * `{ message }`) or with no JSON at all, so each field falls back to its flat
939
959
  * form and then to a default. The body is read leniently: a failure's status
940
960
  * and class never depend on the body being JSON. The `Retry-After` is read by
941
- * the transfer policy's one parser (`@sparkvault/app-sdk/transfer-retry`),
942
- * never a second one: the policy reads a whole answer at once, and only its
943
- * header reading is kept here, because an API answer is the service's
944
- * verdict, never a transfer answer the policy's verdict applies to.
961
+ * the platform's one parser (`parseRetryAfterMs`,
962
+ * `@sparkvault/app-sdk/transfer-retry`), never a second one.
945
963
  */
946
964
  function failureOf(status, body, header) {
947
965
  const root = recordField(body) ?? {};
@@ -951,7 +969,7 @@ function failureOf(status, body, header) {
951
969
  message: stringField(nested?.message) ?? stringField(root.message) ?? stringField(root.error) ?? 'Request failed',
952
970
  code: stringField(nested?.code) ?? stringField(root.code) ?? 'api_error',
953
971
  details: recordField(nested?.details) ?? recordField(root.details),
954
- retryAfterMs: classifyTransferResponse({ status, headers: header }).retryAfterMs,
972
+ retryAfterMs: parseRetryAfterMs(header(RETRY_AFTER_HEADER)),
955
973
  };
956
974
  }
957
975
  /**
@@ -1193,6 +1211,7 @@ function resolveConfig(config) {
1193
1211
  portalBaseUrl: normalizeBaseUrl(config.portalBaseUrl ?? PORTAL_URL),
1194
1212
  accessToken: config.accessToken,
1195
1213
  getAccessToken: config.getAccessToken,
1214
+ onVaultSessionTiming: config.onVaultSessionTiming,
1196
1215
  apiKey: config.apiKey,
1197
1216
  clientId: config.clientId,
1198
1217
  // Preloading warms a dialog that only a browser can open; default it off
@@ -1408,6 +1427,7 @@ class SparkVaultApi {
1408
1427
  const { status, message, code, details, retryAfterMs } = await readApiFailure(response);
1409
1428
  throw this.makeError(message, code, status, details, retryAfterMs);
1410
1429
  }
1430
+ options.onResponse?.(response);
1411
1431
  return { data: await readJsonBody(response), status: response.status };
1412
1432
  });
1413
1433
  }
@@ -1496,6 +1516,47 @@ function queryString(params) {
1496
1516
  return query ? `?${query}` : '';
1497
1517
  }
1498
1518
 
1519
+ /** Vault settings for resealing, and the server's timing of a held session. */
1520
+ const VAULT_RESEAL_LIMITS = Object.freeze({ minSeconds: 60, maxSeconds: 86400 });
1521
+
1522
+ /** Timing is bound by clients to the VAT on the request, never a returned bearer. */
1523
+ const VAULT_SESSION_HEADERS = Object.freeze({
1524
+ expiresAt: 'X-Vault-Session-Expires-At',
1525
+ hardExpiresAt: 'X-Vault-Session-Hard-Expires-At',
1526
+ remainingSeconds: 'X-Vault-Session-Remaining-Seconds',
1527
+ hardRemainingSeconds: 'X-Vault-Session-Hard-Remaining-Seconds',
1528
+ idleTimeoutSeconds: 'X-Vault-Session-Idle-Timeout-Seconds'
1529
+ });
1530
+
1531
+ /** Read Fetch Headers or ordinary response headers; old servers return no timing. */
1532
+ function readVaultSessionTiming(headers) {
1533
+ if (!headers) return null;
1534
+ const timing = {};
1535
+ for (const [field, name] of Object.entries(VAULT_SESSION_HEADERS)) {
1536
+ const raw = typeof headers.get === 'function'
1537
+ ? headers.get(name)
1538
+ : headers[name.toLowerCase()] ?? headers[name];
1539
+ if (raw === null || raw === undefined || raw === '') {
1540
+ if (field === 'idleTimeoutSeconds') continue;
1541
+ return null;
1542
+ }
1543
+ const value = Number(raw);
1544
+ if (!Number.isSafeInteger(value) || value < 0) return null;
1545
+ timing[field] = value;
1546
+ }
1547
+ if (timing.expiresAt > timing.hardExpiresAt || timing.remainingSeconds > timing.hardRemainingSeconds) return null;
1548
+ return timing;
1549
+ }
1550
+
1551
+ /** Read only server-confirmed session deadlines, bound to the request's VAT. */
1552
+ function publishVaultSessionTiming(config, vat, response, requestStartedAtMs) {
1553
+ if (!vat || !response.ok || !config.onVaultSessionTiming)
1554
+ return;
1555
+ const timing = readVaultSessionTiming(response.headers);
1556
+ if (timing)
1557
+ config.onVaultSessionTiming({ vat, ...timing, requestStartedAtMs });
1558
+ }
1559
+
1499
1560
  /**
1500
1561
  * SparkVault SDK HTTP Client
1501
1562
  */
@@ -1535,6 +1596,7 @@ class HttpClient {
1535
1596
  const { method = 'GET', headers = {}, body, query, vat, timeout = this.config.timeout, credentials, } = options;
1536
1597
  const url = `${this.config.apiBaseUrl}${path}${queryString(query)}`;
1537
1598
  const requestHeaders = await this.getDefaultHeaders(headers, body !== undefined, vat);
1599
+ const requestStartedAtMs = Date.now();
1538
1600
  return exchange(url, { method, headers: requestHeaders, body: body ? JSON.stringify(body) : undefined,
1539
1601
  ...(credentials !== undefined ? { credentials } : {}) }, {
1540
1602
  timeoutMs: timeout,
@@ -1542,6 +1604,8 @@ class HttpClient {
1542
1604
  if (!response.ok) {
1543
1605
  throw this.createErrorFromResponse(await readApiFailure(response));
1544
1606
  }
1607
+ // Read timing before the body: a successful mutation may answer 204.
1608
+ publishVaultSessionTiming(this.config, new Headers(requestHeaders).get('X-Vault-Access-Token') ?? undefined, response, requestStartedAtMs);
1545
1609
  return { data: this.unwrapApiResponse(await this.parseResponse(response)) };
1546
1610
  },
1547
1611
  fail: (failure, cause) => {
@@ -13359,7 +13423,11 @@ class UploadApi extends SparkVaultApi {
13359
13423
  * envelope.
13360
13424
  */
13361
13425
  async request(path, options) {
13362
- const { data: raw, status } = await this.rawRequest(`${this.config.apiBaseUrl}${path}`, options);
13426
+ const requestStartedAtMs = Date.now();
13427
+ const { data: raw, status } = await this.rawRequest(`${this.config.apiBaseUrl}${path}`, {
13428
+ ...options,
13429
+ onResponse: (response) => publishVaultSessionTiming(this.config, new Headers(options.headers).get('X-Vault-Access-Token') ?? undefined, response, requestStartedAtMs),
13430
+ });
13363
13431
  const envelope = typeof raw === 'object' && raw !== null ? raw : null;
13364
13432
  const data = envelope && 'data' in envelope ? envelope.data : raw;
13365
13433
  return { data, status, requestId: envelope?.meta?.request_id };
@@ -14456,6 +14524,8 @@ class IngotsModule {
14456
14524
  * when you want the URL itself; otherwise prefer {@link download}. The link
14457
14525
  * is single-use: Forge claims it the moment a request arrives, so a retry or
14458
14526
  * a resume needs a link of its own (`fetchDownload`'s `remint`).
14527
+ * Automatic display/prefetch should pass `{ countAsActivity: false }` so
14528
+ * loading visible content does not extend the vault's inactivity deadline.
14459
14529
  *
14460
14530
  * @example
14461
14531
  * const link = await sv.ingots.createDownloadLink(unsealed, 'ing_abc');
@@ -14463,10 +14533,10 @@ class IngotsModule {
14463
14533
  * remint: async () => (await sv.ingots.createDownloadLink(unsealed, 'ing_abc')).downloadUrl,
14464
14534
  * });
14465
14535
  */
14466
- async createDownloadLink(vault, ingotId) {
14536
+ async createDownloadLink(vault, ingotId, options = {}) {
14467
14537
  const vaultId = requireVaultId(vault);
14468
14538
  const id = requireResourceId(ingotId, 'ingotId');
14469
- const response = await this.http.post(apiPath `/v1/vaults/${vaultId}/ingots/${id}/download`, undefined, { vat: vault.vatToken });
14539
+ const response = await this.http.post(apiPath `/v1/vaults/${vaultId}/ingots/${id}/download`, options.countAsActivity === undefined ? undefined : { count_as_activity: options.countAsActivity }, { vat: vault.vatToken });
14470
14540
  if (!response.data.download_url) {
14471
14541
  throw new ValidationError('Download endpoint did not return a download URL');
14472
14542
  }
@@ -14506,8 +14576,8 @@ class IngotsModule {
14506
14576
  * link.download = ingot.downloadFilename;
14507
14577
  * link.click();
14508
14578
  */
14509
- async download(vault, ingotId) {
14510
- const mint = async () => (await this.createDownloadLink(vault, ingotId)).downloadUrl;
14579
+ async download(vault, ingotId, options = {}) {
14580
+ const mint = async () => (await this.createDownloadLink(vault, ingotId, options)).downloadUrl;
14511
14581
  return (await fetchMintedDownload(mint, { isAllowedHost: this.allowsTransferHost })).blob;
14512
14582
  }
14513
14583
  /**
@@ -20248,12 +20318,16 @@ class VaultsModule {
20248
20318
  * const delegated = await sv.vaults.unseal('vlt_abc', 'dvak_...');
20249
20319
  * console.log('Token:', unsealed.vatToken);
20250
20320
  */
20251
- async unseal(vaultId, key) {
20321
+ async unseal(vaultId, key, options = {}) {
20252
20322
  const id = requireResourceId(vaultId, 'vaultId');
20253
20323
  if (typeof key !== 'string' || !key.trim()) {
20254
20324
  throw new ValidationError('A VMK or DVAK token is required');
20255
20325
  }
20256
- const response = await this.http.post(apiPath `/v1/vaults/${id}/unseal`, unsealRequestBody(key));
20326
+ if (options.ttlSeconds !== undefined &&
20327
+ (!Number.isSafeInteger(options.ttlSeconds) || options.ttlSeconds < 1 || options.ttlSeconds > VAULT_RESEAL_LIMITS.maxSeconds)) {
20328
+ throw new ValidationError(`ttlSeconds must be a whole number from 1 to ${VAULT_RESEAL_LIMITS.maxSeconds}`);
20329
+ }
20330
+ const response = await this.http.post(apiPath `/v1/vaults/${id}/unseal`, unsealRequestBody(key, options.ttlSeconds));
20257
20331
  if (!response.data.vat) {
20258
20332
  throw new ValidationError('Unseal response did not include a vault access token');
20259
20333
  }
@@ -20263,6 +20337,30 @@ class VaultsModule {
20263
20337
  issuedAt: response.data.issued_at,
20264
20338
  expiresAt: response.data.expires_at,
20265
20339
  ttlSeconds: response.data.ttl_seconds,
20340
+ ...(response.data.hard_expires_at === undefined ? {} : { hardExpiresAt: response.data.hard_expires_at }),
20341
+ ...(response.data.idle_timeout_seconds === undefined ? {} : { idleTimeoutSeconds: response.data.idle_timeout_seconds }),
20342
+ };
20343
+ }
20344
+ /**
20345
+ * Explicitly extend this live session's inactivity window, up to the
20346
+ * original unseal's fixed maximum. No key is needed and no new VAT is minted.
20347
+ * A fixed-duration session or one at its maximum is refused by Core; another
20348
+ * unseal is required. The normal timing observer receives the new deadline.
20349
+ */
20350
+ async extendSession(vaultId, vat) {
20351
+ const id = requireResourceId(vaultId, 'vaultId');
20352
+ if (typeof vat !== 'string' || !vat.startsWith('vat_')) {
20353
+ throw new ValidationError('A Vault Access Token is required to extend the session');
20354
+ }
20355
+ const response = await this.http.post(apiPath `/v1/vaults/${id}/session/extend`, undefined, { vat });
20356
+ const value = response.data;
20357
+ return {
20358
+ vaultId: value.vault_id,
20359
+ expiresAt: value.expires_at,
20360
+ hardExpiresAt: value.hard_expires_at,
20361
+ idleTimeoutSeconds: value.idle_timeout_seconds,
20362
+ ttlSeconds: value.ttl_seconds,
20363
+ canExtend: value.can_extend,
20266
20364
  };
20267
20365
  }
20268
20366
  /**
@@ -20305,6 +20403,25 @@ class VaultsModule {
20305
20403
  const response = await this.http.get(apiPath `/v1/vaults/${id}`);
20306
20404
  return mapVaultDetail(response.data);
20307
20405
  }
20406
+ /**
20407
+ * Set when this vault reseals after inactivity and after an unseal.
20408
+ * Company administrators only. Changes apply on the next unseal.
20409
+ * Null values inherit system defaults; zero idle seconds disables extensions.
20410
+ */
20411
+ async updateResealSettings(vaultId, settings) {
20412
+ const id = requireResourceId(vaultId, 'vaultId');
20413
+ const response = await this.http.put(apiPath `/v1/vaults/${id}/reseal-settings`, {
20414
+ reseal_idle_seconds: settings.idleSeconds,
20415
+ reseal_max_seconds: settings.maxSeconds,
20416
+ });
20417
+ const value = response.data;
20418
+ return {
20419
+ vaultId: value.vault_id,
20420
+ idleSeconds: value.reseal_idle_seconds,
20421
+ maxSeconds: value.reseal_max_seconds,
20422
+ defaults: { idleSeconds: value.reseal_defaults.idle_seconds, maxSeconds: value.reseal_defaults.max_seconds },
20423
+ };
20424
+ }
20308
20425
  /**
20309
20426
  * Rename a vault.
20310
20427
  *
@@ -20579,6 +20696,11 @@ function mapVaultDetail(v) {
20579
20696
  createdAt: v.created_at,
20580
20697
  lastUnsealedAt: v.last_unsealed_at ?? null,
20581
20698
  unsealCount: v.unseal_count ?? 0,
20699
+ ...(v.reseal_idle_seconds === undefined ? {} : { resealIdleSeconds: v.reseal_idle_seconds }),
20700
+ ...(v.reseal_max_seconds === undefined ? {} : { resealMaxSeconds: v.reseal_max_seconds }),
20701
+ ...(v.reseal_defaults === undefined ? {} : {
20702
+ resealDefaults: { idleSeconds: v.reseal_defaults.idle_seconds, maxSeconds: v.reseal_defaults.max_seconds },
20703
+ }),
20582
20704
  deletionNoticeUnreached: v.deletion_notice_unreached && v.deletion_notice_unreached.map(mapUnreachedAdmin),
20583
20705
  };
20584
20706
  }
@@ -21342,7 +21464,7 @@ class SparkVault {
21342
21464
  }
21343
21465
  /** Get the SDK version */
21344
21466
  static get version() {
21345
- return '14.1.0';
21467
+ return '14.2.0';
21346
21468
  }
21347
21469
  }
21348
21470
  if (typeof window !== 'undefined') {