@astrasyncai/verification-gateway 4.6.0 → 5.1.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.
- 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 +25 -35
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +25 -35
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +2 -2
- package/dist/adapters/mcp.d.ts +2 -2
- package/dist/adapters/mcp.js +42 -67
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +41 -66
- 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 +23 -32
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +23 -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 +22 -126
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +22 -124
- 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/agent/index.js +1 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +1 -1
- package/dist/agent/index.mjs.map +1 -1
- package/dist/bin/astrasync-claude-hook.js +23 -31
- package/dist/bin/astrasync-codex-hook.js +23 -31
- package/dist/bin/astrasync-guard.js +23 -31
- package/dist/bin/astrasync.js +28 -36
- package/dist/browser/background.js +23 -31
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +23 -31
- 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/claude-code/claude-code-adapter.d.mts +2 -2
- package/dist/claude-code/claude-code-adapter.d.ts +2 -2
- package/dist/cli/index.d.mts +2 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/codex/index.d.mts +2 -2
- package/dist/codex/index.d.ts +2 -2
- package/dist/codex/index.js +23 -31
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +23 -31
- package/dist/codex/index.mjs.map +1 -1
- 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 +23 -31
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +23 -31
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/edge-config.d.mts +1 -1
- package/dist/edge-config.d.ts +1 -1
- package/dist/edge-config.js +1 -1
- package/dist/edge-config.js.map +1 -1
- package/dist/edge-config.mjs +1 -1
- package/dist/edge-config.mjs.map +1 -1
- package/dist/edge-core/index.d.mts +12 -3
- package/dist/edge-core/index.d.ts +12 -3
- package/dist/edge-core/index.js +42 -36
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +42 -36
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/{express-DBtPKXOL.d.mts → express-KkBZBMqi.d.mts} +1 -1
- package/dist/{express-D-8Ks2Uo.d.ts → express-xK8pRrmj.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 +23 -31
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +23 -31
- 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-kGCGWd5x.d.mts → index-DIRzR5IS.d.mts} +1 -1
- package/dist/{index-DlZORQsb.d.ts → index-DLQ4Rcuc.d.ts} +1 -1
- package/dist/{index-CUfmJ1Dq.d.mts → index-GPDn_EGI.d.mts} +1 -1
- package/dist/{index-BND3kQev.d.ts → index-Hnz5VyMR.d.ts} +1 -1
- package/dist/index.d.mts +14 -10
- package/dist/index.d.ts +14 -10
- package/dist/index.js +44 -219
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -212
- 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/local-evaluator/evaluator.js.map +1 -1
- package/dist/local-evaluator/evaluator.mjs.map +1 -1
- package/dist/{mcp-DToTlwIn.d.ts → mcp-DPpu4xQz.d.ts} +53 -52
- package/dist/{mcp-ZRN4kY3b.d.mts → mcp-Dju_Sr1o.d.mts} +53 -52
- package/dist/{nextjs-C0KASOy_.d.mts → nextjs-BuoDBN4g.d.mts} +1 -1
- package/dist/{nextjs-lwNvWYWT.d.ts → nextjs-rZKzY_8o.d.ts} +1 -1
- package/dist/registration/index.js +1 -1
- package/dist/registration/index.js.map +1 -1
- package/dist/registration/index.mjs +1 -1
- package/dist/registration/index.mjs.map +1 -1
- package/dist/sdk-CdO6TIEf.d.mts +142 -0
- package/dist/sdk-DxHuIJBm.d.ts +142 -0
- package/dist/transport/index.d.mts +2 -2
- package/dist/transport/index.d.ts +2 -2
- package/dist/transport/index.js +1 -1
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +1 -1
- package/dist/transport/index.mjs.map +1 -1
- package/dist/{types-DhhJxKIC.d.ts → types-3UV7IZx7.d.ts} +1 -3
- package/dist/{types-CGPU7HLi.d.ts → types-CNBaZKxY.d.ts} +24 -50
- package/dist/{types-Cx9hTpKI.d.mts → types-CSHcByFX.d.mts} +24 -50
- package/dist/{types-CfSJLS4i.d.mts → types-CoDjpbVY.d.mts} +1 -3
- package/dist/ui/index.d.mts +2 -17
- package/dist/ui/index.d.ts +2 -17
- package/dist/ui/index.js +1 -43
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/index.mjs +1 -42
- package/dist/ui/index.mjs.map +1 -1
- package/dist/verify.d.mts +3 -4
- package/dist/verify.d.ts +3 -4
- package/dist/verify.js +22 -30
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +22 -30
- package/dist/verify.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/sdk-B4aodEwj.d.ts +0 -215
- package/dist/sdk-B9dSwum7.d.mts +0 -215
package/dist/adapters/mcp.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'express';
|
|
2
|
-
import '../types-
|
|
3
|
-
export { M as MCP_VERIFIED_HOP_HEADER, b as McpMiddlewareOptions, P as ParsedMcpRequest, T as
|
|
2
|
+
import '../types-CSHcByFX.mjs';
|
|
3
|
+
export { M as MCP_VERIFIED_HOP_HEADER, b as McpMiddlewareOptions, P as ParsedMcpRequest, T as ToolGate, c as ToolGateConfig, d as createMcpMiddleware, i as isVerifiedHopValidFor, m as mcpDefaultEnforced, e as mcpToPdlss, p as parseMcpJsonRpc, f as parseVerifiedHop, s as serializeVerifiedHop } from '../mcp-Dju_Sr1o.mjs';
|
|
4
4
|
import '../metadata-capture.mjs';
|
package/dist/adapters/mcp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'express';
|
|
2
|
-
import '../types-
|
|
3
|
-
export { M as MCP_VERIFIED_HOP_HEADER, b as McpMiddlewareOptions, P as ParsedMcpRequest, T as
|
|
2
|
+
import '../types-CNBaZKxY.js';
|
|
3
|
+
export { M as MCP_VERIFIED_HOP_HEADER, b as McpMiddlewareOptions, P as ParsedMcpRequest, T as ToolGate, c as ToolGateConfig, d as createMcpMiddleware, i as isVerifiedHopValidFor, m as mcpDefaultEnforced, e as mcpToPdlss, p as parseMcpJsonRpc, f as parseVerifiedHop, s as serializeVerifiedHop } from '../mcp-DPpu4xQz.js';
|
|
4
4
|
import '../metadata-capture.js';
|
package/dist/adapters/mcp.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(mcp_exports, {
|
|
|
23
23
|
MCP_VERIFIED_HOP_HEADER: () => MCP_VERIFIED_HOP_HEADER,
|
|
24
24
|
createMcpMiddleware: () => createMcpMiddleware,
|
|
25
25
|
isVerifiedHopValidFor: () => isVerifiedHopValidFor,
|
|
26
|
-
|
|
26
|
+
mcpDefaultEnforced: () => mcpDefaultEnforced,
|
|
27
27
|
mcpToPdlss: () => mcpToPdlss,
|
|
28
28
|
parseMcpJsonRpc: () => parseMcpJsonRpc,
|
|
29
29
|
parseVerifiedHop: () => parseVerifiedHop,
|
|
@@ -32,7 +32,7 @@ __export(mcp_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(mcp_exports);
|
|
33
33
|
|
|
34
34
|
// src/version.ts
|
|
35
|
-
var SDK_VERSION = "
|
|
35
|
+
var SDK_VERSION = "5.0.0";
|
|
36
36
|
|
|
37
37
|
// src/http.ts
|
|
38
38
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -52,7 +52,7 @@ function withUserAgent(initHeaders) {
|
|
|
52
52
|
}
|
|
53
53
|
var sdkFetch = (input, init) => fetch(input, { ...init, headers: withUserAgent(init?.headers) });
|
|
54
54
|
|
|
55
|
-
// src/
|
|
55
|
+
// src/trust-levels.ts
|
|
56
56
|
function getTrustLevel(score) {
|
|
57
57
|
if (score >= 80) return "PLATINUM";
|
|
58
58
|
if (score >= 60) return "GOLD";
|
|
@@ -122,11 +122,6 @@ function getCachedWellKnownUrls(apiBaseUrl) {
|
|
|
122
122
|
// src/verify.ts
|
|
123
123
|
var DEFAULT_CONFIG = {
|
|
124
124
|
apiBaseUrl: "https://astrasync.ai/api",
|
|
125
|
-
// v2.3.9 (defect #30): default for unconfigured callers is `'none'` (no
|
|
126
|
-
// access). Pre-rename this defaulted to `'guidance'`, which combined with
|
|
127
|
-
// a route gated at `'guidance'` to silently let unverified traffic
|
|
128
|
-
// through (`hasMinimumAccess('guidance', 'guidance') === true`).
|
|
129
|
-
defaultAccessLevel: "none",
|
|
130
125
|
// minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
|
|
131
126
|
// cacheTtl deliberately unset. When undefined, cacheResult applies the 60s
|
|
132
127
|
// default; the caller's explicit value is honoured for cacheable results.
|
|
@@ -283,6 +278,14 @@ function extractCredentials(headers, query) {
|
|
|
283
278
|
}
|
|
284
279
|
return credentials;
|
|
285
280
|
}
|
|
281
|
+
function mcpGuidance(urls) {
|
|
282
|
+
if (!urls?.mcpEndpoint) return void 0;
|
|
283
|
+
return {
|
|
284
|
+
endpoint: urls.mcpEndpoint,
|
|
285
|
+
discoveryUrl: urls.mcpDiscoveryUrl,
|
|
286
|
+
message: "If you are operating inside an MCP-capable host (Claude, ChatGPT, Cursor, or any MCP client), add the AstraSync MCP connector instead of integrating these URLs by hand: registration through the connector is KEYLESS and HUMAN-APPROVED \u2014 your human approves in an in-chat card, and you never see, hold, or transmit an API key, password, or private key."
|
|
287
|
+
};
|
|
288
|
+
}
|
|
286
289
|
function createGuidanceResponse(_config, reason, options = {}) {
|
|
287
290
|
const source = options.source ?? "no_credentials";
|
|
288
291
|
const isApiError = source === "api_error";
|
|
@@ -309,11 +312,17 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
309
312
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
310
313
|
documentationUrl: urls?.documentationUrl ?? "",
|
|
311
314
|
steps: [
|
|
315
|
+
// MCP steering leads when the hosted bridge is advertised — the
|
|
316
|
+
// connector is the agent-actionable path (keyless, human-approved).
|
|
317
|
+
...urls?.mcpEndpoint ? [
|
|
318
|
+
`Fastest path (inside an MCP host): add the AstraSync MCP connector at ${urls.mcpEndpoint} \u2014 keyless, human-approved registration`
|
|
319
|
+
] : [],
|
|
312
320
|
"Register for an AstraSync account",
|
|
313
321
|
"Create and register your agent",
|
|
314
322
|
"Add your ASTRA-ID to request headers",
|
|
315
323
|
"Retry your request"
|
|
316
|
-
]
|
|
324
|
+
],
|
|
325
|
+
...mcpGuidance(urls) && { mcp: mcpGuidance(urls) }
|
|
317
326
|
};
|
|
318
327
|
return {
|
|
319
328
|
// Round-18 G4: createGuidanceResponse fires for unverified-agent path or
|
|
@@ -321,13 +330,6 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
321
330
|
// policy is not evaluated (we never reached the gate).
|
|
322
331
|
identityVerified: false,
|
|
323
332
|
policyAllowed: false,
|
|
324
|
-
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
325
|
-
// Adapters additionally short-circuit on `!identityVerified ||
|
|
326
|
-
// !policyAllowed` before the gate check, but the access level still has
|
|
327
|
-
// to be honest at the data layer so downstream consumers (SDK adapters
|
|
328
|
-
// in other languages, custom integrations) inherit the correct
|
|
329
|
-
// semantics.
|
|
330
|
-
accessLevel: "none",
|
|
331
333
|
guidance,
|
|
332
334
|
denialReasons: reason ? [reason] : ["No valid agent credentials provided"],
|
|
333
335
|
// Round-10 (#47, O5): on API-error fallback, surface a typed failure so
|
|
@@ -421,7 +423,6 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
421
423
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
|
|
422
424
|
access: {
|
|
423
425
|
allowed: false,
|
|
424
|
-
accessLevel: "none",
|
|
425
426
|
reason: "endpoint_deactivated",
|
|
426
427
|
failures: [
|
|
427
428
|
{
|
|
@@ -484,7 +485,7 @@ async function verify(config, request, options) {
|
|
|
484
485
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
485
486
|
deprecationWarningShown = true;
|
|
486
487
|
console.warn(
|
|
487
|
-
"[VerificationGateway] minTrustScore / minTrustScoreForFull are deprecated in v2.3.0 and have no effect. Server is now the single source of truth for access
|
|
488
|
+
"[VerificationGateway] minTrustScore / minTrustScoreForFull are deprecated in v2.3.0 and have no effect. Server is now the single source of truth for access decisions (verified ID + runtime challenge + PDLSS + trust score). To gate access to an endpoint, configure the endpoint's trust_score_requirement server-side."
|
|
488
489
|
);
|
|
489
490
|
}
|
|
490
491
|
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache) {
|
|
@@ -530,14 +531,6 @@ async function verify(config, request, options) {
|
|
|
530
531
|
const result2 = {
|
|
531
532
|
identityVerified: idVerifiedFromBackend,
|
|
532
533
|
policyAllowed: false,
|
|
533
|
-
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
534
|
-
// Pre-rename this hardcoded `'guidance'`, which conflated with the
|
|
535
|
-
// colocated `guidance: {...}` help-payload object below and let
|
|
536
|
-
// denied requests pass any route gated at `'guidance'` because
|
|
537
|
-
// `hasMinimumAccess('guidance', 'guidance') === true`. Adapters now
|
|
538
|
-
// ALSO short-circuit on `!identityVerified || !policyAllowed` before
|
|
539
|
-
// the gate check — belt-and-braces.
|
|
540
|
-
accessLevel: "none",
|
|
541
534
|
// 3.6.0: the server now emits top-level denialReasons on every deny
|
|
542
535
|
// path — prefer it verbatim; the failure-message reconstruction remains
|
|
543
536
|
// as the fallback for older backends.
|
|
@@ -548,7 +541,10 @@ async function verify(config, request, options) {
|
|
|
548
541
|
guidance: {
|
|
549
542
|
message: apiResponse.access?.reason || "Access denied by PDLSS policy",
|
|
550
543
|
registrationUrl: urls?.registrationUrl ?? "",
|
|
551
|
-
documentationUrl: urls?.documentationUrl ?? ""
|
|
544
|
+
documentationUrl: urls?.documentationUrl ?? "",
|
|
545
|
+
// 5.1.0: anonymous callers land on this branch — steer MCP-hosted
|
|
546
|
+
// agents to the connector (this is what the edge deny body surfaces).
|
|
547
|
+
...mcpGuidance(urls) && { mcp: mcpGuidance(urls) }
|
|
552
548
|
},
|
|
553
549
|
verifiedAt: /* @__PURE__ */ new Date(),
|
|
554
550
|
// Extract sessionId so decisions can be recorded for denials too
|
|
@@ -586,7 +582,6 @@ async function verify(config, request, options) {
|
|
|
586
582
|
trustScore: apiResponse.organization.trustScore
|
|
587
583
|
} : void 0;
|
|
588
584
|
const verificationContext = apiResponse.verificationContext;
|
|
589
|
-
const accessLevel = apiResponse.access?.accessLevel ?? "standard";
|
|
590
585
|
const result = {
|
|
591
586
|
// 4.5.0 (probe F1): read idVerified from verificationContext with the
|
|
592
587
|
// SAME absent⇒false default as the deny branch. The previous `!== false`
|
|
@@ -598,7 +593,6 @@ async function verify(config, request, options) {
|
|
|
598
593
|
// this load-bearing must never be defaulted on.
|
|
599
594
|
identityVerified: apiResponse.verificationContext?.idVerified === true,
|
|
600
595
|
policyAllowed: true,
|
|
601
|
-
accessLevel,
|
|
602
596
|
agent,
|
|
603
597
|
developer,
|
|
604
598
|
organization,
|
|
@@ -625,7 +619,6 @@ async function verify(config, request, options) {
|
|
|
625
619
|
};
|
|
626
620
|
if (result.recommendation === "deny") {
|
|
627
621
|
result.policyAllowed = false;
|
|
628
|
-
result.accessLevel = "none";
|
|
629
622
|
result.denialReasons = serverDenialReasons ?? result.recommendationReasons ?? ["Access denied by AstraSync recommendation"];
|
|
630
623
|
result.guidance = result.runtimeChallenge ? {
|
|
631
624
|
message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
|
|
@@ -1084,18 +1077,13 @@ function mcpToPdlss(parsed, requestPath, headerPurpose, headerAction, toolGate)
|
|
|
1084
1077
|
}
|
|
1085
1078
|
return { purpose, action, resource, purposeSource, actionSource };
|
|
1086
1079
|
}
|
|
1087
|
-
function
|
|
1088
|
-
if (parsed.isInitialize || parsed.method === "notifications/initialized") return
|
|
1089
|
-
if (parsed.isIntrospection) return
|
|
1090
|
-
|
|
1091
|
-
if (parsed.isToolCall) return "standard";
|
|
1092
|
-
return "standard";
|
|
1080
|
+
function mcpDefaultEnforced(parsed) {
|
|
1081
|
+
if (parsed.isInitialize || parsed.method === "notifications/initialized") return false;
|
|
1082
|
+
if (parsed.isIntrospection) return false;
|
|
1083
|
+
return true;
|
|
1093
1084
|
}
|
|
1094
1085
|
|
|
1095
1086
|
// src/adapters/mcp.ts
|
|
1096
|
-
function normalizeToolGate(gate) {
|
|
1097
|
-
return typeof gate === "string" ? { minAccessLevel: gate } : gate;
|
|
1098
|
-
}
|
|
1099
1087
|
function readSingleHeader(value) {
|
|
1100
1088
|
if (typeof value === "string") return value;
|
|
1101
1089
|
if (Array.isArray(value)) return value[0];
|
|
@@ -1148,7 +1136,6 @@ function defaultMcpDenied(result, req, res) {
|
|
|
1148
1136
|
code: !result.identityVerified ? -32e3 : -32001,
|
|
1149
1137
|
message: result.denialReasons?.[0] ?? "Access denied",
|
|
1150
1138
|
data: {
|
|
1151
|
-
accessLevel: result.accessLevel,
|
|
1152
1139
|
guidance: result.guidance,
|
|
1153
1140
|
// Round-10: aggregated per-dimension detail + correlation handle.
|
|
1154
1141
|
failures: result.failures,
|
|
@@ -1161,20 +1148,19 @@ function defaultMcpDenied(result, req, res) {
|
|
|
1161
1148
|
}
|
|
1162
1149
|
});
|
|
1163
1150
|
}
|
|
1164
|
-
function
|
|
1151
|
+
function resolveGate(parsed, opts) {
|
|
1165
1152
|
if (!parsed.toolName) {
|
|
1166
|
-
|
|
1167
|
-
|
|
1153
|
+
const methodGate = opts.methodGates?.[parsed.method];
|
|
1154
|
+
if (methodGate !== void 0) {
|
|
1155
|
+
return methodGate === "observe" ? { enforce: false, source: "methodGate" } : { enforce: true, config: methodGate, source: "methodGate" };
|
|
1168
1156
|
}
|
|
1169
|
-
return {
|
|
1157
|
+
return { enforce: false, source: "discovery_default" };
|
|
1170
1158
|
}
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
source: "toolGate"
|
|
1175
|
-
};
|
|
1159
|
+
const toolGate = opts.toolGates?.[parsed.toolName];
|
|
1160
|
+
if (toolGate !== void 0) {
|
|
1161
|
+
return toolGate === "observe" ? { enforce: false, source: "toolGate" } : { enforce: true, config: toolGate, source: "toolGate" };
|
|
1176
1162
|
}
|
|
1177
|
-
return {
|
|
1163
|
+
return { enforce: mcpDefaultEnforced(parsed), source: "tier" };
|
|
1178
1164
|
}
|
|
1179
1165
|
function createMcpMiddleware(options) {
|
|
1180
1166
|
const {
|
|
@@ -1194,15 +1180,6 @@ function createMcpMiddleware(options) {
|
|
|
1194
1180
|
prefetchWellKnown(config.apiBaseUrl).catch(() => {
|
|
1195
1181
|
});
|
|
1196
1182
|
}
|
|
1197
|
-
if (toolGates) {
|
|
1198
|
-
for (const [toolName, gate] of Object.entries(toolGates)) {
|
|
1199
|
-
if (typeof gate === "string") {
|
|
1200
|
-
console.warn(
|
|
1201
|
-
`[VerificationGateway/MCP] toolGates['${toolName}'] uses the bare-string shorthand ('${gate}'). Gated tools need a PDLSS purpose (else PDLSS_PURPOSE_REQUIRED 400) and evaluate purpose-only without a declared action. Use the object form instead: { minAccessLevel: '${gate}', purpose: '...', action: '...' }.`
|
|
1202
|
-
);
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
1183
|
return async (req, res, next) => {
|
|
1207
1184
|
try {
|
|
1208
1185
|
if (skip) return next();
|
|
@@ -1251,7 +1228,7 @@ function createMcpMiddleware(options) {
|
|
|
1251
1228
|
return next();
|
|
1252
1229
|
}
|
|
1253
1230
|
}
|
|
1254
|
-
const
|
|
1231
|
+
const gateDecision = resolveGate(parsed, {
|
|
1255
1232
|
toolGates,
|
|
1256
1233
|
methodGates
|
|
1257
1234
|
});
|
|
@@ -1260,16 +1237,15 @@ function createMcpMiddleware(options) {
|
|
|
1260
1237
|
req.query
|
|
1261
1238
|
);
|
|
1262
1239
|
if (effectiveAstraId) credentials.astraId = effectiveAstraId;
|
|
1263
|
-
const shouldEnforce =
|
|
1264
|
-
if (
|
|
1240
|
+
const shouldEnforce = gateDecision.enforce;
|
|
1241
|
+
if (!shouldEnforce && (!config.evaluateAlwaysIfCredentialed || !credentials.astraId)) {
|
|
1265
1242
|
if (config.setPassThroughHeader) {
|
|
1266
1243
|
res.setHeader("X-Astra-Gateway-Mode", "unenforced");
|
|
1267
|
-
res.setHeader("X-Astra-Gateway-Reason", "mcp-
|
|
1244
|
+
res.setHeader("X-Astra-Gateway-Reason", "mcp-observe");
|
|
1268
1245
|
}
|
|
1269
1246
|
return next();
|
|
1270
1247
|
}
|
|
1271
|
-
const
|
|
1272
|
-
const gate = rawGate ? normalizeToolGate(rawGate) : void 0;
|
|
1248
|
+
const gate = gateDecision.config;
|
|
1273
1249
|
const headerPurpose = readSingleHeader(req.headers["x-astra-purpose"]);
|
|
1274
1250
|
const headerAction = readSingleHeader(req.headers["x-astra-action"]);
|
|
1275
1251
|
const pdlss = mcpToPdlss(
|
|
@@ -1405,7 +1381,6 @@ function createMcpMiddleware(options) {
|
|
|
1405
1381
|
const result = {
|
|
1406
1382
|
identityVerified: false,
|
|
1407
1383
|
policyAllowed: false,
|
|
1408
|
-
accessLevel: "none",
|
|
1409
1384
|
denialReasons: [`MCP middleware internal error: ${errorClass}`],
|
|
1410
1385
|
failures: [
|
|
1411
1386
|
{
|
|
@@ -1436,7 +1411,7 @@ function createMcpMiddleware(options) {
|
|
|
1436
1411
|
MCP_VERIFIED_HOP_HEADER,
|
|
1437
1412
|
createMcpMiddleware,
|
|
1438
1413
|
isVerifiedHopValidFor,
|
|
1439
|
-
|
|
1414
|
+
mcpDefaultEnforced,
|
|
1440
1415
|
mcpToPdlss,
|
|
1441
1416
|
parseMcpJsonRpc,
|
|
1442
1417
|
parseVerifiedHop,
|