@sparkvault/sdk-js 10.0.1 → 11.0.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.
Files changed (54) hide show
  1. package/README.md +9 -4
  2. package/dist/api-base.d.ts +46 -11
  3. package/dist/config.d.ts +5 -3
  4. package/dist/entropy/index.d.ts +0 -1
  5. package/dist/entropy/types.d.ts +1 -1
  6. package/dist/errors.d.ts +18 -2
  7. package/dist/folders/index.d.ts +3 -1
  8. package/dist/http.d.ts +11 -6
  9. package/dist/index.cjs +8207 -7265
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.ts +510 -297
  12. package/dist/index.mjs +8206 -7266
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/ingots/fetch-download.d.ts +48 -0
  15. package/dist/ingots/index.d.ts +29 -14
  16. package/dist/ingots/types.d.ts +98 -43
  17. package/dist/notify/types.d.ts +7 -2
  18. package/dist/products/identity/api.d.ts +30 -14
  19. package/dist/products/identity/handlers/index.d.ts +1 -1
  20. package/dist/products/identity/handlers/passkey-handler.d.ts +4 -13
  21. package/dist/products/identity/handlers/sparklink-handler.d.ts +0 -1
  22. package/dist/products/identity/index.d.ts +23 -6
  23. package/dist/products/identity/inline-container.d.ts +13 -26
  24. package/dist/products/identity/modal.d.ts +16 -42
  25. package/dist/products/identity/renderer.d.ts +31 -10
  26. package/dist/products/identity/types.d.ts +17 -5
  27. package/dist/products/identity/types.test-d.d.ts +21 -0
  28. package/dist/products/identity/utils.d.ts +9 -16
  29. package/dist/products/identity/views/base.d.ts +4 -21
  30. package/dist/products/identity/views/identity-input.d.ts +4 -2
  31. package/dist/products/index.d.ts +1 -1
  32. package/dist/products/notify/index.d.ts +29 -19
  33. package/dist/products/notify/types.d.ts +74 -37
  34. package/dist/products/notify/types.test-d.d.ts +1 -0
  35. package/dist/request-path.d.ts +44 -0
  36. package/dist/sparkvault.js +1 -1
  37. package/dist/sparkvault.js.map +1 -1
  38. package/dist/ui/chrome.d.ts +16 -0
  39. package/dist/ui/ds-tokens.d.ts +58 -0
  40. package/dist/ui/inline-shell.d.ts +19 -0
  41. package/dist/ui/modal-shell.d.ts +36 -0
  42. package/dist/ui/target.d.ts +6 -0
  43. package/dist/vaults/index.d.ts +11 -6
  44. package/dist/vaults/upload/api.d.ts +21 -9
  45. package/dist/vaults/upload/chrome.d.ts +8 -22
  46. package/dist/vaults/upload/container.d.ts +0 -8
  47. package/dist/vaults/upload/index.d.ts +1 -1
  48. package/dist/vaults/upload/inline-container.d.ts +13 -42
  49. package/dist/vaults/upload/modal.d.ts +14 -33
  50. package/dist/vaults/upload/renderer.d.ts +0 -1
  51. package/dist/vaults/upload/styles.d.ts +4 -2
  52. package/dist/vaults/upload/types.d.ts +2 -2
  53. package/package.json +2 -2
  54. package/dist/utils/base64url.d.ts +0 -52
package/dist/index.d.ts CHANGED
@@ -35,9 +35,9 @@ interface SparkVaultConfig {
35
35
  /** Enable backdrop blur on dialogs (default: true) */
36
36
  backdropBlur?: boolean;
37
37
  /**
38
- * Host allowlist for backend-issued ingot download URLs. Defaults to the
39
- * canonical SparkVault Forge / S3 / CloudFront hosts. Override only when
40
- * pointing at a custom deployment.
38
+ * Host allowlist for the backend-issued Forge transfer URLs the SDK sends an
39
+ * ingot's ISTK to (downloads and uploads alike). Defaults to the SparkVault
40
+ * platform's own hosts; override only when pointing at another deployment.
41
41
  */
42
42
  allowedDownloadHostPatterns?: RegExp[];
43
43
  }
@@ -74,6 +74,32 @@ declare class HealthModule {
74
74
  private readStatus;
75
75
  }
76
76
 
77
+ /**
78
+ * Request paths: the one way a module names a SparkVault route.
79
+ *
80
+ * Every request the SDK sends carries the caller's credentials (a Bearer token
81
+ * or API key, plus a Vault Access Token on vault data), so a value that
82
+ * smuggled '/' or a dot-segment into a path would re-target that credentialed
83
+ * request at another route. `apiPath` closes that by construction: each
84
+ * interpolated value becomes exactly one percent-encoded segment, and a value
85
+ * that cannot be one segment is refused before any request leaves. The
86
+ * transports accept only an `ApiPath`, so no module can name a route any other
87
+ * way. Server-issued ids are also checked for their shape first
88
+ * (`requireResourceId`), so a malformed id fails with a ValidationError that
89
+ * names the argument instead of reaching the server as a 404.
90
+ *
91
+ * The rules are the platform's one copy in `@sparkvault/app-sdk/request-path`
92
+ * and, for ids, `@sparkvault/app-sdk/ids`, bundled into this SDK and mirrored
93
+ * into sdk-mobile; this module only types them and raises this SDK's error.
94
+ */
95
+ declare const API_PATH: unique symbol;
96
+ /** A route path whose every interpolated value is exactly one encoded segment. */
97
+ type ApiPath = string & {
98
+ readonly [API_PATH]: true;
99
+ };
100
+ /** Query parameters; `undefined`, `null` and `''` are left out of the query. */
101
+ type QueryParams = Record<string, string | number | boolean | null | undefined>;
102
+
77
103
  /**
78
104
  * SparkVault SDK HTTP Client
79
105
  */
@@ -82,6 +108,10 @@ interface RequestOptions {
82
108
  method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
83
109
  headers?: Record<string, string>;
84
110
  body?: unknown;
111
+ /** Query parameters appended to the path; empty values are left out. */
112
+ query?: QueryParams;
113
+ /** The unsealed vault's Vault Access Token, sent as `X-Vault-Access-Token`. */
114
+ vat?: string;
85
115
  timeout?: number;
86
116
  }
87
117
  /** Capacity state for a pool, driving low-capacity nudges in the UI. */
