@simplewebauthn reports a mismatch as "Unexpected RP ID hash", which tells a self-hoster nothing about their own .env — and this is the most common support question in #install-help, where charliebelt is currently stuck behind a Cloudflare Tunnel with values that look right. The error now names both configured values back and points at the docs. Neither is a secret: one is the address bar, the other its hostname. Extracted as api/verify-error.js so it can be tested without booting a server that opens files and a port, following push-messages.js. SELF_HOSTING.md gets the diagnosis in order: read what the server logged on startup (it prints rpID and origin, and `docker compose restart` does not re-read .env), then the exact shape of each value as a table, then the reverse-proxy case, then www., then that changing the hostname invalidates existing passkeys. Plus the thing adam934912 called a blocker: on a LAN without certificates there is nothing to configure that makes passkeys work.
13 lines
847 B
JavaScript
13 lines
847 B
JavaScript
// @simplewebauthn reports an RP_ID or origin mismatch as an opaque "Unexpected ..." string, and
|
|
// whoever reads it in the browser has no way to connect that to their .env. A misconfigured
|
|
// RP_ID/ORIGIN is the single most common self-hosting failure (see docs/SELF_HOSTING.md), so
|
|
// name both values back. Neither is a secret: one is the address bar, the other its hostname.
|
|
const MISCONFIGURED = /unexpected (rp id|authentication response origin|registration response origin)/i;
|
|
|
|
export function verifyError(e, { rpId, origin } = {}) {
|
|
const msg = String((e && e.message) || 'verification failed');
|
|
if (!MISCONFIGURED.test(msg)) return 'verification failed: ' + msg;
|
|
return `${msg} — this server is configured with RP_ID=${rpId} and ORIGIN=${origin}, and both `
|
|
+ 'must match the address you opened. See docs/SELF_HOSTING.md.';
|
|
}
|