@proveanything/smartlinks-auth-ui
Version:
Lightweight React authentication UI components with bearer token support and Smartlinks SDK integration
39 lines • 1.25 kB
TypeScript
/**
* Persistent Storage Layer for Smartlinks Auth
*
* Implements a tiered persistence strategy similar to Firebase Auth:
* 1. Primary: IndexedDB (async, large capacity, cross-tab)
* 2. Fallback: localStorage (sync, universal support)
*
* Provides unified async API for all storage operations with automatic
* fallback handling and cross-tab synchronization.
*/
export type StorageBackend = 'indexeddb' | 'localstorage' | 'none';
interface StorageEvent {
type: 'set' | 'remove' | 'clear';
key?: string;
value?: any;
timestamp: number;
}
/**
* Unified persistent storage interface
*/
export interface PersistentStorage {
setItem(key: string, value: any): Promise<void>;
getItem<T>(key: string): Promise<T | null>;
removeItem(key: string): Promise<void>;
clear(): Promise<void>;
isAvailable(): Promise<boolean>;
getBackend(): StorageBackend;
}
export declare function getStorage(): Promise<PersistentStorage>;
/**
* Reset storage (for testing)
*/
export declare function resetStorage(): void;
/**
* Listen for storage changes from other tabs
*/
export declare function onStorageChange(callback: (event: StorageEvent) => void): () => void;
export {};
//# sourceMappingURL=persistentStorage.d.ts.map