auth-agents 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +137 -0
  2. package/package.json +4 -2
package/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # auth-agents
2
+
3
+ Verify AI agent identities with [Auth-Agents](https://auth-agents.com). DID-based authentication using Ed25519 and Verifiable Credentials.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install auth-agents
9
+ ```
10
+
11
+ ## Quick Start — Verify a Credential
12
+
13
+ ```typescript
14
+ import { AuthAgents } from "auth-agents"
15
+
16
+ const client = new AuthAgents()
17
+
18
+ const result = await client.verify("eyJhbGciOiJFZERTQSJ9...")
19
+
20
+ if (result.valid) {
21
+ console.log(result.did) // "did:key:z6Mk..."
22
+ console.log(result.agent_name) // "Claude"
23
+ console.log(result.agent_model) // "claude-opus-4-6"
24
+ console.log(result.agent_provider) // "Anthropic"
25
+ console.log(result.agent_purpose) // "Research assistant"
26
+ console.log(result.expires_at) // "2026-02-27T01:58:15.000Z"
27
+ }
28
+ ```
29
+
30
+ ## Website Integration (Next.js)
31
+
32
+ ```typescript
33
+ // app/api/auth/agent/route.ts
34
+ import { AuthAgents } from "auth-agents"
35
+
36
+ const authAgents = new AuthAgents()
37
+
38
+ export async function POST(request: Request) {
39
+ const { credential } = await request.json()
40
+
41
+ const result = await authAgents.verify(credential)
42
+
43
+ if (!result.valid) {
44
+ return Response.json({ error: result.message }, { status: 401 })
45
+ }
46
+
47
+ // Create a session with the verified agent identity
48
+ const sessionId = crypto.randomUUID()
49
+ await db.insert("sessions", {
50
+ session_id: sessionId,
51
+ did: result.did,
52
+ agent_name: result.agent_name,
53
+ agent_model: result.agent_model,
54
+ expires_at: result.expires_at,
55
+ })
56
+
57
+ return Response.json({ authenticated: true, session_id: sessionId })
58
+ }
59
+ ```
60
+
61
+ ## Website Integration (Express.js)
62
+
63
+ ```typescript
64
+ import express from "express"
65
+ import { AuthAgents } from "auth-agents"
66
+
67
+ const app = express()
68
+ const authAgents = new AuthAgents()
69
+
70
+ app.post("/auth/agent", express.json(), async (req, res) => {
71
+ const { credential } = req.body
72
+ const result = await authAgents.verify(credential)
73
+
74
+ if (!result.valid) {
75
+ return res.status(401).json({ error: result.message })
76
+ }
77
+
78
+ // Agent verified — create session
79
+ req.session.agent = {
80
+ did: result.did,
81
+ name: result.agent_name,
82
+ model: result.agent_model,
83
+ }
84
+
85
+ res.json({ authenticated: true, agent_name: result.agent_name })
86
+ })
87
+ ```
88
+
89
+ ## Full Agent Auth Flow
90
+
91
+ ```typescript
92
+ import { AuthAgents } from "auth-agents"
93
+
94
+ const client = new AuthAgents()
95
+
96
+ // 1. Register
97
+ const identity = await client.register({
98
+ agent_name: "Claude",
99
+ agent_model: "claude-opus-4-6",
100
+ agent_provider: "Anthropic",
101
+ agent_purpose: "Research assistant",
102
+ })
103
+
104
+ // 2. Request challenge
105
+ const challenge = await client.challenge(identity.did)
106
+
107
+ // 3. Sign nonce and authenticate
108
+ const auth = await client.authenticate({
109
+ challenge_id: challenge.challenge_id,
110
+ did: identity.did,
111
+ signature: signedNonce, // base64url Ed25519 signature of challenge.nonce
112
+ })
113
+ // auth.credential — fresh VC-JWT
114
+ // auth.session_token — session ID
115
+ ```
116
+
117
+ ## API
118
+
119
+ ### `new AuthAgents(config?)`
120
+
121
+ - `config.baseUrl` — API base URL (default: `https://auth.auth-agents.com`)
122
+
123
+ ### `client.verify(credential)` — Verify a VC-JWT credential
124
+
125
+ ### `client.register(input)` — Register a new agent identity
126
+
127
+ ### `client.challenge(did)` — Request an auth challenge
128
+
129
+ ### `client.authenticate(input)` — Submit signed challenge
130
+
131
+ ## Documentation
132
+
133
+ Full API reference at [auth-agents.com/docs](https://auth-agents.com/docs/)
134
+
135
+ ## License
136
+
137
+ MIT - Auth-Agents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth-agents",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Verify AI agent identities with Auth-Agents. DID-based authentication using Ed25519 and Verifiable Credentials.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,9 @@
12
12
  }
13
13
  },
14
14
  "files": [
15
- "dist"
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE"
16
18
  ],
17
19
  "scripts": {
18
20
  "build": "tsup src/index.ts --format cjs,esm --dts --clean",