@sparkvault/sdk-js 8.1.0 → 8.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/dist/index.d.ts CHANGED
@@ -108,6 +108,14 @@ interface VerifyOptions {
108
108
  target?: string | HTMLElement;
109
109
  /** Override backdrop blur for this dialog (uses global config if omitted) */
110
110
  backdropBlur?: boolean;
111
+ /**
112
+ * Container chrome for inline (`target`) rendering. `'card'` (default) wraps
113
+ * the flow in a bordered, rounded surface with the SparkVault footer. `'bare'`
114
+ * drops the surface and footer so a host page (e.g. the SparkVault sign-in
115
+ * page) can supply its own full-window chrome — logo, background, footer.
116
+ * Ignored in dialog mode.
117
+ */
118
+ chrome?: 'card' | 'bare';
111
119
  /** Auth context for OIDC/simple mode flows (used by hosted login) */
112
120
  authContext?: AuthContext;
113
121
  /**
@@ -1,25 +1,37 @@
1
1
  /**
2
2
  * Dialog Launcher
3
3
  *
4
- * Host-side half of the popup login flow. Dialog (modal) verification renders a
5
- * thin email/phone launcher in the SDK's own ModalContainer, then — inside the
6
- * user's submit gesture — opens a TOP-LEVEL popup on the Identity origin that
7
- * runs the full login flow. Because the popup is top-level on api.sparkvault.com,
8
- * login completion's first-party `__Host-authsv_sso` cookie persists.
4
+ * Host-side half of the popup login flow. Dialog-mode `verify()` opens a
5
+ * TOP-LEVEL popup on the Identity origin **directly inside the triggering user
6
+ * gesture** and, on the host page, shades it with a small branded **bridge
7
+ * modal** ("continue in the secure window"). The popup (the `chrome: 'bare'`
8
+ * sign-in page) collects the identifier and runs the whole flow first-party, so
9
+ * login's `__Host-authsv_sso` cookie persists. Any `email`/`phone` passed to
10
+ * `verify()` is forwarded as a prefill.
9
11
  *
10
- * The launcher only collects an identifier and bridges the popup result back;
11
- * the flow UI itself lives in the popup (the renderMode:'local' renderer).
12
+ * The popup must open synchronously in the gesture or the browser blocks it as
13
+ * programmatic. `verify()` reaches `start()` through microtask-only awaits (the
14
+ * redirect-result check does no I/O; the preloaded config resolves from cache),
15
+ * so transient activation survives.
16
+ *
17
+ * It is one dialog. The happy path is clean: logo, a subtle animation, and
18
+ * "continue in the secure window". A single warning appears under the logo only
19
+ * when the popup can't be confirmed: it was blocked, it closed, or it never
20
+ * posted a "ready" ping within `OPEN_TIMEOUT_MS` (so the open/load failed). Its
21
+ * "Try again" reopens the popup. The header's close ✕ (or backdrop/Escape)
22
+ * aborts and closes the popup.
12
23
  */
13
24
  import type { ResolvedConfig } from '../../config';
14
25
  import type { VerifyOptions, VerifyResult } from './types';
15
- import { IdentityApi } from './api';
26
+ import type { IdentityApi } from './api';
16
27
  interface LauncherCallbacks {
17
28
  onSuccess: (result: VerifyResult) => void;
18
29
  onError: (error: Error) => void;
19
30
  onCancel: () => void;
20
31
  }
21
32
  /**
22
- * Renders the email/phone launcher modal and opens the login popup on submit.
33
+ * Opens the sign-in popup for dialog-mode `verify()` and bridges its result
34
+ * back, behind a single branded host-page modal.
23
35
  */
24
36
  export declare class DialogLauncher {
25
37
  private readonly config;
@@ -27,47 +39,36 @@ export declare class DialogLauncher {
27
39
  private readonly options;
28
40
  private readonly callbacks;
29
41
  private readonly trustedOrigin;
30
- private readonly modal;
31
42
  private readonly popupLauncher;
32
- private currentView;
43
+ private modal;
44
+ private alertEl;
45
+ private popupWindow;
46
+ private openTimer;
33
47
  private settled;
34
- private allowedTypes;
48
+ private generation;
35
49
  constructor(config: ResolvedConfig, api: IdentityApi, options: VerifyOptions, callbacks: LauncherCallbacks);
36
- /**
37
- * Mount the modal, then load config to render the identifier input (or a
38
- * terminal error view when config fails).
39
- */
50
+ /** Shade the host with the bridge and open the popup in the caller's gesture. */
40
51
  start(): void;
41
- /**
42
- * Close the launcher and tear everything down. Cancels in-flight config
43
- * requests so a late resolution can't render into a destroyed modal.
44
- */
52
+ /** Tear down the bridge modal and close any popup it opened. */
45
53
  close(): void;
46
- private handleClose;
47
- private renderInput;
48
- /**
49
- * Render the identifier input. The submit handler runs synchronously inside
50
- * the user gesture, so the popup open is never treated as programmatic (and
51
- * never blocked).
52
- */
53
- private mountInput;
54
- /**
55
- * Open the login popup for the submitted identifier. SYNCHRONOUS: no await
56
- * precedes window.open, so the browser keeps the user-gesture grant.
57
- */
58
- private handleIdentitySubmit;
54
+ private openPopup;
59
55
  private buildPopupUrl;
60
- private handlePopupResult;
61
- private handlePopupError;
62
- /**
63
- * Re-render the input (its Continue button is disabled to "Please wait…" on
64
- * submit) so it is interactive again after a cancelled or blocked popup.
65
- */
66
- private reEnableInput;
67
- private renderConfigError;
68
- private viewForConfigError;
69
- private retryConfig;
70
- private mountView;
56
+ private handleResult;
57
+ private handleError;
58
+ /** Create the bridge modal (once) and render its single happy-path body. */
59
+ private showBridge;
60
+ private showAlert;
61
+ private hideAlert;
62
+ private scheduleOpenWarning;
63
+ private clearOpenTimer;
64
+ /** "Try again": close any current popup and reopen a fresh one. */
65
+ private retry;
66
+ /** Fetch branding once and drop the tenant logo into the modal header. */
67
+ private loadBranding;
68
+ private closePopup;
69
+ /** Explicit abort (close ✕, backdrop, Escape): close the popup and cancel. */
70
+ private abort;
71
71
  private finish;
72
+ private finishCancel;
72
73
  }
73
74
  export {};
@@ -16,6 +16,11 @@ export interface InlineContainerOptions {
16
16
  showCloseButton?: boolean;
17
17
  /** Show footer with SparkVault branding */
18
18
  showFooter?: boolean;
19
+ /**
20
+ * Bare mode: drop the container's own surface (border, radius, background)
21
+ * so it flows transparently inside a host page that owns the chrome.
22
+ */
23
+ bare?: boolean;
19
24
  }
20
25
  export declare class InlineContainer implements Container {
21
26
  private readonly targetElement;
@@ -32,6 +32,20 @@ export interface OpenPopupOptions {
32
32
  height?: number;
33
33
  /** Timeout in ms before giving up and closing the popup (default 60000). */
34
34
  timeoutMs?: number;
35
+ /**
36
+ * Called synchronously with the popup window the moment it opens, so the
37
+ * opener can close or refocus it (e.g. an abort/"try again" control on a host
38
+ * bridge modal). Not called when the popup is blocked.
39
+ */
40
+ onOpen?: (popup: Window) => void;
41
+ /**
42
+ * `data.type` of a non-terminal "I've loaded" ping the popup posts so the
43
+ * opener can confirm the window actually opened and reached the page (vs.
44
+ * silently failing). Distinct from `resultType`; receiving it does not settle.
45
+ */
46
+ readyType?: string;
47
+ /** Called when a `readyType` message arrives from the trusted origin. */
48
+ onReady?: () => void;
35
49
  }
36
50
  /**
37
51
  * Open a popup and resolve with the first validated result envelope it posts.
@@ -17,6 +17,15 @@ export interface StyleOptions {
17
17
  * Inject modal styles into the document head.
18
18
  */
19
19
  export declare function injectStyles(options: StyleOptions): void;
20
- export declare function updateThemeVariables(_branding: SdkConfigBranding | undefined | null): void;
20
+ /**
21
+ * Re-theme the injected stylesheet when the resolved theme (light/dark) changes.
22
+ *
23
+ * Styles are first injected with default branding before config loads (so the
24
+ * UI paints instantly), then `updateBranding` calls this with the tenant's real
25
+ * `themeMode`. The theme is baked into the generated CSS (not runtime CSS
26
+ * variables), so a theme switch requires regenerating the stylesheet - a no-op
27
+ * when the theme is unchanged.
28
+ */
29
+ export declare function applyBrandingTheme(branding: SdkConfigBranding | undefined | null): void;
21
30
  export declare function removeStyles(): void;
22
31
  export declare function resolveTheme(branding: SdkConfigBranding | undefined | null): 'light' | 'dark';
@@ -34,6 +34,14 @@ export interface VerifyOptions {
34
34
  target?: string | HTMLElement;
35
35
  /** Override backdrop blur for this dialog (uses global config if omitted) */
36
36
  backdropBlur?: boolean;
37
+ /**
38
+ * Container chrome for inline (`target`) rendering. `'card'` (default) wraps
39
+ * the flow in a bordered, rounded surface with the SparkVault footer. `'bare'`
40
+ * drops the surface and footer so a host page (e.g. the SparkVault sign-in
41
+ * page) can supply its own full-window chrome — logo, background, footer.
42
+ * Ignored in dialog mode.
43
+ */
44
+ chrome?: 'card' | 'bare';
37
45
  /** Auth context for OIDC/simple mode flows (used by hosted login) */
38
46
  authContext?: AuthContext;
39
47
  /**