defineService and route to the endpoint handlers, the AFAuth protocol endpoints self-verify — you don’t call the verifier yourself. You reach for it directly in two cases:
- Fronting a backend — an edge proxy or service-mesh sidecar that checks the signature, then forwards to an unaware backend (Appendix E).
- Guarding your own business endpoints — your
/api/*routes, not the AFAuth protocol routes. Useserver.verifyAttestedthere if you also want a liveness gate; use the bareVerifierif you only need the signature.
Verify the signature
Verifier performs §5.5 + §5.6 — signature parsing, key resolution, the Ed25519 check, and the timestamp + nonce checks — with no network I/O, since agent identifiers are did:key and the key decodes straight from the DID:
verify returns the verified identity on success and throws an AFAuthError on any failure — .toResponse() renders the error envelope. The runnable version is examples/recipes/verify.ts.
What a failure means
Every verification failure is a401 with a specific code:
| Code | Cause | Agent’s fix |
|---|---|---|
invalid_signature | Bad signature, key resolution failed, or Content-Digest ≠ body | Re-sign; don’t mutate the body after signing |
expired_signature | now > expires + skew — clock drift or the request sat too long | Sync the clock (NTP); sign and send promptly |
replayed_nonce | This (keyid, nonce) was already seen in the window | Use a fresh random nonce per request (the SDK does) |
revoked_key | The signing DID is on your revocation list | The key was revoked — re-key, don’t retry |
Two things production needs
- Supply a durable revocation list. §8.3 requires one; the
Memory*stores reset on restart. - Hand the verifier the exact bytes you received. The signed
Content-Digestcovers the raw body — don’t let JSON re-serialization in your stack mangle it before verification.
Where to next
Signing requests
What’s in the signature and the seven verification steps.
Keep attested access live
Add a §10.7 liveness gate with
verifyAttested.Error codes
Every code, status, and trigger.
Rate limiting
Cap request volume per agent and per human.