@sparkvault/sdk-js 19.0.1 → 19.1.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 (133) hide show
  1. package/README.md +26 -4
  2. package/dist/npm/chunks/index-C97091lF.mjs +12959 -0
  3. package/dist/npm/chunks/index-C97091lF.mjs.map +1 -0
  4. package/dist/npm/chunks/index-D_p_8VO7.cjs +13024 -0
  5. package/dist/npm/chunks/index-D_p_8VO7.cjs.map +1 -0
  6. package/dist/npm/identity.cjs +23 -0
  7. package/dist/npm/identity.cjs.map +1 -0
  8. package/dist/npm/identity.mjs +12 -0
  9. package/dist/npm/identity.mjs.map +1 -0
  10. package/dist/{index.cjs → npm/index.cjs} +802 -13759
  11. package/dist/npm/index.cjs.map +1 -0
  12. package/dist/{index.mjs → npm/index.mjs} +203 -13159
  13. package/dist/npm/index.mjs.map +1 -0
  14. package/dist/sparkvault-identity.js +2 -0
  15. package/dist/sparkvault-identity.js.map +1 -0
  16. package/dist/sparkvault.js +1 -1
  17. package/dist/sparkvault.js.map +1 -1
  18. package/dist/types/identity.d.ts +8 -0
  19. package/dist/{index.d.ts → types/index.d.ts} +4 -790
  20. package/dist/types/shared/errors-C-gjmGBs.d.ts +800 -0
  21. package/package.json +20 -9
  22. package/dist/api-base.d.ts +0 -116
  23. package/dist/auto-init.d.ts +0 -32
  24. package/dist/config.d.ts +0 -79
  25. package/dist/entropy/index.d.ts +0 -35
  26. package/dist/entropy/types.d.ts +0 -32
  27. package/dist/errors.d.ts +0 -146
  28. package/dist/folders/index.d.ts +0 -102
  29. package/dist/folders/types.d.ts +0 -91
  30. package/dist/health.d.ts +0 -18
  31. package/dist/http.d.ts +0 -46
  32. package/dist/index.cjs.map +0 -1
  33. package/dist/index.mjs.map +0 -1
  34. package/dist/ingots/fetch-download.d.ts +0 -78
  35. package/dist/ingots/history.d.ts +0 -4
  36. package/dist/ingots/index.d.ts +0 -388
  37. package/dist/ingots/revision.d.ts +0 -4
  38. package/dist/ingots/types.d.ts +0 -556
  39. package/dist/logger.d.ts +0 -32
  40. package/dist/notify/index.d.ts +0 -154
  41. package/dist/notify/types.d.ts +0 -232
  42. package/dist/products/help-desk/client.d.ts +0 -198
  43. package/dist/products/help-desk/desk-id.d.ts +0 -2
  44. package/dist/products/help-desk/form-draft.d.ts +0 -37
  45. package/dist/products/help-desk/form-types.d.ts +0 -123
  46. package/dist/products/help-desk/form.d.ts +0 -83
  47. package/dist/products/help-desk/index.d.ts +0 -47
  48. package/dist/products/help-desk/kb-client.d.ts +0 -48
  49. package/dist/products/help-desk/kb-types.d.ts +0 -59
  50. package/dist/products/help-desk/modal.d.ts +0 -8
  51. package/dist/products/help-desk/styles.d.ts +0 -9
  52. package/dist/products/help-desk/support-analytics-types.d.ts +0 -32
  53. package/dist/products/help-desk/support-analytics.d.ts +0 -3
  54. package/dist/products/help-desk/support-brand.d.ts +0 -49
  55. package/dist/products/help-desk/support-controller.d.ts +0 -4
  56. package/dist/products/help-desk/support-history.d.ts +0 -38
  57. package/dist/products/help-desk/support-launcher.d.ts +0 -12
  58. package/dist/products/help-desk/support-styles.d.ts +0 -14
  59. package/dist/products/help-desk/support-types.d.ts +0 -66
  60. package/dist/products/help-desk/support-view.d.ts +0 -173
  61. package/dist/products/help-desk/types.d.ts +0 -285
  62. package/dist/products/help-desk/widget-identity.d.ts +0 -32
  63. package/dist/products/identity/api.d.ts +0 -237
  64. package/dist/products/identity/container.d.ts +0 -44
  65. package/dist/products/identity/dialog-launcher.d.ts +0 -133
  66. package/dist/products/identity/federation-flow.d.ts +0 -31
  67. package/dist/products/identity/handlers/otp-handler.d.ts +0 -69
  68. package/dist/products/identity/handlers/passkey-handler.d.ts +0 -105
  69. package/dist/products/identity/handlers/sparklink-handler.d.ts +0 -34
  70. package/dist/products/identity/index.d.ts +0 -296
  71. package/dist/products/identity/inline-container.d.ts +0 -53
  72. package/dist/products/identity/methods.d.ts +0 -19
  73. package/dist/products/identity/modal.d.ts +0 -51
  74. package/dist/products/identity/pending-signin.d.ts +0 -102
  75. package/dist/products/identity/popup-launcher.d.ts +0 -73
  76. package/dist/products/identity/renderer.d.ts +0 -525
  77. package/dist/products/identity/state.d.ts +0 -84
  78. package/dist/products/identity/styles.d.ts +0 -31
  79. package/dist/products/identity/types.d.ts +0 -561
  80. package/dist/products/identity/utils/cooldown-timer.d.ts +0 -73
  81. package/dist/products/identity/utils.d.ts +0 -85
  82. package/dist/products/identity/views/backup-verify.d.ts +0 -42
  83. package/dist/products/identity/views/base.d.ts +0 -51
  84. package/dist/products/identity/views/error.d.ts +0 -65
  85. package/dist/products/identity/views/icons.d.ts +0 -41
  86. package/dist/products/identity/views/identity-input.d.ts +0 -80
  87. package/dist/products/identity/views/index.d.ts +0 -20
  88. package/dist/products/identity/views/loading.d.ts +0 -23
  89. package/dist/products/identity/views/method-button.d.ts +0 -14
  90. package/dist/products/identity/views/method-select.d.ts +0 -42
  91. package/dist/products/identity/views/origin-not-allowed.d.ts +0 -25
  92. package/dist/products/identity/views/otp-verify.d.ts +0 -58
  93. package/dist/products/identity/views/passkey-auto.d.ts +0 -22
  94. package/dist/products/identity/views/passkey-prompt.d.ts +0 -25
  95. package/dist/products/identity/views/passkey.d.ts +0 -38
  96. package/dist/products/identity/views/product-not-configured.d.ts +0 -21
  97. package/dist/products/identity/views/service-unavailable.d.ts +0 -21
  98. package/dist/products/identity/views/sms-consent.d.ts +0 -16
  99. package/dist/products/identity/views/sparklink-waiting.d.ts +0 -40
  100. package/dist/products/identity/views/two-factor.d.ts +0 -37
  101. package/dist/products/index.d.ts +0 -51
  102. package/dist/products/messaging/index.d.ts +0 -38
  103. package/dist/products/messaging/types.d.ts +0 -162
  104. package/dist/products/notify/index.d.ts +0 -436
  105. package/dist/products/notify/project-types.d.ts +0 -44
  106. package/dist/products/notify/projects.d.ts +0 -15
  107. package/dist/products/notify/types.d.ts +0 -1327
  108. package/dist/products/structured-ingots/index.d.ts +0 -31
  109. package/dist/products/structured-ingots/types-client.d.ts +0 -19
  110. package/dist/products/structured-ingots/types.d.ts +0 -293
  111. package/dist/products/structured-ingots/validation.d.ts +0 -25
  112. package/dist/request-path.d.ts +0 -44
  113. package/dist/sparks/index.d.ts +0 -91
  114. package/dist/sparks/types.d.ts +0 -304
  115. package/dist/ui/chrome.d.ts +0 -16
  116. package/dist/ui/ds-tokens.d.ts +0 -59
  117. package/dist/ui/inline-shell.d.ts +0 -19
  118. package/dist/ui/live-region.d.ts +0 -15
  119. package/dist/ui/modal-shell.d.ts +0 -67
  120. package/dist/ui/target.d.ts +0 -6
  121. package/dist/utils/dom.d.ts +0 -26
  122. package/dist/vault-session.d.ts +0 -2
  123. package/dist/vaults/index.d.ts +0 -254
  124. package/dist/vaults/types.d.ts +0 -368
  125. package/dist/vaults/upload/api.d.ts +0 -310
  126. package/dist/vaults/upload/chrome.d.ts +0 -21
  127. package/dist/vaults/upload/container.d.ts +0 -37
  128. package/dist/vaults/upload/index.d.ts +0 -76
  129. package/dist/vaults/upload/inline-container.d.ts +0 -41
  130. package/dist/vaults/upload/modal.d.ts +0 -55
  131. package/dist/vaults/upload/renderer.d.ts +0 -150
  132. package/dist/vaults/upload/styles.d.ts +0 -14
  133. package/dist/vaults/upload/types.d.ts +0 -220
