The verify package
For: a developer of a server that is not the auth app and must know the caller of a request.
What it does: this page lists the options of createVerifier, the six caller kinds, the answers, and every export of the package. The export check holds this page to packages/verify/src/index.ts.
Before you start
Section titled “Before you start”- Read Mint a JWT for your other services for the session JWT that the auth app mints.
Options
Section titled “Options”createVerifier(options) answers a Verifier. The type of the options is VerifierOptions. A wrong option throws at construction.
| Option | Default | What it does |
|---|---|---|
issuer |
required | baseURL plus basePath of the auth app: the iss of its tokens. An http or https URL with no query, fragment, or user info. |
audience |
none | The jwtMint.audience entry or entries of this server, 1 to 10. Required for session-jwt. |
resources |
none | The oauth.resources entries that this server serves. Required for oauth and oauth-client. |
accept |
["session-jwt"] |
The caller kinds to accept, of the type CallerKind. |
checkSessionEnd |
false |
Asks POST /token/live for each session JWT, so a sign-out ends access at once. |
cache |
{ apiTokenSeconds: 0 } |
How long the verifier keeps an API token answer: 0 to API_TOKEN_CACHE_MAX_SECONDS (60) seconds. A token with a window or a quota is never kept. An answer kept before the app adds a window or a quota lives up to apiTokenSeconds, as after a revoke. |
movedPrefixes |
none | The app’s tokens.movedPrefixes, such as laaa_: the prefixes of keys that moved into core’s token tables. A bearer with one goes to the route of movedKind. Each entry follows core’s moved prefix rule, once. |
movedKind |
"api-token" |
The kind of every moved key: "api-token" (GET /tokens/current) or "organization-token" (GET /organizations/tokens/current). It must be in accept while movedPrefixes has an entry. |
timeoutMs |
TIMEOUT_DEFAULT_MS (5000) |
The deadline of each call to the auth app, from TIMEOUT_MIN_MS (100) to TIMEOUT_MAX_MS (30000). |
fetch |
globalThis.fetch |
The fetch of every call to the auth app. Any function of a request and its init that answers a Response. |
clock |
the system clock | Tests inject one. |
dpop |
none | Accept Authorization: DPoP with a proof of RFC 9449. See DPoP. |
introspect |
none | { clientId, clientSecret }: ask POST /oauth/introspect about each access token. See Introspection. |
createVerifier refuses a URL that is both an audience entry and a resources entry: one key signs both kinds of token.
Warning: the verifier accepts an http: issuer on any host. It then reads the key set and sends each bearer over plain HTTP. Use https: outside local development.
The caller kinds
Section titled “The caller kinds”verifier.verifyRequest(request) answers a VerifyResult: { ok: true, value } with a Caller or null, or a failure.
| Kind | The credential | The check | The fields |
|---|---|---|---|
session-jwt |
A session JWT, header typ JWT |
Offline: the signature, iss, sub, sid, aud, and exp |
userId, sessionId, email, emailVerified, name, organizationId, claims, expiresAt |
oauth |
An access token of a person, header typ at+jwt |
Offline: the signature, iss, sub, client_id, scope, jti, and exp. aud must be the resource that the request URL falls under |
userId, clientId, scopes, resource, tokenId, expiresAt, dpopJkt |
oauth-client |
An access token of the client_credentials grant: its sub is its client_id |
The checks of oauth. The client acts for no person |
clientId, scopes, resource, tokenId, expiresAt, dpopJkt |
api-token |
A tk_ bearer token, or a moved key with movedKind "api-token" |
One call to GET /tokens/current |
user, apiToken |
organization-token |
A to_ bearer token, or a moved key with movedKind "organization-token" |
One call to GET /organizations/tokens/current. The answer is never kept. |
organization, apiToken |
session-token |
A ts_ bearer token |
One call to GET /session. Each check can extend the session, as a visit does. |
user, session |
An impersonation session (plan 12f) shows in two callers. A session-jwt caller has claims.act, { sub } with the operator’s user id (RFC 8693 section 4.1). A session-token caller has session.actorId, which is null for every other session.
The userId of an oauth caller is the token’s sub. That is the user id for a public client, and the pairwise subject (ps_…) for a pairwise client. Core’s auth.caller names the same value subject, beside the user.
A kind that accept does not list answers null with no call.
The verifier reads the Authorization header only. It never reads the session cookie, whose default name is __Host-tempo_session. A request with only the cookie answers null with no call.
The answers
Section titled “The answers”- A bad, expired, or foreign credential answers
{ ok: true, value: null }. - A key set or an auth app that does not answer gives a failure with
networkorunexpected, nevernull. Answer 503, not 401. - A 200 answer whose shape is not the shape of core gives
unexpectedwith status 200. - No call follows a redirect. A 3xx answer gives
unexpected. A call with no answer beforetimeoutMsgivesnetwork. - With
checkSessionEnd, the live route counts ontoken-live:session:<sessionId>, 120 per minute (Limits). A full count gives the failurerate_limitedwith status 429. - An offline check of an access token does not see a deleted user.
auth.callerof core does.
With dpop, the verifier reads Authorization: DPoP <token> and the DPoP header. The check runs offline with checkDpopProof of @authtempo/core/credentials.
| Option | Default | What it does |
|---|---|---|
dpop.algs |
all of FOREIGN_ALGS |
The algs of a proof. |
dpop.windowSeconds |
60 | How far the iat of a proof may be from now, 10 to 300. |
dpop.replay |
memoryReplayStore() |
The ReplayStore of the proofs seen: seen(key, ttlSeconds). |
dpop.required |
false |
True: an access token without the DPoP scheme answers null. |
- The token must be bound, and the proof key must have its thumbprint. The proof must hold
ath, the method, and the URL. - A bound token sent as a Bearer answers
null(RFC 9449 section 7.2). - The default store sees a replay only inside one isolate. A deployment with several isolates passes a shared store, or uses
auth.caller, whose store is the database. - A shared store implements
seen(key, ttlSeconds)in one atomic step. It answers true for a key that it holds and whose life has not ended. Else it keeps the key forttlSecondsand answers false. - A store that answers false twice for one key lets a replay through. A read and a later write in two steps does that under load.
memoryReplayStore(max)keeps at mostmaxkeys,REPLAY_STORE_DEFAULT_MAX(10,000) by default, and drops the oldest key above the bound.- A store that throws gives
network, nevernull.
Introspection
Section titled “Introspection”With introspect, each access token that passes the offline check costs one call to POST /oauth/introspect, with client_secret_basic. A bad token costs no call.
active: falseanswersnull.- An auth app with two or more
oauth.resourcesmust name this client inoauth.introspection. Without that entry, core answersactive: false, and the verifier answersnullfor every token. - Core counts each call on
oauth-introspect:ip:<ip>andoauth-introspect:client:<clientId>, 600 per 60 s each (Limits). Each request costs one call. Above about 10 requests per second the verifier gets 429 and answersunexpected, andrequireMcpAuthanswers 503. - A call with no answer gives
network. A status other than 200 givesunexpectedwith that status. A body overINTROSPECT_MAX_BYTESgivesunexpectedwith status 200.
The key set
Section titled “The key set”- The key set lives for the
max-ageof its answer: at leastKEY_SET_MIN_SECONDS(60), at mostKEY_SET_MAX_SECONDS(3600). With nomax-age, it livesKEY_SET_DEFAULT_SECONDS(300). - An unknown
kidreads the key set again at most once perUNKNOWN_KID_EVERY_MS(30 seconds). - After a failed read, the verifier answers the same failure for
FAILED_READ_PAUSE_MS(5 seconds) with no read. - A body over
KEY_SET_MAX_BYTES(64 KiB) givesunexpected. A set of more thanKEY_SET_MAX_KEYSkeys givesunexpectedtoo. KEY_SET_MAX_KEYSisJWKS_RETIRED_MAXplus 1: the signing key and the retired keys that core can list.- Core keeps a retired key in its set for 24 hours. A token of a rotated key verifies until its
exp. - The check runs on Web Crypto with the code of
@authtempo/core/credentials, the same code as core.
The 401 and the 403
Section titled “The 401 and the 403”verifier.unauthorized({ resource, scope })answers 401 withWWW-Authenticate: Bearer resource_metadata="…", scope="…". An MCP client reads the protected-resource document and the scopes to ask for.invalidToken: trueaddserror="invalid_token". Pass it when the request held a token that you refused.verifier.insufficientScope({ resource, scope, description })answers 403 witherror="insufficient_scope". Name every scope of the operation in one challenge. Withdpopand a DPoPrequest, theDPoPchallenge carries the error.- A scope with a quote, or
offline_access, throws:offline_accessis not a resource scope. - A
resourcethat is not a URL throws too. So does adescriptionwith a quote, a backslash, or a control character. - The input of both is a
ChallengeInput.verifier.unauthorizedalso takesrequest(the typeUnauthorizedInput): the error then goes into the challenge of the request’s scheme. - With
dpop, the 401 holds aDPoPchallenge after theBearerone, withalgs,resource_metadata, andscope. A refused proof giveserror="invalid_dpop_proof". - A verifier with no
dpopanswers a DPoP request with the plain challenge and no error code (RFC 6750 section 3.1). - Pass the request that
verifyRequestread, or a clone of it: the verifier finds a refused proof by the request or by its signature.
Exports
Section titled “Exports”| Export | What it is |
|---|---|
createVerifier |
Makes a Verifier. |
VERIFY_CALLS |
The table of the routes that the verifier calls. VerifyOperation is the type of its operation names. |
KEY_SET_DEFAULT_SECONDS, KEY_SET_MIN_SECONDS, KEY_SET_MAX_SECONDS |
The life of the key set. |
UNKNOWN_KID_EVERY_MS, FAILED_READ_PAUSE_MS |
The two waits between reads of the key set. |
KEY_SET_MAX_BYTES, KEY_SET_MAX_KEYS |
The two caps of the key set. |
TIMEOUT_DEFAULT_MS, TIMEOUT_MIN_MS, TIMEOUT_MAX_MS |
The default and the range of timeoutMs. |
API_TOKEN_CACHE_MAX_SECONDS |
The longest API token cache. |
unauthorizedResponse, insufficientScopeResponse, bearerChallenge |
The 401, the 403, and the challenge text, with no verifier. A server that checks the caller with auth.caller uses them. |
dpopChallenge |
The text of a DPoP challenge (RFC 9449 section 7.1). |
memoryReplayStore, REPLAY_STORE_DEFAULT_MAX |
The default replay store of one isolate, and its default bound. |
INTROSPECT_MAX_BYTES |
The longest introspection answer that the verifier reads: 64 KiB. |
| Area | Types |
|---|---|
| The verifier | Verifier, VerifierOptions, DpopOptions, IntrospectOptions, ReplayStore |
| The answers | VerifyResult, Caller, CallerKind |
| The 401 and the 403 | ChallengeInput, UnauthorizedInput |
| The route table | VerifyOperation |