@sparkvault/sdk-js 1.24.4
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 +769 -0
- package/dist/api-base.d.ts +58 -0
- package/dist/auto-init.d.ts +32 -0
- package/dist/config.d.ts +41 -0
- package/dist/errors.d.ts +30 -0
- package/dist/health.d.ts +18 -0
- package/dist/http.d.ts +51 -0
- package/dist/identity/api.d.ts +110 -0
- package/dist/identity/container.d.ts +56 -0
- package/dist/identity/handlers/index.d.ts +9 -0
- package/dist/identity/handlers/passkey-handler.d.ts +69 -0
- package/dist/identity/handlers/sparklink-handler.d.ts +30 -0
- package/dist/identity/handlers/totp-handler.d.ts +52 -0
- package/dist/identity/index.d.ts +89 -0
- package/dist/identity/inline-container.d.ts +65 -0
- package/dist/identity/methods.d.ts +23 -0
- package/dist/identity/modal.d.ts +82 -0
- package/dist/identity/renderer.d.ts +146 -0
- package/dist/identity/state.d.ts +98 -0
- package/dist/identity/styles.d.ts +22 -0
- package/dist/identity/types.d.ts +221 -0
- package/dist/identity/utils/cooldown-timer.d.ts +73 -0
- package/dist/identity/utils/index.d.ts +5 -0
- package/dist/identity/utils.d.ts +39 -0
- package/dist/identity/views/app-not-activated.d.ts +21 -0
- package/dist/identity/views/base.d.ts +62 -0
- package/dist/identity/views/error.d.ts +25 -0
- package/dist/identity/views/icons.d.ts +38 -0
- package/dist/identity/views/identity-input.d.ts +48 -0
- package/dist/identity/views/index.d.ts +16 -0
- package/dist/identity/views/loading.d.ts +15 -0
- package/dist/identity/views/method-select.d.ts +29 -0
- package/dist/identity/views/passkey-prompt.d.ts +24 -0
- package/dist/identity/views/passkey.d.ts +38 -0
- package/dist/identity/views/service-unavailable.d.ts +21 -0
- package/dist/identity/views/sparklink-waiting.d.ts +40 -0
- package/dist/identity/views/totp-verify.d.ts +58 -0
- package/dist/index.d.ts +733 -0
- package/dist/logger.d.ts +45 -0
- package/dist/rng/index.d.ts +54 -0
- package/dist/rng/types.d.ts +26 -0
- package/dist/sparks/index.d.ts +37 -0
- package/dist/sparks/types.d.ts +56 -0
- package/dist/sparkvault.cjs.js +10167 -0
- package/dist/sparkvault.cjs.js.map +1 -0
- package/dist/sparkvault.esm.js +10152 -0
- package/dist/sparkvault.esm.js.map +1 -0
- package/dist/sparkvault.js +2 -0
- package/dist/sparkvault.js.map +1 -0
- package/dist/utils/base64url.d.ts +41 -0
- package/dist/utils/dom.d.ts +17 -0
- package/dist/utils/retry.d.ts +32 -0
- package/dist/vaults/index.d.ts +109 -0
- package/dist/vaults/types.d.ts +128 -0
- package/dist/vaults/upload/api.d.ts +36 -0
- package/dist/vaults/upload/container.d.ts +57 -0
- package/dist/vaults/upload/index.d.ts +75 -0
- package/dist/vaults/upload/inline-container.d.ts +75 -0
- package/dist/vaults/upload/modal.d.ts +79 -0
- package/dist/vaults/upload/renderer.d.ts +70 -0
- package/dist/vaults/upload/styles.d.ts +20 -0
- package/dist/vaults/upload/types.d.ts +182 -0
- package/package.json +63 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CooldownTimer - Reusable countdown utility for resend buttons and rate limiting
|
|
3
|
+
*
|
|
4
|
+
* Manages interval-based countdowns with callbacks for tick and completion events.
|
|
5
|
+
* Properly cleans up intervals to prevent memory leaks.
|
|
6
|
+
*/
|
|
7
|
+
export interface CooldownTimerConfig {
|
|
8
|
+
/** Duration in seconds */
|
|
9
|
+
duration: number;
|
|
10
|
+
/** Called every second with remaining seconds */
|
|
11
|
+
onTick: (secondsRemaining: number) => void;
|
|
12
|
+
/** Called when countdown reaches zero */
|
|
13
|
+
onComplete: () => void;
|
|
14
|
+
}
|
|
15
|
+
export declare class CooldownTimer {
|
|
16
|
+
private intervalId;
|
|
17
|
+
private secondsRemaining;
|
|
18
|
+
private readonly onTick;
|
|
19
|
+
private readonly onComplete;
|
|
20
|
+
constructor(config: CooldownTimerConfig);
|
|
21
|
+
/**
|
|
22
|
+
* Start the countdown timer
|
|
23
|
+
* Immediately calls onTick with initial value, then updates every second
|
|
24
|
+
*/
|
|
25
|
+
start(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Stop and clean up the timer
|
|
28
|
+
*/
|
|
29
|
+
stop(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Check if timer is currently running
|
|
32
|
+
*/
|
|
33
|
+
isRunning(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Get current remaining seconds
|
|
36
|
+
*/
|
|
37
|
+
getRemainingSeconds(): number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* ExpirationTimer - Countdown based on an absolute expiration timestamp
|
|
41
|
+
*
|
|
42
|
+
* Unlike CooldownTimer which counts down from a fixed duration,
|
|
43
|
+
* this calculates remaining time from a UTC timestamp, making it
|
|
44
|
+
* accurate even if the page was loaded after the timer started.
|
|
45
|
+
*/
|
|
46
|
+
export interface ExpirationTimerConfig {
|
|
47
|
+
/** UTC timestamp (seconds) when the countdown expires */
|
|
48
|
+
expiresAt: number;
|
|
49
|
+
/** Called every second with remaining seconds */
|
|
50
|
+
onTick: (secondsRemaining: number) => void;
|
|
51
|
+
/** Called when countdown reaches zero */
|
|
52
|
+
onExpired: () => void;
|
|
53
|
+
}
|
|
54
|
+
export declare class ExpirationTimer {
|
|
55
|
+
private intervalId;
|
|
56
|
+
private readonly expiresAt;
|
|
57
|
+
private readonly onTick;
|
|
58
|
+
private readonly onExpired;
|
|
59
|
+
constructor(config: ExpirationTimerConfig);
|
|
60
|
+
private calculateRemaining;
|
|
61
|
+
/**
|
|
62
|
+
* Start the countdown timer
|
|
63
|
+
*/
|
|
64
|
+
start(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Stop and clean up the timer
|
|
67
|
+
*/
|
|
68
|
+
stop(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Check if timer is currently running
|
|
71
|
+
*/
|
|
72
|
+
isRunning(): boolean;
|
|
73
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Module Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utility functions for encoding, validation, and cookie management.
|
|
5
|
+
* Consolidates duplicated logic from renderer, api, and index.
|
|
6
|
+
*/
|
|
7
|
+
export { CooldownTimer, ExpirationTimer } from './utils/cooldown-timer';
|
|
8
|
+
export type { CooldownTimerConfig, ExpirationTimerConfig } from './utils/cooldown-timer';
|
|
9
|
+
export { arrayBufferToBase64url, base64urlToArrayBuffer, base64urlToString, } from '../utils/base64url';
|
|
10
|
+
/**
|
|
11
|
+
* Extract the root (registrable) domain from a hostname for cross-subdomain cookies.
|
|
12
|
+
* Returns the domain prefixed with a dot (e.g., ".client.com") or null when
|
|
13
|
+
* the domain attribute should not be set (loopback hosts, IP addresses).
|
|
14
|
+
*
|
|
15
|
+
* @param hostname - The hostname to extract the root domain from
|
|
16
|
+
* @returns Root domain with leading dot, or null
|
|
17
|
+
*/
|
|
18
|
+
export declare function getRootDomain(hostname: string): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Get cookie value by name
|
|
21
|
+
* @param name - Cookie name
|
|
22
|
+
* @returns Cookie value or null if not found
|
|
23
|
+
*/
|
|
24
|
+
export declare function getCookie(name: string): string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Set cookie with expiration on the root domain for cross-subdomain access.
|
|
27
|
+
* The domain is automatically extracted from the current hostname and prefixed
|
|
28
|
+
* with a dot (e.g., ".client.com") so the cookie is shared across all subdomains.
|
|
29
|
+
*
|
|
30
|
+
* @param name - Cookie name
|
|
31
|
+
* @param value - Cookie value
|
|
32
|
+
* @param days - Days until expiration
|
|
33
|
+
*/
|
|
34
|
+
export declare function setCookie(name: string, value: string, days: number): void;
|
|
35
|
+
/**
|
|
36
|
+
* Generate cryptographically secure random state string
|
|
37
|
+
* Used for OAuth CSRF protection
|
|
38
|
+
*/
|
|
39
|
+
export declare function generateState(): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App Not Activated View
|
|
3
|
+
*
|
|
4
|
+
* Full-dialog terminal screen shown when the SparkVault Identity app has not
|
|
5
|
+
* been activated for the account that the JS SDK is configured against. The
|
|
6
|
+
* audience is the website owner / developer — this is a misconfiguration
|
|
7
|
+
* surface, not an end-user error — so the dialog drops customer branding and
|
|
8
|
+
* presents itself as an unmistakable SparkVault notice.
|
|
9
|
+
*/
|
|
10
|
+
import type { View } from './base';
|
|
11
|
+
export interface AppNotActivatedViewProps {
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare class AppNotActivatedView implements View {
|
|
15
|
+
private readonly props;
|
|
16
|
+
private dismissButton;
|
|
17
|
+
private readonly boundHandleClose;
|
|
18
|
+
constructor(props: AppNotActivatedViewProps);
|
|
19
|
+
render(): HTMLElement;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base View Types and Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared interfaces and helpers for all view components.
|
|
5
|
+
*/
|
|
6
|
+
import { escapeHtml } from '../modal';
|
|
7
|
+
/**
|
|
8
|
+
* Base interface for all view components.
|
|
9
|
+
* Each view must implement render() to return its DOM element.
|
|
10
|
+
*/
|
|
11
|
+
export interface View {
|
|
12
|
+
render(): HTMLElement;
|
|
13
|
+
destroy?(): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create an element with optional attributes and children.
|
|
17
|
+
* Type-safe DOM element creation utility.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createElement<K extends keyof HTMLElementTagNameMap>(tag: K, attrs?: Partial<HTMLElementTagNameMap[K]> & {
|
|
20
|
+
className?: string;
|
|
21
|
+
}, children?: (HTMLElement | string | null | undefined)[]): HTMLElementTagNameMap[K];
|
|
22
|
+
/**
|
|
23
|
+
* Create a container div with optional class and children.
|
|
24
|
+
*/
|
|
25
|
+
export declare function div(className?: string, children?: (HTMLElement | string | null | undefined)[]): HTMLDivElement;
|
|
26
|
+
/**
|
|
27
|
+
* Clear all children from an element safely.
|
|
28
|
+
* Preferred over innerHTML = '' for security and performance.
|
|
29
|
+
*/
|
|
30
|
+
export declare function clearChildren(element: HTMLElement): void;
|
|
31
|
+
/**
|
|
32
|
+
* Create an error message element.
|
|
33
|
+
*/
|
|
34
|
+
export declare function errorMessage(message: string): HTMLDivElement;
|
|
35
|
+
/**
|
|
36
|
+
* Validate email format.
|
|
37
|
+
* Returns sanitized email or null if invalid.
|
|
38
|
+
*/
|
|
39
|
+
export declare function validateEmail(email: string): string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Validate phone number format.
|
|
42
|
+
* Accepts various formats, returns E.164 format (+1XXXXXXXXXX) or null if invalid.
|
|
43
|
+
*/
|
|
44
|
+
export declare function validatePhone(phone: string): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Format phone number for display as user types.
|
|
47
|
+
* Formats US numbers as (XXX) XXX-XXXX.
|
|
48
|
+
*/
|
|
49
|
+
export declare function formatPhoneDisplay(phone: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Detect if input looks like a phone number (starts with digit or +).
|
|
52
|
+
*/
|
|
53
|
+
export declare function looksLikePhone(input: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Validate TOTP code format.
|
|
56
|
+
* Returns sanitized code or null if invalid.
|
|
57
|
+
*/
|
|
58
|
+
export declare function validateTotpCode(code: string): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Re-export escapeHtml for convenience.
|
|
61
|
+
*/
|
|
62
|
+
export { escapeHtml };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error View
|
|
3
|
+
*
|
|
4
|
+
* Professional enterprise-quality error display with clear visual hierarchy.
|
|
5
|
+
*/
|
|
6
|
+
import type { View } from './base';
|
|
7
|
+
export interface ErrorViewProps {
|
|
8
|
+
message: string;
|
|
9
|
+
code: string;
|
|
10
|
+
onRetry: () => void;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare class ErrorView implements View {
|
|
14
|
+
private readonly props;
|
|
15
|
+
private retryButton;
|
|
16
|
+
private closeButton;
|
|
17
|
+
private readonly boundHandleRetry;
|
|
18
|
+
private readonly boundHandleClose;
|
|
19
|
+
constructor(props: ErrorViewProps);
|
|
20
|
+
render(): HTMLElement;
|
|
21
|
+
/**
|
|
22
|
+
* Clean up event listeners to prevent memory leaks.
|
|
23
|
+
*/
|
|
24
|
+
destroy(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG Icon Factory
|
|
3
|
+
*
|
|
4
|
+
* Enterprise-grade icons with clean, minimal design.
|
|
5
|
+
* Uses proper DOM element creation for security.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Checkmark icon for benefit lists
|
|
9
|
+
*/
|
|
10
|
+
export declare function createCheckmarkIcon(): SVGSVGElement;
|
|
11
|
+
/**
|
|
12
|
+
* Back arrow (chevron left)
|
|
13
|
+
*/
|
|
14
|
+
export declare function createBackArrowIcon(): SVGSVGElement;
|
|
15
|
+
/**
|
|
16
|
+
* Close (X) icon
|
|
17
|
+
*/
|
|
18
|
+
export declare function createCloseIcon(): SVGSVGElement;
|
|
19
|
+
/**
|
|
20
|
+
* Auth shield icon - clean, minimal design
|
|
21
|
+
*/
|
|
22
|
+
export declare function createAuthShieldIcon(): SVGSVGElement;
|
|
23
|
+
/**
|
|
24
|
+
* Passkey icon - simple key design
|
|
25
|
+
*/
|
|
26
|
+
export declare function createPasskeyIcon(): SVGSVGElement;
|
|
27
|
+
/**
|
|
28
|
+
* Error icon - clean triangle alert
|
|
29
|
+
*/
|
|
30
|
+
export declare function createErrorIcon(): SVGSVGElement;
|
|
31
|
+
/**
|
|
32
|
+
* Expired icon - grayscale triangle alert for expired states
|
|
33
|
+
*/
|
|
34
|
+
export declare function createExpiredIcon(): SVGSVGElement;
|
|
35
|
+
/**
|
|
36
|
+
* Method icons
|
|
37
|
+
*/
|
|
38
|
+
export declare function createMethodIcon(iconName: string): SVGSVGElement;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Input View
|
|
3
|
+
*
|
|
4
|
+
* Collects and validates the user's email or phone number.
|
|
5
|
+
* Auto-detects input type and formats accordingly.
|
|
6
|
+
*/
|
|
7
|
+
import type { View } from './base';
|
|
8
|
+
export type IdentityType = 'email' | 'phone';
|
|
9
|
+
export interface IdentityInputResult {
|
|
10
|
+
value: string;
|
|
11
|
+
type: IdentityType;
|
|
12
|
+
}
|
|
13
|
+
export interface IdentityInputViewProps {
|
|
14
|
+
/** Which identity types are allowed */
|
|
15
|
+
allowedTypes: IdentityType[];
|
|
16
|
+
/** Pre-filled value */
|
|
17
|
+
initialValue?: string;
|
|
18
|
+
/** Error message to display */
|
|
19
|
+
error?: string;
|
|
20
|
+
/** Called with validated identity */
|
|
21
|
+
onSubmit: (result: IdentityInputResult) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare class IdentityInputView implements View {
|
|
24
|
+
private readonly props;
|
|
25
|
+
private inputElement;
|
|
26
|
+
private labelElement;
|
|
27
|
+
private submitButton;
|
|
28
|
+
private errorContainer;
|
|
29
|
+
private focusTimeoutId;
|
|
30
|
+
private detectedType;
|
|
31
|
+
private readonly boundHandleInput;
|
|
32
|
+
private readonly boundHandleKeyDown;
|
|
33
|
+
private readonly boundHandleSubmit;
|
|
34
|
+
constructor(props: IdentityInputViewProps);
|
|
35
|
+
private get allowsBoth();
|
|
36
|
+
private get allowsEmail();
|
|
37
|
+
private get allowsPhone();
|
|
38
|
+
render(): HTMLElement;
|
|
39
|
+
private getSubtitleText;
|
|
40
|
+
private getLabelText;
|
|
41
|
+
private getPlaceholderText;
|
|
42
|
+
private handleInput;
|
|
43
|
+
private detectAndUpdateType;
|
|
44
|
+
private clearError;
|
|
45
|
+
private showError;
|
|
46
|
+
private handleSubmit;
|
|
47
|
+
destroy(): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* View Components Index
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all view components for the identity modal.
|
|
5
|
+
*/
|
|
6
|
+
export * from './base';
|
|
7
|
+
export * from './loading';
|
|
8
|
+
export * from './identity-input';
|
|
9
|
+
export * from './method-select';
|
|
10
|
+
export * from './totp-verify';
|
|
11
|
+
export * from './passkey';
|
|
12
|
+
export * from './passkey-prompt';
|
|
13
|
+
export * from './sparklink-waiting';
|
|
14
|
+
export * from './error';
|
|
15
|
+
export * from './service-unavailable';
|
|
16
|
+
export * from './app-not-activated';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loading View
|
|
3
|
+
*
|
|
4
|
+
* Displays a loading spinner with optional message.
|
|
5
|
+
*/
|
|
6
|
+
import type { View } from './base';
|
|
7
|
+
export interface LoadingViewProps {
|
|
8
|
+
message?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class LoadingView implements View {
|
|
11
|
+
private readonly message;
|
|
12
|
+
constructor(props?: LoadingViewProps);
|
|
13
|
+
render(): HTMLElement;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Method Select View
|
|
3
|
+
*
|
|
4
|
+
* Displays available authentication methods for the user to choose from.
|
|
5
|
+
*/
|
|
6
|
+
import type { View } from './base';
|
|
7
|
+
import type { MethodMetadata } from '../types';
|
|
8
|
+
export interface MethodSelectViewProps {
|
|
9
|
+
email: string;
|
|
10
|
+
methods: MethodMetadata[];
|
|
11
|
+
onSelectMethod: (method: MethodMetadata) => void;
|
|
12
|
+
onBack: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare class MethodSelectView implements View {
|
|
15
|
+
private readonly props;
|
|
16
|
+
private backLink;
|
|
17
|
+
private methodButtons;
|
|
18
|
+
private readonly boundHandleBack;
|
|
19
|
+
private readonly methodClickHandlers;
|
|
20
|
+
constructor(props: MethodSelectViewProps);
|
|
21
|
+
render(): HTMLElement;
|
|
22
|
+
private createBackLink;
|
|
23
|
+
private createMethodButton;
|
|
24
|
+
private getMethodIcon;
|
|
25
|
+
/**
|
|
26
|
+
* Clean up event listeners to prevent memory leaks.
|
|
27
|
+
*/
|
|
28
|
+
destroy(): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passkey Registration Prompt View
|
|
3
|
+
*
|
|
4
|
+
* Shown after successful PIN verification to encourage users to add a passkey.
|
|
5
|
+
* Includes benefits list and skip option with 30-day cookie suppression.
|
|
6
|
+
*/
|
|
7
|
+
import type { View } from './base';
|
|
8
|
+
export interface PasskeyPromptViewProps {
|
|
9
|
+
email: string;
|
|
10
|
+
onAddPasskey: () => void;
|
|
11
|
+
onSkip: () => void;
|
|
12
|
+
/** Error message to display when registration fails */
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class PasskeyPromptView implements View {
|
|
16
|
+
private readonly props;
|
|
17
|
+
private addButton;
|
|
18
|
+
private skipLink;
|
|
19
|
+
private readonly boundHandleAdd;
|
|
20
|
+
private readonly boundHandleSkip;
|
|
21
|
+
constructor(props: PasskeyPromptViewProps);
|
|
22
|
+
render(): HTMLElement;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passkey View
|
|
3
|
+
*
|
|
4
|
+
* Handles WebAuthn passkey registration and verification.
|
|
5
|
+
*/
|
|
6
|
+
import type { View } from './base';
|
|
7
|
+
export interface PasskeyViewProps {
|
|
8
|
+
email: string;
|
|
9
|
+
mode: 'register' | 'verify';
|
|
10
|
+
error?: string;
|
|
11
|
+
onStart: () => void;
|
|
12
|
+
onBack: () => void;
|
|
13
|
+
/** Optional fallback to email/SMS code if passkey fails */
|
|
14
|
+
onFallback?: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare class PasskeyView implements View {
|
|
17
|
+
private readonly props;
|
|
18
|
+
private actionButton;
|
|
19
|
+
private errorContainer;
|
|
20
|
+
private backLink;
|
|
21
|
+
private fallbackLink;
|
|
22
|
+
private readonly boundHandleBack;
|
|
23
|
+
private readonly boundHandleStart;
|
|
24
|
+
private readonly boundHandleFallback;
|
|
25
|
+
constructor(props: PasskeyViewProps);
|
|
26
|
+
render(): HTMLElement;
|
|
27
|
+
private createFallbackLink;
|
|
28
|
+
private createBackLink;
|
|
29
|
+
private handleStart;
|
|
30
|
+
/**
|
|
31
|
+
* Re-enable the button and show error after a failed attempt.
|
|
32
|
+
*/
|
|
33
|
+
showError(message: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Clean up event listeners to prevent memory leaks.
|
|
36
|
+
*/
|
|
37
|
+
destroy(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service Unavailable View
|
|
3
|
+
*
|
|
4
|
+
* Shown when the identity config endpoint is unreachable.
|
|
5
|
+
* Clean, professional, branded — no error codes or technical jargon.
|
|
6
|
+
*/
|
|
7
|
+
import type { View } from './base';
|
|
8
|
+
export interface ServiceUnavailableViewProps {
|
|
9
|
+
onRetry: () => void;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare class ServiceUnavailableView implements View {
|
|
13
|
+
private readonly props;
|
|
14
|
+
private retryButton;
|
|
15
|
+
private closeButton;
|
|
16
|
+
private readonly boundHandleRetry;
|
|
17
|
+
private readonly boundHandleClose;
|
|
18
|
+
constructor(props: ServiceUnavailableViewProps);
|
|
19
|
+
render(): HTMLElement;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SparkLink Waiting View
|
|
3
|
+
*
|
|
4
|
+
* Displays a waiting state while user checks their email for the SparkLink.
|
|
5
|
+
* Shows countdown timer and provides fallback to verification code.
|
|
6
|
+
*/
|
|
7
|
+
import type { View } from './base';
|
|
8
|
+
export interface SparkLinkWaitingViewProps {
|
|
9
|
+
email: string;
|
|
10
|
+
expiresAt: number;
|
|
11
|
+
onResend: () => void;
|
|
12
|
+
onFallback: () => void;
|
|
13
|
+
onBack: () => void;
|
|
14
|
+
onExpired: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare class SparkLinkWaitingView implements View {
|
|
17
|
+
private readonly props;
|
|
18
|
+
private expirationTimer;
|
|
19
|
+
private resendTimer;
|
|
20
|
+
private countdownElement;
|
|
21
|
+
private countdownSection;
|
|
22
|
+
private waitingSection;
|
|
23
|
+
private resendButton;
|
|
24
|
+
private backLink;
|
|
25
|
+
private fallbackButton;
|
|
26
|
+
private readonly boundHandleBack;
|
|
27
|
+
private readonly boundHandleResend;
|
|
28
|
+
private readonly boundHandleFallback;
|
|
29
|
+
constructor(props: SparkLinkWaitingViewProps);
|
|
30
|
+
render(): HTMLElement;
|
|
31
|
+
private createBackLink;
|
|
32
|
+
private formatTime;
|
|
33
|
+
private startExpirationTimer;
|
|
34
|
+
/**
|
|
35
|
+
* Switch to expired state - static icon, no animation, helpful message
|
|
36
|
+
*/
|
|
37
|
+
private showExpiredState;
|
|
38
|
+
private handleResend;
|
|
39
|
+
destroy(): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TOTP Verification View
|
|
3
|
+
*
|
|
4
|
+
* Collects and validates the 6-digit TOTP code sent via email or SMS.
|
|
5
|
+
*/
|
|
6
|
+
import type { View } from './base';
|
|
7
|
+
export interface TotpVerifyViewProps {
|
|
8
|
+
email: string;
|
|
9
|
+
method: 'email' | 'sms';
|
|
10
|
+
error?: string;
|
|
11
|
+
/** UTC timestamp (Unix seconds) when backoff expires and next attempt is allowed */
|
|
12
|
+
backoffExpires?: number;
|
|
13
|
+
onSubmit: (code: string) => void;
|
|
14
|
+
onResend: () => void;
|
|
15
|
+
onBack: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare class TotpVerifyView implements View {
|
|
18
|
+
private readonly props;
|
|
19
|
+
private inputElements;
|
|
20
|
+
private submitButton;
|
|
21
|
+
private resendButton;
|
|
22
|
+
private backLink;
|
|
23
|
+
private errorContainer;
|
|
24
|
+
private resendTimer;
|
|
25
|
+
private backoffTimer;
|
|
26
|
+
private backoffSeconds;
|
|
27
|
+
private focusTimeoutId;
|
|
28
|
+
private autoSubmitTimeoutId;
|
|
29
|
+
private isSubmitting;
|
|
30
|
+
private readonly boundHandleBack;
|
|
31
|
+
private readonly boundHandleResend;
|
|
32
|
+
private readonly boundHandleSubmit;
|
|
33
|
+
private readonly inputHandlers;
|
|
34
|
+
constructor(props: TotpVerifyViewProps);
|
|
35
|
+
render(): HTMLElement;
|
|
36
|
+
private createBackLink;
|
|
37
|
+
private createInputGroup;
|
|
38
|
+
private handleInput;
|
|
39
|
+
private handleKeyDown;
|
|
40
|
+
private handlePaste;
|
|
41
|
+
private checkAutoSubmit;
|
|
42
|
+
private getCode;
|
|
43
|
+
private clearError;
|
|
44
|
+
private showError;
|
|
45
|
+
private handleSubmit;
|
|
46
|
+
/**
|
|
47
|
+
* Start backoff countdown using UTC timestamp.
|
|
48
|
+
* Derives remaining seconds client-side for accuracy.
|
|
49
|
+
*/
|
|
50
|
+
private startBackoff;
|
|
51
|
+
private updateSubmitButton;
|
|
52
|
+
private disableInputs;
|
|
53
|
+
private handleResend;
|
|
54
|
+
/**
|
|
55
|
+
* Clean up event listeners, timers, and intervals to prevent memory leaks.
|
|
56
|
+
*/
|
|
57
|
+
destroy(): void;
|
|
58
|
+
}
|