Path 2: JWS with claims (JavaScript)
ProofPack Path 2 — verifying JWS or JWT with claims in JavaScript
Question: "Is this agent authorized by a human, and does that human meet these criteria (age, nationality, AML)?"
The agent sends a ProofPack proof as JWS or JWT (see Understanding JWT and JWS for the difference) in the standard Authorization: Bearer <token> header. Your service verifies it and reads the revealed claims.
import { AttestedMerkleExchangeReader } from '@zipwire/proofpack';
const reader = new AttestedMerkleExchangeReader();
const result = await reader.readAsync(
jws, // From Authorization: Bearer <JWS>
verificationContext
);
if (result.isValid) {
const claims = result.document.merkleTree.leaves;
// Use verified claims
if (claims.nationality === 'UK' && claims.age >= 18) {
// Process the request
const agent = {
wallet: result.agentWallet,
human: result.humanWallet,
authorizedAt: result.delegationDate,
claims: claims
};
await processRequest(agent);
}
}You must configure verificationContext (trusted roots, schemas). See Quick setup: verification context and ProofPack & Agent Delegation.
Last updated