lucia-sdk 0.9.1 → 0.9.2

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.
Files changed (39) hide show
  1. package/dist/__tests__/auto-init.test.d.ts +5 -5
  2. package/dist/__tests__/base/index.test.d.ts +1 -1
  3. package/dist/__tests__/core/index.test.d.ts +1 -1
  4. package/dist/__tests__/integration/auto-init-integration.test.d.ts +9 -9
  5. package/dist/__tests__/integration/auto-track-integration.test.d.ts +4 -4
  6. package/dist/__tests__/integration/sdk-integration.test.d.ts +1 -1
  7. package/dist/__tests__/utils/click-tracker.test.d.ts +4 -4
  8. package/dist/__tests__/utils/data.test.d.ts +7 -7
  9. package/dist/__tests__/utils/evm.test.d.ts +1 -1
  10. package/dist/__tests__/utils/http-client.test.d.ts +1 -1
  11. package/dist/__tests__/utils/privacy.test.d.ts +4 -4
  12. package/dist/__tests__/utils/session.test.d.ts +1 -1
  13. package/dist/__tests__/utils/solana.test.d.ts +1 -1
  14. package/dist/__tests__/utils/store.test.d.ts +1 -1
  15. package/dist/base/index.d.ts +12 -12
  16. package/dist/constants.d.ts +2 -2
  17. package/dist/core/index.d.ts +65 -64
  18. package/dist/index.d.ts +5 -6
  19. package/dist/index.es.js +1 -18
  20. package/dist/index.es.js.map +1 -1
  21. package/dist/index.js +1 -18
  22. package/dist/index.js.map +1 -1
  23. package/dist/package.json +37 -47
  24. package/dist/types.d.ts +100 -99
  25. package/dist/umd/lucia-sdk-0.9.2.min.js +1 -0
  26. package/dist/umd/lucia-sdk-latest.min.js +1 -18
  27. package/dist/utils/click-tracker.d.ts +100 -100
  28. package/dist/utils/data.d.ts +98 -99
  29. package/dist/utils/evm.d.ts +69 -75
  30. package/dist/utils/http-client.d.ts +17 -17
  31. package/dist/utils/logger.d.ts +7 -7
  32. package/dist/utils/privacy.d.ts +33 -33
  33. package/dist/utils/session.d.ts +51 -51
  34. package/dist/utils/solana.d.ts +50 -50
  35. package/dist/utils/store.d.ts +14 -14
  36. package/dist/version.d.ts +1 -1
  37. package/package.json +37 -47
  38. package/CHANGELOG.md +0 -189
  39. package/dist/umd/lucia-sdk-0.9.1.min.js +0 -18
