@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
package/dist/index.d.ts
CHANGED
|
@@ -167,7 +167,12 @@ declare class HttpClient {
|
|
|
167
167
|
/**
|
|
168
168
|
* Identity Module Types
|
|
169
169
|
*/
|
|
170
|
-
|
|
170
|
+
/**
|
|
171
|
+
* The kind of identifier a sign-in verified. `federated` is a person the
|
|
172
|
+
* account's own identity provider signed in: one person of that account's
|
|
173
|
+
* directory alone, never a global identity.
|
|
174
|
+
*/
|
|
175
|
+
type VerifiedIdentityType = 'email' | 'phone' | 'social' | 'federated';
|
|
171
176
|
/**
|
|
172
177
|
* Auth context for OIDC or simple redirect flows.
|
|
173
178
|
* Used by hosted login pages to complete authorization flows.
|
|
@@ -245,6 +250,15 @@ interface VerifyOptions {
|
|
|
245
250
|
* account exists. Any other value is dropped at URL serialization.
|
|
246
251
|
*/
|
|
247
252
|
prompt?: 'select_account';
|
|
253
|
+
/**
|
|
254
|
+
* `'federation'` starts sign-in with the account's own identity provider
|
|
255
|
+
* at once: the sign-in page skips its account chooser and the method list
|
|
256
|
+
* and leaves for the provider. Honoured only while the account has its
|
|
257
|
+
* identity provider switched on; otherwise the page starts as usual,
|
|
258
|
+
* account chooser included. Any other value is dropped at URL
|
|
259
|
+
* serialization.
|
|
260
|
+
*/
|
|
261
|
+
method?: 'federation';
|
|
248
262
|
/**
|
|
249
263
|
* Rendering strategy (internal). `'local'` renders the flow directly in this
|
|
250
264
|
* document — used inside the popup that runs the flow, and forced for inline
|
|
@@ -252,6 +266,46 @@ interface VerifyOptions {
|
|
|
252
266
|
* opens the popup.
|
|
253
267
|
*/
|
|
254
268
|
renderMode?: 'local';
|
|
269
|
+
/**
|
|
270
|
+
* The sign-in's reference (internal): set by the SparkVault sign-in page
|
|
271
|
+
* that runs the flow, never by a site. Every call that completes the
|
|
272
|
+
* sign-in from the page carries the reference the flow holds at that
|
|
273
|
+
* moment, and so does a start through the account's own identity
|
|
274
|
+
* provider, so Identity records it on the hub session the sign-in creates
|
|
275
|
+
* or chooses (or, for the provider, which opens none, releases it from the
|
|
276
|
+
* browser's hub sessions), and a lost popup result recovers that sign-in
|
|
277
|
+
* only. The flow offers the provider only on an explicit signal: a
|
|
278
|
+
* reference held, or `completesInWindow`. The reference never holds up the
|
|
279
|
+
* sign-in: a call made before it arrives carries none.
|
|
280
|
+
* - A reference: held from the start. The provider is offered. A value
|
|
281
|
+
* that is no reference is `null`.
|
|
282
|
+
* - A function: the reference arrives after the flow renders. The flow
|
|
283
|
+
* calls it once as it starts, and again only on the person's Try Again;
|
|
284
|
+
* each call asks afresh, and resolves to a reference, or to null when
|
|
285
|
+
* none could be had for now (a rejection, or a value that is no
|
|
286
|
+
* reference, is null too). The provider is offered once a reference
|
|
287
|
+
* arrives. Until then an account with other methods shows those; one
|
|
288
|
+
* whose only way in is the provider waits for it, and is told to try
|
|
289
|
+
* again when none could be had.
|
|
290
|
+
* - `null`: the page can never hold one (an SDK that predates the
|
|
291
|
+
* reference opened it), so the provider is never offered: such a
|
|
292
|
+
* sign-in opens no hub session, and its lost result could recover
|
|
293
|
+
* another person's.
|
|
294
|
+
* - Omitted: the provider is offered only when the page says it completes
|
|
295
|
+
* in its own window (`completesInWindow`); never for a page that predates
|
|
296
|
+
* the reference, whatever its window.
|
|
297
|
+
*/
|
|
298
|
+
signinRef?: string | null | (() => Promise<string | null>);
|
|
299
|
+
/**
|
|
300
|
+
* The sign-in completes in this window (internal): set by the SparkVault
|
|
301
|
+
* hosted sign-in page, which finishes an authorization request where it
|
|
302
|
+
* runs (an authorization code to the relying party, or a simple-mode
|
|
303
|
+
* redirect) and never hands its result to an opener. No recovery ever
|
|
304
|
+
* stands in for that result, so the page offers the account's own identity
|
|
305
|
+
* provider without a reference, in a popup too. Ignored when `signinRef`
|
|
306
|
+
* is given.
|
|
307
|
+
*/
|
|
308
|
+
completesInWindow?: boolean;
|
|
255
309
|
/** Called when user cancels (if omitted, uses server-configured redirect) */
|
|
256
310
|
onCancel?: () => void;
|
|
257
311
|
/** Called when verification completes (if omitted, uses server-configured redirect) */
|
|
@@ -269,6 +323,8 @@ interface AttachOptions {
|
|
|
269
323
|
authContext?: AuthContext;
|
|
270
324
|
/** `'select_account'` always shows the account chooser (see `VerifyOptions.prompt`) */
|
|
271
325
|
prompt?: 'select_account';
|
|
326
|
+
/** `'federation'` starts with the account's own identity provider (see `VerifyOptions.method`) */
|
|
327
|
+
method?: 'federation';
|
|
272
328
|
/** Called when user cancels */
|
|
273
329
|
onCancel?: () => void;
|
|
274
330
|
/** Called when verification completes */
|
|
@@ -319,10 +375,11 @@ interface VerifyResult {
|
|
|
319
375
|
}
|
|
320
376
|
/**
|
|
321
377
|
* Options for `signIn()` — the customer-facing popup sign-in. The popup owns its
|
|
322
|
-
* rendering, so there is no inline `target`/`renderMode`/`chrome
|
|
323
|
-
* are internal to the SparkVault-hosted
|
|
378
|
+
* rendering, so there is no inline `target`/`renderMode`/`chrome`/`signinRef`/
|
|
379
|
+
* `completesInWindow` here; those are internal to the SparkVault-hosted
|
|
380
|
+
* sign-in surfaces.
|
|
324
381
|
*/
|
|
325
|
-
type SignInOptions = Omit<VerifyOptions, 'target' | 'renderMode' | 'chrome'>;
|
|
382
|
+
type SignInOptions = Omit<VerifyOptions, 'target' | 'renderMode' | 'chrome' | 'signinRef' | 'completesInWindow'>;
|
|
326
383
|
/** The verified identity returned by `signIn()`. */
|
|
327
384
|
type SignInResult = VerifyResult;
|
|
328
385
|
/**
|
|
@@ -364,6 +421,14 @@ interface TokenClaims {
|
|
|
364
421
|
verified_at: number;
|
|
365
422
|
/** Authentication method used */
|
|
366
423
|
method: string;
|
|
424
|
+
/**
|
|
425
|
+
* Only on a `federated` sign-in whose provider asserted an email: the
|
|
426
|
+
* address as the provider sent it. The provider may assert an address it
|
|
427
|
+
* never verified, so it is no identifier: key people by `sub`.
|
|
428
|
+
*/
|
|
429
|
+
email?: string;
|
|
430
|
+
/** Only beside `email`: true only when the provider said it verified the address. */
|
|
431
|
+
email_verified?: boolean;
|
|
367
432
|
/**
|
|
368
433
|
* The person's public avatar URL (my.auth.sv), present only when they have a visible
|
|
369
434
|
* avatar. The URL always renders an image — their photo, or a neutral placeholder.
|
|
@@ -371,13 +436,14 @@ interface TokenClaims {
|
|
|
371
436
|
picture?: string;
|
|
372
437
|
}
|
|
373
438
|
/** Method ID returned by config endpoint */
|
|
374
|
-
type MethodId = 'otp_email' | 'otp_sms' | 'otp_voice' | 'passkey' | 'sparklink' | 'social_google' | 'social_apple' | 'social_microsoft' | 'social_github' | 'social_facebook' | 'social_linkedin';
|
|
439
|
+
type MethodId = 'otp_email' | 'otp_sms' | 'otp_voice' | 'passkey' | 'sparklink' | 'social_google' | 'social_apple' | 'social_microsoft' | 'social_github' | 'social_facebook' | 'social_linkedin' | 'federation';
|
|
375
440
|
|
|
376
441
|
/**
|
|
377
442
|
* Identity Module
|
|
378
443
|
*
|
|
379
444
|
* Passwordless sign-in through the first-party SparkVault popup.
|
|
380
|
-
* Supports passkey, OTP, SparkLink, and
|
|
445
|
+
* Supports passkey, OTP, SparkLink, social authentication, and the account's
|
|
446
|
+
* own identity provider.
|
|
381
447
|
*
|
|
382
448
|
* @example Programmatic
|
|
383
449
|
* const result = await sv.products.identity.signIn();
|
|
@@ -391,6 +457,7 @@ declare class IdentityModule {
|
|
|
391
457
|
private readonly api;
|
|
392
458
|
private renderer;
|
|
393
459
|
private launcher;
|
|
460
|
+
private pendingSignIn;
|
|
394
461
|
constructor(config: ResolvedConfig);
|
|
395
462
|
/**
|
|
396
463
|
* Build a deep link into the person's auth.sv Identity portal — where they
|
|
@@ -448,8 +515,10 @@ declare class IdentityModule {
|
|
|
448
515
|
* Resilience: pair this with `handleRedirectResult()` on page load. If the
|
|
449
516
|
* popup's result is ever lost (a mobile browser discards the backgrounded
|
|
450
517
|
* opener tab), the next load silently self-heals from the SSO session the
|
|
451
|
-
*
|
|
452
|
-
*
|
|
518
|
+
* popup signed in or chose; a sign-in that opened none (the account's own
|
|
519
|
+
* identity provider) comes back signed out, to sign in again. `flow:
|
|
520
|
+
* 'redirect'` opts a caller out of the popup into a same-tab navigation
|
|
521
|
+
* instead.
|
|
453
522
|
*
|
|
454
523
|
* @example
|
|
455
524
|
* const result = await sv.products.identity.signIn();
|
|
@@ -465,7 +534,9 @@ declare class IdentityModule {
|
|
|
465
534
|
* Core flow runner. Default mode (no `target`) opens the popup; `flow:
|
|
466
535
|
* 'redirect'` navigates the tab instead; local mode (`renderMode: 'local'` /
|
|
467
536
|
* `target`) renders into the current document and powers the
|
|
468
|
-
* SparkVault-hosted sign-in surfaces (see the internal `render`)
|
|
537
|
+
* SparkVault-hosted sign-in surfaces (see the internal `render`), which
|
|
538
|
+
* hands it what a round trip to the account's own identity provider
|
|
539
|
+
* returned (`federationReturn`).
|
|
469
540
|
*/
|
|
470
541
|
private runFlow;
|
|
471
542
|
/**
|
|
@@ -512,10 +583,13 @@ declare class IdentityModule {
|
|
|
512
583
|
* `onSuccess` (and resolve with it).
|
|
513
584
|
* 2. A sign-in was in flight but never delivered (a mobile browser
|
|
514
585
|
* discarded the backgrounded opener tab, killing the popup's
|
|
515
|
-
* postMessage) — silently re-mint from the SSO session the
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
586
|
+
* postMessage) — silently re-mint from the SSO session the popup signed
|
|
587
|
+
* in or chose, by navigating this tab through the silent SSO endpoint
|
|
588
|
+
* and straight back with a code (case 1 on return). The bounce names
|
|
589
|
+
* the sign-in's reference, and the endpoint mints only when the
|
|
590
|
+
* session it would mint from carries it. Nothing is shown; with no
|
|
591
|
+
* such session (a sign-in that opened none, such as one through the
|
|
592
|
+
* account's own identity provider) it comes back logged-out, no oracle.
|
|
519
593
|
*
|
|
520
594
|
* The code is one-time, PKCE-bound, and origin-locked — never the token. The
|
|
521
595
|
* host must still verify `result.token` server-side via the Identity JWKS.
|
|
@@ -529,8 +603,8 @@ declare class IdentityModule {
|
|
|
529
603
|
/** Redeem a returned `#sv_code` (or surface a returned `#sv_error`). */
|
|
530
604
|
private consumeHandoffFragment;
|
|
531
605
|
/**
|
|
532
|
-
* Silently re-mint the sign-in result from the SSO session the
|
|
533
|
-
*
|
|
606
|
+
* Silently re-mint the sign-in result from the SSO session the popup signed
|
|
607
|
+
* in or chose. Navigates this tab through the silent SSO endpoint
|
|
534
608
|
* (a top-level GET, so the `SameSite=Lax` hub cookie rides along) which,
|
|
535
609
|
* PKCE-bound, returns a one-time code in the fragment — handled by case 1 on
|
|
536
610
|
* return. No-op (stays put) if session storage or WebCrypto is unavailable,
|
|
@@ -542,51 +616,59 @@ declare class IdentityModule {
|
|
|
542
616
|
*/
|
|
543
617
|
private startRecoveryBounce;
|
|
544
618
|
/**
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
* returns via the fragment code;
|
|
548
|
-
*
|
|
619
|
+
* Navigate this tab to the interactive sign-in page: explicit `flow:
|
|
620
|
+
* 'redirect'`, or a popup whose handle COOP severed. Plain sign-in carries
|
|
621
|
+
* redirect_uri + state + PKCE challenge and returns via the fragment code;
|
|
622
|
+
* OIDC/simple modes navigate without them (their server-rendered pages drive
|
|
623
|
+
* the server-validated redirect back). Either carries `signinRef`, the
|
|
624
|
+
* severed popup's reference; a redirect draws none of its own.
|
|
549
625
|
*
|
|
626
|
+
* @param signinRef - The reference the pending marker holds for this
|
|
627
|
+
* sign-in, or null for a page sent without one
|
|
550
628
|
* @returns false when the return leg cannot be armed (no session storage or
|
|
551
629
|
* WebCrypto) — the caller surfaces an actionable error instead of a
|
|
552
630
|
* silent dead-end.
|
|
553
631
|
*/
|
|
554
632
|
private startRedirectFlow;
|
|
555
633
|
/**
|
|
556
|
-
* Arm the PKCE + state return leg
|
|
557
|
-
*
|
|
558
|
-
* Returns null when session storage or WebCrypto is
|
|
559
|
-
* can degrade.
|
|
560
|
-
*/
|
|
561
|
-
private prepareHandoffNavigation;
|
|
562
|
-
/**
|
|
563
|
-
* Arm the self-heal marker for an in-flight sign-in. `hint` is the identifier
|
|
564
|
-
* (email or phone) the sign-in was started with, when the caller supplied
|
|
565
|
-
* one — the recovery bounce forwards it as the /sso `login_hint`, so with
|
|
566
|
-
* several hub sessions recovery re-mints the account this sign-in was for,
|
|
567
|
-
* never a different one.
|
|
634
|
+
* Arm the PKCE + state return leg of a handoff navigation and return what
|
|
635
|
+
* the navigation carries for it (redirect_uri = this page, per
|
|
636
|
+
* `currentPageReturnUrl`). Returns null when session storage or WebCrypto is
|
|
637
|
+
* unavailable so callers can degrade.
|
|
568
638
|
*/
|
|
569
|
-
private
|
|
570
|
-
private clearSignInPending;
|
|
639
|
+
private armHandoffReturn;
|
|
571
640
|
/**
|
|
572
|
-
* Consume the pending marker:
|
|
573
|
-
* sign-in is still awaiting its result
|
|
574
|
-
* carried, for the recovery bounce's `login_hint
|
|
641
|
+
* Consume the pending marker: the marker once (then cleared) while a recent
|
|
642
|
+
* sign-in is still awaiting its result, else null. Its `hint` is the
|
|
643
|
+
* identifier that sign-in carried, for the recovery bounce's `login_hint`,
|
|
644
|
+
* and its `ref` the sign-in's reference, when the marker holds one.
|
|
575
645
|
*/
|
|
576
646
|
private consumeSignInPending;
|
|
647
|
+
/** Close the popup sign-in's launcher, ending the sign-in it ran. */
|
|
648
|
+
private closeLauncher;
|
|
577
649
|
/** Remove the result fragment from the URL bar (and history entry). */
|
|
578
650
|
private clearUrlFragment;
|
|
579
651
|
/** Drop the one-shot PKCE state/verifier a bounce staged. */
|
|
580
652
|
private clearOneShotAuthState;
|
|
581
653
|
/**
|
|
582
|
-
* Complete a social round trip
|
|
583
|
-
*
|
|
654
|
+
* Complete a social round trip, or one through the account's own identity
|
|
655
|
+
* provider, that returned to the sign-in page as `#token=…&state=…`. Only
|
|
656
|
+
* `render()`, the Identity-origin sign-in page,
|
|
584
657
|
* reads it: no SDK flow returns a `#token` to a site (a site's results arrive
|
|
585
658
|
* by the popup's postMessage, FedCM, or a PKCE-bound `#sv_code`), so on a site
|
|
586
659
|
* it could only be someone else's token, or the site's own direct
|
|
587
660
|
* token-redirect result.
|
|
588
661
|
*/
|
|
589
662
|
private consumeRedirectResult;
|
|
663
|
+
/**
|
|
664
|
+
* Read a refusal a round trip through the account's own identity provider
|
|
665
|
+
* returned to the sign-in page (`#error=…&state=…`, see federation-flow.ts).
|
|
666
|
+
* Such a fragment is consumed exactly once, with the state it answers,
|
|
667
|
+
* whatever it holds. Null for any other fragment, and for a refusal whose
|
|
668
|
+
* state is not the one this browser stored before it left: an answer to no
|
|
669
|
+
* sign-in this browser started, which the page ignores.
|
|
670
|
+
*/
|
|
671
|
+
private consumeFederationReturn;
|
|
590
672
|
/**
|
|
591
673
|
* Close the identity dialog/inline UI if open.
|
|
592
674
|
*
|
|
@@ -613,9 +695,12 @@ declare class IdentityModule {
|
|
|
613
695
|
/**
|
|
614
696
|
* Render the flow into a page element instead of a popup.
|
|
615
697
|
*
|
|
616
|
-
* A social login
|
|
617
|
-
*
|
|
618
|
-
* `
|
|
698
|
+
* A social login, or one through the account's own identity provider,
|
|
699
|
+
* started here returns to this same page with its result in the fragment,
|
|
700
|
+
* so a returned `#token` is completed first (see `consumeRedirectResult`)
|
|
701
|
+
* instead of starting the flow again, and a returned refusal of the
|
|
702
|
+
* account's own identity provider is handed to the flow it starts (see
|
|
703
|
+
* `consumeFederationReturn`).
|
|
619
704
|
*
|
|
620
705
|
* @internal Used only by the SparkVault-hosted sign-in popup and hosted login
|
|
621
706
|
* page (which own their chrome and pass `renderMode: 'local'`). Customer
|