@datacules/agent-identity-fastify
v0.13.0
Published
Fastify plugin for @datacules/agent-identity
Maintainers
Readme
@datacules/agent-identity-fastify
Fastify plugin for the agent-identity framework. Resolves credentials server-side and decorates each request with request.resolvedCredential.
Install
npm install @datacules/agent-identity-fastify @datacules/agent-identityUsage
import Fastify from 'fastify';
import { agentIdentityPlugin } from '@datacules/agent-identity-fastify';
import { credentials, rules, logger } from './config';
const app = Fastify();
await app.register(agentIdentityPlugin, { credentials, rules, logger });
app.post('/ai/complete', async (request, reply) => {
const { ref, resolvedFor, credentialId } = request.resolvedCredential!;
// ref → fetch the raw secret from your vault server-side
return { resolvedFor };
});
await app.listen({ port: 3000 });Plugin options
await app.register(agentIdentityPlugin, {
credentials, // Credential[]
rules, // RoutingRule[]
logger, // AuditLogger (optional)
store, // CredentialStore (alternative to credentials[])
contextKey: 'body.agentContext', // default path in request body
});TypeScript decoration
The plugin augments FastifyRequest with resolvedCredential?: ResolvedCredential via Fastify's decoration system — no manual augmentation needed.
Part of the agent-identity monorepo by Datacules LLC.
