Signed context_token & JWKS Verification
Verify RS256 signed id_token and context_token JWS payloads against /.well-known/jwks.json using standard JOSE libraries for verifiable third-party bundle handoff.
Every token response includes a signed RS256 JWS called context_token—and GET /api/v0/context?format=jwt returns a fresh signed copy on demand—verifiable directly against /.well-known/jwks.json.
A signed context_token embeds { sub, protext: <bundle> } with standard iss, aud, iat, and exp claims (1-hour TTL) signed with RS256 and a stable kid matching the provider's RSA public key at /.well-known/jwks.json.
RS256 JWT / JWS verification parameters in PROTEXT/0.1
| Property | id_token | context_token |
|---|---|---|
| Where returned | POST /oidc/token | POST /oidc/token or GET /api/v0/context?format=jwt (Content-Type: application/jwt) |
| Protected header | { alg: "RS256", kid, typ: "JWT" } | { alg: "RS256", kid, typ: "JWT" } |
| iss (Issuer) | Provider issuer (https://protext.org) | Provider issuer (https://protext.org) |
| aud (Audience) | Relying party client_id | Relying party client_id |
| Payload claims | sub, derived OIDC claims, protext_handle, protext_url, optional nonce | sub, protext (complete ContextBundle with items & personhood) |
| Lifetime (exp - iat) | 3600 seconds (ID_TOKEN_TTL) | 3600 seconds (ACCESS_TTL) |
| Verification key set | GET /.well-known/jwks.json (Cache-Control: public, max-age=600) | GET /.well-known/jwks.json (Cache-Control: public, max-age=600) |
Verifying context_token and fetching a signed live bundle with jose
Uses standard RS256 JWKS verification matching lib/oidc.ts and examples/node-relying-party/server.mjs.
import { createRemoteJWKSet, jwtVerify } from "jose";
const ISSUER = "https://protext.org";
const CLIENT_ID = process.env.PROTEXT_CLIENT_ID;
const jwks = createRemoteJWKSet(new URL(`${ISSUER}/.well-known/jwks.json`));
// Verify context_token returned inline from POST /oidc/token
const { payload } = await jwtVerify(tokenResponse.context_token, jwks, {
issuer: ISSUER,
audience: CLIENT_ID,
algorithms: ["RS256"],
});
const bundle = payload.protext; // { protext: "0.1", sub, handle, issued_at, items, personhood }
// Or request a freshly signed live bundle later using an active access token
const res = await fetch(`${ISSUER}/api/v0/context?format=jwt`, {
headers: { Authorization: `Bearer ${accessToken}` },
});
const freshJwt = await res.text();
const verifiedFresh = await jwtVerify(freshJwt, jwks, {
issuer: ISSUER,
audience: CLIENT_ID,
algorithms: ["RS256"],
});When to use context_token instead of plain JSON context
When your own backend calls POST /oidc/token or GET /api/v0/context directly over TLS, the inline JSON context object is already authenticated by the direct HTTPS response from the provider. However, when a browser client receives a bundle or when your service needs to pass a user's consented context bundle to a downstream microservice or partner, plain JSON cannot prove which provider issued it.
context_token solves this with standard RS256 JWS signatures using the exact same JWKS endpoint (https://protext.org/.well-known/jwks.json) already used for id_token verification. Any verifier with the provider URL and expected client_id audience can confirm authenticity and expiration offline against the cached public key.
Key management and production hygiene
The reference provider loads its persistent private RSA key from the PROTEXT_JWK environment variable (generated with node scripts/keygen.mjs) and publishes only the public parameters (without d, p, q, dp, dq, qi) at /.well-known/jwks.json with use: "sig" and alg: "RS256".
As verified in tests/prod-smoke.mjs, production deployments must always configure PROTEXT_JWK so kid values remain stable across serverless invocations and never start with ephemeral-.
- Always enforce issuer, audience, and algorithms: ["RS256"] when verifying both id_token and context_token.
- Remember that a valid signature on context_token proves the provider issued the bundle at iat—not that external source.url pointers have been independently crawled (§9).
- Planned for PROTEXT/0.2: SD-JWT VC selective disclosure so individual items can be proven to third parties without the provider online (§9).
Verify against the normative specification or register your client.
Frequently asked questions
What signing algorithm does Protext use for id_token and context_token?
PROTEXT/0.1 signs both id_token and context_token with RS256 (RSA 2048-bit keys) and publishes the corresponding public JWK at /.well-known/jwks.json.
What is inside the payload of a Protext context_token?
Per SPEC.md §5 and lib/oidc.ts, the JWT payload contains sub, protext (the full 0.1 ContextBundle object), plus standard JWT claims iss (provider URL), aud (relying party client_id), iat, and exp.
How do I fetch a fresh signed bundle after initial login?
Send GET https://protext.org/api/v0/context?format=jwt with Authorization: Bearer <access_token>. The endpoint returns the freshly assembled RS256 JWS with Content-Type: application/jwt and Cache-Control: no-store.
Does a signed context_token verify the external source.url of an item?
No. SPEC.md §9 explicitly notes that source.url is a pointer, not a proof. The RS256 signature proves the Protext provider issued the bundle; a verifier who needs external proof must inspect source.url itself.
Why does /.well-known/jwks.json strip private key fields?
lib/oidc.ts removes private RSA components (d, p, q, dp, dq, qi) before exposing the JWK at /.well-known/jwks.json, publishing only the public verification key with use: sig and alg: RS256.
What is planned for verifiable presentations in PROTEXT/0.2?
SPEC.md §9 lists SD-JWT VC selective-disclosure presentation of context bundles and W3C Digital Credentials API presentation from the provider page on the 0.2 roadmap.
Continue exploring PROTEXT/0.1
OpenID Connect & OAuth 2.1 PKCE Integration
Integrate Sign in with Protext using OpenID Connect Core discovery, OAuth 2.1 authorization code flow with S256 PKCE, RFC 9207 iss checks, and RS256 ID tokens.
Read guide →Live Grants, Refresh Rotation, Revocation & Vault Export
Read live context updates via GET /api/v0/context and /oidc/userinfo, rotate offline_access refresh tokens, revoke tokens with RFC 7009, and export full vaults via /api/v0/export.
Read guide →Self-Hosting a Protext Provider & Multi-Provider Discovery
Deploy your own MIT-licensed PROTEXT/0.1 provider with Next.js 15, Postgres, Drizzle, and PROTEXT_JWK, and implement /.well-known/protext.json multi-provider discovery.
Read guide →