@@ -1,525 +0,0 @@
1
- /**
2
- * Identity View Renderer
3
- *
4
- * Orchestrates view state and rendering for identity verification flows.
5
- * Uses extracted handlers for OTP and Passkey operations.
6
- */
7
- import type { VerifyOptions, VerifyResult } from './types';
8
- import { IdentityApi } from './api';
9
- import type { Container } from './container';
10
- import { type FederationReturn } from './federation-flow';
11
- import { type SigninIdentityTypesRead } from './utils';
12
- interface RendererCallbacks {
13
- onSuccess: (result: VerifyResult) => void;
14
- onError: (error: Error) => void;
15
- onCancel: () => void;
16
- }
17
- export declare class IdentityRenderer {
18
- private readonly api;
19
- private readonly container;
20
- private readonly options;
21
- private readonly callbacks;
22
- private readonly verificationState;
23
- private readonly passkeyHandler;
24
- private readonly otpHandler;
25
- private readonly sparkLinkHandler;
26
- private identityPrefilled;
27
- private currentView;
28
- private focusTimeoutId;
29
- private morphTimer;
30
- private discoverableVerifyAbort;
31
- private postLoginResult;
32
- private postLoginQueue;
33
- private sparkLinkWs;
34
- private sparkLinkKindling;
35
- private sparkLinkVisibilityHandler;
36
- private sparkLinkClaiming;
37
- private sparkLinkRetryTimer;
38
- private federationReturn;
39
- private federationMayAutoStart;
40
- private pageRestoreHandler;
41
- private readonly askReference;
42
- private referenceAsk;
43
- private referenceAsks;
44
- private readonly offeredWithoutReference;
45
- private untouchedStep;
46
- private readonly identityTypesUnreadable;
47
- private statusRegion;
48
- constructor(container: Container, api: IdentityApi, options: VerifyOptions, callbacks: RendererCallbacks, federationReturn?: FederationReturn | null, identityTypes?: SigninIdentityTypesRead);
49
- /**
50
- * Seed the verification identity from the render options, deriving the
51
- * channel (email vs phone) from the value itself rather than trusting which
52
- * option field carried it. The hosted login forwards a simple-mode identity
53
- * hint (which may be a phone number) as `email`; keying off the value keeps
54
- * the method list AND the OTP delivery target aligned with the real channel
55
- * instead of falling back to the email methods. Normalizes to E.164 /
56
- * lowercased email so the code goes to the canonical identifier.
57
- */
58
- private applyInitialIdentity;
59
- /**
60
- * True when the identifier is fixed by the flow and the person must prove
61
- * that exact identity: the invite / simple-redirect case. There is no
62
- * identifier-entry step to return to, so the picker must not offer a
63
- * "change identity" back link that would let them verify a different
64
- * identifier than the one they were invited as.
65
- */
66
- private isIdentityFixed;
67
- /**
68
- * Fire the host's onSuccess callback, swallowing any exception so a
69
- * misbehaving host handler can't block the post-success redirect the
70
- * caller is depending on. The verify flow continues regardless.
71
- */
72
- private safeOnSuccess;
73
- private get recipient();
74
- private get identityType();
75
- private get sdkConfig();
76
- /**
77
- * Start the identity verification flow.
78
- * If config was preloaded, opens modal and proceeds immediately.
79
- * Otherwise shows loading state while fetching config.
80
- */
81
- start(): Promise<void>;
82
- /**
83
- * Surface a terminal startup failure *inside* the dialog instead of letting
84
- * it reject to the host.
85
- *
86
- * `start()` already routes config-fetch failures to an in-dialog view via its
87
- * own catch, but an unexpected throw (or a throw while rendering that view)
88
- * would otherwise escape. In the default embedded/dialog mode that escape is
89
- * exactly the "closes silently" failure: the host's `onError` runs, the
90
- * embedding page tears the iframe down, and the user is left with no message.
91
- * Render the error in the SparkVault dialog, consistent with how every
92
- * in-flow error already behaves, so the dialog stays open and the user can
93
- * retry or close it (→ onCancel).
94
- */
95
- showStartupError(error: unknown): void;
96
- /**
97
- * Map a config-fetch error to the appropriate terminal view.
98
- *
99
- * Two failures are permanent developer-misconfigurations, not transient
100
- * outages, so they get dedicated terminal screens (no "Try Again", since retrying
101
- * can never clear them) instead of the generic service-unavailable view:
102
- * - `product_not_configured`: the account has not configured Identity.
103
- * - `ORIGIN_NOT_ALLOWED`: this site's domain is not on the account's
104
- * allowlist. Surfacing it as "Temporarily Unavailable / try again" sends
105
- * the developer chasing a non-existent outage.
106
- * Everything else (network errors, 5xx) is genuinely transient.
107
- */
108
- private viewStateForConfigError;
109
- /**
110
- * Fetch config with a single retry on network errors.
111
- * Handles transient failures common during subdomain switches
112
- * (DNS resolution, connection setup, Safari ITP).
113
- */
114
- private fetchConfigWithRetry;
115
- /**
116
- * Retry loading config after a service-unavailable error.
117
- * Shows loading state, re-fetches config, then proceeds normally.
118
- */
119
- private retryConfigLoad;
120
- /**
121
- * Close the modal and clean up.
122
- * Cancels all pending API requests to prevent orphaned operations.
123
- */
124
- close(): void;
125
- private handleClose;
126
- private get viewState();
127
- private setState;
128
- private showInitialAuthStep;
129
- /**
130
- * The account's own identity provider as the flow's first step. A failed
131
- * round trip is said first. Otherwise the provider may start on its own
132
- * (startFederationAutomatically). Returns true when it took the step.
133
- */
134
- private startWithFederation;
135
- /**
136
- * Leave for the account's own identity provider without the person's
137
- * click, while this page offers it and it starts on its own
138
- * (federationStartsOnItsOwn). Returns true when it left.
139
- */
140
- private startFederationAutomatically;
141
- /**
142
- * Whether the given account's own identity provider starts without the
143
- * person's click while this page may still leave on its own: when the
144
- * account asks for a silent attempt (`federation.silent`: the provider
145
- * answers without showing anything, and a refusal comes back as
146
- * `interaction_required`) or the caller asked for it (`method:
147
- * 'federation'`, interactive unless the account asks for the silent
148
- * attempt).
149
- */
150
- private federationStartsOnItsOwn;
151
- /**
152
- * The account's own identity provider while a step for this identifier
153
- * lacks it only because the page's ask for the sign-in's reference is still
154
- * out: with the reference held, the provider would be on that step, so the
155
- * step holds every automatic advance a held reference would not have made.
156
- * Once the reference lands the provider joins the step, or starts on its
157
- * own from the untouched first step (offerArrivedReference); an ask that
158
- * finds none leaves the held step up for the person's tap.
159
- */
160
- private federationAwaitingReference;
161
- /**
162
- * Ask the page for the sign-in's reference (VerifyOptions.signinRef as a
163
- * function) without waiting on the answer: the flow goes on, and the
164
- * answer joins it when it lands. A call that throws or rejects, and an
165
- * answer that is no reference, found none.
166
- */
167
- private requestReference;
168
- /** The reference arrived: every completing call from now on carries it, and the step offers the provider. */
169
- private referenceArrived;
170
- /**
171
- * The ask found no reference for now. An account with other ways in
172
- * simply keeps them; a person waiting on the provider as the only way in
173
- * is told to try again.
174
- */
175
- private referenceUnavailable;
176
- /** The person's Try Again: ask again, and show the sign-in step meanwhile. */
177
- private retryReference;
178
- /**
179
- * Offer the account's own identity provider on the step that offers it,
180
- * now that the page holds its reference. On the sign-in step as it first
181
- * showed, still untouched, the provider starts on its own as it would have
182
- * with the reference held from the start; otherwise its button joins the
183
- * step in place, keeping what the person typed and their focus. A person
184
- * who has moved past that step sees nothing change, and the step offers
185
- * the provider whenever it shows again.
186
- */
187
- private offerArrivedReference;
188
- /**
189
- * The sign-in's own first step: the method list when no identifier is
190
- * asked for (or one is already known), the discoverable passkey ceremony for
191
- * a returning browser, else the identifier field (which leads with the
192
- * account's own identity provider when it offers one).
193
- */
194
- private showSignInStep;
195
- /**
196
- * True when the discoverable ceremony may be started without a gesture and
197
- * this verification actually offers passkey login: the flow runs on the
198
- * Identity origin, the browser carries the passkey hint, and `passkey` is
199
- * among the verification's methods.
200
- */
201
- private canDiscoverableVerify;
202
- /**
203
- * Run the no-identifier discoverable ceremony behind the passkey-auto view.
204
- * Fired on open for returning browsers and from the identifier form's
205
- * "Sign in with a passkey" shortcut. Anything short of a terminal outcome
206
- * (dismissed sheet, no credential on the device, transient failure) falls
207
- * back to the identifier form with no error banner: the person simply
208
- * lands where a first-time visitor starts.
209
- */
210
- private launchDiscoverableVerify;
211
- /**
212
- * Abort the pending discoverable ceremony (dismisses the browser sheet where
213
- * the platform allows) and land on the identifier form.
214
- */
215
- private cancelDiscoverableVerify;
216
- private render;
217
- /** Place the empty live region beside the flow content, once per container. */
218
- private placeStatusRegion;
219
- private destroyCurrentView;
220
- /**
221
- * Replace the mounted view with a Google-style height morph: the flow region
222
- * animates its height from the outgoing content to the incoming content while
223
- * the new step fades + rises in (`.sv-step-enter`), so the popup reads as one
224
- * object reshaping rather than separate screens swapping. Falls back to an
225
- * instant swap when layout metrics are unavailable (jsdom, where heights read
226
- * 0) or the person prefers reduced motion.
227
- */
228
- private morphSwap;
229
- private createViewForState;
230
- private showIdentityInput;
231
- /**
232
- * Render the picker. With `autoRoute` left default, a recipient that
233
- * already has a passkey is sent straight to the WebAuthn view; pass
234
- * `false` from the passkey view's back arrow so the user lands on the
235
- * actual list of alternatives instead of bouncing back to passkey.
236
- */
237
- private showMethodSelect;
238
- /**
239
- * The state for a verification that leaves this person no method. A request
240
- * its sender held to a passkey admits the passkey alone, so a person the
241
- * check found holding none is told the request needs a passkey already
242
- * registered with SparkVault and that only the sender can resend it at a
243
- * level they can clear: no retry here changes that. An account whose
244
- * remaining way in is its own identity provider, which this page does not
245
- * offer now (see `federationOffered`), depends on why:
246
- * - the page can never hold a reference (an SDK that predates it opened
247
- * the page): the site must update its sign-in, and no retry here changes
248
- * that;
249
- * - the page's ask for its reference is still out: the step waits for it;
250
- * - the ask found none for now: the person is told to try again, which
251
- * asks again.
252
- * A sign-in whose restriction on the identity types it may produce took
253
- * away a way in it would otherwise offer is told which types it accepts and
254
- * that none of the ways here gives one: only the site that asked for the
255
- * restriction can change that. Any other verification with nothing to
256
- * offer is a configuration fault, shown as one.
257
- */
258
- private noMethodState;
259
- /**
260
- * The methods the sign-in's restriction admits (app-sdk
261
- * signinMethodAdmitted): every method for a sign-in with none, else those
262
- * that can produce a type it names.
263
- */
264
- private admittedMethods;
265
- /**
266
- * After Identity refused a sign-in of a type the restriction does not name:
267
- * the ways in for this identifier, with nothing starting on its own, or the
268
- * identifier field when the person has typed none.
269
- */
270
- private chooseAnotherWay;
271
- /**
272
- * Identity refused the sign-in for a type its restriction does not name
273
- * (SIGNIN_IDENTITY_TYPES.refusalCode): show Identity's own words, which say
274
- * what this sign-in accepts, and return true. False for any other code.
275
- */
276
- private renderIdentityTypeRefusal;
277
- private handleIdentitySubmit;
278
- /**
279
- * The identifier types the identifier field takes: the verification's,
280
- * less any its restriction does not name, whose codes and links could only
281
- * produce a sign-in it refuses.
282
- */
283
- private getAllowedIdentityTypes;
284
- /**
285
- * @param userInitiated True when called from a live click on the picker, so
286
- * a popup may be opened synchronously within that gesture. False when
287
- * auto-selected after an async step (e.g. the single enabled method), where
288
- * opening a popup would be blocked.
289
- */
290
- private handleMethodSelect;
291
- /**
292
- * If the error code means the site owner's Identity access is blocked
293
- * (trial exhausted/expired, or paid capacity wall), render the dedicated
294
- * end-user interstitial and return true. The message is intentionally
295
- * generic so no billing internals leak to the end user. Returns false for
296
- * any other code so the caller falls through to its normal handling.
297
- */
298
- private renderBlockedInterstitial;
299
- private handleOtpSubmit;
300
- private handleSecondFactorSubmit;
301
- private handleOtpResend;
302
- private handlePasskeyStart;
303
- /**
304
- * Open the verify popup straight from a live picker gesture, showing a
305
- * loading state while the ceremony runs. window.open inside verify() fires
306
- * synchronously (before the first await), so it stays within the gesture.
307
- */
308
- private launchPasskeyVerify;
309
- /**
310
- * Handle the terminal passkey outcomes every entry point shares: a verified
311
- * login (close + onSuccess + redirect), a blocked-Identity interstitial, or
312
- * a locked identity. Returns false for the retryable failures each caller
313
- * routes according to its own flow.
314
- */
315
- private applyTerminalPasskeyResult;
316
- /**
317
- * Apply a passkey ceremony result: complete on success, or route to the
318
- * matching recovery state. Shared by the passkey view and the direct
319
- * picker launch so both behave identically.
320
- */
321
- private applyPasskeyResult;
322
- /**
323
- * Handle fallback from passkey to an identifier-based code.
324
- * User clicked "Having trouble? Use a code instead".
325
- */
326
- private handlePasskeyFallback;
327
- private passkeyFallbackMethodsAvailable;
328
- /**
329
- * Handle skipping passkey registration when coming from passkey prompt.
330
- * User clicked "Back" or cancelled registration after being prompted.
331
- */
332
- private handlePasskeyRegistrationSkip;
333
- /**
334
- * Leave for the social provider. The renderer runs on the Identity origin's
335
- * sign-in page, and the round trip returns to that same page, query intact,
336
- * because the query carries the destination the page was opened for (the
337
- * popup's `origin`, or the redirect mode's handoff parameters), which the
338
- * page re-gates before releasing the result. The state stored here is what
339
- * the returning page's `#token` must answer; it is drawn from the Entropy
340
- * service through the Identity origin, the page's own.
341
- */
342
- private handleSocialLogin;
343
- /**
344
- * The account's own identity provider, while this verification offers it:
345
- * this page offers it now (federationOffered), `/config` describes it, and
346
- * the verification's methods list it. A verify session's methods never do,
347
- * for such a sign-in cannot complete one.
348
- */
349
- private get federation();
350
- /**
351
- * Whether this page offers the account's own identity provider now (see
352
- * VerifyOptions.signinRef): while it holds its sign-in's reference, or
353
- * when it completes in its own window.
354
- */
355
- private get federationOffered();
356
- /**
357
- * The account's own identity provider while `/config` describes it, the
358
- * verification's methods list it, and the sign-in's restriction admits it.
359
- */
360
- private get accountFederation();
361
- /**
362
- * Whether a list of methods offers the account's own identity provider
363
- * beside the identifier it is for. It needs no identifier, so the first
364
- * step offers it (above the identifier field, or in a list with none), and
365
- * so does a list for an identifier the flow supplied, whose person never saw
366
- * that step. An identifier the person typed came from the identifier
367
- * field, which already offered it.
368
- */
369
- private offersFederationBeside;
370
- /** The identifier field's leading method: the account's own identity provider, when offered. */
371
- private leadingFederationMethod;
372
- /**
373
- * Leave for the account's own identity provider, the way a social sign-in
374
- * leaves (handleSocialLogin): the round trip returns to this page, query
375
- * intact, the state stored here is what its `#token` (or its refusal's
376
- * fragment) must answer, and the start carries the sign-in's reference
377
- * when the page holds one. A silent attempt shows a status the whole time
378
- * it runs. A start without the person's click (`automatic`) is recorded, so
379
- * a person who comes Back from the provider's page is not sent on again.
380
- */
381
- private leaveForFederation;
382
- /**
383
- * A browser that restores this page from its back/forward cache, as the
384
- * person comes Back from the provider, runs nothing again, so the page would
385
- * keep the wait it left on. Show the sign-in's first step instead, with the
386
- * automatic start spent.
387
- */
388
- private watchForPageRestore;
389
- /** The failure of a sign-in through the account's own identity provider, in fixed words, never the provider's. */
390
- private federationFailedState;
391
- private normalizeError;
392
- /**
393
- * Check if error is a session/token expiration that should redirect to identity input.
394
- */
395
- private isSessionExpiredError;
396
- /**
397
- * Handle errors - redirect to identity input for session errors, show error view otherwise.
398
- */
399
- private handleErrorWithRecovery;
400
- /**
401
- * Run the post-login step pipeline for a completed primary login.
402
- *
403
- * The server returns an ordered `recommendations` list (passkey upsell,
404
- * backup verification, …); this walks it, rendering the step views the SDK
405
- * supports and finalizing when the queue drains. A redirect target skips the
406
- * pipeline. A future nudge is one new recommendation type + view case, no
407
- * primary-login handler changes.
408
- */
409
- private runPostLogin;
410
- /**
411
- * Show the next supported recommendation, or finalize when the queue is
412
- * empty. The single hand-off from each step back into the pipeline.
413
- */
414
- private advancePostLogin;
415
- /**
416
- * Best-effort: tell the server the person skipped a recommendation so it is
417
- * suppressed for 30 days. Never blocks completing the login.
418
- */
419
- private dismissRecommendation;
420
- /**
421
- * Complete the login: hand the result to the host before tearing down the
422
- * modal (so its onSuccess can act while the browsing context is alive), then
423
- * navigate any redirect the flow returned.
424
- */
425
- private finalizeLogin;
426
- /**
427
- * Send a code to the new backup identifier the person entered. Already-attached
428
- * identifiers short-circuit straight to completion; otherwise advance to code
429
- * entry.
430
- */
431
- private handleBackupSubmit;
432
- /**
433
- * Verify the backup code and attach the identifier, then finish the original
434
- * login. An identifier owned by another account (409 backup_conflict) bounces
435
- * back to the input so the person can try a different one.
436
- */
437
- private handleBackupCodeSubmit;
438
- /**
439
- * Resend the backup code, refreshing the pending-attach session.
440
- */
441
- private handleBackupResend;
442
- /**
443
- * "Not now" on the backup prompt: suppress this identifier type for 30 days
444
- * (server-side) and advance to the next step.
445
- */
446
- private handleBackupSkip;
447
- /**
448
- * Handle user clicking "Add Passkey" in the prompt.
449
- * Directly triggers browser passkey creation without intermediate screen.
450
- */
451
- private handlePasskeyPromptAdd;
452
- /**
453
- * Handle user clicking "Not now" / "Skip" in the passkey prompt: suppress it
454
- * for 30 days (server-side) and advance to the next step.
455
- */
456
- private handlePasskeyPromptSkip;
457
- /**
458
- * Open a WebSocket connection and return the connectionId.
459
- * The server echoes back the connectionId on init; this is used to route
460
- * the SparkLink verification result back to this SDK instance.
461
- *
462
- * Returns:
463
- * - { connectionId: string } on success
464
- * - { error: 'csp' } if blocked by Content Security Policy
465
- * - { error: 'connection' } for other connection failures
466
- */
467
- private openSparkLinkWebSocket;
468
- /**
469
- * Set up WebSocket message handler for SparkLink verification results.
470
- * Handles: sparklink_verified, sparklink_second_factor, sparklink_failed,
471
- * sparklink_resent.
472
- */
473
- private setupSparkLinkWsHandler;
474
- /**
475
- * Act on what the SparkLink click produced, from either channel (WebSocket
476
- * push or kindling reclaim).
477
- *
478
- * A completed login runs the post-login pipeline, which hands the host the
479
- * full result (including any redirect URL) before attempting top-level
480
- * navigation: the host page is the source of truth for what happens next;
481
- * the SDK's window.location.href call is a fallback for hosts that delegate
482
- * navigation entirely to the SDK. A login held at the second-factor gate
483
- * opens the two-factor view, exactly as after an emailed code.
484
- */
485
- private applySparkLinkOutcome;
486
- /**
487
- * The push delivered the click's result, but the click also persisted a
488
- * fallback copy for the kindling reclaim. Burn it so neither a completed
489
- * login nor a pending challenge stays claimable. Best-effort,
490
- * fire-and-forget; must run before cleanup clears the kindling.
491
- */
492
- private burnSparkLinkFallback;
493
- /** End the SparkLink wait on a failed or unusable result. */
494
- private failSparkLink;
495
- /**
496
- * Arm the WebSocket-loss fallback for the waiting screen.
497
- *
498
- * While waiting for the emailed link, the socket can be dropped when the tab
499
- * is suspended (mobile: the user leaves to the mail app). On refocus, if the
500
- * socket is no longer open, reclaim the click's result once by kindling. A
501
- * single ~2s retry covers returning before the server finished writing it.
502
- * Deliberately NOT a polling loop: it fires only on refocus, and only when
503
- * the socket is actually gone.
504
- */
505
- private armSparkLinkRefocusClaim;
506
- /**
507
- * Reclaim the click's result by kindling. Single attempt; if still pending
508
- * and allowRetry, schedule exactly one ~2s retry, then stop (the next refocus
509
- * or Resend can try again).
510
- */
511
- private claimSparkLinkResult;
512
- /**
513
- * Clean up SparkLink WebSocket connection.
514
- */
515
- private cleanupSparkLink;
516
- /**
517
- * Handle resending SparkLink.
518
- */
519
- private handleSparkLinkResend;
520
- /**
521
- * Handle fallback from SparkLink to OTP verification code.
522
- */
523
- private handleSparkLinkFallback;
524
- }
525
- export {};
@@ -1,84 +0,0 @@
1
- /**
2
- * Verification State Manager
3
- *
4
- * Single source of truth for all verification flow state:
5
- * - Predictable state transitions
6
- * - Easier debugging and testing
7
- * - Clear data ownership
8
- */
9
- import type { SdkConfig, VerifyResult, IdentityViewState, AuthContext, MethodId, SigninIdentityType } from './types';
10
- import type { IdentityType } from './views';
11
- /**
12
- * Passkey-specific state
13
- */
14
- interface PasskeyState {
15
- /** Whether user has registered passkeys (null = unknown) */
16
- hasPasskey: boolean | null;
17
- /** Whether user fell back from passkey to another method */
18
- isFallbackMode: boolean;
19
- /** Pending result when prompting for passkey registration after OTP */
20
- pendingResult: VerifyResult | null;
21
- }
22
- /**
23
- * OTP-specific state
24
- */
25
- interface OtpState {
26
- /** Current kindling token for OTP verification */
27
- kindling: string;
28
- /** Current OTP method (email, sms, or voice) */
29
- method: 'email' | 'sms' | 'voice' | null;
30
- }
31
- /**
32
- * Centralized verification state
33
- */
34
- export declare class VerificationState {
35
- private _sdkConfig;
36
- private _viewState;
37
- private _recipient;
38
- private _identityType;
39
- private _authContext;
40
- private _signinRef;
41
- private _identityTypes;
42
- private readonly _passkey;
43
- private readonly _otp;
44
- get sdkConfig(): SdkConfig | null;
45
- setConfig(config: SdkConfig): void;
46
- get accountId(): string;
47
- get viewState(): IdentityViewState;
48
- setViewState(state: IdentityViewState): void;
49
- get recipient(): string;
50
- get identityType(): IdentityType;
51
- setIdentity(recipient: string, type: IdentityType): void;
52
- /**
53
- * The methods this verification may use: what its verify session admits,
54
- * as the hosted page names it, else the account's sign-in methods.
55
- */
56
- get methodIds(): MethodId[];
57
- /**
58
- * Whether this verification proves a request its sender held to a passkey,
59
- * as its verify session's hosted page names it: the session admits the
60
- * passkey alone.
61
- */
62
- get passkeyRequired(): boolean;
63
- /**
64
- * The identifier types this verification's methods deliver to: its verify
65
- * session's, else the account's.
66
- */
67
- getAllowedIdentityTypes(): IdentityType[];
68
- get authContext(): AuthContext | undefined;
69
- setAuthContext(context: AuthContext | undefined): void;
70
- /** The reference every call that completes this sign-in carries, else null. */
71
- get signinRef(): string | null;
72
- setSigninRef(signinRef: string | null): void;
73
- /** The restriction every call that starts a ceremony carries, else null. */
74
- get identityTypes(): SigninIdentityType[] | null;
75
- setIdentityTypes(identityTypes: SigninIdentityType[] | null): void;
76
- get passkey(): Readonly<PasskeyState>;
77
- setPasskeyStatus(hasPasskey: boolean | null): void;
78
- enablePasskeyFallback(): void;
79
- setPendingResult(result: VerifyResult | null): void;
80
- get otp(): Readonly<OtpState>;
81
- setKindling(kindling: string): void;
82
- setOtpMethod(method: 'email' | 'sms' | 'voice'): void;
83
- }
84
- export {};
@@ -1,31 +0,0 @@
1
- /**
2
- * Identity Modal Styles
3
- *
4
- * SparkVault design system, product register:
5
- * - Quiet slate neutrals; Action Blue carries all interactivity
6
- * - 4px base spacing unit for consistency
7
- * - Hairline borders over shadows; shadows minimal and DS-weighted
8
- * - Restrained motion: 120-280ms, standard/decelerate curves only
9
- * - One accent per surface; tenant-tintable via --sv-primary
10
- */
11
- import type { SdkConfigBranding } from './types';
12
- export interface StyleOptions {
13
- branding: SdkConfigBranding;
14
- backdropBlur?: boolean;
15
- }
16
- /**
17
- * Inject modal styles into the document head.
18
- */
19
- export declare function injectStyles(options: StyleOptions): void;
20
- /**
21
- * Re-theme the injected stylesheet when the resolved theme (light/dark) changes.
22
- *
23
- * Styles are first injected with default branding before config loads (so the
24
- * UI paints instantly), then `updateBranding` calls this with the tenant's real
25
- * `themeMode`. The theme is baked into the generated CSS (not runtime CSS
26
- * variables), so a theme switch requires regenerating the stylesheet - a no-op
27
- * when the theme is unchanged.
28
- */
29
- export declare function applyBrandingTheme(branding: SdkConfigBranding | undefined | null): void;
30
- export declare function removeStyles(): void;
31
- export declare function resolveTheme(branding: SdkConfigBranding | undefined | null): 'light' | 'dark';