Poppy.Server.verifier
Verify a Poppy session
Creates a request verifier for Poppy’s delegated Poppy-Session JWT: a Personal Agent’s signed statement of which user it acts for at your Company (the seller).
Usage
import * as from 'mppx/extensions/identity/poppy'
const = ..({
: 'https://api.example.com',
: ['https://agent.example.com/agent.json'],
})
Pass session in a route's identity: [session]. Pair with Poppy.Client.prover. Verify any accompanying access token separately, including that it was issued to the verified Session's clientId. If that verifier uses Authorization, configure server Mppx.create({ requiresAuth: true, ... }).
Return type
Identity.Verifier<Poppy.Session>. A valid value contains clientId: string, sessionId: string, userId: string, and optional agentId: string.
Missing or invalid Sessions produce a verification outcome that the payment handler sends as HTTP 400. The outcome’s reason is a serialized JSON string: { error: 'invalid_session', error_description: string }. Poppy specifies 400 rather than 401 so OAuth clients keep a valid access token instead of treating the Session failure as an expired token. Key-fetch outages return unavailable (503). A Session doesn't grant account access.
Parameters
Configuration type: Poppy.Server.verifier.Config.
audience
- Type:
string
Company identifier matched exactly against aud.
clients
- Type:
readonly string[]
Explicit Personal Agent client metadata URLs to accept. Only these URLs are fetched.
fetch (optional)
- Type:
typeof globalThis.fetch
Defaults to globalThis.fetch. Metadata and JWKS calls use a 5000-millisecond timeout and don’t follow redirects.
maxAge (optional)
- Type:
number
Accepted seconds before or after a Session’s iat; default 60. Must be a positive integer.
Verification behavior
- Fetches each accepted
client_idmetadata document, checks itsclient_id, then fetches its HTTPSjwks_urion the same hostname. - Verifies delegation signatures with ES256 or PS384. A delegation must be live and last no more than
86400seconds. Itscnf.jwkdelegates the ES256 Session key; the Session'skidmust be that key's thumbprint. - Checks Session type, signature, audience, method, URL without query or fragment, timestamp, and access-token hash. Missing or malformed required claims reject.
- Requires
athexactly whenAuthorizationcarries one Bearer or DPoP token. Combined or malformed values reject; Payment Credentials aren't access tokens. This binds a Session to the token, but doesn't verify the token itself. - Caches metadata and keys for
300seconds. Unknown keys can refresh after30seconds; failures cache for30seconds. A failed refresh retains last-good keys for at most3600seconds after loading.
Constants
Poppy.Constants exports:
| Property | Value |
|---|---|
defaultDelegationLifetime | 3600 seconds |
delegationType | poppy-delegation+jwt |
keyCacheTtl | 300 seconds |
keyRetryAfter | 30 seconds |
keyStaleTtl | 3600 seconds |
maxAge | 60 seconds |
maxDelegationLifetime | 86400 seconds |
sessionHeader | Poppy-Session |
sessionType | poppy-session+jwt |
version | 1.0 |
versionHeader | Poppy-Version |
Errors
Malformed clients throws TypeError; invalid maxAge throws RangeError. Protocol refusals are returned as Identity.Verification outcomes, not thrown exceptions.