@sparkvault/sdk-js 10.0.1 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The one browser transfer for a signed ingot download link: fetch it into a
3
+ * Blob under liveness bounds. `sv.ingots.download` uses it, and so can a caller
4
+ * that mints its own link (`createDownloadLink`, or its own authenticated
5
+ * call) and needs cancellation, byte progress or the published revision.
6
+ */
7
+ export interface FetchDownloadOptions {
8
+ /** Cancels the transfer; the returned promise rejects with the signal's reason. */
9
+ signal?: AbortSignal;
10
+ /** Bytes received so far and the declared length (0 when the server declared none). */
11
+ onProgress?: (loaded: number, total: number) => void;
12
+ /**
13
+ * The published revision the caller read. A response naming another one is
14
+ * refused (code `content_changed`) before its body is read: the bytes would
15
+ * not be the file the caller described.
16
+ */
17
+ expectedContentVersion?: string | null;
18
+ /**
19
+ * The hosts a download link may name (handed the lowercased host name);
20
+ * SparkVault's own hosts when omitted. `sv.ingots.download` passes the
21
+ * client's `allowedDownloadHostPatterns`.
22
+ */
23
+ isAllowedHost?: (hostname: string) => boolean;
24
+ }
25
+ export interface FetchedDownload {
26
+ blob: Blob;
27
+ /** The revision the bytes are (the response's X-Content-Version), or null when the server named none. */
28
+ contentVersion: string | null;
29
+ }
30
+ /**
31
+ * Refuse a download link that is not a Forge decrypt URL on an allowed host
32
+ * (SparkVault's own when the caller names none), by the one reading of a
33
+ * Core-issued transfer URL (app-sdk forge-url): https, no credentials, port or
34
+ * fragment, the decrypt path, exactly one ISTK. The ISTK is a bearer
35
+ * credential for the transfer, so nothing is sent to a link this refuses.
36
+ *
37
+ * @throws {ValidationError} 'Invalid download URL', with `details.reason` naming the refusal
38
+ */
39
+ export declare function assertDownloadUrl(url: string, isAllowedHost?: (hostname: string) => boolean): void;
40
+ /**
41
+ * Fetch a signed download URL as a Blob under liveness bounds: one deadline
42
+ * for the response headers, then an idle deadline rearmed on every body chunk.
43
+ * Nothing caps the transfer as a whole, so file size never decides whether a
44
+ * download can finish. The link is single-use: a caller that retries mints a
45
+ * fresh one first. A link that is not a Forge decrypt URL on an allowed host is
46
+ * refused before anything is sent (assertDownloadUrl).
47
+ */
48
+ export declare function fetchDownload(url: string, options?: FetchDownloadOptions): Promise<FetchedDownload>;
@@ -9,19 +9,12 @@
9
9
  * (shared with the public upload widget), with server-side finalization and
10
10
  * download-host allowlisting enforced — no per-size branching.
11
11
  */
12
- import type { ResolvedConfig } from '../config';
12
+ import { type ResolvedConfig } from '../config';
13
13
  import { HttpClient } from '../http';
