@sparkvault/sdk-js 14.1.1 → 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
  *
@@ -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
@@ -1211,6 +1211,7 @@ function resolveConfig(config) {
1211
1211
  portalBaseUrl: normalizeBaseUrl(config.portalBaseUrl ?? PORTAL_URL),
1212
1212
  accessToken: config.accessToken,
1213
1213
  getAccessToken: config.getAccessToken,
1214
+ onVaultSessionTiming: config.onVaultSessionTiming,
1214
1215
  apiKey: config.apiKey,
1215
1216
  clientId: config.clientId,
1216
1217
  // Preloading warms a dialog that only a browser can open; default it off
@@ -1426,6 +1427,7 @@ class SparkVaultApi {
1426
1427
  const { status, message, code, details, retryAfterMs } = await readApiFailure(response);
1427
1428
  throw this.makeError(message, code, status, details, retryAfterMs);
1428
1429
  }
1430
+ options.onResponse?.(response);
1429
1431
  return { data: await readJsonBody(response), status: response.status };
1430
1432
  });
1431
1433
  }
@@ -1514,6 +1516,47 @@ function queryString(params) {
1514
1516
  return query ? `?${query}` : '';
1515
1517
  }
1516
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
+
1517
1560
  /**
1518
1561
  * SparkVault SDK HTTP Client
1519
1562
  */
@@ -1553,6 +1596,7 @@ class HttpClient {
1553
1596
  const { method = 'GET', headers = {}, body, query, vat, timeout = this.config.timeout, credentials, } = options;
1554
1597
  const url = `${this.config.apiBaseUrl}${path}${queryString(query)}`;
1555
1598
  const requestHeaders = await this.getDefaultHeaders(headers, body !== undefined, vat);
1599
+ const requestStartedAtMs = Date.now();
1556
1600
  return exchange(url, { method, headers: requestHeaders, body: body ? JSON.stringify(body) : undefined,
1557
1601
  ...(credentials !== undefined ? { credentials } : {}) }, {
1558
1602
  timeoutMs: timeout,
@@ -1560,6 +1604,8 @@ class HttpClient {
1560
1604
  if (!response.ok) {
1561
1605
  throw this.createErrorFromResponse(await readApiFailure(response));
1562
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);
1563
1609
  return { data: this.unwrapApiResponse(await this.parseResponse(response)) };
1564
1610
  },
1565
1611
  fail: (failure, cause) => {
@@ -13377,7 +13423,11 @@ class UploadApi extends SparkVaultApi {
13377
13423
  * envelope.
13378
13424
  */
13379
13425
  async request(path, options) {
13380
- 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
+ });
13381
13431
  const envelope = typeof raw === 'object' && raw !== null ? raw : null;
13382
13432
  const data = envelope && 'data' in envelope ? envelope.data : raw;
13383
13433
  return { data, status, requestId: envelope?.meta?.request_id };
@@ -14474,6 +14524,8 @@ class IngotsModule {
14474
14524
  * when you want the URL itself; otherwise prefer {@link download}. The link
14475
14525
  * is single-use: Forge claims it the moment a request arrives, so a retry or
14476
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.
14477
14529
  *
14478
14530
  * @example
14479
14531
  * const link = await sv.ingots.createDownloadLink(unsealed, 'ing_abc');
@@ -14481,10 +14533,10 @@ class IngotsModule {
14481
14533
  * remint: async () => (await sv.ingots.createDownloadLink(unsealed, 'ing_abc')).downloadUrl,
14482
14534
  * });
14483
14535
  */
14484
- async createDownloadLink(vault, ingotId) {
14536
+ async createDownloadLink(vault, ingotId, options = {}) {
14485
14537
  const vaultId = requireVaultId(vault);
14486
14538
  const id = requireResourceId(ingotId, 'ingotId');
14487
- 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 });
14488
14540
  if (!response.data.download_url) {
14489
14541
  throw new ValidationError('Download endpoint did not return a download URL');
14490
14542
  }
@@ -14524,8 +14576,8 @@ class IngotsModule {
14524
14576
  * link.download = ingot.downloadFilename;
14525
14577
  * link.click();
14526
14578
  */
14527
- async download(vault, ingotId) {
14528
- 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;
14529
14581
  return (await fetchMintedDownload(mint, { isAllowedHost: this.allowsTransferHost })).blob;
14530
14582
  }
14531
14583
  /**
@@ -20266,12 +20318,16 @@ class VaultsModule {
20266
20318
  * const delegated = await sv.vaults.unseal('vlt_abc', 'dvak_...');
20267
20319
  * console.log('Token:', unsealed.vatToken);
20268
20320
  */
20269
- async unseal(vaultId, key) {
20321
+ async unseal(vaultId, key, options = {}) {
20270
20322
  const id = requireResourceId(vaultId, 'vaultId');
20271
20323
  if (typeof key !== 'string' || !key.trim()) {
20272
20324
  throw new ValidationError('A VMK or DVAK token is required');
20273
20325
  }
20274
- 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));
20275
20331
  if (!response.data.vat) {
20276
20332
  throw new ValidationError('Unseal response did not include a vault access token');
20277
20333
  }
@@ -20281,6 +20337,30 @@ class VaultsModule {
20281
20337
  issuedAt: response.data.issued_at,
20282
20338
  expiresAt: response.data.expires_at,
20283
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,
20284
20364
  };
20285
20365
  }
20286
20366
  /**
@@ -20323,6 +20403,25 @@ class VaultsModule {
20323
20403
  const response = await this.http.get(apiPath `/v1/vaults/${id}`);
20324
20404
  return mapVaultDetail(response.data);
20325
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
+ }
20326
20425
  /**
20327
20426
  * Rename a vault.
20328
20427
  *
@@ -20597,6 +20696,11 @@ function mapVaultDetail(v) {
20597
20696
  createdAt: v.created_at,
20598
20697
  lastUnsealedAt: v.last_unsealed_at ?? null,
20599
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
+ }),
20600
20704
  deletionNoticeUnreached: v.deletion_notice_unreached && v.deletion_notice_unreached.map(mapUnreachedAdmin),
20601
20705
  };
20602
20706
  }
@@ -21360,7 +21464,7 @@ class SparkVault {
21360
21464
  }
21361
21465
  /** Get the SDK version */
21362
21466
  static get version() {
21363
- return '14.1.1';
21467
+ return '14.2.0';
21364
21468
  }
21365
21469
  }
21366
21470
  if (typeof window !== 'undefined') {