@sparkvault/sdk 1.0.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 +720 -0
- package/dist/auto-init.d.ts +51 -0
- package/dist/config.d.ts +25 -0
- package/dist/errors.d.ts +30 -0
- package/dist/http.d.ts +48 -0
- package/dist/identity/api.d.ts +101 -0
- package/dist/identity/container.d.ts +49 -0
- package/dist/identity/handlers/index.d.ts +9 -0
- package/dist/identity/handlers/passkey-handler.d.ts +52 -0
- package/dist/identity/handlers/sparklink-handler.d.ts +43 -0
- package/dist/identity/handlers/totp-handler.d.ts +52 -0
- package/dist/identity/index.d.ts +69 -0
- package/dist/identity/inline-container.d.ts +60 -0
- package/dist/identity/methods.d.ts +23 -0
- package/dist/identity/modal.d.ts +74 -0
- package/dist/identity/renderer.d.ts +97 -0
- package/dist/identity/state.d.ts +95 -0
- package/dist/identity/styles.d.ts +22 -0
- package/dist/identity/types.d.ts +183 -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 +27 -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 +34 -0
- package/dist/identity/views/identity-input.d.ts +48 -0
- package/dist/identity/views/index.d.ts +14 -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 +22 -0
- package/dist/identity/views/passkey.d.ts +38 -0
- package/dist/identity/views/sparklink-waiting.d.ts +33 -0
- package/dist/identity/views/totp-verify.d.ts +58 -0
- package/dist/index.d.ts +658 -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 +6152 -0
- package/dist/sparkvault.cjs.js.map +1 -0
- package/dist/sparkvault.esm.js +6137 -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 +49 -0
- package/dist/utils/retry.d.ts +32 -0
- package/dist/vaults/index.d.ts +83 -0
- package/dist/vaults/types.d.ts +120 -0
- package/package.json +64 -0
|
@@ -0,0 +1,34 @@
|
|
|
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
|
|
25
|
+
*/
|
|
26
|
+
export declare function createPasskeyIcon(): SVGSVGElement;
|
|
27
|
+
/**
|
|
28
|
+
* Error icon - clean triangle alert
|
|
29
|
+
*/
|
|
30
|
+
export declare function createErrorIcon(): SVGSVGElement;
|
|
31
|
+
/**
|
|
32
|
+
* Method icons
|
|
33
|
+
*/
|
|
34
|
+
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,14 @@
|
|
|
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';
|
|
@@ -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,22 @@
|
|
|
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
|
+
}
|
|
13
|
+
export declare class PasskeyPromptView implements View {
|
|
14
|
+
private readonly props;
|
|
15
|
+
private addButton;
|
|
16
|
+
private skipLink;
|
|
17
|
+
private readonly boundHandleAdd;
|
|
18
|
+
private readonly boundHandleSkip;
|
|
19
|
+
constructor(props: PasskeyPromptViewProps);
|
|
20
|
+
render(): HTMLElement;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
}
|
|
@@ -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,33 @@
|
|
|
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
|
+
}
|
|
15
|
+
export declare class SparkLinkWaitingView implements View {
|
|
16
|
+
private readonly props;
|
|
17
|
+
private expirationTimer;
|
|
18
|
+
private resendTimer;
|
|
19
|
+
private countdownElement;
|
|
20
|
+
private resendButton;
|
|
21
|
+
private backLink;
|
|
22
|
+
private fallbackButton;
|
|
23
|
+
private readonly boundHandleBack;
|
|
24
|
+
private readonly boundHandleResend;
|
|
25
|
+
private readonly boundHandleFallback;
|
|
26
|
+
constructor(props: SparkLinkWaitingViewProps);
|
|
27
|
+
render(): HTMLElement;
|
|
28
|
+
private createBackLink;
|
|
29
|
+
private formatTime;
|
|
30
|
+
private startExpirationTimer;
|
|
31
|
+
private handleResend;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
}
|
|
@@ -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
|
+
}
|