xat-agent
v1.0.0
Published
XAT -- Agent infrastructure for AI. Identity, trust, signing, audit. Zero dependencies.
Downloads
265
Maintainers
Readme
XAT
Agent infrastructure for AI. Identity, trust, signing, audit. Zero dependencies.
Based on the x-agent-trust extension registered in the OpenAPI Extensions Registry.
Install
npm install xat-agentAgent side (sign outbound requests)
const xat = require('xat-agent');
const agent = xat.createAgent({
provider: xat.providers.file('./agent.key'), // dev only
keyid: 'my-agent'
});
// fetch wrapper -- Agent-Signature header added automatically
const res = await agent.fetch('https://api.example.com/v1/pay', {
method: 'POST',
body: JSON.stringify({ amount: 500, currency: 'usd' })
});API side (verify inbound requests)
const xat = require('xat-agent');
app.use('/api', xat.verify({
resolveKey: async (keyid) => {
// look up the agent's public key by keyid
return agents[keyid].publicKeyPem;
}
}));
app.post('/api/pay', (req, res) => {
console.log('Verified agent:', req.agent.keyid);
res.json({ ok: true });
});JWKS endpoint
app.use(xat.jwks(() => [agentPublicKeyPem]));
// serves /.well-known/agent-trust-keys automaticallyKey providers
Private keys never enter XAT memory in production. The signing operation happens inside the provider boundary.
// Dev only -- file on disk
xat.providers.file('./key.pem')
// Dev only -- environment variable
xat.providers.env('XAT_PRIVATE_KEY')
// Production -- AWS KMS (key never leaves HSM)
xat.providers.awsKms({ keyId: 'arn:aws:kms:...' })
// Production -- Google Cloud KMS
xat.providers.gcpKms({ keyName: 'projects/.../cryptoKeyVersions/1' })
// Production -- HashiCorp Vault Transit
xat.providers.vault({ addr: 'https://vault:8200', keyName: 'agent-key' })
// Bring your own
xat.providers.custom({
sign: async (data) => { /* return base64 signature */ },
getPublicKey: async () => { /* return PEM */ }
})Generate keys
const { publicKey, privateKey } = xat.generateKeyPair();Lint your OpenAPI spec
npm install spectral-x-agent-trust
npx @stoplight/spectral-cli lint openapi.yaml --ruleset node_modules/spectral-x-agent-trust/ruleset.jsLinks
Author
Raza Sharif, CyberSecAI Ltd
License
Apache-2.0
