@astrasyncai/verification-gateway 1.0.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.
Files changed (40) hide show
  1. package/README.md +213 -0
  2. package/dist/adapters/express.d.mts +3 -0
  3. package/dist/adapters/express.d.ts +3 -0
  4. package/dist/adapters/express.js +516 -0
  5. package/dist/adapters/express.js.map +1 -0
  6. package/dist/adapters/express.mjs +486 -0
  7. package/dist/adapters/express.mjs.map +1 -0
  8. package/dist/adapters/nextjs.d.mts +3 -0
  9. package/dist/adapters/nextjs.d.ts +3 -0
  10. package/dist/adapters/nextjs.js +624 -0
  11. package/dist/adapters/nextjs.js.map +1 -0
  12. package/dist/adapters/nextjs.mjs +586 -0
  13. package/dist/adapters/nextjs.mjs.map +1 -0
  14. package/dist/adapters/sdk.d.mts +2 -0
  15. package/dist/adapters/sdk.d.ts +2 -0
  16. package/dist/adapters/sdk.js +505 -0
  17. package/dist/adapters/sdk.js.map +1 -0
  18. package/dist/adapters/sdk.mjs +473 -0
  19. package/dist/adapters/sdk.mjs.map +1 -0
  20. package/dist/express-BhD3mWsL.d.ts +64 -0
  21. package/dist/express-DUDYpvNZ.d.mts +64 -0
  22. package/dist/index.d.mts +353 -0
  23. package/dist/index.d.ts +353 -0
  24. package/dist/index.js +1499 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/index.mjs +1446 -0
  27. package/dist/index.mjs.map +1 -0
  28. package/dist/nextjs-BtqyLSVQ.d.mts +22 -0
  29. package/dist/nextjs-C9FPOjSh.d.ts +22 -0
  30. package/dist/sdk-BkVigGjF.d.ts +190 -0
  31. package/dist/sdk-xCbZgeZx.d.mts +190 -0
  32. package/dist/types-CS6v75-d.d.mts +359 -0
  33. package/dist/types-CS6v75-d.d.ts +359 -0
  34. package/dist/ui/index.d.mts +140 -0
  35. package/dist/ui/index.d.ts +140 -0
  36. package/dist/ui/index.js +826 -0
  37. package/dist/ui/index.js.map +1 -0
  38. package/dist/ui/index.mjs +782 -0
  39. package/dist/ui/index.mjs.map +1 -0
  40. package/package.json +89 -0
