createSecretVaultWithNewPasskey generates a fresh 32-byte salt per vault, creates the passkey, and encrypts the secret. The salt and credential metadata are stored in the returned vault (vault format).
Creates a passkey and encrypts one secret into a vault.
@param ― options - Passkey creation inputs and secret bytes.
@returns ― A JSON-safe secret vault containing the new credential metadata.
@remarks ―
Runs one creation ceremony and shows one user-verification prompt. On
authenticators that do not evaluate PRF during creation, also runs an
assertion, which shows a second.
A fresh random PRF salt is generated internally and stored in the returned
vault.
A fresh random user handle (user.id) is generated for the new credential,
so each call adds a passkey instead of replacing one.
A runtime without crypto.subtle fails before any prompt. If the fallback
ceremony or vault encryption fails, the passkey from the completed creation
ceremony still exists on the authenticator, but the thrown error does not
carry its metadata.
@throws ― MeraError with code PRF_UNAVAILABLE when the authenticator does not enable PRF or return a usable 32-byte PRF output.
@throws ― MeraError with code INPUT_INVALID when secret is empty.
@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 a 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.
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.
Creates a passkey and encrypts one secret into a vault.
@param ― options - Passkey creation inputs and secret bytes.
@returns ― A JSON-safe secret vault containing the new credential metadata.
@remarks ―
Runs one creation ceremony and shows one user-verification prompt. On
authenticators that do not evaluate PRF during creation, also runs an
assertion, which shows a second.
A fresh random PRF salt is generated internally and stored in the returned
vault.
A fresh random user handle (user.id) is generated for the new credential,
so each call adds a passkey instead of replacing one.
A runtime without crypto.subtle fails before any prompt. If the fallback
ceremony or vault encryption fails, the passkey from the completed creation
ceremony still exists on the authenticator, but the thrown error does not
carry its metadata.
@throws ― MeraError with code PRF_UNAVAILABLE when the authenticator does not enable PRF or return a usable 32-byte PRF output.
@throws ― MeraError with code INPUT_INVALID when secret is empty.
@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 a 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.
createSecretVaultWithNewPasskey({
rp: PasskeyRelyingParty
Relying party identity passed to WebAuthn. id is required so the
fallback assertion can target the same relying party.
rp: {
id: string
Relying party ID: the host the passkey is scoped to.
id:
const rpId:string
rpId,
name: string
Relying party name the authenticator may show.
name: "Example" },
user: {
name: string;
displayName: string;
}
User identity passed to WebAuthn.
user: {
name: string
User name displayed or stored by the authenticator.
name: "account@example.com",
displayName: string
Human-readable display name for the authenticator UI.
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.
Performs the passkey assertion for a vault and decrypts its secret.
@param ― options - Relying party ID and vault.
@returns ― The decrypted secret bytes in a fresh allocation.
@remarks ― Runs one assertion ceremony and shows one user-verification prompt. The
assertion is restricted to the credential stored in the vault.
@throws ― MeraError with code VAULT_FORMAT_INVALID when the vault's required structure, version, or encoded data is invalid.
@throws ― MeraError with code PRF_UNAVAILABLE when the authenticator does not return a usable 32-byte PRF output.
@throws ― MeraError with code DECRYPT_FAILED when AES-GCM authentication fails.
@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.
parseSecretVault,
} from"@category-labs/mera";
asyncfunction
functionunlockPhrase():Promise<string>
unlockPhrase():
interface Promise<T>
Represents the completion of an asynchronous operation
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.
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.
Performs the passkey assertion for a vault and decrypts its secret.
@param ― options - Relying party ID and vault.
@returns ― The decrypted secret bytes in a fresh allocation.
@remarks ― Runs one assertion ceremony and shows one user-verification prompt. The
assertion is restricted to the credential stored in the vault.
@throws ― MeraError with code VAULT_FORMAT_INVALID when the vault's required structure, version, or encoded data is invalid.
@throws ― MeraError with code PRF_UNAVAILABLE when the authenticator does not return a usable 32-byte PRF output.
@throws ― MeraError with code DECRYPT_FAILED when AES-GCM authentication fails.
@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.
decryptSecretVaultWithPasskey({
rpId: string
Relying party ID for the WebAuthn assertion.
rpId,
vault: PasskeySecretVault
Secret vault to decrypt.
vault });
returnnew
var TextDecoder: new (label?:string, options?:TextDecoderOptions) => TextDecoder
The TextDecoder interface represents a decoder for a specific text encoding, such as UTF-8, ISO-8859-2, KOI8-R, GBK, etc.