@sparkvault/sdk-js 16.0.1 → 16.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 +2 -0
- package/dist/index.cjs +1735 -636
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +126 -41
- package/dist/index.mjs +1735 -636
- 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/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
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import type { VerifyOptions, VerifyResult } from './types';
|
|
8
8
|
import { IdentityApi } from './api';
|
|
9
9
|
import type { Container } from './container';
|
|
10
|
+
import { type FederationReturn } from './federation-flow';
|
|
10
11
|
interface RendererCallbacks {
|
|
11
12
|
onSuccess: (result: VerifyResult) => void;
|
|
12
13
|
onError: (error: Error) => void;
|
|
@@ -33,7 +34,17 @@ export declare class IdentityRenderer {
|
|
|
33
34
|
private sparkLinkVisibilityHandler;
|
|
34
35
|
private sparkLinkClaiming;
|
|
35
36
|
private sparkLinkRetryTimer;
|
|
36
|
-
|
|
37
|
+
private federationReturn;
|
|
38
|
+
private federationMayAutoStart;
|
|
39
|
+
private pageRestoreHandler;
|
|
40
|
+
private readonly askReference;
|
|
41
|
+
private referenceAsk;
|
|
42
|
+
private referenceAsks;
|
|
43
|
+
private readonly offeredWithoutReference;
|
|
44
|
+
private untouchedStep;
|
|
45
|
+
private statusRegion;
|
|
46
|
+
private statusTimer;
|
|
47
|
+
constructor(container: Container, api: IdentityApi, options: VerifyOptions, callbacks: RendererCallbacks, federationReturn?: FederationReturn | null);
|
|
37
48
|
/**
|
|
38
49
|
* Seed the verification identity from the render options, deriving the
|
|
39
50
|
* channel (email vs phone) from the value itself rather than trusting which
|
|
@@ -114,6 +125,72 @@ export declare class IdentityRenderer {
|
|
|
114
125
|
private get viewState();
|
|
115
126
|
private setState;
|
|
116
127
|
private showInitialAuthStep;
|
|
128
|
+
/**
|
|
129
|
+
* The account's own identity provider as the flow's first step. A failed
|
|
130
|
+
* round trip is said first. Otherwise the provider may start on its own
|
|
131
|
+
* (startFederationAutomatically). Returns true when it took the step.
|
|
132
|
+
*/
|
|
133
|
+
private startWithFederation;
|
|
134
|
+
/**
|
|
135
|
+
* Leave for the account's own identity provider without the person's
|
|
136
|
+
* click, while this page offers it and it starts on its own
|
|
137
|
+
* (federationStartsOnItsOwn). Returns true when it left.
|
|
138
|
+
*/
|
|
139
|
+
private startFederationAutomatically;
|
|
140
|
+
/**
|
|
141
|
+
* Whether the given account's own identity provider starts without the
|
|
142
|
+
* person's click while this page may still leave on its own: when the
|
|
143
|
+
* account asks for a silent attempt (`federation.silent`: the provider
|
|
144
|
+
* answers without showing anything, and a refusal comes back as
|
|
145
|
+
* `interaction_required`) or the caller asked for it (`method:
|
|
146
|
+
* 'federation'`, interactive unless the account asks for the silent
|
|
147
|
+
* attempt).
|
|
148
|
+
*/
|
|
149
|
+
private federationStartsOnItsOwn;
|
|
150
|
+
/**
|
|
151
|
+
* The account's own identity provider while a step for this identifier
|
|
152
|
+
* lacks it only because the page's ask for the sign-in's reference is still
|
|
153
|
+
* out: with the reference held, the provider would be on that step, so the
|
|
154
|
+
* step holds every automatic advance a held reference would not have made.
|
|
155
|
+
* Once the reference lands the provider joins the step, or starts on its
|
|
156
|
+
* own from the untouched first step (offerArrivedReference); an ask that
|
|
157
|
+
* finds none leaves the held step up for the person's tap.
|
|
158
|
+
*/
|
|
159
|
+
private federationAwaitingReference;
|
|
160
|
+
/**
|
|
161
|
+
* Ask the page for the sign-in's reference (VerifyOptions.signinRef as a
|
|
162
|
+
* function) without waiting on the answer: the flow goes on, and the
|
|
163
|
+
* answer joins it when it lands. A call that throws or rejects, and an
|
|
164
|
+
* answer that is no reference, found none.
|
|
165
|
+
*/
|
|
166
|
+
private requestReference;
|
|
167
|
+
/** The reference arrived: every completing call from now on carries it, and the step offers the provider. */
|
|
168
|
+
private referenceArrived;
|
|
169
|
+
/**
|
|
170
|
+
* The ask found no reference for now. An account with other ways in
|
|
171
|
+
* simply keeps them; a person waiting on the provider as the only way in
|
|
172
|
+
* is told to try again.
|
|
173
|
+
*/
|
|
174
|
+
private referenceUnavailable;
|
|
175
|
+
/** The person's Try Again: ask again, and show the sign-in step meanwhile. */
|
|
176
|
+
private retryReference;
|
|
177
|
+
/**
|
|
178
|
+
* Offer the account's own identity provider on the step that offers it,
|
|
179
|
+
* now that the page holds its reference. On the sign-in step as it first
|
|
180
|
+
* showed, still untouched, the provider starts on its own as it would have
|
|
181
|
+
* with the reference held from the start; otherwise its button joins the
|
|
182
|
+
* step in place, keeping what the person typed and their focus. A person
|
|
183
|
+
* who has moved past that step sees nothing change, and the step offers
|
|
184
|
+
* the provider whenever it shows again.
|
|
185
|
+
*/
|
|
186
|
+
private offerArrivedReference;
|
|
187
|
+
/**
|
|
188
|
+
* The sign-in's own first step: the method list when no identifier is
|
|
189
|
+
* asked for (or one is already known), the discoverable passkey ceremony for
|
|
190
|
+
* a returning browser, else the identifier field (which leads with the
|
|
191
|
+
* account's own identity provider when it offers one).
|
|
192
|
+
*/
|
|
193
|
+
private showSignInStep;
|
|
117
194
|
/**
|
|
118
195
|
* True when the discoverable ceremony may be started without a gesture and
|
|
119
196
|
* this verification actually offers passkey login: the flow runs on the
|
|
@@ -136,6 +213,14 @@ export declare class IdentityRenderer {
|
|
|
136
213
|
*/
|
|
137
214
|
private cancelDiscoverableVerify;
|
|
138
215
|
private render;
|
|
216
|
+
/** Place the empty live region beside the flow content, once per container. */
|
|
217
|
+
private placeStatusRegion;
|
|
218
|
+
/**
|
|
219
|
+
* Put `words` in the live region, a moment after the view that says them
|
|
220
|
+
* is in place, so they never land in the same change as the region or the
|
|
221
|
+
* view that holds them; empty words clear it at once.
|
|
222
|
+
*/
|
|
223
|
+
private announce;
|
|
139
224
|
private destroyCurrentView;
|
|
140
225
|
/**
|
|
141
226
|
* Replace the mounted view with a Google-style height morph: the flow region
|
|
@@ -160,8 +245,17 @@ export declare class IdentityRenderer {
|
|
|
160
245
|
* its sender held to a passkey admits the passkey alone, so a person the
|
|
161
246
|
* check found holding none is told the request needs a passkey already
|
|
162
247
|
* registered with SparkVault and that only the sender can resend it at a
|
|
163
|
-
* level they can clear: no retry here changes that.
|
|
164
|
-
*
|
|
248
|
+
* level they can clear: no retry here changes that. An account whose
|
|
249
|
+
* remaining way in is its own identity provider, which this page does not
|
|
250
|
+
* offer now (see `federationOffered`), depends on why:
|
|
251
|
+
* - the page can never hold a reference (an SDK that predates it opened
|
|
252
|
+
* the page): the site must update its sign-in, and no retry here changes
|
|
253
|
+
* that;
|
|
254
|
+
* - the page's ask for its reference is still out: the step waits for it;
|
|
255
|
+
* - the ask found none for now: the person is told to try again, which
|
|
256
|
+
* asks again.
|
|
257
|
+
* Any other verification with nothing to offer is a configuration fault,
|
|
258
|
+
* shown as one.
|
|
165
259
|
*/
|
|
166
260
|
private noMethodState;
|
|
167
261
|
private handleIdentitySubmit;
|
|
@@ -225,6 +319,51 @@ export declare class IdentityRenderer {
|
|
|
225
319
|
* service through the Identity origin, the page's own.
|
|
226
320
|
*/
|
|
227
321
|
private handleSocialLogin;
|
|
322
|
+
/**
|
|
323
|
+
* The account's own identity provider, while this verification offers it:
|
|
324
|
+
* this page offers it now (federationOffered), `/config` describes it, and
|
|
325
|
+
* the verification's methods list it. A verify session's methods never do,
|
|
326
|
+
* for such a sign-in cannot complete one.
|
|
327
|
+
*/
|
|
328
|
+
private get federation();
|
|
329
|
+
/**
|
|
330
|
+
* Whether this page offers the account's own identity provider now (see
|
|
331
|
+
* VerifyOptions.signinRef): while it holds its sign-in's reference, or
|
|
332
|
+
* when it completes in its own window.
|
|
333
|
+
*/
|
|
334
|
+
private get federationOffered();
|
|
335
|
+
/** The account's own identity provider while `/config` describes it and the verification's methods list it. */
|
|
336
|
+
private get accountFederation();
|
|
337
|
+
/**
|
|
338
|
+
* Whether a list of methods offers the account's own identity provider
|
|
339
|
+
* beside the identifier it is for. It needs no identifier, so the first
|
|
340
|
+
* step offers it (above the identifier field, or in a list with none), and
|
|
341
|
+
* so does a list for an identifier the flow supplied, whose person never saw
|
|
342
|
+
* that step. An identifier the person typed came from the identifier
|
|
343
|
+
* field, which already offered it.
|
|
344
|
+
*/
|
|
345
|
+
private offersFederationBeside;
|
|
346
|
+
/** The identifier field's leading method: the account's own identity provider, when offered. */
|
|
347
|
+
private leadingFederationMethod;
|
|
348
|
+
/**
|
|
349
|
+
* Leave for the account's own identity provider, the way a social sign-in
|
|
350
|
+
* leaves (handleSocialLogin): the round trip returns to this page, query
|
|
351
|
+
* intact, the state stored here is what its `#token` (or its refusal's
|
|
352
|
+
* fragment) must answer, and the start carries the sign-in's reference
|
|
353
|
+
* when the page holds one. A silent attempt shows a status the whole time
|
|
354
|
+
* it runs. A start without the person's click (`automatic`) is recorded, so
|
|
355
|
+
* a person who comes Back from the provider's page is not sent on again.
|
|
356
|
+
*/
|
|
357
|
+
private leaveForFederation;
|
|
358
|
+
/**
|
|
359
|
+
* A browser that restores this page from its back/forward cache, as the
|
|
360
|
+
* person comes Back from the provider, runs nothing again, so the page would
|
|
361
|
+
* keep the wait it left on. Show the sign-in's first step instead, with the
|
|
362
|
+
* automatic start spent.
|
|
363
|
+
*/
|
|
364
|
+
private watchForPageRestore;
|
|
365
|
+
/** The failure of a sign-in through the account's own identity provider, in fixed words, never the provider's. */
|
|
366
|
+
private federationFailedState;
|
|
228
367
|
private normalizeError;
|
|
229
368
|
/**
|
|
230
369
|
* Check if error is a session/token expiration that should redirect to identity input.
|
|
@@ -37,6 +37,7 @@ export declare class VerificationState {
|
|
|
37
37
|
private _recipient;
|
|
38
38
|
private _identityType;
|
|
39
39
|
private _authContext;
|
|
40
|
+
private _signinRef;
|
|
40
41
|
private readonly _passkey;
|
|
41
42
|
private readonly _otp;
|
|
42
43
|
get sdkConfig(): SdkConfig | null;
|
|
@@ -65,6 +66,9 @@ export declare class VerificationState {
|
|
|
65
66
|
getAllowedIdentityTypes(): IdentityType[];
|
|
66
67
|
get authContext(): AuthContext | undefined;
|
|
67
68
|
setAuthContext(context: AuthContext | undefined): void;
|
|
69
|
+
/** The reference every call that completes this sign-in carries, else null. */
|
|
70
|
+
get signinRef(): string | null;
|
|
71
|
+
setSigninRef(signinRef: string | null): void;
|
|
68
72
|
get passkey(): Readonly<PasskeyState>;
|
|
69
73
|
setPasskeyStatus(hasPasskey: boolean | null): void;
|
|
70
74
|
enablePasskeyFallback(): void;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Identity Module Types
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The kind of identifier a sign-in verified. `federated` is a person the
|
|
6
|
+
* account's own identity provider signed in: one person of that account's
|
|
7
|
+
* directory alone, never a global identity.
|
|
8
|
+
*/
|
|
9
|
+
export type VerifiedIdentityType = 'email' | 'phone' | 'social' | 'federated';
|
|
5
10
|
/**
|
|
6
11
|
* Auth context for OIDC or simple redirect flows.
|
|
7
12
|
* Used by hosted login pages to complete authorization flows.
|
|
@@ -79,6 +84,15 @@ export interface VerifyOptions {
|
|
|
79
84
|
* account exists. Any other value is dropped at URL serialization.
|
|
80
85
|
*/
|
|
81
86
|
prompt?: 'select_account';
|
|
87
|
+
/**
|
|
88
|
+
* `'federation'` starts sign-in with the account's own identity provider
|
|
89
|
+
* at once: the sign-in page skips its account chooser and the method list
|
|
90
|
+
* and leaves for the provider. Honoured only while the account has its
|
|
91
|
+
* identity provider switched on; otherwise the page starts as usual,
|
|
92
|
+
* account chooser included. Any other value is dropped at URL
|
|
93
|
+
* serialization.
|
|
94
|
+
*/
|
|
95
|
+
method?: 'federation';
|
|
82
96
|
/**
|
|
83
97
|
* Rendering strategy (internal). `'local'` renders the flow directly in this
|
|
84
98
|
* document — used inside the popup that runs the flow, and forced for inline
|
|
@@ -86,6 +100,46 @@ export interface VerifyOptions {
|
|
|
86
100
|
* opens the popup.
|
|
87
101
|
*/
|
|
88
102
|
renderMode?: 'local';
|
|
103
|
+
/**
|
|
104
|
+
* The sign-in's reference (internal): set by the SparkVault sign-in page
|
|
105
|
+
* that runs the flow, never by a site. Every call that completes the
|
|
106
|
+
* sign-in from the page carries the reference the flow holds at that
|
|
107
|
+
* moment, and so does a start through the account's own identity
|
|
108
|
+
* provider, so Identity records it on the hub session the sign-in creates
|
|
109
|
+
* or chooses (or, for the provider, which opens none, releases it from the
|
|
110
|
+
* browser's hub sessions), and a lost popup result recovers that sign-in
|
|
111
|
+
* only. The flow offers the provider only on an explicit signal: a
|
|
112
|
+
* reference held, or `completesInWindow`. The reference never holds up the
|
|
113
|
+
* sign-in: a call made before it arrives carries none.
|
|
114
|
+
* - A reference: held from the start. The provider is offered. A value
|
|
115
|
+
* that is no reference is `null`.
|
|
116
|
+
* - A function: the reference arrives after the flow renders. The flow
|
|
117
|
+
* calls it once as it starts, and again only on the person's Try Again;
|
|
118
|
+
* each call asks afresh, and resolves to a reference, or to null when
|
|
119
|
+
* none could be had for now (a rejection, or a value that is no
|
|
120
|
+
* reference, is null too). The provider is offered once a reference
|
|
121
|
+
* arrives. Until then an account with other methods shows those; one
|
|
122
|
+
* whose only way in is the provider waits for it, and is told to try
|
|
123
|
+
* again when none could be had.
|
|
124
|
+
* - `null`: the page can never hold one (an SDK that predates the
|
|
125
|
+
* reference opened it), so the provider is never offered: such a
|
|
126
|
+
* sign-in opens no hub session, and its lost result could recover
|
|
127
|
+
* another person's.
|
|
128
|
+
* - Omitted: the provider is offered only when the page says it completes
|
|
129
|
+
* in its own window (`completesInWindow`); never for a page that predates
|
|
130
|
+
* the reference, whatever its window.
|
|
131
|
+
*/
|
|
132
|
+
signinRef?: string | null | (() => Promise<string | null>);
|
|
133
|
+
/**
|
|
134
|
+
* The sign-in completes in this window (internal): set by the SparkVault
|
|
135
|
+
* hosted sign-in page, which finishes an authorization request where it
|
|
136
|
+
* runs (an authorization code to the relying party, or a simple-mode
|
|
137
|
+
* redirect) and never hands its result to an opener. No recovery ever
|
|
138
|
+
* stands in for that result, so the page offers the account's own identity
|
|
139
|
+
* provider without a reference, in a popup too. Ignored when `signinRef`
|
|
140
|
+
* is given.
|
|
141
|
+
*/
|
|
142
|
+
completesInWindow?: boolean;
|
|
89
143
|
/** Called when user cancels (if omitted, uses server-configured redirect) */
|
|
90
144
|
onCancel?: () => void;
|
|
91
145
|
/** Called when verification completes (if omitted, uses server-configured redirect) */
|
|
@@ -103,6 +157,8 @@ export interface AttachOptions {
|
|
|
103
157
|
authContext?: AuthContext;
|
|
104
158
|
/** `'select_account'` always shows the account chooser (see `VerifyOptions.prompt`) */
|
|
105
159
|
prompt?: 'select_account';
|
|
160
|
+
/** `'federation'` starts with the account's own identity provider (see `VerifyOptions.method`) */
|
|
161
|
+
method?: 'federation';
|
|
106
162
|
/** Called when user cancels */
|
|
107
163
|
onCancel?: () => void;
|
|
108
164
|
/** Called when verification completes */
|
|
@@ -155,10 +211,11 @@ export interface VerifyResult {
|
|
|
155
211
|
}
|
|
156
212
|
/**
|
|
157
213
|
* Options for `signIn()` — the customer-facing popup sign-in. The popup owns its
|
|
158
|
-
* rendering, so there is no inline `target`/`renderMode`/`chrome
|
|
159
|
-
* are internal to the SparkVault-hosted
|
|
214
|
+
* rendering, so there is no inline `target`/`renderMode`/`chrome`/`signinRef`/
|
|
215
|
+
* `completesInWindow` here; those are internal to the SparkVault-hosted
|
|
216
|
+
* sign-in surfaces.
|
|
160
217
|
*/
|
|
161
|
-
export type SignInOptions = Omit<VerifyOptions, 'target' | 'renderMode' | 'chrome'>;
|
|
218
|
+
export type SignInOptions = Omit<VerifyOptions, 'target' | 'renderMode' | 'chrome' | 'signinRef' | 'completesInWindow'>;
|
|
162
219
|
/** The verified identity returned by `signIn()`. */
|
|
163
220
|
export type SignInResult = VerifyResult;
|
|
164
221
|
/**
|
|
@@ -214,6 +271,14 @@ export interface TokenClaims {
|
|
|
214
271
|
verified_at: number;
|
|
215
272
|
/** Authentication method used */
|
|
216
273
|
method: string;
|
|
274
|
+
/**
|
|
275
|
+
* Only on a `federated` sign-in whose provider asserted an email: the
|
|
276
|
+
* address as the provider sent it. The provider may assert an address it
|
|
277
|
+
* never verified, so it is no identifier: key people by `sub`.
|
|
278
|
+
*/
|
|
279
|
+
email?: string;
|
|
280
|
+
/** Only beside `email`: true only when the provider said it verified the address. */
|
|
281
|
+
email_verified?: boolean;
|
|
217
282
|
/**
|
|
218
283
|
* The person's public avatar URL (my.auth.sv), present only when they have a visible
|
|
219
284
|
* avatar. The URL always renders an image — their photo, or a neutral placeholder.
|
|
@@ -228,7 +293,16 @@ export interface SdkConfigBranding {
|
|
|
228
293
|
themeMode?: 'light' | 'dark';
|
|
229
294
|
}
|
|
230
295
|
/** Method ID returned by config endpoint */
|
|
231
|
-
export type MethodId = 'otp_email' | 'otp_sms' | 'otp_voice' | 'passkey' | 'sparklink' | 'social_google' | 'social_apple' | 'social_microsoft' | 'social_github' | 'social_facebook' | 'social_linkedin';
|
|
296
|
+
export type MethodId = 'otp_email' | 'otp_sms' | 'otp_voice' | 'passkey' | 'sparklink' | 'social_google' | 'social_apple' | 'social_microsoft' | 'social_github' | 'social_facebook' | 'social_linkedin' | 'federation';
|
|
297
|
+
/**
|
|
298
|
+
* The account's own identity provider, as `/config` describes it while it is
|
|
299
|
+
* switched on: the name its button shows ("Continue with {display_name}"),
|
|
300
|
+
* and whether the sign-in page tries it silently first.
|
|
301
|
+
*/
|
|
302
|
+
export interface SdkConfigFederation {
|
|
303
|
+
display_name: string;
|
|
304
|
+
silent: boolean;
|
|
305
|
+
}
|
|
232
306
|
export interface SdkConfig {
|
|
233
307
|
accountId: string;
|
|
234
308
|
/** Branding configuration (optional in v1 - uses defaults if not provided) */
|
|
@@ -245,11 +319,13 @@ export interface SdkConfig {
|
|
|
245
319
|
sso?: {
|
|
246
320
|
enabled: boolean;
|
|
247
321
|
};
|
|
322
|
+
/** The account's own identity provider; present only while `methods` lists `federation`. */
|
|
323
|
+
federation?: SdkConfigFederation;
|
|
248
324
|
}
|
|
249
325
|
/** Method metadata for SDK rendering (static lookup) */
|
|
250
326
|
export interface MethodMetadata {
|
|
251
327
|
id: MethodId;
|
|
252
|
-
type: 'otp' | 'passkey' | 'sparklink' | 'social';
|
|
328
|
+
type: 'otp' | 'passkey' | 'sparklink' | 'social' | 'federation';
|
|
253
329
|
/** Which identifier type this method requires. Passkeys are SVID-scoped and do not require one. */
|
|
254
330
|
identityType?: 'email' | 'phone';
|
|
255
331
|
name: string;
|
|
@@ -386,6 +462,8 @@ export interface SparkLinkSendResponse {
|
|
|
386
462
|
}
|
|
387
463
|
export type IdentityViewState = {
|
|
388
464
|
view: 'loading';
|
|
465
|
+
} | {
|
|
466
|
+
view: 'awaiting-reference';
|
|
389
467
|
} | {
|
|
390
468
|
view: 'identity-input';
|
|
391
469
|
error?: string;
|
|
@@ -437,6 +515,9 @@ export type IdentityViewState = {
|
|
|
437
515
|
} | {
|
|
438
516
|
view: 'oauth-pending';
|
|
439
517
|
provider: string;
|
|
518
|
+
} | {
|
|
519
|
+
view: 'federation-checking';
|
|
520
|
+
displayName: string;
|
|
440
521
|
} | {
|
|
441
522
|
view: 'error';
|
|
442
523
|
message: string;
|
|
@@ -16,18 +16,37 @@ export declare function arrayBufferToBase64url(buffer: ArrayBuffer): string;
|
|
|
16
16
|
* in.
|
|
17
17
|
*/
|
|
18
18
|
export declare function currentPageReturnUrl(): string;
|
|
19
|
-
/**
|
|
19
|
+
/** The PKCE + state return leg a handoff navigation carries back to this page. */
|
|
20
20
|
export interface SigninUrlRedirectExtras {
|
|
21
21
|
redirectUri: string;
|
|
22
22
|
state: string;
|
|
23
23
|
codeChallenge: string;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* How the sign-in page is delivered, and so how it learns its sign-in's
|
|
27
|
+
* reference (app-sdk SIGNIN_REFERENCE):
|
|
28
|
+
* - `popup`: the page opens in a popup inside the click, before any draw can
|
|
29
|
+
* finish, so its URL says the opener posts the reference.
|
|
30
|
+
* - `redirect`: this tab navigates there. A reference rides in the URL; with
|
|
31
|
+
* none, the URL says no recovery stands in for the page's result
|
|
32
|
+
* (`noRecoveryValue`): the caller holds no pending marker for it. `handoff`
|
|
33
|
+
* arms the return to this page as a one-time code in the fragment; an OIDC
|
|
34
|
+
* auth request or a verify session navigates without it, its page driving
|
|
35
|
+
* the return.
|
|
36
|
+
*/
|
|
37
|
+
export type SigninPageDelivery = {
|
|
38
|
+
kind: 'popup';
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'redirect';
|
|
41
|
+
signinRef: string | null;
|
|
42
|
+
handoff?: SigninUrlRedirectExtras;
|
|
43
|
+
};
|
|
25
44
|
/**
|
|
26
45
|
* Build the sign-in page URL on the Identity origin. Single source for BOTH
|
|
27
46
|
* delivery modes: the popup (opener + postMessage) and the same-tab redirect
|
|
28
47
|
* (redirect_uri + state + code_challenge → one-time code in the fragment).
|
|
29
48
|
*/
|
|
30
|
-
export declare function buildSigninUrl(config: ResolvedConfig, options: VerifyOptions,
|
|
49
|
+
export declare function buildSigninUrl(config: ResolvedConfig, options: VerifyOptions, delivery: SigninPageDelivery): string;
|
|
31
50
|
/**
|
|
32
51
|
* Warm the connection to another origin by injecting `<link rel="preconnect">`
|
|
33
52
|
* hints (one plain for top-level navigations, one `crossorigin` for CORS
|
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
export interface View {
|
|
11
11
|
render(): HTMLElement;
|
|
12
12
|
destroy?(): void;
|
|
13
|
+
/**
|
|
14
|
+
* What the page announces as its status while this view shows: the
|
|
15
|
+
* renderer writes it into its one live region, which stays in the page
|
|
16
|
+
* across views so the change is heard. None for a view with nothing to say.
|
|
17
|
+
*/
|
|
18
|
+
readonly announcement?: string;
|
|
13
19
|
}
|
|
14
20
|
/**
|
|
15
21
|
* Create an element with optional attributes and children.
|
|
@@ -20,6 +20,18 @@ export declare const IDENTITY_BLOCKED_ERROR_CODES: readonly ["identity_trial_exh
|
|
|
20
20
|
* level they can clear (the message says so).
|
|
21
21
|
*/
|
|
22
22
|
export declare const STRONGER_VERIFICATION_REQUIRED_CODE = "stronger_verification_required";
|
|
23
|
+
/**
|
|
24
|
+
* The code of a sign-in whose only way in is the account's own identity
|
|
25
|
+
* provider, on a page that may not offer it: the site's sign-in predates what
|
|
26
|
+
* that provider needs, so only the site updating it clears this.
|
|
27
|
+
*/
|
|
28
|
+
export declare const FEDERATION_UNAVAILABLE_CODE = "federation_unavailable";
|
|
29
|
+
/**
|
|
30
|
+
* The code of a sign-in whose only way in is the account's own identity
|
|
31
|
+
* provider, on a page that could not get its sign-in's reference just now:
|
|
32
|
+
* a genuine error, which the person's Try Again asks for again.
|
|
33
|
+
*/
|
|
34
|
+
export declare const SIGNIN_REFERENCE_UNAVAILABLE_CODE = "signin_reference_unavailable";
|
|
23
35
|
export interface ErrorViewProps {
|
|
24
36
|
message: string;
|
|
25
37
|
code: string;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* number is typed. A field that takes a phone number carries the SMS and voice
|
|
8
8
|
* consent beneath it.
|
|
9
9
|
*/
|
|
10
|
+
import type { MethodMetadata } from '../types';
|
|
10
11
|
import type { View } from './base';
|
|
11
12
|
export type IdentityType = 'email' | 'phone';
|
|
12
13
|
export interface IdentityInputResult {
|
|
@@ -28,13 +29,30 @@ export interface IdentityInputViewProps {
|
|
|
28
29
|
* whose auto-started prompt was dismissed.
|
|
29
30
|
*/
|
|
30
31
|
onPasskey?: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* A method that needs no identifier, offered above the field: the account's
|
|
34
|
+
* own identity provider, whose people sign in without typing anything here.
|
|
35
|
+
* One the flow can offer only later joins the view through
|
|
36
|
+
* `offerLeadingMethod`.
|
|
37
|
+
*/
|
|
38
|
+
leadingMethod?: LeadingMethod;
|
|
39
|
+
/** Called each time the person edits the field. */
|
|
40
|
+
onType?: () => void;
|
|
41
|
+
}
|
|
42
|
+
/** A method offered above the identifier field, and what its click does. */
|
|
43
|
+
export interface LeadingMethod {
|
|
44
|
+
method: MethodMetadata;
|
|
45
|
+
onSelect: () => void;
|
|
31
46
|
}
|
|
32
47
|
export declare class IdentityInputView implements View {
|
|
33
48
|
private readonly props;
|
|
49
|
+
private container;
|
|
34
50
|
private inputElement;
|
|
35
51
|
private labelElement;
|
|
36
52
|
private submitButton;
|
|
37
53
|
private passkeyLink;
|
|
54
|
+
private leadingButton;
|
|
55
|
+
private leadingHandler;
|
|
38
56
|
private errorContainer;
|
|
39
57
|
private focusTimeoutId;
|
|
40
58
|
private detectedType;
|
|
@@ -47,6 +65,12 @@ export declare class IdentityInputView implements View {
|
|
|
47
65
|
private get allowsEmail();
|
|
48
66
|
private get allowsPhone();
|
|
49
67
|
render(): HTMLElement;
|
|
68
|
+
/**
|
|
69
|
+
* Offer `leading` above the field, set apart by "or". On a view already on
|
|
70
|
+
* screen it joins in place, so what the person typed and where their focus
|
|
71
|
+
* is stay as they were. A view that already leads with a method keeps it.
|
|
72
|
+
*/
|
|
73
|
+
offerLeadingMethod(leading: LeadingMethod): void;
|
|
50
74
|
private getSubtitleText;
|
|
51
75
|
private getLabelText;
|
|
52
76
|
private getPlaceholderText;
|
|
@@ -6,9 +6,17 @@
|
|
|
6
6
|
import type { View } from './base';
|
|
7
7
|
export interface LoadingViewProps {
|
|
8
8
|
message?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Announce the message as the page's status, for a wait whose words say
|
|
11
|
+
* what is happening: the renderer's live region carries it, so the spinner
|
|
12
|
+
* and the visible words are hidden from assistive technology. Otherwise
|
|
13
|
+
* the spinner is the status, named "Loading".
|
|
14
|
+
*/
|
|
15
|
+
announce?: boolean;
|
|
9
16
|
}
|
|
10
17
|
export declare class LoadingView implements View {
|
|
11
18
|
private readonly message;
|
|
19
|
+
readonly announcement?: string;
|
|
12
20
|
constructor(props?: LoadingViewProps);
|
|
13
21
|
render(): HTMLElement;
|
|
14
22
|
destroy(): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Method Button
|
|
3
|
+
*
|
|
4
|
+
* A sign-in method's button, drawn one way wherever a method is offered: the
|
|
5
|
+
* method list, and the identifier step that leads with the account's own
|
|
6
|
+
* identity provider. The caller attaches its click handler, and removes it.
|
|
7
|
+
*/
|
|
8
|
+
import type { MethodMetadata } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* The button: its glyph, hidden from assistive technology so the button is
|
|
11
|
+
* named by its words alone; the method's name; and its description, when it
|
|
12
|
+
* has one.
|
|
13
|
+
*/
|
|
14
|
+
export declare function methodButton(method: MethodMetadata): HTMLButtonElement;
|
|
@@ -21,14 +21,20 @@ export interface MethodSelectViewProps {
|
|
|
21
21
|
export declare class MethodSelectView implements View {
|
|
22
22
|
private readonly props;
|
|
23
23
|
private backLink;
|
|
24
|
+
private methodsContainer;
|
|
24
25
|
private methodButtons;
|
|
25
26
|
private readonly boundHandleBack;
|
|
26
27
|
private readonly methodClickHandlers;
|
|
27
28
|
constructor(props: MethodSelectViewProps);
|
|
28
29
|
render(): HTMLElement;
|
|
30
|
+
/**
|
|
31
|
+
* Put `method` at the head of a list already on screen, in place, so the
|
|
32
|
+
* person's focus stays where it was. The method sends no text or call (the
|
|
33
|
+
* account's own identity provider), so the list's consent stands as it is.
|
|
34
|
+
*/
|
|
35
|
+
offerLeadingMethod(method: MethodMetadata): void;
|
|
29
36
|
private createBackLink;
|
|
30
37
|
private createMethodButton;
|
|
31
|
-
private getMethodIcon;
|
|
32
38
|
/**
|
|
33
39
|
* Clean up event listeners to prevent memory leaks.
|
|
34
40
|
*/
|