@sparkvault/sdk-js 19.0.1 → 19.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -4
- package/dist/npm/chunks/index-BnP-2w0t.cjs +13025 -0
- package/dist/npm/chunks/index-BnP-2w0t.cjs.map +1 -0
- package/dist/npm/chunks/index-CgR08uMG.mjs +12960 -0
- package/dist/npm/chunks/index-CgR08uMG.mjs.map +1 -0
- package/dist/npm/identity.cjs +23 -0
- package/dist/npm/identity.cjs.map +1 -0
- package/dist/npm/identity.mjs +12 -0
- package/dist/npm/identity.mjs.map +1 -0
- package/dist/{index.cjs → npm/index.cjs} +799 -13755
- package/dist/npm/index.cjs.map +1 -0
- package/dist/{index.mjs → npm/index.mjs} +200 -13155
- package/dist/npm/index.mjs.map +1 -0
- package/dist/sparkvault-identity.js +2 -0
- package/dist/sparkvault-identity.js.map +1 -0
- package/dist/sparkvault.js +1 -1
- package/dist/types/identity.d.ts +8 -0
- package/dist/{index.d.ts → types/index.d.ts} +4 -790
- package/dist/types/shared/errors-C-gjmGBs.d.ts +800 -0
- package/package.json +20 -9
- package/dist/api-base.d.ts +0 -116
- package/dist/auto-init.d.ts +0 -32
- package/dist/config.d.ts +0 -79
- package/dist/entropy/index.d.ts +0 -35
- package/dist/entropy/types.d.ts +0 -32
- package/dist/errors.d.ts +0 -146
- package/dist/folders/index.d.ts +0 -102
- package/dist/folders/types.d.ts +0 -91
- package/dist/health.d.ts +0 -18
- package/dist/http.d.ts +0 -46
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/ingots/fetch-download.d.ts +0 -78
- package/dist/ingots/history.d.ts +0 -4
- package/dist/ingots/index.d.ts +0 -388
- package/dist/ingots/revision.d.ts +0 -4
- package/dist/ingots/types.d.ts +0 -556
- package/dist/logger.d.ts +0 -32
- package/dist/notify/index.d.ts +0 -154
- package/dist/notify/types.d.ts +0 -232
- package/dist/products/help-desk/client.d.ts +0 -198
- package/dist/products/help-desk/desk-id.d.ts +0 -2
- package/dist/products/help-desk/form-draft.d.ts +0 -37
- package/dist/products/help-desk/form-types.d.ts +0 -123
- package/dist/products/help-desk/form.d.ts +0 -83
- package/dist/products/help-desk/index.d.ts +0 -47
- package/dist/products/help-desk/kb-client.d.ts +0 -48
- package/dist/products/help-desk/kb-types.d.ts +0 -59
- package/dist/products/help-desk/modal.d.ts +0 -8
- package/dist/products/help-desk/styles.d.ts +0 -9
- package/dist/products/help-desk/support-analytics-types.d.ts +0 -32
- package/dist/products/help-desk/support-analytics.d.ts +0 -3
- package/dist/products/help-desk/support-brand.d.ts +0 -49
- package/dist/products/help-desk/support-controller.d.ts +0 -4
- package/dist/products/help-desk/support-history.d.ts +0 -38
- package/dist/products/help-desk/support-launcher.d.ts +0 -12
- package/dist/products/help-desk/support-styles.d.ts +0 -14
- package/dist/products/help-desk/support-types.d.ts +0 -66
- package/dist/products/help-desk/support-view.d.ts +0 -173
- package/dist/products/help-desk/types.d.ts +0 -285
- package/dist/products/help-desk/widget-identity.d.ts +0 -32
- package/dist/products/identity/api.d.ts +0 -237
- package/dist/products/identity/container.d.ts +0 -44
- package/dist/products/identity/dialog-launcher.d.ts +0 -133
- package/dist/products/identity/federation-flow.d.ts +0 -31
- package/dist/products/identity/handlers/otp-handler.d.ts +0 -69
- package/dist/products/identity/handlers/passkey-handler.d.ts +0 -105
- package/dist/products/identity/handlers/sparklink-handler.d.ts +0 -34
- package/dist/products/identity/index.d.ts +0 -296
- package/dist/products/identity/inline-container.d.ts +0 -53
- package/dist/products/identity/methods.d.ts +0 -19
- package/dist/products/identity/modal.d.ts +0 -51
- package/dist/products/identity/pending-signin.d.ts +0 -102
- package/dist/products/identity/popup-launcher.d.ts +0 -73
- package/dist/products/identity/renderer.d.ts +0 -525
- package/dist/products/identity/state.d.ts +0 -84
- package/dist/products/identity/styles.d.ts +0 -31
- package/dist/products/identity/types.d.ts +0 -561
- package/dist/products/identity/utils/cooldown-timer.d.ts +0 -73
- package/dist/products/identity/utils.d.ts +0 -85
- package/dist/products/identity/views/backup-verify.d.ts +0 -42
- package/dist/products/identity/views/base.d.ts +0 -51
- package/dist/products/identity/views/error.d.ts +0 -65
- package/dist/products/identity/views/icons.d.ts +0 -41
- package/dist/products/identity/views/identity-input.d.ts +0 -80
- package/dist/products/identity/views/index.d.ts +0 -20
- package/dist/products/identity/views/loading.d.ts +0 -23
- package/dist/products/identity/views/method-button.d.ts +0 -14
- package/dist/products/identity/views/method-select.d.ts +0 -42
- package/dist/products/identity/views/origin-not-allowed.d.ts +0 -25
- package/dist/products/identity/views/otp-verify.d.ts +0 -58
- package/dist/products/identity/views/passkey-auto.d.ts +0 -22
- package/dist/products/identity/views/passkey-prompt.d.ts +0 -25
- package/dist/products/identity/views/passkey.d.ts +0 -38
- package/dist/products/identity/views/product-not-configured.d.ts +0 -21
- package/dist/products/identity/views/service-unavailable.d.ts +0 -21
- package/dist/products/identity/views/sms-consent.d.ts +0 -16
- package/dist/products/identity/views/sparklink-waiting.d.ts +0 -40
- package/dist/products/identity/views/two-factor.d.ts +0 -37
- package/dist/products/index.d.ts +0 -51
- package/dist/products/messaging/index.d.ts +0 -38
- package/dist/products/messaging/types.d.ts +0 -162
- package/dist/products/notify/index.d.ts +0 -436
- package/dist/products/notify/project-types.d.ts +0 -44
- package/dist/products/notify/projects.d.ts +0 -15
- package/dist/products/notify/types.d.ts +0 -1327
- package/dist/products/structured-ingots/index.d.ts +0 -31
- package/dist/products/structured-ingots/types-client.d.ts +0 -19
- package/dist/products/structured-ingots/types.d.ts +0 -293
- package/dist/products/structured-ingots/validation.d.ts +0 -25
- package/dist/request-path.d.ts +0 -44
- package/dist/sparks/index.d.ts +0 -91
- package/dist/sparks/types.d.ts +0 -304
- package/dist/ui/chrome.d.ts +0 -16
- package/dist/ui/ds-tokens.d.ts +0 -59
- package/dist/ui/inline-shell.d.ts +0 -19
- package/dist/ui/live-region.d.ts +0 -15
- package/dist/ui/modal-shell.d.ts +0 -67
- package/dist/ui/target.d.ts +0 -6
- package/dist/utils/dom.d.ts +0 -26
- package/dist/vault-session.d.ts +0 -2
- package/dist/vaults/index.d.ts +0 -254
- package/dist/vaults/types.d.ts +0 -368
- package/dist/vaults/upload/api.d.ts +0 -310
- package/dist/vaults/upload/chrome.d.ts +0 -21
- package/dist/vaults/upload/container.d.ts +0 -37
- package/dist/vaults/upload/index.d.ts +0 -76
- package/dist/vaults/upload/inline-container.d.ts +0 -41
- package/dist/vaults/upload/modal.d.ts +0 -55
- package/dist/vaults/upload/renderer.d.ts +0 -150
- package/dist/vaults/upload/styles.d.ts +0 -14
- package/dist/vaults/upload/types.d.ts +0 -220
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Identity Module
|
|
3
|
-
*
|
|
4
|
-
* Passwordless sign-in through the first-party SparkVault popup.
|
|
5
|
-
* Supports passkey, OTP, SparkLink, social authentication, and the account's
|
|
6
|
-
* own identity provider.
|
|
7
|
-
*
|
|
8
|
-
* @example Programmatic
|
|
9
|
-
* const result = await sv.products.identity.signIn();
|
|
10
|
-
*
|
|
11
|
-
* @example Attached to clicks
|
|
12
|
-
* sv.products.identity.attach('.login-btn');
|
|
13
|
-
*/
|
|
14
|
-
import type { ResolvedConfig } from '../../config';
|
|
15
|
-
import type { VerifyResult, SignInOptions, SignInResult, SigninIdentityType, TokenClaims, AttachOptions, PortalUrlOptions, RedirectResultOptions, RenderOptions } from './types';
|
|
16
|
-
/**
|
|
17
|
-
* Whether `handleRedirectResult()` has anything to do on this load: a returned
|
|
18
|
-
* sign-in fragment to consume, or a pending sign-in to self-heal. Public + side
|
|
19
|
-
* effect-free (peeks, never consumes) so a host that defers SDK init for
|
|
20
|
-
* performance can cheaply decide whether to boot the SDK on a given page load,
|
|
21
|
-
* WITHOUT reaching into the SDK's internal storage keys. Exposed as
|
|
22
|
-
* `SparkVault.isRecoveryPending()`.
|
|
23
|
-
*/
|
|
24
|
-
export declare function isSignInRecoveryPending(): boolean;
|
|
25
|
-
export declare class IdentityModule {
|
|
26
|
-
private readonly config;
|
|
27
|
-
private readonly api;
|
|
28
|
-
private renderer;
|
|
29
|
-
private launcher;
|
|
30
|
-
private pendingSignIn;
|
|
31
|
-
constructor(config: ResolvedConfig);
|
|
32
|
-
/**
|
|
33
|
-
* Build a deep link into the person's auth.sv Identity portal, where they
|
|
34
|
-
* manage their verified identity, passkeys, sessions, and connected sites
|
|
35
|
-
* across every SparkVault-integrated site. Send a signed-in user here to
|
|
36
|
-
* self-serve;
|
|
37
|
-
* the portal authenticates them with their own SparkVault Identity.
|
|
38
|
-
*
|
|
39
|
-
* @example Manage this site (block/notifications/etc.)
|
|
40
|
-
* window.location.href = sv.products.identity.portalUrl({ section: 'sites' });
|
|
41
|
-
*
|
|
42
|
-
* @example Open the security screen
|
|
43
|
-
* sv.products.identity.portalUrl({ section: 'security' });
|
|
44
|
-
*
|
|
45
|
-
* @returns An absolute URL on the configured `portalBaseUrl` (default https://auth.sv).
|
|
46
|
-
*/
|
|
47
|
-
portalUrl(options?: PortalUrlOptions): string;
|
|
48
|
-
/**
|
|
49
|
-
* One-click sign-in through the browser's native FedCM account chooser.
|
|
50
|
-
*
|
|
51
|
-
* When the person is already signed into SparkVault Identity (carrying the
|
|
52
|
-
* SSO hub session on the Identity origin),
|
|
53
|
-
* the browser surfaces a "Continue as …" prompt with no popup, redirect, or
|
|
54
|
-
* typing. Requires a registered `clientId` in the SDK config and a browser
|
|
55
|
-
* with FedCM support: callers should feature-detect with
|
|
56
|
-
* `IdentityModule.isFedcmAvailable()` and fall back to `signIn()` otherwise.
|
|
57
|
-
*
|
|
58
|
-
* @returns the verified result, or `null` when the browser has no FedCM
|
|
59
|
-
* support (so the caller can fall back). Throws `UserCancelledError` when
|
|
60
|
-
* the browser ends the request without a credential: the person dismissed
|
|
61
|
-
* the chooser, or the browser had no SparkVault account to offer (the
|
|
62
|
-
* browser reports both alike). Throws `IdentityProviderError`, carrying
|
|
63
|
-
* SparkVault's own error code, when SparkVault answered the sign-in with an
|
|
64
|
-
* error (`IDENTITY_TYPE_NOT_ALLOWED` for an account of a type
|
|
65
|
-
* `identityTypes` does not name).
|
|
66
|
-
*
|
|
67
|
-
* `identityTypes` restricts the sign-in as `SignInOptions.identityTypes`
|
|
68
|
-
* does; a bad value is a ValidationError before anything is asked.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* const result = IdentityModule.isFedcmAvailable()
|
|
72
|
-
* ? await sv.products.identity.signInWithFedcm().catch(() => sv.products.identity.signIn())
|
|
73
|
-
* : await sv.products.identity.signIn();
|
|
74
|
-
*/
|
|
75
|
-
signInWithFedcm(options?: {
|
|
76
|
-
mediation?: 'optional' | 'required' | 'silent';
|
|
77
|
-
nonce?: string;
|
|
78
|
-
identityTypes?: SigninIdentityType[];
|
|
79
|
-
}): Promise<VerifyResult | null>;
|
|
80
|
-
/** Whether this browser exposes the FedCM API (`navigator.credentials` + IdentityCredential). */
|
|
81
|
-
static isFedcmAvailable(): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Sign in through the first-party SparkVault sign-in popup.
|
|
84
|
-
*
|
|
85
|
-
* This is the single programmatic entry point; `attach()` binds it to element
|
|
86
|
-
* clicks. The popup runs the flow top-level on the Identity origin (so
|
|
87
|
-
* login's `__Host-` hub cookie is a first-party write and cross-domain SSO
|
|
88
|
-
* works) and posts the result back; the promise resolves with it.
|
|
89
|
-
*
|
|
90
|
-
* Resilience: pair this with `handleRedirectResult()` on page load. If the
|
|
91
|
-
* popup's result is ever lost (a mobile browser discards the backgrounded
|
|
92
|
-
* opener tab), the next load silently self-heals from the SSO session the
|
|
93
|
-
* popup signed in or chose; a sign-in that opened none (the account's own
|
|
94
|
-
* identity provider) comes back signed out, to sign in again. `flow:
|
|
95
|
-
* 'redirect'` opts a caller out of the popup into a same-tab navigation
|
|
96
|
-
* instead.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* const result = await sv.products.identity.signIn();
|
|
100
|
-
* // Your backend verifies the token before it grants access; never log it.
|
|
101
|
-
* await fetch('/api/auth/login', {
|
|
102
|
-
* method: 'POST',
|
|
103
|
-
* headers: { 'Content-Type': 'application/json' },
|
|
104
|
-
* body: JSON.stringify({ token: result.token }),
|
|
105
|
-
* });
|
|
106
|
-
*/
|
|
107
|
-
signIn(options?: SignInOptions): Promise<SignInResult>;
|
|
108
|
-
/**
|
|
109
|
-
* Core flow runner. Default mode (no `target`) opens the popup; `flow:
|
|
110
|
-
* 'redirect'` navigates the tab instead; local mode (`renderMode: 'local'` /
|
|
111
|
-
* `target`) renders into the current document and powers the
|
|
112
|
-
* SparkVault-hosted sign-in surfaces (see the internal `render`), which
|
|
113
|
-
* hands it its restriction as its page's URL spelled it (`identityTypes`)
|
|
114
|
-
* and what a round trip to the account's own identity provider returned
|
|
115
|
-
* (`federationReturn`). The popup and the redirect carry the restriction
|
|
116
|
-
* `options.identityTypes` names, which signIn() validated.
|
|
117
|
-
*/
|
|
118
|
-
private runFlow;
|
|
119
|
-
/**
|
|
120
|
-
* Attach identity verification to element clicks.
|
|
121
|
-
* When any matching element is clicked, opens the verification dialog.
|
|
122
|
-
*
|
|
123
|
-
* @param selector - CSS selector for elements to attach to
|
|
124
|
-
* @param options - Verification options and callbacks
|
|
125
|
-
* @returns Cleanup function to remove event listeners
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* const cleanup = sv.products.identity.attach('.login-btn', {
|
|
129
|
-
* onSuccess: (result) => console.log('Verified:', result.identity)
|
|
130
|
-
* });
|
|
131
|
-
*
|
|
132
|
-
* // Later, remove listeners
|
|
133
|
-
* cleanup();
|
|
134
|
-
*/
|
|
135
|
-
attach(selector: string, options?: AttachOptions): () => void;
|
|
136
|
-
/**
|
|
137
|
-
* Decode an identity token's claims WITHOUT verifying its signature.
|
|
138
|
-
*
|
|
139
|
-
* This is an UNVERIFIED, client-side decode: it parses the JWT payload and
|
|
140
|
-
* sanity-checks structure, `exp`, `iss`, `aud`, and the header `alg` (accepting
|
|
141
|
-
* only the algorithms the Identity server signs with, so an unsigned or
|
|
142
|
-
* algorithm-confused token cannot masquerade as valid). It does NOT verify the
|
|
143
|
-
* signature, so its result MUST NOT be trusted for any authorization decision.
|
|
144
|
-
*
|
|
145
|
-
* To trust a token (e.g. before keying records by `claims.svid`), verify the
|
|
146
|
-
* signature server-side against the Identity JWKS endpoint
|
|
147
|
-
* (`https://auth.sparkvault.com/{account_id}/.well-known/jwks.json`), which
|
|
148
|
-
* publishes the EdDSA and RS256 keys and selects the verifying key by `kid`.
|
|
149
|
-
* See docs/SDK.md.
|
|
150
|
-
*/
|
|
151
|
-
decodeToken(token: string): TokenClaims;
|
|
152
|
-
/**
|
|
153
|
-
* Complete a sign-in on page load: the return leg of `signIn()`. Call once
|
|
154
|
-
* on every page load; it resolves `null` when there is nothing to do.
|
|
155
|
-
*
|
|
156
|
-
* It handles two cases:
|
|
157
|
-
* 1. A one-time code is in the URL fragment (`#sv_code=…`): the popup's
|
|
158
|
-
* result was lost and self-heal navigated here, or `flow: 'redirect'`
|
|
159
|
-
* returned. Redeem it server-side and hand the full result to
|
|
160
|
-
* `onSuccess` (and resolve with it).
|
|
161
|
-
* 2. A sign-in was in flight but never delivered (a mobile browser
|
|
162
|
-
* discarded the backgrounded opener tab, killing the popup's
|
|
163
|
-
* postMessage): silently re-mint from the SSO session the popup signed
|
|
164
|
-
* in or chose, by navigating this tab through the silent SSO endpoint
|
|
165
|
-
* and straight back with a code (case 1 on return). The bounce names
|
|
166
|
-
* the sign-in's reference, and the endpoint mints only when the
|
|
167
|
-
* session it would mint from carries it. Nothing is shown; with no
|
|
168
|
-
* such session (a sign-in that opened none, such as one through the
|
|
169
|
-
* account's own identity provider) it comes back logged-out, no oracle.
|
|
170
|
-
*
|
|
171
|
-
* The code is one-time, PKCE-bound, and origin-locked, never the token. The
|
|
172
|
-
* host must still verify `result.token` server-side via the Identity JWKS.
|
|
173
|
-
*
|
|
174
|
-
* @example Call on page load; sign-in clicks stay unchanged.
|
|
175
|
-
* sv.products.identity.handleRedirectResult({
|
|
176
|
-
* onSuccess: (result) => createSession(result.token),
|
|
177
|
-
* }).catch((error) => showError(error));
|
|
178
|
-
*/
|
|
179
|
-
handleRedirectResult(options?: RedirectResultOptions): Promise<SignInResult | null>;
|
|
180
|
-
/** Redeem a returned `#sv_code` (or surface a returned `#sv_error`). */
|
|
181
|
-
private consumeHandoffFragment;
|
|
182
|
-
/**
|
|
183
|
-
* Silently re-mint the sign-in result from the SSO session the popup signed
|
|
184
|
-
* in or chose. Navigates this tab through the silent SSO endpoint
|
|
185
|
-
* (a top-level GET, so the `SameSite=Lax` hub cookie rides along) which,
|
|
186
|
-
* PKCE-bound, returns a one-time code in the fragment, handled by case 1 on
|
|
187
|
-
* return. No-op (stays put) if session storage or WebCrypto is unavailable,
|
|
188
|
-
* so a degraded environment simply never recovers rather than erroring. The
|
|
189
|
-
* bounce's PKCE verifier and state are a draw from the Identity origin
|
|
190
|
-
* (`drawAuthorizationValues`): a draw that fails (the origin unreachable, a
|
|
191
|
-
* malformed answer) rejects `handleRedirectResult()` with that error, and the
|
|
192
|
-
* page stays put.
|
|
193
|
-
*/
|
|
194
|
-
private startRecoveryBounce;
|
|
195
|
-
/**
|
|
196
|
-
* Navigate this tab to the interactive sign-in page: explicit `flow:
|
|
197
|
-
* 'redirect'`, or a popup whose handle COOP severed. Plain sign-in carries
|
|
198
|
-
* redirect_uri + state + PKCE challenge and returns via the fragment code;
|
|
199
|
-
* OIDC/simple modes navigate without them (their server-rendered pages drive
|
|
200
|
-
* the server-validated redirect back). Either carries the severed popup's
|
|
201
|
-
* reference; a redirect draws none of its own.
|
|
202
|
-
*
|
|
203
|
-
* The return leg is armed first: the check that the sign-in still runs and
|
|
204
|
-
* the pending marker's removal then share one turn with the navigation, so
|
|
205
|
-
* no sign-in can start or end between them.
|
|
206
|
-
*
|
|
207
|
-
* @param severed - The popup sign-in whose severed popup this continues,
|
|
208
|
-
* with the reference its marker holds for that popup (null for none), or
|
|
209
|
-
* null for an explicit redirect, which carries none
|
|
210
|
-
* @returns false when the return leg cannot be armed (no session storage or
|
|
211
|
-
* WebCrypto), so the caller surfaces an actionable error instead of a
|
|
212
|
-
* silent dead-end, or when the severed popup's sign-in ended meanwhile.
|
|
213
|
-
*/
|
|
214
|
-
private startRedirectFlow;
|
|
215
|
-
/**
|
|
216
|
-
* Arm the PKCE + state return leg of a handoff navigation and return what
|
|
217
|
-
* the navigation carries for it (redirect_uri = this page, per
|
|
218
|
-
* `currentPageReturnUrl`). Returns null when session storage or WebCrypto is
|
|
219
|
-
* unavailable so callers can degrade.
|
|
220
|
-
*/
|
|
221
|
-
private armHandoffReturn;
|
|
222
|
-
/**
|
|
223
|
-
* Consume the pending marker: the marker once (then cleared) while a recent
|
|
224
|
-
* sign-in is still awaiting its result, else null. Its `hint` is the
|
|
225
|
-
* identifier that sign-in carried, for the recovery bounce's `login_hint`,
|
|
226
|
-
* and its `ref` the sign-in's reference, when the marker holds one.
|
|
227
|
-
*/
|
|
228
|
-
private consumeSignInPending;
|
|
229
|
-
/** Close the popup sign-in's launcher, ending the sign-in it ran. */
|
|
230
|
-
private closeLauncher;
|
|
231
|
-
/** Remove the result fragment from the URL bar (and history entry). */
|
|
232
|
-
private clearUrlFragment;
|
|
233
|
-
/** Drop the one-shot PKCE state/verifier a bounce staged. */
|
|
234
|
-
private clearOneShotAuthState;
|
|
235
|
-
/**
|
|
236
|
-
* Complete a social round trip, or one through the account's own identity
|
|
237
|
-
* provider, that returned to the sign-in page as `#token=…&state=…`. Only
|
|
238
|
-
* `render()`, the Identity-origin sign-in page,
|
|
239
|
-
* reads it: no SDK flow returns a `#token` to a site (a site's results arrive
|
|
240
|
-
* by the popup's postMessage, FedCM, or a PKCE-bound `#sv_code`), so on a site
|
|
241
|
-
* it could only be someone else's token, or the site's own direct
|
|
242
|
-
* token-redirect result.
|
|
243
|
-
*/
|
|
244
|
-
private consumeRedirectResult;
|
|
245
|
-
/**
|
|
246
|
-
* Read a refusal a round trip through the account's own identity provider
|
|
247
|
-
* returned to the sign-in page (`#error=…&state=…`, see federation-flow.ts).
|
|
248
|
-
* Such a fragment is consumed exactly once, with the state it answers,
|
|
249
|
-
* whatever it holds. Null for any other fragment, and for a refusal whose
|
|
250
|
-
* state is not the one this browser stored before it left: an answer to no
|
|
251
|
-
* sign-in this browser started, which the page ignores.
|
|
252
|
-
*/
|
|
253
|
-
private consumeFederationReturn;
|
|
254
|
-
/**
|
|
255
|
-
* Close the identity dialog/inline UI if open.
|
|
256
|
-
*
|
|
257
|
-
* Tears down whichever surface is active: the dialog launcher (default dialog
|
|
258
|
-
* mode) or the local renderer (inline / local mode).
|
|
259
|
-
*/
|
|
260
|
-
close(): void;
|
|
261
|
-
/**
|
|
262
|
-
* Whether the preloaded config has already settled as a *permanent* failure
|
|
263
|
-
* the popup can't surface (origin not allowed, or product not configured).
|
|
264
|
-
* Used to skip the launcher and show the error dialog in-page immediately.
|
|
265
|
-
* Returns false (proceed to the launcher) when config is not preloaded,
|
|
266
|
-
* still in flight (raced against a short timeout so the common path is never
|
|
267
|
-
* delayed), resolved, or failed only transiently (the launcher surfaces a
|
|
268
|
-
* transient failure in its own dialog).
|
|
269
|
-
*/
|
|
270
|
-
private preloadedConfigPermanentlyFailed;
|
|
271
|
-
/**
|
|
272
|
-
* The inline container for an embedded render. Bare chrome: the host page
|
|
273
|
-
* owns logo + footer + background, so the container drops its own surface
|
|
274
|
-
* and the SparkVault footer.
|
|
275
|
-
*/
|
|
276
|
-
private createInlineContainer;
|
|
277
|
-
/**
|
|
278
|
-
* Render the flow into a page element instead of a popup.
|
|
279
|
-
*
|
|
280
|
-
* A social login, or one through the account's own identity provider,
|
|
281
|
-
* started here returns to this same page with its result in the fragment,
|
|
282
|
-
* so a returned `#token` is completed first (see `consumeRedirectResult`)
|
|
283
|
-
* instead of starting the flow again, and a returned refusal of the
|
|
284
|
-
* account's own identity provider is handed to the flow it starts (see
|
|
285
|
-
* `consumeFederationReturn`).
|
|
286
|
-
*
|
|
287
|
-
* The page hands its restriction as its URL spelled it (`identityTypes`),
|
|
288
|
-
* which the flow reads here: a spelling it cannot read shows as an error.
|
|
289
|
-
*
|
|
290
|
-
* @internal Used only by the SparkVault-hosted sign-in popup and hosted login
|
|
291
|
-
* page (which own their chrome and pass `renderMode: 'local'`). Customer
|
|
292
|
-
* integrations have no inline mode; use `signIn()` / `attach()`.
|
|
293
|
-
*/
|
|
294
|
-
render(options: RenderOptions): Promise<VerifyResult>;
|
|
295
|
-
}
|
|
296
|
-
export type { SignInOptions, SignInResult, SigninIdentityType, AttachOptions, VerifyResult, VerifyOptions, TokenClaims, } from './types';
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inline Container
|
|
3
|
-
*
|
|
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
|
-
*
|
|
8
|
-
* Implements the Container interface for use with IdentityRenderer.
|
|
9
|
-
*/
|
|
10
|
-
import type { Container } from './container';
|
|
11
|
-
import type { SdkConfigBranding } from './types';
|
|
12
|
-
export interface InlineContainerOptions {
|
|
13
|
-
/**
|
|
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.
|
|
17
|
-
*/
|
|
18
|
-
bare?: boolean;
|
|
19
|
-
}
|
|
20
|
-
export declare class InlineContainer implements Container {
|
|
21
|
-
private readonly targetElement;
|
|
22
|
-
private readonly bare;
|
|
23
|
-
private shell;
|
|
24
|
-
constructor(targetElement: HTMLElement, options?: InlineContainerOptions);
|
|
25
|
-
/**
|
|
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.
|
|
28
|
-
*/
|
|
29
|
-
createLoading(_options: {
|
|
30
|
-
backdropBlur?: boolean;
|
|
31
|
-
}, _onClose: () => void): void;
|
|
32
|
-
/**
|
|
33
|
-
* Re-theme the stylesheet once the SDK config loads.
|
|
34
|
-
*/
|
|
35
|
-
updateBranding(branding: SdkConfigBranding): void;
|
|
36
|
-
/**
|
|
37
|
-
* Minimal-chrome toggle (no-op for inline container).
|
|
38
|
-
* Inline containers don't own page-level chrome to hide.
|
|
39
|
-
*/
|
|
40
|
-
setMinimalChrome(_enabled: boolean): void;
|
|
41
|
-
/**
|
|
42
|
-
* Get the body element for content rendering.
|
|
43
|
-
*/
|
|
44
|
-
getBody(): HTMLDivElement | null;
|
|
45
|
-
/**
|
|
46
|
-
* Check if the container is currently active.
|
|
47
|
-
*/
|
|
48
|
-
isOpen(): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Destroy the container, leaving the target empty.
|
|
51
|
-
*/
|
|
52
|
-
destroy(): void;
|
|
53
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Method Registry
|
|
3
|
-
*
|
|
4
|
-
* Static metadata for all authentication methods.
|
|
5
|
-
* API returns method IDs; SDK enriches with this metadata for rendering.
|
|
6
|
-
*/
|
|
7
|
-
import type { MethodId, MethodMetadata, SdkConfigFederation } from './types';
|
|
8
|
-
/**
|
|
9
|
-
* Static method metadata registry
|
|
10
|
-
*/
|
|
11
|
-
export declare const METHOD_REGISTRY: Record<MethodId, MethodMetadata>;
|
|
12
|
-
/**
|
|
13
|
-
* Enrich method IDs with full metadata
|
|
14
|
-
* @param ids - Array of method IDs from config
|
|
15
|
-
* @param federation - The account's own identity provider as `/config` describes it;
|
|
16
|
-
* without it no `federation` method is offered, for its button has no name to show
|
|
17
|
-
* @returns Array of method metadata objects
|
|
18
|
-
*/
|
|
19
|
-
export declare function enrichMethods(ids: MethodId[], federation?: SdkConfigFederation | null): MethodMetadata[];
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Identity Modal Container
|
|
3
|
-
*
|
|
4
|
-
* Single responsibility: the identity dialog's chrome (branded header, body,
|
|
5
|
-
* footer) inside the SDK's shared modal shell, which owns the dialog
|
|
6
|
-
* behaviour (dismissal, scroll lock, focus). Does NOT handle content
|
|
7
|
-
* rendering - that's the Renderer's job.
|
|
8
|
-
*/
|
|
9
|
-
import type { SdkConfigBranding } from './types';
|
|
10
|
-
import type { Container } from './container';
|
|
11
|
-
export declare class ModalContainer implements Container {
|
|
12
|
-
private shell;
|
|
13
|
-
private body;
|
|
14
|
-
private header;
|
|
15
|
-
private onCloseCallback;
|
|
16
|
-
private effectiveTheme;
|
|
17
|
-
private floatingCloseBtn;
|
|
18
|
-
/**
|
|
19
|
-
* Create and show the modal immediately with loading state, in default
|
|
20
|
-
* branding until the real config loads, so the user gets instant feedback.
|
|
21
|
-
*/
|
|
22
|
-
createLoading(options: {
|
|
23
|
-
backdropBlur?: boolean;
|
|
24
|
-
}, onClose: () => void): void;
|
|
25
|
-
/**
|
|
26
|
-
* Update the header and styles with the real branding once the SDK config
|
|
27
|
-
* loads.
|
|
28
|
-
*/
|
|
29
|
-
updateBranding(branding: SdkConfigBranding): void;
|
|
30
|
-
/**
|
|
31
|
-
* Toggle minimal-chrome mode. In minimal mode the header (logo + close)
|
|
32
|
-
* is hidden and a floating close button is positioned over the modal so
|
|
33
|
-
* the body view can render edge-to-edge as its own full-dialog design.
|
|
34
|
-
*/
|
|
35
|
-
setMinimalChrome(enabled: boolean): void;
|
|
36
|
-
private createHeader;
|
|
37
|
-
private handleClose;
|
|
38
|
-
/**
|
|
39
|
-
* Get the modal body element for content rendering.
|
|
40
|
-
*/
|
|
41
|
-
getBody(): HTMLDivElement | null;
|
|
42
|
-
/**
|
|
43
|
-
* Check if the modal is currently open.
|
|
44
|
-
*/
|
|
45
|
-
isOpen(): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Destroy the modal; the shell removes its listeners, releases the scroll
|
|
48
|
-
* lock and returns focus.
|
|
49
|
-
*/
|
|
50
|
-
destroy(): void;
|
|
51
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The pending sign-in marker: what lets a site whose popup result was lost (a
|
|
3
|
-
* mobile browser discards the backgrounded opener tab, which clears the
|
|
4
|
-
* message listener but not sessionStorage) recover it on its next load, for
|
|
5
|
-
* at most SIGNIN_RECOVERY.pendingTtlMs.
|
|
6
|
-
*
|
|
7
|
-
* `sv_signin_pending` holds JSON `{ at, hint, ref, identity_types }`:
|
|
8
|
-
* - `at`: when the current popup opened, on this browser's clock; the
|
|
9
|
-
* marker's TTL.
|
|
10
|
-
* - `hint`: the email or phone the sign-in started with, or null when the
|
|
11
|
-
* flow collects the identifier itself; the recovery bounce's `login_hint`.
|
|
12
|
-
* - `ref`: the current popup's reference (app-sdk SIGNIN_REFERENCE), present
|
|
13
|
-
* once drawn and written; the recovery bounce names it, and `/sso` then
|
|
14
|
-
* mints only when the hub session it would mint from carries it. A marker
|
|
15
|
-
* without one bounces with no reference.
|
|
16
|
-
* - `identity_types` (SIGNIN_IDENTITY_TYPES.param): the sign-in's restriction
|
|
17
|
-
* on the identity types it may produce, in its one spelling, present only
|
|
18
|
-
* when the sign-in named one; the recovery bounce names it, so `/sso` mints
|
|
19
|
-
* only a type the sign-in accepts.
|
|
20
|
-
*/
|
|
21
|
-
/** A parsed pending marker. */
|
|
22
|
-
export interface PendingMarker {
|
|
23
|
-
at: number;
|
|
24
|
-
hint: string | null;
|
|
25
|
-
ref: string | null;
|
|
26
|
-
/** The sign-in's restriction in its one spelling, or null for none. */
|
|
27
|
-
identityTypes: string | null;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Read and parse the pending marker. Anything unreadable yields null: a value
|
|
31
|
-
* that is not a JSON object, an `at` that is no finite number, a `ref` that
|
|
32
|
-
* is present but no sign-in reference, or a restriction that is present but
|
|
33
|
-
* not in its spelling. A recovery that cannot name the reference its marker
|
|
34
|
-
* records could mint any hub session in this browser, and one that cannot
|
|
35
|
-
* name its restriction could mint a type its sign-in refuses, so such a
|
|
36
|
-
* marker recovers nothing.
|
|
37
|
-
*/
|
|
38
|
-
export declare function readPendingMarker(): PendingMarker | null;
|
|
39
|
-
/** True while a marker is within the recovery TTL. */
|
|
40
|
-
export declare function isFreshPendingMarker(marker: PendingMarker | null): marker is PendingMarker;
|
|
41
|
-
/** Remove the pending marker. */
|
|
42
|
-
export declare function removePendingMarker(): void;
|
|
43
|
-
/**
|
|
44
|
-
* One popup sign-in's marker, from its first popup's open until the sign-in
|
|
45
|
-
* settles. Every popup it opens, the first and each "Try again", is an open
|
|
46
|
-
* of its own: it re-arms the marker holding no reference and draws its own
|
|
47
|
-
* reference (signinReferenceInTime), which joins the marker once drawn. A
|
|
48
|
-
* popup that has none asks again, and the same popup is then opened afresh,
|
|
49
|
-
* with a draw of its own. An earlier open's reference is never reused, and
|
|
50
|
-
* its draw, should it land later, is discarded. `reference` is what the
|
|
51
|
-
* current popup is told, and the marker always holds it: a popup can never
|
|
52
|
-
* hold a reference the marker does not.
|
|
53
|
-
*/
|
|
54
|
-
export declare class PendingSignIn {
|
|
55
|
-
private readonly hint;
|
|
56
|
-
private readonly identityTypes;
|
|
57
|
-
private at;
|
|
58
|
-
private ended;
|
|
59
|
-
private opens;
|
|
60
|
-
private current;
|
|
61
|
-
private decided;
|
|
62
|
-
/**
|
|
63
|
-
* @param hint - The identifier the sign-in started with, or null
|
|
64
|
-
* @param identityTypes - The sign-in's restriction in its one spelling, or null for none
|
|
65
|
-
*/
|
|
66
|
-
constructor(hint: string | null, identityTypes: string | null);
|
|
67
|
-
/**
|
|
68
|
-
* The current popup's reference: undefined while its draw is out, null
|
|
69
|
-
* when it has none (its draw failed or missed the deadline, the marker
|
|
70
|
-
* write failed, or the popup already ended), else the reference the marker
|
|
71
|
-
* holds.
|
|
72
|
-
*/
|
|
73
|
-
get reference(): string | null | undefined;
|
|
74
|
-
/** False once the sign-in ended: it settled, was closed, or another replaced it. */
|
|
75
|
-
get live(): boolean;
|
|
76
|
-
/**
|
|
77
|
-
* A popup opened, or the current one asked again for the reference it
|
|
78
|
-
* lacks: arm the marker holding no reference, and draw this open's own.
|
|
79
|
-
* Resolves true once this open's reference is decided while its popup is
|
|
80
|
-
* still the current one of a live sign-in, so that popup may be told; false
|
|
81
|
-
* when the popup ended or was replaced, or the sign-in ended. Never
|
|
82
|
-
* rejects.
|
|
83
|
-
*/
|
|
84
|
-
open(draw: () => Promise<string>): Promise<boolean>;
|
|
85
|
-
/**
|
|
86
|
-
* The opener saw the popup end with no result, so there is no lost result
|
|
87
|
-
* to recover: without this, a reload while the retry alert is up would
|
|
88
|
-
* bounce for nothing. The ended popup is told nothing more, and its draw,
|
|
89
|
-
* should it land, is dropped.
|
|
90
|
-
*/
|
|
91
|
-
retire(): void;
|
|
92
|
-
/** The sign-in settled, or another replaced it: retire the marker, and nothing this sign-in does later touches it. */
|
|
93
|
-
end(): void;
|
|
94
|
-
/**
|
|
95
|
-
* The current popup's reference, waiting at most `waitMs` for an open still
|
|
96
|
-
* drawing it: the reference the marker holds, else null (the popup has
|
|
97
|
-
* none, or its draw has not landed in time). Never rejects.
|
|
98
|
-
*/
|
|
99
|
-
referenceWithin(waitMs: number): Promise<string | null>;
|
|
100
|
-
/** Write the marker; a write that fails leaves the stored marker as it was. */
|
|
101
|
-
private write;
|
|
102
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Popup Launcher
|
|
3
|
-
*
|
|
4
|
-
* Opens a top-level popup on the Identity origin and bridges its result back
|
|
5
|
-
* over postMessage. Used by both the passkey ceremony (which needs a popup so
|
|
6
|
-
* WebAuthn runs same-origin with the RP id) and the dialog login flow (which
|
|
7
|
-
* needs a top-level window on the IdP origin so login's first-party SSO cookie
|
|
8
|
-
* persists).
|
|
9
|
-
*
|
|
10
|
-
* The single transfer path: synchronous `window.open` inside the user gesture
|
|
11
|
-
* (so the browser never blocks it), strict `event.origin` + `data.type`
|
|
12
|
-
* validation against the caller-supplied trusted origin, a 30-minute
|
|
13
|
-
* abandoned-window backstop, and a `window.closed` poll that surfaces a manual
|
|
14
|
-
* close as a cancellation.
|
|
15
|
-
*/
|
|
16
|
-
/** Minimal shape every popup result envelope shares. */
|
|
17
|
-
export interface PopupResultEnvelope {
|
|
18
|
-
type: string;
|
|
19
|
-
[key: string]: unknown;
|
|
20
|
-
}
|
|
21
|
-
export interface OpenPopupOptions {
|
|
22
|
-
/** URL the popup navigates to (already includes the encoded origin param). */
|
|
23
|
-
url: string;
|
|
24
|
-
/** `window.open` target name. */
|
|
25
|
-
windowName: string;
|
|
26
|
-
/** `data.type` the opener accepts; any other message is ignored. */
|
|
27
|
-
resultType: string;
|
|
28
|
-
/** Exact origin the popup must postMessage from; any other origin is ignored. */
|
|
29
|
-
trustedOrigin: string;
|
|
30
|
-
/** Popup width in px (default 480). */
|
|
31
|
-
width?: number;
|
|
32
|
-
/** Popup height in px (default 640). */
|
|
33
|
-
height?: number;
|
|
34
|
-
/** Timeout in ms before giving up and closing the popup (default 30 minutes). */
|
|
35
|
-
timeoutMs?: number;
|
|
36
|
-
/**
|
|
37
|
-
* Called synchronously with the popup window the moment it opens, so the
|
|
38
|
-
* opener can close or refocus it (e.g. an abort/"try again" control on a host
|
|
39
|
-
* bridge modal). Not called when the popup is blocked.
|
|
40
|
-
*/
|
|
41
|
-
onOpen?: (popup: Window) => void;
|
|
42
|
-
/**
|
|
43
|
-
* `data.type` of a non-terminal "I've loaded" ping the popup posts so the
|
|
44
|
-
* opener can confirm the window actually opened and reached the page (vs.
|
|
45
|
-
* silently failing). Distinct from `resultType`; receiving it does not settle.
|
|
46
|
-
*/
|
|
47
|
-
readyType?: string;
|
|
48
|
-
/** Called when a `readyType` message arrives from the trusted origin. */
|
|
49
|
-
onReady?: () => void;
|
|
50
|
-
/**
|
|
51
|
-
* `data.type` of a non-terminal request the popup makes of its opener (the
|
|
52
|
-
* sign-in page asking again for its sign-in's reference). Distinct from
|
|
53
|
-
* `resultType` and `readyType`; receiving it does not settle.
|
|
54
|
-
*/
|
|
55
|
-
requestType?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Called when a `requestType` message arrives from this popup's own window
|
|
58
|
-
* on the trusted origin: a request asks the opener to act, so it is taken
|
|
59
|
-
* from this window alone, never from another of the origin's windows.
|
|
60
|
-
*/
|
|
61
|
-
onRequest?: () => void;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Open a popup and resolve with the first validated result envelope it posts.
|
|
65
|
-
*
|
|
66
|
-
* Resolves with the raw `event.data` (the caller inspects its `success`/`error`
|
|
67
|
-
* fields). Rejects with `PopupBlockedError` when the browser blocked the popup,
|
|
68
|
-
* `UserCancelledError` when the user closed it manually, and `TimeoutError`
|
|
69
|
-
* when no result arrived within the timeout.
|
|
70
|
-
*/
|
|
71
|
-
export declare class PopupLauncher {
|
|
72
|
-
openPopup<TData extends PopupResultEnvelope = PopupResultEnvelope>(options: OpenPopupOptions): Promise<TData>;
|
|
73
|
-
}
|