package/README.md ADDED
@@ -0,0 +1,213 @@
1
+ # @astrasyncai/verification-gateway
2
+
3
+ Universal Verification Gateway for AstraSync KYA Platform - verify AI agents across any counterparty type.
4
+
5
+ ## Overview
6
+
7
+ The Verification Gateway provides a single, universal solution for verifying AI agents. One codebase, multiple deployment targets:
8
+
9
+ - **Express.js middleware** - Protect API endpoints
10
+ - **Next.js middleware** - Protect web applications with Commerce Shield
11
+ - **SDK functions** - Direct verification for agent-to-agent or serverless
12
+
13
+ All verification flows through the same `POST /agents/verify-access` endpoint, ensuring consistent PDLSS (Permission, Duration, Limit, Scope, Self-instantiation) enforcement.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @astrasyncai/verification-gateway
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ### Express Middleware
24
+
25
+ ```typescript
26
+ import express from 'express';
27
+ import { createMiddleware } from '@astrasyncai/verification-gateway/express';
28
+
29
+ const app = express();
30
+
31
+ app.use(createMiddleware({
32
+ apiBaseUrl: 'https://api.astrasync.ai',
33
+ routes: [
34
+ { pattern: '/api/public/*', method: '*', minAccessLevel: 'none' },
35
+ { pattern: '/api/data/*', method: 'GET', minAccessLevel: 'read-only' },
36
+ { pattern: '/api/data/*', method: '*', minAccessLevel: 'standard' },
37
+ { pattern: '/api/admin/*', method: '*', minAccessLevel: 'internal' },
38
+ ],
39
+ }));
40
+ ```
41
+
42
+ ### Next.js Middleware
43
+
44
+ ```typescript
45
+ // middleware.ts
46
+ import { createMiddleware } from '@astrasyncai/verification-gateway/nextjs';
47
+
48
+ export const middleware = createMiddleware({
49
+ apiBaseUrl: 'https://api.astrasync.ai',
50
+ showCommerceShield: true,
51
+ routes: [
52
+ { pattern: '/api/*', method: '*', minAccessLevel: 'standard' },
53
+ { pattern: '/dashboard/*', method: '*', minAccessLevel: 'read-only' },
54
+ ],
55
+ });
56
+
57
+ export const config = {
58
+ matcher: ['/api/:path*', '/dashboard/:path*'],
59
+ };
60
+ ```
61
+
62
+ ### SDK (Direct Usage)
63
+
64
+ ```typescript
65
+ import { createClient } from '@astrasyncai/verification-gateway/sdk';
66
+
67
+ const gateway = createClient({
68
+ apiBaseUrl: 'https://api.astrasync.ai',
69
+ });
70
+
71
+ // Verify another agent before interacting
72
+ const result = await gateway.verify({
73
+ astraId: 'ASTRA-abc123',
74
+ purpose: 'data-exchange',
75
+ });
76
+
77
+ if (result.verified && result.accessLevel !== 'none') {
78
+ // Safe to interact with this agent
79
+ console.log(`Trust score: ${result.agent?.trustScore}`);
80
+ }
81
+ ```
82
+
83
+ ## Access Levels
84
+
85
+ | Level | Description |
86
+ |-------|-------------|
87
+ | `none` | No credentials provided |
88
+ | `guidance` | Commerce Shield overlay shown |
89
+ | `read-only` | Can browse, no mutations |
90
+ | `standard` | Normal access per PDLSS |
91
+ | `full` | Full access for high-trust agents |
92
+ | `internal` | Organization member access |
93
+
94
+ ## Trust Levels
95
+
96
+ | Level | Score Range |
97
+ |-------|-------------|
98
+ | BRONZE | 0-39 |
99
+ | SILVER | 40-59 |
100
+ | GOLD | 60-79 |
101
+ | PLATINUM | 80-100 |
102
+
103
+ ## UI Components
104
+
105
+ The package includes React components for displaying verification status:
106
+
107
+ ```tsx
108
+ import { CommerceShield, TrustLevelBadge, GuidanceCard } from '@astrasyncai/verification-gateway/ui';
109
+
110
+ // Commerce Shield overlay
111
+ <CommerceShield
112
+ visible={!verified}
113
+ result={verificationResult}
114
+ onRegister={() => window.location.href = '/register'}
115
+ allowGuestAccess={true}
116
+ />
117
+
118
+ // Trust level badge
119
+ <TrustLevelBadge level="GOLD" score={75} />
120
+
121
+ // Guidance card
122
+ <GuidanceCard guidance={verificationResult.guidance} />
123
+ ```
124
+
125
+ ## Credential Extraction
126
+
127
+ Agents can provide credentials via:
128
+
129
+ 1. **Headers** (recommended):
130
+ - `X-Astra-Id`: Agent ASTRA-ID
131
+ - `X-Api-Key`: API key
132
+ - `Authorization: Bearer <jwt>`: JWT token
133
+
134
+ 2. **Query Parameters** (fallback):
135
+ - `?astraId=ASTRA-xxx`
136
+ - `?apiKey=xxx`
137
+
138
+ ## Verification Response
139
+
140
+ ```typescript
141
+ interface VerificationResult {
142
+ verified: boolean;
143
+ accessLevel: 'none' | 'guidance' | 'read-only' | 'standard' | 'full' | 'internal';
144
+
145
+ agent?: {
146
+ astraId: string;
147
+ name: string;
148
+ trustScore: number;
149
+ trustLevel: 'BRONZE' | 'SILVER' | 'GOLD' | 'PLATINUM';
150
+ blockchainVerified: boolean;
151
+ };
152
+
153
+ developer?: {
154
+ astradId: string;
155
+ verified: boolean;
156
+ };
157
+
158
+ organization?: {
159
+ name: string;
160
+ verified: boolean;
161
+ trustScore: number;
162
+ };
163
+
164
+ pdlss?: {
165
+ purposeAllowed: boolean;
166
+ withinDuration: boolean;
167
+ withinLimits: boolean;
168
+ scopeAllowed: boolean;
169
+ selfInstantiationAllowed: boolean;
170
+ };
171
+
172
+ guidance?: {
173
+ message: string;
174
+ registrationUrl: string;
175
+ documentationUrl: string;
176
+ steps?: string[];
177
+ };
178
+
179
+ denialReasons?: string[];
180
+ }
181
+ ```
182
+
183
+ ## Configuration
184
+
185
+ ```typescript
186
+ interface GatewayConfig {
187
+ // Required
188
+ apiBaseUrl: string;
189
+
190
+ // Optional
191
+ apiKey?: string; // For authenticated requests
192
+ defaultAccessLevel?: string; // Default: 'guidance'
193
+ minTrustScore?: number; // For 'standard' access (default: 40)
194
+ minTrustScoreForFull?: number; // For 'full' access (default: 70)
195
+ cacheTtl?: number; // Cache duration in seconds (default: 300)
196
+ debug?: boolean; // Enable debug logging
197
+ }
198
+ ```
199
+
200
+ ## Commerce Shield
201
+
202
+ When an unverified agent visits a protected page, the Commerce Shield overlay displays:
203
+
204
+ - Registration guidance
205
+ - Steps to get verified
206
+ - Link to documentation
207
+ - Optional guest access
208
+
209
+ This creates a smooth experience for agents while maintaining security.
210
+
211
+ ## License
212
+
213
+ MIT
@@ -0,0 +1,3 @@
1
+ import 'express';
2
+ import '../types-CS6v75-d.mjs';
3
+ export { c as createMiddleware, a as extractAstraSyncCredentials, r as requireAccess, v as verifyOnly } from '../express-DUDYpvNZ.mjs';
@@ -0,0 +1,3 @@
1
+ import 'express';
2
+ import '../types-CS6v75-d.js';
3
+ export { c as createMiddleware, a as extractAstraSyncCredentials, r as requireAccess, v as verifyOnly } from '../express-BhD3mWsL.js';