@astrasyncai/verification-gateway 2.4.8 → 2.4.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/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 +81 -31
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +81 -31
- 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 +64 -26
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +64 -26
- 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 +89 -32
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +89 -32
- 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 +65 -25
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +65 -25
- 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 +60 -25
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +60 -25
- 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 +60 -25
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +60 -25
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/{express-DvVjR2H4.d.mts → express-4WStX3PV.d.mts} +1 -1
- package/dist/{express-714gJbaW.d.ts → express-C1ePFB7n.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 +60 -25
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +60 -25
- 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-DYFS9QVb.d.mts → index-ChPX4WHl.d.mts} +1 -1
- package/dist/{index-DO0oG8ED.d.ts → index-Cjm-zBeZ.d.ts} +1 -1
- package/dist/{index-2WAlxs2G.d.ts → index-CzJMCgEy.d.ts} +1 -1
- package/dist/{index-P9t7M_dJ.d.mts → index-D8IEntil.d.mts} +1 -1
- package/dist/index.d.mts +22 -11
- package/dist/index.d.ts +22 -11
- package/dist/index.js +133 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +132 -42
- 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-CZ-MwSOT.d.ts → nextjs-BIORS__0.d.ts} +1 -1
- package/dist/{nextjs-BCoH7EqF.d.mts → nextjs-CjzHdaXA.d.mts} +1 -1
- package/dist/registration/index.d.mts +76 -1
- package/dist/registration/index.d.ts +76 -1
- package/dist/registration/index.js +27 -2
- package/dist/registration/index.js.map +1 -1
- package/dist/registration/index.mjs +25 -1
- package/dist/registration/index.mjs.map +1 -1
- package/dist/{sdk-wwhFDXWX.d.mts → sdk-Chhz-FcT.d.mts} +9 -4
- package/dist/{sdk-kiA49vqJ.d.ts → sdk-CqTEQAc6.d.ts} +9 -4
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/{types-DOAb89cm.d.mts → types-DNK2BgIf.d.mts} +1 -1
- package/dist/{types-aucqzfUa.d.ts → types-DoWIuzfj.d.ts} +1 -1
- package/dist/{types-BwDmjIdr.d.mts → types-L15pYd2c.d.mts} +21 -4
- package/dist/{types-BwDmjIdr.d.ts → types-L15pYd2c.d.ts} +21 -4
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +1 -1
- package/dist/ui/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/adapters/mcp.js
CHANGED
|
@@ -51,7 +51,7 @@ function hasMinimumAccess(actual, required) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// src/version.ts
|
|
54
|
-
var SDK_VERSION = "2.4.
|
|
54
|
+
var SDK_VERSION = "2.4.10";
|
|
55
55
|
|
|
56
56
|
// src/verify.ts
|
|
57
57
|
var DEFAULT_CONFIG = {
|
|
@@ -62,8 +62,10 @@ var DEFAULT_CONFIG = {
|
|
|
62
62
|
// through (`hasMinimumAccess('guidance', 'guidance') === true`).
|
|
63
63
|
defaultAccessLevel: "none",
|
|
64
64
|
// minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
|
|
65
|
-
|
|
66
|
-
//
|
|
65
|
+
// Round-18.5 F4: cacheTtl deliberately unset. When undefined, cacheResult
|
|
66
|
+
// applies the split default (60s autonomous / 300s step-up). When the
|
|
67
|
+
// caller sets cacheTtl explicitly, that value is honoured uniformly.
|
|
68
|
+
// Set cacheTtl: 0 to disable caching entirely.
|
|
67
69
|
debug: false
|
|
68
70
|
};
|
|
69
71
|
var initCheckPerformed = false;
|
|
@@ -90,11 +92,28 @@ async function performInitCheck(apiBaseUrl, debug) {
|
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
var verificationCache = /* @__PURE__ */ new Map();
|
|
93
|
-
function getCacheKey(
|
|
94
|
-
|
|
95
|
+
function getCacheKey(request) {
|
|
96
|
+
const c = request.credentials;
|
|
97
|
+
return [
|
|
98
|
+
c.astraId || "",
|
|
99
|
+
c.apiKey || "",
|
|
100
|
+
c.jwt || "",
|
|
101
|
+
request.purpose || "",
|
|
102
|
+
request.action || "",
|
|
103
|
+
request.resourceType || "",
|
|
104
|
+
request.resource || "",
|
|
105
|
+
request.jurisdiction || "",
|
|
106
|
+
request.transactionValue ?? "",
|
|
107
|
+
request.currency || "",
|
|
108
|
+
request.counterpartyUrl || "",
|
|
109
|
+
request.counterpartyType || "",
|
|
110
|
+
request.isSubAgentRequest ? "1" : "0",
|
|
111
|
+
request.parentAgentId || "",
|
|
112
|
+
request.subAgentDepth ?? ""
|
|
113
|
+
].join("|");
|
|
95
114
|
}
|
|
96
|
-
function getCachedResult(
|
|
97
|
-
const key = getCacheKey(
|
|
115
|
+
function getCachedResult(request) {
|
|
116
|
+
const key = getCacheKey(request);
|
|
98
117
|
const cached = verificationCache.get(key);
|
|
99
118
|
if (cached && cached.expiresAt > Date.now()) {
|
|
100
119
|
return cached.result;
|
|
@@ -104,8 +123,11 @@ function getCachedResult(credentials) {
|
|
|
104
123
|
}
|
|
105
124
|
return null;
|
|
106
125
|
}
|
|
107
|
-
|
|
108
|
-
|
|
126
|
+
var DEFAULT_AUTONOMOUS_TTL_SECONDS = 60;
|
|
127
|
+
var DEFAULT_STEP_UP_TTL_SECONDS = 300;
|
|
128
|
+
function cacheResult(request, result, configuredTtl) {
|
|
129
|
+
const ttlSeconds = configuredTtl && configuredTtl > 0 ? configuredTtl : result.requiresStepUp ? DEFAULT_STEP_UP_TTL_SECONDS : DEFAULT_AUTONOMOUS_TTL_SECONDS;
|
|
130
|
+
const key = getCacheKey(request);
|
|
109
131
|
verificationCache.set(key, {
|
|
110
132
|
result,
|
|
111
133
|
expiresAt: Date.now() + ttlSeconds * 1e3
|
|
@@ -162,12 +184,17 @@ function createGuidanceResponse(config, reason, options = {}) {
|
|
|
162
184
|
]
|
|
163
185
|
};
|
|
164
186
|
return {
|
|
165
|
-
|
|
187
|
+
// Round-18 G4: createGuidanceResponse fires for unverified-agent path or
|
|
188
|
+
// API-error fallback. Identity is not verified (no agent resolved);
|
|
189
|
+
// policy is not evaluated (we never reached the gate).
|
|
190
|
+
identityVerified: false,
|
|
191
|
+
policyAllowed: false,
|
|
166
192
|
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
167
|
-
// Adapters additionally short-circuit on
|
|
168
|
-
// the gate check, but the access level still has
|
|
169
|
-
// data layer so downstream consumers (SDK adapters
|
|
170
|
-
// custom integrations) inherit the correct
|
|
193
|
+
// Adapters additionally short-circuit on `!identityVerified ||
|
|
194
|
+
// !policyAllowed` before the gate check, but the access level still has
|
|
195
|
+
// to be honest at the data layer so downstream consumers (SDK adapters
|
|
196
|
+
// in other languages, custom integrations) inherit the correct
|
|
197
|
+
// semantics.
|
|
171
198
|
accessLevel: "none",
|
|
172
199
|
guidance,
|
|
173
200
|
denialReasons: reason ? [reason] : ["No valid agent credentials provided"],
|
|
@@ -283,8 +310,8 @@ async function verify(config, request) {
|
|
|
283
310
|
"[VerificationGateway] minTrustScore / minTrustScoreForFull are deprecated in v2.3.0 and have no effect. Server is now the single source of truth for access-level decisions (the SDK reads access.accessLevel from the verify-access response). To gate access to an endpoint, configure the endpoint's trust_score_requirement server-side."
|
|
284
311
|
);
|
|
285
312
|
}
|
|
286
|
-
if (mergedConfig.cacheTtl
|
|
287
|
-
const cached = getCachedResult(request
|
|
313
|
+
if (mergedConfig.cacheTtl !== 0) {
|
|
314
|
+
const cached = getCachedResult(request);
|
|
288
315
|
if (cached) {
|
|
289
316
|
if (mergedConfig.debug) {
|
|
290
317
|
console.log("[VerificationGateway] Returning cached result");
|
|
@@ -311,15 +338,17 @@ async function verify(config, request) {
|
|
|
311
338
|
}
|
|
312
339
|
if (!apiResponse.access?.allowed) {
|
|
313
340
|
const aggregatedFailures = apiResponse.access?.failures;
|
|
341
|
+
const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true;
|
|
314
342
|
const result2 = {
|
|
315
|
-
|
|
343
|
+
identityVerified: idVerifiedFromBackend,
|
|
344
|
+
policyAllowed: false,
|
|
316
345
|
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
317
346
|
// Pre-rename this hardcoded `'guidance'`, which conflated with the
|
|
318
347
|
// colocated `guidance: {...}` help-payload object below and let
|
|
319
348
|
// denied requests pass any route gated at `'guidance'` because
|
|
320
349
|
// `hasMinimumAccess('guidance', 'guidance') === true`. Adapters now
|
|
321
|
-
// ALSO short-circuit on
|
|
322
|
-
// belt-and-braces.
|
|
350
|
+
// ALSO short-circuit on `!identityVerified || !policyAllowed` before
|
|
351
|
+
// the gate check — belt-and-braces.
|
|
323
352
|
accessLevel: "none",
|
|
324
353
|
denialReasons: aggregatedFailures && aggregatedFailures.length > 0 ? aggregatedFailures.map((f) => f.message) : apiResponse.access?.reason ? [apiResponse.access.reason] : ["Access denied"],
|
|
325
354
|
failures: aggregatedFailures,
|
|
@@ -363,7 +392,13 @@ async function verify(config, request) {
|
|
|
363
392
|
const verificationContext = apiResponse.verificationContext;
|
|
364
393
|
const accessLevel = apiResponse.access?.accessLevel ?? "standard";
|
|
365
394
|
const result = {
|
|
366
|
-
|
|
395
|
+
// Round-18 G4: backend allowed access. Identity is verified (we resolved
|
|
396
|
+
// the caller to an agent) and policy passed all gates. Read idVerified
|
|
397
|
+
// from verificationContext for symmetry with the deny branch; default true
|
|
398
|
+
// on success path since `access.allowed === true` implies identity was
|
|
399
|
+
// resolvable (anonymous-allow paths flow through createGuidanceResponse).
|
|
400
|
+
identityVerified: apiResponse.verificationContext?.idVerified !== false,
|
|
401
|
+
policyAllowed: true,
|
|
367
402
|
accessLevel,
|
|
368
403
|
agent,
|
|
369
404
|
developer,
|
|
@@ -386,7 +421,7 @@ async function verify(config, request) {
|
|
|
386
421
|
warningHeader: apiResponse.warningHeader
|
|
387
422
|
};
|
|
388
423
|
if (result.recommendation === "deny") {
|
|
389
|
-
result.
|
|
424
|
+
result.policyAllowed = false;
|
|
390
425
|
result.accessLevel = "none";
|
|
391
426
|
result.denialReasons = result.recommendationReasons || [
|
|
392
427
|
"Access denied by AstraSync recommendation"
|
|
@@ -405,8 +440,8 @@ async function verify(config, request) {
|
|
|
405
440
|
}
|
|
406
441
|
result.denialReasons = result.recommendationReasons || ["Step-up verification required"];
|
|
407
442
|
}
|
|
408
|
-
if (mergedConfig.cacheTtl
|
|
409
|
-
cacheResult(request
|
|
443
|
+
if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny") {
|
|
444
|
+
cacheResult(request, result, mergedConfig.cacheTtl);
|
|
410
445
|
}
|
|
411
446
|
return result;
|
|
412
447
|
}
|
|
@@ -576,13 +611,16 @@ function readSingleHeader(value) {
|
|
|
576
611
|
}
|
|
577
612
|
function defaultMcpDenied(result, req, res) {
|
|
578
613
|
const id = req.body?.id ?? null;
|
|
579
|
-
const status = result.
|
|
614
|
+
const status = !result.identityVerified ? 401 : 403;
|
|
580
615
|
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
581
616
|
res.status(status).json({
|
|
582
617
|
jsonrpc: "2.0",
|
|
583
618
|
id,
|
|
584
619
|
error: {
|
|
585
|
-
|
|
620
|
+
// JSON-RPC error codes:
|
|
621
|
+
// -32000 → unauthorized (no identity resolved)
|
|
622
|
+
// -32001 → insufficient access (identity OK, policy denied)
|
|
623
|
+
code: !result.identityVerified ? -32e3 : -32001,
|
|
586
624
|
message: result.denialReasons?.[0] ?? "Access denied",
|
|
587
625
|
data: {
|
|
588
626
|
accessLevel: result.accessLevel,
|
|
@@ -716,7 +754,7 @@ function createMcpMiddleware(options) {
|
|
|
716
754
|
req.agentVerification = result;
|
|
717
755
|
const sessionId = result.sessionId;
|
|
718
756
|
const correlationId = result.correlationId;
|
|
719
|
-
if (!result.
|
|
757
|
+
if (!result.identityVerified || !result.policyAllowed) {
|
|
720
758
|
if (shouldRecordDecisions && sessionId) {
|
|
721
759
|
recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
|
|
722
760
|
});
|