@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
@@ -0,0 +1,190 @@
1
+ import { a as AccessLevel, i as TrustLevel, S as SDKOptions, b as VerificationResult } from './types-CS6v75-d.mjs';
2
+
3
+ /**
4
+ * AstraSync Universal Verification Gateway - Access Level Definitions
5
+ *
6
+ * Defines the hierarchy and capabilities of each access level.
7
+ */
8
+
9
+ /**
10
+ * Access level hierarchy (higher number = more access)
11
+ */
12
+ declare const ACCESS_LEVEL_HIERARCHY: Record<AccessLevel, number>;
13
+ /**
14
+ * Access level descriptions for UI
15
+ */
16
+ declare const ACCESS_LEVEL_DESCRIPTIONS: Record<AccessLevel, string>;
17
+ /**
18
+ * Default trust score thresholds for access levels
19
+ */
20
+ declare const DEFAULT_TRUST_THRESHOLDS: Record<AccessLevel, number>;
21
+ /**
22
+ * Trust level score ranges
23
+ */
24
+ declare const TRUST_LEVEL_RANGES: Record<TrustLevel, {
25
+ min: number;
26
+ max: number;
27
+ }>;
28
+ /**
29
+ * Determine trust level from score
30
+ */
31
+ declare function getTrustLevel(score: number): TrustLevel;
32
+ /**
33
+ * Check if access level A is greater than or equal to access level B
34
+ */
35
+ declare function hasMinimumAccess(actual: AccessLevel, required: AccessLevel): boolean;
36
+ /**
37
+ * Get the highest access level for a given trust score
38
+ */
39
+ declare function getAccessLevelForScore(trustScore: number, thresholds?: Record<AccessLevel, number>): AccessLevel;
40
+ /**
41
+ * Determine access level from verification result
42
+ */
43
+ declare function determineAccessLevel(verified: boolean, trustScore: number, isOrgMember: boolean, customThresholds?: Partial<Record<AccessLevel, number>>): AccessLevel;
44
+ /**
45
+ * Access capabilities per level
46
+ */
47
+ interface AccessCapabilities {
48
+ canRead: boolean;
49
+ canWrite: boolean;
50
+ canDelete: boolean;
51
+ canAdmin: boolean;
52
+ canAccessInternal: boolean;
53
+ maxTransactionValue?: number;
54
+ allowedPurposes?: string[];
55
+ }
56
+ /**
57
+ * Get capabilities for an access level
58
+ */
59
+ declare function getCapabilities(accessLevel: AccessLevel): AccessCapabilities;
60
+
61
+ /**
62
+ * AstraSync Universal Verification Gateway - SDK Adapter
63
+ *
64
+ * Direct SDK for verifying agents in any JavaScript/TypeScript environment.
65
+ * Useful for agent-to-agent verification, serverless functions, or custom integrations.
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * import { createClient } from '@astrasyncai/verification-gateway/sdk';
70
+ *
71
+ * const gateway = createClient({
72
+ * apiBaseUrl: 'https://api.astrasync.ai',
73
+ * });
74
+ *
75
+ * // Verify another agent before interacting
76
+ * const result = await gateway.verify({
77
+ * astraId: 'ASTRA-abc123',
78
+ * purpose: 'data-exchange',
79
+ * });
80
+ *
81
+ * if (result.verified && result.accessLevel !== 'none') {
82
+ * // Safe to interact with this agent
83
+ * }
84
+ * ```
85
+ */
86
+
87
+ /**
88
+ * Verification Gateway SDK Client
89
+ */
90
+ declare class VerificationGatewayClient {
91
+ private config;
92
+ private timeout;
93
+ private retryConfig;
94
+ constructor(options: SDKOptions);
95
+ /**
96
+ * Full verification with all details
97
+ */
98
+ verify(options: {
99
+ astraId?: string;
100
+ apiKey?: string;
101
+ jwt?: string;
102
+ purpose?: string;
103
+ action?: string;
104
+ resourceType?: string;
105
+ resource?: string;
106
+ jurisdiction?: string;
107
+ transactionValue?: number;
108
+ currency?: string;
109
+ isSubAgentRequest?: boolean;
110
+ parentAgentId?: string;
111
+ subAgentDepth?: number;
112
+ }): Promise<VerificationResult>;
113
+ /**
114
+ * Quick verification - just check if credentials are valid
115
+ */
116
+ quickVerify(credentials: {
117
+ astraId?: string;
118
+ apiKey?: string;
119
+ jwt?: string;
120
+ }): Promise<{
121
+ verified: boolean;
122
+ accessLevel: AccessLevel;
123
+ reason?: string;
124
+ }>;
125
+ /**
126
+ * Check if an agent has a specific access level
127
+ */
128
+ hasAccess(credentials: {
129
+ astraId?: string;
130
+ apiKey?: string;
131
+ jwt?: string;
132
+ }, requiredLevel: AccessLevel): Promise<boolean>;
133
+ /**
134
+ * Get capabilities for a verified agent
135
+ */
136
+ getCapabilities(credentials: {
137
+ astraId?: string;
138
+ apiKey?: string;
139
+ jwt?: string;
140
+ }): Promise<AccessCapabilities>;
141
+ /**
142
+ * Verify a specific ASTRA-ID
143
+ */
144
+ verifyAstraId(astraId: string, options?: {
145
+ purpose?: string;
146
+ action?: string;
147
+ }): Promise<VerificationResult>;
148
+ /**
149
+ * Verify using an API key
150
+ */
151
+ verifyApiKey(apiKey: string, options?: {
152
+ purpose?: string;
153
+ action?: string;
154
+ }): Promise<VerificationResult>;
155
+ /**
156
+ * Clear the verification cache
157
+ */
158
+ clearCache(): void;
159
+ /**
160
+ * Execute a function with retry logic
161
+ */
162
+ private executeWithRetry;
163
+ }
164
+ /**
165
+ * Create a new SDK client
166
+ */
167
+ declare function createClient(options: SDKOptions): VerificationGatewayClient;
168
+ /**
169
+ * One-shot verification without creating a client
170
+ */
171
+ declare function verifyOnce(options: SDKOptions & {
172
+ astraId?: string;
173
+ apiKey?: string;
174
+ jwt?: string;
175
+ purpose?: string;
176
+ action?: string;
177
+ }): Promise<VerificationResult>;
178
+
179
+ type sdk_VerificationGatewayClient = VerificationGatewayClient;
180
+ declare const sdk_VerificationGatewayClient: typeof VerificationGatewayClient;
181
+ declare const sdk_createClient: typeof createClient;
182
+ declare const sdk_getCapabilities: typeof getCapabilities;
183
+ declare const sdk_getTrustLevel: typeof getTrustLevel;
184
+ declare const sdk_hasMinimumAccess: typeof hasMinimumAccess;
185
+ declare const sdk_verifyOnce: typeof verifyOnce;
186
+ declare namespace sdk {
187
+ export { sdk_VerificationGatewayClient as VerificationGatewayClient, sdk_createClient as createClient, sdk_getCapabilities as getCapabilities, sdk_getTrustLevel as getTrustLevel, sdk_hasMinimumAccess as hasMinimumAccess, sdk_verifyOnce as verifyOnce };
188
+ }
189
+
190
+ export { ACCESS_LEVEL_DESCRIPTIONS as A, DEFAULT_TRUST_THRESHOLDS as D, TRUST_LEVEL_RANGES as T, VerificationGatewayClient as V, ACCESS_LEVEL_HIERARCHY as a, type AccessCapabilities as b, getCapabilities as c, determineAccessLevel as d, getTrustLevel as e, createClient as f, getAccessLevelForScore as g, hasMinimumAccess as h, sdk as s, verifyOnce as v };
@@ -0,0 +1,359 @@
1
+ /**
2
+ * AstraSync Universal Verification Gateway Types
3
+ *
4
+ * TypeScript type definitions for agent verification across all counterparty types.
5
+ */
6
+ /**
7
+ * Trust levels assigned to agents based on their composite trust score
8
+ */
9
+ type TrustLevel = 'BRONZE' | 'SILVER' | 'GOLD' | 'PLATINUM';
10
+ /**
11
+ * Access levels granted based on verification result
12
+ * - none: No credentials provided, show guidance
13
+ * - guidance: Commerce Shield overlay with registration info
14
+ * - read-only: Can browse, no mutations
15
+ * - standard: Normal access per PDLSS
16
+ * - full: Full access for high-trust agents
17
+ * - internal: Internal org access (same organization)
18
+ */
19
+ type AccessLevel = 'none' | 'guidance' | 'read-only' | 'standard' | 'full' | 'internal';
20
+ /**
21
+ * Types of counterparties that can integrate the gateway
22
+ */
23
+ type CounterpartyType = 'agent' | 'api' | 'mcp_server' | 'website' | 'other';
24
+ /**
25
+ * Agent credentials extracted from request
26
+ */
27
+ interface AgentCredentials {
28
+ /** ASTRA-xxx identifier */
29
+ astraId?: string;
30
+ /** API key for authentication */
31
+ apiKey?: string;
32
+ /** JWT token */
33
+ jwt?: string;
34
+ /** Raw authorization header */
35
+ authorizationHeader?: string;
36
+ }
37
+ /**
38
+ * Configuration options for the verification gateway
39
+ */
40
+ interface GatewayConfig {
41
+ /** AstraSync API base URL */
42
+ apiBaseUrl: string;
43
+ /** API key for authenticating with AstraSync (optional for public endpoints) */
44
+ apiKey?: string;
45
+ /** Default access level for unverified requests */
46
+ defaultAccessLevel?: AccessLevel;
47
+ /** Minimum trust score required for standard access */
48
+ minTrustScore?: number;
49
+ /** Minimum trust score required for full access */
50
+ minTrustScoreForFull?: number;
51
+ /** Cache verification results (TTL in seconds) */
52
+ cacheTtl?: number;
53
+ /** Enable debug logging */
54
+ debug?: boolean;
55
+ /** Custom headers to send with verification requests */
56
+ customHeaders?: Record<string, string>;
57
+ }
58
+ /**
59
+ * Verified agent information
60
+ */
61
+ interface VerifiedAgent {
62
+ /** ASTRA-xxx identifier */
63
+ astraId: string;
64
+ /** Agent display name */
65
+ name: string;
66
+ /** Composite trust score (0-100) */
67
+ trustScore: number;
68
+ /** Trust level tier */
69
+ trustLevel: TrustLevel;
70
+ /** Whether agent is blockchain-verified */
71
+ blockchainVerified: boolean;
72
+ /** Agent status */
73
+ status: 'active' | 'inactive' | 'suspended' | 'migrating' | 'terminated' | 'retired';
74
+ }
75
+ /**
76
+ * Verified developer (KYD) information
77
+ */
78
+ interface VerifiedDeveloper {
79
+ /** ASTRAD-xxx identifier */
80
+ astradId: string;
81
+ /** Developer name */
82
+ name?: string;
83
+ /** Developer trust score */
84
+ trustScore: number;
85
+ /** Whether developer identity is verified */
86
+ verified: boolean;
87
+ }
88
+ /**
89
+ * Verified organization (KYO) information
90
+ */
91
+ interface VerifiedOrganization {
92
+ /** Organization name */
93
+ name: string;
94
+ /** Whether organization is verified */
95
+ verified: boolean;
96
+ /** Organization trust score */
97
+ trustScore: number;
98
+ }
99
+ /**
100
+ * PDLSS policy information returned with verification
101
+ */
102
+ interface PDLSSInfo {
103
+ /** Whether purpose was allowed */
104
+ purposeAllowed: boolean;
105
+ /** Whether within duration constraints */
106
+ withinDuration: boolean;
107
+ /** Whether within limits */
108
+ withinLimits: boolean;
109
+ /** Whether scope is allowed */
110
+ scopeAllowed: boolean;
111
+ /** Whether self-instantiation is allowed (if applicable) */
112
+ selfInstantiationAllowed: boolean;
113
+ /** Allowed purpose categories */
114
+ allowedPurposes?: string[];
115
+ /** Transaction limits */
116
+ limits?: Record<string, number>;
117
+ /** Allowed scope/resources */
118
+ scope?: string[];
119
+ /** Applied policy details */
120
+ appliedPolicy?: {
121
+ boundaryId: string;
122
+ boundaryName: string;
123
+ policyId: string;
124
+ policyVersion: string;
125
+ };
126
+ }
127
+ /**
128
+ * Guidance information for unverified agents
129
+ */
130
+ interface GuidanceInfo {
131
+ /** Human-readable guidance message */
132
+ message: string;
133
+ /** URL to register for AstraSync */
134
+ registrationUrl: string;
135
+ /** URL to documentation */
136
+ documentationUrl: string;
137
+ /** Steps to get verified */
138
+ steps?: string[];
139
+ }
140
+ /**
141
+ * Complete verification result
142
+ */
143
+ interface VerificationResult {
144
+ /** Whether the agent is verified */
145
+ verified: boolean;
146
+ /** Access level granted */
147
+ accessLevel: AccessLevel;
148
+ /** Verified agent info (if verified) */
149
+ agent?: VerifiedAgent;
150
+ /** Developer info (if available) */
151
+ developer?: VerifiedDeveloper;
152
+ /** Organization info (if available) */
153
+ organization?: VerifiedOrganization;
154
+ /** PDLSS policy info (if verified) */
155
+ pdlss?: PDLSSInfo;
156
+ /** Guidance for unverified agents */
157
+ guidance?: GuidanceInfo;
158
+ /** Reasons for denial (if not allowed) */
159
+ denialReasons?: string[];
160
+ /** Whether step-up authentication is required */
161
+ requiresStepUp?: boolean;
162
+ /** Whether approval is required */
163
+ requiresApproval?: boolean;
164
+ /** Timestamp of verification */
165
+ verifiedAt: Date;
166
+ /** TTL for this result (seconds) */
167
+ cacheTtl?: number;
168
+ }
169
+ /**
170
+ * Request context for verification
171
+ */
172
+ interface VerificationRequest {
173
+ /** Agent credentials */
174
+ credentials: AgentCredentials;
175
+ /** Purpose of the access request */
176
+ purpose?: string;
177
+ /** Specific action being performed */
178
+ action?: string;
179
+ /** Type of resource being accessed */
180
+ resourceType?: string;
181
+ /** Specific resource identifier */
182
+ resource?: string;
183
+ /** Jurisdiction for the request */
184
+ jurisdiction?: string;
185
+ /** Transaction value (if applicable) */
186
+ transactionValue?: number;
187
+ /** Currency for transaction value */
188
+ currency?: string;
189
+ /** Whether this is a sub-agent request */
190
+ isSubAgentRequest?: boolean;
191
+ /** Parent agent ID for sub-agent requests */
192
+ parentAgentId?: string;
193
+ /** Depth of sub-agent chain */
194
+ subAgentDepth?: number;
195
+ /** Client IP address */
196
+ clientIp?: string;
197
+ /** User agent string */
198
+ userAgent?: string;
199
+ /** Enable runtime challenge for this request */
200
+ enableRuntimeChallenge?: boolean;
201
+ /** Create a verification session (returns sessionId) */
202
+ createSession?: boolean;
203
+ /** Counterparty type */
204
+ counterpartyType?: CounterpartyType;
205
+ /** Runtime challenge options */
206
+ runtimeChallengeOptions?: {
207
+ timeoutOverride?: number;
208
+ };
209
+ }
210
+ /**
211
+ * Route-specific access configuration
212
+ */
213
+ interface RouteAccessConfig {
214
+ /** Route pattern (supports wildcards) */
215
+ pattern: string;
216
+ /** HTTP method (or * for all) */
217
+ method: string | '*';
218
+ /** Minimum access level required */
219
+ minAccessLevel: AccessLevel;
220
+ /** Minimum trust score required (optional) */
221
+ minTrustScore?: number;
222
+ /** Required purposes (optional) */
223
+ requiredPurposes?: string[];
224
+ }
225
+ /**
226
+ * Express middleware options
227
+ */
228
+ interface ExpressMiddlewareOptions extends GatewayConfig {
229
+ /** Route access configurations */
230
+ routes?: RouteAccessConfig[];
231
+ /** Function to extract credentials from request */
232
+ extractCredentials?: (req: unknown) => AgentCredentials;
233
+ /** Function to extract purpose from request */
234
+ extractPurpose?: (req: unknown) => string | undefined;
235
+ /** Skip verification for certain paths */
236
+ skipPaths?: string[];
237
+ /** Custom response for denied requests */
238
+ onDenied?: (result: VerificationResult, req: unknown, res: unknown) => void;
239
+ }
240
+ /**
241
+ * Next.js middleware options
242
+ */
243
+ interface NextJsMiddlewareOptions extends GatewayConfig {
244
+ /** Route access configurations */
245
+ routes?: RouteAccessConfig[];
246
+ /** Paths to skip verification */
247
+ skipPaths?: string[];
248
+ /** Whether to show Commerce Shield overlay for unverified */
249
+ showCommerceShield?: boolean;
250
+ /** Commerce Shield configuration */
251
+ commerceShield?: {
252
+ title?: string;
253
+ message?: string;
254
+ allowGuestAccess?: boolean;
255
+ guestAccessLevel?: AccessLevel;
256
+ };
257
+ }
258
+ /**
259
+ * SDK function options
260
+ */
261
+ interface SDKOptions extends GatewayConfig {
262
+ /** Timeout for verification requests (ms) */
263
+ timeout?: number;
264
+ /** Retry configuration */
265
+ retry?: {
266
+ maxRetries: number;
267
+ backoffMs: number;
268
+ };
269
+ }
270
+ /**
271
+ * Token guidance returned from verify-access
272
+ */
273
+ interface TokenGuidance {
274
+ recommendedScopes: string[];
275
+ recommendedTtlSeconds: number;
276
+ recommendedRateLimit?: {
277
+ requestsPerMinute: number;
278
+ maxTransactionValue?: number;
279
+ currency?: string;
280
+ };
281
+ jurisdictionConstraints?: string[];
282
+ delegationAllowed: boolean;
283
+ maxDelegationDepth?: number;
284
+ safetyDefaults: {
285
+ writePrivilegesRequested: boolean;
286
+ shortLivedTokenRecommended: boolean;
287
+ scopeConvention: 'astrasync-canonical';
288
+ };
289
+ }
290
+ /**
291
+ * Runtime challenge result
292
+ */
293
+ interface RuntimeChallengeResult {
294
+ status: 'passed' | 'failed' | 'skipped' | 'timeout' | 'not_supported';
295
+ challengeId?: string;
296
+ challengeSentAt?: string;
297
+ responseReceivedAt?: string;
298
+ latencyMs?: number;
299
+ reason?: string;
300
+ }
301
+ /**
302
+ * Enhanced verification result (extends existing VerificationResult)
303
+ */
304
+ interface EnhancedVerificationResult extends VerificationResult {
305
+ sessionId?: string;
306
+ runtimeChallenge?: RuntimeChallengeResult;
307
+ tokenGuidance?: TokenGuidance;
308
+ recommendation?: 'grant' | 'deny' | 'step_up_required';
309
+ recommendationReasons?: string[];
310
+ }
311
+ /**
312
+ * Cross-protocol credential config
313
+ */
314
+ interface AstraSyncCredentials {
315
+ agentId: string;
316
+ verifyUrl?: string;
317
+ challengeUrl?: string;
318
+ pdlss?: {
319
+ purpose?: {
320
+ category: string;
321
+ action?: string;
322
+ };
323
+ duration?: {
324
+ maxSessionDuration?: number;
325
+ };
326
+ scope?: {
327
+ jurisdiction?: string;
328
+ };
329
+ };
330
+ }
331
+ /**
332
+ * Protocol transport type
333
+ */
334
+ type ProtocolTransport = 'http' | 'a2a' | 'mcp';
335
+ /**
336
+ * Commerce Shield UI props
337
+ */
338
+ interface CommerceShieldProps {
339
+ /** Whether the shield is visible */
340
+ visible: boolean;
341
+ /** Verification result (if any) */
342
+ result?: VerificationResult;
343
+ /** Callback when user chooses to register */
344
+ onRegister?: () => void;
345
+ /** Callback when user chooses guest access */
346
+ onGuestAccess?: () => void;
347
+ /** Callback when user dismisses */
348
+ onDismiss?: () => void;
349
+ /** Custom title */
350
+ title?: string;
351
+ /** Custom message */
352
+ message?: string;
353
+ /** Whether guest access is allowed */
354
+ allowGuestAccess?: boolean;
355
+ /** Custom styles */
356
+ className?: string;
357
+ }
358
+
359
+ export type { AgentCredentials as A, CommerceShieldProps as C, EnhancedVerificationResult as E, GatewayConfig as G, NextJsMiddlewareOptions as N, ProtocolTransport as P, RouteAccessConfig as R, SDKOptions as S, TokenGuidance as T, VerificationRequest as V, AccessLevel as a, VerificationResult as b, AstraSyncCredentials as c, CounterpartyType as d, ExpressMiddlewareOptions as e, GuidanceInfo as f, PDLSSInfo as g, RuntimeChallengeResult as h, TrustLevel as i, VerifiedAgent as j, VerifiedDeveloper as k, VerifiedOrganization as l };