14
- import type { UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, AddInviteOptions, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse } from './types';
14
+ import type { UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, AddInviteOptions, IngotAccessLogPage, AccessLogsOptions, HashCheckResponse } from './types';
15
15
  export declare class IngotsModule {
16
16
  private readonly config;
17
17
  private readonly http;
18
- /**
19
- * Forge transfer client for authenticated ingot uploads. A dedicated
20
- * instance: the widget's own client is session-scoped (reset/aborted with
21
- * the widget lifecycle), and sharing it would let a widget close() abort an
22
- * unrelated upload() transfer.
23
- */
24
- private readonly uploadApi;
25
18
  constructor(config: ResolvedConfig, http: HttpClient);
26
19
  /**
27
20
  * Create an ingot upload session (discrete primitive).
@@ -38,6 +31,23 @@ export declare class IngotsModule {
38
31
  * console.log(session.uploadUrl);
39
32
  */
40
33
  createUpload(options: CreateUploadOptions): Promise<IngotUpload>;
34
+ /**
35
+ * Send a file's bytes to an upload session — the `uploadUrl` a
36
+ * {@link createUpload} returned — over the resumable transfer every SDK
37
+ * upload uses. Resolves only once the server confirms the ingot is
38
+ * published, so a resolved promise never stands for a stored file whose
39
+ * ingot never went live.
40
+ *
41
+ * @param options.signal - Cancels this transfer (it rejects with code
42
+ * `cancelled`); other transfers carry on.
43
+ * @param options.onProgress - Bytes sent so far and the file size; never runs backwards.
44
+ *
45
+ * @example
46
+ * const session = await sv.ingots.createUpload({ vault: unsealed, name: file.name,
47
+ * contentType: file.type, sizeBytes: file.size });
48
+ * await sv.ingots.sendUpload(session.uploadUrl, file, { signal: controller.signal });
49
+ */
50
+ sendUpload(uploadUrl: string, file: File | Blob, options?: SendUploadOptions): Promise<void>;
41
51
  /**
42
52
  * Upload a file as a new ingot (high-level flow).
43
53
  *
@@ -101,12 +111,13 @@ export declare class IngotsModule {
101
111
  */
102
112
  search(vault: UnsealedVault, options?: SearchIngotsOptions): Promise<IngotPage>;
103
113
  /**
104
- * List the contents (ingots) of a folder, or the vault root.
114
+ * List a folder, or the vault root, whole: the folder, its breadcrumb trail,
115
+ * its direct subfolders and every ingot directly in it, in one response.
105
116
  *
106
117
  * @example
107
- * const { ingots } = await sv.ingots.listContents(unsealed, { folderId: 'fld_x' });
118
+ * const { folders, ingots } = await sv.ingots.listContents(unsealed, { folderId: 'fld_x' });
108
119
  */
109
- listContents(vault: UnsealedVault, options?: ListContentsOptions): Promise<IngotPage>;
120
+ listContents(vault: UnsealedVault, options?: ListContentsOptions): Promise<FolderContents>;
110
121
  /**
111
122
  * Create a signed download link for an ingot (discrete primitive).
112
123
  *
@@ -195,6 +206,10 @@ export declare class IngotsModule {
195
206
  */
196
207
  private transferAndFinalize;
197
208
  private validateFile;
198
- private validateDownloadUrl;
209
+ /** The client's transfer-host allowlist (`allowedDownloadHostPatterns`), as a download link is read against it. */
210
+ private readonly allowsTransferHost;
199
211
  }
200
- export type { UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, AddInviteOptions, IngotAccessLog, IngotAccessLogPage, AccessLogsOptions, HashCheckMatch, HashCheckResponse, } from './types';
212
+ export { NAME_CONFLICT_POLICIES } from './types';
213
+ export { fetchDownload } from './fetch-download';
214
+ export type { FetchDownloadOptions, FetchedDownload } from './fetch-download';
215
+ export type { NameConflictPolicy, UnsealedVault, Ingot, IngotUpload, CreatedIngot, IngotDownloadLink, CreateUploadOptions, UploadIngotOptions, SendUploadOptions, ReplaceIngotOptions, ListIngotsOptions, ListContentsOptions, FolderContents, SearchIngotsOptions, IngotPage, IngotSharingConfig, UpdateIngotSharingOptions, IngotInvite, AddInviteOptions, IngotAccessLog, IngotAccessLogPage, AccessLogsOptions, HashCheckMatch, HashCheckResponse, } from './types';
@@ -7,7 +7,25 @@
7
7
  * private to the module.
8
8
  */
9
9
  import type { UnsealedVault } from '../vaults/types';
10
+ import type { Folder, FolderBreadcrumbItem, FolderWire } from '../folders/types';
10
11
  export type { UnsealedVault };