@@ -1,99 +1,98 @@
1
- import { BrowserData, WalletData } from '../types';
2
- /**
3
- * Collects static browser and hardware data that's unlikely to change during a session.
4
- * This data can be cached for performance optimization.
5
- *
6
- * @returns {BrowserData} Static browser and hardware data including device capabilities,
7
- * screen specifications, and browser features.
8
- */
9
- export declare function getBrowserData(): BrowserData;
10
- declare global {
11
- interface Function {
12
- cachedData?: any;
13
- }
14
- }
15
- /**
16
- * Collects dynamic wallet information that may change during a session.
17
- * This data should be fetched each time it's needed for up-to-date values.
18
- *
19
- * @returns {Promise<WalletData>} Dynamic wallet data including addresses and provider information.
20
- */
21
- export declare function getWalletData(): Promise<WalletData>;
22
- /**
23
- * Extracts tracking parameters from the current URL.
24
- * Captures UTM parameters, ID-related values, and referrer information.
25
- *
26
- * @returns {Record<string, string>} An object containing all tracking parameters
27
- * from the current URL as key-value pairs.
28
- */
29
- export declare function getUtmParams(): Record<string, string>;
30
- /**
31
- * Safely executes a function and handles any exceptions that may occur.
32
- * Provides type safety through function overloads.
33
- *
34
- * @template T - The return type of the function
35
- * @param {() => T} fn - The function to execute safely
36
- * @param {T} [fallback] - Optional fallback value to return if the function throws
37
- * @returns {T | undefined} The result of the function or fallback/undefined if it throws
38
- * @example
39
- * // Returns 42 or undefined if window.answer doesn't exist
40
- * const answer = safeAccess(() => window.answer);
41
- *
42
- * // Returns window.width or 800 if accessing window.width throws
43
- * const width = safeAccess(() => window.width, 800);
44
- */
45
- export declare function safeAccess<T>(fn: () => T): T | undefined;
46
- export declare function safeAccess<T>(fn: () => T, fallback: T): T;
47
- /**
48
- * Filters an object by removing all falsy values (undefined, null, false, 0, '', NaN)
49
- * from its properties.
50
- *
51
- * @template T - The type of the input object
52
- * @param {T} obj - The object to filter
53
- * @returns {Partial<T>} A new object containing only the properties with truthy values
54
- * @example
55
- * // Returns { name: 'John', age: 30 }
56
- * filterObject({ name: 'John', age: 30, address: '', active: false });
57
- */
58
- export declare function filterObject<T extends object>(obj: T): Partial<T>;
59
- /**
60
- * Generates a unique hash based on canvas rendering characteristics.
61
- * Creates a canvas with specific shapes and colors, then generates a SHA-256 hash
62
- * of the canvas data. This serves as a fingerprinting mechanism for the browser.
63
- *
64
- * @returns {string | undefined} A SHA-256 hexadecimal hash string representing the canvas fingerprint,
65
- * or undefined if canvas is not supported or operation fails
66
- */
67
- export declare function getCanvasFingerprint(): string | undefined;
68
- /**
69
- * Detects if the device supports touch events.
70
- * Used to determine if the user is on a touch-enabled device.
71
- *
72
- * @returns {boolean} True if touch events are supported, false otherwise
73
- */
74
- export declare function isTouchEnabled(): boolean;
75
- /**
76
- * Detects if Apple Pay is available in the current browser.
77
- * Checks for the presence and functionality of the ApplePaySession API.
78
- *
79
- * @returns {boolean | undefined} True if Apple Pay is available, false if it's not,
80
- * or undefined if detection fails
81
- */
82
- export declare function getApplePayAvailable(): boolean | undefined;
83
- /**
84
- * Detects the user's contrast preference setting from the browser.
85
- * Uses the matchMedia API to determine if the user has specified any
86
- * contrast preference in their system settings.
87
- *
88
- * @returns {string | undefined} The contrast preference ('None', 'More', 'Less', 'ForcedColors'),
89
- * or undefined if detection fails
90
- */
91
- export declare function getContrastPreference(): string | undefined;
92
- /**
93
- * Detects the color gamuts supported by the user's device.
94
- * Uses the matchMedia API to test for support of various color gamut formats.
95
- *
96
- * @returns {string[]} An array of supported color gamut identifiers
97
- * (e.g., 'rec2020', 'p3', 'srgb', etc.)
98
- */
99
- export declare function getColorGamut(): string[];
1
+ import { BrowserData, WalletData } from '../types';
2
+ /**
3
+ * Collects static browser and hardware data that's unlikely to change during a session.
4
+ * This data can be cached for performance optimization.
5
+ *
6
+ * @returns {Promise<BrowserData>} Static browser and hardware data including device capabilities,
7
+ * screen specifications, and browser features.
8
+ */
9
+ export declare function getBrowserData(): Promise<BrowserData>;
10
+ /**
11
+ * Clears the browser data cache (useful for testing)
12
+ */
13
+ export declare function clearBrowserDataCache(): void;
14
+ /**
15
+ * Collects dynamic wallet information that may change during a session.
16
+ * This data should be fetched each time it's needed for up-to-date values.
17
+ *
18
+ * @returns {Promise<WalletData>} Dynamic wallet data including addresses and provider information.
19
+ */
20
+ export declare function getWalletData(): Promise<WalletData>;
21
+ /**
22
+ * Extracts tracking parameters from the current URL.
23
+ * Captures UTM parameters, ID-related values, and referrer information.
24
+ *
25
+ * @returns {Record<string, string>} An object containing all tracking parameters
26
+ * from the current URL as key-value pairs.
27
+ */
28
+ export declare function getUtmParams(): Record<string, string>;
29
+ /**
30
+ * Safely executes a function and handles any exceptions that may occur.
31
+ * Provides type safety through function overloads.
32
+ *
33
+ * @template T - The return type of the function
34
+ * @param {() => T} fn - The function to execute safely
35
+ * @param {T} [fallback] - Optional fallback value to return if the function throws
36
+ * @returns {T | undefined} The result of the function or fallback/undefined if it throws
37
+ * @example
38
+ * // Returns 42 or undefined if window.answer doesn't exist
39
+ * const answer = safeAccess(() => window.answer);
40
+ *
41
+ * // Returns window.width or 800 if accessing window.width throws
42
+ * const width = safeAccess(() => window.width, 800);
43
+ */
44
+ export declare function safeAccess<T>(fn: () => T): T | undefined;
45
+ export declare function safeAccess<T>(fn: () => T, fallback: T): T;
46
+ /**
47
+ * Filters an object by removing all falsy values (undefined, null, false, 0, '', NaN)
48
+ * from its properties.
49
+ *
50
+ * @template T - The type of the input object
51
+ * @param {T} obj - The object to filter
52
+ * @returns {Partial<T>} A new object containing only the properties with truthy values
53
+ * @example
54
+ * // Returns { name: 'John', age: 30 }
55
+ * filterObject({ name: 'John', age: 30, address: '', active: false });
56
+ */
57
+ export declare function filterObject<T extends object>(obj: T): Partial<T>;
58
+ /**
59
+ * Generates a unique hash based on canvas rendering characteristics.
60
+ * Creates a canvas with specific shapes and colors, then generates a SHA-256 hash
61
+ * of the canvas data. This serves as a fingerprinting mechanism for the browser.
62
+ *
63
+ * @returns {Promise<string | undefined>} A SHA-256 hexadecimal hash string representing the canvas fingerprint,
64
+ * or undefined if canvas is not supported or operation fails
65
+ */
66
+ export declare function getCanvasFingerprint(): Promise<string | undefined>;
67
+ /**
68
+ * Detects if the device supports touch events.
69
+ * Used to determine if the user is on a touch-enabled device.
70
+ *
71
+ * @returns {boolean} True if touch events are supported, false otherwise
72
+ */
73
+ export declare function isTouchEnabled(): boolean;
74
+ /**
75
+ * Detects if Apple Pay is available in the current browser.
76
+ * Checks for the presence and functionality of the ApplePaySession API.
77
+ *
78
+ * @returns {boolean | undefined} True if Apple Pay is available, false if it's not,
79
+ * or undefined if detection fails
80
+ */
81
+ export declare function getApplePayAvailable(): boolean | undefined;
82
+ /**
83
+ * Detects the user's contrast preference setting from the browser.
84
+ * Uses the matchMedia API to determine if the user has specified any
85
+ * contrast preference in their system settings.
86
+ *
87
+ * @returns {string | undefined} The contrast preference ('None', 'More', 'Less', 'ForcedColors'),
88
+ * or undefined if detection fails
89
+ */
90
+ export declare function getContrastPreference(): string | undefined;
91
+ /**
92
+ * Detects the color gamuts supported by the user's device.
93
+ * Uses the matchMedia API to test for support of various color gamut formats.
94
+ *
95
+ * @returns {string[]} An array of supported color gamut identifiers
96
+ * (e.g., 'rec2020', 'p3', 'srgb', etc.)
97
+ */
98
+ export declare function getColorGamut(): string[];
@@ -1,75 +1,69 @@
1
- /**
2
- * Checks if an Ethereum provider exists in the window object
3
- * @returns boolean indicating if an Ethereum provider exists
4
- */
5
- export declare function checkIfEthereumProviderExists(): boolean;
6
- /**
7
- * Gets the Ethereum address from the connected wallet
8
- * @returns Promise resolving to the Ethereum address or null if not available
9
- */
10
- export declare function getEthereumAddress(): Promise<string | null>;
11
- /**
12
- * Formats an Ethereum address for display by shortening it
13
- * @param address The full Ethereum address
14
- * @returns Shortened address in the format "0x1234...5678"
15
- */
16
- export declare function formatEthereumAddress(address: string): string;
17
- /**
18
- * Sets up listeners for Ethereum account changes
19
- * @param callback Function to call when accounts change
20
- */
21
- export declare function setupEthereumAccountListeners(callback: (accounts: string[]) => void): void;
22
- /**
23
- * Gets the current Ethereum chain ID
24
- * @returns Promise resolving to the chain ID or null if not available
25
- */
26
- export declare function getEthereumChainId(): Promise<string | null>;
27
- /**
28
- * Checks if a wallet is connected and returns the address if it is
29
- * @returns Promise resolving to the connected address or null
30
- */
31
- export declare function getConnectedWalletAddress(): Promise<string | null>;
32
- /**
33
- * Checks if the connected wallet is MetaMask
34
- * @returns boolean indicating if the connected wallet is MetaMask
35
- */
36
- export declare function isMetaMask(): Promise<boolean>;
37
- /**
38
- * Gets the name of the connected wallet
39
- * @returns Promise resolving to the name of the connected wallet, or null if not available
40
- */
41
- export declare function getWalletName(): Promise<string | null>;
42
- /**
43
- * Provider information interface
44
- */
45
- export interface ProviderInfo {
46
- isMetaMask: boolean;
47
- isCoinbaseWallet: boolean;
48
- isWalletConnect: boolean;
49
- isTrust: boolean;
50
- isImToken: boolean;
51
- isBraveWallet: boolean;
52
- isTokenPocket: boolean;
53
- isStatus: boolean;
54
- isTally: boolean;
55
- isAlphaWallet: boolean;
56
- isOpera: boolean;
57
- isCoin98: boolean;
58
- isMathWallet: boolean;
59
- isOneInch: boolean;
60
- isRainbow: boolean;
61
- isBinanceChainWallet: boolean;
62
- isFrame: boolean;
63
- userAgent: string;
64
- chainId?: string;
65
- networkVersion?: string;
66
- name: string;
67
- isPossiblyGenericInjectedProvider?: boolean;
68
- }
69
- declare global {
70
- interface Window {
71
- BinanceChain?: any;
72
- ethereum?: any;
73
- }
74
- }
75
- export declare function getExtendedProviderInfo(): Promise<ProviderInfo | null>;
1
+ /**
2
+ * Checks if an Ethereum provider exists in the window object
3
+ * @returns boolean indicating if an Ethereum provider exists
4
+ */
5
+ export declare function checkIfEthereumProviderExists(): boolean;
6
+ /**
7
+ * Gets the Ethereum address from the connected wallet
8
+ * @returns Promise resolving to the Ethereum address or null if not available
9
+ */
10
+ export declare function getEthereumAddress(): Promise<string | null>;
11
+ /**
12
+ * Formats an Ethereum address for display by shortening it
13
+ * @param address The full Ethereum address
14
+ * @returns Shortened address in the format "0x1234...5678"
15
+ */
16
+ export declare function formatEthereumAddress(address: string): string;
17
+ /**
18
+ * Sets up listeners for Ethereum account changes
19
+ * @param callback Function to call when accounts change
20
+ */
21
+ export declare function setupEthereumAccountListeners(callback: (accounts: string[]) => void): void;
22
+ /**
23
+ * Gets the current Ethereum chain ID
24
+ * @returns Promise resolving to the chain ID or null if not available
25
+ */
26
+ export declare function getEthereumChainId(): Promise<string | null>;
27
+ /**
28
+ * Checks if a wallet is connected and returns the address if it is
29
+ * @returns Promise resolving to the connected address or null
30
+ */
31
+ export declare function getConnectedWalletAddress(): Promise<string | null>;
32
+ /**
33
+ * Checks if the connected wallet is MetaMask
34
+ * @returns boolean indicating if the connected wallet is MetaMask
35
+ */
36
+ export declare function isMetaMask(): Promise<boolean>;
37
+ /**
38
+ * Gets the name of the connected wallet
39
+ * @returns Promise resolving to the name of the connected wallet, or null if not available
40
+ */
41
+ export declare function getWalletName(): Promise<string | null>;
42
+ /**
43
+ * Provider information interface
44
+ */
45
+ export interface ProviderInfo {
46
+ isMetaMask: boolean;
47
+ isCoinbaseWallet: boolean;
48
+ isWalletConnect: boolean;
49
+ isTrust: boolean;
50
+ isImToken: boolean;
51
+ isBraveWallet: boolean;
52
+ isTokenPocket: boolean;
53
+ isStatus: boolean;
54
+ isTally: boolean;
55
+ isAlphaWallet: boolean;
56
+ isOpera: boolean;
57
+ isCoin98: boolean;
58
+ isMathWallet: boolean;
59
+ isOneInch: boolean;
60
+ isRainbow: boolean;
61
+ isBinanceChainWallet: boolean;
62
+ isFrame: boolean;
63
+ userAgent: string;
64
+ chainId?: string;
65
+ networkVersion?: string;
66
+ name: string;
67
+ isPossiblyGenericInjectedProvider?: boolean;
68
+ }
69
+ export declare function getExtendedProviderInfo(): Promise<ProviderInfo | null>;
@@ -1,17 +1,17 @@
1
- import Logger from './logger';
2
- import Store from './store';
3
- declare class HttpClient {
4
- store: typeof Store.store;
5
- baseURL: string;
6
- logger: Logger;
7
- private requestQueue;
8
- private isProcessingQueue;
9
- private initComplete;
10
- constructor(store: typeof Store.store);
11
- private getBaseURL;
12
- get<T extends unknown>(url: string): Promise<T | null>;
13
- post<T extends unknown>(url: string, data: unknown, fireAndForget?: boolean): Promise<T | null>;
14
- private processQueue;
15
- private executePost;
16
- }
17
- export default HttpClient;
1
+ import Logger from './logger';
2
+ import Store from './store';
3
+ declare class HttpClient {
4
+ store: typeof Store.store;
5
+ baseURL: string;
6
+ logger: Logger;
7
+ private requestQueue;
8
+ private isProcessingQueue;
9
+ private initComplete;
10
+ constructor(store: typeof Store.store);
11
+ private getBaseURL;
12
+ get<T extends unknown>(url: string): Promise<T | null>;
13
+ post<T extends unknown>(url: string, data: unknown, fireAndForget?: boolean): Promise<T | null>;
14
+ private processQueue;
15
+ private executePost;
16
+ }
17
+ export default HttpClient;
@@ -1,7 +1,7 @@
1
- import Store from './store';
2
- declare class Logger {
3
- store: typeof Store.store;
4
- constructor(store: typeof Store.store);
5
- log(level: 'log' | 'error' | 'warn' | 'info', ...args: unknown[]): void;
6
- }
7
- export default Logger;
1
+ import Store from './store';
2
+ declare class Logger {
3
+ store: typeof Store.store;
4
+ constructor(store: typeof Store.store);
5
+ log(level: 'log' | 'error' | 'warn' | 'info', ...args: unknown[]): void;
6
+ }
7
+ export default Logger;
@@ -1,33 +1,33 @@
1
- /**
2
- * Privacy utilities for automated click tracking
3
- * Handles sensitive element detection and text sanitization
4
- */
5
- /**
6
- * Privacy guard class for detecting sensitive elements and content
7
- */
8
- export declare class PrivacyGuard {
9
- private sensitiveSelectors;
10
- constructor(additionalSelectors?: string[]);
11
- /**
12
- * Check if an element or its ancestors are sensitive
13
- * @param element Element to check
14
- * @returns true if element should not be tracked
15
- */
16
- isSensitive(element: Element): boolean;
17
- /**
18
- * Check if text content contains sensitive patterns
19
- * @param text Text to check
20
- * @returns true if text appears to contain sensitive data
21
- */
22
- containsSensitiveData(text: string): boolean;
23
- /**
24
- * Sanitize text by removing or masking potentially sensitive content
25
- * @param text Text to sanitize
26
- * @returns Sanitized text
27
- */
28
- sanitizeText(text: string): string;
29
- }
30
- /**
31
- * Default privacy guard instance
32
- */
33
- export declare const defaultPrivacyGuard: PrivacyGuard;
1
+ /**
2
+ * Privacy utilities for automated click tracking
3
+ * Handles sensitive element detection and text sanitization
4
+ */
5
+ /**
6
+ * Privacy guard class for detecting sensitive elements and content
7
+ */
8
+ export declare class PrivacyGuard {
9
+ private sensitiveSelectors;
10
+ constructor(additionalSelectors?: string[]);
11
+ /**
12
+ * Check if an element or its ancestors are sensitive
13
+ * @param element Element to check
14
+ * @returns true if element should not be tracked
15
+ */
16
+ isSensitive(element: Element): boolean;
17
+ /**
18
+ * Check if text content contains sensitive patterns
19
+ * @param text Text to check
20
+ * @returns true if text appears to contain sensitive data
21
+ */
22
+ containsSensitiveData(text: string): boolean;
23
+ /**
24
+ * Sanitize text by removing or masking potentially sensitive content
25
+ * @param text Text to sanitize
26
+ * @returns Sanitized text
27
+ */
28
+ sanitizeText(text: string): string;
29
+ }
30
+ /**
31
+ * Default privacy guard instance
32
+ */
33
+ export declare const defaultPrivacyGuard: PrivacyGuard;
@@ -1,51 +1,51 @@
1
- /**
2
- * Retrieves session data from sessionStorage
3
- * @returns Session data object or null if no session exists
4
- */
5
- export declare function getSessionData(): {
6
- id: string;
7
- hash?: string;
8
- timestamp: number;
9
- } | null;
10
- /**
11
- * Stores a new client session ID in sessionStorage (before init call)
12
- * No hash is generated - hash comes from backend after init
13
- * @returns The newly created session object
14
- */
15
- export declare function storeSessionID(): {
16
- id: string;
17
- timestamp: number;
18
- };
19
- /**
20
- * Updates session storage with server-provided session data (after init call)
21
- * @param serverSession Server session object containing hash and id
22
- * @returns The updated session object
23
- */
24
- export declare function updateSessionFromServer(serverSession: {
25
- hash: string;
26
- id: string;
27
- }): {
28
- id: string;
29
- hash: string;
30
- timestamp: number;
31
- };
32
- /**
33
- * Checks if the current session is valid (exists in sessionStorage)
34
- * @returns Boolean indicating if the session is valid
35
- */
36
- export declare function isSessionValid(): boolean;
37
- /**
38
- * Generates a new session ID using UUID
39
- * @returns Unique session ID
40
- */
41
- export declare function generateSessionID(): string;
42
- /**
43
- * Retrieves the LuciaID data from localStorage
44
- * @returns LuciaID string or null if not found
45
- */
46
- export declare function getLidData(): string | null;
47
- /**
48
- * Gets the current user ID from localStorage
49
- * @returns User ID or null if not found
50
- */
51
- export declare function getUser(): string | null;
1
+ /**
2
+ * Retrieves session data from sessionStorage
3
+ * @returns Session data object or null if no session exists
4
+ */
5
+ export declare function getSessionData(): {
6
+ id: string;
7
+ hash?: string;
8
+ timestamp: number;
9
+ } | null;
10
+ /**
11
+ * Stores a new client session ID in sessionStorage (before init call)
12
+ * No hash is generated - hash comes from backend after init
13
+ * @returns The newly created session object
14
+ */
15
+ export declare function storeSessionID(): {
16
+ id: string;
17
+ timestamp: number;
18
+ };
19
+ /**
20
+ * Updates session storage with server-provided session data (after init call)
21
+ * @param serverSession Server session object containing hash and id
22
+ * @returns The updated session object
23
+ */
24
+ export declare function updateSessionFromServer(serverSession: {
25
+ hash: string;
26
+ id: string;
27
+ }): {
28
+ id: string;
29
+ hash: string;
30
+ timestamp: number;
31
+ };
32
+ /**
33
+ * Checks if the current session is valid (exists in sessionStorage)
34
+ * @returns Boolean indicating if the session is valid
35
+ */
36
+ export declare function isSessionValid(): boolean;
37
+ /**
38
+ * Generates a new session ID using UUID
39
+ * @returns Unique session ID
40
+ */
41
+ export declare function generateSessionID(): string;
42
+ /**
43
+ * Retrieves the LuciaID data from localStorage
44
+ * @returns LuciaID string or null if not found
45
+ */
46
+ export declare function getLidData(): string | null;
47
+ /**
48
+ * Gets the current user ID from localStorage
49
+ * @returns User ID or null if not found
50
+ */
51
+ export declare function getUser(): string | null;