@astrasyncai/verification-gateway 2.3.8 → 2.3.10
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 +93 -10
- package/dist/adapter-interface/interface.d.mts +2 -2
- package/dist/adapter-interface/interface.d.ts +2 -2
- package/dist/adapters/express.d.mts +2 -2
- package/dist/adapters/express.d.ts +2 -2
- package/dist/adapters/express.js +45 -6
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +45 -6
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.d.ts +1 -1
- package/dist/adapters/mcp.js +93 -11
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +93 -11
- package/dist/adapters/mcp.mjs.map +1 -1
- package/dist/adapters/nextjs.d.mts +2 -2
- package/dist/adapters/nextjs.d.ts +2 -2
- package/dist/adapters/nextjs.js +27 -5
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +27 -5
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +2 -2
- package/dist/adapters/sdk.d.ts +2 -2
- package/dist/adapters/sdk.js +27 -5
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +27 -5
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.d.mts +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/browser/background.js +26 -4
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +26 -4
- package/dist/browser/background.mjs.map +1 -1
- package/dist/browser/browser-adapter.d.mts +2 -2
- package/dist/browser/browser-adapter.d.ts +2 -2
- package/dist/cli/index.d.mts +2 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/cursor/cursor-adapter.d.mts +2 -2
- package/dist/cursor/cursor-adapter.d.ts +2 -2
- package/dist/cursor/extension.d.mts +2 -2
- package/dist/cursor/extension.d.ts +2 -2
- package/dist/cursor/extension.js +26 -4
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +26 -4
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/{express-BNWqDVIz.d.mts → express-4Vau6x6X.d.mts} +1 -1
- package/dist/{express-BYup_4Jg.d.ts → express-Nq-wWICa.d.ts} +1 -1
- package/dist/gateway/gateway.d.mts +2 -2
- package/dist/gateway/gateway.d.ts +2 -2
- package/dist/gateway/gateway.js +26 -4
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +26 -4
- package/dist/gateway/gateway.mjs.map +1 -1
- package/dist/git-trigger/git-hooks.d.mts +2 -2
- package/dist/git-trigger/git-hooks.d.ts +2 -2
- package/dist/{index-DN3ztP2d.d.ts → index-B-EovXnY.d.ts} +1 -1
- package/dist/{index-CSMpOcxV.d.ts → index-CxwCN7AC.d.ts} +1 -1
- package/dist/{index-CK4lNLVn.d.mts → index-DiToN8gh.d.mts} +1 -1
- package/dist/{index-BHXa2WTO.d.mts → index-DkyPV14Y.d.mts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +51 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -12
- package/dist/index.mjs.map +1 -1
- package/dist/local-evaluator/evaluator.d.mts +2 -2
- package/dist/local-evaluator/evaluator.d.ts +2 -2
- package/dist/{nextjs-Bzdfu8Eg.d.mts → nextjs-BTR7Oix-.d.mts} +1 -1
- package/dist/{nextjs-C4h_MpgK.d.ts → nextjs-DO_4crcp.d.ts} +1 -1
- package/dist/{sdk-Tzsn6s-O.d.ts → sdk-DSLCyXIX.d.mts} +9 -2
- package/dist/{sdk-CDdD7EcJ.d.mts → sdk-TnHXD-Oh.d.ts} +9 -2
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-D_tmbDA_.d.mts → types-BVp22KkN.d.mts} +27 -3
- package/dist/{types-D_tmbDA_.d.ts → types-BVp22KkN.d.ts} +27 -3
- package/dist/{types-Bzp1SMaD.d.ts → types-DVCWReEN.d.ts} +1 -1
- package/dist/{types-z-QVnG4b.d.mts → types-pU2O0BFq.d.mts} +1 -1
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +3 -3
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +3 -3
- package/dist/ui/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,15 +40,16 @@ import { createMiddleware } from '@astrasyncai/verification-gateway/express';
|
|
|
40
40
|
|
|
41
41
|
const app = express();
|
|
42
42
|
|
|
43
|
+
// v2.3.7+ — per-route policy lives in the AstraSync dashboard.
|
|
44
|
+
// The SDK fetches it on init via counterpartyId; do NOT pass routes here.
|
|
43
45
|
app.use(
|
|
44
46
|
createMiddleware({
|
|
45
47
|
apiBaseUrl: 'https://astrasync.ai/api',
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
],
|
|
48
|
+
apiKey: process.env.ASTRASYNC_API_KEY,
|
|
49
|
+
counterpartyId: 'ASTRAE-...', // your endpoint id from the dashboard
|
|
50
|
+
setPassThroughHeader: true, // recommended for local-dev / staging
|
|
51
|
+
// — surfaces pass-through mode when
|
|
52
|
+
// no per-route policy is configured
|
|
52
53
|
})
|
|
53
54
|
);
|
|
54
55
|
```
|
|
@@ -59,13 +60,13 @@ app.use(
|
|
|
59
60
|
// middleware.ts
|
|
60
61
|
import { createMiddleware } from '@astrasyncai/verification-gateway/nextjs';
|
|
61
62
|
|
|
63
|
+
// v2.3.7+ — per-route policy lives in the AstraSync dashboard.
|
|
64
|
+
// The SDK fetches it on init via counterpartyId; do NOT pass routes here.
|
|
62
65
|
export const middleware = createMiddleware({
|
|
63
66
|
apiBaseUrl: 'https://api.astrasync.ai',
|
|
67
|
+
apiKey: process.env.ASTRASYNC_API_KEY,
|
|
68
|
+
counterpartyId: 'ASTRAE-...',
|
|
64
69
|
showCommerceShield: true,
|
|
65
|
-
routes: [
|
|
66
|
-
{ pattern: '/api/*', method: '*', minAccessLevel: 'standard' },
|
|
67
|
-
{ pattern: '/dashboard/*', method: '*', minAccessLevel: 'read-only' },
|
|
68
|
-
],
|
|
69
70
|
});
|
|
70
71
|
|
|
71
72
|
export const config = {
|
|
@@ -94,6 +95,88 @@ if (result.verified && result.accessLevel !== 'none') {
|
|
|
94
95
|
}
|
|
95
96
|
```
|
|
96
97
|
|
|
98
|
+
### Inner-hop verification (MCP → REST dedupe with X-Astra-Verified-Hop)
|
|
99
|
+
|
|
100
|
+
When an MCP tool calls an inner REST endpoint that ALSO runs the
|
|
101
|
+
verification gateway, two verify-access calls fire for the same agent in
|
|
102
|
+
the same logical request — audit gets noisy and you pay a doubled
|
|
103
|
+
round-trip. The `X-Astra-Verified-Hop` header marks the inner hop as
|
|
104
|
+
already-verified by the upstream so the inner middleware skips a
|
|
105
|
+
redundant verify-access call.
|
|
106
|
+
|
|
107
|
+
The MCP middleware emits the marker automatically on its outbound
|
|
108
|
+
response. Tool handlers calling inner REST hops need to forward it on
|
|
109
|
+
outgoing fetches; the inner middleware reads it via `parseVerifiedHop` +
|
|
110
|
+
`isVerifiedHopValidFor` and skips a duplicate verify-access if the
|
|
111
|
+
marker is fresh AND matches the agent claimed on the inner hop.
|
|
112
|
+
|
|
113
|
+
**Worked example — upstream MCP → inner REST hop:**
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
// === outer MCP server ===
|
|
117
|
+
import express from 'express';
|
|
118
|
+
import { createMcpMiddleware } from '@astrasyncai/verification-gateway/mcp';
|
|
119
|
+
|
|
120
|
+
const mcp = express();
|
|
121
|
+
mcp.use(express.json());
|
|
122
|
+
mcp.use(
|
|
123
|
+
createMcpMiddleware({
|
|
124
|
+
apiBaseUrl: 'https://astrasync.ai/api',
|
|
125
|
+
apiKey: process.env.ASTRASYNC_API_KEY,
|
|
126
|
+
counterpartyId: 'ASTRAE-mcp...',
|
|
127
|
+
toolGates: { start_checkout: 'standard' },
|
|
128
|
+
})
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
// MCP middleware sets X-Astra-Verified-Hop on the response automatically
|
|
132
|
+
// AND populates req.agentVerification. Tool handlers can read both.
|
|
133
|
+
mcp.post('/mcp', async (req, res) => {
|
|
134
|
+
const v = req.agentVerification!;
|
|
135
|
+
// Forward the verified-hop marker on outgoing inner-hop calls.
|
|
136
|
+
// Build it from the same fields the middleware uses on the response.
|
|
137
|
+
const { serializeVerifiedHop, MCP_VERIFIED_HOP_HEADER } =
|
|
138
|
+
await import('@astrasyncai/verification-gateway/mcp');
|
|
139
|
+
const hop = serializeVerifiedHop({
|
|
140
|
+
astraId: v.agent!.astraId,
|
|
141
|
+
sessionId: v.sessionId,
|
|
142
|
+
checkedAt: Date.now(),
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const inner = await fetch('http://internal/api/checkout/items', {
|
|
146
|
+
method: 'POST',
|
|
147
|
+
headers: {
|
|
148
|
+
'Content-Type': 'application/json',
|
|
149
|
+
'X-Astra-Id': v.agent!.astraId, // identity marker
|
|
150
|
+
[MCP_VERIFIED_HOP_HEADER]: hop, // verified-hop dedupe marker
|
|
151
|
+
},
|
|
152
|
+
body: JSON.stringify({ sku: 'sku_42' }),
|
|
153
|
+
});
|
|
154
|
+
res.status(inner.status).json(await inner.json());
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// === inner REST hop (same fleet) ===
|
|
158
|
+
import { createMiddleware } from '@astrasyncai/verification-gateway/express';
|
|
159
|
+
|
|
160
|
+
const rest = express();
|
|
161
|
+
rest.use(
|
|
162
|
+
createMiddleware({
|
|
163
|
+
apiBaseUrl: 'https://astrasync.ai/api',
|
|
164
|
+
apiKey: process.env.ASTRASYNC_API_KEY,
|
|
165
|
+
counterpartyId: 'ASTRAE-rest...',
|
|
166
|
+
trustVerifiedHop: true, // accept the dedupe marker
|
|
167
|
+
verifiedHopMaxAgeMs: 60_000, // 60s default; tighten for high-stakes
|
|
168
|
+
})
|
|
169
|
+
);
|
|
170
|
+
// Inner middleware reads X-Astra-Verified-Hop, validates via
|
|
171
|
+
// parseVerifiedHop + isVerifiedHopValidFor, and skips verify-access
|
|
172
|
+
// when the marker is fresh AND its astraId matches the X-Astra-Id on
|
|
173
|
+
// this request.
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Important:** the marker is NOT proof of identity by itself — pair it
|
|
177
|
+
with `X-Astra-Id` so the inner middleware can verify the marker matches
|
|
178
|
+
the claimed agent. The marker only gates the dedupe-skip decision.
|
|
179
|
+
|
|
97
180
|
## Access Levels
|
|
98
181
|
|
|
99
182
|
| Level | Description |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstraSyncGateway } from '../gateway/gateway.mjs';
|
|
2
|
-
import { A as AgentAction, I as InterceptResult, P as PDLSSContext, V as VerificationDecision } from '../types-
|
|
3
|
-
import '../types-
|
|
2
|
+
import { A as AgentAction, I as InterceptResult, P as PDLSSContext, V as VerificationDecision } from '../types-pU2O0BFq.mjs';
|
|
3
|
+
import '../types-BVp22KkN.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* PlatformAdapter Interface
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AstraSyncGateway } from '../gateway/gateway.js';
|
|
2
|
-
import { A as AgentAction, I as InterceptResult, P as PDLSSContext, V as VerificationDecision } from '../types-
|
|
3
|
-
import '../types-
|
|
2
|
+
import { A as AgentAction, I as InterceptResult, P as PDLSSContext, V as VerificationDecision } from '../types-DVCWReEN.js';
|
|
3
|
+
import '../types-BVp22KkN.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* PlatformAdapter Interface
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'express';
|
|
2
|
-
import '../types-
|
|
3
|
-
export { c as createMiddleware, a as extractAstraSyncCredentials } from '../express-
|
|
2
|
+
import '../types-BVp22KkN.mjs';
|
|
3
|
+
export { c as createMiddleware, a as extractAstraSyncCredentials } from '../express-4Vau6x6X.mjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'express';
|
|
2
|
-
import '../types-
|
|
3
|
-
export { c as createMiddleware, a as extractAstraSyncCredentials } from '../express-
|
|
2
|
+
import '../types-BVp22KkN.js';
|
|
3
|
+
export { c as createMiddleware, a as extractAstraSyncCredentials } from '../express-Nq-wWICa.js';
|
package/dist/adapters/express.js
CHANGED
|
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(express_exports);
|
|
|
28
28
|
// src/access-levels.ts
|
|
29
29
|
var ACCESS_LEVEL_HIERARCHY = {
|
|
30
30
|
none: 0,
|
|
31
|
-
|
|
31
|
+
restricted: 1,
|
|
32
32
|
"read-only": 2,
|
|
33
33
|
standard: 3,
|
|
34
34
|
full: 4,
|
|
@@ -47,7 +47,11 @@ function hasMinimumAccess(actual, required) {
|
|
|
47
47
|
// src/verify.ts
|
|
48
48
|
var DEFAULT_CONFIG = {
|
|
49
49
|
apiBaseUrl: "https://astrasync.ai/api",
|
|
50
|
-
|
|
50
|
+
// v2.3.9 (defect #30): default for unconfigured callers is `'none'` (no
|
|
51
|
+
// access). Pre-rename this defaulted to `'guidance'`, which combined with
|
|
52
|
+
// a route gated at `'guidance'` to silently let unverified traffic
|
|
53
|
+
// through (`hasMinimumAccess('guidance', 'guidance') === true`).
|
|
54
|
+
defaultAccessLevel: "none",
|
|
51
55
|
// minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
|
|
52
56
|
cacheTtl: 300,
|
|
53
57
|
// 5 minutes
|
|
@@ -140,7 +144,12 @@ function createGuidanceResponse(config, reason) {
|
|
|
140
144
|
};
|
|
141
145
|
return {
|
|
142
146
|
verified: false,
|
|
143
|
-
|
|
147
|
+
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
148
|
+
// Adapters additionally short-circuit on `verified === false` before
|
|
149
|
+
// the gate check, but the access level still has to be honest at the
|
|
150
|
+
// data layer so downstream consumers (SDK adapters in other languages,
|
|
151
|
+
// custom integrations) inherit the correct semantics.
|
|
152
|
+
accessLevel: "none",
|
|
144
153
|
guidance,
|
|
145
154
|
denialReasons: reason ? [reason] : ["No valid agent credentials provided"],
|
|
146
155
|
verifiedAt: /* @__PURE__ */ new Date()
|
|
@@ -267,7 +276,14 @@ async function verify(config, request) {
|
|
|
267
276
|
const aggregatedFailures = apiResponse.access?.failures;
|
|
268
277
|
const result2 = {
|
|
269
278
|
verified: false,
|
|
270
|
-
|
|
279
|
+
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
280
|
+
// Pre-rename this hardcoded `'guidance'`, which conflated with the
|
|
281
|
+
// colocated `guidance: {...}` help-payload object below and let
|
|
282
|
+
// denied requests pass any route gated at `'guidance'` because
|
|
283
|
+
// `hasMinimumAccess('guidance', 'guidance') === true`. Adapters now
|
|
284
|
+
// ALSO short-circuit on `verified === false` before the gate check —
|
|
285
|
+
// belt-and-braces.
|
|
286
|
+
accessLevel: "none",
|
|
271
287
|
denialReasons: aggregatedFailures && aggregatedFailures.length > 0 ? aggregatedFailures.map((f) => f.message) : apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"],
|
|
272
288
|
failures: aggregatedFailures,
|
|
273
289
|
requiresStepUp: apiResponse.access?.requiresStepUp,
|
|
@@ -280,6 +296,9 @@ async function verify(config, request) {
|
|
|
280
296
|
verifiedAt: /* @__PURE__ */ new Date(),
|
|
281
297
|
// Extract sessionId so decisions can be recorded for denials too
|
|
282
298
|
sessionId: apiResponse.sessionId,
|
|
299
|
+
// v2.3.10 (defect #34, round-4): anonymous traffic has no session →
|
|
300
|
+
// correlationId is the linking key for paired local_override events.
|
|
301
|
+
correlationId: apiResponse.correlationId,
|
|
283
302
|
recommendation: apiResponse.recommendation,
|
|
284
303
|
recommendationReasons: apiResponse.recommendationReasons
|
|
285
304
|
};
|
|
@@ -320,6 +339,9 @@ async function verify(config, request) {
|
|
|
320
339
|
cacheTtl: mergedConfig.cacheTtl,
|
|
321
340
|
// Handshake Protocol v10 enhanced fields (present when backend returns them)
|
|
322
341
|
sessionId: apiResponse.sessionId,
|
|
342
|
+
// v2.3.10 (defect #34, round-4): anonymous responses surface correlationId
|
|
343
|
+
// (no session row exists for unverified callers).
|
|
344
|
+
correlationId: apiResponse.correlationId,
|
|
323
345
|
runtimeChallenge: apiResponse.runtimeChallenge,
|
|
324
346
|
tokenGuidance: apiResponse.tokenGuidance,
|
|
325
347
|
recommendation: apiResponse.recommendation,
|
|
@@ -351,7 +373,7 @@ async function verify(config, request) {
|
|
|
351
373
|
}
|
|
352
374
|
return result;
|
|
353
375
|
}
|
|
354
|
-
async function recordDecision(config, sessionId, decision, reason) {
|
|
376
|
+
async function recordDecision(config, sessionId, decision, reason, override) {
|
|
355
377
|
const headers = { "Content-Type": "application/json" };
|
|
356
378
|
if (config.apiKey) {
|
|
357
379
|
headers["Authorization"] = `Bearer ${config.apiKey}`;
|
|
@@ -360,7 +382,16 @@ async function recordDecision(config, sessionId, decision, reason) {
|
|
|
360
382
|
await fetch(`${config.apiBaseUrl}/agents/verify-access/${sessionId}/decision`, {
|
|
361
383
|
method: "POST",
|
|
362
384
|
headers,
|
|
363
|
-
body: JSON.stringify({
|
|
385
|
+
body: JSON.stringify({
|
|
386
|
+
decision,
|
|
387
|
+
reason,
|
|
388
|
+
...override && {
|
|
389
|
+
overriddenBy: override.overriddenBy,
|
|
390
|
+
toolName: override.toolName,
|
|
391
|
+
requestedLevel: override.requestedLevel,
|
|
392
|
+
grantedLevel: override.grantedLevel
|
|
393
|
+
}
|
|
394
|
+
})
|
|
364
395
|
}).catch(() => {
|
|
365
396
|
});
|
|
366
397
|
}
|
|
@@ -674,6 +705,14 @@ function createMiddleware(options) {
|
|
|
674
705
|
});
|
|
675
706
|
req.agentVerification = result;
|
|
676
707
|
const sessionId = result.sessionId;
|
|
708
|
+
if (!result.verified) {
|
|
709
|
+
if (shouldRecordDecisions && sessionId) {
|
|
710
|
+
recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
onDenied(result, req, res);
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
677
716
|
if (!hasMinimumAccess(result.accessLevel, routeConfig.minAccessLevel)) {
|
|
678
717
|
if (shouldRecordDecisions && sessionId) {
|
|
679
718
|
recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
|