<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/webauthn-passkey-recovery-fallbacks-and-backup-codes-in-node-js-qcnqwp7gg" -->

---
title: WebAuthn Passkey Recovery: Fallbacks and Backup Codes in...
description: A detailed Node.js implementation guide for building zero-trust WebAuthn passkey recovery when a user's authenticator is lost, stolen, or wiped. It covers...
canonical: https://daily.dev/posts/webauthn-passkey-recovery-fallbacks-and-backup-codes-in-node-js-qcnqwp7gg
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: WebAuthn Passkey Recovery: Fallbacks and Backup Codes in Node.js | daily.dev
og:description: A detailed Node.js implementation guide for building zero-trust WebAuthn passkey recovery when a user's authenticator is lost, stolen, or wiped. It covers...
og:url: https://daily.dev/posts/webauthn-passkey-recovery-fallbacks-and-backup-codes-in-node-js-qcnqwp7gg
og:image: https://api.daily.dev/og/posts/qCnqwp7GG.png
og:image:alt: WebAuthn Passkey Recovery: Fallbacks and Backup Codes in Node.js
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# WebAuthn Passkey Recovery: Fallbacks and Backup Codes in Node.js

**[SitePoint](https://daily.dev/sources/sitepoint)** · 22 min read · 0 upvotes · 0 comments

## Summary

A detailed Node.js implementation guide for building zero-trust WebAuthn passkey recovery when a user's authenticator is lost, stolen, or wiped. It covers generating 128-bit-entropy backup codes with crypto.randomBytes, hashing them individually with Argon2id at OWASP parameters, verifying them via a rate-limited constant-time endpoint, issuing 10-minute TTL JWT recovery sessions in HttpOnly cookies, and registering a new passkey through @simplewebauthn/server v10 while selectively revoking only pre-recovery credentials. It explains why passwords should never be reintroduced as a fallback, contrasts backup codes with TOTP and SMS OTP entropy, describes a six-state recovery state machine, and closes with a hardening checklist and common implementation pitfalls (v10's Uint8Array userID requirement, case-folding entropy loss, revoking all credentials instead of only compromised ones).

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.sitepoint.com/webauthn-passkey-recovery-account-fallbacks-nodejs>

## Questions this post answers

### How many bits of entropy should a WebAuthn passkey backup code have, and how many characters does that require?

Backup codes should carry at least 128 bits of entropy to resist offline brute-force, since they may be stored for months or years. This requires roughly 22 base64url characters generated from 16 bytes of crypto.randomBytes output. The full 64-symbol base64url alphabet must be preserved; calling toUpperCase() collapses it to about 38 symbols, dropping effective entropy to roughly 116 bits.

_daily.dev surfaces implementation details like this for teams hardening passwordless account recovery._

### What Argon2id parameters does OWASP recommend for hashing backup codes or passwords?

OWASP's Argon2id minimum recommendation is a memory cost of 19456 KiB (19 MiB), a time cost of 2 iterations, and a parallelism of 1. Each backup code should be hashed individually with these parameters rather than as a batch, so that a database leak exposing one hash never reveals the other codes. Hashing ten codes in parallel keeps wall-clock latency around 50-100ms instead of 500-1000ms sequentially.

_developers tuning Argon2id settings can track hashing best practices on daily.dev._

### In @simplewebauthn/server v10, why does passing a string for userID throw an error during passkey registration?

Version 10 of @simplewebauthn/server requires the userID field in generateRegistrationOptions to be a Uint8Array, not a plain string; passing a string causes a type error. The fix is to wrap the user identifier with Buffer.from(userId, 'utf-8') before passing it in. The library also restructured registrationInfo so credential fields like id, publicKey, and counter now live under verification.registrationInfo.credential.

_track breaking API changes like this on daily.dev before they stall a passkey migration._

## Similar posts on daily.dev

