@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.
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { verifyError } from './verify-error.js';
|
|
|
|
const cfg = { rpId: 'gym.example.com', origin: 'https://gym.example.com' };
|
|
|
|
test('names the configured values when the RP ID does not match', () => {
|
|
const out = verifyError(new Error('Unexpected RP ID hash'), cfg);
|
|
assert.match(out, /RP_ID=gym\.example\.com/);
|
|
assert.match(out, /ORIGIN=https:\/\/gym\.example\.com/);
|
|
assert.match(out, /SELF_HOSTING\.md/);
|
|
});
|
|
|
|
test('does the same for an origin mismatch, on login and on registration', () => {
|
|
assert.match(verifyError(new Error('Unexpected authentication response origin'), cfg), /must match the address you opened/);
|
|
assert.match(verifyError(new Error('Unexpected registration response origin'), cfg), /must match the address you opened/);
|
|
});
|
|
|
|
test('leaves an unrelated verification failure alone', () => {
|
|
assert.equal(
|
|
verifyError(new Error('Signature verification failed'), cfg),
|
|
'verification failed: Signature verification failed'
|
|
);
|
|
});
|
|
|
|
test('does not throw on a missing or empty error', () => {
|
|
assert.equal(verifyError(undefined, cfg), 'verification failed: verification failed');
|
|
assert.equal(verifyError(new Error(''), cfg), 'verification failed: verification failed');
|
|
});
|