@astrasyncai/verification-gateway 4.5.1 → 5.0.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/README.md +1 -1
- 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 +11 -33
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +11 -33
- 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 +28 -65
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +27 -64
- 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 +9 -30
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +9 -30
- 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 +8 -124
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +8 -122
- 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 +63 -41
- package/dist/bin/astrasync-codex-hook.js +63 -41
- package/dist/bin/astrasync-guard.js +63 -41
- package/dist/bin/astrasync.js +75 -48
- package/dist/browser/background.js +63 -41
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +63 -41
- 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 +33 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +33 -6
- 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 +63 -41
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +63 -41
- 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 +63 -41
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +63 -41
- 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 +1 -3
- package/dist/edge-core/index.d.ts +1 -3
- package/dist/edge-core/index.js +11 -33
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +11 -33
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/{express-DaqL11tx.d.ts → express-B5lWuemA.d.ts} +1 -1
- package/dist/{express-CR6F3njD.d.mts → express-Dm-snUuY.d.mts} +1 -1
- package/dist/gateway/gateway.d.mts +2 -2
- package/dist/gateway/gateway.d.ts +2 -2
- package/dist/gateway/gateway.js +63 -41
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +63 -41
- 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-Cub7lK-T.d.mts → index-B5k_vUmK.d.mts} +1 -1
- package/dist/{index-BfIxCYIZ.d.ts → index-BOzM6xUq.d.mts} +1 -2
- package/dist/{index-CwAh7Tln.d.mts → index-dRfxUdFA.d.ts} +1 -2
- package/dist/{index-B5Ts1WtM.d.ts → index-y8xToocF.d.ts} +1 -1
- package/dist/index.d.mts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +30 -217
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -210
- 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 +22 -7
- package/dist/local-evaluator/evaluator.js.map +1 -1
- package/dist/local-evaluator/evaluator.mjs +22 -7
- package/dist/local-evaluator/evaluator.mjs.map +1 -1
- package/dist/{mcp-BgBJu4Jl.d.mts → mcp-DgsyQiQq.d.mts} +53 -52
- package/dist/{mcp--DgKOwfu.d.ts → mcp-OosmAcKf.d.ts} +53 -52
- package/dist/{nextjs-DlX6xwbU.d.mts → nextjs-B1sBdEav.d.mts} +1 -1
- package/dist/{nextjs-DL6uE1ye.d.ts → nextjs-DoRmhV_Z.d.ts} +1 -1
- package/dist/registration/index.d.mts +5 -1
- package/dist/registration/index.d.ts +5 -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-B83N3xKc.d.mts +142 -0
- package/dist/sdk-H_9BTNBS.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-DwSfO7Sb.d.ts → types-BK2POWNc.d.ts} +23 -50
- package/dist/{types-C0zfSXMB.d.mts → types-CJjZvPr9.d.mts} +23 -50
- package/dist/{types-C7Rb-w0d.d.mts → types-CXf3q4kZ.d.ts} +14 -3
- package/dist/{types-nIh3HtuA.d.ts → types-DQmop7ZW.d.mts} +14 -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 +8 -28
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +8 -28
- package/dist/verify.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/sdk-Bbh9B_dw.d.mts +0 -215
- package/dist/sdk-C6SASmsh.d.ts +0 -215
package/dist/adapters/mcp.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = "
|
|
2
|
+
var SDK_VERSION = "5.0.0";
|
|
3
3
|
|
|
4
4
|
// src/http.ts
|
|
5
5
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -19,7 +19,7 @@ function withUserAgent(initHeaders) {
|
|
|
19
19
|
}
|
|
20
20
|
var sdkFetch = (input, init) => fetch(input, { ...init, headers: withUserAgent(init?.headers) });
|
|
21
21
|
|
|
22
|
-
// src/
|
|
22
|
+
// src/trust-levels.ts
|
|
23
23
|
function getTrustLevel(score) {
|
|
24
24
|
if (score >= 80) return "PLATINUM";
|
|
25
25
|
if (score >= 60) return "GOLD";
|
|
@@ -89,11 +89,6 @@ function getCachedWellKnownUrls(apiBaseUrl) {
|
|
|
89
89
|
// src/verify.ts
|
|
90
90
|
var DEFAULT_CONFIG = {
|
|
91
91
|
apiBaseUrl: "https://astrasync.ai/api",
|
|
92
|
-
// v2.3.9 (defect #30): default for unconfigured callers is `'none'` (no
|
|
93
|
-
// access). Pre-rename this defaulted to `'guidance'`, which combined with
|
|
94
|
-
// a route gated at `'guidance'` to silently let unverified traffic
|
|
95
|
-
// through (`hasMinimumAccess('guidance', 'guidance') === true`).
|
|
96
|
-
defaultAccessLevel: "none",
|
|
97
92
|
// minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
|
|
98
93
|
// cacheTtl deliberately unset. When undefined, cacheResult applies the 60s
|
|
99
94
|
// default; the caller's explicit value is honoured for cacheable results.
|
|
@@ -288,13 +283,6 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
288
283
|
// policy is not evaluated (we never reached the gate).
|
|
289
284
|
identityVerified: false,
|
|
290
285
|
policyAllowed: false,
|
|
291
|
-
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
292
|
-
// Adapters additionally short-circuit on `!identityVerified ||
|
|
293
|
-
// !policyAllowed` before the gate check, but the access level still has
|
|
294
|
-
// to be honest at the data layer so downstream consumers (SDK adapters
|
|
295
|
-
// in other languages, custom integrations) inherit the correct
|
|
296
|
-
// semantics.
|
|
297
|
-
accessLevel: "none",
|
|
298
286
|
guidance,
|
|
299
287
|
denialReasons: reason ? [reason] : ["No valid agent credentials provided"],
|
|
300
288
|
// Round-10 (#47, O5): on API-error fallback, surface a typed failure so
|
|
@@ -317,6 +305,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
317
305
|
// 4.0.0: typed marker so adapters render the misconfig envelope (503 +
|
|
318
306
|
// MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
|
|
319
307
|
...isMisconfig && { misconfigured: true },
|
|
308
|
+
// 4.6.0: a transient api_error is retryable — mark it so consumers surface
|
|
309
|
+
// "temporarily unavailable, retry" (recommendation 'error') instead of
|
|
310
|
+
// coercing the absent recommendation to a policy 'deny'. Misconfig is
|
|
311
|
+
// deterministic and intentionally NOT marked retryable.
|
|
312
|
+
...isApiError && { retryable: true },
|
|
320
313
|
correlationId: options.correlationId,
|
|
321
314
|
attemptId: options.attemptId,
|
|
322
315
|
verifiedAt: /* @__PURE__ */ new Date()
|
|
@@ -383,7 +376,6 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
383
376
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
|
|
384
377
|
access: {
|
|
385
378
|
allowed: false,
|
|
386
|
-
accessLevel: "none",
|
|
387
379
|
reason: "endpoint_deactivated",
|
|
388
380
|
failures: [
|
|
389
381
|
{
|
|
@@ -446,7 +438,7 @@ async function verify(config, request, options) {
|
|
|
446
438
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
447
439
|
deprecationWarningShown = true;
|
|
448
440
|
console.warn(
|
|
449
|
-
"[VerificationGateway] minTrustScore / minTrustScoreForFull are deprecated in v2.3.0 and have no effect. Server is now the single source of truth for access
|
|
441
|
+
"[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."
|
|
450
442
|
);
|
|
451
443
|
}
|
|
452
444
|
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache) {
|
|
@@ -492,14 +484,6 @@ async function verify(config, request, options) {
|
|
|
492
484
|
const result2 = {
|
|
493
485
|
identityVerified: idVerifiedFromBackend,
|
|
494
486
|
policyAllowed: false,
|
|
495
|
-
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
496
|
-
// Pre-rename this hardcoded `'guidance'`, which conflated with the
|
|
497
|
-
// colocated `guidance: {...}` help-payload object below and let
|
|
498
|
-
// denied requests pass any route gated at `'guidance'` because
|
|
499
|
-
// `hasMinimumAccess('guidance', 'guidance') === true`. Adapters now
|
|
500
|
-
// ALSO short-circuit on `!identityVerified || !policyAllowed` before
|
|
501
|
-
// the gate check — belt-and-braces.
|
|
502
|
-
accessLevel: "none",
|
|
503
487
|
// 3.6.0: the server now emits top-level denialReasons on every deny
|
|
504
488
|
// path — prefer it verbatim; the failure-message reconstruction remains
|
|
505
489
|
// as the fallback for older backends.
|
|
@@ -548,7 +532,6 @@ async function verify(config, request, options) {
|
|
|
548
532
|
trustScore: apiResponse.organization.trustScore
|
|
549
533
|
} : void 0;
|
|
550
534
|
const verificationContext = apiResponse.verificationContext;
|
|
551
|
-
const accessLevel = apiResponse.access?.accessLevel ?? "standard";
|
|
552
535
|
const result = {
|
|
553
536
|
// 4.5.0 (probe F1): read idVerified from verificationContext with the
|
|
554
537
|
// SAME absent⇒false default as the deny branch. The previous `!== false`
|
|
@@ -560,7 +543,6 @@ async function verify(config, request, options) {
|
|
|
560
543
|
// this load-bearing must never be defaulted on.
|
|
561
544
|
identityVerified: apiResponse.verificationContext?.idVerified === true,
|
|
562
545
|
policyAllowed: true,
|
|
563
|
-
accessLevel,
|
|
564
546
|
agent,
|
|
565
547
|
developer,
|
|
566
548
|
organization,
|
|
@@ -587,7 +569,6 @@ async function verify(config, request, options) {
|
|
|
587
569
|
};
|
|
588
570
|
if (result.recommendation === "deny") {
|
|
589
571
|
result.policyAllowed = false;
|
|
590
|
-
result.accessLevel = "none";
|
|
591
572
|
result.denialReasons = serverDenialReasons ?? result.recommendationReasons ?? ["Access denied by AstraSync recommendation"];
|
|
592
573
|
result.guidance = result.runtimeChallenge ? {
|
|
593
574
|
message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
|
|
@@ -1046,18 +1027,13 @@ function mcpToPdlss(parsed, requestPath, headerPurpose, headerAction, toolGate)
|
|
|
1046
1027
|
}
|
|
1047
1028
|
return { purpose, action, resource, purposeSource, actionSource };
|
|
1048
1029
|
}
|
|
1049
|
-
function
|
|
1050
|
-
if (parsed.isInitialize || parsed.method === "notifications/initialized") return
|
|
1051
|
-
if (parsed.isIntrospection) return
|
|
1052
|
-
|
|
1053
|
-
if (parsed.isToolCall) return "standard";
|
|
1054
|
-
return "standard";
|
|
1030
|
+
function mcpDefaultEnforced(parsed) {
|
|
1031
|
+
if (parsed.isInitialize || parsed.method === "notifications/initialized") return false;
|
|
1032
|
+
if (parsed.isIntrospection) return false;
|
|
1033
|
+
return true;
|
|
1055
1034
|
}
|
|
1056
1035
|
|
|
1057
1036
|
// src/adapters/mcp.ts
|
|
1058
|
-
function normalizeToolGate(gate) {
|
|
1059
|
-
return typeof gate === "string" ? { minAccessLevel: gate } : gate;
|
|
1060
|
-
}
|
|
1061
1037
|
function readSingleHeader(value) {
|
|
1062
1038
|
if (typeof value === "string") return value;
|
|
1063
1039
|
if (Array.isArray(value)) return value[0];
|
|
@@ -1110,7 +1086,6 @@ function defaultMcpDenied(result, req, res) {
|
|
|
1110
1086
|
code: !result.identityVerified ? -32e3 : -32001,
|
|
1111
1087
|
message: result.denialReasons?.[0] ?? "Access denied",
|
|
1112
1088
|
data: {
|
|
1113
|
-
accessLevel: result.accessLevel,
|
|
1114
1089
|
guidance: result.guidance,
|
|
1115
1090
|
// Round-10: aggregated per-dimension detail + correlation handle.
|
|
1116
1091
|
failures: result.failures,
|
|
@@ -1123,20 +1098,19 @@ function defaultMcpDenied(result, req, res) {
|
|
|
1123
1098
|
}
|
|
1124
1099
|
});
|
|
1125
1100
|
}
|
|
1126
|
-
function
|
|
1101
|
+
function resolveGate(parsed, opts) {
|
|
1127
1102
|
if (!parsed.toolName) {
|
|
1128
|
-
|
|
1129
|
-
|
|
1103
|
+
const methodGate = opts.methodGates?.[parsed.method];
|
|
1104
|
+
if (methodGate !== void 0) {
|
|
1105
|
+
return methodGate === "observe" ? { enforce: false, source: "methodGate" } : { enforce: true, config: methodGate, source: "methodGate" };
|
|
1130
1106
|
}
|
|
1131
|
-
return {
|
|
1107
|
+
return { enforce: false, source: "discovery_default" };
|
|
1132
1108
|
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
source: "toolGate"
|
|
1137
|
-
};
|
|
1109
|
+
const toolGate = opts.toolGates?.[parsed.toolName];
|
|
1110
|
+
if (toolGate !== void 0) {
|
|
1111
|
+
return toolGate === "observe" ? { enforce: false, source: "toolGate" } : { enforce: true, config: toolGate, source: "toolGate" };
|
|
1138
1112
|
}
|
|
1139
|
-
return {
|
|
1113
|
+
return { enforce: mcpDefaultEnforced(parsed), source: "tier" };
|
|
1140
1114
|
}
|
|
1141
1115
|
function createMcpMiddleware(options) {
|
|
1142
1116
|
const {
|
|
@@ -1156,15 +1130,6 @@ function createMcpMiddleware(options) {
|
|
|
1156
1130
|
prefetchWellKnown(config.apiBaseUrl).catch(() => {
|
|
1157
1131
|
});
|
|
1158
1132
|
}
|
|
1159
|
-
if (toolGates) {
|
|
1160
|
-
for (const [toolName, gate] of Object.entries(toolGates)) {
|
|
1161
|
-
if (typeof gate === "string") {
|
|
1162
|
-
console.warn(
|
|
1163
|
-
`[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: '...' }.`
|
|
1164
|
-
);
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
1133
|
return async (req, res, next) => {
|
|
1169
1134
|
try {
|
|
1170
1135
|
if (skip) return next();
|
|
@@ -1213,7 +1178,7 @@ function createMcpMiddleware(options) {
|
|
|
1213
1178
|
return next();
|
|
1214
1179
|
}
|
|
1215
1180
|
}
|
|
1216
|
-
const
|
|
1181
|
+
const gateDecision = resolveGate(parsed, {
|
|
1217
1182
|
toolGates,
|
|
1218
1183
|
methodGates
|
|
1219
1184
|
});
|
|
@@ -1222,16 +1187,15 @@ function createMcpMiddleware(options) {
|
|
|
1222
1187
|
req.query
|
|
1223
1188
|
);
|
|
1224
1189
|
if (effectiveAstraId) credentials.astraId = effectiveAstraId;
|
|
1225
|
-
const shouldEnforce =
|
|
1226
|
-
if (
|
|
1190
|
+
const shouldEnforce = gateDecision.enforce;
|
|
1191
|
+
if (!shouldEnforce && (!config.evaluateAlwaysIfCredentialed || !credentials.astraId)) {
|
|
1227
1192
|
if (config.setPassThroughHeader) {
|
|
1228
1193
|
res.setHeader("X-Astra-Gateway-Mode", "unenforced");
|
|
1229
|
-
res.setHeader("X-Astra-Gateway-Reason", "mcp-
|
|
1194
|
+
res.setHeader("X-Astra-Gateway-Reason", "mcp-observe");
|
|
1230
1195
|
}
|
|
1231
1196
|
return next();
|
|
1232
1197
|
}
|
|
1233
|
-
const
|
|
1234
|
-
const gate = rawGate ? normalizeToolGate(rawGate) : void 0;
|
|
1198
|
+
const gate = gateDecision.config;
|
|
1235
1199
|
const headerPurpose = readSingleHeader(req.headers["x-astra-purpose"]);
|
|
1236
1200
|
const headerAction = readSingleHeader(req.headers["x-astra-action"]);
|
|
1237
1201
|
const pdlss = mcpToPdlss(
|
|
@@ -1367,7 +1331,6 @@ function createMcpMiddleware(options) {
|
|
|
1367
1331
|
const result = {
|
|
1368
1332
|
identityVerified: false,
|
|
1369
1333
|
policyAllowed: false,
|
|
1370
|
-
accessLevel: "none",
|
|
1371
1334
|
denialReasons: [`MCP middleware internal error: ${errorClass}`],
|
|
1372
1335
|
failures: [
|
|
1373
1336
|
{
|
|
@@ -1397,7 +1360,7 @@ export {
|
|
|
1397
1360
|
MCP_VERIFIED_HOP_HEADER,
|
|
1398
1361
|
createMcpMiddleware,
|
|
1399
1362
|
isVerifiedHopValidFor,
|
|
1400
|
-
|
|
1363
|
+
mcpDefaultEnforced,
|
|
1401
1364
|
mcpToPdlss,
|
|
1402
1365
|
parseMcpJsonRpc,
|
|
1403
1366
|
parseVerifiedHop,
|