@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/index.js
CHANGED
|
@@ -30,8 +30,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
ACCESS_LEVEL_DESCRIPTIONS: () => ACCESS_LEVEL_DESCRIPTIONS,
|
|
34
|
-
ACCESS_LEVEL_HIERARCHY: () => ACCESS_LEVEL_HIERARCHY,
|
|
35
33
|
AgentClient: () => AgentClient,
|
|
36
34
|
AstraSync: () => AstraSync,
|
|
37
35
|
AstraSyncError: () => AstraSyncError,
|
|
@@ -39,7 +37,6 @@ __export(src_exports, {
|
|
|
39
37
|
CAPTURE_SCHEMA_VERSION: () => CAPTURE_SCHEMA_VERSION,
|
|
40
38
|
ChallengeHandler: () => ChallengeHandler,
|
|
41
39
|
DEFAULT_EDGE_CONFIG: () => DEFAULT_EDGE_CONFIG,
|
|
42
|
-
DEFAULT_TRUST_THRESHOLDS: () => DEFAULT_TRUST_THRESHOLDS,
|
|
43
40
|
KYDRequiredError: () => KYDRequiredError,
|
|
44
41
|
MAX_HEADERS: () => MAX_HEADERS,
|
|
45
42
|
MAX_HEADER_VALUE_BYTES: () => MAX_HEADER_VALUE_BYTES,
|
|
@@ -66,7 +63,6 @@ __export(src_exports, {
|
|
|
66
63
|
deriveConnectionFromHeaders: () => deriveConnectionFromHeaders,
|
|
67
64
|
detectPlatformFingerprint: () => detectPlatformFingerprint,
|
|
68
65
|
detectRuntime: () => detectRuntime,
|
|
69
|
-
determineAccessLevel: () => determineAccessLevel,
|
|
70
66
|
express: () => express_exports,
|
|
71
67
|
extractApiKeyFormat: () => extractApiKeyFormat,
|
|
72
68
|
extractCredentials: () => extractCredentials,
|
|
@@ -74,14 +70,11 @@ __export(src_exports, {
|
|
|
74
70
|
extractPlatformHeaders: () => extractPlatformHeaders,
|
|
75
71
|
fetchEdgeConfig: () => fetchEdgeConfig,
|
|
76
72
|
fetchRoutes: () => fetchRoutes,
|
|
77
|
-
getAccessLevelForScore: () => getAccessLevelForScore,
|
|
78
73
|
getCachedWellKnownUrls: () => getCachedWellKnownUrls,
|
|
79
|
-
getCapabilities: () => getCapabilities,
|
|
80
74
|
getEdgeConfig: () => getEdgeConfig,
|
|
81
75
|
getTrustLevel: () => getTrustLevel,
|
|
82
76
|
getWellKnownUrls: () => getWellKnownUrls,
|
|
83
77
|
hasCredentials: () => hasCredentials,
|
|
84
|
-
hasMinimumAccess: () => hasMinimumAccess,
|
|
85
78
|
isEdgeConfig: () => isEdgeConfig,
|
|
86
79
|
isVerifiedHopValidFor: () => isVerifiedHopValidFor,
|
|
87
80
|
matchEdgePathRule: () => matchEdgePathRule,
|
|
@@ -104,32 +97,7 @@ __export(src_exports, {
|
|
|
104
97
|
});
|
|
105
98
|
module.exports = __toCommonJS(src_exports);
|
|
106
99
|
|
|
107
|
-
// src/
|
|
108
|
-
var ACCESS_LEVEL_HIERARCHY = {
|
|
109
|
-
none: 0,
|
|
110
|
-
restricted: 1,
|
|
111
|
-
"read-only": 2,
|
|
112
|
-
standard: 3,
|
|
113
|
-
full: 4,
|
|
114
|
-
internal: 5
|
|
115
|
-
};
|
|
116
|
-
var ACCESS_LEVEL_DESCRIPTIONS = {
|
|
117
|
-
none: "No access - credentials required",
|
|
118
|
-
restricted: "Restricted access - registration prompt only",
|
|
119
|
-
"read-only": "Read-only access - can browse but not modify",
|
|
120
|
-
standard: "Standard access - normal operations per PDLSS policy",
|
|
121
|
-
full: "Full access - all operations for high-trust agents",
|
|
122
|
-
internal: "Internal access - organization member privileges"
|
|
123
|
-
};
|
|
124
|
-
var DEFAULT_TRUST_THRESHOLDS = {
|
|
125
|
-
none: 0,
|
|
126
|
-
restricted: 0,
|
|
127
|
-
"read-only": 20,
|
|
128
|
-
standard: 40,
|
|
129
|
-
full: 70,
|
|
130
|
-
internal: 0
|
|
131
|
-
// Internal is based on org membership, not score
|
|
132
|
-
};
|
|
100
|
+
// src/trust-levels.ts
|
|
133
101
|
var TRUST_LEVEL_RANGES = {
|
|
134
102
|
BRONZE: { min: 0, max: 39 },
|
|
135
103
|
SILVER: { min: 40, max: 59 },
|
|
@@ -142,91 +110,9 @@ function getTrustLevel(score) {
|
|
|
142
110
|
if (score >= 40) return "SILVER";
|
|
143
111
|
return "BRONZE";
|
|
144
112
|
}
|
|
145
|
-
function hasMinimumAccess(actual, required) {
|
|
146
|
-
return ACCESS_LEVEL_HIERARCHY[actual] >= ACCESS_LEVEL_HIERARCHY[required];
|
|
147
|
-
}
|
|
148
|
-
function getAccessLevelForScore(trustScore, thresholds = DEFAULT_TRUST_THRESHOLDS) {
|
|
149
|
-
if (trustScore >= thresholds.full) return "full";
|
|
150
|
-
if (trustScore >= thresholds.standard) return "standard";
|
|
151
|
-
if (trustScore >= thresholds["read-only"]) return "read-only";
|
|
152
|
-
return "restricted";
|
|
153
|
-
}
|
|
154
|
-
function determineAccessLevel(verified, trustScore, isOrgMember, customThresholds) {
|
|
155
|
-
if (!verified) {
|
|
156
|
-
return "none";
|
|
157
|
-
}
|
|
158
|
-
if (isOrgMember) {
|
|
159
|
-
return "internal";
|
|
160
|
-
}
|
|
161
|
-
const thresholds = {
|
|
162
|
-
...DEFAULT_TRUST_THRESHOLDS,
|
|
163
|
-
...customThresholds
|
|
164
|
-
};
|
|
165
|
-
return getAccessLevelForScore(trustScore, thresholds);
|
|
166
|
-
}
|
|
167
|
-
function getCapabilities(accessLevel) {
|
|
168
|
-
switch (accessLevel) {
|
|
169
|
-
case "none":
|
|
170
|
-
return {
|
|
171
|
-
canRead: false,
|
|
172
|
-
canWrite: false,
|
|
173
|
-
canDelete: false,
|
|
174
|
-
canAdmin: false,
|
|
175
|
-
canAccessInternal: false
|
|
176
|
-
};
|
|
177
|
-
case "restricted":
|
|
178
|
-
return {
|
|
179
|
-
canRead: false,
|
|
180
|
-
canWrite: false,
|
|
181
|
-
canDelete: false,
|
|
182
|
-
canAdmin: false,
|
|
183
|
-
canAccessInternal: false
|
|
184
|
-
};
|
|
185
|
-
case "read-only":
|
|
186
|
-
return {
|
|
187
|
-
canRead: true,
|
|
188
|
-
canWrite: false,
|
|
189
|
-
canDelete: false,
|
|
190
|
-
canAdmin: false,
|
|
191
|
-
canAccessInternal: false
|
|
192
|
-
};
|
|
193
|
-
case "standard":
|
|
194
|
-
return {
|
|
195
|
-
canRead: true,
|
|
196
|
-
canWrite: true,
|
|
197
|
-
canDelete: false,
|
|
198
|
-
canAdmin: false,
|
|
199
|
-
canAccessInternal: false
|
|
200
|
-
};
|
|
201
|
-
case "full":
|
|
202
|
-
return {
|
|
203
|
-
canRead: true,
|
|
204
|
-
canWrite: true,
|
|
205
|
-
canDelete: true,
|
|
206
|
-
canAdmin: false,
|
|
207
|
-
canAccessInternal: false
|
|
208
|
-
};
|
|
209
|
-
case "internal":
|
|
210
|
-
return {
|
|
211
|
-
canRead: true,
|
|
212
|
-
canWrite: true,
|
|
213
|
-
canDelete: true,
|
|
214
|
-
canAdmin: true,
|
|
215
|
-
canAccessInternal: true
|
|
216
|
-
};
|
|
217
|
-
default:
|
|
218
|
-
return {
|
|
219
|
-
canRead: false,
|
|
220
|
-
canWrite: false,
|
|
221
|
-
canDelete: false,
|
|
222
|
-
canAdmin: false,
|
|
223
|
-
canAccessInternal: false
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
113
|
|
|
228
114
|
// src/version.ts
|
|
229
|
-
var SDK_VERSION = "
|
|
115
|
+
var SDK_VERSION = "5.0.0";
|
|
230
116
|
|
|
231
117
|
// src/http.ts
|
|
232
118
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -308,11 +194,6 @@ function getCachedWellKnownUrls(apiBaseUrl) {
|
|
|
308
194
|
// src/verify.ts
|
|
309
195
|
var DEFAULT_CONFIG = {
|
|
310
196
|
apiBaseUrl: "https://astrasync.ai/api",
|
|
311
|
-
// v2.3.9 (defect #30): default for unconfigured callers is `'none'` (no
|
|
312
|
-
// access). Pre-rename this defaulted to `'guidance'`, which combined with
|
|
313
|
-
// a route gated at `'guidance'` to silently let unverified traffic
|
|
314
|
-
// through (`hasMinimumAccess('guidance', 'guidance') === true`).
|
|
315
|
-
defaultAccessLevel: "none",
|
|
316
197
|
// minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
|
|
317
198
|
// cacheTtl deliberately unset. When undefined, cacheResult applies the 60s
|
|
318
199
|
// default; the caller's explicit value is honoured for cacheable results.
|
|
@@ -513,13 +394,6 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
513
394
|
// policy is not evaluated (we never reached the gate).
|
|
514
395
|
identityVerified: false,
|
|
515
396
|
policyAllowed: false,
|
|
516
|
-
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
517
|
-
// Adapters additionally short-circuit on `!identityVerified ||
|
|
518
|
-
// !policyAllowed` before the gate check, but the access level still has
|
|
519
|
-
// to be honest at the data layer so downstream consumers (SDK adapters
|
|
520
|
-
// in other languages, custom integrations) inherit the correct
|
|
521
|
-
// semantics.
|
|
522
|
-
accessLevel: "none",
|
|
523
397
|
guidance,
|
|
524
398
|
denialReasons: reason ? [reason] : ["No valid agent credentials provided"],
|
|
525
399
|
// Round-10 (#47, O5): on API-error fallback, surface a typed failure so
|
|
@@ -542,6 +416,11 @@ function createGuidanceResponse(_config, reason, options = {}) {
|
|
|
542
416
|
// 4.0.0: typed marker so adapters render the misconfig envelope (503 +
|
|
543
417
|
// MERCHANT_VERIFICATION_MISCONFIGURED) without string-matching.
|
|
544
418
|
...isMisconfig && { misconfigured: true },
|
|
419
|
+
// 4.6.0: a transient api_error is retryable — mark it so consumers surface
|
|
420
|
+
// "temporarily unavailable, retry" (recommendation 'error') instead of
|
|
421
|
+
// coercing the absent recommendation to a policy 'deny'. Misconfig is
|
|
422
|
+
// deterministic and intentionally NOT marked retryable.
|
|
423
|
+
...isApiError && { retryable: true },
|
|
545
424
|
correlationId: options.correlationId,
|
|
546
425
|
attemptId: options.attemptId,
|
|
547
426
|
verifiedAt: /* @__PURE__ */ new Date()
|
|
@@ -608,7 +487,6 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
608
487
|
attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
|
|
609
488
|
access: {
|
|
610
489
|
allowed: false,
|
|
611
|
-
accessLevel: "none",
|
|
612
490
|
reason: "endpoint_deactivated",
|
|
613
491
|
failures: [
|
|
614
492
|
{
|
|
@@ -671,7 +549,7 @@ async function verify(config, request, options) {
|
|
|
671
549
|
if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
|
|
672
550
|
deprecationWarningShown = true;
|
|
673
551
|
console.warn(
|
|
674
|
-
"[VerificationGateway] minTrustScore / minTrustScoreForFull are deprecated in v2.3.0 and have no effect. Server is now the single source of truth for access
|
|
552
|
+
"[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."
|
|
675
553
|
);
|
|
676
554
|
}
|
|
677
555
|
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache) {
|
|
@@ -717,14 +595,6 @@ async function verify(config, request, options) {
|
|
|
717
595
|
const result2 = {
|
|
718
596
|
identityVerified: idVerifiedFromBackend,
|
|
719
597
|
policyAllowed: false,
|
|
720
|
-
// v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
|
|
721
|
-
// Pre-rename this hardcoded `'guidance'`, which conflated with the
|
|
722
|
-
// colocated `guidance: {...}` help-payload object below and let
|
|
723
|
-
// denied requests pass any route gated at `'guidance'` because
|
|
724
|
-
// `hasMinimumAccess('guidance', 'guidance') === true`. Adapters now
|
|
725
|
-
// ALSO short-circuit on `!identityVerified || !policyAllowed` before
|
|
726
|
-
// the gate check — belt-and-braces.
|
|
727
|
-
accessLevel: "none",
|
|
728
598
|
// 3.6.0: the server now emits top-level denialReasons on every deny
|
|
729
599
|
// path — prefer it verbatim; the failure-message reconstruction remains
|
|
730
600
|
// as the fallback for older backends.
|
|
@@ -773,7 +643,6 @@ async function verify(config, request, options) {
|
|
|
773
643
|
trustScore: apiResponse.organization.trustScore
|
|
774
644
|
} : void 0;
|
|
775
645
|
const verificationContext = apiResponse.verificationContext;
|
|
776
|
-
const accessLevel = apiResponse.access?.accessLevel ?? "standard";
|
|
777
646
|
const result = {
|
|
778
647
|
// 4.5.0 (probe F1): read idVerified from verificationContext with the
|
|
779
648
|
// SAME absent⇒false default as the deny branch. The previous `!== false`
|
|
@@ -785,7 +654,6 @@ async function verify(config, request, options) {
|
|
|
785
654
|
// this load-bearing must never be defaulted on.
|
|
786
655
|
identityVerified: apiResponse.verificationContext?.idVerified === true,
|
|
787
656
|
policyAllowed: true,
|
|
788
|
-
accessLevel,
|
|
789
657
|
agent,
|
|
790
658
|
developer,
|
|
791
659
|
organization,
|
|
@@ -812,7 +680,6 @@ async function verify(config, request, options) {
|
|
|
812
680
|
};
|
|
813
681
|
if (result.recommendation === "deny") {
|
|
814
682
|
result.policyAllowed = false;
|
|
815
|
-
result.accessLevel = "none";
|
|
816
683
|
result.denialReasons = serverDenialReasons ?? result.recommendationReasons ?? ["Access denied by AstraSync recommendation"];
|
|
817
684
|
result.guidance = result.runtimeChallenge ? {
|
|
818
685
|
message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
|
|
@@ -915,7 +782,6 @@ async function quickVerify(config, credentials) {
|
|
|
915
782
|
return {
|
|
916
783
|
identityVerified: result.identityVerified,
|
|
917
784
|
policyAllowed: result.policyAllowed,
|
|
918
|
-
accessLevel: result.accessLevel,
|
|
919
785
|
reason: result.denialReasons?.[0]
|
|
920
786
|
};
|
|
921
787
|
}
|
|
@@ -1945,7 +1811,6 @@ function defaultOnDenied(result, _req, res) {
|
|
|
1945
1811
|
error: {
|
|
1946
1812
|
code: !result.identityVerified ? "UNAUTHORIZED" : "INSUFFICIENT_ACCESS",
|
|
1947
1813
|
message: result.denialReasons?.[0] || "Access denied",
|
|
1948
|
-
accessLevel: result.accessLevel,
|
|
1949
1814
|
guidance: result.guidance,
|
|
1950
1815
|
// Round-10: aggregated per-dimension detail + correlation handle.
|
|
1951
1816
|
failures: result.failures,
|
|
@@ -2061,11 +1926,11 @@ function createMiddleware(options) {
|
|
|
2061
1926
|
}
|
|
2062
1927
|
const wellKnownUrls = config.apiBaseUrl ? await getWellKnownUrls(config.apiBaseUrl).catch(() => void 0) : void 0;
|
|
2063
1928
|
const credentials = customExtractCredentials ? customExtractCredentials(req) : defaultExtractCredentials(req);
|
|
2064
|
-
const shouldEnforce = routeConfig.
|
|
2065
|
-
if (routeConfig.
|
|
1929
|
+
const shouldEnforce = !routeConfig.observe;
|
|
1930
|
+
if (routeConfig.observe && (!config.evaluateAlwaysIfCredentialed || !credentials.astraId)) {
|
|
2066
1931
|
if (config.setPassThroughHeader) {
|
|
2067
1932
|
res.setHeader("X-Astra-Gateway-Mode", "unenforced");
|
|
2068
|
-
res.setHeader("X-Astra-Gateway-Reason", "route-
|
|
1933
|
+
res.setHeader("X-Astra-Gateway-Reason", "route-observe");
|
|
2069
1934
|
}
|
|
2070
1935
|
beaconPassThrough?.(req);
|
|
2071
1936
|
return next();
|
|
@@ -2102,7 +1967,6 @@ function createMiddleware(options) {
|
|
|
2102
1967
|
const result2 = {
|
|
2103
1968
|
identityVerified: false,
|
|
2104
1969
|
policyAllowed: false,
|
|
2105
|
-
accessLevel: "none",
|
|
2106
1970
|
denialReasons: preCheckFailures.map((f) => f.message),
|
|
2107
1971
|
guidance: {
|
|
2108
1972
|
message: "Request exceeds counterparty-defined PDLSS limits.",
|
|
@@ -2265,7 +2129,6 @@ function createMiddleware(options) {
|
|
|
2265
2129
|
const result = {
|
|
2266
2130
|
identityVerified: false,
|
|
2267
2131
|
policyAllowed: false,
|
|
2268
|
-
accessLevel: "none",
|
|
2269
2132
|
denialReasons: [`Verification middleware internal error: ${errorClass}`],
|
|
2270
2133
|
failures: [
|
|
2271
2134
|
{
|
|
@@ -2594,7 +2457,7 @@ function createMiddleware2(options) {
|
|
|
2594
2457
|
beaconPassThrough?.(request, pathname);
|
|
2595
2458
|
return NextResponse.next();
|
|
2596
2459
|
}
|
|
2597
|
-
if (routeConfig.
|
|
2460
|
+
if (routeConfig.observe) {
|
|
2598
2461
|
beaconPassThrough?.(request, pathname);
|
|
2599
2462
|
return NextResponse.next();
|
|
2600
2463
|
}
|
|
@@ -2624,7 +2487,6 @@ function createMiddleware2(options) {
|
|
|
2624
2487
|
const preCheckResult = {
|
|
2625
2488
|
identityVerified: false,
|
|
2626
2489
|
policyAllowed: false,
|
|
2627
|
-
accessLevel: "none",
|
|
2628
2490
|
denialReasons: preCheckFailures.map((f) => f.message),
|
|
2629
2491
|
guidance: {
|
|
2630
2492
|
message: "Request exceeds counterparty-defined PDLSS limits.",
|
|
@@ -2762,7 +2624,6 @@ function createMiddleware2(options) {
|
|
|
2762
2624
|
}
|
|
2763
2625
|
response.headers.set("X-AstraSync-Identity-Verified", result.identityVerified.toString());
|
|
2764
2626
|
response.headers.set("X-AstraSync-Policy-Allowed", result.policyAllowed.toString());
|
|
2765
|
-
response.headers.set("X-AstraSync-Access-Level", result.accessLevel);
|
|
2766
2627
|
if (result.agent) {
|
|
2767
2628
|
response.headers.set("X-AstraSync-Agent-Id", result.agent.astraId);
|
|
2768
2629
|
}
|
|
@@ -2778,9 +2639,7 @@ var sdk_exports = {};
|
|
|
2778
2639
|
__export(sdk_exports, {
|
|
2779
2640
|
VerificationGatewayClient: () => VerificationGatewayClient,
|
|
2780
2641
|
createClient: () => createClient,
|
|
2781
|
-
getCapabilities: () => getCapabilities,
|
|
2782
2642
|
getTrustLevel: () => getTrustLevel,
|
|
2783
|
-
hasMinimumAccess: () => hasMinimumAccess,
|
|
2784
2643
|
verifyOnce: () => verifyOnce
|
|
2785
2644
|
});
|
|
2786
2645
|
var VerificationGatewayClient = class {
|
|
@@ -2788,7 +2647,6 @@ var VerificationGatewayClient = class {
|
|
|
2788
2647
|
this.config = {
|
|
2789
2648
|
apiBaseUrl: options.apiBaseUrl,
|
|
2790
2649
|
apiKey: options.apiKey,
|
|
2791
|
-
defaultAccessLevel: options.defaultAccessLevel,
|
|
2792
2650
|
minTrustScore: options.minTrustScore,
|
|
2793
2651
|
minTrustScoreForFull: options.minTrustScoreForFull,
|
|
2794
2652
|
cacheTtl: options.cacheTtl,
|
|
@@ -2837,26 +2695,6 @@ var VerificationGatewayClient = class {
|
|
|
2837
2695
|
async quickVerify(credentials) {
|
|
2838
2696
|
return this.executeWithRetry(() => quickVerify(this.config, credentials));
|
|
2839
2697
|
}
|
|
2840
|
-
/**
|
|
2841
|
-
* Check if an agent has a specific access level.
|
|
2842
|
-
*
|
|
2843
|
-
* @deprecated 3.2.0 — the access-level band is informational only; it no
|
|
2844
|
-
* longer gates in the middleware adapters (post-3.1.0 feedback #1). This
|
|
2845
|
-
* explicit opt-in query still works, but prefer gating on the server-side
|
|
2846
|
-
* policy decision (identity + policy + trust) or per-route `minTrustScore`.
|
|
2847
|
-
* Explicit per-route condition→constraint rules are the Phase-2 successor.
|
|
2848
|
-
*/
|
|
2849
|
-
async hasAccess(credentials, requiredLevel) {
|
|
2850
|
-
const result = await this.quickVerify(credentials);
|
|
2851
|
-
return hasMinimumAccess(result.accessLevel, requiredLevel);
|
|
2852
|
-
}
|
|
2853
|
-
/**
|
|
2854
|
-
* Get capabilities for a verified agent
|
|
2855
|
-
*/
|
|
2856
|
-
async getCapabilities(credentials) {
|
|
2857
|
-
const result = await this.quickVerify(credentials);
|
|
2858
|
-
return getCapabilities(result.accessLevel);
|
|
2859
|
-
}
|
|
2860
2698
|
/**
|
|
2861
2699
|
* Verify a specific ASTRA-ID
|
|
2862
2700
|
*/
|
|
@@ -5584,18 +5422,13 @@ function mcpToPdlss(parsed, requestPath, headerPurpose, headerAction, toolGate)
|
|
|
5584
5422
|
}
|
|
5585
5423
|
return { purpose, action, resource, purposeSource, actionSource };
|
|
5586
5424
|
}
|
|
5587
|
-
function
|
|
5588
|
-
if (parsed.isInitialize || parsed.method === "notifications/initialized") return
|
|
5589
|
-
if (parsed.isIntrospection) return
|
|
5590
|
-
|
|
5591
|
-
if (parsed.isToolCall) return "standard";
|
|
5592
|
-
return "standard";
|
|
5425
|
+
function mcpDefaultEnforced(parsed) {
|
|
5426
|
+
if (parsed.isInitialize || parsed.method === "notifications/initialized") return false;
|
|
5427
|
+
if (parsed.isIntrospection) return false;
|
|
5428
|
+
return true;
|
|
5593
5429
|
}
|
|
5594
5430
|
|
|
5595
5431
|
// src/adapters/mcp.ts
|
|
5596
|
-
function normalizeToolGate(gate) {
|
|
5597
|
-
return typeof gate === "string" ? { minAccessLevel: gate } : gate;
|
|
5598
|
-
}
|
|
5599
5432
|
function readSingleHeader(value) {
|
|
5600
5433
|
if (typeof value === "string") return value;
|
|
5601
5434
|
if (Array.isArray(value)) return value[0];
|
|
@@ -5648,7 +5481,6 @@ function defaultMcpDenied(result, req, res) {
|
|
|
5648
5481
|
code: !result.identityVerified ? -32e3 : -32001,
|
|
5649
5482
|
message: result.denialReasons?.[0] ?? "Access denied",
|
|
5650
5483
|
data: {
|
|
5651
|
-
accessLevel: result.accessLevel,
|
|
5652
5484
|
guidance: result.guidance,
|
|
5653
5485
|
// Round-10: aggregated per-dimension detail + correlation handle.
|
|
5654
5486
|
failures: result.failures,
|
|
@@ -5661,20 +5493,19 @@ function defaultMcpDenied(result, req, res) {
|
|
|
5661
5493
|
}
|
|
5662
5494
|
});
|
|
5663
5495
|
}
|
|
5664
|
-
function
|
|
5496
|
+
function resolveGate(parsed, opts) {
|
|
5665
5497
|
if (!parsed.toolName) {
|
|
5666
|
-
|
|
5667
|
-
|
|
5498
|
+
const methodGate = opts.methodGates?.[parsed.method];
|
|
5499
|
+
if (methodGate !== void 0) {
|
|
5500
|
+
return methodGate === "observe" ? { enforce: false, source: "methodGate" } : { enforce: true, config: methodGate, source: "methodGate" };
|
|
5668
5501
|
}
|
|
5669
|
-
return {
|
|
5502
|
+
return { enforce: false, source: "discovery_default" };
|
|
5670
5503
|
}
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
source: "toolGate"
|
|
5675
|
-
};
|
|
5504
|
+
const toolGate = opts.toolGates?.[parsed.toolName];
|
|
5505
|
+
if (toolGate !== void 0) {
|
|
5506
|
+
return toolGate === "observe" ? { enforce: false, source: "toolGate" } : { enforce: true, config: toolGate, source: "toolGate" };
|
|
5676
5507
|
}
|
|
5677
|
-
return {
|
|
5508
|
+
return { enforce: mcpDefaultEnforced(parsed), source: "tier" };
|
|
5678
5509
|
}
|
|
5679
5510
|
function createMcpMiddleware(options) {
|
|
5680
5511
|
const {
|
|
@@ -5694,15 +5525,6 @@ function createMcpMiddleware(options) {
|
|
|
5694
5525
|
prefetchWellKnown(config.apiBaseUrl).catch(() => {
|
|
5695
5526
|
});
|
|
5696
5527
|
}
|
|
5697
|
-
if (toolGates) {
|
|
5698
|
-
for (const [toolName, gate] of Object.entries(toolGates)) {
|
|
5699
|
-
if (typeof gate === "string") {
|
|
5700
|
-
console.warn(
|
|
5701
|
-
`[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: '...' }.`
|
|
5702
|
-
);
|
|
5703
|
-
}
|
|
5704
|
-
}
|
|
5705
|
-
}
|
|
5706
5528
|
return async (req, res, next) => {
|
|
5707
5529
|
try {
|
|
5708
5530
|
if (skip) return next();
|
|
@@ -5751,7 +5573,7 @@ function createMcpMiddleware(options) {
|
|
|
5751
5573
|
return next();
|
|
5752
5574
|
}
|
|
5753
5575
|
}
|
|
5754
|
-
const
|
|
5576
|
+
const gateDecision = resolveGate(parsed, {
|
|
5755
5577
|
toolGates,
|
|
5756
5578
|
methodGates
|
|
5757
5579
|
});
|
|
@@ -5760,16 +5582,15 @@ function createMcpMiddleware(options) {
|
|
|
5760
5582
|
req.query
|
|
5761
5583
|
);
|
|
5762
5584
|
if (effectiveAstraId) credentials.astraId = effectiveAstraId;
|
|
5763
|
-
const shouldEnforce =
|
|
5764
|
-
if (
|
|
5585
|
+
const shouldEnforce = gateDecision.enforce;
|
|
5586
|
+
if (!shouldEnforce && (!config.evaluateAlwaysIfCredentialed || !credentials.astraId)) {
|
|
5765
5587
|
if (config.setPassThroughHeader) {
|
|
5766
5588
|
res.setHeader("X-Astra-Gateway-Mode", "unenforced");
|
|
5767
|
-
res.setHeader("X-Astra-Gateway-Reason", "mcp-
|
|
5589
|
+
res.setHeader("X-Astra-Gateway-Reason", "mcp-observe");
|
|
5768
5590
|
}
|
|
5769
5591
|
return next();
|
|
5770
5592
|
}
|
|
5771
|
-
const
|
|
5772
|
-
const gate = rawGate ? normalizeToolGate(rawGate) : void 0;
|
|
5593
|
+
const gate = gateDecision.config;
|
|
5773
5594
|
const headerPurpose = readSingleHeader(req.headers["x-astra-purpose"]);
|
|
5774
5595
|
const headerAction = readSingleHeader(req.headers["x-astra-action"]);
|
|
5775
5596
|
const pdlss = mcpToPdlss(
|
|
@@ -5905,7 +5726,6 @@ function createMcpMiddleware(options) {
|
|
|
5905
5726
|
const result = {
|
|
5906
5727
|
identityVerified: false,
|
|
5907
5728
|
policyAllowed: false,
|
|
5908
|
-
accessLevel: "none",
|
|
5909
5729
|
denialReasons: [`MCP middleware internal error: ${errorClass}`],
|
|
5910
5730
|
failures: [
|
|
5911
5731
|
{
|
|
@@ -6661,8 +6481,6 @@ function detectRuntime(userAgent) {
|
|
|
6661
6481
|
}
|
|
6662
6482
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6663
6483
|
0 && (module.exports = {
|
|
6664
|
-
ACCESS_LEVEL_DESCRIPTIONS,
|
|
6665
|
-
ACCESS_LEVEL_HIERARCHY,
|
|
6666
6484
|
AgentClient,
|
|
6667
6485
|
AstraSync,
|
|
6668
6486
|
AstraSyncError,
|
|
@@ -6670,7 +6488,6 @@ function detectRuntime(userAgent) {
|
|
|
6670
6488
|
CAPTURE_SCHEMA_VERSION,
|
|
6671
6489
|
ChallengeHandler,
|
|
6672
6490
|
DEFAULT_EDGE_CONFIG,
|
|
6673
|
-
DEFAULT_TRUST_THRESHOLDS,
|
|
6674
6491
|
KYDRequiredError,
|
|
6675
6492
|
MAX_HEADERS,
|
|
6676
6493
|
MAX_HEADER_VALUE_BYTES,
|
|
@@ -6697,7 +6514,6 @@ function detectRuntime(userAgent) {
|
|
|
6697
6514
|
deriveConnectionFromHeaders,
|
|
6698
6515
|
detectPlatformFingerprint,
|
|
6699
6516
|
detectRuntime,
|
|
6700
|
-
determineAccessLevel,
|
|
6701
6517
|
express,
|
|
6702
6518
|
extractApiKeyFormat,
|
|
6703
6519
|
extractCredentials,
|
|
@@ -6705,14 +6521,11 @@ function detectRuntime(userAgent) {
|
|
|
6705
6521
|
extractPlatformHeaders,
|
|
6706
6522
|
fetchEdgeConfig,
|
|
6707
6523
|
fetchRoutes,
|
|
6708
|
-
getAccessLevelForScore,
|
|
6709
6524
|
getCachedWellKnownUrls,
|
|
6710
|
-
getCapabilities,
|
|
6711
6525
|
getEdgeConfig,
|
|
6712
6526
|
getTrustLevel,
|
|
6713
6527
|
getWellKnownUrls,
|
|
6714
6528
|
hasCredentials,
|
|
6715
|
-
hasMinimumAccess,
|
|
6716
6529
|
isEdgeConfig,
|
|
6717
6530
|
isVerifiedHopValidFor,
|
|
6718
6531
|
matchEdgePathRule,
|