- [Passkey Recovery and Lockout: The Complete Guide for Relying Parties](https://daily.dev/posts/passkey-recovery-and-lockout-the-complete-guide-for-relying-parties-9r5gr95zb) · Security Boulevard · 0 upvotes · 0 comments
- [Passwordless Authentication and Identity Theft: Can Passkeys Make the Web Safer?](https://daily.dev/posts/passwordless-authentication-and-identity-theft-can-passkeys-make-the-web-safer--ctnhfcv2s) · SitePoint · 0 upvotes · 0 comments
- [Passkeys in Production: A 2026 Developer Guide](https://daily.dev/posts/passkeys-in-production-a-2026-developer-guide-uprvdh0dz) · Alex CloudStar · 0 upvotes · 0 comments
- [How to Build Passkey Authentication with WebAuthn, Next.js and NestJS](https://daily.dev/posts/how-to-build-passkey-authentication-with-webauthn-next-js-and-nestjs-ecvxpqbbu) · freeCodeCamp · 4 upvotes · 2 comments
- [39 New Methods That Compromise Passkey Authentication](https://daily.dev/posts/39-new-methods-that-compromise-passkey-authentication-z1hysnxm6) · BleepingComputer · 1 upvotes · 0 comments

---

Tags: [#nodejs](https://daily.dev/tags/nodejs), [#authentication](https://daily.dev/tags/authentication), [#passkeys](https://daily.dev/tags/passkeys)

[View this post on daily.dev](https://daily.dev/posts/webauthn-passkey-recovery-fallbacks-and-backup-codes-in-node-js-qcnqwp7gg)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"WebAuthn Passkey Recovery: Fallbacks and Backup Codes in Node.js","url":"https://daily.dev/posts/webauthn-passkey-recovery-fallbacks-and-backup-codes-in-node-js-qcnqwp7gg","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/webauthn-passkey-recovery-fallbacks-and-backup-codes-in-node-js-qcnqwp7gg"},"datePublished":"2026-09-18T20:27:09.951Z","dateModified":"2026-09-18T20:27:36.752Z","description":"A detailed Node.js implementation guide for building zero-trust WebAuthn passkey recovery when a user's authenticator is lost, stolen, or wiped. It covers...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/5de91e2e2364683ec3b5085338585384?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/5de91e2e2364683ec3b5085338585384?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"SitePoint","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"SitePoint","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/sitepoint","url":"https://daily.dev/sources/sitepoint"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/webauthn-passkey-recovery-fallbacks-and-backup-codes-in-node-js-qcnqwp7gg","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"nodejs,authentication,passkeys","timeRequired":"PT22M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"SitePoint","item":"https://daily.dev/sources/sitepoint"},{"@type":"ListItem","position":3,"name":"WebAuthn Passkey Recovery: Fallbacks and Backup Codes in Node.js"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/webauthn-passkey-recovery-fallbacks-and-backup-codes-in-node-js-qcnqwp7gg#faq","mainEntity":[{"@type":"Question","name":"How many bits of entropy should a WebAuthn passkey backup code have, and how many characters does that require?","acceptedAnswer":{"@type":"Answer","text":"Backup codes should carry at least 128 bits of entropy to resist offline brute-force, since they may be stored for months or years. This requires roughly 22 base64url characters generated from 16 bytes of crypto.randomBytes output. The full 64-symbol base64url alphabet must be preserved; calling toUpperCase() collapses it to about 38 symbols, dropping effective entropy to roughly 116 bits. daily.dev surfaces implementation details like this for teams hardening passwordless account recovery."}},{"@type":"Question","name":"What Argon2id parameters does OWASP recommend for hashing backup codes or passwords?","acceptedAnswer":{"@type":"Answer","text":"OWASP's Argon2id minimum recommendation is a memory cost of 19456 KiB (19 MiB), a time cost of 2 iterations, and a parallelism of 1. Each backup code should be hashed individually with these parameters rather than as a batch, so that a database leak exposing one hash never reveals the other codes. Hashing ten codes in parallel keeps wall-clock latency around 50-100ms instead of 500-1000ms sequentially. developers tuning Argon2id settings can track hashing best practices on daily.dev."}},{"@type":"Question","name":"In @simplewebauthn/server v10, why does passing a string for userID throw an error during passkey registration?","acceptedAnswer":{"@type":"Answer","text":"Version 10 of @simplewebauthn/server requires the userID field in generateRegistrationOptions to be a Uint8Array, not a plain string; passing a string causes a type error. The fix is to wrap the user identifier with Buffer.from(userId, 'utf-8') before passing it in. The library also restructured registrationInfo so credential fields like id, publicKey, and counter now live under verification.registrationInfo.credential. track breaking API changes like this on daily.dev before they stall a passkey migration."}}]}
```

