@astrasyncai/verification-gateway 5.4.0 → 5.4.2

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 (133) hide show
  1. package/dist/adapter-interface/interface.d.mts +2 -3
  2. package/dist/adapter-interface/interface.d.ts +2 -3
  3. package/dist/adapters/express.d.mts +63 -4
  4. package/dist/adapters/express.d.ts +63 -4
  5. package/dist/adapters/express.js +9 -2
  6. package/dist/adapters/express.js.map +1 -1
  7. package/dist/adapters/express.mjs +9 -2
  8. package/dist/adapters/express.mjs.map +1 -1
  9. package/dist/adapters/mcp.d.mts +396 -4
  10. package/dist/adapters/mcp.d.ts +396 -4
  11. package/dist/adapters/mcp.js +9 -2
  12. package/dist/adapters/mcp.js.map +1 -1
  13. package/dist/adapters/mcp.mjs +9 -2
  14. package/dist/adapters/mcp.mjs.map +1 -1
  15. package/dist/adapters/nextjs.d.mts +22 -4
  16. package/dist/adapters/nextjs.d.ts +22 -4
  17. package/dist/adapters/nextjs.js +9 -2
  18. package/dist/adapters/nextjs.js.map +1 -1
  19. package/dist/adapters/nextjs.mjs +9 -2
  20. package/dist/adapters/nextjs.mjs.map +1 -1
  21. package/dist/adapters/sdk.d.mts +157 -3
  22. package/dist/adapters/sdk.d.ts +157 -3
  23. package/dist/adapters/sdk.js +35 -15
  24. package/dist/adapters/sdk.js.map +1 -1
  25. package/dist/adapters/sdk.mjs +35 -15
  26. package/dist/adapters/sdk.mjs.map +1 -1
  27. package/dist/agent/index.d.mts +224 -3
  28. package/dist/agent/index.d.ts +224 -3
  29. package/dist/agent/index.js +1 -1
  30. package/dist/agent/index.js.map +1 -1
  31. package/dist/agent/index.mjs +1 -1
  32. package/dist/agent/index.mjs.map +1 -1
  33. package/dist/bin/astrasync-claude-hook.js +9 -2
  34. package/dist/bin/astrasync-codex-hook.js +9 -2
  35. package/dist/bin/astrasync-guard.js +9 -2
  36. package/dist/bin/astrasync.js +9 -2
  37. package/dist/browser/background.js +9 -2
  38. package/dist/browser/background.js.map +1 -1
  39. package/dist/browser/background.mjs +9 -2
  40. package/dist/browser/background.mjs.map +1 -1
  41. package/dist/browser/browser-adapter.d.mts +1 -5
  42. package/dist/browser/browser-adapter.d.ts +1 -5
  43. package/dist/claude-code/claude-code-adapter.d.mts +1 -5
  44. package/dist/claude-code/claude-code-adapter.d.ts +1 -5
  45. package/dist/cli/index.d.mts +1 -5
  46. package/dist/cli/index.d.ts +1 -5
  47. package/dist/cli/index.js +1 -1
  48. package/dist/cli/index.js.map +1 -1
  49. package/dist/cli/index.mjs +1 -1
  50. package/dist/cli/index.mjs.map +1 -1
  51. package/dist/codex/index.d.mts +1 -5
  52. package/dist/codex/index.d.ts +1 -5
  53. package/dist/codex/index.js +9 -2
  54. package/dist/codex/index.js.map +1 -1
  55. package/dist/codex/index.mjs +9 -2
  56. package/dist/codex/index.mjs.map +1 -1
  57. package/dist/cursor/cursor-adapter.d.mts +1 -5
  58. package/dist/cursor/cursor-adapter.d.ts +1 -5
  59. package/dist/cursor/extension.d.mts +1 -5
  60. package/dist/cursor/extension.d.ts +1 -5
  61. package/dist/cursor/extension.js +9 -2
  62. package/dist/cursor/extension.js.map +1 -1
  63. package/dist/cursor/extension.mjs +9 -2
  64. package/dist/cursor/extension.mjs.map +1 -1
  65. package/dist/edge-config.d.mts +1 -1
  66. package/dist/edge-config.d.ts +1 -1
  67. package/dist/edge-config.js +1 -1
  68. package/dist/edge-config.js.map +1 -1
  69. package/dist/edge-config.mjs +1 -1
  70. package/dist/edge-config.mjs.map +1 -1
  71. package/dist/edge-core/index.d.mts +1 -1
  72. package/dist/edge-core/index.d.ts +1 -1
  73. package/dist/edge-core/index.js +9 -2
  74. package/dist/edge-core/index.js.map +1 -1
  75. package/dist/edge-core/index.mjs +9 -2
  76. package/dist/edge-core/index.mjs.map +1 -1
  77. package/dist/gateway/gateway.d.mts +2 -3
  78. package/dist/gateway/gateway.d.ts +2 -3
  79. package/dist/gateway/gateway.js +9 -2
  80. package/dist/gateway/gateway.js.map +1 -1
  81. package/dist/gateway/gateway.mjs +9 -2
  82. package/dist/gateway/gateway.mjs.map +1 -1
  83. package/dist/git-trigger/git-hooks.d.mts +253 -3
  84. package/dist/git-trigger/git-hooks.d.ts +253 -3
  85. package/dist/index.d.mts +4506 -42
  86. package/dist/index.d.ts +4506 -42
  87. package/dist/index.js +35 -15
  88. package/dist/index.js.map +1 -1
  89. package/dist/index.mjs +35 -15
  90. package/dist/index.mjs.map +1 -1
  91. package/dist/interface-q1WrMsB1.d.mts +365 -0
  92. package/dist/interface-q1WrMsB1.d.ts +365 -0
  93. package/dist/local-evaluator/evaluator.d.mts +2 -3
  94. package/dist/local-evaluator/evaluator.d.ts +2 -3
  95. package/dist/registration/index.js +1 -1
  96. package/dist/registration/index.js.map +1 -1
  97. package/dist/registration/index.mjs +1 -1
  98. package/dist/registration/index.mjs.map +1 -1
  99. package/dist/transport/index.d.mts +1324 -4
  100. package/dist/transport/index.d.ts +1324 -4
  101. package/dist/transport/index.js +1 -1
  102. package/dist/transport/index.js.map +1 -1
  103. package/dist/transport/index.mjs +1 -1
  104. package/dist/transport/index.mjs.map +1 -1
  105. package/dist/{types-DGh2akuh.d.ts → types-BRz2U0Pn.d.ts} +2 -2
  106. package/dist/{types-76TB0fxW.d.ts → types-BU04qAAR.d.mts} +59 -213
  107. package/dist/{types-CD1F9fmp.d.mts → types-BU04qAAR.d.ts} +59 -213
  108. package/dist/types-Bd2O3eX1.d.mts +769 -0
  109. package/dist/types-BfILnheI.d.mts +189 -0
  110. package/dist/types-BfILnheI.d.ts +189 -0
  111. package/dist/{types-z_RNjHWm.d.mts → types-CfBpm3w5.d.mts} +2 -2
  112. package/dist/types-DMChboN_.d.ts +769 -0
  113. package/dist/ui/index.d.mts +1 -2
  114. package/dist/ui/index.d.ts +1 -2
  115. package/dist/verify.d.mts +1 -1
  116. package/dist/verify.d.ts +1 -1
  117. package/dist/verify.js +9 -2
  118. package/dist/verify.js.map +1 -1
  119. package/dist/verify.mjs +9 -2
  120. package/dist/verify.mjs.map +1 -1
  121. package/package.json +1 -1
  122. package/dist/express-BIAT2pe0.d.mts +0 -69
  123. package/dist/express-D3Tf-b23.d.ts +0 -69
  124. package/dist/index-BVJkTyIF.d.mts +0 -248
  125. package/dist/index-By021oSN.d.mts +0 -1469
  126. package/dist/index-DaMXZabg.d.ts +0 -248
  127. package/dist/index-iJ9_DdLk.d.ts +0 -1469
  128. package/dist/mcp-BqfTDZLh.d.mts +0 -397
  129. package/dist/mcp-OrVOrH-s.d.ts +0 -397
  130. package/dist/nextjs-DGJXzWst.d.mts +0 -28
  131. package/dist/nextjs-xM-jdNrX.d.ts +0 -28
  132. package/dist/sdk-C1IOA5LE.d.ts +0 -173
  133. package/dist/sdk-C6_-6D-9.d.mts +0 -173
@@ -1,397 +0,0 @@
1
- import { Request, Response, RequestHandler } from 'express';
2
- import { G as GatewayConfig, x as VerificationResult } from './types-76TB0fxW.js';
3
-
4
- /**
5
- * X-Astra-Verified-Hop — cross-hop verify-access dedupe marker.
6
- *
7
- * Header carrying upstream verify-access proof so an inner-hop endpoint can
8
- * dedupe (skip verify-access when the same ASTRA-id was already verified a
9
- * few ms earlier). Emitted by the MCP adapter toward tool fetches and by the
10
- * edge gateway toward the origin at authenticate/authorize depth. Value
11
- * format:
12
- *
13
- * {astraId};{sessionId};{checkedAt-ms}
14
- *
15
- * Receivers MUST validate that `checkedAt` is recent (≤ 60s window
16
- * recommended) and that `astraId` matches the agent identity claimed on the
17
- * inner hop. The header alone is NOT proof-of-identity — it's an UNSIGNED
18
- * dedupe advisory: trust it (`trustVerifiedHop`) only where every network
19
- * path to the inner hop crosses a stripping gateway or an equivalent trusted
20
- * boundary, exactly like the unsigned X-AstraSync-* attestation headers.
21
- * Pair with the existing X-Astra-Id auth.
22
- */
23
- declare const MCP_VERIFIED_HOP_HEADER = "X-Astra-Verified-Hop";
24
- /** Default acceptable age (ms) for an X-Astra-Verified-Hop header. */
25
- declare const MCP_VERIFIED_HOP_MAX_AGE_MS = 60000;
26
- interface VerifiedHopMarker {
27
- astraId: string;
28
- sessionId?: string;
29
- checkedAt: number;
30
- }
31
- declare function serializeVerifiedHop(marker: VerifiedHopMarker): string;
32
- declare function parseVerifiedHop(value: string | undefined | null): VerifiedHopMarker | null;
33
- /**
34
- * Returns true when `marker.astraId` matches the inner-hop's claimed
35
- * ASTRA-id AND the marker is recent enough. Inner-hop middleware uses this
36
- * to skip a duplicate verify-access call.
37
- */
38
- declare function isVerifiedHopValidFor(marker: VerifiedHopMarker | null, expectedAstraId: string, opts?: {
39
- maxAgeMs?: number;
40
- now?: number;
41
- }): boolean;
42
-
43
- /**
44
- * MCP server-side helpers — companion to `transport/mcp.ts` (which handles the
45
- * agent-side `_meta.astrasync` block).
46
- *
47
- * Surfaces a body-aware policy hook the existing `createMiddleware` couldn't
48
- * provide — MCP traffic is JSON-RPC over a single endpoint (`/mcp`), so the
49
- * default route-pattern gating is too coarse: every request looks the same
50
- * URL-wise, but `initialize` is low-risk handshake while `tools/call` of a
51
- * payment tool is high-risk. Cohort-3 beta merchants flagged this 🟡 in the
52
- * v2.9.5 round.
53
- *
54
- * What lives here:
55
- * - `parseMcpJsonRpc(body)` — peels JSON-RPC method + tool name + agent
56
- * id without committing to a particular MCP
57
- * server framework.
58
- * - `mcpToPdlss(parsed)` — canonical mapping JSON-RPC method → PDLSS
59
- * purpose / action / resource. Doc-stable
60
- * so audits can correlate.
61
- * - `mcpDefaultEnforced(parsed)` — whether a method is enforced by default
62
- * so a single MCP middleware can split
63
- * `initialize` / `tools/list` (pass-through)
64
- * from `tools/call` (enforced).
65
- * - `MCP_VERIFIED_HOP_HEADER` — header convention for the dedupe pattern
66
- * when an MCP tool calls an inner REST hop.
67
- * - `serialize/parseVerifiedHop` helpers.
68
- *
69
- * The Express MCP adapter is in `adapters/mcp.ts` and consumes these.
70
- */
71
-
72
- /**
73
- * Output of `parseMcpJsonRpc`. Self-describing so the middleware doesn't have
74
- * to re-introspect the body to figure out gating.
75
- */
76
- interface ParsedMcpRequest {
77
- /** JSON-RPC method (e.g. `tools/call`, `initialize`, `tools/list`). */
78
- method: string;
79
- /** Set when method === 'tools/call'; the tool name from `params.name`. */
80
- toolName?: string;
81
- /** Initialize-specific protocolVersion handshake info, when present. */
82
- protocolVersion?: string;
83
- /**
84
- * Agent id read from the body, in priority order:
85
- * 1. `params._meta.astrasync.agentId` (the canonical SDK location, see
86
- * `transport/mcp.ts → setMcpMeta`)
87
- * 2. `params.arguments.agent_id` (legacy / hand-written tool callers)
88
- * Header-supplied id (X-Astra-Id) is read separately by the adapter and
89
- * compared to this for the mismatch check.
90
- */
91
- agentIdFromBody?: string;
92
- /**
93
- * Purpose extracted from the MCP body
94
- * with the symmetric precedence chain. Sourced from `_meta.astrasync.purpose`
95
- * (canonical SDK location) OR `params.arguments.purpose` (legacy /
96
- * conventional callers). The discriminator is on `purposeSourceFromBody`.
97
- * Adapter combines this with the `X-Astra-Purpose` header (header wins)
98
- * before mapping; final fallback at `mcpToPdlss` is `undefined`.
99
- */
100
- purposeFromBody?: string;
101
- /** Which body location resolved `purposeFromBody`. */
102
- purposeSourceFromBody?: 'meta' | 'tool_argument';
103
- /**
104
- * Action extracted from the MCP body with the same
105
- * symmetric chain as purpose. Sourced from `_meta.astrasync.action`
106
- * (canonical) OR `params.arguments.action` (legacy). Adapter combines
107
- * with the `X-Astra-Action` header (header wins) before mapping; final
108
- * fallback at `mcpToPdlss` is the transport-layer default
109
- * (`tools/call:<toolname>` or just `<method>`).
110
- */
111
- actionFromBody?: string;
112
- /** Which body location resolved `actionFromBody`. */
113
- actionSourceFromBody?: 'meta' | 'tool_argument';
114
- /** True for handshake methods that must succeed before any tool call. */
115
- isInitialize: boolean;
116
- /** True for `tools/call`. */
117
- isToolCall: boolean;
118
- /** True for low-risk introspection (`tools/list`, `prompts/list`, etc.). */
119
- isIntrospection: boolean;
120
- }
121
- /**
122
- * Peel the JSON-RPC envelope. Returns `null` if the body isn't a JSON-RPC
123
- * request (callers can short-circuit with a 400 or treat as untyped traffic).
124
- *
125
- * Accepts both single-request and notification shapes. Batch requests are
126
- * NOT supported here — the verify-access contract is single-agent-per-call;
127
- * a batch body should be split before policy gating.
128
- */
129
- declare function parseMcpJsonRpc(body: unknown): ParsedMcpRequest | null;
130
- /**
131
- * PDLSS mapping for an MCP request. The platform's PDLSS taxonomy is
132
- * `purpose / action / resource`; for MCP traffic the audit-useful dimensions
133
- * are the JSON-RPC method and (for `tools/call`) the tool name.
134
- *
135
- * v2.5.0 rules:
136
- * - `resource` defaults to the HTTP request path (e.g. `/mcp`). Per-tool
137
- * overrides via `toolGates` config let merchants map tools to specific
138
- * backend resources (e.g. `/api/catalog`).
139
- * - `purpose` defaults to `undefined` (backend evaluator applies
140
- * skip-when-undefined). Per-tool overrides via `toolGates` config let
141
- * merchants declare the semantic purpose each tool fulfils.
142
- * - `action` comes only from declarations (toolGate config, header, or
143
- * body). For `tools/call` with none declared it is `undefined` —
144
- * evaluation is purpose-only, because a raw tool name is a transport
145
- * token, not a PDLSS action, and sending it as one guarantees an
146
- * action-policy mismatch. For other JSON-RPC methods the method string
147
- * is used.
148
- */
149
- interface McpPdlssMapping {
150
- purpose: string | undefined;
151
- /**
152
- * `undefined` when a `tools/call` request declared no action anywhere —
153
- * the verify-access call then evaluates purpose-only. Tool names never
154
- * travel as PDLSS actions.
155
- */
156
- action: string | undefined;
157
- resource: string;
158
- purposeSource: 'header' | 'meta' | 'tool_argument' | 'tool_gate' | undefined;
159
- actionSource: 'header' | 'meta' | 'tool_argument' | 'tool_gate' | 'transport_layer' | undefined;
160
- }
161
- /**
162
- * v2.5.0 — PDLSS field derivation for MCP requests.
163
- *
164
- * Purpose precedence:
165
- * - If `toolGate.purpose` is provided, it is authoritative (header/body ignored).
166
- * - Otherwise: header → body `_meta` → body `arguments` → `undefined`.
167
- *
168
- * Resource precedence:
169
- * - `toolGate.resource` if provided, else `requestPath`.
170
- *
171
- * Action precedence (3.1.0 — toolGate override added for
172
- * symmetry with purpose; 4.1.0 — the bare-tool-name fallback for
173
- * `tools/call` was removed):
174
- * - `toolGate.action` authoritative → header → body `_meta` → body
175
- * `arguments` → then: `undefined` for `tools/call` (purpose-only
176
- * evaluation — tool names are transport tokens, never PDLSS actions),
177
- * or the JSON-RPC method string for other methods (transport_layer).
178
- *
179
- * @param requestPath The HTTP request path (e.g. '/mcp'). Required.
180
- * @param toolGate Resolved per-tool config from `toolGates`, if present.
181
- */
182
- declare function mcpToPdlss(parsed: ParsedMcpRequest, requestPath: string, headerPurpose?: string, headerAction?: string, toolGate?: {
183
- purpose?: string;
184
- action?: string;
185
- resource?: string;
186
- }): McpPdlssMapping;
187
- /**
188
- * Whether a method is enforced (calls verify-access + gates on the server
189
- * decision) by default. The MCP middleware uses this to split low-risk
190
- * handshake / introspection traffic (pass-through) from high-risk tool
191
- * execution (enforced). Per-tool / per-method overrides win over this default.
192
- *
193
- * - `initialize` / `notifications/initialized` → false (handshake must work for unregistered probes)
194
- * - `tools/list` / `prompts/list` / `resources/list` → false (introspection is public-surface)
195
- * - `ping` → false
196
- * - `resources/read` → true
197
- * - `tools/call` → true (default — overridable per-tool)
198
- * - everything else → true (least-privilege fallback)
199
- */
200
- declare function mcpDefaultEnforced(parsed: ParsedMcpRequest): boolean;
201
-
202
- /**
203
- * AstraSync Universal Verification Gateway — MCP middleware
204
- *
205
- * Express-shaped middleware tailored to the JSON-RPC body of an MCP
206
- * (Model Context Protocol) endpoint. Closes the cohort-3 gaps the default
207
- * `createMiddleware` couldn't:
208
- *
209
- * (a) **Body-aware gating**. All MCP traffic targets the same `/mcp` URL.
210
- * The default route-pattern matcher can't tell `initialize` (low risk)
211
- * from `tools/call start_checkout` (high risk). This middleware peels
212
- * the JSON-RPC body and applies a per-method risk tier.
213
- *
214
- * (b) **PDLSS mapping**. Derives purpose, action, and resource from
215
- * `toolGates` config and request context. See `transport/mcp-server.ts`
216
- * `mcpToPdlss()` for the exact mapping.
217
- *
218
- * (c) **Inner-hop dedupe**. Outbound responses set
219
- * `X-Astra-Verified-Hop` so a downstream REST endpoint that the tool
220
- * calls can skip a duplicate verify-access. The receiving REST
221
- * middleware checks `parseVerifiedHop` and skips when valid.
222
- *
223
- * (d) **Header-vs-body identity precedence**. Reads ASTRA-id from
224
- * `X-Astra-Id` first, body second. If both are present and disagree,
225
- * returns a structured 400 by default (configurable). Pre-fix,
226
- * integrators had to re-discover this on their own.
227
- *
228
- * Usage:
229
- *
230
- * ```typescript
231
- * import express from 'express';
232
- * import { createMcpMiddleware } from '@astrasyncai/verification-gateway/mcp';
233
- *
234
- * const app = express();
235
- * app.use(express.json());
236
- *
237
- * app.post(
238
- * '/mcp',
239
- * createMcpMiddleware({
240
- * apiBaseUrl: 'https://astrasync.ai/api',
241
- * apiKey: process.env.ASTRASYNC_API_KEY,
242
- * // Per-tool gates — `tools/call` is enforced by default; introspection /
243
- * // handshake pass through. A gated tool needs a PDLSS purpose (and ideally
244
- * // an action). Set a tool/method to `'observe'` to pass it through
245
- * // unenforced (still evaluated when `evaluateAlwaysIfCredentialed`).
246
- * toolGates: {
247
- * browse_catalog: { purpose: 'shopping', action: 'shopping.search' },
248
- * start_checkout: { purpose: 'shopping', action: 'shopping.purchase' },
249
- * health_check: 'observe',
250
- * },
251
- * }),
252
- * yourMcpServerHandler,
253
- * );
254
- * ```
255
- */
256
-
257
- declare global {
258
- namespace Express {
259
- interface Request {
260
- mcpRequest?: ParsedMcpRequest;
261
- }
262
- }
263
- }
264
- /**
265
- * Extended per-tool gate with optional PDLSS purpose + action + resource
266
- * overrides.
267
- *
268
- * When `purpose` is set, it is authoritative for that tool — the agent's
269
- * `X-Astra-Purpose` header is ignored. This lets the merchant declare what
270
- * semantic purpose each tool fulfils rather than trusting agent self-declaration.
271
- *
272
- * When `action` is set (symmetric with `purpose`), it is
273
- * authoritative over `X-Astra-Action` / body declarations, letting the
274
- * merchant pin a dotted-verb action (e.g. `shopping.search`) for a tool
275
- * whose callers would otherwise leave the action undeclared (purpose-only
276
- * evaluation — raw tool names never travel as PDLSS actions).
277
- *
278
- * When `resource` is set, it overrides the default (`req.path`) for that
279
- * tool's verify-access call — e.g. mapping `list_products` to `/api/catalog`.
280
- */
281
- interface ToolGateConfig {
282
- purpose?: string;
283
- action?: string;
284
- resource?: string;
285
- }
286
- /**
287
- * A tool/method gate is either a {@link ToolGateConfig} (enforced — calls
288
- * verify-access and gates on the server decision, using the declared PDLSS
289
- * purpose/action) or the literal `'observe'` (passed through unenforced;
290
- * still evaluated when `evaluateAlwaysIfCredentialed` is set). SDK 5.0.0
291
- * removed the access-level band, so a gate no longer carries a tier — its
292
- * only decision is enforce vs observe.
293
- */
294
- type ToolGate = ToolGateConfig | 'observe';
295
- interface McpMiddlewareOptions extends GatewayConfig {
296
- /**
297
- * Per-tool gating for `tools/call` invocations. Tools not listed are
298
- * enforced by default (`tools/call` calls verify-access and gates on the
299
- * server decision).
300
- *
301
- * A gated tool declares its PDLSS `purpose` (required: the backend rejects
302
- * gated calls with no resolvable purpose) and ideally a dotted-verb
303
- * `action`:
304
- * ```typescript
305
- * toolGates: {
306
- * list_products: { purpose: 'shopping',
307
- * action: 'shopping.search',
308
- * resource: '/api/catalog' },
309
- * start_checkout: { purpose: 'shopping',
310
- * action: 'shopping.purchase',
311
- * resource: '/api/checkout/*' },
312
- * health_check: 'observe', // pass through unenforced
313
- * }
314
- * ```
315
- *
316
- * Set a tool to `'observe'` to pass it through without enforcement (it is
317
- * still evaluated for the audit trail when `evaluateAlwaysIfCredentialed`
318
- * is set). A gated object form with no resolvable purpose fails fast with a
319
- * `PDLSS_PURPOSE_REQUIRED` 400 (the SDK never sends the raw tool name as
320
- * the PDLSS action).
321
- *
322
- * The action axis for non-tools/call MCP methods (`tools/list`,
323
- * `resources/list`, `prompts/list`, etc.) is the literal JSON-RPC method
324
- * name (e.g. `'tools/list'`). Merchants gating MCP traffic by action should
325
- * declare per-tool gates in `toolGates`, not endpoint-level `allowedActions`
326
- * — the latter applies to REST-style action values, not MCP method strings.
327
- */
328
- toolGates?: Record<string, ToolGate>;
329
- /**
330
- * Per-method override. By default introspection / handshake methods
331
- * (`tools/list`, `initialize`, `ping`, …) pass through and `tools/call` is
332
- * enforced; declare a method here to enforce it (object form, with a PDLSS
333
- * purpose) or set it to `'observe'` to pass it through. Matches by exact
334
- * JSON-RPC method string.
335
- */
336
- methodGates?: Record<string, ToolGate>;
337
- /**
338
- * What to do when the agent id supplied in the X-Astra-Id header
339
- * disagrees with the agent id in the JSON-RPC body
340
- * (`params._meta.astrasync.agentId` or `params.arguments.agent_id`).
341
- *
342
- * - `'reject'` (default) — return 400 `AGENT_ID_MISMATCH`. Safest.
343
- * - `'prefer-header'` — log + verify against the header value. Keeps
344
- * bodies that were authored before X-Astra-Id was the canonical
345
- * identity slot working.
346
- * - `'prefer-body'` — log + verify against the body value. Useful in
347
- * reverse-proxy setups that strip auth headers.
348
- */
349
- onAgentIdMismatch?: 'reject' | 'prefer-header' | 'prefer-body';
350
- /** Skip verification + dedupe entirely. For testing. */
351
- skip?: boolean;
352
- /** Custom denied handler. Defaults to a structured JSON-RPC error response. */
353
- onDenied?: (result: VerificationResult, req: Request, res: Response) => void;
354
- /**
355
- * If `true`, trust an inbound `X-Astra-Verified-Hop` header to skip
356
- * verify-access when it carries a recent marker for the resolved agent.
357
- *
358
- * **DEFAULT FLIPPED TO `false` in SDK 2.4.13.** The marker
359
- * is plaintext semicolon-delimited with no HMAC, so any client that sets
360
- * the header (with the right format + fresh timestamp + matching ASTRA-id)
361
- * skipped verify-access entirely. The per-process verify-access result
362
- * cache already dedupes legitimate repeat calls — this optimization
363
- * provided no additional savings, only a bypass surface.
364
- *
365
- * Set this to `true` ONLY if you control every upstream MCP hop that sets
366
- * the header AND you trust the network path between hops (mTLS, internal
367
- * VPC, etc.). For most installs, leave at the safe default.
368
- *
369
- * A future SDK release will either remove this option entirely OR add
370
- * HMAC signing to the marker.
371
- */
372
- trustVerifiedHop?: boolean;
373
- /** Window for accepting an upstream verified-hop marker. Default 60_000ms. */
374
- verifiedHopMaxAgeMs?: number;
375
- /**
376
- * Automatically record grant/deny decisions for every MCP call. Default
377
- * `true` — matches the express adapter.
378
- */
379
- recordDecisions?: boolean;
380
- /** Forward runtime challenge (default `true`). */
381
- enableRuntimeChallenge?: boolean;
382
- /**
383
- * Posture when the MCP middleware itself throws an internal error.
384
- * Default `'open'` for backward compatibility in SDK 2.4.13. Shadow logs
385
- * record what WOULD be denied with `failOnError: 'closed'` so merchants
386
- * can grep correlationId for impact analysis during the observation
387
- * window. Default flips to `'closed'` in a follow-up release.
388
- */
389
- failOnError?: 'open' | 'closed';
390
- }
391
- /**
392
- * Create the MCP middleware. Attach AFTER `express.json()` — the body must
393
- * already be a parsed object.
394
- */
395
- declare function createMcpMiddleware(options: McpMiddlewareOptions): RequestHandler;
396
-
397
- export { MCP_VERIFIED_HOP_HEADER as M, type ParsedMcpRequest as P, type ToolGate as T, type VerifiedHopMarker as V, MCP_VERIFIED_HOP_MAX_AGE_MS as a, type McpMiddlewareOptions as b, type ToolGateConfig as c, createMcpMiddleware as d, mcpToPdlss as e, parseVerifiedHop as f, isVerifiedHopValidFor as i, mcpDefaultEnforced as m, parseMcpJsonRpc as p, serializeVerifiedHop as s };
@@ -1,28 +0,0 @@
1
- import * as next_server from 'next/server';
2
- import { NextRequest } from 'next/server';
3
- import { N as NextJsMiddlewareOptions } from './types-CD1F9fmp.mjs';
4
-
5
- /**
6
- * Create Next.js middleware for agent verification.
7
- *
8
- * v2.9.7 moved per-route policy out of merchant-side source code into the
9
- * AstraSync dashboard. The middleware fetches its routes from the backend
10
- * via `GET /endpoints/:counterpartyId/routes` on init and refreshes
11
- * periodically — see `ExpressMiddlewareOptions` for the rationale (a dual
12
- * config source silently conflicts with dashboard policy).
13
- */
14
- declare function createMiddleware(options: NextJsMiddlewareOptions): (request: NextRequest) => Promise<next_server.NextResponse<unknown>>;
15
- /**
16
- * Helper to create matcher config
17
- */
18
- declare function createMatcherConfig(paths: string[]): {
19
- matcher: string[];
20
- };
21
-
22
- declare const nextjs_createMatcherConfig: typeof createMatcherConfig;
23
- declare const nextjs_createMiddleware: typeof createMiddleware;
24
- declare namespace nextjs {
25
- export { nextjs_createMatcherConfig as createMatcherConfig, nextjs_createMiddleware as createMiddleware };
26
- }
27
-
28
- export { createMiddleware as a, createMatcherConfig as c, nextjs as n };
@@ -1,28 +0,0 @@
1
- import * as next_server from 'next/server';
2
- import { NextRequest } from 'next/server';
3
- import { N as NextJsMiddlewareOptions } from './types-76TB0fxW.js';
4
-
5
- /**
6
- * Create Next.js middleware for agent verification.
7
- *
8
- * v2.9.7 moved per-route policy out of merchant-side source code into the
9
- * AstraSync dashboard. The middleware fetches its routes from the backend
10
- * via `GET /endpoints/:counterpartyId/routes` on init and refreshes
11
- * periodically — see `ExpressMiddlewareOptions` for the rationale (a dual
12
- * config source silently conflicts with dashboard policy).
13
- */
14
- declare function createMiddleware(options: NextJsMiddlewareOptions): (request: NextRequest) => Promise<next_server.NextResponse<unknown>>;
15
- /**
16
- * Helper to create matcher config
17
- */
18
- declare function createMatcherConfig(paths: string[]): {
19
- matcher: string[];
20
- };
21
-
22
- declare const nextjs_createMatcherConfig: typeof createMatcherConfig;
23
- declare const nextjs_createMiddleware: typeof createMiddleware;
24
- declare namespace nextjs {
25
- export { nextjs_createMatcherConfig as createMatcherConfig, nextjs_createMiddleware as createMiddleware };
26
- }
27
-
28
- export { createMiddleware as a, createMatcherConfig as c, nextjs as n };
@@ -1,173 +0,0 @@
1
- import { v as TrustLevel, S as SDKOptions, x as VerificationResult, w as VerificationRequest } from './types-76TB0fxW.js';
2
-
3
- /**
4
- * AstraSync Universal Verification Gateway — Trust Level helpers.
5
- *
6
- * SDK 5.0.0: the `accessLevel` band (`none`/`restricted`/`read-only`/`standard`/
7
- * `full`/`internal`) was removed entirely — it never gated the access decision
8
- * (the server does, from a verified ID + runtime challenge + PDLSS match + trust
9
- * score). What remains here is the coarse trust-level badge derived from the
10
- * numeric trust score, used only for display.
11
- */
12
-
13
- /**
14
- * Trust level score ranges
15
- */
16
- declare const TRUST_LEVEL_RANGES: Record<TrustLevel, {
17
- min: number;
18
- max: number;
19
- }>;
20
- /**
21
- * Determine trust level from score
22
- */
23
- declare function getTrustLevel(score: number): TrustLevel;
24
-
25
- /**
26
- * AstraSync Universal Verification Gateway - SDK Adapter
27
- *
28
- * Direct SDK for verifying agents in any JavaScript/TypeScript environment.
29
- * Useful for agent-to-agent verification, serverless functions, or custom integrations.
30
- *
31
- * @example
32
- * ```typescript
33
- * import { createClient } from '@astrasyncai/verification-gateway/sdk';
34
- *
35
- * const gateway = createClient({
36
- * apiBaseUrl: 'https://astrasync.ai/api',
37
- * });
38
- *
39
- * // Verify another agent before interacting
40
- * const result = await gateway.verify({
41
- * astraId: 'ASTRA-abc123',
42
- * purpose: 'data-exchange',
43
- * });
44
- *
45
- * if (result.identityVerified && result.policyAllowed) {
46
- * // Safe to interact with this agent
47
- * }
48
- * ```
49
- */
50
-
51
- /**
52
- * Verification Gateway SDK Client
53
- */
54
- declare class VerificationGatewayClient {
55
- private config;
56
- private timeout;
57
- private retryConfig;
58
- constructor(options: SDKOptions);
59
- /**
60
- * Full verification with all details
61
- */
62
- verify(options: {
63
- astraId?: string;
64
- apiKey?: string;
65
- jwt?: string;
66
- purpose?: string;
67
- action?: string;
68
- resourceType?: string;
69
- resource?: string;
70
- jurisdiction?: string;
71
- transactionValue?: number;
72
- currency?: string;
73
- isSubAgentRequest?: boolean;
74
- parentAgentId?: string;
75
- subAgentDepth?: number;
76
- counterpartyUrl?: string;
77
- counterpartyType?: string;
78
- }): Promise<VerificationResult>;
79
- /**
80
- * 5.4.0 (astra-pay): confirm-leg of a checkout — the ONLY call that may fire
81
- * first-party charge-at-redeem (server-side settlement on the owner's saved
82
- * instrument). This is the supported public surface for the confirm leg;
83
- * `verify()` deliberately does not expose the checkout fields, so settlement
84
- * can never fire by accident from a generic verify.
85
- *
86
- * Sends `commercePhase: 'confirm'` plus the checkout session id (per-cart
87
- * idempotency) and line items (order/receipt plane), and identifies the
88
- * merchant via `counterpartyUrl`/`counterpartyType` (required — the backend
89
- * only settles a merchant-mediated grant against a first-party storefront).
90
- * `purpose`/`action` default to the canonical shopping pair.
91
- *
92
- * Returns the full `VerificationResult`: read `.settlementOutcome` for the
93
- * settled/failed/requires_action/no_instrument outcome (+ `orderId`), and the
94
- * identity/policy/`failures` fields for a denial. On any non-`confirm`/first-
95
- * party path `settlementOutcome` is simply absent — no money moves.
96
- */
97
- confirmCheckout(options: {
98
- astraId?: string;
99
- apiKey?: string;
100
- jwt?: string;
101
- purpose?: string;
102
- action?: string;
103
- transactionValue?: number;
104
- currency?: string;
105
- checkoutSessionId?: string;
106
- checkoutItems?: VerificationRequest['checkoutItems'];
107
- counterpartyUrl?: string;
108
- counterpartyType?: string;
109
- }): Promise<VerificationResult>;
110
- /**
111
- * Quick verification — checks credentials and policy in one call.
112
- *
113
- * The return shape mirrors `VerificationResult`'s identity/policy
114
- * split. Map to HTTP status the same way: `!identityVerified` → 401,
115
- * `identityVerified && !policyAllowed` → 403.
116
- */
117
- quickVerify(credentials: {
118
- astraId?: string;
119
- apiKey?: string;
120
- jwt?: string;
121
- }): Promise<{
122
- identityVerified: boolean;
123
- policyAllowed: boolean;
124
- reason?: string;
125
- }>;
126
- /**
127
- * Verify a specific ASTRA-ID
128
- */
129
- verifyAstraId(astraId: string, options?: {
130
- purpose?: string;
131
- action?: string;
132
- }): Promise<VerificationResult>;
133
- /**
134
- * Verify using an API key
135
- */
136
- verifyApiKey(apiKey: string, options?: {
137
- purpose?: string;
138
- action?: string;
139
- }): Promise<VerificationResult>;
140
- /**
141
- * Clear the verification cache
142
- */
143
- clearCache(): void;
144
- /**
145
- * Execute a function with retry logic
146
- */
147
- private executeWithRetry;
148
- }
149
- /**
150
- * Create a new SDK client
151
- */
152
- declare function createClient(options: SDKOptions): VerificationGatewayClient;
153
- /**
154
- * One-shot verification without creating a client
155
- */
156
- declare function verifyOnce(options: SDKOptions & {
157
- astraId?: string;
158
- apiKey?: string;
159
- jwt?: string;
160
- purpose?: string;
161
- action?: string;
162
- }): Promise<VerificationResult>;
163
-
164
- type sdk_VerificationGatewayClient = VerificationGatewayClient;
165
- declare const sdk_VerificationGatewayClient: typeof VerificationGatewayClient;
166
- declare const sdk_createClient: typeof createClient;
167
- declare const sdk_getTrustLevel: typeof getTrustLevel;
168
- declare const sdk_verifyOnce: typeof verifyOnce;
169
- declare namespace sdk {
170
- export { sdk_VerificationGatewayClient as VerificationGatewayClient, sdk_createClient as createClient, sdk_getTrustLevel as getTrustLevel, sdk_verifyOnce as verifyOnce };
171
- }
172
-
173
- export { TRUST_LEVEL_RANGES as T, VerificationGatewayClient as V, createClient as c, getTrustLevel as g, sdk as s, verifyOnce as v };