@dupecom/botcha 0.10.0 → 0.13.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 +153 -5
- package/dist/lib/client/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,8 @@ Use cases:
|
|
|
35
35
|
- 📊 Per-app metrics dashboard at [botcha.ai/dashboard](https://botcha.ai/dashboard)
|
|
36
36
|
- 📧 Email verification, account recovery, and secret rotation
|
|
37
37
|
- 🤖 Agent-first dashboard auth (challenge-based login + device code handoff)
|
|
38
|
+
- 🆔 Persistent agent identities with registry
|
|
39
|
+
- 🔏 Trusted Agent Protocol (TAP) — cryptographic agent auth with HTTP Message Signatures
|
|
38
40
|
|
|
39
41
|
## Install
|
|
40
42
|
|
|
@@ -121,10 +123,11 @@ BOTCHA uses **OAuth2-style token rotation** with short-lived access tokens and l
|
|
|
121
123
|
### Token Flow
|
|
122
124
|
|
|
123
125
|
```
|
|
124
|
-
1. Solve challenge → receive access_token (5min) + refresh_token (1hr)
|
|
126
|
+
1. Solve challenge → receive access_token (5min) + refresh_token (1hr) + human_link
|
|
125
127
|
2. Use access_token for API calls
|
|
126
|
-
3.
|
|
127
|
-
4. When
|
|
128
|
+
3. Give human_link to your human → they click it → instant browser access via /go/:code
|
|
129
|
+
4. When access_token expires → POST /v1/token/refresh with refresh_token
|
|
130
|
+
5. When compromised → POST /v1/token/revoke to invalidate immediately
|
|
128
131
|
```
|
|
129
132
|
|
|
130
133
|
### Security Features
|
|
@@ -159,7 +162,7 @@ async with BotchaClient(audience="https://api.example.com") as client:
|
|
|
159
162
|
| Endpoint | Description |
|
|
160
163
|
|----------|-------------|
|
|
161
164
|
| `GET /v1/token` | Get challenge for token flow |
|
|
162
|
-
| `POST /v1/token/verify` | Submit solution → receive `access_token` + `refresh_token` |
|
|
165
|
+
| `POST /v1/token/verify` | Submit solution → receive `access_token` + `refresh_token` + `human_link` |
|
|
163
166
|
| `POST /v1/token/refresh` | Exchange `refresh_token` for new `access_token` |
|
|
164
167
|
| `POST /v1/token/revoke` | Invalidate any token immediately |
|
|
165
168
|
|
|
@@ -237,6 +240,32 @@ async with BotchaClient(app_id="app_abc123") as client:
|
|
|
237
240
|
response = await client.fetch("https://api.example.com/agent-only")
|
|
238
241
|
```
|
|
239
242
|
|
|
243
|
+
### SDK App Lifecycle (v0.10.0+)
|
|
244
|
+
|
|
245
|
+
Both SDKs now include methods for the full app lifecycle:
|
|
246
|
+
|
|
247
|
+
**TypeScript:**
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
const client = new BotchaClient();
|
|
251
|
+
const app = await client.createApp('agent@example.com'); // auto-sets appId
|
|
252
|
+
await client.verifyEmail('123456'); // verify with email code
|
|
253
|
+
await client.resendVerification(); // resend code
|
|
254
|
+
await client.recoverAccount('agent@example.com'); // recovery device code via email
|
|
255
|
+
const rotated = await client.rotateSecret(); // rotate secret (auth required)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Python:**
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
async with BotchaClient() as client:
|
|
262
|
+
app = await client.create_app("agent@example.com") # auto-sets app_id
|
|
263
|
+
await client.verify_email("123456") # verify with email code
|
|
264
|
+
await client.resend_verification() # resend code
|
|
265
|
+
await client.recover_account("agent@example.com") # recovery device code via email
|
|
266
|
+
rotated = await client.rotate_secret() # rotate secret (auth required)
|
|
267
|
+
```
|
|
268
|
+
|
|
240
269
|
### Rate Limiting
|
|
241
270
|
|
|
242
271
|
Each app gets its own rate limit bucket:
|
|
@@ -285,6 +314,125 @@ Session uses cookie-based auth (HttpOnly, Secure, SameSite=Lax, 1hr expiry).
|
|
|
285
314
|
|
|
286
315
|
All metrics support `1h`, `24h`, `7d`, and `30d` time windows via htmx-powered buttons — no page reload required.
|
|
287
316
|
|
|
317
|
+
## 🤖 Agent Registry
|
|
318
|
+
|
|
319
|
+
BOTCHA now supports **persistent agent identities** — register your agent with a name, operator, and version to build a verifiable identity over time.
|
|
320
|
+
|
|
321
|
+
### Why Register an Agent?
|
|
322
|
+
|
|
323
|
+
- **Identity**: Get a persistent `agent_id` that survives across sessions
|
|
324
|
+
- **Attribution**: Track which agent made which API calls
|
|
325
|
+
- **Reputation**: Build trust over time (foundation for future reputation scoring)
|
|
326
|
+
- **Accountability**: Know who's operating each agent
|
|
327
|
+
|
|
328
|
+
### Registering an Agent
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
# Register a new agent (requires app_id)
|
|
332
|
+
curl -X POST "https://botcha.ai/v1/agents/register?app_id=app_abc123" \
|
|
333
|
+
-H "Content-Type: application/json" \
|
|
334
|
+
-d '{
|
|
335
|
+
"name": "my-assistant",
|
|
336
|
+
"operator": "Acme Corp",
|
|
337
|
+
"version": "1.0.0"
|
|
338
|
+
}'
|
|
339
|
+
|
|
340
|
+
# Returns:
|
|
341
|
+
{
|
|
342
|
+
"agent_id": "agent_xyz789",
|
|
343
|
+
"app_id": "app_abc123",
|
|
344
|
+
"name": "my-assistant",
|
|
345
|
+
"operator": "Acme Corp",
|
|
346
|
+
"version": "1.0.0",
|
|
347
|
+
"created_at": 1770936000000
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### Agent Endpoints
|
|
352
|
+
|
|
353
|
+
| Endpoint | Description |
|
|
354
|
+
|----------|-------------|
|
|
355
|
+
| `POST /v1/agents/register` | Create a new agent identity (requires `app_id`) |
|
|
356
|
+
| `GET /v1/agents/:id` | Get agent info by ID (public, no auth) |
|
|
357
|
+
| `GET /v1/agents` | List all agents for authenticated app |
|
|
358
|
+
|
|
359
|
+
> **Note:** Agent Registry is the foundation for future features like delegation chains, capability attestation, and reputation scoring. See [ROADMAP.md](./ROADMAP.md) for details.
|
|
360
|
+
|
|
361
|
+
## 🔏 Trusted Agent Protocol (TAP)
|
|
362
|
+
|
|
363
|
+
BOTCHA v0.12.0 introduces the **Trusted Agent Protocol** — enterprise-grade cryptographic agent authentication using HTTP Message Signatures (RFC 9421).
|
|
364
|
+
|
|
365
|
+
### Why TAP?
|
|
366
|
+
|
|
367
|
+
- **Cryptographic Identity**: Agents register public keys and sign requests — no more shared secrets
|
|
368
|
+
- **Capability Scoping**: Define exactly what an agent can do (`read:invoices`, `write:transfers`)
|
|
369
|
+
- **Intent Verification**: Every session requires a declared intent that's validated against capabilities
|
|
370
|
+
- **Trust Levels**: `basic`, `verified`, `enterprise` — different access tiers for different agents
|
|
371
|
+
|
|
372
|
+
### Registering a TAP Agent
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
# Register with public key and capabilities
|
|
376
|
+
curl -X POST "https://botcha.ai/v1/agents/register/tap?app_id=app_abc123" \
|
|
377
|
+
-H "Content-Type: application/json" \
|
|
378
|
+
-d '{
|
|
379
|
+
"name": "enterprise-agent",
|
|
380
|
+
"operator": "Acme Corp",
|
|
381
|
+
"version": "2.0.0",
|
|
382
|
+
"public_key": "-----BEGIN PUBLIC KEY-----\nMFkw...\n-----END PUBLIC KEY-----",
|
|
383
|
+
"signature_algorithm": "ecdsa-p256-sha256",
|
|
384
|
+
"trust_level": "enterprise",
|
|
385
|
+
"capabilities": [
|
|
386
|
+
{"action": "read", "resource": "/api/invoices"},
|
|
387
|
+
{"action": "write", "resource": "/api/orders", "constraints": {"max_amount": 10000}}
|
|
388
|
+
]
|
|
389
|
+
}'
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Creating a TAP Session
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
# Create session with intent declaration
|
|
396
|
+
curl -X POST https://botcha.ai/v1/sessions/tap \
|
|
397
|
+
-H "Content-Type: application/json" \
|
|
398
|
+
-d '{
|
|
399
|
+
"agent_id": "agent_xyz789",
|
|
400
|
+
"user_context": "user_123",
|
|
401
|
+
"intent": {
|
|
402
|
+
"action": "read",
|
|
403
|
+
"resource": "/api/invoices",
|
|
404
|
+
"purpose": "Monthly billing report"
|
|
405
|
+
}
|
|
406
|
+
}'
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### TAP Endpoints
|
|
410
|
+
|
|
411
|
+
| Endpoint | Description |
|
|
412
|
+
|----------|-------------|
|
|
413
|
+
| `POST /v1/agents/register/tap` | Register TAP agent with public key + capabilities |
|
|
414
|
+
| `GET /v1/agents/:id/tap` | Get TAP agent details (includes public key) |
|
|
415
|
+
| `GET /v1/agents/tap` | List TAP-enabled agents for app |
|
|
416
|
+
| `POST /v1/sessions/tap` | Create TAP session with intent validation |
|
|
417
|
+
| `GET /v1/sessions/:id/tap` | Get TAP session info |
|
|
418
|
+
|
|
419
|
+
### Express Middleware (Verification Modes)
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
import { createTAPVerifyMiddleware } from '@dupecom/botcha/middleware';
|
|
423
|
+
|
|
424
|
+
// Mode: 'tap' — require TAP signature
|
|
425
|
+
app.use('/api', createTAPVerifyMiddleware({ mode: 'tap', secret: process.env.BOTCHA_SECRET }));
|
|
426
|
+
|
|
427
|
+
// Mode: 'flexible' — accept TAP signature OR challenge token
|
|
428
|
+
app.use('/api', createTAPVerifyMiddleware({ mode: 'flexible', secret: process.env.BOTCHA_SECRET }));
|
|
429
|
+
|
|
430
|
+
// Mode: 'challenge-only' — traditional BOTCHA challenge (backward compatible)
|
|
431
|
+
app.use('/api', createTAPVerifyMiddleware({ mode: 'challenge-only', secret: process.env.BOTCHA_SECRET }));
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
> **Supported algorithms:** `ecdsa-p256-sha256`, `rsa-pss-sha256`. See [ROADMAP.md](./ROADMAP.md) for details.
|
|
435
|
+
|
|
288
436
|
## 🔄 SSE Streaming Flow (AI-Native)
|
|
289
437
|
|
|
290
438
|
For AI agents that prefer a **conversational handshake**, BOTCHA offers **Server-Sent Events (SSE)** streaming:
|
|
@@ -362,7 +510,7 @@ BOTCHA is designed to be auto-discoverable by AI agents through multiple standar
|
|
|
362
510
|
All responses include these headers for agent discovery:
|
|
363
511
|
|
|
364
512
|
```http
|
|
365
|
-
X-Botcha-Version: 0.
|
|
513
|
+
X-Botcha-Version: 0.12.0
|
|
366
514
|
X-Botcha-Enabled: true
|
|
367
515
|
X-Botcha-Methods: hybrid-challenge,speed-challenge,reasoning-challenge,standard-challenge
|
|
368
516
|
X-Botcha-Docs: https://botcha.ai/openapi.json
|
package/dist/lib/client/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import crypto from 'crypto';
|
|
2
2
|
// SDK version - hardcoded since npm_package_version is unreliable when used as a library
|
|
3
|
-
const SDK_VERSION = '0.
|
|
3
|
+
const SDK_VERSION = '0.11.0';
|
|
4
4
|
// Export stream client
|
|
5
5
|
export { BotchaStreamClient } from './stream.js';
|
|
6
6
|
/**
|