locked-storage
Version:
A JavaScript library that provides cryptographically encrypted local and session storage with automatic key/value encryption and synchronous API
52 lines (44 loc) • 1.33 kB
TypeScript
/**
* LockedStorage - TypeScript definitions
* @version 2.0.0
* @license MIT
*/
export declare class LockedStorage {
constructor(masterKey: string, storageType?: 'localStorage' | 'sessionStorage');
/**
* Stores an item with encrypted key and value
* @param key - The key to store the value under
* @param value - The value to store
*/
setItem(key: string, value: string): void;
/**
* Retrieves and decrypts an item by key
* @param key - The key to retrieve the value for
* @returns The decrypted value or null if not found
*/
getItem(key: string): string | null;
/**
* Removes an encrypted item by key
* @param key - The key to remove
*/
removeItem(key: string): void;
/**
* Clears all locked-storage items
*/
clear(): void;
}
/**
* Creates a new LockedStorage instance for localStorage
* @param masterKey - The master key for encryption/decryption
*/
export declare function createLockedLocalStorage(masterKey: string): LockedStorage;
/**
* Creates a new LockedStorage instance for sessionStorage
* @param masterKey - The master key for encryption/decryption
*/
export declare function createLockedSessionStorage(masterKey: string): LockedStorage;
export default {
LockedStorage,
createLockedLocalStorage,
createLockedSessionStorage
};