Skip to content
Get startedGetting started →

decryptSecretVaultWithPasskey

Performs the passkey assertion for a parsed vault and decrypts its secret. Runs one navigator.credentials.get() ceremony.

import { decryptSecretVaultWithPasskey } from "@category-labs/mera";
import {
decryptSecretVaultWithPasskey,
parseSecretVault,
} from "@category-labs/mera";
const vault = parseSecretVault(localStorage.getItem("vault"));
const secret = await decryptSecretVaultWithPasskey({
rpId: "account.example.com",
vault,
});
try {
// use the secret bytes
} finally {
secret.fill(0);
}

options is a DecryptSecretVaultWithPasskeyOptions.

  • Type: string
  • Required

Relying party ID for the WebAuthn assertion. It must match the ID under which the vault’s passkey was created.

  • Type: PasskeySecretVault
  • Required

A parsed secret vault; parseSecretVault produces one from untrusted stored data. The assertion is restricted to the credential stored in the vault.

  • Type: number
  • Optional; browser defaults apply when omitted

WebAuthn timeout in milliseconds.

Promise<Uint8Array>: the decrypted secret bytes as a fresh allocation.

The WebAuthn challenge is generated internally.