@sparkvault/sdk-js 14.1.1 → 14.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -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. */
848
866
  expiresAt: number;
849
- /** VAT lifetime in seconds */
867
+ /** Seconds until the initial reseal deadline. */
850
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;
881
+ expiresAt: number;
882
+ hardExpiresAt: number;
883
+ idleTimeoutSeconds: number;
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
@@ -1194,6 +1249,11 @@ interface NotifyRecipientRef {
1194
1249
  type NotifyRecipient = string | NotifyRecipientRef;
1195
1250
  /** Content to seal into a fresh Spark, one per recipient. */
1196
1251
  interface NotifySendContent {
1252
+ /**
1253
+ * Sealed as written. A plaintext send's has its text-direction control
1254
+ * characters (U+202A to U+202E, U+2066 to U+2069) removed, so it shows in
1255
+ * the order it is written.
1256
+ */
1197
1257
  payload: string;
1198
1258
  /** Defaults to `text/plain`. A plaintext send accepts only `text/plain` or `text/html`. */
1199
1259
  contentType?: string;
@@ -1274,7 +1334,11 @@ interface CreateNotifySendOptions {
1274
1334
  * recipients and their handles, title, category, instructions, policy,
1275
1335
  * channels and escalation): one that differs in any of them is refused 400
1276
1336
  * (`serviceCode` `VALIDATION_ERROR`), and the stored send stands. `type` and
1277
- * `historyTtlDays` are not compared: the stored send keeps its own.
1337
+ * `historyTtlDays` are not compared: the stored send keeps its own. The send
1338
+ * stores the title, instructions and a plaintext payload without their
1339
+ * text-direction control characters (U+202A to U+202E, U+2066 to U+2069) and
1340
+ * compares a replay's the same way, so one that differs only by them is the
1341
+ * same send.
1278
1342
  */
1279
1343
  sendId?: string;
1280
1344
  /** 1-500 recipients. An ingot send accepts exactly one. */
@@ -1295,9 +1359,10 @@ interface CreateNotifySendOptions {
1295
1359
  channels?: Array<'in_app' | 'email' | 'push' | 'web_push'>;
1296
1360
  escalation?: NotifyEscalation;
1297
1361
  /**
1298
- * Channel-agnostic display title (rides the email subject). Cut to 200
1299
- * characters, never rejected for its length. A title that reads as SparkVault,
1300
- * or holds a text-direction control character, is refused 400 with
1362
+ * Channel-agnostic display title (rides the email subject). Its text-direction
1363
+ * control characters (U+202A to U+202E, U+2066 to U+2069) are removed, and it
1364
+ * is cut to 200 characters, never rejected for its length. A title that reads
1365
+ * as SparkVault is refused 400 with
1301
1366
  * `details: { field: 'title', reason: 'reserved_name' }`: the notification goes
1302
1367
  * out in your organization's name.
1303
1368
  */
@@ -1317,7 +1382,8 @@ interface CreateNotifySendOptions {
1317
1382
  */
1318
1383
  type?: string;
1319
1384
  /**
1320
- * NON-SECRET display text (≤500 chars) shown alongside a sealed send — e.g.
1385
+ * NON-SECRET display text (≤500 chars once its text-direction control
1386
+ * characters are removed) shown alongside a sealed send, such as
1321
1387
  * "verify with your passkey to open". It is never the sealed content.
1322
1388
  */
1323
1389
  instructions?: string;
@@ -2756,6 +2822,11 @@ interface CreatedIngot {
2756
2822
  */
2757
2823
  created: boolean;
2758
2824
  }
2825
+ /** Options shared by download and createDownloadLink. */
2826
+ interface DownloadIngotOptions {
2827
+ /** False for automatic display/prefetch: fetching bytes will not extend vault inactivity. */
2828
+ countAsActivity?: boolean;
2829
+ }
2759
2830
  /** The discrete primitive returned by createDownloadLink. */
2760
2831
  interface IngotDownloadLink {
2761
2832
  /** Opaque published-content revision; null for legacy content. */
@@ -3627,7 +3698,14 @@ declare class VaultsModule {
3627
3698
  * const delegated = await sv.vaults.unseal('vlt_abc', 'dvak_...');
3628
3699
  * console.log('Token:', unsealed.vatToken);
3629
3700
  */
3630
- unseal(vaultId: string, key: string): Promise<UnsealedVault>;
3701
+ unseal(vaultId: string, key: string, options?: UnsealVaultOptions): Promise<UnsealedVault>;
3702
+ /**
3703
+ * Explicitly extend this live session's inactivity window, up to the
3704
+ * original unseal's fixed maximum. No key is needed and no new VAT is minted.
3705
+ * A fixed-duration session or one at its maximum is refused by Core; another
3706
+ * unseal is required. The normal timing observer receives the new deadline.
3707
+ */
3708
+ extendSession(vaultId: string, vat: string): Promise<VaultSessionExtension>;
3631
3709
  /**
3632
3710
  * List vaults for the account. Results are paginated (server default 100 per
3633
3711
  * page, max 500); follow `nextCursor` to fetch subsequent pages.
@@ -3649,6 +3727,12 @@ declare class VaultsModule {
3649
3727
  * console.log(vault.status, vault.ingotCount);
3650
3728
  */
3651
3729
  get(vaultId: string): Promise<VaultDetail>;
3730
+ /**
3731
+ * Set when this vault reseals after inactivity and after an unseal.
3732
+ * Company administrators only. Changes apply on the next unseal.
3733
+ * Null values inherit system defaults; zero idle seconds disables extensions.
3734
+ */
3735
+ updateResealSettings(vaultId: string, settings: VaultResealSettings): Promise<VaultResealSettingsResult>;
3652
3736
  /**
3653
3737
  * Rename a vault.
3654
3738
  *
@@ -4234,6 +4318,8 @@ declare class IngotsModule {
4234
4318
  * when you want the URL itself; otherwise prefer {@link download}. The link
4235
4319
  * is single-use: Forge claims it the moment a request arrives, so a retry or
4236
4320
  * a resume needs a link of its own (`fetchDownload`'s `remint`).
4321
+ * Automatic display/prefetch should pass `{ countAsActivity: false }` so
4322
+ * loading visible content does not extend the vault's inactivity deadline.
4237
4323
  *
4238
4324
  * @example
4239
4325
  * const link = await sv.ingots.createDownloadLink(unsealed, 'ing_abc');
@@ -4241,7 +4327,7 @@ declare class IngotsModule {
4241
4327
  * remint: async () => (await sv.ingots.createDownloadLink(unsealed, 'ing_abc')).downloadUrl,
4242
4328
  * });
4243
4329
  */
4244
- createDownloadLink(vault: UnsealedVault, ingotId: string): Promise<IngotDownloadLink>;
4330
+ createDownloadLink(vault: UnsealedVault, ingotId: string, options?: DownloadIngotOptions): Promise<IngotDownloadLink>;
4245
4331
  /**
4246
4332
  * Download an ingot as a Blob (high-level flow).
4247
4333
  *
@@ -4268,7 +4354,7 @@ declare class IngotsModule {
4268
4354
  * link.download = ingot.downloadFilename;
4269
4355
  * link.click();
4270
4356
  */
4271
- download(vault: UnsealedVault, ingotId: string): Promise<Blob>;
4357
+ download(vault: UnsealedVault, ingotId: string, options?: DownloadIngotOptions): Promise<Blob>;
4272
4358
  /**
4273
4359
  * Get an ingot's sharing configuration.
4274
4360
  *
@@ -5022,4 +5108,4 @@ declare global {
5022
5108
  }
5023
5109
 
5024
5110
  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 };
5111
+ 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
  /**
@@ -16440,14 +16492,17 @@ const BRACKET_PAIRS =
16440
16492
  * right-to-left letter or mark, or an Arabic digit, between Latin words
16441
16493
  * reverses their order: "Vault", U+05BE HEBREW PUNCTUATION MAQAF, "Spark" is
16442
16494
  * laid out in a right-to-left paragraph as "Spark", the maqaf, "Vault".
16443
- * An explicit direction control (holdsDirectionControl) sets the direction of
16444
- * the text after it beyond what this lays out, so a caller that judges what a
16445
- * reader sees refuses it as well, as isReservedDisplayText, for any text an
16446
- * organization shows under its name, and isReservedOrganizationName do. Both
16447
- * also judge a text at every cut of it as stored, each cut read in this way,
16448
- * since the platform shows a text cut to fit.
16495
+ * An explicit direction control (holdsDirectionControl, ./display-text.js)
16496
+ * sets the direction of the text after it beyond what this lays out, so a
16497
+ * caller that judges what a reader sees refuses it as well, as
16498
+ * isReservedDisplayText, for any text an organization shows under its name,
16499
+ * and isReservedOrganizationName do. Both also judge a text at every cut of it
16500
+ * as stored, each cut read in this way, since the platform shows a text cut to
16501
+ * fit. The implicit marks are no such control: each is a strong character of
16502
+ * its direction, laid out as a letter of that direction is.
16449
16503
  *
16450
- * BROWSER-SAFE: imports only ./organization-name-unicode.js, and needs
16504
+ * BROWSER-SAFE: imports only ./display-text.js and
16505
+ * ./organization-name-unicode.js, neither of which imports anything, and needs
16451
16506
  * String.prototype.isWellFormed and toWellFormed (ES2024: Chrome 111,
16452
16507
  * Firefox 119, Safari 16.4).
16453
16508
  */
@@ -20266,12 +20321,16 @@ class VaultsModule {
20266
20321
  * const delegated = await sv.vaults.unseal('vlt_abc', 'dvak_...');
20267
20322
  * console.log('Token:', unsealed.vatToken);
20268
20323
  */
20269
- async unseal(vaultId, key) {
20324
+ async unseal(vaultId, key, options = {}) {
20270
20325
  const id = requireResourceId(vaultId, 'vaultId');
20271
20326
  if (typeof key !== 'string' || !key.trim()) {
20272
20327
  throw new ValidationError('A VMK or DVAK token is required');
20273
20328
  }
20274
- const response = await this.http.post(apiPath `/v1/vaults/${id}/unseal`, unsealRequestBody(key));
20329
+ if (options.ttlSeconds !== undefined &&
20330
+ (!Number.isSafeInteger(options.ttlSeconds) || options.ttlSeconds < 1 || options.ttlSeconds > VAULT_RESEAL_LIMITS.maxSeconds)) {
20331
+ throw new ValidationError(`ttlSeconds must be a whole number from 1 to ${VAULT_RESEAL_LIMITS.maxSeconds}`);
20332
+ }
20333
+ const response = await this.http.post(apiPath `/v1/vaults/${id}/unseal`, unsealRequestBody(key, options.ttlSeconds));
20275
20334
  if (!response.data.vat) {
20276
20335
  throw new ValidationError('Unseal response did not include a vault access token');
20277
20336
  }
@@ -20281,6 +20340,30 @@ class VaultsModule {
20281
20340
  issuedAt: response.data.issued_at,
20282
20341
  expiresAt: response.data.expires_at,
20283
20342
  ttlSeconds: response.data.ttl_seconds,
20343
+ ...(response.data.hard_expires_at === undefined ? {} : { hardExpiresAt: response.data.hard_expires_at }),
20344
+ ...(response.data.idle_timeout_seconds === undefined ? {} : { idleTimeoutSeconds: response.data.idle_timeout_seconds }),
20345
+ };
20346
+ }
20347
+ /**
20348
+ * Explicitly extend this live session's inactivity window, up to the
20349
+ * original unseal's fixed maximum. No key is needed and no new VAT is minted.
20350
+ * A fixed-duration session or one at its maximum is refused by Core; another
20351
+ * unseal is required. The normal timing observer receives the new deadline.
20352
+ */
20353
+ async extendSession(vaultId, vat) {
20354
+ const id = requireResourceId(vaultId, 'vaultId');
20355
+ if (typeof vat !== 'string' || !vat.startsWith('vat_')) {
20356
+ throw new ValidationError('A Vault Access Token is required to extend the session');
20357
+ }
20358
+ const response = await this.http.post(apiPath `/v1/vaults/${id}/session/extend`, undefined, { vat });
20359
+ const value = response.data;
20360
+ return {
20361
+ vaultId: value.vault_id,
20362
+ expiresAt: value.expires_at,
20363
+ hardExpiresAt: value.hard_expires_at,
20364
+ idleTimeoutSeconds: value.idle_timeout_seconds,
20365
+ ttlSeconds: value.ttl_seconds,
20366
+ canExtend: value.can_extend,
20284
20367
  };
20285
20368
  }
20286
20369
  /**
@@ -20323,6 +20406,25 @@ class VaultsModule {
20323
20406
  const response = await this.http.get(apiPath `/v1/vaults/${id}`);
20324
20407
  return mapVaultDetail(response.data);
20325
20408
  }
20409
+ /**
20410
+ * Set when this vault reseals after inactivity and after an unseal.
20411
+ * Company administrators only. Changes apply on the next unseal.
20412
+ * Null values inherit system defaults; zero idle seconds disables extensions.
20413
+ */
20414
+ async updateResealSettings(vaultId, settings) {
20415
+ const id = requireResourceId(vaultId, 'vaultId');
20416
+ const response = await this.http.put(apiPath `/v1/vaults/${id}/reseal-settings`, {
20417
+ reseal_idle_seconds: settings.idleSeconds,
20418
+ reseal_max_seconds: settings.maxSeconds,
20419
+ });
20420
+ const value = response.data;
20421
+ return {
20422
+ vaultId: value.vault_id,
20423
+ idleSeconds: value.reseal_idle_seconds,
20424
+ maxSeconds: value.reseal_max_seconds,
20425
+ defaults: { idleSeconds: value.reseal_defaults.idle_seconds, maxSeconds: value.reseal_defaults.max_seconds },
20426
+ };
20427
+ }
20326
20428
  /**
20327
20429
  * Rename a vault.
20328
20430
  *
@@ -20597,6 +20699,11 @@ function mapVaultDetail(v) {
20597
20699
  createdAt: v.created_at,
20598
20700
  lastUnsealedAt: v.last_unsealed_at ?? null,
20599
20701
  unsealCount: v.unseal_count ?? 0,
20702
+ ...(v.reseal_idle_seconds === undefined ? {} : { resealIdleSeconds: v.reseal_idle_seconds }),
20703
+ ...(v.reseal_max_seconds === undefined ? {} : { resealMaxSeconds: v.reseal_max_seconds }),
20704
+ ...(v.reseal_defaults === undefined ? {} : {
20705
+ resealDefaults: { idleSeconds: v.reseal_defaults.idle_seconds, maxSeconds: v.reseal_defaults.max_seconds },
20706
+ }),
20600
20707
  deletionNoticeUnreached: v.deletion_notice_unreached && v.deletion_notice_unreached.map(mapUnreachedAdmin),
20601
20708
  };
20602
20709
  }
@@ -21360,7 +21467,7 @@ class SparkVault {
21360
21467
  }
21361
21468
  /** Get the SDK version */
21362
21469
  static get version() {
21363
- return '14.1.1';
21470
+ return '14.2.1';
21364
21471
  }
21365
21472
  }
21366
21473
  if (typeof window !== 'undefined') {