Getting started¶
Requirements¶
- Node.js 20 or newer
Install¶
The three primitives¶
- Identity — every agent and operator has a
did:key. - Passport — the operator issues a scoped credential to the agent.
- Action — the agent signs each action; verifiers check who did it.
import {
createIdentity, issuePassport, verifyPassport, assertScope,
signAction, verifyAction,
} from 'agent-passport';
const operator = createIdentity();
const agent = createIdentity();
const passportJwt = await issuePassport({
operator, agentDid: agent.did, name: 'support-bot',
scopes: ['email:send'], expiresIn: 86400,
});
const passport = await verifyPassport(passportJwt);
assertScope(passport, 'email:send');
const actionJwt = await signAction(agent, { type: 'email:send', target: 'a@b.com' });
const done = await verifyAction(actionJwt);
Persisting an identity¶
createIdentity() returns a 32-byte privateKey. Store it securely (KMS, encrypted
secret) and rehydrate the same DID later: