@astrasyncai/verification-gateway 3.7.1 → 3.9.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 (109) hide show
  1. package/README.md +99 -11
  2. package/dist/adapter-interface/interface.d.mts +2 -2
  3. package/dist/adapter-interface/interface.d.ts +2 -2
  4. package/dist/adapters/express.d.mts +2 -2
  5. package/dist/adapters/express.d.ts +2 -2
  6. package/dist/adapters/express.js +2 -1
  7. package/dist/adapters/express.js.map +1 -1
  8. package/dist/adapters/express.mjs +2 -1
  9. package/dist/adapters/express.mjs.map +1 -1
  10. package/dist/adapters/http-pdlss.d.mts +81 -0
  11. package/dist/adapters/http-pdlss.d.ts +81 -0
  12. package/dist/adapters/http-pdlss.js +117 -0
  13. package/dist/adapters/http-pdlss.js.map +1 -0
  14. package/dist/adapters/http-pdlss.mjs +87 -0
  15. package/dist/adapters/http-pdlss.mjs.map +1 -0
  16. package/dist/adapters/mcp.d.mts +1 -1
  17. package/dist/adapters/mcp.d.ts +1 -1
  18. package/dist/adapters/mcp.js +2 -1
  19. package/dist/adapters/mcp.js.map +1 -1
  20. package/dist/adapters/mcp.mjs +2 -1
  21. package/dist/adapters/mcp.mjs.map +1 -1
  22. package/dist/adapters/nextjs.d.mts +2 -2
  23. package/dist/adapters/nextjs.d.ts +2 -2
  24. package/dist/adapters/nextjs.js +2 -1
  25. package/dist/adapters/nextjs.js.map +1 -1
  26. package/dist/adapters/nextjs.mjs +2 -1
  27. package/dist/adapters/nextjs.mjs.map +1 -1
  28. package/dist/adapters/sdk.d.mts +2 -2
  29. package/dist/adapters/sdk.d.ts +2 -2
  30. package/dist/adapters/sdk.js +2 -1
  31. package/dist/adapters/sdk.js.map +1 -1
  32. package/dist/adapters/sdk.mjs +2 -1
  33. package/dist/adapters/sdk.mjs.map +1 -1
  34. package/dist/agent/index.d.mts +2 -2
  35. package/dist/agent/index.d.ts +2 -2
  36. package/dist/bin/astrasync-claude-hook.js +14 -1
  37. package/dist/bin/astrasync-guard.js +14 -1
  38. package/dist/bin/astrasync.js +31 -1
  39. package/dist/browser/background.js +14 -1
  40. package/dist/browser/background.js.map +1 -1
  41. package/dist/browser/background.mjs +14 -1
  42. package/dist/browser/background.mjs.map +1 -1
  43. package/dist/browser/browser-adapter.d.mts +2 -2
  44. package/dist/browser/browser-adapter.d.ts +2 -2
  45. package/dist/claude-code/claude-code-adapter.d.mts +2 -2
  46. package/dist/claude-code/claude-code-adapter.d.ts +2 -2
  47. package/dist/cli/index.d.mts +2 -2
  48. package/dist/cli/index.d.ts +2 -2
  49. package/dist/cursor/cursor-adapter.d.mts +2 -2
  50. package/dist/cursor/cursor-adapter.d.ts +2 -2
  51. package/dist/cursor/extension.d.mts +2 -2
  52. package/dist/cursor/extension.d.ts +2 -2
  53. package/dist/cursor/extension.js +14 -1
  54. package/dist/cursor/extension.js.map +1 -1
  55. package/dist/cursor/extension.mjs +14 -1
  56. package/dist/cursor/extension.mjs.map +1 -1
  57. package/dist/edge-config.d.mts +130 -0
  58. package/dist/edge-config.d.ts +130 -0
  59. package/dist/edge-config.js +162 -0
  60. package/dist/edge-config.js.map +1 -0
  61. package/dist/edge-config.mjs +131 -0
  62. package/dist/edge-config.mjs.map +1 -0
  63. package/dist/{express-BnMO-H3y.d.mts → express-DXUyvv7t.d.mts} +1 -1
  64. package/dist/{express-DQhDzNAt.d.ts → express-sGXhDdd0.d.ts} +1 -1
  65. package/dist/gateway/gateway.d.mts +2 -2
  66. package/dist/gateway/gateway.d.ts +2 -2
  67. package/dist/gateway/gateway.js +14 -1
  68. package/dist/gateway/gateway.js.map +1 -1
  69. package/dist/gateway/gateway.mjs +14 -1
  70. package/dist/gateway/gateway.mjs.map +1 -1
  71. package/dist/git-trigger/git-hooks.d.mts +2 -2
  72. package/dist/git-trigger/git-hooks.d.ts +2 -2
  73. package/dist/{index-D8-dvUFA.d.ts → index-C61VL_OW.d.ts} +1 -1
  74. package/dist/{index-rftma0ln.d.ts → index-CMg-vjEK.d.ts} +1 -1
  75. package/dist/{index-WHKq2v17.d.mts → index-Dalih3EB.d.mts} +1 -1
  76. package/dist/{index-BT_aRn-I.d.mts → index-DmmdehNu.d.mts} +1 -1
  77. package/dist/index.d.mts +26 -82
  78. package/dist/index.d.ts +26 -82
  79. package/dist/index.js +226 -10
  80. package/dist/index.js.map +1 -1
  81. package/dist/index.mjs +215 -10
  82. package/dist/index.mjs.map +1 -1
  83. package/dist/local-evaluator/evaluator.d.mts +2 -2
  84. package/dist/local-evaluator/evaluator.d.ts +2 -2
  85. package/dist/{nextjs-DPj7ZNlq.d.ts → nextjs-DwUW-Nm1.d.ts} +1 -1
  86. package/dist/{nextjs-DFKYhxe6.d.mts → nextjs-F_2pbPIA.d.mts} +1 -1
  87. package/dist/platform-signatures.d.mts +47 -0
  88. package/dist/platform-signatures.d.ts +47 -0
  89. package/dist/platform-signatures.js +89 -0
  90. package/dist/platform-signatures.js.map +1 -0
  91. package/dist/platform-signatures.mjs +63 -0
  92. package/dist/platform-signatures.mjs.map +1 -0
  93. package/dist/{sdk-CAcHgB5x.d.ts → sdk-CfHANs4A.d.ts} +1 -1
  94. package/dist/{sdk-Cy3wAmDt.d.mts → sdk-Clob2-0A.d.mts} +1 -1
  95. package/dist/transport/index.d.mts +2 -2
  96. package/dist/transport/index.d.ts +2 -2
  97. package/dist/{types-CKe8O0lR.d.mts → types-ACMsV07B.d.mts} +112 -9
  98. package/dist/{types-CKe8O0lR.d.ts → types-ACMsV07B.d.ts} +112 -9
  99. package/dist/{types-B-ubjHER.d.mts → types-BtqUvK8v.d.mts} +1 -1
  100. package/dist/{types-Bgn5gxHQ.d.ts → types-DmSDgPpG.d.ts} +1 -1
  101. package/dist/ui/index.d.mts +1 -1
  102. package/dist/ui/index.d.ts +1 -1
  103. package/dist/verify.d.mts +144 -0
  104. package/dist/verify.d.ts +144 -0
  105. package/dist/verify.js +593 -0
  106. package/dist/verify.js.map +1 -0
  107. package/dist/verify.mjs +557 -0
  108. package/dist/verify.mjs.map +1 -0
  109. package/package.json +21 -1
