@datacules/agent-identity-fastify 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="../../../assets/logo.svg" alt="Agent Identity — by Datacules LLC" width="360"/>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# `@datacules/agent-identity-fastify`
|
|
6
|
+
|
|
7
|
+
Fastify plugin for the agent-identity framework. Resolves credentials server-side and decorates each request with `request.resolvedCredential`.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @datacules/agent-identity-fastify @datacules/agent-identity
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import Fastify from 'fastify';
|
|
19
|
+
import { agentIdentityPlugin } from '@datacules/agent-identity-fastify';
|
|
20
|
+
import { credentials, rules, logger } from './config';
|
|
21
|
+
|
|
22
|
+
const app = Fastify();
|
|
23
|
+
|
|
24
|
+
await app.register(agentIdentityPlugin, { credentials, rules, logger });
|
|
25
|
+
|
|
26
|
+
app.post('/ai/complete', async (request, reply) => {
|
|
27
|
+
const { ref, resolvedFor, credentialId } = request.resolvedCredential!;
|
|
28
|
+
// ref → fetch the raw secret from your vault server-side
|
|
29
|
+
return { resolvedFor };
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
await app.listen({ port: 3000 });
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Plugin options
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
await app.register(agentIdentityPlugin, {
|
|
39
|
+
credentials, // Credential[]
|
|
40
|
+
rules, // RoutingRule[]
|
|
41
|
+
logger, // AuditLogger (optional)
|
|
42
|
+
store, // CredentialStore (alternative to credentials[])
|
|
43
|
+
contextKey: 'body.agentContext', // default path in request body
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## TypeScript decoration
|
|
48
|
+
|
|
49
|
+
The plugin augments `FastifyRequest` with `resolvedCredential?: ResolvedCredential` via Fastify's decoration system — no manual augmentation needed.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
Part of the [agent-identity monorepo](https://github.com/hvrcharon1/agent-identity) by [Datacules LLC](https://datacules.com).
|