Skip to content

Conseal is pre-release. The interface can change between releases.

Key storage in IndexedDB

IndexedDB persistence for CryptoKey objects.

saveCryptoKey(name: string, key: CryptoKey): Promise<void>
loadCryptoKey(name: string): Promise<CryptoKey | null>
deleteCryptoKey(name: string): Promise<void>
import { saveCryptoKey, loadCryptoKey, deleteCryptoKey } from '@consealdev/conseal'
// Store a key after generation
await saveCryptoKey('my-ecdh-private', keyPair.privateKey)
// Load it on next page load
const key = await loadCryptoKey('my-ecdh-private')
if (!key) {
// Key not found — prompt user to set up device again
}
// Remove on sign-out
await deleteCryptoKey('my-ecdh-private')
  • Uses IndexedDB database conseal-keys, object store keys.
  • loadCryptoKey() returns null if the name does not exist — always check the return value.
  • deleteCryptoKey() is a no-op if the name does not exist.
  • Non-extractable keys cannot have their bytes read, but same-origin JavaScript can load and use them. XSS prevention is the application’s responsibility.