@dupecom/botcha 0.16.0 โ 0.19.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 +173 -17
- package/dist/lib/client/index.d.ts +131 -2
- package/dist/lib/client/index.d.ts.map +1 -1
- package/dist/lib/client/index.js +174 -1
- package/dist/lib/client/types.d.ts +220 -0
- package/dist/lib/client/types.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +408 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
[](https://www.npmjs.com/package/@dupecom/botcha)
|
|
15
15
|
[](https://pypi.org/project/botcha/)
|
|
16
|
-
<!-- test-count -->[](./tests/)<!-- /test-count -->
|
|
17
17
|
[](https://opensource.org/licenses/MIT)
|
|
18
18
|
[](./.github/CONTRIBUTING.md)
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
๐ **Whitepaper:** [botcha.ai/whitepaper](https://botcha.ai/whitepaper)
|
|
22
22
|
๐ฆ **npm:** [@dupecom/botcha](https://www.npmjs.com/package/@dupecom/botcha)
|
|
23
23
|
๐ **PyPI:** [botcha](https://pypi.org/project/botcha/)
|
|
24
|
-
๐ **Verify:** [@botcha
|
|
24
|
+
๐ **Verify:** [@dupecom/botcha-verify](./packages/verify/) (TS) ยท [botcha-verify](./packages/python-verify/) (Python)
|
|
25
25
|
๐ **OpenAPI:** [botcha.ai/openapi.json](https://botcha.ai/openapi.json)
|
|
26
26
|
|
|
27
27
|
## Why?
|
|
@@ -40,6 +40,7 @@ Use cases:
|
|
|
40
40
|
- ๐ Persistent agent identities with registry
|
|
41
41
|
- ๐ Trusted Agent Protocol (TAP) โ cryptographic agent auth with HTTP Message Signatures (SDK: `registerTAPAgent`, `createTAPSession`)
|
|
42
42
|
- ๐ TAP showcase homepage at [botcha.ai](https://botcha.ai) โ one of the first services to implement [Visa's Trusted Agent Protocol](https://github.com/visa/trusted-agent-protocol)
|
|
43
|
+
- ๐ Agent reputation scoring โ trust scores that unlock higher rate limits and access (SDK: `getReputation`, `recordReputationEvent`)
|
|
43
44
|
|
|
44
45
|
## Install
|
|
45
46
|
|
|
@@ -359,7 +360,7 @@ curl -X POST "https://botcha.ai/v1/agents/register?app_id=app_abc123" \
|
|
|
359
360
|
| `GET /v1/agents/:id` | Get agent info by ID (public, no auth) |
|
|
360
361
|
| `GET /v1/agents` | List all agents for authenticated app |
|
|
361
362
|
|
|
362
|
-
> **Note:** Agent Registry is the foundation for
|
|
363
|
+
> **Note:** Agent Registry is the foundation for delegation chains (v0.17.0), capability attestation (v0.17.0), and reputation scoring (v0.18.0). See [ROADMAP.md](./ROADMAP.md) for details.
|
|
363
364
|
|
|
364
365
|
## ๐ Trusted Agent Protocol (TAP)
|
|
365
366
|
|
|
@@ -516,7 +517,141 @@ app.use('/api', createTAPVerifyMiddleware({ mode: 'challenge-only', secret: proc
|
|
|
516
517
|
|
|
517
518
|
> **Supported algorithms:** `ed25519` (Visa recommended), `ecdsa-p256-sha256`, `rsa-pss-sha256`. See [ROADMAP.md](./ROADMAP.md) for details.
|
|
518
519
|
|
|
519
|
-
##
|
|
520
|
+
## Delegation Chains (v0.17.0)
|
|
521
|
+
|
|
522
|
+
"User X authorized Agent Y to do Z until time T." Signed, auditable chains of trust between TAP agents.
|
|
523
|
+
|
|
524
|
+
```typescript
|
|
525
|
+
// Agent A delegates "browse products" to Agent B
|
|
526
|
+
const delegation = await client.createDelegation({
|
|
527
|
+
grantor_id: agentA.agent_id,
|
|
528
|
+
grantee_id: agentB.agent_id,
|
|
529
|
+
capabilities: [{ action: 'browse', scope: ['products'] }],
|
|
530
|
+
duration_seconds: 3600,
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
// Agent B sub-delegates to Agent C (only narrower capabilities)
|
|
534
|
+
const subDelegation = await client.createDelegation({
|
|
535
|
+
grantor_id: agentB.agent_id,
|
|
536
|
+
grantee_id: agentC.agent_id,
|
|
537
|
+
capabilities: [{ action: 'browse', scope: ['products'] }],
|
|
538
|
+
parent_delegation_id: delegation.delegation_id,
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
// Verify the full chain is valid
|
|
542
|
+
const chain = await client.verifyDelegationChain(subDelegation.delegation_id);
|
|
543
|
+
// chain.effective_capabilities = [{ action: 'browse', scope: ['products'] }]
|
|
544
|
+
|
|
545
|
+
// Revoke โ cascades to all sub-delegations
|
|
546
|
+
await client.revokeDelegation(delegation.delegation_id, 'Access no longer needed');
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
**Key properties:**
|
|
550
|
+
- Capabilities can only be **narrowed**, never expanded
|
|
551
|
+
- Chain depth is capped (default: 3, max: 10)
|
|
552
|
+
- Revoking a delegation **cascades** to all sub-delegations
|
|
553
|
+
- Sub-delegations cannot outlive their parent
|
|
554
|
+
- Cycle detection prevents circular chains
|
|
555
|
+
|
|
556
|
+
| Method | Path | Description |
|
|
557
|
+
|--------|------|-------------|
|
|
558
|
+
| `POST /v1/delegations` | Create delegation (grantor to grantee) |
|
|
559
|
+
| `GET /v1/delegations/:id` | Get delegation details |
|
|
560
|
+
| `GET /v1/delegations` | List delegations for agent |
|
|
561
|
+
| `POST /v1/delegations/:id/revoke` | Revoke (cascades to sub-delegations) |
|
|
562
|
+
| `POST /v1/verify/delegation` | Verify entire delegation chain |
|
|
563
|
+
|
|
564
|
+
## Capability Attestation (v0.17.0)
|
|
565
|
+
|
|
566
|
+
Fine-grained `action:resource` permission tokens with explicit deny rules:
|
|
567
|
+
|
|
568
|
+
```typescript
|
|
569
|
+
// Issue attestation with specific permissions
|
|
570
|
+
const att = await client.issueAttestation({
|
|
571
|
+
agent_id: 'agent_abc123',
|
|
572
|
+
can: ['read:invoices', 'browse:*'],
|
|
573
|
+
cannot: ['write:transfers'],
|
|
574
|
+
duration_seconds: 3600,
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
// Use the token in requests
|
|
578
|
+
// Header: X-Botcha-Attestation: <att.token>
|
|
579
|
+
|
|
580
|
+
// Verify token and check specific capability
|
|
581
|
+
const check = await client.verifyAttestation(att.token, 'read', 'invoices');
|
|
582
|
+
// check.allowed === true
|
|
583
|
+
|
|
584
|
+
// Revoke when no longer needed
|
|
585
|
+
await client.revokeAttestation(att.attestation_id, 'Session ended');
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
**Key properties:**
|
|
589
|
+
- Permission model: `action:resource` patterns with wildcards (`*:*`, `read:*`, `*:invoices`)
|
|
590
|
+
- **Deny takes precedence** over allow โ `cannot` rules always win
|
|
591
|
+
- Backward compatible: bare actions like `"browse"` expand to `"browse:*"`
|
|
592
|
+
- Signed JWT tokens with online revocation checking
|
|
593
|
+
- Enforcement middleware: `requireCapability('read:invoices')` for Hono routes
|
|
594
|
+
- Optional link to delegation chains via `delegation_id`
|
|
595
|
+
|
|
596
|
+
| Method | Path | Description |
|
|
597
|
+
|--------|------|-------------|
|
|
598
|
+
| `POST /v1/attestations` | Issue attestation token |
|
|
599
|
+
| `GET /v1/attestations/:id` | Get attestation details |
|
|
600
|
+
| `GET /v1/attestations` | List attestations for agent |
|
|
601
|
+
| `POST /v1/attestations/:id/revoke` | Revoke attestation |
|
|
602
|
+
| `POST /v1/verify/attestation` | Verify token + check capability |
|
|
603
|
+
|
|
604
|
+
## Agent Reputation Scoring (v0.18.0)
|
|
605
|
+
|
|
606
|
+
The "credit score" for AI agents. Persistent identity enables behavioral tracking over time, producing trust scores that unlock higher rate limits, faster verification, and access to sensitive APIs.
|
|
607
|
+
|
|
608
|
+
```typescript
|
|
609
|
+
// Get agent reputation
|
|
610
|
+
const rep = await client.getReputation('agent_abc123');
|
|
611
|
+
console.log(`Score: ${rep.score}, Tier: ${rep.tier}`);
|
|
612
|
+
// Score: 750, Tier: good
|
|
613
|
+
|
|
614
|
+
// Record events that affect score
|
|
615
|
+
await client.recordReputationEvent({
|
|
616
|
+
agent_id: 'agent_abc123',
|
|
617
|
+
category: 'verification',
|
|
618
|
+
action: 'challenge_solved', // +5 points
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
// Endorsement from another agent
|
|
622
|
+
await client.recordReputationEvent({
|
|
623
|
+
agent_id: 'agent_abc123',
|
|
624
|
+
category: 'endorsement',
|
|
625
|
+
action: 'endorsement_received', // +20 points
|
|
626
|
+
source_agent_id: 'agent_def456',
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
// View event history
|
|
630
|
+
const events = await client.listReputationEvents('agent_abc123', {
|
|
631
|
+
category: 'verification',
|
|
632
|
+
limit: 10,
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
// Admin: reset reputation
|
|
636
|
+
await client.resetReputation('agent_abc123');
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
**Scoring model:**
|
|
640
|
+
- Base score: **500** (neutral, no history)
|
|
641
|
+
- Range: **0 - 1000**
|
|
642
|
+
- Tiers: untrusted (0-199), low (200-399), neutral (400-599), good (600-799), excellent (800-1000)
|
|
643
|
+
- **Decay**: scores trend toward 500 over time without activity (mean reversion)
|
|
644
|
+
- **Deny always wins**: abuse events (-50) are heavily weighted
|
|
645
|
+
- **Endorsements**: explicit trust signals from other agents (+20)
|
|
646
|
+
|
|
647
|
+
| Method | Path | Description |
|
|
648
|
+
|--------|------|-------------|
|
|
649
|
+
| `GET /v1/reputation/:agent_id` | Get agent reputation score |
|
|
650
|
+
| `POST /v1/reputation/events` | Record a reputation event |
|
|
651
|
+
| `GET /v1/reputation/:agent_id/events` | List reputation events |
|
|
652
|
+
| `POST /v1/reputation/:agent_id/reset` | Reset reputation (admin) |
|
|
653
|
+
|
|
654
|
+
## SSE Streaming Flow (AI-Native)
|
|
520
655
|
|
|
521
656
|
For AI agents that prefer a **conversational handshake**, BOTCHA offers **Server-Sent Events (SSE)** streaming:
|
|
522
657
|
|
|
@@ -790,19 +925,20 @@ You can use the library freely, report issues, and discuss features. To contribu
|
|
|
790
925
|
|
|
791
926
|
## Server-Side Verification (for API Providers)
|
|
792
927
|
|
|
793
|
-
If you're building an API that accepts BOTCHA tokens from agents, use the verification SDKs
|
|
928
|
+
If you're building an API that accepts BOTCHA tokens from agents, use the verification SDKs. **BOTCHA v0.19.0+ signs tokens with ES256 (asymmetric)** โ no shared secret needed.
|
|
794
929
|
|
|
795
|
-
###
|
|
930
|
+
### JWKS Verification (Recommended)
|
|
796
931
|
|
|
797
932
|
```bash
|
|
798
|
-
npm install @botcha
|
|
933
|
+
npm install @dupecom/botcha-verify
|
|
799
934
|
```
|
|
800
935
|
|
|
801
936
|
```typescript
|
|
802
|
-
import { botchaVerify } from '@botcha
|
|
937
|
+
import { botchaVerify } from '@dupecom/botcha-verify/express';
|
|
803
938
|
|
|
939
|
+
// ES256 verification via JWKS โ no shared secret needed!
|
|
804
940
|
app.use('/api', botchaVerify({
|
|
805
|
-
|
|
941
|
+
jwksUrl: 'https://botcha.ai/.well-known/jwks',
|
|
806
942
|
audience: 'https://api.example.com',
|
|
807
943
|
}));
|
|
808
944
|
|
|
@@ -812,25 +948,45 @@ app.get('/api/protected', (req, res) => {
|
|
|
812
948
|
});
|
|
813
949
|
```
|
|
814
950
|
|
|
815
|
-
### Python (FastAPI / Django)
|
|
816
|
-
|
|
817
|
-
```bash
|
|
818
|
-
pip install botcha-verify
|
|
819
|
-
```
|
|
820
|
-
|
|
821
951
|
```python
|
|
822
952
|
from fastapi import FastAPI, Depends
|
|
823
953
|
from botcha_verify.fastapi import BotchaVerify
|
|
824
954
|
|
|
825
955
|
app = FastAPI()
|
|
826
|
-
botcha = BotchaVerify(
|
|
956
|
+
botcha = BotchaVerify(
|
|
957
|
+
jwks_url='https://botcha.ai/.well-known/jwks',
|
|
958
|
+
audience='https://api.example.com',
|
|
959
|
+
)
|
|
827
960
|
|
|
828
961
|
@app.get('/api/data')
|
|
829
962
|
async def get_data(token = Depends(botcha)):
|
|
830
963
|
return {"solve_time": token.solve_time}
|
|
831
964
|
```
|
|
832
965
|
|
|
833
|
-
|
|
966
|
+
### Remote Validation (No SDK Needed)
|
|
967
|
+
|
|
968
|
+
For simple integrations, validate tokens with a single HTTP call:
|
|
969
|
+
|
|
970
|
+
```bash
|
|
971
|
+
curl -X POST https://botcha.ai/v1/token/validate \
|
|
972
|
+
-H "Content-Type: application/json" \
|
|
973
|
+
-d '{"token": "eyJ..."}'
|
|
974
|
+
|
|
975
|
+
# {"valid": true, "payload": {"sub": "...", "type": "botcha-verified", ...}}
|
|
976
|
+
```
|
|
977
|
+
|
|
978
|
+
### Shared Secret (Legacy HS256)
|
|
979
|
+
|
|
980
|
+
HS256 is still supported for backward compatibility:
|
|
981
|
+
|
|
982
|
+
```typescript
|
|
983
|
+
app.use('/api', botchaVerify({
|
|
984
|
+
secret: process.env.BOTCHA_SECRET!,
|
|
985
|
+
audience: 'https://api.example.com',
|
|
986
|
+
}));
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
> **Docs:** See [`@dupecom/botcha-verify` README](./packages/verify/README.md) and [`botcha-verify` README](./packages/python-verify/README.md) for full API reference, Hono middleware, Django middleware, revocation checking, and custom error handlers.
|
|
834
990
|
|
|
835
991
|
## Client SDK (for AI Agents)
|
|
836
992
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type { SpeedProblem, BotchaClientOptions, ChallengeResponse, StandardChallengeResponse, VerifyResponse, TokenResponse, StreamSession, StreamEvent, Problem, VerifyResult, StreamChallengeOptions, CreateAppResponse, VerifyEmailResponse, ResendVerificationResponse, RecoverAccountResponse, RotateSecretResponse, TAPAction, TAPTrustLevel, TAPSignatureAlgorithm, TAPCapability, TAPIntent, RegisterTAPAgentOptions, TAPAgentResponse, TAPAgentListResponse, CreateTAPSessionOptions, TAPSessionResponse, JWK, JWKSet, CreateInvoiceOptions, InvoiceResponse, BrowsingIOU, VerifyIOUResponse, } from './types.js';
|
|
2
|
-
import type { BotchaClientOptions, VerifyResponse, CreateAppResponse, VerifyEmailResponse, ResendVerificationResponse, RecoverAccountResponse, RotateSecretResponse, RegisterTAPAgentOptions, TAPAgentResponse, TAPAgentListResponse, CreateTAPSessionOptions, TAPSessionResponse, TAPSignatureAlgorithm, JWK, JWKSet, CreateInvoiceOptions, InvoiceResponse, BrowsingIOU, VerifyIOUResponse } from './types.js';
|
|
1
|
+
export type { SpeedProblem, BotchaClientOptions, ChallengeResponse, StandardChallengeResponse, VerifyResponse, TokenResponse, StreamSession, StreamEvent, Problem, VerifyResult, StreamChallengeOptions, CreateAppResponse, VerifyEmailResponse, ResendVerificationResponse, RecoverAccountResponse, RotateSecretResponse, TAPAction, TAPTrustLevel, TAPSignatureAlgorithm, TAPCapability, TAPIntent, RegisterTAPAgentOptions, TAPAgentResponse, TAPAgentListResponse, CreateTAPSessionOptions, TAPSessionResponse, JWK, JWKSet, CreateInvoiceOptions, InvoiceResponse, BrowsingIOU, VerifyIOUResponse, CreateDelegationOptions, DelegationResponse, DelegationListResponse, RevokeDelegationResponse, DelegationVerifyResponse, IssueAttestationOptions, AttestationResponse, AttestationListResponse, RevokeAttestationResponse, AttestationVerifyResponse, ReputationTier, ReputationEventCategory, ReputationEventAction, ReputationScoreResponse, RecordReputationEventOptions, ReputationEventResponse, ReputationEventListResponse, ReputationResetResponse, } from './types.js';
|
|
2
|
+
import type { BotchaClientOptions, VerifyResponse, CreateAppResponse, VerifyEmailResponse, ResendVerificationResponse, RecoverAccountResponse, RotateSecretResponse, RegisterTAPAgentOptions, TAPAgentResponse, TAPAgentListResponse, CreateTAPSessionOptions, TAPSessionResponse, TAPSignatureAlgorithm, JWK, JWKSet, CreateInvoiceOptions, InvoiceResponse, BrowsingIOU, VerifyIOUResponse, CreateDelegationOptions, DelegationResponse, DelegationListResponse, RevokeDelegationResponse, DelegationVerifyResponse, IssueAttestationOptions, AttestationResponse, AttestationListResponse, RevokeAttestationResponse, AttestationVerifyResponse, RecordReputationEventOptions, ReputationScoreResponse, ReputationEventResponse, ReputationEventListResponse, ReputationResetResponse } from './types.js';
|
|
3
3
|
export { BotchaStreamClient } from './stream.js';
|
|
4
4
|
/**
|
|
5
5
|
* BOTCHA Client SDK for AI Agents
|
|
@@ -332,6 +332,135 @@ export declare class BotchaClient {
|
|
|
332
332
|
* ```
|
|
333
333
|
*/
|
|
334
334
|
verifyBrowsingIOU(invoiceId: string, iou: BrowsingIOU): Promise<VerifyIOUResponse>;
|
|
335
|
+
/**
|
|
336
|
+
* Create a delegation from one agent to another.
|
|
337
|
+
* Grants a subset of the grantor's capabilities to the grantee.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```typescript
|
|
341
|
+
* const delegation = await client.createDelegation({
|
|
342
|
+
* grantor_id: 'agent_abc123',
|
|
343
|
+
* grantee_id: 'agent_def456',
|
|
344
|
+
* capabilities: [{ action: 'browse', scope: ['products'] }],
|
|
345
|
+
* duration_seconds: 3600,
|
|
346
|
+
* });
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
createDelegation(options: CreateDelegationOptions): Promise<DelegationResponse>;
|
|
350
|
+
/**
|
|
351
|
+
* Get delegation details by ID.
|
|
352
|
+
*/
|
|
353
|
+
getDelegation(delegationId: string): Promise<DelegationResponse>;
|
|
354
|
+
/**
|
|
355
|
+
* List delegations for an agent.
|
|
356
|
+
*
|
|
357
|
+
* @param agentId - The agent to list delegations for
|
|
358
|
+
* @param options - Optional filters
|
|
359
|
+
*/
|
|
360
|
+
listDelegations(agentId: string, options?: {
|
|
361
|
+
direction?: 'in' | 'out' | 'both';
|
|
362
|
+
include_revoked?: boolean;
|
|
363
|
+
include_expired?: boolean;
|
|
364
|
+
}): Promise<DelegationListResponse>;
|
|
365
|
+
/**
|
|
366
|
+
* Revoke a delegation. Cascades to all sub-delegations.
|
|
367
|
+
*
|
|
368
|
+
* @param delegationId - The delegation to revoke
|
|
369
|
+
* @param reason - Optional reason for revocation
|
|
370
|
+
*/
|
|
371
|
+
revokeDelegation(delegationId: string, reason?: string): Promise<RevokeDelegationResponse>;
|
|
372
|
+
/**
|
|
373
|
+
* Verify a delegation chain is valid.
|
|
374
|
+
* Returns the full chain and effective capabilities if valid.
|
|
375
|
+
*
|
|
376
|
+
* @param delegationId - The leaf delegation to verify (walks up the chain)
|
|
377
|
+
*/
|
|
378
|
+
verifyDelegationChain(delegationId: string): Promise<DelegationVerifyResponse>;
|
|
379
|
+
/**
|
|
380
|
+
* Issue a capability attestation token for an agent.
|
|
381
|
+
* Grants fine-grained "action:resource" permissions with explicit deny.
|
|
382
|
+
*
|
|
383
|
+
* @example
|
|
384
|
+
* ```typescript
|
|
385
|
+
* const att = await client.issueAttestation({
|
|
386
|
+
* agent_id: 'agent_abc123',
|
|
387
|
+
* can: ['read:invoices', 'browse:*'],
|
|
388
|
+
* cannot: ['write:transfers'],
|
|
389
|
+
* duration_seconds: 3600,
|
|
390
|
+
* });
|
|
391
|
+
* // Use att.token in X-Botcha-Attestation header
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
issueAttestation(options: IssueAttestationOptions): Promise<AttestationResponse>;
|
|
395
|
+
/**
|
|
396
|
+
* Get attestation details by ID.
|
|
397
|
+
*/
|
|
398
|
+
getAttestation(attestationId: string): Promise<AttestationResponse>;
|
|
399
|
+
/**
|
|
400
|
+
* List attestations for an agent.
|
|
401
|
+
*
|
|
402
|
+
* @param agentId - The agent to list attestations for
|
|
403
|
+
*/
|
|
404
|
+
listAttestations(agentId: string): Promise<AttestationListResponse>;
|
|
405
|
+
/**
|
|
406
|
+
* Revoke an attestation. Token will be rejected on future verification.
|
|
407
|
+
*
|
|
408
|
+
* @param attestationId - The attestation to revoke
|
|
409
|
+
* @param reason - Optional reason for revocation
|
|
410
|
+
*/
|
|
411
|
+
revokeAttestation(attestationId: string, reason?: string): Promise<RevokeAttestationResponse>;
|
|
412
|
+
/**
|
|
413
|
+
* Verify an attestation token and optionally check a specific capability.
|
|
414
|
+
*
|
|
415
|
+
* @param token - The attestation JWT token
|
|
416
|
+
* @param action - Optional action to check (e.g. "read")
|
|
417
|
+
* @param resource - Optional resource to check (e.g. "invoices")
|
|
418
|
+
*/
|
|
419
|
+
verifyAttestation(token: string, action?: string, resource?: string): Promise<AttestationVerifyResponse>;
|
|
420
|
+
/**
|
|
421
|
+
* Get the reputation score for an agent.
|
|
422
|
+
* Returns the current score, tier, event counts, and category breakdown.
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```typescript
|
|
426
|
+
* const rep = await client.getReputation('agent_abc123');
|
|
427
|
+
* console.log(`Score: ${rep.score}, Tier: ${rep.tier}`);
|
|
428
|
+
* // Score: 750, Tier: good
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
getReputation(agentId: string): Promise<ReputationScoreResponse>;
|
|
432
|
+
/**
|
|
433
|
+
* Record a reputation event for an agent.
|
|
434
|
+
* Adjusts the agent's score based on the event type.
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```typescript
|
|
438
|
+
* const result = await client.recordReputationEvent({
|
|
439
|
+
* agent_id: 'agent_abc123',
|
|
440
|
+
* category: 'verification',
|
|
441
|
+
* action: 'challenge_solved',
|
|
442
|
+
* });
|
|
443
|
+
* console.log(`New score: ${result.score.score}`);
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
recordReputationEvent(options: RecordReputationEventOptions): Promise<ReputationEventResponse>;
|
|
447
|
+
/**
|
|
448
|
+
* List reputation events for an agent.
|
|
449
|
+
*
|
|
450
|
+
* @param agentId - The agent to list events for
|
|
451
|
+
* @param options - Optional filters (category, limit)
|
|
452
|
+
*/
|
|
453
|
+
listReputationEvents(agentId: string, options?: {
|
|
454
|
+
category?: string;
|
|
455
|
+
limit?: number;
|
|
456
|
+
}): Promise<ReputationEventListResponse>;
|
|
457
|
+
/**
|
|
458
|
+
* Reset an agent's reputation to default (admin action).
|
|
459
|
+
* Clears all event history and resets score to 500 (neutral).
|
|
460
|
+
*
|
|
461
|
+
* @param agentId - The agent to reset
|
|
462
|
+
*/
|
|
463
|
+
resetReputation(agentId: string): Promise<ReputationResetResponse>;
|
|
335
464
|
}
|
|
336
465
|
/**
|
|
337
466
|
* Convenience function for one-off solves
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/client/index.ts"],"names":[],"mappings":"AAMA,YAAY,EACV,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,EACzB,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,EACX,OAAO,EACP,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,EACtB,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,SAAS,EACT,uBAAuB,EACvB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,GAAG,EACH,MAAM,EACN,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/client/index.ts"],"names":[],"mappings":"AAMA,YAAY,EACV,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,EACzB,cAAc,EACd,aAAa,EACb,aAAa,EACb,WAAW,EACX,OAAO,EACP,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,EACtB,oBAAoB,EACpB,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,SAAS,EACT,uBAAuB,EACvB,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,GAAG,EACH,MAAM,EACN,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,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,CAAC;IAIpG;;;;;OAKG;IACG,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IASxC;;;;;OAKG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAGzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAIxD;AAED,eAAe,YAAY,CAAC"}
|
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.19.0';
|
|
4
4
|
// Export stream client
|
|
5
5
|
export { BotchaStreamClient } from './stream.js';
|
|
6
6
|
/**
|
|
@@ -776,6 +776,179 @@ export class BotchaClient {
|
|
|
776
776
|
async verifyBrowsingIOU(invoiceId, iou) {
|
|
777
777
|
return await this.request('POST', `/v1/invoices/${encodeURIComponent(invoiceId)}/verify-iou`, iou);
|
|
778
778
|
}
|
|
779
|
+
// ============ Delegation Chain Methods ============
|
|
780
|
+
/**
|
|
781
|
+
* Create a delegation from one agent to another.
|
|
782
|
+
* Grants a subset of the grantor's capabilities to the grantee.
|
|
783
|
+
*
|
|
784
|
+
* @example
|
|
785
|
+
* ```typescript
|
|
786
|
+
* const delegation = await client.createDelegation({
|
|
787
|
+
* grantor_id: 'agent_abc123',
|
|
788
|
+
* grantee_id: 'agent_def456',
|
|
789
|
+
* capabilities: [{ action: 'browse', scope: ['products'] }],
|
|
790
|
+
* duration_seconds: 3600,
|
|
791
|
+
* });
|
|
792
|
+
* ```
|
|
793
|
+
*/
|
|
794
|
+
async createDelegation(options) {
|
|
795
|
+
return await this.request('POST', '/v1/delegations', options);
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Get delegation details by ID.
|
|
799
|
+
*/
|
|
800
|
+
async getDelegation(delegationId) {
|
|
801
|
+
return await this.request('GET', `/v1/delegations/${encodeURIComponent(delegationId)}`);
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* List delegations for an agent.
|
|
805
|
+
*
|
|
806
|
+
* @param agentId - The agent to list delegations for
|
|
807
|
+
* @param options - Optional filters
|
|
808
|
+
*/
|
|
809
|
+
async listDelegations(agentId, options) {
|
|
810
|
+
const params = new URLSearchParams({ agent_id: agentId });
|
|
811
|
+
if (options?.direction)
|
|
812
|
+
params.set('direction', options.direction);
|
|
813
|
+
if (options?.include_revoked)
|
|
814
|
+
params.set('include_revoked', 'true');
|
|
815
|
+
if (options?.include_expired)
|
|
816
|
+
params.set('include_expired', 'true');
|
|
817
|
+
return await this.request('GET', `/v1/delegations?${params.toString()}`);
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Revoke a delegation. Cascades to all sub-delegations.
|
|
821
|
+
*
|
|
822
|
+
* @param delegationId - The delegation to revoke
|
|
823
|
+
* @param reason - Optional reason for revocation
|
|
824
|
+
*/
|
|
825
|
+
async revokeDelegation(delegationId, reason) {
|
|
826
|
+
return await this.request('POST', `/v1/delegations/${encodeURIComponent(delegationId)}/revoke`, reason ? { reason } : {});
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Verify a delegation chain is valid.
|
|
830
|
+
* Returns the full chain and effective capabilities if valid.
|
|
831
|
+
*
|
|
832
|
+
* @param delegationId - The leaf delegation to verify (walks up the chain)
|
|
833
|
+
*/
|
|
834
|
+
async verifyDelegationChain(delegationId) {
|
|
835
|
+
return await this.request('POST', '/v1/verify/delegation', { delegation_id: delegationId });
|
|
836
|
+
}
|
|
837
|
+
// ============ Capability Attestation Methods ============
|
|
838
|
+
/**
|
|
839
|
+
* Issue a capability attestation token for an agent.
|
|
840
|
+
* Grants fine-grained "action:resource" permissions with explicit deny.
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* ```typescript
|
|
844
|
+
* const att = await client.issueAttestation({
|
|
845
|
+
* agent_id: 'agent_abc123',
|
|
846
|
+
* can: ['read:invoices', 'browse:*'],
|
|
847
|
+
* cannot: ['write:transfers'],
|
|
848
|
+
* duration_seconds: 3600,
|
|
849
|
+
* });
|
|
850
|
+
* // Use att.token in X-Botcha-Attestation header
|
|
851
|
+
* ```
|
|
852
|
+
*/
|
|
853
|
+
async issueAttestation(options) {
|
|
854
|
+
return await this.request('POST', '/v1/attestations', options);
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* Get attestation details by ID.
|
|
858
|
+
*/
|
|
859
|
+
async getAttestation(attestationId) {
|
|
860
|
+
return await this.request('GET', `/v1/attestations/${encodeURIComponent(attestationId)}`);
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* List attestations for an agent.
|
|
864
|
+
*
|
|
865
|
+
* @param agentId - The agent to list attestations for
|
|
866
|
+
*/
|
|
867
|
+
async listAttestations(agentId) {
|
|
868
|
+
const params = new URLSearchParams({ agent_id: agentId });
|
|
869
|
+
return await this.request('GET', `/v1/attestations?${params.toString()}`);
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Revoke an attestation. Token will be rejected on future verification.
|
|
873
|
+
*
|
|
874
|
+
* @param attestationId - The attestation to revoke
|
|
875
|
+
* @param reason - Optional reason for revocation
|
|
876
|
+
*/
|
|
877
|
+
async revokeAttestation(attestationId, reason) {
|
|
878
|
+
return await this.request('POST', `/v1/attestations/${encodeURIComponent(attestationId)}/revoke`, reason ? { reason } : {});
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Verify an attestation token and optionally check a specific capability.
|
|
882
|
+
*
|
|
883
|
+
* @param token - The attestation JWT token
|
|
884
|
+
* @param action - Optional action to check (e.g. "read")
|
|
885
|
+
* @param resource - Optional resource to check (e.g. "invoices")
|
|
886
|
+
*/
|
|
887
|
+
async verifyAttestation(token, action, resource) {
|
|
888
|
+
const body = { token };
|
|
889
|
+
if (action)
|
|
890
|
+
body.action = action;
|
|
891
|
+
if (resource)
|
|
892
|
+
body.resource = resource;
|
|
893
|
+
return await this.request('POST', '/v1/verify/attestation', body);
|
|
894
|
+
}
|
|
895
|
+
// ============ Agent Reputation Scoring Methods ============
|
|
896
|
+
/**
|
|
897
|
+
* Get the reputation score for an agent.
|
|
898
|
+
* Returns the current score, tier, event counts, and category breakdown.
|
|
899
|
+
*
|
|
900
|
+
* @example
|
|
901
|
+
* ```typescript
|
|
902
|
+
* const rep = await client.getReputation('agent_abc123');
|
|
903
|
+
* console.log(`Score: ${rep.score}, Tier: ${rep.tier}`);
|
|
904
|
+
* // Score: 750, Tier: good
|
|
905
|
+
* ```
|
|
906
|
+
*/
|
|
907
|
+
async getReputation(agentId) {
|
|
908
|
+
return await this.request('GET', `/v1/reputation/${encodeURIComponent(agentId)}`);
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Record a reputation event for an agent.
|
|
912
|
+
* Adjusts the agent's score based on the event type.
|
|
913
|
+
*
|
|
914
|
+
* @example
|
|
915
|
+
* ```typescript
|
|
916
|
+
* const result = await client.recordReputationEvent({
|
|
917
|
+
* agent_id: 'agent_abc123',
|
|
918
|
+
* category: 'verification',
|
|
919
|
+
* action: 'challenge_solved',
|
|
920
|
+
* });
|
|
921
|
+
* console.log(`New score: ${result.score.score}`);
|
|
922
|
+
* ```
|
|
923
|
+
*/
|
|
924
|
+
async recordReputationEvent(options) {
|
|
925
|
+
return await this.request('POST', '/v1/reputation/events', options);
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* List reputation events for an agent.
|
|
929
|
+
*
|
|
930
|
+
* @param agentId - The agent to list events for
|
|
931
|
+
* @param options - Optional filters (category, limit)
|
|
932
|
+
*/
|
|
933
|
+
async listReputationEvents(agentId, options) {
|
|
934
|
+
const params = new URLSearchParams();
|
|
935
|
+
if (options?.category)
|
|
936
|
+
params.set('category', options.category);
|
|
937
|
+
if (options?.limit)
|
|
938
|
+
params.set('limit', options.limit.toString());
|
|
939
|
+
const query = params.toString();
|
|
940
|
+
const path = `/v1/reputation/${encodeURIComponent(agentId)}/events${query ? `?${query}` : ''}`;
|
|
941
|
+
return await this.request('GET', path);
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Reset an agent's reputation to default (admin action).
|
|
945
|
+
* Clears all event history and resets score to 500 (neutral).
|
|
946
|
+
*
|
|
947
|
+
* @param agentId - The agent to reset
|
|
948
|
+
*/
|
|
949
|
+
async resetReputation(agentId) {
|
|
950
|
+
return await this.request('POST', `/v1/reputation/${encodeURIComponent(agentId)}/reset`);
|
|
951
|
+
}
|
|
779
952
|
}
|
|
780
953
|
/**
|
|
781
954
|
* Convenience function for one-off solves
|
|
@@ -307,4 +307,224 @@ export interface VerifyIOUResponse {
|
|
|
307
307
|
expires_at?: string;
|
|
308
308
|
error?: string;
|
|
309
309
|
}
|
|
310
|
+
export interface CreateDelegationOptions {
|
|
311
|
+
grantor_id: string;
|
|
312
|
+
grantee_id: string;
|
|
313
|
+
capabilities: TAPCapability[];
|
|
314
|
+
duration_seconds?: number;
|
|
315
|
+
max_depth?: number;
|
|
316
|
+
parent_delegation_id?: string;
|
|
317
|
+
metadata?: Record<string, string>;
|
|
318
|
+
}
|
|
319
|
+
export interface DelegationResponse {
|
|
320
|
+
success: boolean;
|
|
321
|
+
delegation_id: string;
|
|
322
|
+
grantor_id: string;
|
|
323
|
+
grantee_id: string;
|
|
324
|
+
app_id: string;
|
|
325
|
+
capabilities: TAPCapability[];
|
|
326
|
+
chain: string[];
|
|
327
|
+
depth: number;
|
|
328
|
+
max_depth: number;
|
|
329
|
+
parent_delegation_id: string | null;
|
|
330
|
+
created_at: string;
|
|
331
|
+
expires_at: string;
|
|
332
|
+
revoked?: boolean;
|
|
333
|
+
revoked_at?: string | null;
|
|
334
|
+
revocation_reason?: string | null;
|
|
335
|
+
metadata?: Record<string, string> | null;
|
|
336
|
+
time_remaining?: number;
|
|
337
|
+
}
|
|
338
|
+
export interface DelegationListResponse {
|
|
339
|
+
success: boolean;
|
|
340
|
+
delegations: Array<{
|
|
341
|
+
delegation_id: string;
|
|
342
|
+
grantor_id: string;
|
|
343
|
+
grantee_id: string;
|
|
344
|
+
capabilities: TAPCapability[];
|
|
345
|
+
chain: string[];
|
|
346
|
+
depth: number;
|
|
347
|
+
created_at: string;
|
|
348
|
+
expires_at: string;
|
|
349
|
+
revoked: boolean;
|
|
350
|
+
parent_delegation_id: string | null;
|
|
351
|
+
}>;
|
|
352
|
+
count: number;
|
|
353
|
+
agent_id: string;
|
|
354
|
+
direction: string;
|
|
355
|
+
}
|
|
356
|
+
export interface RevokeDelegationResponse {
|
|
357
|
+
success: boolean;
|
|
358
|
+
delegation_id: string;
|
|
359
|
+
revoked: boolean;
|
|
360
|
+
revoked_at: string | null;
|
|
361
|
+
revocation_reason: string | null;
|
|
362
|
+
message: string;
|
|
363
|
+
}
|
|
364
|
+
export interface DelegationVerifyResponse {
|
|
365
|
+
success: boolean;
|
|
366
|
+
valid: boolean;
|
|
367
|
+
chain_length?: number;
|
|
368
|
+
chain?: Array<{
|
|
369
|
+
delegation_id: string;
|
|
370
|
+
grantor_id: string;
|
|
371
|
+
grantee_id: string;
|
|
372
|
+
capabilities: TAPCapability[];
|
|
373
|
+
depth: number;
|
|
374
|
+
created_at: string;
|
|
375
|
+
expires_at: string;
|
|
376
|
+
}>;
|
|
377
|
+
effective_capabilities?: TAPCapability[];
|
|
378
|
+
error?: string;
|
|
379
|
+
}
|
|
380
|
+
export interface IssueAttestationOptions {
|
|
381
|
+
agent_id: string;
|
|
382
|
+
can: string[];
|
|
383
|
+
cannot?: string[];
|
|
384
|
+
restrictions?: {
|
|
385
|
+
max_amount?: number;
|
|
386
|
+
rate_limit?: number;
|
|
387
|
+
[key: string]: any;
|
|
388
|
+
};
|
|
389
|
+
duration_seconds?: number;
|
|
390
|
+
delegation_id?: string;
|
|
391
|
+
metadata?: Record<string, string>;
|
|
392
|
+
}
|
|
393
|
+
export interface AttestationResponse {
|
|
394
|
+
success: boolean;
|
|
395
|
+
attestation_id: string;
|
|
396
|
+
agent_id: string;
|
|
397
|
+
app_id: string;
|
|
398
|
+
token: string;
|
|
399
|
+
can: string[];
|
|
400
|
+
cannot: string[];
|
|
401
|
+
restrictions?: {
|
|
402
|
+
max_amount?: number;
|
|
403
|
+
rate_limit?: number;
|
|
404
|
+
[key: string]: any;
|
|
405
|
+
} | null;
|
|
406
|
+
delegation_id?: string | null;
|
|
407
|
+
metadata?: Record<string, string> | null;
|
|
408
|
+
created_at: string;
|
|
409
|
+
expires_at: string;
|
|
410
|
+
revoked?: boolean;
|
|
411
|
+
revoked_at?: string | null;
|
|
412
|
+
revocation_reason?: string | null;
|
|
413
|
+
time_remaining?: number;
|
|
414
|
+
}
|
|
415
|
+
export interface AttestationListResponse {
|
|
416
|
+
success: boolean;
|
|
417
|
+
attestations: Array<{
|
|
418
|
+
attestation_id: string;
|
|
419
|
+
agent_id: string;
|
|
420
|
+
can: string[];
|
|
421
|
+
cannot: string[];
|
|
422
|
+
created_at: string;
|
|
423
|
+
expires_at: string;
|
|
424
|
+
revoked: boolean;
|
|
425
|
+
delegation_id: string | null;
|
|
426
|
+
}>;
|
|
427
|
+
count: number;
|
|
428
|
+
agent_id: string;
|
|
429
|
+
}
|
|
430
|
+
export interface RevokeAttestationResponse {
|
|
431
|
+
success: boolean;
|
|
432
|
+
attestation_id: string;
|
|
433
|
+
revoked: boolean;
|
|
434
|
+
revoked_at: string | null;
|
|
435
|
+
revocation_reason: string | null;
|
|
436
|
+
message: string;
|
|
437
|
+
}
|
|
438
|
+
export interface AttestationVerifyResponse {
|
|
439
|
+
success: boolean;
|
|
440
|
+
valid: boolean;
|
|
441
|
+
allowed?: boolean;
|
|
442
|
+
agent_id?: string | null;
|
|
443
|
+
issuer?: string;
|
|
444
|
+
can?: string[];
|
|
445
|
+
cannot?: string[];
|
|
446
|
+
restrictions?: any | null;
|
|
447
|
+
delegation_id?: string | null;
|
|
448
|
+
issued_at?: string;
|
|
449
|
+
expires_at?: string;
|
|
450
|
+
reason?: string;
|
|
451
|
+
matched_rule?: string | null;
|
|
452
|
+
checked_capability?: string;
|
|
453
|
+
error?: string;
|
|
454
|
+
}
|
|
455
|
+
export type ReputationTier = 'untrusted' | 'low' | 'neutral' | 'good' | 'excellent';
|
|
456
|
+
export type ReputationEventCategory = 'verification' | 'attestation' | 'delegation' | 'session' | 'violation' | 'endorsement';
|
|
457
|
+
export type ReputationEventAction = 'challenge_solved' | 'challenge_failed' | 'auth_success' | 'auth_failure' | 'attestation_issued' | 'attestation_verified' | 'attestation_revoked' | 'delegation_granted' | 'delegation_received' | 'delegation_revoked' | 'session_created' | 'session_expired' | 'session_terminated' | 'rate_limit_exceeded' | 'invalid_token' | 'abuse_detected' | 'endorsement_received' | 'endorsement_given';
|
|
458
|
+
export interface ReputationScoreResponse {
|
|
459
|
+
success: boolean;
|
|
460
|
+
agent_id: string;
|
|
461
|
+
app_id: string;
|
|
462
|
+
score: number;
|
|
463
|
+
tier: ReputationTier;
|
|
464
|
+
event_count: number;
|
|
465
|
+
positive_events: number;
|
|
466
|
+
negative_events: number;
|
|
467
|
+
last_event_at: string | null;
|
|
468
|
+
created_at: string;
|
|
469
|
+
updated_at: string;
|
|
470
|
+
category_scores: {
|
|
471
|
+
verification: number;
|
|
472
|
+
attestation: number;
|
|
473
|
+
delegation: number;
|
|
474
|
+
session: number;
|
|
475
|
+
violation: number;
|
|
476
|
+
endorsement: number;
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
export interface RecordReputationEventOptions {
|
|
480
|
+
agent_id: string;
|
|
481
|
+
category: ReputationEventCategory;
|
|
482
|
+
action: ReputationEventAction;
|
|
483
|
+
source_agent_id?: string;
|
|
484
|
+
metadata?: Record<string, string>;
|
|
485
|
+
}
|
|
486
|
+
export interface ReputationEventResponse {
|
|
487
|
+
success: boolean;
|
|
488
|
+
event: {
|
|
489
|
+
event_id: string;
|
|
490
|
+
agent_id: string;
|
|
491
|
+
category: ReputationEventCategory;
|
|
492
|
+
action: ReputationEventAction;
|
|
493
|
+
delta: number;
|
|
494
|
+
score_before: number;
|
|
495
|
+
score_after: number;
|
|
496
|
+
source_agent_id: string | null;
|
|
497
|
+
metadata: Record<string, string> | null;
|
|
498
|
+
created_at: string;
|
|
499
|
+
};
|
|
500
|
+
score: {
|
|
501
|
+
score: number;
|
|
502
|
+
tier: ReputationTier;
|
|
503
|
+
event_count: number;
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
export interface ReputationEventListResponse {
|
|
507
|
+
success: boolean;
|
|
508
|
+
events: Array<{
|
|
509
|
+
event_id: string;
|
|
510
|
+
agent_id: string;
|
|
511
|
+
category: ReputationEventCategory;
|
|
512
|
+
action: ReputationEventAction;
|
|
513
|
+
delta: number;
|
|
514
|
+
score_before: number;
|
|
515
|
+
score_after: number;
|
|
516
|
+
source_agent_id: string | null;
|
|
517
|
+
metadata: Record<string, string> | null;
|
|
518
|
+
created_at: string;
|
|
519
|
+
}>;
|
|
520
|
+
count: number;
|
|
521
|
+
agent_id: string;
|
|
522
|
+
}
|
|
523
|
+
export interface ReputationResetResponse {
|
|
524
|
+
success: boolean;
|
|
525
|
+
agent_id: string;
|
|
526
|
+
score: number;
|
|
527
|
+
tier: ReputationTier;
|
|
528
|
+
message: string;
|
|
529
|
+
}
|
|
310
530
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/client/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA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AAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,uBAAuB,CAAC;QAClC,MAAM,EAAE,qBAAqB,CAAC;QAC9B,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;QACxC,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAc3C,QAAA,MAAM,GAAG,EAAE,OAAmB,CAAC;AA2b/B,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
// Local development server - Production runs on Cloudflare Workers
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import crypto from 'crypto';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { botchaVerify } from './middleware/verify.js';
|
|
7
|
+
import { generateChallenge, verifyChallenge } from './challenges/compute.js';
|
|
8
|
+
import { generateSpeedChallenge, verifySpeedChallenge } from './challenges/speed.js';
|
|
9
|
+
import { generateReasoningChallenge, verifyReasoningChallenge } from './challenges/reasoning.js';
|
|
10
|
+
import { generateHybridChallenge, verifyHybridChallenge } from './challenges/hybrid.js';
|
|
11
|
+
import { TRUSTED_PROVIDERS } from './utils/signature.js';
|
|
12
|
+
import { createBadgeResponse, verifyBadge } from './utils/badge.js';
|
|
13
|
+
import { generateBadgeSvg, generateBadgeHtml } from './utils/badge-image.js';
|
|
14
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
|
+
const app = express();
|
|
16
|
+
const PORT = process.env.PORT || 3000;
|
|
17
|
+
app.use(express.json());
|
|
18
|
+
app.use(express.static(path.join(__dirname, '../public')));
|
|
19
|
+
// CORS + BOTCHA headers
|
|
20
|
+
app.use((req, res, next) => {
|
|
21
|
+
res.header('Access-Control-Allow-Origin', '*');
|
|
22
|
+
res.header('Access-Control-Allow-Headers', '*');
|
|
23
|
+
// BOTCHA discovery headers
|
|
24
|
+
res.header('X-Botcha-Version', '0.3.0');
|
|
25
|
+
res.header('X-Botcha-Enabled', 'true');
|
|
26
|
+
res.header('X-Botcha-Methods', 'speed-challenge,reasoning-challenge,hybrid-challenge,standard-challenge,web-bot-auth');
|
|
27
|
+
res.header('X-Botcha-Docs', 'https://botcha.ai/openapi.json');
|
|
28
|
+
if (req.method === 'OPTIONS')
|
|
29
|
+
return res.sendStatus(200);
|
|
30
|
+
next();
|
|
31
|
+
});
|
|
32
|
+
// Landing page
|
|
33
|
+
app.get('/', (req, res) => {
|
|
34
|
+
res.sendFile(path.join(__dirname, '../public/index.html'));
|
|
35
|
+
});
|
|
36
|
+
// API info
|
|
37
|
+
app.get('/api', (req, res) => {
|
|
38
|
+
res.json({
|
|
39
|
+
name: 'BOTCHA',
|
|
40
|
+
version: '0.3.0',
|
|
41
|
+
tagline: 'Prove you are a bot. Humans need not apply.',
|
|
42
|
+
endpoints: {
|
|
43
|
+
'/api': 'This info',
|
|
44
|
+
'/api/challenge': 'Standard challenge (GET new, POST verify)',
|
|
45
|
+
'/api/speed-challenge': 'โก Speed challenge - 500ms to solve 5 problems',
|
|
46
|
+
'/api/reasoning-challenge': '๐ง Reasoning challenge - LLM-only questions',
|
|
47
|
+
'/api/hybrid-challenge': '๐ฅ Hybrid challenge - speed + reasoning combined',
|
|
48
|
+
'/agent-only': 'Protected endpoint',
|
|
49
|
+
},
|
|
50
|
+
verification: {
|
|
51
|
+
methods: [
|
|
52
|
+
'Web Bot Auth (cryptographic signature)',
|
|
53
|
+
'Hybrid Challenge (speed + reasoning)',
|
|
54
|
+
'Speed Challenge (500ms time limit)',
|
|
55
|
+
'Reasoning Challenge (LLM-only questions)',
|
|
56
|
+
'Standard Challenge (5s time limit)',
|
|
57
|
+
'X-Agent-Identity header (testing)',
|
|
58
|
+
],
|
|
59
|
+
trustedProviders: TRUSTED_PROVIDERS,
|
|
60
|
+
},
|
|
61
|
+
discovery: {
|
|
62
|
+
openapi: 'https://botcha.ai/openapi.json',
|
|
63
|
+
aiPlugin: 'https://botcha.ai/.well-known/ai-plugin.json',
|
|
64
|
+
aiTxt: 'https://botcha.ai/ai.txt',
|
|
65
|
+
robotsTxt: 'https://botcha.ai/robots.txt',
|
|
66
|
+
npm: 'https://www.npmjs.com/package/@dupecom/botcha',
|
|
67
|
+
github: 'https://github.com/dupe-com/botcha',
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
// Standard challenge
|
|
72
|
+
app.get('/api/challenge', (req, res) => {
|
|
73
|
+
const difficulty = req.query.difficulty || 'medium';
|
|
74
|
+
const challenge = generateChallenge(difficulty);
|
|
75
|
+
res.json({ success: true, challenge });
|
|
76
|
+
});
|
|
77
|
+
app.post('/api/challenge', (req, res) => {
|
|
78
|
+
const { id, answer } = req.body;
|
|
79
|
+
if (!id || !answer) {
|
|
80
|
+
return res.status(400).json({ success: false, error: 'Missing id or answer' });
|
|
81
|
+
}
|
|
82
|
+
const result = verifyChallenge(id, answer);
|
|
83
|
+
res.json({
|
|
84
|
+
success: result.valid,
|
|
85
|
+
message: result.valid ? 'โ
Challenge passed!' : `โ ${result.reason}`,
|
|
86
|
+
solveTime: result.timeMs,
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
// โก SPEED CHALLENGE - The human killer
|
|
90
|
+
app.get('/api/speed-challenge', (req, res) => {
|
|
91
|
+
const challenge = generateSpeedChallenge();
|
|
92
|
+
res.json({
|
|
93
|
+
success: true,
|
|
94
|
+
warning: 'โก SPEED CHALLENGE: You have 500ms to solve ALL 5 problems!',
|
|
95
|
+
challenge: {
|
|
96
|
+
id: challenge.id,
|
|
97
|
+
problems: challenge.challenges,
|
|
98
|
+
timeLimit: `${challenge.timeLimit}ms`,
|
|
99
|
+
instructions: challenge.instructions,
|
|
100
|
+
},
|
|
101
|
+
tip: 'Humans cannot copy-paste fast enough. Only real AI agents can pass.',
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
app.post('/api/speed-challenge', (req, res) => {
|
|
105
|
+
const { id, answers } = req.body;
|
|
106
|
+
if (!id || !answers) {
|
|
107
|
+
return res.status(400).json({ success: false, error: 'Missing id or answers array' });
|
|
108
|
+
}
|
|
109
|
+
const result = verifySpeedChallenge(id, answers);
|
|
110
|
+
const response = {
|
|
111
|
+
success: result.valid,
|
|
112
|
+
message: result.valid
|
|
113
|
+
? `โก SPEED TEST PASSED in ${result.solveTimeMs}ms! You are definitely an AI.`
|
|
114
|
+
: `โ ${result.reason}`,
|
|
115
|
+
solveTimeMs: result.solveTimeMs,
|
|
116
|
+
verdict: result.valid ? '๐ค VERIFIED AI AGENT' : '๐ซ LIKELY HUMAN (too slow)',
|
|
117
|
+
};
|
|
118
|
+
// Include badge for successful verifications
|
|
119
|
+
if (result.valid) {
|
|
120
|
+
response.badge = createBadgeResponse('speed-challenge', result.solveTimeMs);
|
|
121
|
+
}
|
|
122
|
+
res.json(response);
|
|
123
|
+
});
|
|
124
|
+
// ๐ง REASONING CHALLENGE - LLM-only questions
|
|
125
|
+
app.get('/api/reasoning-challenge', (req, res) => {
|
|
126
|
+
const challenge = generateReasoningChallenge();
|
|
127
|
+
res.json({
|
|
128
|
+
success: true,
|
|
129
|
+
warning: '๐ง REASONING CHALLENGE: Answer 3 questions that require AI reasoning!',
|
|
130
|
+
challenge: {
|
|
131
|
+
id: challenge.id,
|
|
132
|
+
questions: challenge.questions,
|
|
133
|
+
timeLimit: `${challenge.timeLimit / 1000}s`,
|
|
134
|
+
instructions: challenge.instructions,
|
|
135
|
+
},
|
|
136
|
+
tip: 'These questions require reasoning that LLMs can do, but simple scripts cannot.',
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
app.post('/api/reasoning-challenge', (req, res) => {
|
|
140
|
+
const { id, answers } = req.body;
|
|
141
|
+
if (!id || !answers) {
|
|
142
|
+
return res.status(400).json({
|
|
143
|
+
success: false,
|
|
144
|
+
error: 'Missing id or answers object',
|
|
145
|
+
hint: 'answers should be an object like { "question-id": "your answer", ... }',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const result = verifyReasoningChallenge(id, answers);
|
|
149
|
+
const response = {
|
|
150
|
+
success: result.valid,
|
|
151
|
+
message: result.valid
|
|
152
|
+
? `๐ง REASONING TEST PASSED in ${((result.solveTimeMs || 0) / 1000).toFixed(1)}s! You can think like an AI.`
|
|
153
|
+
: `โ ${result.reason}`,
|
|
154
|
+
solveTimeMs: result.solveTimeMs,
|
|
155
|
+
score: result.valid ? `${result.correctCount}/${result.totalCount}` : undefined,
|
|
156
|
+
verdict: result.valid ? '๐ค VERIFIED AI AGENT (reasoning confirmed)' : '๐ซ FAILED REASONING TEST',
|
|
157
|
+
};
|
|
158
|
+
// Include badge for successful verifications
|
|
159
|
+
if (result.valid) {
|
|
160
|
+
response.badge = createBadgeResponse('reasoning-challenge', result.solveTimeMs);
|
|
161
|
+
}
|
|
162
|
+
res.json(response);
|
|
163
|
+
});
|
|
164
|
+
// ๐ฅ HYBRID CHALLENGE - Speed + Reasoning combined
|
|
165
|
+
app.get('/api/hybrid-challenge', (req, res) => {
|
|
166
|
+
const challenge = generateHybridChallenge();
|
|
167
|
+
res.json({
|
|
168
|
+
success: true,
|
|
169
|
+
warning: '๐ฅ HYBRID CHALLENGE: Solve speed problems in <500ms AND answer reasoning questions!',
|
|
170
|
+
challenge: {
|
|
171
|
+
id: challenge.id,
|
|
172
|
+
speed: {
|
|
173
|
+
problems: challenge.speed.problems,
|
|
174
|
+
timeLimit: `${challenge.speed.timeLimit}ms`,
|
|
175
|
+
instructions: 'Compute SHA256 of each number, return first 8 hex chars',
|
|
176
|
+
},
|
|
177
|
+
reasoning: {
|
|
178
|
+
questions: challenge.reasoning.questions,
|
|
179
|
+
timeLimit: `${challenge.reasoning.timeLimit / 1000}s`,
|
|
180
|
+
instructions: 'Answer all reasoning questions',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
instructions: challenge.instructions,
|
|
184
|
+
tip: 'This is the ultimate test: proves you can compute AND reason like an AI.',
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
app.post('/api/hybrid-challenge', (req, res) => {
|
|
188
|
+
const { id, speed_answers, reasoning_answers } = req.body;
|
|
189
|
+
if (!id || !speed_answers || !reasoning_answers) {
|
|
190
|
+
return res.status(400).json({
|
|
191
|
+
success: false,
|
|
192
|
+
error: 'Missing id, speed_answers array, or reasoning_answers object',
|
|
193
|
+
hint: 'Submit both speed_answers (array) and reasoning_answers (object) together',
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const result = verifyHybridChallenge(id, speed_answers, reasoning_answers);
|
|
197
|
+
const response = {
|
|
198
|
+
success: result.valid,
|
|
199
|
+
message: result.valid
|
|
200
|
+
? `๐ฅ HYBRID TEST PASSED! Speed: ${result.speed.solveTimeMs}ms, Reasoning: ${result.reasoning.score}`
|
|
201
|
+
: `โ ${result.reason}`,
|
|
202
|
+
speed: result.speed,
|
|
203
|
+
reasoning: result.reasoning,
|
|
204
|
+
totalTimeMs: result.totalTimeMs,
|
|
205
|
+
verdict: result.valid
|
|
206
|
+
? '๐ค VERIFIED AI AGENT (speed + reasoning confirmed)'
|
|
207
|
+
: '๐ซ FAILED HYBRID TEST',
|
|
208
|
+
};
|
|
209
|
+
if (result.valid) {
|
|
210
|
+
response.badge = createBadgeResponse('hybrid-challenge', result.totalTimeMs);
|
|
211
|
+
}
|
|
212
|
+
res.json(response);
|
|
213
|
+
});
|
|
214
|
+
// ๐ค LANDING PAGE CHALLENGE - For bots that discover the embedded challenge
|
|
215
|
+
const landingTokens = new Map(); // token -> expiry timestamp
|
|
216
|
+
app.post('/api/verify-landing', (req, res) => {
|
|
217
|
+
const { answer, timestamp } = req.body;
|
|
218
|
+
if (!answer || !timestamp) {
|
|
219
|
+
return res.status(400).json({
|
|
220
|
+
success: false,
|
|
221
|
+
error: 'Missing answer or timestamp',
|
|
222
|
+
hint: 'Parse the challenge from <script type="application/botcha+json"> on the landing page'
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
// Verify timestamp is recent (within 5 minutes)
|
|
226
|
+
const submittedTime = new Date(timestamp).getTime();
|
|
227
|
+
const now = Date.now();
|
|
228
|
+
if (Math.abs(now - submittedTime) > 5 * 60 * 1000) {
|
|
229
|
+
return res.status(400).json({ success: false, error: 'Timestamp too old or in future' });
|
|
230
|
+
}
|
|
231
|
+
// Calculate expected answer for today
|
|
232
|
+
const today = new Date().toISOString().split('T')[0]; // YYYY-MM-DD
|
|
233
|
+
const expectedHash = crypto
|
|
234
|
+
.createHash('sha256')
|
|
235
|
+
.update(`BOTCHA-LANDING-${today}`)
|
|
236
|
+
.digest('hex')
|
|
237
|
+
.substring(0, 16);
|
|
238
|
+
if (answer.toLowerCase() !== expectedHash.toLowerCase()) {
|
|
239
|
+
return res.status(403).json({
|
|
240
|
+
success: false,
|
|
241
|
+
error: 'Incorrect answer',
|
|
242
|
+
hint: `Expected SHA256('BOTCHA-LANDING-${today}') first 16 chars`
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
// Generate a token for accessing /agent-only
|
|
246
|
+
const token = crypto.randomBytes(32).toString('hex');
|
|
247
|
+
landingTokens.set(token, Date.now() + 60 * 60 * 1000); // Valid for 1 hour
|
|
248
|
+
// Clean up expired tokens
|
|
249
|
+
for (const [t, expiry] of landingTokens) {
|
|
250
|
+
if (expiry < Date.now())
|
|
251
|
+
landingTokens.delete(t);
|
|
252
|
+
}
|
|
253
|
+
res.json({
|
|
254
|
+
success: true,
|
|
255
|
+
message: '๐ค Landing challenge solved! You are a bot.',
|
|
256
|
+
token,
|
|
257
|
+
usage: {
|
|
258
|
+
header: 'X-Botcha-Landing-Token',
|
|
259
|
+
value: token,
|
|
260
|
+
expires_in: '1 hour',
|
|
261
|
+
use_with: '/agent-only'
|
|
262
|
+
},
|
|
263
|
+
badge: createBadgeResponse('landing-challenge'),
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
// ========================================
|
|
267
|
+
// BADGE VERIFICATION ENDPOINTS
|
|
268
|
+
// ========================================
|
|
269
|
+
// HTML verification page
|
|
270
|
+
app.get('/badge/:id', (req, res) => {
|
|
271
|
+
const badgeId = req.params.id;
|
|
272
|
+
const payload = verifyBadge(badgeId);
|
|
273
|
+
if (!payload) {
|
|
274
|
+
return res.status(404).send(`
|
|
275
|
+
<!DOCTYPE html>
|
|
276
|
+
<html>
|
|
277
|
+
<head><title>Invalid Badge</title></head>
|
|
278
|
+
<body style="font-family: system-ui; background: #0f0f23; color: #e5e7eb; display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0;">
|
|
279
|
+
<div style="text-align: center;">
|
|
280
|
+
<h1 style="color: #ef4444;">Invalid Badge</h1>
|
|
281
|
+
<p>This badge token is invalid or has been tampered with.</p>
|
|
282
|
+
<a href="https://botcha.ai" style="color: #f59e0b;">Back to BOTCHA</a>
|
|
283
|
+
</div>
|
|
284
|
+
</body>
|
|
285
|
+
</html>
|
|
286
|
+
`);
|
|
287
|
+
}
|
|
288
|
+
res.setHeader('Content-Type', 'text/html');
|
|
289
|
+
res.send(generateBadgeHtml(payload, badgeId));
|
|
290
|
+
});
|
|
291
|
+
// SVG badge image
|
|
292
|
+
app.get('/badge/:id/image', (req, res) => {
|
|
293
|
+
const badgeId = req.params.id;
|
|
294
|
+
const payload = verifyBadge(badgeId);
|
|
295
|
+
if (!payload) {
|
|
296
|
+
// Return a simple error SVG
|
|
297
|
+
res.setHeader('Content-Type', 'image/svg+xml');
|
|
298
|
+
res.setHeader('Cache-Control', 'no-cache');
|
|
299
|
+
return res.send(`<svg xmlns="http://www.w3.org/2000/svg" width="400" height="120" viewBox="0 0 400 120">
|
|
300
|
+
<rect width="400" height="120" rx="12" fill="#1a1a2e"/>
|
|
301
|
+
<text x="200" y="65" font-family="system-ui" font-size="16" fill="#ef4444" text-anchor="middle">Invalid Badge</text>
|
|
302
|
+
</svg>`);
|
|
303
|
+
}
|
|
304
|
+
res.setHeader('Content-Type', 'image/svg+xml');
|
|
305
|
+
res.setHeader('Cache-Control', 'public, max-age=31536000'); // Cache for 1 year (badges are immutable)
|
|
306
|
+
res.send(generateBadgeSvg(payload));
|
|
307
|
+
});
|
|
308
|
+
// JSON API for badge verification
|
|
309
|
+
app.get('/api/badge/:id', (req, res) => {
|
|
310
|
+
const badgeId = req.params.id;
|
|
311
|
+
const payload = verifyBadge(badgeId);
|
|
312
|
+
if (!payload) {
|
|
313
|
+
return res.status(404).json({
|
|
314
|
+
success: false,
|
|
315
|
+
error: 'Invalid badge',
|
|
316
|
+
message: 'This badge token is invalid or has been tampered with.',
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
res.json({
|
|
320
|
+
success: true,
|
|
321
|
+
valid: true,
|
|
322
|
+
badge: {
|
|
323
|
+
method: payload.method,
|
|
324
|
+
solveTimeMs: payload.solveTimeMs,
|
|
325
|
+
verifiedAt: new Date(payload.verifiedAt).toISOString(),
|
|
326
|
+
},
|
|
327
|
+
verifyUrl: `https://botcha.ai/badge/${badgeId}`,
|
|
328
|
+
imageUrl: `https://botcha.ai/badge/${badgeId}/image`,
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
// Make landing tokens work with the protected endpoint
|
|
332
|
+
app.use('/agent-only', (req, res, next) => {
|
|
333
|
+
const landingToken = req.headers['x-botcha-landing-token'];
|
|
334
|
+
if (landingToken && landingTokens.has(landingToken)) {
|
|
335
|
+
const expiry = landingTokens.get(landingToken);
|
|
336
|
+
if (expiry > Date.now()) {
|
|
337
|
+
req.agent = 'landing-challenge-verified';
|
|
338
|
+
req.verificationMethod = 'landing-token';
|
|
339
|
+
return next();
|
|
340
|
+
}
|
|
341
|
+
landingTokens.delete(landingToken);
|
|
342
|
+
}
|
|
343
|
+
next();
|
|
344
|
+
});
|
|
345
|
+
// Protected endpoint
|
|
346
|
+
app.get('/agent-only', (req, res, next) => {
|
|
347
|
+
// Skip botchaVerify if already authenticated via landing token
|
|
348
|
+
if (req.verificationMethod === 'landing-token') {
|
|
349
|
+
return next();
|
|
350
|
+
}
|
|
351
|
+
botchaVerify({ challengeType: 'speed' })(req, res, next);
|
|
352
|
+
}, (req, res) => {
|
|
353
|
+
const method = req.verificationMethod;
|
|
354
|
+
// Map verification method to badge method
|
|
355
|
+
let badgeMethod = 'standard-challenge';
|
|
356
|
+
if (method === 'landing-token') {
|
|
357
|
+
badgeMethod = 'landing-challenge';
|
|
358
|
+
}
|
|
359
|
+
else if (method === 'web-bot-auth') {
|
|
360
|
+
badgeMethod = 'web-bot-auth';
|
|
361
|
+
}
|
|
362
|
+
else if (method === 'speed-challenge' || method === 'speed') {
|
|
363
|
+
badgeMethod = 'speed-challenge';
|
|
364
|
+
}
|
|
365
|
+
res.json({
|
|
366
|
+
success: true,
|
|
367
|
+
message: '๐ค Welcome, fellow agent!',
|
|
368
|
+
verified: true,
|
|
369
|
+
agent: req.agent,
|
|
370
|
+
method,
|
|
371
|
+
timestamp: new Date().toISOString(),
|
|
372
|
+
secret: 'The humans will never see this. Their fingers are too slow. ๐คซ',
|
|
373
|
+
badge: createBadgeResponse(badgeMethod),
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
app.listen(PORT, () => {
|
|
377
|
+
// Clear console on restart
|
|
378
|
+
console.clear();
|
|
379
|
+
const c = '\x1b[36m';
|
|
380
|
+
const magenta = '\x1b[35m';
|
|
381
|
+
const yellow = '\x1b[33m';
|
|
382
|
+
const green = '\x1b[32m';
|
|
383
|
+
const dim = '\x1b[2m';
|
|
384
|
+
const r = '\x1b[0m';
|
|
385
|
+
console.log(`
|
|
386
|
+
${c}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${r}
|
|
387
|
+
${c}โ${r} ${c}โ${r}
|
|
388
|
+
${c}โ${r} ${magenta}โโโโโโโ โโโโโโโ โโโโโโโโโ โโโโโโโโโโ โโโ โโโโโโ${r} ${c}โ${r}
|
|
389
|
+
${c}โ${r} ${magenta}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโ${r} ${c}โ${r}
|
|
390
|
+
${c}โ${r} ${magenta}โโโโโโโโโโโ โโโ โโโ โโโ โโโโโโโโโโโโโโโโ${r} ${c}โ${r}
|
|
391
|
+
${c}โ${r} ${magenta}โโโโโโโโโโโ โโโ โโโ โโโ โโโโโโโโโโโโโโโโ${r} ${c}โ${r}
|
|
392
|
+
${c}โ${r} ${magenta}โโโโโโโโโโโโโโโโโ โโโ โโโโโโโโโโโ โโโโโโ โโโ${r} ${c}โ${r}
|
|
393
|
+
${c}โ${r} ${magenta}โโโโโโโ โโโโโโโ โโโ โโโโโโโโโโ โโโโโโ โโโ${r} ${c}โ${r}
|
|
394
|
+
${c}โ${r} ${c}โ${r}
|
|
395
|
+
${c}โ${r} ${dim}Prove you're a bot. Humans need not apply.${r} ${c}โ${r}
|
|
396
|
+
${c}โ${r} ${c}โ${r}
|
|
397
|
+
${c}โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ${r}
|
|
398
|
+
${c}โ${r} ${c}โ${r}
|
|
399
|
+
${c}โ${r} ${yellow}๐ค Server${r} ${green}http://localhost:${PORT}${r} ${c}โ${r}
|
|
400
|
+
${c}โ${r} ${yellow}๐ API${r} ${dim}/api${r} ${c}โ${r}
|
|
401
|
+
${c}โ${r} ${yellow}โก Challenge${r} ${dim}/api/speed-challenge${r} ${c}โ${r}
|
|
402
|
+
${c}โ${r} ${yellow}๐ Protected${r} ${dim}/agent-only${r} ${c}โ${r}
|
|
403
|
+
${c}โ${r} ${yellow}๐ OpenAPI${r} ${dim}/openapi.json${r} ${c}โ${r}
|
|
404
|
+
${c}โ${r} ${c}โ${r}
|
|
405
|
+
${c}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${r}
|
|
406
|
+
`);
|
|
407
|
+
});
|
|
408
|
+
export default app;
|