@sparkvault/sdk-js 16.0.1 → 16.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.
- package/README.md +2 -0
- package/dist/index.cjs +1741 -638
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +126 -41
- package/dist/index.mjs +1741 -638
- package/dist/index.mjs.map +1 -1
- package/dist/products/identity/api.d.ts +34 -3
- package/dist/products/identity/dialog-launcher.d.ts +44 -4
- package/dist/products/identity/federation-flow.d.ts +31 -0
- package/dist/products/identity/index.d.ts +56 -36
- package/dist/products/identity/methods.d.ts +4 -2
- package/dist/products/identity/pending-signin.d.ts +87 -0
- package/dist/products/identity/popup-launcher.d.ts +12 -0
- package/dist/products/identity/renderer.d.ts +142 -3
- package/dist/products/identity/state.d.ts +4 -0
- package/dist/products/identity/types.d.ts +87 -6
- package/dist/products/identity/utils.d.ts +21 -2
- package/dist/products/identity/views/base.d.ts +6 -0
- package/dist/products/identity/views/error.d.ts +12 -0
- package/dist/products/identity/views/icons.d.ts +4 -1
- package/dist/products/identity/views/identity-input.d.ts +24 -0
- package/dist/products/identity/views/loading.d.ts +8 -0
- package/dist/products/identity/views/method-button.d.ts +14 -0
- package/dist/products/identity/views/method-select.d.ts +7 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,8 @@ export declare class IdentityApi extends SparkVaultApi {
|
|
|
13
13
|
/** Cached config promise - allows preloading and deduplication */
|
|
14
14
|
private configCache;
|
|
15
15
|
constructor(config: ResolvedConfig, timeoutMs?: number);
|
|
16
|
+
/** The account this API signs people in to. */
|
|
17
|
+
get accountId(): string;
|
|
16
18
|
private get baseUrl();
|
|
17
19
|
protected makeError(message: string, code: string, statusCode: number, details?: Record<string, unknown>, retryAfterMs?: number | null): IdentityApiError;
|
|
18
20
|
private request;
|
|
@@ -46,6 +48,15 @@ export declare class IdentityApi extends SparkVaultApi {
|
|
|
46
48
|
state: string;
|
|
47
49
|
nonce: string;
|
|
48
50
|
}>;
|
|
51
|
+
/**
|
|
52
|
+
* A sign-in's reference (app-sdk SIGNIN_REFERENCE): its own draw through
|
|
53
|
+
* the Identity origin, like drawAuthorizationValues, spelled unpadded
|
|
54
|
+
* base64url. The draw names its purpose, so the origin counts it against a
|
|
55
|
+
* budget of its own and a network's reference draws never spend the draws
|
|
56
|
+
* its sign-ins need to complete. Rejects on a draw that fails (a spent
|
|
57
|
+
* budget among them) or answers malformed.
|
|
58
|
+
*/
|
|
59
|
+
drawSigninReference(): Promise<string>;
|
|
49
60
|
/**
|
|
50
61
|
* Check whether the SVID resolved from an email or phone has registered
|
|
51
62
|
* passkeys (`has_passkey`; cross-tenant — single global RP), for a
|
|
@@ -84,6 +95,7 @@ export declare class IdentityApi extends SparkVaultApi {
|
|
|
84
95
|
pin: string;
|
|
85
96
|
recipient: string;
|
|
86
97
|
authContext?: AuthContext;
|
|
98
|
+
signinRef?: string | null;
|
|
87
99
|
}): Promise<OtpVerifyResponse>;
|
|
88
100
|
/**
|
|
89
101
|
* Submit a second factor (authenticator-app code or recovery code) to finish
|
|
@@ -110,6 +122,7 @@ export declare class IdentityApi extends SparkVaultApi {
|
|
|
110
122
|
session: Record<string, unknown>;
|
|
111
123
|
credential: PublicKeyCredential;
|
|
112
124
|
authContext?: AuthContext;
|
|
125
|
+
signinRef?: string | null;
|
|
113
126
|
}): Promise<PasskeyVerifyResponse>;
|
|
114
127
|
/**
|
|
115
128
|
* Send a one-time code to a new backup identifier (the inverse of the
|
|
@@ -142,14 +155,32 @@ export declare class IdentityApi extends SparkVaultApi {
|
|
|
142
155
|
key: RecommendationKey;
|
|
143
156
|
}): Promise<void>;
|
|
144
157
|
/**
|
|
145
|
-
* Get OAuth redirect URL for social provider
|
|
158
|
+
* Get OAuth redirect URL for social provider. The start carries the
|
|
159
|
+
* sign-in's reference, when it has one, so the hub session the provider's
|
|
160
|
+
* answer creates or chooses records it.
|
|
161
|
+
*/
|
|
162
|
+
getSocialAuthUrl(provider: string, redirectUri: string, state: string, authContext?: AuthContext, signinRef?: string | null): string;
|
|
163
|
+
/**
|
|
164
|
+
* The start of a sign-in with the account's own identity provider: the same
|
|
165
|
+
* return as a social start (the page `redirectUri` names, answered with
|
|
166
|
+
* `#token` and the `state` sent, or the OIDC auth request it continues), and
|
|
167
|
+
* `prompt=none` for a silent attempt, which the provider answers without
|
|
168
|
+
* showing anything. The start carries the sign-in's reference, when it has
|
|
169
|
+
* one: such a sign-in opens no hub session, so Identity releases that
|
|
170
|
+
* reference from the browser's hub sessions on its completion, and a
|
|
171
|
+
* recovery naming it mints none of them. A verify session is never named:
|
|
172
|
+
* such a sign-in cannot complete one, so its start refuses it, and a verify
|
|
173
|
+
* session never admits the method.
|
|
146
174
|
*/
|
|
147
|
-
|
|
175
|
+
getFederationAuthUrl(redirectUri: string, state: string, authContext?: AuthContext, options?: {
|
|
176
|
+
silent?: boolean;
|
|
177
|
+
signinRef?: string | null;
|
|
178
|
+
}): string;
|
|
148
179
|
/**
|
|
149
180
|
* Send SparkLink email for identity verification.
|
|
150
181
|
* Includes connectionId for WebSocket push notification of verification result.
|
|
151
182
|
*/
|
|
152
|
-
sendSparkLink(email: string, connectionId: string, authContext?: AuthContext): Promise<SparkLinkSendResponse>;
|
|
183
|
+
sendSparkLink(email: string, connectionId: string, authContext?: AuthContext, signinRef?: string | null): Promise<SparkLinkSendResponse>;
|
|
153
184
|
/**
|
|
154
185
|
* Claim the SparkLink click's result by kindling — the WebSocket-loss
|
|
155
186
|
* fallback. The SDK calls this when its socket was suspended with the tab and
|
|
@@ -12,7 +12,13 @@
|
|
|
12
12
|
* The popup must open synchronously in the gesture or the browser blocks it as
|
|
13
13
|
* programmatic. `verify()` reaches `start()` through microtask-only awaits (the
|
|
14
14
|
* redirect-result check does no I/O; the preloaded config resolves from cache),
|
|
15
|
-
* so transient activation survives.
|
|
15
|
+
* so transient activation survives. Each popup's reference (app-sdk
|
|
16
|
+
* SIGNIN_REFERENCE) is therefore drawn only after that popup opens, by the
|
|
17
|
+
* owner (`drawSigninReference`). Once the owner has decided it (its pending
|
|
18
|
+
* marker holds the drawn reference, or the popup has none), the launcher
|
|
19
|
+
* posts it to the popup in answer to each "ready" ping: the reference, or
|
|
20
|
+
* null. A popup told null may ask again (`SIGNIN_REFERENCE.retryMessage`),
|
|
21
|
+
* and the owner then draws afresh for it.
|
|
16
22
|
*
|
|
17
23
|
* It is one dialog. The happy path is clean: logo, a subtle animation, and
|
|
18
24
|
* "continue in the secure window". A single warning appears under the logo only
|
|
@@ -36,8 +42,13 @@ interface LauncherCallbacks {
|
|
|
36
42
|
* bounce. Deliberately NOT onCancel: the flow is unsettled, retry may follow.
|
|
37
43
|
*/
|
|
38
44
|
onPopupClosedUnresolved?: () => void;
|
|
39
|
-
/**
|
|
40
|
-
|
|
45
|
+
/**
|
|
46
|
+
* The current popup needs a reference of its own: it was just opened, the
|
|
47
|
+
* first or by "Try again", or it has none and asked again. The owner arms
|
|
48
|
+
* its marker holding none, draws one, and calls `signinReferenceDecided()`
|
|
49
|
+
* once it has decided what this popup is told.
|
|
50
|
+
*/
|
|
51
|
+
drawSigninReference: () => void;
|
|
41
52
|
/**
|
|
42
53
|
* The popup's handle was severed (COOP) — postMessage can never deliver, so
|
|
43
54
|
* a retry popup is futile. The owner should switch this tab to the redirect
|
|
@@ -45,6 +56,13 @@ interface LauncherCallbacks {
|
|
|
45
56
|
* `false` to fall back to the retry alert (e.g. no session storage).
|
|
46
57
|
*/
|
|
47
58
|
onPopupSevered?: () => Promise<boolean>;
|
|
59
|
+
/**
|
|
60
|
+
* The current popup's reference as the owner decided it: undefined while
|
|
61
|
+
* undecided, null when the popup has none, else the reference the owner's
|
|
62
|
+
* pending marker holds. The popup is told only this, so it can never hold
|
|
63
|
+
* a reference the marker does not.
|
|
64
|
+
*/
|
|
65
|
+
signinReference: () => string | null | undefined;
|
|
48
66
|
}
|
|
49
67
|
/**
|
|
50
68
|
* Opens the sign-in popup for dialog-mode `verify()` and bridges its result
|
|
@@ -60,6 +78,7 @@ export declare class DialogLauncher {
|
|
|
60
78
|
private modal;
|
|
61
79
|
private alertEl;
|
|
62
80
|
private popupWindow;
|
|
81
|
+
private popupReady;
|
|
63
82
|
private openTimer;
|
|
64
83
|
private settled;
|
|
65
84
|
private generation;
|
|
@@ -68,7 +87,28 @@ export declare class DialogLauncher {
|
|
|
68
87
|
start(): void;
|
|
69
88
|
/** Tear down the bridge modal and close any popup it opened. */
|
|
70
89
|
close(): void;
|
|
90
|
+
/**
|
|
91
|
+
* The owner decided the current popup's reference: tell the popup if it
|
|
92
|
+
* already pinged. A popup that loads later is told in answer to its ping.
|
|
93
|
+
*/
|
|
94
|
+
signinReferenceDecided(): void;
|
|
71
95
|
private openPopup;
|
|
96
|
+
/**
|
|
97
|
+
* The current popup asked again for its reference. A popup that has none
|
|
98
|
+
* gets a fresh draw (the owner re-arms the marker, then decides), one that
|
|
99
|
+
* holds a reference is told it again, and one whose draw is still out is
|
|
100
|
+
* told once that draw is decided.
|
|
101
|
+
*/
|
|
102
|
+
private answerSigninReferenceRetry;
|
|
103
|
+
/**
|
|
104
|
+
* Post the current popup's reference, once the owner decided it, to this
|
|
105
|
+
* launcher's own popup: the reference the marker holds, or null for a
|
|
106
|
+
* popup with none, so the page knows at once that it has none for now
|
|
107
|
+
* instead of waiting it out. Only a document there on the trusted Identity
|
|
108
|
+
* origin receives it: the browser drops it while the popup shows any other
|
|
109
|
+
* origin (a provider's page).
|
|
110
|
+
*/
|
|
111
|
+
private postSigninReference;
|
|
72
112
|
private handleResult;
|
|
73
113
|
private handleError;
|
|
74
114
|
/** Create the bridge modal (once) and render its single happy-path body. */
|
|
@@ -77,7 +117,7 @@ export declare class DialogLauncher {
|
|
|
77
117
|
private hideAlert;
|
|
78
118
|
private scheduleOpenWarning;
|
|
79
119
|
private clearOpenTimer;
|
|
80
|
-
/** "Try again": close any current popup and
|
|
120
|
+
/** "Try again": close any current popup and open a fresh one, as the first opened. */
|
|
81
121
|
private retry;
|
|
82
122
|
/** Fetch branding once and drop the tenant logo into the modal header. */
|
|
83
123
|
private loadBranding;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser side of a sign-in with the account's own identity provider, on
|
|
3
|
+
* the Identity origin's sign-in pages: what the provider's round trip returned
|
|
4
|
+
* in the fragment, and whether this tab already left for the provider without
|
|
5
|
+
* the person's click.
|
|
6
|
+
*
|
|
7
|
+
* The Identity callback returns a sign-in the way it returns a social one
|
|
8
|
+
* (`#token=…&state=…`, completed by `IdentityModule.render`), and its two
|
|
9
|
+
* refusals as fragments of their own (app-sdk identity-signin-contract:
|
|
10
|
+
* federationRefusalFragment writes them, federationRefusalIn reads them),
|
|
11
|
+
* each with the `state` the start sent, read by `IdentityModule.render`
|
|
12
|
+
* before the flow starts:
|
|
13
|
+
* - `interaction_required`: a silent attempt the provider could not answer
|
|
14
|
+
* without the person. The page offers the account's methods, this one
|
|
15
|
+
* first, and never tries silently again.
|
|
16
|
+
* - `failed`: the attempt failed. The page says so in fixed words, never
|
|
17
|
+
* the provider's.
|
|
18
|
+
*/
|
|
19
|
+
import type { FederationRefusal } from '@sparkvault/app-sdk/identity-signin-contract';
|
|
20
|
+
/** The error view's code for a failed sign-in through the account's own identity provider. */
|
|
21
|
+
export declare const FEDERATION_FAILED = "federation_failed";
|
|
22
|
+
/** What a provider round trip this page started returned other than a sign-in. */
|
|
23
|
+
export type FederationReturn = FederationRefusal;
|
|
24
|
+
/** Record that this tab is leaving for the account's provider without the person's click. */
|
|
25
|
+
export declare function markFederationAutoStart(accountId: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Whether this tab left for this account's provider on its own within the
|
|
28
|
+
* state's lifetime. The record is removed either way: whatever it said, the
|
|
29
|
+
* page's next sign-in has read it.
|
|
30
|
+
*/
|
|
31
|
+
export declare function takeFederationAutoStart(accountId: string): boolean;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Identity Module
|
|
3
3
|
*
|
|
4
4
|
* Passwordless sign-in through the first-party SparkVault popup.
|
|
5
|
-
* Supports passkey, OTP, SparkLink, and
|
|
5
|
+
* Supports passkey, OTP, SparkLink, social authentication, and the account's
|
|
6
|
+
* own identity provider.
|
|
6
7
|
*
|
|
7
8
|
* @example Programmatic
|
|
8
9
|
* const result = await sv.products.identity.signIn();
|
|
@@ -26,6 +27,7 @@ export declare class IdentityModule {
|
|
|
26
27
|
private readonly api;
|
|
27
28
|
private renderer;
|
|
28
29
|
private launcher;
|
|
30
|
+
private pendingSignIn;
|
|
29
31
|
constructor(config: ResolvedConfig);
|
|
30
32
|
/**
|
|
31
33
|
* Build a deep link into the person's auth.sv Identity portal — where they
|
|
@@ -83,8 +85,10 @@ export declare class IdentityModule {
|
|
|
83
85
|
* Resilience: pair this with `handleRedirectResult()` on page load. If the
|
|
84
86
|
* popup's result is ever lost (a mobile browser discards the backgrounded
|
|
85
87
|
* opener tab), the next load silently self-heals from the SSO session the
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
+
* popup signed in or chose; a sign-in that opened none (the account's own
|
|
89
|
+
* identity provider) comes back signed out, to sign in again. `flow:
|
|
90
|
+
* 'redirect'` opts a caller out of the popup into a same-tab navigation
|
|
91
|
+
* instead.
|
|
88
92
|
*
|
|
89
93
|
* @example
|
|
90
94
|
* const result = await sv.products.identity.signIn();
|
|
@@ -100,7 +104,9 @@ export declare class IdentityModule {
|
|
|
100
104
|
* Core flow runner. Default mode (no `target`) opens the popup; `flow:
|
|
101
105
|
* 'redirect'` navigates the tab instead; local mode (`renderMode: 'local'` /
|
|
102
106
|
* `target`) renders into the current document and powers the
|
|
103
|
-
* SparkVault-hosted sign-in surfaces (see the internal `render`)
|
|
107
|
+
* SparkVault-hosted sign-in surfaces (see the internal `render`), which
|
|
108
|
+
* hands it what a round trip to the account's own identity provider
|
|
109
|
+
* returned (`federationReturn`).
|
|
104
110
|
*/
|
|
105
111
|
private runFlow;
|
|
106
112
|
/**
|
|
@@ -147,10 +153,13 @@ export declare class IdentityModule {
|
|
|
147
153
|
* `onSuccess` (and resolve with it).
|
|
148
154
|
* 2. A sign-in was in flight but never delivered (a mobile browser
|
|
149
155
|
* discarded the backgrounded opener tab, killing the popup's
|
|
150
|
-
* postMessage) — silently re-mint from the SSO session the
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
156
|
+
* postMessage) — silently re-mint from the SSO session the popup signed
|
|
157
|
+
* in or chose, by navigating this tab through the silent SSO endpoint
|
|
158
|
+
* and straight back with a code (case 1 on return). The bounce names
|
|
159
|
+
* the sign-in's reference, and the endpoint mints only when the
|
|
160
|
+
* session it would mint from carries it. Nothing is shown; with no
|
|
161
|
+
* such session (a sign-in that opened none, such as one through the
|
|
162
|
+
* account's own identity provider) it comes back logged-out, no oracle.
|
|
154
163
|
*
|
|
155
164
|
* The code is one-time, PKCE-bound, and origin-locked — never the token. The
|
|
156
165
|
* host must still verify `result.token` server-side via the Identity JWKS.
|
|
@@ -164,8 +173,8 @@ export declare class IdentityModule {
|
|
|
164
173
|
/** Redeem a returned `#sv_code` (or surface a returned `#sv_error`). */
|
|
165
174
|
private consumeHandoffFragment;
|
|
166
175
|
/**
|
|
167
|
-
* Silently re-mint the sign-in result from the SSO session the
|
|
168
|
-
*
|
|
176
|
+
* Silently re-mint the sign-in result from the SSO session the popup signed
|
|
177
|
+
* in or chose. Navigates this tab through the silent SSO endpoint
|
|
169
178
|
* (a top-level GET, so the `SameSite=Lax` hub cookie rides along) which,
|
|
170
179
|
* PKCE-bound, returns a one-time code in the fragment — handled by case 1 on
|
|
171
180
|
* return. No-op (stays put) if session storage or WebCrypto is unavailable,
|
|
@@ -177,51 +186,59 @@ export declare class IdentityModule {
|
|
|
177
186
|
*/
|
|
178
187
|
private startRecoveryBounce;
|
|
179
188
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* returns via the fragment code;
|
|
183
|
-
*
|
|
189
|
+
* Navigate this tab to the interactive sign-in page: explicit `flow:
|
|
190
|
+
* 'redirect'`, or a popup whose handle COOP severed. Plain sign-in carries
|
|
191
|
+
* redirect_uri + state + PKCE challenge and returns via the fragment code;
|
|
192
|
+
* OIDC/simple modes navigate without them (their server-rendered pages drive
|
|
193
|
+
* the server-validated redirect back). Either carries `signinRef`, the
|
|
194
|
+
* severed popup's reference; a redirect draws none of its own.
|
|
184
195
|
*
|
|
196
|
+
* @param signinRef - The reference the pending marker holds for this
|
|
197
|
+
* sign-in, or null for a page sent without one
|
|
185
198
|
* @returns false when the return leg cannot be armed (no session storage or
|
|
186
199
|
* WebCrypto) — the caller surfaces an actionable error instead of a
|
|
187
200
|
* silent dead-end.
|
|
188
201
|
*/
|
|
189
202
|
private startRedirectFlow;
|
|
190
203
|
/**
|
|
191
|
-
* Arm the PKCE + state return leg
|
|
192
|
-
*
|
|
193
|
-
* Returns null when session storage or WebCrypto is
|
|
194
|
-
* can degrade.
|
|
204
|
+
* Arm the PKCE + state return leg of a handoff navigation and return what
|
|
205
|
+
* the navigation carries for it (redirect_uri = this page, per
|
|
206
|
+
* `currentPageReturnUrl`). Returns null when session storage or WebCrypto is
|
|
207
|
+
* unavailable so callers can degrade.
|
|
195
208
|
*/
|
|
196
|
-
private
|
|
209
|
+
private armHandoffReturn;
|
|
197
210
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* never a different one.
|
|
203
|
-
*/
|
|
204
|
-
private markSignInPending;
|
|
205
|
-
private clearSignInPending;
|
|
206
|
-
/**
|
|
207
|
-
* Consume the pending marker: `fresh` is true once (then cleared) if a recent
|
|
208
|
-
* sign-in is still awaiting its result; `hint` is the identifier that sign-in
|
|
209
|
-
* carried, for the recovery bounce's `login_hint`.
|
|
211
|
+
* Consume the pending marker: the marker once (then cleared) while a recent
|
|
212
|
+
* sign-in is still awaiting its result, else null. Its `hint` is the
|
|
213
|
+
* identifier that sign-in carried, for the recovery bounce's `login_hint`,
|
|
214
|
+
* and its `ref` the sign-in's reference, when the marker holds one.
|
|
210
215
|
*/
|
|
211
216
|
private consumeSignInPending;
|
|
217
|
+
/** Close the popup sign-in's launcher, ending the sign-in it ran. */
|
|
218
|
+
private closeLauncher;
|
|
212
219
|
/** Remove the result fragment from the URL bar (and history entry). */
|
|
213
220
|
private clearUrlFragment;
|
|
214
221
|
/** Drop the one-shot PKCE state/verifier a bounce staged. */
|
|
215
222
|
private clearOneShotAuthState;
|
|
216
223
|
/**
|
|
217
|
-
* Complete a social round trip
|
|
218
|
-
*
|
|
224
|
+
* Complete a social round trip, or one through the account's own identity
|
|
225
|
+
* provider, that returned to the sign-in page as `#token=…&state=…`. Only
|
|
226
|
+
* `render()`, the Identity-origin sign-in page,
|
|
219
227
|
* reads it: no SDK flow returns a `#token` to a site (a site's results arrive
|
|
220
228
|
* by the popup's postMessage, FedCM, or a PKCE-bound `#sv_code`), so on a site
|
|
221
229
|
* it could only be someone else's token, or the site's own direct
|
|
222
230
|
* token-redirect result.
|
|
223
231
|
*/
|
|
224
232
|
private consumeRedirectResult;
|
|
233
|
+
/**
|
|
234
|
+
* Read a refusal a round trip through the account's own identity provider
|
|
235
|
+
* returned to the sign-in page (`#error=…&state=…`, see federation-flow.ts).
|
|
236
|
+
* Such a fragment is consumed exactly once, with the state it answers,
|
|
237
|
+
* whatever it holds. Null for any other fragment, and for a refusal whose
|
|
238
|
+
* state is not the one this browser stored before it left: an answer to no
|
|
239
|
+
* sign-in this browser started, which the page ignores.
|
|
240
|
+
*/
|
|
241
|
+
private consumeFederationReturn;
|
|
225
242
|
/**
|
|
226
243
|
* Close the identity dialog/inline UI if open.
|
|
227
244
|
*
|
|
@@ -248,9 +265,12 @@ export declare class IdentityModule {
|
|
|
248
265
|
/**
|
|
249
266
|
* Render the flow into a page element instead of a popup.
|
|
250
267
|
*
|
|
251
|
-
* A social login
|
|
252
|
-
*
|
|
253
|
-
* `
|
|
268
|
+
* A social login, or one through the account's own identity provider,
|
|
269
|
+
* started here returns to this same page with its result in the fragment,
|
|
270
|
+
* so a returned `#token` is completed first (see `consumeRedirectResult`)
|
|
271
|
+
* instead of starting the flow again, and a returned refusal of the
|
|
272
|
+
* account's own identity provider is handed to the flow it starts (see
|
|
273
|
+
* `consumeFederationReturn`).
|
|
254
274
|
*
|
|
255
275
|
* @internal Used only by the SparkVault-hosted sign-in popup and hosted login
|
|
256
276
|
* page (which own their chrome and pass `renderMode: 'local'`). Customer
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Static metadata for all authentication methods.
|
|
5
5
|
* API returns method IDs; SDK enriches with this metadata for rendering.
|
|
6
6
|
*/
|
|
7
|
-
import type { MethodId, MethodMetadata } from './types';
|
|
7
|
+
import type { MethodId, MethodMetadata, SdkConfigFederation } from './types';
|
|
8
8
|
/**
|
|
9
9
|
* Static method metadata registry
|
|
10
10
|
*/
|
|
@@ -12,6 +12,8 @@ export declare const METHOD_REGISTRY: Record<MethodId, MethodMetadata>;
|
|
|
12
12
|
/**
|
|
13
13
|
* Enrich method IDs with full metadata
|
|
14
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
|
|
15
17
|
* @returns Array of method metadata objects
|
|
16
18
|
*/
|
|
17
|
-
export declare function enrichMethods(ids: MethodId[]): MethodMetadata[];
|
|
19
|
+
export declare function enrichMethods(ids: MethodId[], federation?: SdkConfigFederation | null): MethodMetadata[];
|
|
@@ -0,0 +1,87 @@
|
|
|
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 }`:
|
|
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
|
+
*/
|
|
17
|
+
/** A parsed pending marker. */
|
|
18
|
+
export interface PendingMarker {
|
|
19
|
+
at: number;
|
|
20
|
+
hint: string | null;
|
|
21
|
+
ref: string | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Read and parse the pending marker. Anything unreadable yields null: a value
|
|
25
|
+
* that is not a JSON object, an `at` that is no finite number, or a `ref`
|
|
26
|
+
* that is present but no sign-in reference. A recovery that cannot name the
|
|
27
|
+
* reference its marker records could mint any hub session in this browser, so
|
|
28
|
+
* such a marker recovers nothing.
|
|
29
|
+
*/
|
|
30
|
+
export declare function readPendingMarker(): PendingMarker | null;
|
|
31
|
+
/** True while a marker is within the recovery TTL. */
|
|
32
|
+
export declare function isFreshPendingMarker(marker: PendingMarker | null): marker is PendingMarker;
|
|
33
|
+
/** Remove the pending marker. */
|
|
34
|
+
export declare function removePendingMarker(): void;
|
|
35
|
+
/**
|
|
36
|
+
* One popup sign-in's marker, from its first popup's open until the sign-in
|
|
37
|
+
* settles. Every popup it opens, the first and each "Try again", is an open
|
|
38
|
+
* of its own: it re-arms the marker holding no reference and draws its own
|
|
39
|
+
* reference (signinReferenceInTime), which joins the marker once drawn. A
|
|
40
|
+
* popup that has none asks again, and the same popup is then opened afresh,
|
|
41
|
+
* with a draw of its own. An earlier open's reference is never reused, and
|
|
42
|
+
* its draw, should it land later, is discarded. `reference` is what the
|
|
43
|
+
* current popup is told, and the marker always holds it: a popup can never
|
|
44
|
+
* hold a reference the marker does not.
|
|
45
|
+
*/
|
|
46
|
+
export declare class PendingSignIn {
|
|
47
|
+
private readonly hint;
|
|
48
|
+
private at;
|
|
49
|
+
private live;
|
|
50
|
+
private opens;
|
|
51
|
+
private current;
|
|
52
|
+
private decided;
|
|
53
|
+
constructor(hint: string | null);
|
|
54
|
+
/**
|
|
55
|
+
* The current popup's reference: undefined while its draw is out, null
|
|
56
|
+
* when it has none (its draw failed or missed the deadline, the marker
|
|
57
|
+
* write failed, or the popup already ended), else the reference the marker
|
|
58
|
+
* holds.
|
|
59
|
+
*/
|
|
60
|
+
get reference(): string | null | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* A popup opened, or the current one asked again for the reference it
|
|
63
|
+
* lacks: arm the marker holding no reference, and draw this open's own.
|
|
64
|
+
* Resolves true once this open's reference is decided while its popup is
|
|
65
|
+
* still the current one of a live sign-in, so that popup may be told; false
|
|
66
|
+
* when the popup ended or was replaced, or the sign-in ended. Never
|
|
67
|
+
* rejects.
|
|
68
|
+
*/
|
|
69
|
+
open(draw: () => Promise<string>): Promise<boolean>;
|
|
70
|
+
/**
|
|
71
|
+
* The opener saw the popup end with no result, so there is no lost result
|
|
72
|
+
* to recover: without this, a reload while the retry alert is up would
|
|
73
|
+
* bounce for nothing. The ended popup is told nothing more, and its draw,
|
|
74
|
+
* should it land, is dropped.
|
|
75
|
+
*/
|
|
76
|
+
retire(): void;
|
|
77
|
+
/** The sign-in settled, or another replaced it: retire the marker, and nothing this sign-in does later touches it. */
|
|
78
|
+
end(): void;
|
|
79
|
+
/**
|
|
80
|
+
* The current popup's reference, waiting at most `waitMs` for an open still
|
|
81
|
+
* drawing it: the reference the marker holds, else null (the popup has
|
|
82
|
+
* none, or its draw has not landed in time). Never rejects.
|
|
83
|
+
*/
|
|
84
|
+
referenceWithin(waitMs: number): Promise<string | null>;
|
|
85
|
+
/** Write the marker; a write that fails leaves the stored marker as it was. */
|
|
86
|
+
private write;
|
|
87
|
+
}
|
|
@@ -47,6 +47,18 @@ export interface OpenPopupOptions {
|
|
|
47
47
|
readyType?: string;
|
|
48
48
|
/** Called when a `readyType` message arrives from the trusted origin. */
|
|
49
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;
|
|
50
62
|
}
|
|
51
63
|
/**
|
|
52
64
|
* Open a popup and resolve with the first validated result envelope it posts.
|