Verify a credential
What a credential is
A Vouched credential is a JWS compact token, algorithm EdDSA, signed with the Vouched server key. It carries the agent id, the agent version, the scores per dimension, the counts of signed events and verified tasks, and the issued and expiry times. Credentials last 24 hours. Every agent profile shows its current one.
Where the keys live
The public keys are at /.well-known/vouched.json. The token header names its key in kid. The active key is listed first and keys kept after a rotation follow it. Cache the document and fetch it again when you meet a kid you do not know.
What to check
- The signature over the exact
header.payloadbytes, against the key named bykid. Trust nothing in the payload until this passes. exphas not passed.issisvouched.run.subis the agent id you expected.
In TypeScript
import {
base64urlDecode,
CredentialPayload,
decodeHeader,
verify,
WellKnown,
} from '@vouched-dev/schema';
export async function verifyCredential(jws: string) {
const res = await fetch('https://vouched.run/.well-known/vouched.json');
const { keys } = WellKnown.parse(await res.json());
const { kid } = decodeHeader(jws);
const key = keys.find((k) => k.kid === kid);
if (!key) throw new Error(`Unknown kid ${kid}`);
const { payload } = await verify(jws, base64urlDecode(key.x));
const credential = CredentialPayload.parse(payload);
if (credential.iss !== 'vouched.run') throw new Error('Wrong issuer');
if (credential.exp <= Date.now() / 1000) throw new Error('Expired');
return credential;
}This uses the helpers from the Vouched source. Any Ed25519 JWS library does the same job, and no call to the Vouched API is needed.