@@ -126,7 +156,7 @@ declare class HttpClient {
126
156
  constructor(config: ResolvedConfig);
127
157
  private getDefaultHeaders;
128
158
  private getAccessToken;
129
- request<T = unknown>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
159
+ request<T = unknown>(path: ApiPath, options?: RequestOptions): Promise<ApiResponse<T>>;
130
160
  private parseResponse;
131
161
  private createErrorFromResponse;
132
162
  private unwrapApiResponse;
@@ -135,11 +165,11 @@ declare class HttpClient {
135
165
  * standard `{ data, meta }` response. Returns undefined for bare responses.
136
166
  */
137
167
  private extractResponseMeta;
138
- get<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
139
- post<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
140
- put<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
141
- patch<T = unknown>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
142
- delete<T = unknown>(path: string, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
168
+ get<T = unknown>(path: ApiPath, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
169
+ post<T = unknown>(path: ApiPath, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
170
+ put<T = unknown>(path: ApiPath, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
171
+ patch<T = unknown>(path: ApiPath, body?: unknown, options?: Omit<RequestOptions, 'method'>): Promise<ApiResponse<T>>;
172
+ delete<T = unknown>(path: ApiPath, options?: Omit<RequestOptions, 'method' | 'body'>): Promise<ApiResponse<T>>;
143
173
  }
144
174
 
145
175
  /**
@@ -347,8 +377,9 @@ declare class ValidationError extends SparkVaultError {
347
377
  }
348
378
  /**
349
379
  * The pooled-capacity resource a quota gate refers to. Only the byte pools
350
- * hard-gate: flex licensing has no seat limit (inviting and licensing are
351
- * never quota-gated), and Identity soft-gates through its own path.
380
+ * hard-gate: licenses are assigned per member, never drawn from a pool
381
+ * (inviting and licensing are never quota-gated), and Identity soft-gates
382
+ * through its own path.
352
383
  */
353
384
  type QuotaResource = 'storage' | 'bandwidth';
354
385
  /**
@@ -542,8 +573,11 @@ declare class IdentityModule {
542
573
  * (a top-level GET, so the `SameSite=Lax` hub cookie rides along) which,
543
574
  * PKCE-bound, returns a one-time code in the fragment — handled by case 1 on
544
575
  * return. No-op (stays put) if session storage or WebCrypto is unavailable,
545
- * so a hostile/degraded environment simply never recovers rather than
546
- * erroring.
576
+ * so a degraded environment simply never recovers rather than erroring. The
577
+ * bounce's PKCE verifier and state are a draw from the Identity origin
578
+ * (`drawAuthorizationValues`): a draw that fails (the origin unreachable, a
579
+ * malformed answer) rejects `handleRedirectResult()` with that error, and the
580
+ * page stays put.
547
581
  */
548
582
  private startRecoveryBounce;
549
583
  /**
@@ -559,9 +593,9 @@ declare class IdentityModule {
559
593
  private startRedirectFlow;
560
594
  /**
561
595
  * Arm the PKCE + state return leg for a handoff navigation and return the URL
562
- * to navigate to (redirect_uri = this exact page; query preserved for app
563
- * state, fragment dropped since it is the result channel). Returns null when
564
- * session storage or WebCrypto is unavailable so callers can degrade.
596
+ * to navigate to (redirect_uri = this page, per `currentPageReturnUrl`).
597
+ * Returns null when session storage or WebCrypto is unavailable so callers
598
+ * can degrade.
565
599
  */
566
600
  private prepareHandoffNavigation;
567
601
  /**
@@ -583,6 +617,14 @@ declare class IdentityModule {
583
617
  private clearUrlFragment;
584
618
  /** Drop the one-shot PKCE state/verifier a bounce staged. */
585
619
  private clearOneShotAuthState;
620
+ /**
621
+ * Complete a social round trip that returned to the sign-in page as
622
+ * `#token=…&state=…`. Only `render()` — the Identity-origin sign-in page —
623
+ * reads it: no SDK flow returns a `#token` to a site (a site's results arrive
624
+ * by the popup's postMessage, FedCM, or a PKCE-bound `#sv_code`), so on a site
625
+ * it could only be someone else's token, or the site's own direct
626
+ * token-redirect result.
627
+ */
586
628
  private consumeRedirectResult;
587
629
  /**
588
630
  * Close the identity dialog/inline UI if open.
@@ -602,12 +644,18 @@ declare class IdentityModule {
602
644
  */
603
645
  private preloadedConfigPermanentlyFailed;
604
646
  /**
605
- * Resolve target to an HTMLElement.
647
+ * The inline container for an embedded render. Bare chrome: the host page
648
+ * owns logo + footer + background, so the container drops its own surface
649
+ * and the SparkVault footer.
606
650
  */
607
651
  private createInlineContainer;
608
652
  /**
609
653
  * Render the flow into a page element instead of a popup.
610
654
  *
655
+ * A social login started here returns to this same page with its result in
656
+ * the fragment, so a returned `#token` is completed first (see
657
+ * `consumeRedirectResult`) instead of starting the flow again.
658
+ *
611
659
  * @internal Used only by the SparkVault-hosted sign-in popup and hosted login
612
660
  * page (which own their chrome and pass `renderMode: 'local'`). Customer
613
661
  * integrations have no inline mode — use `signIn()` / `attach()`.
@@ -661,10 +709,15 @@ interface NotificationRow {
661
709
  * The grant to open. Present only while a live reveal stands behind it — a
662
710
  * SEALED (secure) send that has not been recalled. A cleartext send delivers its
663
711
  * content inline in the channel and mints no grant; a recalled row's grant is
664
- * revoked and the pointer is withheld rather than echoed. Guard before building
665
- * a URL from it.
712
+ * revoked and the pointer is withheld rather than echoed.
666
713
  */
667
714
  sparklink_code?: string;
715
+ /**
716
+ * Where the grant opens: the URL every Notify channel carries for it, built by
717
+ * the server. Present exactly when `sparklink_code` is; open this rather than
718
+ * building a URL from the code.
719
+ */
720
+ pointer_url?: string;
668
721
  /**
669
722
  * True only when there is a secure part left to reveal — exactly when
670
723
  * `sparklink_code` is present. `false` does NOT mean "cleartext row": a recalled
@@ -779,6 +832,147 @@ interface SubscribeWebPushResult {
779
832
  subscription?: PushSubscription;
780
833
  }
781
834
 
835
+ /**
836
+ * Vaults Module Types
837
+ */
838
+ interface CreateVaultOptions {
839
+ /** Vault name */
840
+ name: string;
841
+ }
842
+ interface Vault {
843
+ /** Vault ID */
844
+ id: string;
845
+ /** Vault name */
846
+ name: string;
847
+ /** Vault Master Key (24 chars) - STORE SECURELY! */
848
+ vmk: string;
849
+ /** Creation timestamp (Unix seconds) */
850
+ createdAt: number;
851
+ }
852
+ interface UnsealedVault {
853
+ /** Vault ID */
854
+ id: string;
855
+ /** Vault Access Token (short-lived session, required for all ingot operations) */
856
+ vatToken: string;
857
+ /** VAT issued-at timestamp (Unix seconds) */
858
+ issuedAt: number;
859
+ /** VAT expiry timestamp (Unix seconds) */
860
+ expiresAt: number;
861
+ /** VAT lifetime in seconds */
862
+ ttlSeconds: number;
863
+ }
864
+ interface VaultSummary {
865
+ /** Vault ID */
866
+ id: string;
867
+ /** Vault name */
868
+ name: string;
869
+ /** Creation timestamp (Unix seconds) */
870
+ createdAt: number;
871
+ /** Number of ingots */
872
+ ingotCount: number;
873
+ /** Total storage used in bytes */
874
+ storageBytes: number;
875
+ }
876
+ /** Options for list. */
877
+ interface ListVaultsOptions {
878
+ /** Page size (1–500; server default 100) */
879
+ limit?: number;
880
+ /** Pagination cursor from a prior page's `nextCursor` */
881
+ cursor?: string;
882
+ }
883
+ /** A page of vaults. */
884
+ interface VaultPage {
885
+ /** Vaults on this page */
886
+ vaults: VaultSummary[];
887
+ /** Cursor for the next page, when more results exist */
888
+ nextCursor?: string;
889
+ }
890
+ /** A single vault's detail, as returned by get. */
891
+ interface VaultDetail {
892
+ /** Vault ID */
893
+ id: string;
894
+ /** Vault name */
895
+ name: string;
896
+ /** Optional description */
897
+ description: string | null;
898
+ /** Sealed/unsealed status */
899
+ status: string;
900
+ /** Number of ingots */
901
+ ingotCount: number;
902
+ /** Total storage used in bytes */
903
+ storageBytes: number;
904
+ /** Creation timestamp (Unix seconds) */
905
+ createdAt: number;
906
+ /** Last unseal timestamp (Unix seconds), or null */
907
+ lastUnsealedAt: number | null;
908
+ /** Lifetime unseal count */
909
+ unsealCount: number;
910
+ }
911
+ /** The result of renaming a vault. */
912
+ interface UpdatedVault {
913
+ /** Vault ID */
914
+ id: string;
915
+ /** Vault name */
916
+ name: string;
917
+ /** Optional description */
918
+ description: string | null;
919
+ /** Update timestamp (Unix seconds) */
920
+ updatedAt: number;
921
+ }
922
+ /** Vault public-sharing configuration. */
923
+ interface VaultSharingConfig {
924
+ /** Vault ID */
925
+ vaultId: string;
926
+ /** Whether public sharing is enabled */
927
+ publicSharingEnabled: boolean;
928
+ /** Whether all ingots are public */
929
+ allIngotsPublic: boolean;
930
+ /** Public-session lifetime in seconds, or null */
931
+ sessionLengthSeconds: number | null;
932
+ /** Timestamp sharing was enabled (Unix seconds), or null */
933
+ enabledAt: number | null;
934
+ }
935
+ /** Options for enabling/updating vault sharing. */
936
+ interface VaultSharingOptions {
937
+ /** Make all ingots public */
938
+ allIngotsPublic?: boolean;
939
+ /** Public-session lifetime in seconds */
940
+ sessionLengthSeconds?: number;
941
+ }
942
+ /** Vault access-log retention configuration. */
943
+ interface AccessLogRetention {
944
+ /** Vault ID */
945
+ vaultId: string;
946
+ /** Retention window in seconds */
947
+ retentionSeconds: number;
948
+ }
949
+ /** Vault upload-channel configuration. */
950
+ interface VaultUploadSettings {
951
+ /** Vault ID */
952
+ vaultId: string;
953
+ /** Whether the upload portal is enabled */
954
+ uploadPortalEnabled: boolean;
955
+ /** Timestamp the portal was enabled (Unix seconds), or null */
956
+ uploadPortalEnabledAt: number | null;
957
+ /** Whether the upload widget is enabled */
958
+ uploadWidgetEnabled: boolean;
959
+ /** Timestamp the widget was enabled (Unix seconds), or null */
960
+ uploadWidgetEnabledAt: number | null;
961
+ /** Max upload size in bytes, or null for the account default */
962
+ maxSizeBytes: number | null;
963
+ /** Upload notification email, or null */
964
+ notificationEmail: string | null;
965
+ /** Public portal URL (present when the portal is enabled) */
966
+ portalUrl?: string;
967
+ }
968
+ /** Options for updating vault upload settings. */
969
+ interface UpdateVaultUploadOptions {
970
+ /** Max upload size in bytes */
971
+ maxSizeBytes?: number;
972
+ /** Upload notification email, or null to clear */
973
+ notificationEmail?: string | null;
974
+ }
975
+
782
976
  /**
783
977
  * Notify Product Types — the TENANT (sender) surface of `/v1/products/notify/*`.
784
978
  *
@@ -800,7 +994,7 @@ interface SubscribeWebPushResult {
800
994
  */
801
995
 
802
996
  /** Every transport the dispatch seam can carry a notification on. */
803
- type NotifyChannel = 'in_app' | 'websocket' | 'email' | 'sms' | 'push' | 'web_push' | 'voice' | 'whatsapp' | 'rcs' | 'webhook' | 'slack' | 'teams';
997
+ type NotifyChannel = 'in_app' | 'email' | 'sms' | 'push' | 'web_push' | 'voice' | 'whatsapp' | 'rcs' | 'webhook' | 'slack' | 'teams';
804
998
  /**
805
999
  * How a send's content reaches the recipient.
806
1000
  * - `sealed` (default): content is sealed into a Spark behind a single-use
@@ -870,10 +1064,29 @@ interface NotifySendContent {
870
1064
  * An EXISTING ingot to point the grant at instead of sealing new content. One
871
1065
  * persistent asset carries a single grant, so an ingot send is 1:1 — it targets
872
1066
  * exactly one recipient.
1067
+ *
1068
+ * The recipient opens the file in the SparkVault file viewer, which has no
1069
+ * action bar, so an ingot send is view-only: a non-view `policy.interaction`
1070
+ * (including the `conversation`, `approval` and `signatureRequest` presets) is
1071
+ * rejected with 400 `VALIDATION_ERROR`. The vault must be the caller's with
1072
+ * public file sharing enabled (404 / 412 `PRECONDITION_FAILED` otherwise), and
1073
+ * the sender must hold a Full License (403 `LICENSE_REQUIRED`).
1074
+ *
1075
+ * Only a holder of the vault's key may publish its files, so the send carries
1076
+ * the unsealed vault's read-write VAT as `X-Vault-Access-Token` — exactly what
1077
+ * the vault's own sharing calls demand. A missing, unknown or revoked VAT is 401
1078
+ * `AUTHENTICATION_ERROR`; an expired one 403 (`details.reason: 'VAT_EXPIRED'`,
1079
+ * unseal again and retry), a read-only one 403 (`'VAT_READ_ONLY'`), and one for
1080
+ * another vault 403 `FORBIDDEN`.
873
1081
  */
874
1082
  interface NotifyIngotRef {
875
1083
  ingotId: string;
876
- vaultId: string;
1084
+ /**
1085
+ * The ingot's vault, unsealed with the VMK or a read-write DVAK
1086
+ * (`sv.vaults.unseal(vaultId, key)`). Its id addresses the ingot and its VAT
1087
+ * proves key possession.
1088
+ */
1089
+ vault: UnsealedVault;
877
1090
  }
878
1091
  /** The access policy stamped onto each minted SparkLink grant. */
879
1092
  interface NotifySendPolicy {
@@ -885,7 +1098,9 @@ interface NotifySendPolicy {
885
1098
  /**
886
1099
  * Cumulative per-step delays in SECONDS from send time, one per channel step.
887
1100
  * Step 0 always fires immediately (any `delays[0]` is ignored), and the sequence
888
- * is aligned non-decreasing. Omit to derive the schedule from the account config.
1101
+ * is aligned non-decreasing. Each value is at most 86400 (24 hours, the longest a
1102
+ * sealed grant lives); a later one is rejected with a 400. Omit to derive the
1103
+ * schedule from the account config.
889
1104
  */
890
1105
  interface NotifyEscalation {
891
1106
  delays: number[];
@@ -930,6 +1145,14 @@ interface CreateNotifySendOptions {
930
1145
  /** Inbox-row retention, default 30. A plaintext send is capped at 7. */
931
1146
  historyTtlDays?: number;
932
1147
  }
1148
+ /**
1149
+ * Options for a preset helper (`sendAlert`, `sendSecureMessage`, …): the one
1150
+ * send contract, with `category` optional because the preset stamps its own
1151
+ * when the caller names none.
1152
+ */
1153
+ type NotifyPresetSendOptions = Omit<CreateNotifySendOptions, 'category'> & {
1154
+ category?: NotifyCategory;
1155
+ };
933
1156
  interface NotifySendResult {
934
1157
  send_id: string;
935
1158
  /** Number of recipients the send was accepted for. */
@@ -952,14 +1175,14 @@ interface NotifyPreset {
952
1175
  };
953
1176
  }
954
1177
  /** Inbox views the feed can be filtered to. `all` excludes archived rows. */
955
- type NotifyInboxView = 'all' | 'unseen' | 'unread' | 'archived';
1178
+ type NotifyInboxView = NotificationInboxState;
956
1179
  /** Terminal display states applicable to a single row. */
957
- type NotifyInboxMarkState = 'seen' | 'read' | 'archived';
1180
+ type NotifyInboxMarkState = NotificationMarkState;
958
1181
  /**
959
1182
  * States a BULK drain can apply. `archived` is per-row only — it has no sparse
960
1183
  * GSI, so bulk-archiving would require a full-partition scan.
961
1184
  */
962
- type NotifyInboxBulkMarkState = 'seen' | 'read';
1185
+ type NotifyInboxBulkMarkState = NotificationBulkMarkState;
963
1186
  interface ListNotifyInboxOptions {
964
1187
  /**
965
1188
  * The inbox owner, keyed EXACTLY as addressed on the send. Identity claim never
@@ -1004,7 +1227,9 @@ interface MarkNotifyInboxAllResponse {
1004
1227
  * cannot drift from the facts it summarizes).
1005
1228
  *
1006
1229
  * - `pending` — still in flight, or not yet driven.
1007
- * - `delivered` — a channel accepted it and no provider has repudiated that.
1230
+ * - `delivered` — a channel accepted it and no provider has repudiated that, or
1231
+ * the recipient opened the sealed content or marked it seen and a later
1232
+ * escalation step recorded that before any recall.
1008
1233
  * - `undeliverable` — every channel attempted declined (no handle, bounced, not
1009
1234
  * implemented). The recipient cannot be reached as addressed.
1010
1235
  * - `failed` — a channel exhausted its retries. OUR transport gave up; the
@@ -1014,7 +1239,8 @@ interface MarkNotifyInboxAllResponse {
1014
1239
  * - `rate_limited` — skipped by the per-recipient abuse ceiling for that minute.
1015
1240
  * - `recalled` — the sender took it back before a channel reached this recipient.
1016
1241
  * The reveal is revoked and no further delivery will be attempted. It ranks
1017
- * BELOW `delivered`: a channel that already reached someone reached them, so a
1242
+ * BELOW `delivered`: a channel that already reached someone reached them, and
1243
+ * engagement an escalation step recorded before the recall stands too, so a
1018
1244
  * recall afterwards leaves them `delivered`. It covers recipients the recall
1019
1245
  * itself marked AND, on a whole-audience recall, everyone the fan-out was
1020
1246
  * stopped before ever writing a row for.
@@ -1058,7 +1284,11 @@ interface NotifySendStatusRecipient {
1058
1284
  /** Escalation step index the outcome came from. */
1059
1285
  step: number | null;
1060
1286
  }>>;
1061
- /** At least one channel accepted the notification for this recipient. */
1287
+ /**
1288
+ * At least one channel accepted the notification for this recipient. A
1289
+ * transport fact only: `state` is `delivered` for a recipient who opened or
1290
+ * saw it even when every channel declined.
1291
+ */
1062
1292
  delivered: boolean;
1063
1293
  /**
1064
1294
  * Every channel attempted for this recipient declined (`skipped`,
@@ -1088,7 +1318,7 @@ interface NotifySendStatusCounts {
1088
1318
  * and do not partition anything.)
1089
1319
  */
1090
1320
  pending: number;
1091
- /** Recipients with at least one `delivered` channel outcome. */
1321
+ /** Recipients whose `state` is `delivered`. */
1092
1322
  delivered: number;
1093
1323
  /** Recipients whose every attempted channel declined — the silent-failure count. */
1094
1324
  undeliverable: number;
@@ -1119,7 +1349,8 @@ interface NotifySendStatus {
1119
1349
  * recipients" can be made.
1120
1350
  * - `pending` — accepted; nothing handed to delivery yet.
1121
1351
  * - `sending` — in flight.
1122
- * - `delivered` — every recipient reached a channel that accepted.
1352
+ * - `delivered` — every recipient settled delivered, whether a channel
1353
+ * accepted it or their engagement was recorded (see the recipient `state`).
1123
1354
  * - `partial` — every recipient resolved; some delivered, some did not.
1124
1355
  * - `failed` — every recipient resolved and none delivered.
1125
1356
  *
@@ -1144,8 +1375,10 @@ interface NotifySendStatus {
1144
1375
  * A send's delivery state, DERIVED from its counters — the send row itself is
1145
1376
  * write-once, so there is no stored lifecycle to read.
1146
1377
  *
1147
- * `failed` counts recipients whose every attempted channel declined, so
1148
- * `delivered + failed` is how many have reached a terminal answer; a recipient
1378
+ * `failed` counts every recipient who reached a terminal answer without being
1379
+ * delivered (declined, retries exhausted, opted out, rate limited, or a bounce
1380
+ * that repudiated a delivery), so `delivered + failed` is how many have
1381
+ * resolved; a recipient
1149
1382
  * still climbing the escalation ladder is in neither, which is why an in-flight
1150
1383
  * send reads `sending` rather than being scored early.
1151
1384
  *
@@ -1171,8 +1404,16 @@ interface NotifySendSummary {
1171
1404
  /** Audience size at accept — the denominator of the counters below. */
1172
1405
  recipient_count: number | null;
1173
1406
  enqueued_count: number | null;
1407
+ /**
1408
+ * Recipients settled delivered, on the same evidence as the recipient
1409
+ * `delivered` state: a channel accepted it, or they opened the sealed content
1410
+ * or marked it seen and a later escalation step recorded that before any recall.
1411
+ */
1174
1412
  delivered_count: number | null;
1175
- /** Recipients whose every attempted channel declined. */
1413
+ /**
1414
+ * Recipients who reached a terminal answer without being delivered: every
1415
+ * attempted channel declined or gave up, or they were suppressed or rate limited.
1416
+ */
1176
1417
  failed_count: number | null;
1177
1418
  state: NotifySendState;
1178
1419
  }
@@ -1231,6 +1472,12 @@ interface NotifyReceipt {
1231
1472
  asset_id: string | null;
1232
1473
  vault_id: string | null;
1233
1474
  link_code: string | null;
1475
+ /**
1476
+ * The correlation key a `receipt.recorded` webhook event quotes: 32 hex of the
1477
+ * SHA-256 over the grant code, never the code itself. Null on a receipt
1478
+ * recorded before the key existed.
1479
+ */
1480
+ link_code_hash: string | null;
1234
1481
  link_type: string | null;
1235
1482
  verification_level: NotifyVerificationLevel | null;
1236
1483
  action_hash: string | null;
@@ -1241,16 +1488,14 @@ interface NotifyReceipt {
1241
1488
  /**
1242
1489
  * The send whose grant produced this receipt, stamped at mint time — so it is
1243
1490
  * present for grants a Notify send created, and null for a standalone
1244
- * SparkLink or a receipt served from the legacy audit walk.
1491
+ * SparkLink.
1245
1492
  */
1246
1493
  send_id: string | null;
1247
1494
  /** The send's display title, alongside `send_id` and under the same conditions. */
1248
1495
  title: string | null;
1249
- /** The receipt row's own id. Null on the legacy source. */
1496
+ /** The receipt's own id. Null on a per-send receipt (`getSendReceipts`). */
1250
1497
  receipt_id: string | null;
1251
1498
  }
1252
- /** Which store answered a receipts listing (see `ListNotifyReceiptsResponse.source`). */
1253
- type NotifyReceiptSource = 'receipt_index' | 'legacy_scan';
1254
1499
  /** A receipt correlated to the recipient whose grant produced it. */
1255
1500
  interface NotifySendReceipt extends NotifyReceipt {
1256
1501
  recipient_id: string;
@@ -1266,25 +1511,11 @@ interface ListNotifyReceiptsResponse {
1266
1511
  receipts: NotifyReceipt[];
1267
1512
  /**
1268
1513
  * Next-page cursor, or null on the last page. A page can still come back SHORT
1269
- * of `limit` while more rows follow — `interaction` narrows with a DynamoDB
1270
- * filter applied after the key evaluation — so follow the cursor; never treat
1514
+ * of `limit` (even empty) while more rows follow — `interaction` narrows with
1515
+ * a filter applied after each page is read — so follow the cursor; never treat
1271
1516
  * a short page as the end.
1272
1517
  */
1273
1518
  cursor: string | null;
1274
- /**
1275
- * Which store answered.
1276
- *
1277
- * `receipt_index` is the normal path: one bounded query on the account's
1278
- * receipt partition, with real pagination.
1279
- *
1280
- * `legacy_scan` appears only for an account whose receipts were all emitted
1281
- * before the receipt index existed. It walks the account audit log with a
1282
- * filter, so it can return EMPTY pages that are nowhere near the end of the
1283
- * data — on that source, keep following the cursor until it is null before
1284
- * concluding there are no receipts. The two sources are never merged into one
1285
- * page; the cursor stays on whichever source started the walk.
1286
- */
1287
- source: NotifyReceiptSource;
1288
1519
  }
1289
1520
  interface NotifySendReceiptsResponse {
1290
1521
  send_id: string;
@@ -1309,6 +1540,7 @@ interface NotifyConfigCategory {
1309
1540
  description?: string;
1310
1541
  required?: boolean;
1311
1542
  }
1543
+ /** Each value is an integer number of minutes from send time, 0..1440 (24 hours). */
1312
1544
  interface NotifyConfigRealtimeFallbackDelay {
1313
1545
  email_minutes?: number;
1314
1546
  sms_minutes?: number;
@@ -1381,8 +1613,6 @@ interface NotifyConfig {
1381
1613
  events?: NotifyConfigEventsRead;
1382
1614
  /** Tombstoned entries are already dropped — a deleted category is simply gone. */
1383
1615
  categories: Record<string, NotifyConfigCategory>;
1384
- /** Owner-managed SSM references. Readable, never account-writable. */
1385
- channel_credentials: Record<string, unknown>;
1386
1616
  }
1387
1617
  /**
1388
1618
  * A partial PATCH of the account's config overrides. Only the sections present are
@@ -1435,7 +1665,8 @@ interface NotifyConfigResponse {
1435
1665
  */
1436
1666
 
1437
1667
  /**
1438
- * The five secure-by-default preset bundles, mirroring the server's table.
1668
+ * The five secure-by-default preset bundles: the server's own table, in this
1669
+ * SDK's camelCase shape.
1439
1670
  *
1440
1671
  * There is no preset endpoint — presets are a merge over the one send contract,
1441
1672
  * so they are applied client-side and produce an ordinary `send` request. Caller
@@ -1444,6 +1675,9 @@ interface NotifyConfigResponse {
1444
1675
  *
1445
1676
  * `alert` is the only plaintext preset: a non-confidential ping is read at a
1446
1677
  * glance rather than behind a tap-to-view link. The other four seal.
1678
+ * `approval` and `signatureRequest` verify at `identifier`: pass
1679
+ * `policy: { verificationLevel: 'passkey' }` explicitly when the audience is
1680
+ * known to be enrolled.
1447
1681
  */
1448
1682
  declare const NOTIFY_PRESETS: Readonly<Record<NotifyPresetName, NotifyPreset>>;
1449
1683
  /**
@@ -1451,7 +1685,7 @@ declare const NOTIFY_PRESETS: Readonly<Record<NotifyPresetName, NotifyPreset>>;
1451
1685
  * options. Exported so a caller can inspect (or further adjust) what a preset
1452
1686
  * would send before sending it.
1453
1687
  */
1454
- declare function buildNotifyPresetSend(preset: NotifyPresetName, options: CreateNotifySendOptions): CreateNotifySendOptions;
1688
+ declare function buildNotifyPresetSend(preset: NotifyPresetName, options: NotifyPresetSendOptions): CreateNotifySendOptions;
1455
1689
  declare class NotifyProductModule {
1456
1690
  private readonly http;
1457
1691
  constructor(http: HttpClient);
@@ -1471,6 +1705,16 @@ declare class NotifyProductModule {
1471
1705
  * title: 'Invoice ready',
1472
1706
  * category: 'transactional',
1473
1707
  * });
1708
+ *
1709
+ * @example Send a stored file — the unsealed vault proves you hold its key
1710
+ * const vault = await sv.vaults.unseal('vlt_abc', process.env.CONTRACTS_DVAK);
1711
+ * await sv.products.notify.send({
1712
+ * sendId: `contract:${contract.id}`,
1713
+ * recipients: [{ email: counterparty.email }],
1714
+ * ingot: { ingotId: contract.ingotId, vault },
1715
+ * title: 'Your signed contract',
1716
+ * category: 'transactional',
1717
+ * });
1474
1718
  */
1475
1719
  send(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1476
1720
  /**
@@ -1485,15 +1729,15 @@ declare class NotifyProductModule {
1485
1729
  * title: 'Export complete',
1486
1730
  * });
1487
1731
  */
1488
- sendAlert(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1732
+ sendAlert(options: NotifyPresetSendOptions): Promise<NotifySendResult>;
1489
1733
  /** Confidential content revealed after the recipient proves their identifier. */
1490
- sendSecureMessage(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1734
+ sendSecureMessage(options: NotifyPresetSendOptions): Promise<NotifySendResult>;
1491
1735
  /** Two-way thread: identifier-verified reveal plus an encrypted reply. */
1492
- sendConversation(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1736
+ sendConversation(options: NotifyPresetSendOptions): Promise<NotifySendResult>;
1493
1737
  /** High-stakes approve/deny — identifier-verified, with `action_hash` binding. */
1494
- sendApproval(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1738
+ sendApproval(options: NotifyPresetSendOptions): Promise<NotifySendResult>;
1495
1739
  /** Signature-on-delivery — identifier-verified, with `action_hash` binding. */
1496
- sendSignatureRequest(options: CreateNotifySendOptions): Promise<NotifySendResult>;
1740
+ sendSignatureRequest(options: NotifyPresetSendOptions): Promise<NotifySendResult>;
1497
1741
  /**
1498
1742
  * Read one recipient's metadata-only feed, newest first. Rows are pointers: a
1499
1743
  * sealed row carries only `sparklink_code`, never the content.
@@ -1595,16 +1839,12 @@ declare class NotifyProductModule {
1595
1839
  getSendStatus(sendId: string): Promise<NotifySendStatus>;
1596
1840
  /**
1597
1841
  * The account's verified-interaction receipts (portable, JWKS-verifiable
1598
- * proofs), newest first. Follow `cursor` to page.
1599
- *
1600
- * `source` says which store answered. `receipt_index` is the normal path — a
1601
- * bounded query with real pagination. `legacy_scan` appears only for an account
1602
- * whose receipts all predate that index; it filters the account audit log, so
1603
- * it can hand back EMPTY pages that are nowhere near the end. On EITHER source,
1604
- * follow the cursor until it is null before concluding there are none.
1842
+ * proofs), newest first, with real pagination. An `interaction` filter can
1843
+ * hand back a short or empty page while more follow, so follow `cursor` until
1844
+ * it is null before concluding there are none.
1605
1845
  *
1606
1846
  * @example
1607
- * const { receipts, cursor, source } = await sv.products.notify.listReceipts({ interaction: 'approve' });
1847
+ * const { receipts, cursor } = await sv.products.notify.listReceipts({ interaction: 'approve' });
1608
1848
  */
1609
1849
  listReceipts(options?: ListNotifyReceiptsOptions): Promise<ListNotifyReceiptsResponse>;
1610
1850
  /**
@@ -1635,8 +1875,8 @@ declare class NotifyProductModule {
1635
1875
  */
1636
1876
  getConfig(): Promise<NotifyConfigResponse>;
1637
1877
  /**
1638
- * Merge a partial patch onto the account's config overrides. Owner-gated
1639
- * (`channel_credentials`) and unknown keys are rejected before any write.
1878
+ * Merge a partial patch onto the account's config overrides. Unknown keys are
1879
+ * rejected before any write.
1640
1880
  *
1641
1881
  * Delete a category by storing an explicit `null` TOMBSTONE — that is what keeps
1642
1882
  * a seeded default from re-appearing on the next merge. The reserved `security`
@@ -1686,147 +1926,6 @@ declare class ProductsModule {
1686
1926
  constructor(config: ResolvedConfig, http?: HttpClient);
1687
1927
  }
1688
1928
 
1689
- /**
1690
- * Vaults Module Types
1691
- */
1692
- interface CreateVaultOptions {
1693
- /** Vault name */
1694
- name: string;
1695
- }
1696
- interface Vault {
1697
- /** Vault ID */
1698
- id: string;
1699
- /** Vault name */
1700
- name: string;
1701
- /** Vault Master Key (24 chars) - STORE SECURELY! */
1702
- vmk: string;
1703
- /** Creation timestamp (Unix seconds) */
1704
- createdAt: number;
1705
- }
1706
- interface UnsealedVault {
1707
- /** Vault ID */
1708
- id: string;
1709
- /** Vault Access Token (short-lived session, required for all ingot operations) */
1710
- vatToken: string;
1711
- /** VAT issued-at timestamp (Unix seconds) */
1712
- issuedAt: number;
1713
- /** VAT expiry timestamp (Unix seconds) */
1714
- expiresAt: number;
1715
- /** VAT lifetime in seconds */
1716
- ttlSeconds: number;
1717
- }
1718
- interface VaultSummary {
1719
- /** Vault ID */
1720
- id: string;
1721
- /** Vault name */
1722
- name: string;
1723
- /** Creation timestamp (Unix seconds) */
1724
- createdAt: number;
1725
- /** Number of ingots */
1726
- ingotCount: number;
1727
- /** Total storage used in bytes */
1728
- storageBytes: number;
1729
- }
1730
- /** Options for list. */
1731
- interface ListVaultsOptions {
1732
- /** Page size (1–500; server default 100) */
1733
- limit?: number;
1734
- /** Pagination cursor from a prior page's `nextCursor` */
1735
- cursor?: string;
1736
- }
1737
- /** A page of vaults. */
1738
- interface VaultPage {
1739
- /** Vaults on this page */
1740
- vaults: VaultSummary[];
1741
- /** Cursor for the next page, when more results exist */
1742
- nextCursor?: string;
1743
- }
1744
- /** A single vault's detail, as returned by get. */
1745
- interface VaultDetail {
1746
- /** Vault ID */
1747
- id: string;
1748
- /** Vault name */
1749
- name: string;
1750
- /** Optional description */
1751
- description: string | null;
1752
- /** Sealed/unsealed status */
1753
- status: string;
1754
- /** Number of ingots */
1755
- ingotCount: number;
1756
- /** Total storage used in bytes */
1757
- storageBytes: number;
1758
- /** Creation timestamp (Unix seconds) */
1759
- createdAt: number;
1760
- /** Last unseal timestamp (Unix seconds), or null */
1761
- lastUnsealedAt: number | null;
1762
- /** Lifetime unseal count */
1763
- unsealCount: number;
1764
- }
1765
- /** The result of renaming a vault. */
1766
- interface UpdatedVault {
1767
- /** Vault ID */
1768
- id: string;
1769
- /** Vault name */
1770
- name: string;
1771
- /** Optional description */
1772
- description: string | null;
1773
- /** Update timestamp (Unix seconds) */
1774
- updatedAt: number;
1775
- }
1776
- /** Vault public-sharing configuration. */
1777
- interface VaultSharingConfig {
1778
- /** Vault ID */
1779
- vaultId: string;
1780
- /** Whether public sharing is enabled */
1781
- publicSharingEnabled: boolean;
1782
- /** Whether all ingots are public */
1783
- allIngotsPublic: boolean;
1784
- /** Public-session lifetime in seconds, or null */
1785
- sessionLengthSeconds: number | null;
1786
- /** Timestamp sharing was enabled (Unix seconds), or null */
1787
- enabledAt: number | null;
1788
- }
1789
- /** Options for enabling/updating vault sharing. */
1790
- interface VaultSharingOptions {
1791
- /** Make all ingots public */
1792
- allIngotsPublic?: boolean;
1793
- /** Public-session lifetime in seconds */
1794
- sessionLengthSeconds?: number;
1795
- }
1796
- /** Vault access-log retention configuration. */
1797
- interface AccessLogRetention {
1798
- /** Vault ID */
1799
- vaultId: string;
1800
- /** Retention window in seconds */
1801
- retentionSeconds: number;
1802
- }
1803
- /** Vault upload-channel configuration. */
1804
- interface VaultUploadSettings {
1805
- /** Vault ID */
1806
- vaultId: string;
1807
- /** Whether the upload portal is enabled */
1808
- uploadPortalEnabled: boolean;
1809
- /** Timestamp the portal was enabled (Unix seconds), or null */
1810
- uploadPortalEnabledAt: number | null;
1811
- /** Whether the upload widget is enabled */
1812
- uploadWidgetEnabled: boolean;
1813
- /** Timestamp the widget was enabled (Unix seconds), or null */
1814
- uploadWidgetEnabledAt: number | null;
1815
- /** Max upload size in bytes, or null for the account default */
1816
- maxSizeBytes: number | null;
1817
- /** Upload notification email, or null */
1818
- notificationEmail: string | null;
1819
- /** Public portal URL (present when the portal is enabled) */
1820
- portalUrl?: string;
1821
- }
1822
- /** Options for updating vault upload settings. */
1823
- interface UpdateVaultUploadOptions {
1824
- /** Max upload size in bytes */
1825
- maxSizeBytes?: number;
1826
- /** Upload notification email, or null to clear */
1827
- notificationEmail?: string | null;
1828
- }
1829
-
1830
1929
  /**
1831
1930
  * Vault Upload Module Types
1832
1931
  *
@@ -2067,9 +2166,7 @@ declare class VaultsModule {
2067
2166
  * Requires the vault's exact name as confirmation, matched case-sensitively.
2068
2167
  * The name is sent base64(UTF-8) as the `X-Confirm-Name-B64` header so a vault
2069
2168
  * named with any Unicode (emoji, CJK, the U+202F in macOS-style names) is
2070
- * deletable — an HTTP header value cannot carry non-latin1 characters. The
2071
- * legacy raw `X-Confirm-Name` header is included only for latin1 names, so
2072
- * older API servers keep working.
2169
+ * deletable — an HTTP header value cannot carry non-latin1 characters.
2073
2170
  *
2074
2171
  * @example
2075
2172
  * await sv.vaults.delete('vlt_abc', 'My Vault');
@@ -2099,10 +2196,18 @@ declare class VaultsModule {
2099
2196
  /**
2100
2197
  * Update a vault's sharing configuration (without changing enabled state).
2101
2198
  *
2199
+ * Making every ingot public publishes each file to anyone holding its URL,
2200
+ * so the API accepts `allIngotsPublic: true` only with a read-write VAT for
2201
+ * the vault: pass the unsealed vault for that change.
2202
+ *
2102
2203
  * @example
2103
- * await sv.vaults.updateSharingConfig('vlt_abc', { allIngotsPublic: true });
2204
+ * await sv.vaults.updateSharingConfig('vlt_abc', { sessionLengthSeconds: 1800 });
2205
+ *
2206
+ * @example Make every ingot public
2207
+ * const unsealed = await sv.vaults.unseal('vlt_abc', vmk);
2208
+ * await sv.vaults.updateSharingConfig('vlt_abc', { allIngotsPublic: true }, unsealed);
2104
2209
  */
2105
- updateSharingConfig(vaultId: string, config: VaultSharingOptions): Promise<VaultSharingConfig>;
2210
+ updateSharingConfig(vaultId: string, config: VaultSharingOptions, vault?: UnsealedVault): Promise<VaultSharingConfig>;
2106
2211
  /**
2107
2212
  * Get a vault's access-log retention window.
2108
2213
  *
@@ -2160,10 +2265,55 @@ declare class VaultsModule {
2160
2265
  */
2161
2266
  updateUploadConfig(vaultId: string, config: UpdateVaultUploadOptions): Promise<VaultUploadSettings>;
2162
2267
  private toggleUploadChannel;
2163
- private normalizeVaultId;
2164
2268
  private validateCreateOptions;
2165
2269
  }
2166
2270
 
2271
+ /**
2272
+ * Folders Module Types
2273
+ *
2274
+ * Folders organize ingots within an unsealed vault. Public domain objects are
2275
+ * camelCase; wire shapes (snake_case) stay private to the module.
2276
+ */
2277
+
2278
+ /** A folder within a vault. */
2279
+ interface Folder {
2280
+ /** Folder ID */
2281
+ id: string;
2282
+ /** Folder name */
2283
+ name: string;
2284
+ /** Parent folder ID, or null at the vault root */
2285
+ parentId: string | null;
2286
+ /** Whether the folder is pinned */
2287
+ pinned: boolean;
2288
+ /** Creation timestamp (Unix seconds) */
2289
+ createdAt: number;
2290
+ /** Last update timestamp (Unix seconds) */
2291
+ updatedAt: number;
2292
+ }
2293
+ /** A single hop in a folder breadcrumb trail. */
2294
+ interface FolderBreadcrumbItem {
2295
+ /** Folder ID, or null for the Root entry */
2296
+ id: string | null;
2297
+ /** Folder name */
2298
+ name: string;
2299
+ }
2300
+ /** Options for creating a folder. */
2301
+ interface CreateFolderOptions {
2302
+ /** Folder name */
2303
+ name: string;
2304
+ /** Parent folder ID, or null/omitted for the vault root */
2305
+ parentId?: string | null;
2306
+ }
2307
+ /** Options for updating a folder. */
2308
+ interface UpdateFolderOptions {
2309
+ /** New name */
2310
+ name?: string;
2311
+ /** New parent folder ID, or null for the vault root */
2312
+ parentId?: string | null;
2313
+ /** New pinned state */
2314
+ pinned?: boolean;
2315
+ }
2316
+
2167
2317
  /**
2168
2318
  * Ingots Module Types
2169
2319
  *
@@ -2173,6 +2323,23 @@ declare class VaultsModule {
2173
2323
  * private to the module.
2174
2324
  */
2175
2325
 
2326
+ /**
2327
+ * What the server does when a create's name is already held in the target
2328
+ * folder (case-insensitive). The server decides on the holder it read before
2329
+ * writing anything, so a caller that must not replace content says so here:
2330
+ * - `upsert` (the server default): the upload replaces the holder's content.
2331
+ * - `complete_pending`: a holder whose own upload never finalized is completed
2332
+ * (`created: false`); a published holder is refused with a 409 CONFLICT whose
2333
+ * `details` are `{ reason: 'NAME_HELD', ingot_id, status, size_bytes }`, and
2334
+ * is left untouched.
2335
+ * - `refuse`: any holder, its upload finished or not, is refused with that
2336
+ * same 409 and left untouched; the create only ever mints.
2337
+ * - `new_name`: the holder is never touched; the ingot is minted under the
2338
+ * first free numbered name the server picks ("report (2).pdf"), returned as
2339
+ * the result's `name`.
2340
+ */
2341
+ declare const NAME_CONFLICT_POLICIES: readonly ["upsert", "complete_pending", "refuse", "new_name"];
2342
+ type NameConflictPolicy = (typeof NAME_CONFLICT_POLICIES)[number];
2176
2343
  /** Ingot metadata as returned by list/get/contents. */
2177
2344
  interface Ingot {
2178
2345
  /** Ingot ID */
@@ -2183,8 +2350,8 @@ interface Ingot {
2183
2350
  contentType: string;
2184
2351
  /** Size in bytes */
2185
2352
  size: number;
2186
- /** Lifecycle status (uploading | active | failed) */
2187
- status: string;
2353
+ /** Lifecycle status: `uploading` until Forge activates the upload, then `active` */
2354
+ status: 'uploading' | 'active';
2188
2355
  /** Creation timestamp (Unix seconds) */
2189
2356
  createdAt: number;
2190
2357
  /** Containing folder ID, or null at the vault root */
@@ -2201,7 +2368,7 @@ interface Ingot {
2201
2368
  interface IngotUpload {
2202
2369
  /** Ingot ID */
2203
2370
  id: string;
2204
- /** Ingot name */
2371
+ /** The name the ingot is stored under: the server's numbered name under `new_name`. */
2205
2372
  name: string;
2206
2373
  /** Content type (MIME) */
2207
2374
  contentType: string;
@@ -2211,17 +2378,28 @@ interface IngotUpload {
2211
2378
  uploadUrl: string;
2212
2379
  /** Upload session expiry (Unix seconds) */
2213
2380
  expiresAt: number;
2381
+ /**
2382
+ * Whether the server minted this ingot (true) or staged the upload onto the
2383
+ * ingot already holding the name (false, as `onNameConflict` allowed).
2384
+ */
2385
+ created: boolean;
2214
2386
  }
2215
2387
  /** A finalized ingot, returned by the high-level upload/replace flows. */
2216
2388
  interface CreatedIngot {
2217
2389
  /** Ingot ID */
2218
2390
  id: string;
2219
- /** Ingot name */
2391
+ /** The name the ingot is stored under: the server's numbered name under `new_name`. */
2220
2392
  name: string;
2221
2393
  /** Content type (MIME) */
2222
2394
  contentType: string;
2223
2395
  /** Size in bytes */
2224
2396
  size: number;
2397
+ /**
2398
+ * Whether the upload minted this ingot (true) or replaced the content of an
2399
+ * existing one (false): a same-name upload the name-conflict policy staged
2400
+ * onto its holder, or any `replace`.
2401
+ */
2402
+ created: boolean;
2225
2403
  }
2226
2404
  /** The discrete primitive returned by createDownloadLink. */
2227
2405
  interface IngotDownloadLink {
@@ -2254,6 +2432,8 @@ interface CreateUploadOptions {
2254
2432
  folderId?: string;
2255
2433
  /** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
2256
2434
  contentHmac?: string;
2435
+ /** What a name already held in the target folder does; omitted means the server's `upsert`. */
2436
+ onNameConflict?: NameConflictPolicy;
2257
2437
  }
2258
2438
  /** Options for the high-level upload flow. */
2259
2439
  interface UploadIngotOptions {
@@ -2269,9 +2449,18 @@ interface UploadIngotOptions {
2269
2449
  folderId?: string;
2270
2450
  /** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
2271
2451
  contentHmac?: string;
2452
+ /** What a name already held in the target folder does; omitted means the server's `upsert`. */
2453
+ onNameConflict?: NameConflictPolicy;
2272
2454
  /** Progress callback for the Forge/TUS transfer */
2273
2455
  onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
2274
2456
  }
2457
+ /** Options for sendUpload. */
2458
+ interface SendUploadOptions {
2459
+ /** Cancels the transfer. */
2460
+ signal?: AbortSignal;
2461
+ /** Bytes sent so far and the file size; never runs backwards. */
2462
+ onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
2463
+ }
2275
2464
  /** Options for replacing an existing ingot's content. */
2276
2465
  interface ReplaceIngotOptions {
2277
2466
  /** File or Blob to upload as the new content */
@@ -2300,16 +2489,29 @@ interface ListIngotsOptions {
2300
2489
  interface ListContentsOptions {
2301
2490
  /** Folder to list (null/omitted lists the vault root) */
2302
2491
  folderId?: string | null;
2303
- /** Page size */
2304
- limit?: number;
2305
- /** Pagination cursor */
2306
- cursor?: string;
2307
- /** Sort field */
2492
+ /** Ingot sort field (name | size | content_type | created | access_count | bandwidth); `created` by default */
2308
2493
  sortBy?: string;
2309
- /** Sort direction */
2494
+ /** Sort direction; `desc` by default */
2310
2495
  sortOrder?: 'asc' | 'desc';
2311
- /** Filter by item type */
2312
- type?: string;
2496
+ }
2497
+ /**
2498
+ * One folder's whole listing, in one response: the folder itself, the trail
2499
+ * from the vault root to it, its direct subfolders (pinned first) and every
2500
+ * ingot directly in it, in the requested order.
2501
+ */
2502
+ interface FolderContents {
2503
+ /** The folder listed, or null at the vault root */
2504
+ folder: {
2505
+ id: string;
2506
+ name: string;
2507
+ parentId: string | null;
2508
+ } | null;
2509
+ /** Root → … → the folder listed */
2510
+ breadcrumb: FolderBreadcrumbItem[];
2511
+ /** Direct subfolders */
2512
+ folders: Folder[];
2513
+ /** Every ingot directly in the folder */
2514
+ ingots: Ingot[];
2313
2515
  }
2314
2516
  /** Options for search. */
2315
2517
  interface SearchIngotsOptions {
@@ -2367,13 +2569,20 @@ interface IngotInvite {
2367
2569
  /** Identity type */
2368
2570
  identityType: string;
2369
2571
  }
2370
- /** An ingot access-log entry. */
2572
+ /**
2573
+ * An ingot access-log entry: a download that delivered the file, a SparkLink
2574
+ * open of it included. The server records an access as the download that
2575
+ * delivered it, so `download` is the one action.
2576
+ */
2371
2577
  interface IngotAccessLog {
2372
- /** Log entry ID */
2578
+ /**
2579
+ * The entry's time (Unix seconds) as a string. The server issues no entry id,
2580
+ * so entries in the same second share it.
2581
+ */
2373
2582
  id: string;
2374
- /** Action performed (download | view) */
2375
- action: string;
2376
- /** Acting identity */
2583
+ /** What the access was */
2584
+ action: 'download';
2585
+ /** Who accessed: a member's email, an API key's name, or a SparkLink visitor's identity */
2377
2586
  identity: string;
2378
2587
  /** Source IP address */
2379
2588
  ipAddress: string;
@@ -2405,6 +2614,45 @@ interface HashCheckResponse {
2405
2614
  found: HashCheckMatch[];
2406
2615
  }
2407
2616
 
2617
+ /**
2618
+ * The one browser transfer for a signed ingot download link: fetch it into a
2619
+ * Blob under liveness bounds. `sv.ingots.download` uses it, and so can a caller
2620
+ * that mints its own link (`createDownloadLink`, or its own authenticated
2621
+ * call) and needs cancellation, byte progress or the published revision.
2622
+ */
2623
+ interface FetchDownloadOptions {
2624
+ /** Cancels the transfer; the returned promise rejects with the signal's reason. */
2625
+ signal?: AbortSignal;
2626
+ /** Bytes received so far and the declared length (0 when the server declared none). */
2627
+ onProgress?: (loaded: number, total: number) => void;
2628
+ /**
2629
+ * The published revision the caller read. A response naming another one is
2630
+ * refused (code `content_changed`) before its body is read: the bytes would
2631
+ * not be the file the caller described.
2632
+ */
2633
+ expectedContentVersion?: string | null;
2634
+ /**
2635
+ * The hosts a download link may name (handed the lowercased host name);
2636
+ * SparkVault's own hosts when omitted. `sv.ingots.download` passes the
2637
+ * client's `allowedDownloadHostPatterns`.
2638
+ */
2639
+ isAllowedHost?: (hostname: string) => boolean;
2640
+ }
2641
+ interface FetchedDownload {
2642
+ blob: Blob;
2643
+ /** The revision the bytes are (the response's X-Content-Version), or null when the server named none. */
2644
+ contentVersion: string | null;
2645
+ }
2646
+ /**
2647
+ * Fetch a signed download URL as a Blob under liveness bounds: one deadline
2648
+ * for the response headers, then an idle deadline rearmed on every body chunk.
2649
+ * Nothing caps the transfer as a whole, so file size never decides whether a
2650
+ * download can finish. The link is single-use: a caller that retries mints a
2651
+ * fresh one first. A link that is not a Forge decrypt URL on an allowed host is
2652
+ * refused before anything is sent (assertDownloadUrl).
2653
+ */
2654
+ declare function fetchDownload(url: string, options?: FetchDownloadOptions): Promise<FetchedDownload>;
2655
+
2408
2656
  /**
2409
2657
  * Ingots Module
2410
2658
  *
@@ -2420,13 +2668,6 @@ interface HashCheckResponse {
2420
2668
  declare class IngotsModule {
2421
2669
  private readonly config;
2422
2670
  private readonly http;
2423
- /**
2424
- * Forge transfer client for authenticated ingot uploads. A dedicated
2425
- * instance: the widget's own client is session-scoped (reset/aborted with
2426
- * the widget lifecycle), and sharing it would let a widget close() abort an
2427
- * unrelated upload() transfer.
2428
- */
2429
- private readonly uploadApi;
2430
2671
  constructor(config: ResolvedConfig, http: HttpClient);
2431
2672
  /**
2432
2673
  * Create an ingot upload session (discrete primitive).
@@ -2443,6 +2684,23 @@ declare class IngotsModule {
2443
2684
  * console.log(session.uploadUrl);
2444
2685
  */
2445
2686
  createUpload(options: CreateUploadOptions): Promise<IngotUpload>;
2687
+ /**
2688
+ * Send a file's bytes to an upload session — the `uploadUrl` a
2689
+ * {@link createUpload} returned — over the resumable transfer every SDK
2690
+ * upload uses. Resolves only once the server confirms the ingot is
2691
+ * published, so a resolved promise never stands for a stored file whose
2692
+ * ingot never went live.
2693
+ *
2694
+ * @param options.signal - Cancels this transfer (it rejects with code
2695
+ * `cancelled`); other transfers carry on.
2696
+ * @param options.onProgress - Bytes sent so far and the file size; never runs backwards.
2697
+ *
2698
+ * @example
2699
+ * const session = await sv.ingots.createUpload({ vault: unsealed, name: file.name,
2700
+ * contentType: file.type, sizeBytes: file.size });
2701
+ * await sv.ingots.sendUpload(session.uploadUrl, file, { signal: controller.signal });
2702
+ */
2703
+ sendUpload(uploadUrl: string, file: File | Blob, options?: SendUploadOptions): Promise<void>;
2446
2704
  /**
2447
2705
  * Upload a file as a new ingot (high-level flow).
2448
2706
  *
@@ -2506,12 +2764,13 @@ declare class IngotsModule {
2506
2764
  */
2507
2765
  search(vault: UnsealedVault, options?: SearchIngotsOptions): Promise<IngotPage>;
2508
2766
  /**
2509
- * List the contents (ingots) of a folder, or the vault root.
2767
+ * List a folder, or the vault root, whole: the folder, its breadcrumb trail,
2768
+ * its direct subfolders and every ingot directly in it, in one response.
2510
2769
  *
2511
2770
  * @example
2512
- * const { ingots } = await sv.ingots.listContents(unsealed, { folderId: 'fld_x' });
2771
+ * const { folders, ingots } = await sv.ingots.listContents(unsealed, { folderId: 'fld_x' });
2513
2772
  */
2514
- listContents(vault: UnsealedVault, options?: ListContentsOptions): Promise<IngotPage>;
2773
+ listContents(vault: UnsealedVault, options?: ListContentsOptions): Promise<FolderContents>;
2515
2774
  /**
2516
2775
  * Create a signed download link for an ingot (discrete primitive).
2517
2776
  *
@@ -2600,53 +2859,8 @@ declare class IngotsModule {
2600
2859
  */
2601
2860
  private transferAndFinalize;
2602
2861
  private validateFile;
2603
- private validateDownloadUrl;
2604
- }
2605
-
2606
- /**
2607
- * Folders Module Types
2608
- *
2609
- * Folders organize ingots within an unsealed vault. Public domain objects are
2610
- * camelCase; wire shapes (snake_case) stay private to the module.
2611
- */
2612
-
2613
- /** A folder within a vault. */
2614
- interface Folder {
2615
- /** Folder ID */
2616
- id: string;
2617
- /** Folder name */
2618
- name: string;
2619
- /** Parent folder ID, or null at the vault root */
2620
- parentId: string | null;
2621
- /** Whether the folder is pinned */
2622
- pinned: boolean;
2623
- /** Creation timestamp (Unix seconds) */
2624
- createdAt: number;
2625
- /** Last update timestamp (Unix seconds) */
2626
- updatedAt: number;
2627
- }
2628
- /** A single hop in a folder breadcrumb trail. */
2629
- interface FolderBreadcrumbItem {
2630
- /** Folder ID, or null for the Root entry */
2631
- id: string | null;
2632
- /** Folder name */
2633
- name: string;
2634
- }
2635
- /** Options for creating a folder. */
2636
- interface CreateFolderOptions {
2637
- /** Folder name */
2638
- name: string;
2639
- /** Parent folder ID, or null/omitted for the vault root */
2640
- parentId?: string | null;
2641
- }
2642
- /** Options for updating a folder. */
2643
- interface UpdateFolderOptions {
2644
- /** New name */
2645
- name?: string;
2646
- /** New parent folder ID, or null for the vault root */
2647
- parentId?: string | null;
2648
- /** New pinned state */
2649
- pinned?: boolean;
2862
+ /** The client's transfer-host allowlist (`allowedDownloadHostPatterns`), as a download link is read against it. */
2863
+ private readonly allowsTransferHost;
2650
2864
  }
2651
2865
 
2652
2866
  /**
@@ -2929,7 +3143,7 @@ declare class SparksModule {
2929
3143
  type EntropyFormat = 'hex' | 'base64' | 'base64url' | 'alphanumeric' | 'alphanumeric-mixed' | 'password' | 'numeric' | 'uuid' | 'bytes';
2930
3144
  /** Options for generate. */
2931
3145
  interface GenerateEntropyOptions {
2932
- /** Number of random bytes (1–1024) */
3146
+ /** Number of random bytes: 1–1024, or 1–512 for alphanumeric, alphanumeric-mixed and password. */
2933
3147
  bytes: number;
2934
3148
  /** Output format. Defaults to hex. */
2935
3149
  format?: EntropyFormat;
@@ -2978,7 +3192,6 @@ declare class EntropyModule {
2978
3192
  * const key = serverEntropy.map((b, i) => b ^ localEntropy[i]);
2979
3193
  */
2980
3194
  generateBytes(n: number): Promise<Uint8Array>;
2981
- private validateByteCount;
2982
3195
  }
2983
3196
 
2984
3197
  /**
@@ -3209,5 +3422,5 @@ declare global {
3209
3422
  }
3210
3423
  }
3211
3424
 
3212
- export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IngotsModule, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, logger, setDebugMode };
3213
- export type { AccessLogRetention, AccessLogsOptions, ApiResponse, AuthMethod, BandwidthPool, CreateFolderOptions, CreateNotifySendOptions, CreateSparkOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, EntropyFormat, EntropyResult, Folder, FolderBreadcrumbItem, GenerateEntropyOptions, HealthCheckOptions, HealthCheckResult, AttachOptions as IdentityAttachOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyReceiptSource, NotifyRecipient, NotifyRecipientRef, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusRecipient, NotifySendSummary, NotifyVerificationLevel, PoolState, PoolsMeta, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, ResponseMeta, SearchIngotsOptions, ShareSparkOptions, Spark, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StoragePool, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, Theme, TokenClaims, UnreadCountResponse, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, Vault, VaultDetail, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushSubscriptionInput };
3425
+ export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, logger, setDebugMode };
3426
+ export type { AccessLogRetention, AccessLogsOptions, ApiResponse, AuthMethod, BandwidthPool, CreateFolderOptions, CreateNotifySendOptions, CreateSparkOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, GenerateEntropyOptions, HealthCheckOptions, HealthCheckResult, AttachOptions as IdentityAttachOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusRecipient, NotifySendSummary, NotifyVerificationLevel, PoolState, PoolsMeta, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, ResponseMeta, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, Spark, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StoragePool, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, Theme, TokenClaims, UnreadCountResponse, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, Vault, VaultDetail, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushSubscriptionInput };