Evaluates an existing passkey and encrypts one secret into a vault.
@param ― options - Passkey assertion inputs and secret bytes.
@returns ― A JSON-safe secret vault containing the selected credential metadata.
@remarks ―
Runs one assertion ceremony and shows one user-verification prompt.
A fresh random PRF salt is generated internally and stored in the returned
vault.
@throws ― MeraError with code PRF_UNAVAILABLE when the authenticator does not return a usable 32-byte PRF output.
@throws ― MeraError with code INPUT_INVALID when secret is empty, or credential.credentialId is empty or not canonical base64url.
@throws ― MeraError with code CRYPTO_UNAVAILABLE when crypto.getRandomValues or crypto.subtle is unavailable, or crypto.subtle lacks the HKDF or AES-GCM support the vault needs.
@throws ― MeraError with code PASSKEY_CANCELLED when the person dismisses the prompt, it times out, or no passkey answers.
@throws ― MeraError with code PASSKEY_OPERATION_FAILED when WebAuthn is unavailable, fails for another reason, or returns an unexpected credential.
Evaluates an existing passkey and encrypts one secret into a vault.
@param ― options - Passkey assertion inputs and secret bytes.
@returns ― A JSON-safe secret vault containing the selected credential metadata.
@remarks ―
Runs one assertion ceremony and shows one user-verification prompt.
A fresh random PRF salt is generated internally and stored in the returned
vault.
@throws ― MeraError with code PRF_UNAVAILABLE when the authenticator does not return a usable 32-byte PRF output.
@throws ― MeraError with code INPUT_INVALID when secret is empty, or credential.credentialId is empty or not canonical base64url.
@throws ― MeraError with code CRYPTO_UNAVAILABLE when crypto.getRandomValues or crypto.subtle is unavailable, or crypto.subtle lacks the HKDF or AES-GCM support the vault needs.
@throws ― MeraError with code PASSKEY_CANCELLED when the person dismisses the prompt, it times out, or no passkey answers.
@throws ― MeraError with code PASSKEY_OPERATION_FAILED when WebAuthn is unavailable, fails for another reason, or returns an unexpected credential.
Parses and validates untrusted secret-vault JSON or objects.
Only version 1 vaults are accepted. The credential ID, PRF salt, nonce, and
ciphertext are validated as canonical base64url and length-checked. Unknown
fields are dropped from the returned vault.
@param ― value - Secret vault as JSON text or an untrusted object.
@returns ― A validated secret vault.
@throws ― MeraError with code VAULT_FORMAT_INVALID when required structure, version, or encoded data is invalid.
Parses and validates untrusted secret-vault JSON or objects.
Only version 1 vaults are accepted. The credential ID, PRF salt, nonce, and
ciphertext are validated as canonical base64url and length-checked. Unknown
fields are dropped from the returned vault.
@param ― value - Secret vault as JSON text or an untrusted object.
@returns ― A validated secret vault.
@throws ― MeraError with code VAULT_FORMAT_INVALID when required structure, version, or encoded data is invalid.
The getItem() method of the Storage interface, when passed a key name, will return that key's value, or null if the key does not exist, in the given Storage object.
The TextEncoder.encode() method takes a string as input, and returns a Global_Objects/Uint8Array containing the text given in parameters encoded with the specific method for that TextEncoder object.
Evaluates an existing passkey and encrypts one secret into a vault.
@param ― options - Passkey assertion inputs and secret bytes.
@returns ― A JSON-safe secret vault containing the selected credential metadata.
@remarks ―
Runs one assertion ceremony and shows one user-verification prompt.
A fresh random PRF salt is generated internally and stored in the returned
vault.
@throws ― MeraError with code PRF_UNAVAILABLE when the authenticator does not return a usable 32-byte PRF output.
@throws ― MeraError with code INPUT_INVALID when secret is empty, or credential.credentialId is empty or not canonical base64url.
@throws ― MeraError with code CRYPTO_UNAVAILABLE when crypto.getRandomValues or crypto.subtle is unavailable, or crypto.subtle lacks the HKDF or AES-GCM support the vault needs.
@throws ― MeraError with code PASSKEY_CANCELLED when the person dismisses the prompt, it times out, or no passkey answers.
@throws ― MeraError with code PASSKEY_OPERATION_FAILED when WebAuthn is unavailable, fails for another reason, or returns an unexpected credential.
createSecretVaultWithExistingPasskey({
rpId: string
Relying party ID for the WebAuthn assertion.
rpId: "account.example.com",
credential?: PasskeyCredentialMetadata |undefined
Credential metadata to restrict the assertion to one passkey. When
omitted, WebAuthn may choose any discoverable credential for the relying
party.
The setItem() method of the Storage interface, when passed a key name and value, will add that key to the given Storage object, or update that key's value if it already exists.
Optional; when omitted, WebAuthn may choose any discoverable credential for the relying party
Credential metadata that restricts the assertion to one passkey. Reported transports are retained in the new vault when the selected credential matches.
Versioned JSON-safe vault holding one secret encrypted behind a passkey.
The secret bytes are opaque to the library.
PasskeySecretVault } from"@category-labs/mera";
type
type ReturnType =Promise<PasskeySecretVault>
ReturnType=
interface Promise<T>
Represents the completion of an asynchronous operation
Promise<
type PasskeySecretVault = {
readonly version:1;
readonly credential:PasskeyCredentialMetadata;
readonly prfSalt:string;
readonly nonce:string;
readonly ciphertext:string;
}
Versioned JSON-safe vault holding one secret encrypted behind a passkey.
The secret bytes are opaque to the library.
PasskeySecretVault>;
A JSON-safe vault with version, credential, prfSalt, nonce, and ciphertext. It contains the selected credential’s metadata and a fresh random 32-byte PRF salt. The secret vault format page documents every field.
PRF_UNAVAILABLE: the authenticator did not return a usable 32-byte PRF output.
INPUT_INVALID: secret is empty, or credential.credentialId is empty or not canonical base64url.
CRYPTO_UNAVAILABLE: the runtime provides no crypto.getRandomValues or crypto.subtle, or its crypto.subtle lacks the HKDF or AES-GCM support the vault needs.