SecureStorageService

Transparent AES-GCM encrypted storage on top of localStorage/sessionStorage. Supports ephemeral in-memory keys for single-session security or passphrase-derived keys via PBKDF2 for cross-session persistence.

TypeScriptexample.ts
import { SecureStorageService } from '@angular-helpers/security'

# Methods

MethodSignatureReturnsDescription
isSupportedisSupported(): booleanbooleanPublic method isSupported.
initWithPassphraseinitWithPassphrase(passphrase: string, explicitSalt?: string): Promise<void>Promise<void>Initializes the service with a passphrase-derived key (PBKDF2 + AES-GCM). The salt is automatically persisted in storage on first call and reused on subsequent calls. Calling this again replaces the active key.
setset(key: string, value: T, namespace?: string): Promise<void>Promise<void>Encrypts and stores a value. A fresh random IV is generated for every write.
getget(key: string, namespace?: string): Promise<T | null>Promise<T | null>Decrypts and returns a stored value. Returns `null` if the key does not exist, was written without encryption, or the ciphertext is corrupted.
removeremove(key: string, namespace?: string): voidvoidRemoves a single entry from storage.
clearclear(namespace?: string): voidvoidClears all entries belonging to a namespace. When called without arguments, clears the entire storage target.
LCP N/A
CLS N/A
INP N/A