12
+ /**
13
+ * What the server does when a create's name is already held in the target
14
+ * folder (case-insensitive). The server decides on the holder it read before
15
+ * writing anything, so a caller that must not replace content says so here:
16
+ * - `upsert` (the server default): the upload replaces the holder's content.
17
+ * - `complete_pending`: a holder whose own upload never finalized is completed
18
+ * (`created: false`); a published holder is refused with a 409 CONFLICT whose
19
+ * `details` are `{ reason: 'NAME_HELD', ingot_id, status, size_bytes }`, and
20
+ * is left untouched.
21
+ * - `refuse`: any holder, its upload finished or not, is refused with that
22
+ * same 409 and left untouched; the create only ever mints.
23
+ * - `new_name`: the holder is never touched; the ingot is minted under the
24
+ * first free numbered name the server picks ("report (2).pdf"), returned as
25
+ * the result's `name`.
26
+ */
27
+ export declare const NAME_CONFLICT_POLICIES: readonly ["upsert", "complete_pending", "refuse", "new_name"];
28
+ export type NameConflictPolicy = (typeof NAME_CONFLICT_POLICIES)[number];
11
29
  /** Ingot metadata as returned by list/get/contents. */
12
30
  export interface Ingot {
13
31
  /** Ingot ID */
@@ -18,8 +36,8 @@ export interface Ingot {
18
36
  contentType: string;
19
37
  /** Size in bytes */
20
38
  size: number;
21
- /** Lifecycle status (uploading | active | failed) */
22
- status: string;
39
+ /** Lifecycle status: `uploading` until Forge activates the upload, then `active` */
40
+ status: 'uploading' | 'active';
23
41
  /** Creation timestamp (Unix seconds) */
24
42
  createdAt: number;
25
43
  /** Containing folder ID, or null at the vault root */
@@ -36,7 +54,7 @@ export interface Ingot {
36
54
  export interface IngotUpload {
37
55
  /** Ingot ID */
38
56
  id: string;
39
- /** Ingot name */
57
+ /** The name the ingot is stored under: the server's numbered name under `new_name`. */
40
58
  name: string;
41
59
  /** Content type (MIME) */
42
60
  contentType: string;
@@ -46,17 +64,28 @@ export interface IngotUpload {
46
64
  uploadUrl: string;
47
65
  /** Upload session expiry (Unix seconds) */
48
66
  expiresAt: number;
67
+ /**
68
+ * Whether the server minted this ingot (true) or staged the upload onto the
69
+ * ingot already holding the name (false, as `onNameConflict` allowed).
70
+ */
71
+ created: boolean;
49
72
  }
50
73
  /** A finalized ingot, returned by the high-level upload/replace flows. */
51
74
  export interface CreatedIngot {
52
75
  /** Ingot ID */
53
76
  id: string;
54
- /** Ingot name */
77
+ /** The name the ingot is stored under: the server's numbered name under `new_name`. */
55
78
  name: string;
56
79
  /** Content type (MIME) */
57
80
  contentType: string;
58
81
  /** Size in bytes */
59
82
  size: number;
83
+ /**
84
+ * Whether the upload minted this ingot (true) or replaced the content of an
85
+ * existing one (false): a same-name upload the name-conflict policy staged
86
+ * onto its holder, or any `replace`.
87
+ */
88
+ created: boolean;
60
89
  }
61
90
  /** The discrete primitive returned by createDownloadLink. */
62
91
  export interface IngotDownloadLink {
@@ -89,6 +118,8 @@ export interface CreateUploadOptions {
89
118
  folderId?: string;
90
119
  /** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
91
120
  contentHmac?: string;
121
+ /** What a name already held in the target folder does; omitted means the server's `upsert`. */
122
+ onNameConflict?: NameConflictPolicy;
92
123
  }
93
124
  /** Options for the high-level upload flow. */
94
125
  export interface UploadIngotOptions {
@@ -104,9 +135,18 @@ export interface UploadIngotOptions {
104
135
  folderId?: string;
105
136
  /** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
106
137
  contentHmac?: string;
138
+ /** What a name already held in the target folder does; omitted means the server's `upsert`. */
139
+ onNameConflict?: NameConflictPolicy;
107
140
  /** Progress callback for the Forge/TUS transfer */
108
141
  onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
109
142
  }
143
+ /** Options for sendUpload. */
144
+ export interface SendUploadOptions {
145
+ /** Cancels the transfer. */
146
+ signal?: AbortSignal;
147
+ /** Bytes sent so far and the file size; never runs backwards. */
148
+ onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
149
+ }
110
150
  /** Options for replacing an existing ingot's content. */
111
151
  export interface ReplaceIngotOptions {
112
152
  /** File or Blob to upload as the new content */
@@ -135,16 +175,29 @@ export interface ListIngotsOptions {
135
175
  export interface ListContentsOptions {
136
176
  /** Folder to list (null/omitted lists the vault root) */
137
177
  folderId?: string | null;
138
- /** Page size */
139
- limit?: number;
140
- /** Pagination cursor */
141
- cursor?: string;
142
- /** Sort field */
178
+ /** Ingot sort field (name | size | content_type | created | access_count | bandwidth); `created` by default */
143
179
  sortBy?: string;
144
- /** Sort direction */
180
+ /** Sort direction; `desc` by default */
145
181
  sortOrder?: 'asc' | 'desc';
146
- /** Filter by item type */
147
- type?: string;
182
+ }
183
+ /**
184
+ * One folder's whole listing, in one response: the folder itself, the trail
185
+ * from the vault root to it, its direct subfolders (pinned first) and every
186
+ * ingot directly in it, in the requested order.
187
+ */
188
+ export interface FolderContents {
189
+ /** The folder listed, or null at the vault root */
190
+ folder: {
191
+ id: string;
192
+ name: string;
193
+ parentId: string | null;
194
+ } | null;
195
+ /** Root → … → the folder listed */
196
+ breadcrumb: FolderBreadcrumbItem[];
197
+ /** Direct subfolders */
198
+ folders: Folder[];
199
+ /** Every ingot directly in the folder */
200
+ ingots: Ingot[];
148
201
  }
149
202
  /** Options for search. */
150
203
  export interface SearchIngotsOptions {
@@ -202,13 +255,20 @@ export interface IngotInvite {
202
255
  /** Identity type */
203
256
  identityType: string;
204
257
  }
205
- /** An ingot access-log entry. */
258
+ /**
259
+ * An ingot access-log entry: a download that delivered the file, a SparkLink
260
+ * open of it included. The server records an access as the download that
261
+ * delivered it, so `download` is the one action.
262
+ */
206
263
  export interface IngotAccessLog {
207
- /** Log entry ID */
264
+ /**
265
+ * The entry's time (Unix seconds) as a string. The server issues no entry id,
266
+ * so entries in the same second share it.
267
+ */
208
268
  id: string;
209
- /** Action performed (download | view) */
210
- action: string;
211
- /** Acting identity */
269
+ /** What the access was */
270
+ action: 'download';
271
+ /** Who accessed: a member's email, an API key's name, or a SparkLink visitor's identity */
212
272
  identity: string;
213
273
  /** Source IP address */
214
274
  ipAddress: string;
@@ -236,7 +296,7 @@ export interface IngotWire {
236
296
  name: string;
237
297
  content_type: string;
238
298
  size_bytes: number;
239
- status?: string;
299
+ status?: Ingot['status'];
240
300
  created_at?: number;
241
301
  folder_id?: string | null;
242
302
  content_hmac?: string | null;
@@ -250,7 +310,8 @@ export interface HashCheckMatch {
250
310
  export interface HashCheckResponse {
251
311
  found: HashCheckMatch[];
252
312
  }
253
- export interface CreateIngotResponse {
313
+ /** PUT /ingots/:id — a replace stages new content onto the caller's existing ingot. */
314
+ export interface ReplaceIngotResponse {
254
315
  ingot_id: string;
255
316
  name: string;
256
317
  content_type: string;
@@ -259,11 +320,29 @@ export interface CreateIngotResponse {
259
320
  forge_url: string;
260
321
  expires_at: number;
261
322
  }
323
+ /** POST /ingots — `created` says whether the name was minted or its holder staged onto. */
324
+ export interface CreateIngotResponse extends ReplaceIngotResponse {
325
+ created: boolean;
326
+ }
262
327
  export interface ListIngotsResponse {
263
328
  ingots: IngotWire[];
264
329
  count?: number;
265
330
  next_cursor?: string;
266
331
  }
332
+ /** GET /vaults/:id/contents */
333
+ export interface ListContentsResponse {
334
+ folder: {
335
+ folder_id: string;
336
+ name: string;
337
+ parent_id: string | null;
338
+ } | null;
339
+ breadcrumb?: {
340
+ folder_id: string | null;
341
+ name: string;
342
+ }[];
343
+ folders?: FolderWire[];
344
+ ingots?: IngotWire[];
345
+ }
267
346
  export interface DownloadIngotResponse {
268
347
  content_version?: string | null;
269
348
  download_url: string;
@@ -288,27 +367,3 @@ export interface IngotInviteResponse {
288
367
  identity: string;
289
368
  identity_type?: string;
290
369
  }
291
- export interface IngotAuditLogEntry {
292
- id?: string;
293
- log_id?: string;
294
- event_id?: string;
295
- event_type?: string;
296
- action?: string;
297
- actor?: {
298
- email?: string;
299
- id?: string;
300
- user_id?: string;
301
- api_key_id?: string;
302
- };
303
- actor_email?: string;
304
- actor_id?: string;
305
- identity?: string;
306
- ip_address?: string;
307
- user_agent?: string;
308
- timestamp?: number;
309
- created_at?: number;
310
- }
311
- export interface IngotAuditLogsResponse {
312
- entries?: IngotAuditLogEntry[];
313
- next_cursor?: string;
314
- }
@@ -42,10 +42,15 @@ export interface NotificationRow {
42
42
  * The grant to open. Present only while a live reveal stands behind it — a
43
43
  * SEALED (secure) send that has not been recalled. A cleartext send delivers its
44
44
  * content inline in the channel and mints no grant; a recalled row's grant is
45
- * revoked and the pointer is withheld rather than echoed. Guard before building
46
- * a URL from it.
45
+ * revoked and the pointer is withheld rather than echoed.
47
46
  */
48
47
  sparklink_code?: string;
48
+ /**
49
+ * Where the grant opens: the URL every Notify channel carries for it, built by
50
+ * the server. Present exactly when `sparklink_code` is; open this rather than
51
+ * building a URL from the code.
52
+ */
53
+ pointer_url?: string;
49
54
  /**
50
55
  * True only when there is a secure part left to reveal — exactly when
51
56
  * `sparklink_code` is present. `false` does NOT mean "cleartext row": a recalled
@@ -7,7 +7,7 @@
7
7
  import type { ResolvedConfig } from '../../config';
8
8
  import { SparkVaultApi } from '../../api-base';
9
9
  import { SparkVaultError } from '../../errors';
10
- import type { SdkConfig, OtpSendResponse, OtpVerifyResponse, PasskeyChallengeResponse, PasskeyVerifyResponse, SecondFactorVerifyResponse, SparkLinkSendResponse, BackupSendResponse, BackupVerifyResponse, Recommendation, RecommendationKey, AuthContext, VerifyResult, RedeemHandoffResponse } from './types';
10
+ import type { SdkConfig, OtpSendResponse, OtpVerifyResponse, PasskeyChallengeResponse, PasskeyVerifyResponse, SecondFactorVerifyResponse, SparkLinkSendResponse, SparkLinkOutcome, BackupSendResponse, BackupVerifyResponse, Recommendation, RecommendationKey, AuthContext, RedeemHandoffResponse } from './types';
11
11
  export declare class IdentityApi extends SparkVaultApi {
12
12
  private readonly config;
13
13
  /** Cached config promise - allows preloading and deduplication */
@@ -35,16 +35,22 @@ export declare class IdentityApi extends SparkVaultApi {
35
35
  */
36
36
  isConfigPreloaded(): boolean;
37
37
  /**
38
- * Check whether the SVID resolved from an email or phone has registered passkeys.
39
- *
40
- * Returns:
41
- * - identity_valid: identity passes per-type validity check
42
- * (email: MX lookup; phone: E.164 format)
43
- * - has_passkey: whether any passkeys are registered on the resolved SVID
44
- * (cross-tenant — single global RP)
38
+ * An authorization request's PKCE verifier, state and nonce, each spelled
39
+ * from its own slice of one Entropy service draw taken through the Identity
40
+ * origin (POST /{account}/entropy). The page signing in holds no SparkVault
41
+ * credential, and already reaches the Identity origin, so its CSP needs no
42
+ * other origin for the draw.
43
+ */
44
+ drawAuthorizationValues(): Promise<{
45
+ codeVerifier: string;
46
+ state: string;
47
+ nonce: string;
48
+ }>;
49
+ /**
50
+ * Check whether the SVID resolved from an email or phone has registered
51
+ * passkeys (`has_passkey`; cross-tenant — single global RP).
45
52
  */
46
53
  checkPasskey(identity: string, identityType?: 'email' | 'phone'): Promise<{
47
- identity_valid: boolean;
48
54
  has_passkey: boolean;
49
55
  }>;
50
56
  /**
@@ -153,14 +159,24 @@ export declare class IdentityApi extends SparkVaultApi {
153
159
  */
154
160
  sendSparkLink(email: string, connectionId: string, authContext?: AuthContext): Promise<SparkLinkSendResponse>;
155
161
  /**
156
- * Claim the SparkLink verification result by kindling — the WebSocket-loss
162
+ * Claim the SparkLink click's result by kindling — the WebSocket-loss
157
163
  * fallback. The SDK calls this when its socket was suspended with the tab and
158
- * it refocuses. Returns the verified result, or null while still pending (not
159
- * yet clicked) or already consumed. The read burns the server-side spark, so
160
- * the result can be claimed exactly once.
164
+ * it refocuses. Returns what the click produced (a completed login, or its
165
+ * second-factor challenge), or null while still pending (not yet clicked) or
166
+ * already consumed. The read burns the server-side spark, so the result can
167
+ * be claimed exactly once.
161
168
  */
162
- consumeSparkLinkResult(kindling: string): Promise<VerifyResult | null>;
169
+ consumeSparkLinkResult(kindling: string): Promise<SparkLinkOutcome | null>;
163
170
  }
171
+ /**
172
+ * Read a SparkLink result event. The WebSocket push and the kindling reclaim
173
+ * carry the same server-built event, so this is the one reader for both.
174
+ * Returns null for anything that is not a usable result: a still-pending
175
+ * reclaim, or an event missing what its type requires — a challenge without a
176
+ * ticket, or a completed login with neither a token (default flow) nor the
177
+ * redirect that continues it (OIDC hosted login).
178
+ */
179
+ export declare function parseSparkLinkEvent(raw: unknown): SparkLinkOutcome | null;
164
180
  /**
165
181
  * Map the API's snake_case recommendation list to the SDK's typed shape,
166
182
  * dropping any entries the SDK does not understand. Returns undefined when
@@ -4,6 +4,6 @@
4
4
  * Extracted handlers for specific authentication flows.
5
5
  * Each handler has a single responsibility.
6
6
  */
7
- export { PasskeyHandler, type PasskeyResult, type PasskeyCheckResult } from './passkey-handler';
7
+ export { PasskeyHandler, type PasskeyResult } from './passkey-handler';
8
8
  export { OtpHandler, type OtpSendResult, type OtpVerifyResult } from './otp-handler';
9
9
  export { SparkLinkHandler, type SparkLinkSendResult } from './sparklink-handler';
@@ -30,15 +30,6 @@ export interface PasskeyResult {
30
30
  */
31
31
  errorCode?: string;
32
32
  }
33
- /**
34
- * Result of passkey check operation
35
- */
36
- export interface PasskeyCheckResult {
37
- /** Whether the identifier is valid (email domain or phone format) */
38
- identityValid: boolean;
39
- /** Whether the resolved SVID has registered passkeys */
40
- hasPasskey: boolean;
41
- }
42
33
  /**
43
34
  * Handles WebAuthn passkey registration and verification via popup
44
35
  */
@@ -56,11 +47,11 @@ export declare class PasskeyHandler {
56
47
  private readonly popupLauncher;
57
48
  constructor(api: IdentityApi, state: VerificationState);
58
49
  /**
59
- * Resolve the current identifier (email or phone) to its SVID and report
60
- * whether that SVID has any registered passkeys.
61
- * @returns Check result with identityValid and hasPasskey, or null on error
50
+ * Resolve the current identifier (email or phone) to its SVID and record on
51
+ * the verification state whether that SVID has any registered passkeys
52
+ * (null when the check fails).
62
53
  */
63
- checkPasskey(): Promise<PasskeyCheckResult | null>;
54
+ checkPasskey(): Promise<void>;
64
55
  /**
65
56
  * Register a new passkey for the user via popup
66
57
  */
@@ -11,7 +11,6 @@ import type { VerificationState } from '../state';
11
11
  */
12
12
  export interface SparkLinkSendResult {
13
13
  success: boolean;
14
- sparkId?: string;
15
14
  expiresAt?: number;
16
15
  /** Login-ceremony handle used to reclaim the result if the WebSocket is lost. */
17
16
  kindling?: string;
@@ -160,8 +160,11 @@ export declare class IdentityModule {
160
160
  * (a top-level GET, so the `SameSite=Lax` hub cookie rides along) which,
161
161
  * PKCE-bound, returns a one-time code in the fragment — handled by case 1 on
162
162
  * return. No-op (stays put) if session storage or WebCrypto is unavailable,
163
- * so a hostile/degraded environment simply never recovers rather than
164
- * erroring.
163
+ * so a degraded environment simply never recovers rather than erroring. The
164
+ * bounce's PKCE verifier and state are a draw from the Identity origin
165
+ * (`drawAuthorizationValues`): a draw that fails (the origin unreachable, a
166
+ * malformed answer) rejects `handleRedirectResult()` with that error, and the
167
+ * page stays put.
165
168
  */
166
169
  private startRecoveryBounce;
167
170
  /**
@@ -177,9 +180,9 @@ export declare class IdentityModule {
177
180
  private startRedirectFlow;
178
181
  /**
179
182
  * Arm the PKCE + state return leg for a handoff navigation and return the URL
180
- * to navigate to (redirect_uri = this exact page; query preserved for app
181
- * state, fragment dropped since it is the result channel). Returns null when
182
- * session storage or WebCrypto is unavailable so callers can degrade.
183
+ * to navigate to (redirect_uri = this page, per `currentPageReturnUrl`).
184
+ * Returns null when session storage or WebCrypto is unavailable so callers
185
+ * can degrade.
183
186
  */
184
187
  private prepareHandoffNavigation;
185
188
  /**
@@ -201,6 +204,14 @@ export declare class IdentityModule {
201
204
  private clearUrlFragment;
202
205
  /** Drop the one-shot PKCE state/verifier a bounce staged. */
203
206
  private clearOneShotAuthState;
207
+ /**
208
+ * Complete a social round trip that returned to the sign-in page as
209
+ * `#token=…&state=…`. Only `render()` — the Identity-origin sign-in page —
210
+ * reads it: no SDK flow returns a `#token` to a site (a site's results arrive
211
+ * by the popup's postMessage, FedCM, or a PKCE-bound `#sv_code`), so on a site
212
+ * it could only be someone else's token, or the site's own direct
213
+ * token-redirect result.
214
+ */
204
215
  private consumeRedirectResult;
205
216
  /**
206
217
  * Close the identity dialog/inline UI if open.
@@ -220,12 +231,18 @@ export declare class IdentityModule {
220
231
  */
221
232
  private preloadedConfigPermanentlyFailed;
222
233
  /**
223
- * Resolve target to an HTMLElement.
234
+ * The inline container for an embedded render. Bare chrome: the host page
235
+ * owns logo + footer + background, so the container drops its own surface
236
+ * and the SparkVault footer.
224
237
  */
225
238
  private createInlineContainer;
226
239
  /**
227
240
  * Render the flow into a page element instead of a popup.
228
241
  *
242
+ * A social login started here returns to this same page with its result in
243
+ * the fragment, so a returned `#token` is completed first (see
244
+ * `consumeRedirectResult`) instead of starting the flow again.
245
+ *
229
246
  * @internal Used only by the SparkVault-hosted sign-in popup and hosted login
230
247
  * page (which own their chrome and pass `renderMode: 'local'`). Customer
231
248
  * integrations have no inline mode — use `signIn()` / `attach()`.
@@ -1,47 +1,36 @@
1
1
  /**
2
2
  * Inline Container
3
3
  *
4
- * Renders identity verification UI inline within a target element.
5
- * Unlike ModalContainer which creates an overlay popup, this embeds
6
- * directly into the customer's page/dialog where render() was called.
4
+ * Renders identity verification UI inline within a target element, in the
5
+ * SDK's shared inline shell. Unlike ModalContainer, which opens a dialog, this
6
+ * embeds directly into the customer's page/dialog where render() was called.
7
7
  *
8
8
  * Implements the Container interface for use with IdentityRenderer.
9
9
  */
10
10
  import type { Container } from './container';
11
11
  import type { SdkConfigBranding } from './types';
12
12
  export interface InlineContainerOptions {
13
- /** Show header with branding and optional close button */
14
- showHeader?: boolean;
15
- /** Show close button in header (requires showHeader) */
16
- showCloseButton?: boolean;
17
- /** Show footer with SparkVault branding */
18
- showFooter?: boolean;
19
13
  /**
20
- * Bare mode: drop the container's own surface (border, radius, background)
21
- * so it flows transparently inside a host page that owns the chrome.
14
+ * Bare mode: the host page owns the chrome, so the container drops its own
15
+ * surface (border, radius, background) and the SparkVault footer and flows
16
+ * transparently inside the page.
22
17
  */
23
18
  bare?: boolean;
24
19
  }
25
20
  export declare class InlineContainer implements Container {
26
21
  private readonly targetElement;
27
- private readonly containerOptions;
28
- private container;
29
- private header;
30
- private body;
31
- private footer;
32
- private closeBtn;
33
- private onCloseCallback;
34
- private closeBtnClickHandler;
35
- private effectiveTheme;
22
+ private readonly bare;
23
+ private shell;
36
24
  constructor(targetElement: HTMLElement, options?: InlineContainerOptions);
37
25
  /**
38
- * Create the inline container with loading state.
26
+ * Create the inline container with loading state. An embedded widget has no
27
+ * close affordance of its own, so the close callback is not wired.
39
28
  */
40
29
  createLoading(_options: {
41
30
  backdropBlur?: boolean;
42
- }, onClose: () => void): void;
31
+ }, _onClose: () => void): void;
43
32
  /**
44
- * Update branding after SDK config loads.
33
+ * Re-theme the stylesheet once the SDK config loads.
45
34
  */
46
35
  updateBranding(branding: SdkConfigBranding): void;
47
36
  /**
@@ -62,9 +51,7 @@ export declare class InlineContainer implements Container {
62
51
  */
63
52
  isOpen(): boolean;
64
53
  /**
65
- * Destroy the container and clean up.
54
+ * Destroy the container, leaving the target empty.
66
55
  */
67
56
  destroy(): void;
68
- private createHeader;
69
- private handleClose;
70
57
  }