userdnajs
Version:
Community edition of UserDNA JS. A fingerprint generator library for creating unique user identifiers
81 lines (80 loc) • 2.46 kB
TypeScript
/**
* Storage options
*/
interface StorageOptions {
storageType?: 'localStorage' | 'sessionStorage' | 'none';
storagePrefix?: string;
}
/**
* Checks if localStorage is available
* @returns Whether localStorage is available
*/
export declare function isLocalStorageAvailable(): boolean;
/**
* Checks if sessionStorage is available
* @returns Whether sessionStorage is available
*/
export declare function isSessionStorageAvailable(): boolean;
/**
* Checks if IndexedDB is available
* @returns Whether IndexedDB is available
*/
export declare function isIndexedDBAvailable(): boolean;
/**
* Saves a value to localStorage
* @param key - Storage key
* @param value - Value to store
* @returns Whether the operation was successful
*/
export declare function saveToLocalStorage(key: string, value: string): boolean;
/**
* Retrieves a value from localStorage
* @param key - Storage key
* @returns Retrieved value or null if not found
*/
export declare function getFromLocalStorage<T>(key: string): T | null;
/**
* Removes a value from localStorage
* @param key - Storage key
* @returns Whether the operation was successful
*/
export declare function removeFromLocalStorage(key: string): boolean;
/**
* Saves a value to sessionStorage
* @param key - Storage key
* @param value - Value to store
* @returns Whether the operation was successful
*/
export declare function saveToSessionStorage(key: string, value: string): boolean;
/**
* Retrieves a value from sessionStorage
* @param key - Storage key
* @returns Retrieved value or null if not found
*/
export declare function getFromSessionStorage<T>(key: string): T | null;
/**
* Removes a value from sessionStorage
* @param key - Storage key
* @returns Whether the operation was successful
*/
export declare function removeFromSessionStorage(key: string): boolean;
/**
* Storage utilities for UserDNA
*/
export declare const Storage: {
getKey: (prefix?: string) => string;
/**
* Saves fingerprint data to the specified storage
* @param data - Data to store
* @param options - Storage options
* @returns Whether the operation was successful
*/
save: (data: any, options?: StorageOptions) => boolean;
/**
* Retrieves fingerprint data from the specified storage
* @param options - Storage options
* @returns Retrieved data or null if not found
*/
get: <T>(options?: StorageOptions) => T | null;
};
export {};