@@ -1,4 +1,4 @@
1
- import { a as AccessLevel, d as CounterpartyType, T as TokenGuidance } from './types-CKe8O0lR.mjs';
1
+ import { a as AccessLevel, e as CounterpartyType, T as TokenGuidance } from './types-ACMsV07B.mjs';
2
2
 
3
3
  /**
4
4
  * AstraSync Gateway - Types for gateway modes, local evaluation, and adapter interface.
@@ -1,4 +1,4 @@
1
- import { a as AccessLevel, d as CounterpartyType, T as TokenGuidance } from './types-CKe8O0lR.js';
1
+ import { a as AccessLevel, e as CounterpartyType, T as TokenGuidance } from './types-ACMsV07B.js';
2
2
 
3
3
  /**
4
4
  * AstraSync Gateway - Types for gateway modes, local evaluation, and adapter interface.
@@ -1,4 +1,4 @@
1
- import { C as CommerceShieldProps, n as VerificationResult, b as AgentCredentials, f as GuidanceInfo, m as TrustLevel } from '../types-CKe8O0lR.mjs';
1
+ import { d as CommerceShieldProps, r as VerificationResult, b as AgentCredentials, g as GuidanceInfo, q as TrustLevel } from '../types-ACMsV07B.mjs';
2
2
 
3
3
  /**
4
4
  * AstraSync Commerce Shield Component
@@ -1,4 +1,4 @@
1
- import { C as CommerceShieldProps, n as VerificationResult, b as AgentCredentials, f as GuidanceInfo, m as TrustLevel } from '../types-CKe8O0lR.js';
1
+ import { d as CommerceShieldProps, r as VerificationResult, b as AgentCredentials, g as GuidanceInfo, q as TrustLevel } from '../types-ACMsV07B.js';
2
2
 
3
3
  /**
4
4
  * AstraSync Commerce Shield Component
@@ -0,0 +1,144 @@
1
+ import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, V as VerificationRequest, r as VerificationResult } from './types-ACMsV07B.mjs';
2
+
3
+ /**
4
+ * AstraSync Universal Verification Gateway - Core Verification Logic
5
+ *
6
+ * This module handles the core verification logic, calling the AstraSync API
7
+ * and processing the response into a standardized VerificationResult.
8
+ */
9
+
10
+ /**
11
+ * Clear the verification cache
12
+ */
13
+ declare function clearCache(): void;
14
+ /**
15
+ * Extract agent credentials from various sources
16
+ */
17
+ declare function extractCredentials(headers: Record<string, string | string[] | undefined>, query?: Record<string, string | undefined>): AgentCredentials;
18
+ /**
19
+ * Check if credentials are present
20
+ */
21
+ declare function hasCredentials(credentials: AgentCredentials): boolean;
22
+ /**
23
+ * Options for a single verify() call (as opposed to GatewayConfig, which is
24
+ * per-gateway). Mirrors the Java SDK's `verify(request, bypassCache)`.
25
+ */
26
+ interface VerifyOptions {
27
+ /**
28
+ * Skip the cache READ for this call so the request is guaranteed to reach
29
+ * the backend (the result is still written to the cache if cacheable).
30
+ * Used by the step-up hold-and-poll retry: the re-verify after an approval
31
+ * must hit the server to redeem the single-use approval.
32
+ */
33
+ bypassCache?: boolean;
34
+ }
35
+ /**
36
+ * Main verification function
37
+ */
38
+ declare function verify(config: GatewayConfig, request: VerificationRequest, options?: VerifyOptions): Promise<VerificationResult>;
39
+ /**
40
+ * Record a counterparty's grant/deny decision for a verification session.
41
+ * Fire-and-forget — errors are silently swallowed.
42
+ */
43
+ declare function recordDecision(config: GatewayConfig, sessionId: string, decision: 'granted' | 'denied', reason?: string): Promise<void>;
44
+ /**
45
+ * Fetch the per-route policy for an endpoint from the AstraSync backend.
46
+ * v2.9.7 moved policy authority into the dashboard — the SDK no longer
47
+ * accepts `routes` from merchant-side source code, it fetches them from
48
+ * here on init (and refreshes periodically).
49
+ *
50
+ * Returns `null` when the request fails for any reason — the caller decides
51
+ * how to fall back (the middleware allows-all when no policy is loaded so
52
+ * a misconfigured init doesn't take down the merchant's API).
53
+ */
54
+ declare function fetchRoutes(config: GatewayConfig, counterpartyId: string): Promise<RouteAccessConfigShape[] | null>;
55
+ /**
56
+ * Minimal shape of an EndpointRoute as the SDK consumes it. Mirrors the
57
+ * server's `EndpointRoute` type and the SDK's `RouteAccessConfig` — same
58
+ * JSON moves between server and SDK unchanged.
59
+ */
60
+ interface RouteAccessConfigShape {
61
+ pattern: string;
62
+ method: string;
63
+ /** @deprecated 3.2.0 — band no longer gates; optional, ignored. Use minTrustScore. */
64
+ minAccessLevel?: 'none' | 'restricted' | 'read-only' | 'standard' | 'full' | 'internal';
65
+ minTrustScore?: number;
66
+ requiredPurposes?: string[];
67
+ allowedPurposes?: string[];
68
+ allowedJurisdictions?: string[];
69
+ maxDuration?: number;
70
+ maxTransactionValue?: number;
71
+ requirePurpose?: boolean;
72
+ /** Send-mapping (Bug 14, §4.6) — see RouteAccessConfig in types.ts. */
73
+ purpose?: string;
74
+ action?: string;
75
+ }
76
+ /**
77
+ * Verify an agent AND automatically record the grant/deny decision.
78
+ *
79
+ * This is the recommended entry point for counterparties that call verify()
80
+ * directly (e.g. MCP servers) rather than using createMiddleware().
81
+ * It adds createSession: true, then fire-and-forgets the decision.
82
+ */
83
+ declare function verifyAndRecord(config: GatewayConfig, request: VerificationRequest, options?: VerifyOptions): Promise<VerificationResult>;
84
+ /**
85
+ * Report an unregistered agent attempt (no AstraSync credentials).
86
+ * Called by SDK adapters when an agent is redirected to /docs/agent-access.
87
+ * Fire-and-forget — errors are silently swallowed.
88
+ */
89
+ declare function reportUnregisteredAttempt(config: GatewayConfig, data: {
90
+ /**
91
+ * 3.6.0: optional — the backend attributes by counterpartyId first (sent
92
+ * from config below) and requires at least ONE of counterpartyId/URL.
93
+ * A null/undefined URL is omitted from the body, not sent as null.
94
+ */
95
+ counterpartyUrl?: string;
96
+ counterpartyType?: string;
97
+ sourceIp?: string;
98
+ userAgent?: string;
99
+ requestPath?: string;
100
+ requestMethod?: string;
101
+ /**
102
+ * 3.9.0 (§33.5 #1) — edge-adapter evidence fields, persisted into the
103
+ * event's eventData by the backend: `protocol` = detected transport/
104
+ * credential protocol; `evidence` = light crypto-free detection detail.
105
+ */
106
+ protocol?: string;
107
+ evidence?: Record<string, unknown>;
108
+ }): Promise<void>;
109
+ /**
110
+ * Report a counterparty-side PDLSS pre-check failure.
111
+ * Called by SDK adapters when the agent's requested PDLSS exceeds
112
+ * counterparty-defined maximums BEFORE calling verify-access.
113
+ * Fire-and-forget — errors are silently swallowed.
114
+ */
115
+ declare function reportCounterpartyPreCheckFailure(config: GatewayConfig, data: {
116
+ agentId: string;
117
+ counterpartyUrl: string;
118
+ counterpartyType?: string;
119
+ failures: Array<{
120
+ field: string;
121
+ requested: string | number;
122
+ limit: string | number | string[];
123
+ message: string;
124
+ }>;
125
+ requestPath?: string;
126
+ requestMethod?: string;
127
+ }): Promise<void>;
128
+ /**
129
+ * Quick verification — checks credentials and policy in one call.
130
+ *
131
+ * Round-18 G4: return shape mirrors `VerificationResult`'s split — partners
132
+ * writing custom handlers around `quickVerify` get the same identity/policy
133
+ * distinction as those calling `verify()` directly. Map to HTTP status the
134
+ * same way: `!identityVerified` → 401; `identityVerified && !policyAllowed`
135
+ * → 403.
136
+ */
137
+ declare function quickVerify(config: GatewayConfig, credentials: AgentCredentials): Promise<{
138
+ identityVerified: boolean;
139
+ policyAllowed: boolean;
140
+ accessLevel: AccessLevel;
141
+ reason?: string;
142
+ }>;
143
+
144
+ export { type RouteAccessConfigShape, type VerifyOptions, clearCache, extractCredentials, fetchRoutes, hasCredentials, quickVerify, recordDecision, reportCounterpartyPreCheckFailure, reportUnregisteredAttempt, verify, verifyAndRecord };
@@ -0,0 +1,144 @@
1
+ import { b as AgentCredentials, G as GatewayConfig, a as AccessLevel, V as VerificationRequest, r as VerificationResult } from './types-ACMsV07B.js';
2
+
3
+ /**
4
+ * AstraSync Universal Verification Gateway - Core Verification Logic
5
+ *
6
+ * This module handles the core verification logic, calling the AstraSync API
7
+ * and processing the response into a standardized VerificationResult.
8
+ */
9
+
10
+ /**
11
+ * Clear the verification cache
12
+ */
13
+ declare function clearCache(): void;
14
+ /**
15
+ * Extract agent credentials from various sources
16
+ */
17
+ declare function extractCredentials(headers: Record<string, string | string[] | undefined>, query?: Record<string, string | undefined>): AgentCredentials;
18
+ /**
19
+ * Check if credentials are present
20
+ */
21
+ declare function hasCredentials(credentials: AgentCredentials): boolean;
22
+ /**
23
+ * Options for a single verify() call (as opposed to GatewayConfig, which is
24
+ * per-gateway). Mirrors the Java SDK's `verify(request, bypassCache)`.
25
+ */
26
+ interface VerifyOptions {
27
+ /**
28
+ * Skip the cache READ for this call so the request is guaranteed to reach
29
+ * the backend (the result is still written to the cache if cacheable).
30
+ * Used by the step-up hold-and-poll retry: the re-verify after an approval
31
+ * must hit the server to redeem the single-use approval.
32
+ */
33
+ bypassCache?: boolean;
34
+ }
35
+ /**
36
+ * Main verification function
37
+ */
38
+ declare function verify(config: GatewayConfig, request: VerificationRequest, options?: VerifyOptions): Promise<VerificationResult>;
39
+ /**
40
+ * Record a counterparty's grant/deny decision for a verification session.
41
+ * Fire-and-forget — errors are silently swallowed.
42
+ */
43
+ declare function recordDecision(config: GatewayConfig, sessionId: string, decision: 'granted' | 'denied', reason?: string): Promise<void>;
44
+ /**
45
+ * Fetch the per-route policy for an endpoint from the AstraSync backend.
46
+ * v2.9.7 moved policy authority into the dashboard — the SDK no longer
47
+ * accepts `routes` from merchant-side source code, it fetches them from
48
+ * here on init (and refreshes periodically).
49
+ *
50
+ * Returns `null` when the request fails for any reason — the caller decides
51
+ * how to fall back (the middleware allows-all when no policy is loaded so
52
+ * a misconfigured init doesn't take down the merchant's API).
53
+ */
54
+ declare function fetchRoutes(config: GatewayConfig, counterpartyId: string): Promise<RouteAccessConfigShape[] | null>;
55
+ /**
56
+ * Minimal shape of an EndpointRoute as the SDK consumes it. Mirrors the
57
+ * server's `EndpointRoute` type and the SDK's `RouteAccessConfig` — same
58
+ * JSON moves between server and SDK unchanged.
59
+ */
60
+ interface RouteAccessConfigShape {
61
+ pattern: string;
62
+ method: string;
63
+ /** @deprecated 3.2.0 — band no longer gates; optional, ignored. Use minTrustScore. */
64
+ minAccessLevel?: 'none' | 'restricted' | 'read-only' | 'standard' | 'full' | 'internal';
65
+ minTrustScore?: number;
66
+ requiredPurposes?: string[];
67
+ allowedPurposes?: string[];
68
+ allowedJurisdictions?: string[];
69
+ maxDuration?: number;
70
+ maxTransactionValue?: number;
71
+ requirePurpose?: boolean;
72
+ /** Send-mapping (Bug 14, §4.6) — see RouteAccessConfig in types.ts. */
73
+ purpose?: string;
74
+ action?: string;
75
+ }
76
+ /**
77
+ * Verify an agent AND automatically record the grant/deny decision.
78
+ *
79
+ * This is the recommended entry point for counterparties that call verify()
80
+ * directly (e.g. MCP servers) rather than using createMiddleware().
81
+ * It adds createSession: true, then fire-and-forgets the decision.
82
+ */
83
+ declare function verifyAndRecord(config: GatewayConfig, request: VerificationRequest, options?: VerifyOptions): Promise<VerificationResult>;
84
+ /**
85
+ * Report an unregistered agent attempt (no AstraSync credentials).
86
+ * Called by SDK adapters when an agent is redirected to /docs/agent-access.
87
+ * Fire-and-forget — errors are silently swallowed.
88
+ */
89
+ declare function reportUnregisteredAttempt(config: GatewayConfig, data: {
90
+ /**
91
+ * 3.6.0: optional — the backend attributes by counterpartyId first (sent
92
+ * from config below) and requires at least ONE of counterpartyId/URL.
93
+ * A null/undefined URL is omitted from the body, not sent as null.
94
+ */
95
+ counterpartyUrl?: string;
96
+ counterpartyType?: string;
97
+ sourceIp?: string;
98
+ userAgent?: string;
99
+ requestPath?: string;
100
+ requestMethod?: string;
101
+ /**
102
+ * 3.9.0 (§33.5 #1) — edge-adapter evidence fields, persisted into the
103
+ * event's eventData by the backend: `protocol` = detected transport/
104
+ * credential protocol; `evidence` = light crypto-free detection detail.
105
+ */
106
+ protocol?: string;
107
+ evidence?: Record<string, unknown>;
108
+ }): Promise<void>;
109
+ /**
110
+ * Report a counterparty-side PDLSS pre-check failure.
111
+ * Called by SDK adapters when the agent's requested PDLSS exceeds
112
+ * counterparty-defined maximums BEFORE calling verify-access.
113
+ * Fire-and-forget — errors are silently swallowed.
114
+ */
115
+ declare function reportCounterpartyPreCheckFailure(config: GatewayConfig, data: {
116
+ agentId: string;
117
+ counterpartyUrl: string;
118
+ counterpartyType?: string;
119
+ failures: Array<{
120
+ field: string;
121
+ requested: string | number;
122
+ limit: string | number | string[];
123
+ message: string;
124
+ }>;
125
+ requestPath?: string;
126
+ requestMethod?: string;
127
+ }): Promise<void>;
128
+ /**
129
+ * Quick verification — checks credentials and policy in one call.
130
+ *
131
+ * Round-18 G4: return shape mirrors `VerificationResult`'s split — partners
132
+ * writing custom handlers around `quickVerify` get the same identity/policy
133
+ * distinction as those calling `verify()` directly. Map to HTTP status the
134
+ * same way: `!identityVerified` → 401; `identityVerified && !policyAllowed`
135
+ * → 403.
136
+ */
137
+ declare function quickVerify(config: GatewayConfig, credentials: AgentCredentials): Promise<{
138
+ identityVerified: boolean;
139
+ policyAllowed: boolean;
140
+ accessLevel: AccessLevel;
141
+ reason?: string;
142
+ }>;
143
+
144
+ export { type RouteAccessConfigShape, type VerifyOptions, clearCache, extractCredentials, fetchRoutes, hasCredentials, quickVerify, recordDecision, reportCounterpartyPreCheckFailure, reportUnregisteredAttempt, verify, verifyAndRecord };