@astrasyncai/verification-gateway 4.6.0 → 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.
Files changed (135) hide show
  1. package/dist/adapter-interface/interface.d.mts +2 -2
  2. package/dist/adapter-interface/interface.d.ts +2 -2
  3. package/dist/adapters/express.d.mts +2 -2
  4. package/dist/adapters/express.d.ts +2 -2
  5. package/dist/adapters/express.js +6 -33
  6. package/dist/adapters/express.js.map +1 -1
  7. package/dist/adapters/express.mjs +6 -33
  8. package/dist/adapters/express.mjs.map +1 -1
  9. package/dist/adapters/mcp.d.mts +2 -2
  10. package/dist/adapters/mcp.d.ts +2 -2
  11. package/dist/adapters/mcp.js +23 -65
  12. package/dist/adapters/mcp.js.map +1 -1
  13. package/dist/adapters/mcp.mjs +22 -64
  14. package/dist/adapters/mcp.mjs.map +1 -1
  15. package/dist/adapters/nextjs.d.mts +2 -2
  16. package/dist/adapters/nextjs.d.ts +2 -2
  17. package/dist/adapters/nextjs.js +4 -30
  18. package/dist/adapters/nextjs.js.map +1 -1
  19. package/dist/adapters/nextjs.mjs +4 -30
  20. package/dist/adapters/nextjs.mjs.map +1 -1
  21. package/dist/adapters/sdk.d.mts +2 -2
  22. package/dist/adapters/sdk.d.ts +2 -2
  23. package/dist/adapters/sdk.js +3 -124
  24. package/dist/adapters/sdk.js.map +1 -1
  25. package/dist/adapters/sdk.mjs +3 -122
  26. package/dist/adapters/sdk.mjs.map +1 -1
  27. package/dist/agent/index.d.mts +2 -2
  28. package/dist/agent/index.d.ts +2 -2
  29. package/dist/agent/index.js +1 -1
  30. package/dist/agent/index.js.map +1 -1
  31. package/dist/agent/index.mjs +1 -1
  32. package/dist/agent/index.mjs.map +1 -1
  33. package/dist/bin/astrasync-claude-hook.js +4 -29
  34. package/dist/bin/astrasync-codex-hook.js +4 -29
  35. package/dist/bin/astrasync-guard.js +4 -29
  36. package/dist/bin/astrasync.js +9 -34
  37. package/dist/browser/background.js +4 -29
  38. package/dist/browser/background.js.map +1 -1
  39. package/dist/browser/background.mjs +4 -29
  40. package/dist/browser/background.mjs.map +1 -1
  41. package/dist/browser/browser-adapter.d.mts +2 -2
  42. package/dist/browser/browser-adapter.d.ts +2 -2
  43. package/dist/claude-code/claude-code-adapter.d.mts +2 -2
  44. package/dist/claude-code/claude-code-adapter.d.ts +2 -2
  45. package/dist/cli/index.d.mts +2 -2
  46. package/dist/cli/index.d.ts +2 -2
  47. package/dist/cli/index.js +1 -1
  48. package/dist/cli/index.js.map +1 -1
  49. package/dist/cli/index.mjs +1 -1
  50. package/dist/cli/index.mjs.map +1 -1
  51. package/dist/codex/index.d.mts +2 -2
  52. package/dist/codex/index.d.ts +2 -2
  53. package/dist/codex/index.js +4 -29
  54. package/dist/codex/index.js.map +1 -1
  55. package/dist/codex/index.mjs +4 -29
  56. package/dist/codex/index.mjs.map +1 -1
  57. package/dist/cursor/cursor-adapter.d.mts +2 -2
  58. package/dist/cursor/cursor-adapter.d.ts +2 -2
  59. package/dist/cursor/extension.d.mts +2 -2
  60. package/dist/cursor/extension.d.ts +2 -2
  61. package/dist/cursor/extension.js +4 -29
  62. package/dist/cursor/extension.js.map +1 -1
  63. package/dist/cursor/extension.mjs +4 -29
  64. package/dist/cursor/extension.mjs.map +1 -1
  65. package/dist/edge-config.d.mts +1 -1
  66. package/dist/edge-config.d.ts +1 -1
  67. package/dist/edge-config.js +1 -1
  68. package/dist/edge-config.js.map +1 -1
  69. package/dist/edge-config.mjs +1 -1
  70. package/dist/edge-config.mjs.map +1 -1
  71. package/dist/edge-core/index.d.mts +1 -3
  72. package/dist/edge-core/index.d.ts +1 -3
  73. package/dist/edge-core/index.js +6 -33
  74. package/dist/edge-core/index.js.map +1 -1
  75. package/dist/edge-core/index.mjs +6 -33
  76. package/dist/edge-core/index.mjs.map +1 -1
  77. package/dist/{express-D-8Ks2Uo.d.ts → express-B5lWuemA.d.ts} +1 -1
  78. package/dist/{express-DBtPKXOL.d.mts → express-Dm-snUuY.d.mts} +1 -1
  79. package/dist/gateway/gateway.d.mts +2 -2
  80. package/dist/gateway/gateway.d.ts +2 -2
  81. package/dist/gateway/gateway.js +4 -29
  82. package/dist/gateway/gateway.js.map +1 -1
  83. package/dist/gateway/gateway.mjs +4 -29
  84. package/dist/gateway/gateway.mjs.map +1 -1
  85. package/dist/git-trigger/git-hooks.d.mts +2 -2
  86. package/dist/git-trigger/git-hooks.d.ts +2 -2
  87. package/dist/{index-kGCGWd5x.d.mts → index-B5k_vUmK.d.mts} +1 -1
  88. package/dist/{index-CUfmJ1Dq.d.mts → index-BOzM6xUq.d.mts} +1 -1
  89. package/dist/{index-BND3kQev.d.ts → index-dRfxUdFA.d.ts} +1 -1
  90. package/dist/{index-DlZORQsb.d.ts → index-y8xToocF.d.ts} +1 -1
  91. package/dist/index.d.mts +10 -10
  92. package/dist/index.d.ts +10 -10
  93. package/dist/index.js +25 -217
  94. package/dist/index.js.map +1 -1
  95. package/dist/index.mjs +25 -210
  96. package/dist/index.mjs.map +1 -1
  97. package/dist/local-evaluator/evaluator.d.mts +2 -2
  98. package/dist/local-evaluator/evaluator.d.ts +2 -2
  99. package/dist/local-evaluator/evaluator.js.map +1 -1
  100. package/dist/local-evaluator/evaluator.mjs.map +1 -1
  101. package/dist/{mcp-ZRN4kY3b.d.mts → mcp-DgsyQiQq.d.mts} +53 -52
  102. package/dist/{mcp-DToTlwIn.d.ts → mcp-OosmAcKf.d.ts} +53 -52
  103. package/dist/{nextjs-C0KASOy_.d.mts → nextjs-B1sBdEav.d.mts} +1 -1
  104. package/dist/{nextjs-lwNvWYWT.d.ts → nextjs-DoRmhV_Z.d.ts} +1 -1
  105. package/dist/registration/index.js +1 -1
  106. package/dist/registration/index.js.map +1 -1
  107. package/dist/registration/index.mjs +1 -1
  108. package/dist/registration/index.mjs.map +1 -1
  109. package/dist/sdk-B83N3xKc.d.mts +142 -0
  110. package/dist/sdk-H_9BTNBS.d.ts +142 -0
  111. package/dist/transport/index.d.mts +2 -2
  112. package/dist/transport/index.d.ts +2 -2
  113. package/dist/transport/index.js +1 -1
  114. package/dist/transport/index.js.map +1 -1
  115. package/dist/transport/index.mjs +1 -1
  116. package/dist/transport/index.mjs.map +1 -1
  117. package/dist/{types-CGPU7HLi.d.ts → types-BK2POWNc.d.ts} +15 -50
  118. package/dist/{types-Cx9hTpKI.d.mts → types-CJjZvPr9.d.mts} +15 -50
  119. package/dist/{types-DhhJxKIC.d.ts → types-CXf3q4kZ.d.ts} +1 -3
  120. package/dist/{types-CfSJLS4i.d.mts → types-DQmop7ZW.d.mts} +1 -3
  121. package/dist/ui/index.d.mts +2 -17
  122. package/dist/ui/index.d.ts +2 -17
  123. package/dist/ui/index.js +1 -43
  124. package/dist/ui/index.js.map +1 -1
  125. package/dist/ui/index.mjs +1 -42
  126. package/dist/ui/index.mjs.map +1 -1
  127. package/dist/verify.d.mts +3 -4
  128. package/dist/verify.d.ts +3 -4
  129. package/dist/verify.js +3 -28
  130. package/dist/verify.js.map +1 -1
  131. package/dist/verify.mjs +3 -28
  132. package/dist/verify.mjs.map +1 -1
  133. package/package.json +1 -1
  134. package/dist/sdk-B4aodEwj.d.ts +0 -215
  135. package/dist/sdk-B9dSwum7.d.mts +0 -215
package/dist/index.mjs CHANGED
@@ -4,32 +4,7 @@ var __export = (target, all) => {
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
5
5
  };
6
6
 
7
- // src/access-levels.ts
8
- var ACCESS_LEVEL_HIERARCHY = {
9
- none: 0,
10
- restricted: 1,
11
- "read-only": 2,
12
- standard: 3,
13
- full: 4,
14
- internal: 5
15
- };
16
- var ACCESS_LEVEL_DESCRIPTIONS = {
17
- none: "No access - credentials required",
18
- restricted: "Restricted access - registration prompt only",
19
- "read-only": "Read-only access - can browse but not modify",
20
- standard: "Standard access - normal operations per PDLSS policy",
21
- full: "Full access - all operations for high-trust agents",
22
- internal: "Internal access - organization member privileges"
23
- };
24
- var DEFAULT_TRUST_THRESHOLDS = {
25
- none: 0,
26
- restricted: 0,
27
- "read-only": 20,
28
- standard: 40,
29
- full: 70,
30
- internal: 0
31
- // Internal is based on org membership, not score
32
- };
7
+ // src/trust-levels.ts
33
8
  var TRUST_LEVEL_RANGES = {
34
9
  BRONZE: { min: 0, max: 39 },
35
10
  SILVER: { min: 40, max: 59 },
@@ -42,91 +17,9 @@ function getTrustLevel(score) {
42
17
  if (score >= 40) return "SILVER";
43
18
  return "BRONZE";
44
19
  }
45
- function hasMinimumAccess(actual, required) {
46
- return ACCESS_LEVEL_HIERARCHY[actual] >= ACCESS_LEVEL_HIERARCHY[required];
47
- }
48
- function getAccessLevelForScore(trustScore, thresholds = DEFAULT_TRUST_THRESHOLDS) {
49
- if (trustScore >= thresholds.full) return "full";
50
- if (trustScore >= thresholds.standard) return "standard";
51
- if (trustScore >= thresholds["read-only"]) return "read-only";
52
- return "restricted";
53
- }
54
- function determineAccessLevel(verified, trustScore, isOrgMember, customThresholds) {
55
- if (!verified) {
56
- return "none";
57
- }
58
- if (isOrgMember) {
59
- return "internal";
60
- }
61
- const thresholds = {
62
- ...DEFAULT_TRUST_THRESHOLDS,
63
- ...customThresholds
64
- };
65
- return getAccessLevelForScore(trustScore, thresholds);
66
- }
67
- function getCapabilities(accessLevel) {
68
- switch (accessLevel) {
69
- case "none":
70
- return {
71
- canRead: false,
72
- canWrite: false,
73
- canDelete: false,
74
- canAdmin: false,
75
- canAccessInternal: false
76
- };
77
- case "restricted":
78
- return {
79
- canRead: false,
80
- canWrite: false,
81
- canDelete: false,
82
- canAdmin: false,
83
- canAccessInternal: false
84
- };
85
- case "read-only":
86
- return {
87
- canRead: true,
88
- canWrite: false,
89
- canDelete: false,
90
- canAdmin: false,
91
- canAccessInternal: false
92
- };
93
- case "standard":
94
- return {
95
- canRead: true,
96
- canWrite: true,
97
- canDelete: false,
98
- canAdmin: false,
99
- canAccessInternal: false
100
- };
101
- case "full":
102
- return {
103
- canRead: true,
104
- canWrite: true,
105
- canDelete: true,
106
- canAdmin: false,
107
- canAccessInternal: false
108
- };
109
- case "internal":
110
- return {
111
- canRead: true,
112
- canWrite: true,
113
- canDelete: true,
114
- canAdmin: true,
115
- canAccessInternal: true
116
- };
117
- default:
118
- return {
119
- canRead: false,
120
- canWrite: false,
121
- canDelete: false,
122
- canAdmin: false,
123
- canAccessInternal: false
124
- };
125
- }
126
- }
127
20
 
128
21
  // src/version.ts
129
- var SDK_VERSION = "4.6.0";
22
+ var SDK_VERSION = "5.0.0";
130
23
 
131
24
  // src/http.ts
132
25
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -208,11 +101,6 @@ function getCachedWellKnownUrls(apiBaseUrl) {
208
101
  // src/verify.ts
209
102
  var DEFAULT_CONFIG = {
210
103
  apiBaseUrl: "https://astrasync.ai/api",
211
- // v2.3.9 (defect #30): default for unconfigured callers is `'none'` (no
212
- // access). Pre-rename this defaulted to `'guidance'`, which combined with
213
- // a route gated at `'guidance'` to silently let unverified traffic
214
- // through (`hasMinimumAccess('guidance', 'guidance') === true`).
215
- defaultAccessLevel: "none",
216
104
  // minTrustScore + minTrustScoreForFull deprecated in v2.3.0 — server decides.
217
105
  // cacheTtl deliberately unset. When undefined, cacheResult applies the 60s
218
106
  // default; the caller's explicit value is honoured for cacheable results.
@@ -413,13 +301,6 @@ function createGuidanceResponse(_config, reason, options = {}) {
413
301
  // policy is not evaluated (we never reached the gate).
414
302
  identityVerified: false,
415
303
  policyAllowed: false,
416
- // v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
417
- // Adapters additionally short-circuit on `!identityVerified ||
418
- // !policyAllowed` before the gate check, but the access level still has
419
- // to be honest at the data layer so downstream consumers (SDK adapters
420
- // in other languages, custom integrations) inherit the correct
421
- // semantics.
422
- accessLevel: "none",
423
304
  guidance,
424
305
  denialReasons: reason ? [reason] : ["No valid agent credentials provided"],
425
306
  // Round-10 (#47, O5): on API-error fallback, surface a typed failure so
@@ -513,7 +394,6 @@ async function callVerifyAccessAPI(config, request) {
513
394
  attemptId: typeof data?.attemptId === "string" ? data.attemptId : void 0,
514
395
  access: {
515
396
  allowed: false,
516
- accessLevel: "none",
517
397
  reason: "endpoint_deactivated",
518
398
  failures: [
519
399
  {
@@ -576,7 +456,7 @@ async function verify(config, request, options) {
576
456
  if (!deprecationWarningShown && (config.minTrustScore !== void 0 || config.minTrustScoreForFull !== void 0)) {
577
457
  deprecationWarningShown = true;
578
458
  console.warn(
579
- "[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."
459
+ "[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."
580
460
  );
581
461
  }
582
462
  if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache) {
@@ -622,14 +502,6 @@ async function verify(config, request, options) {
622
502
  const result2 = {
623
503
  identityVerified: idVerifiedFromBackend,
624
504
  policyAllowed: false,
625
- // v2.3.9 (defect #30): denials grant `'none'`, NEVER a positive band.
626
- // Pre-rename this hardcoded `'guidance'`, which conflated with the
627
- // colocated `guidance: {...}` help-payload object below and let
628
- // denied requests pass any route gated at `'guidance'` because
629
- // `hasMinimumAccess('guidance', 'guidance') === true`. Adapters now
630
- // ALSO short-circuit on `!identityVerified || !policyAllowed` before
631
- // the gate check — belt-and-braces.
632
- accessLevel: "none",
633
505
  // 3.6.0: the server now emits top-level denialReasons on every deny
634
506
  // path — prefer it verbatim; the failure-message reconstruction remains
635
507
  // as the fallback for older backends.
@@ -678,7 +550,6 @@ async function verify(config, request, options) {
678
550
  trustScore: apiResponse.organization.trustScore
679
551
  } : void 0;
680
552
  const verificationContext = apiResponse.verificationContext;
681
- const accessLevel = apiResponse.access?.accessLevel ?? "standard";
682
553
  const result = {
683
554
  // 4.5.0 (probe F1): read idVerified from verificationContext with the
684
555
  // SAME absent⇒false default as the deny branch. The previous `!== false`
@@ -690,7 +561,6 @@ async function verify(config, request, options) {
690
561
  // this load-bearing must never be defaulted on.
691
562
  identityVerified: apiResponse.verificationContext?.idVerified === true,
692
563
  policyAllowed: true,
693
- accessLevel,
694
564
  agent,
695
565
  developer,
696
566
  organization,
@@ -717,7 +587,6 @@ async function verify(config, request, options) {
717
587
  };
718
588
  if (result.recommendation === "deny") {
719
589
  result.policyAllowed = false;
720
- result.accessLevel = "none";
721
590
  result.denialReasons = serverDenialReasons ?? result.recommendationReasons ?? ["Access denied by AstraSync recommendation"];
722
591
  result.guidance = result.runtimeChallenge ? {
723
592
  message: `Verification failed: ${result.runtimeChallenge.reason || "runtime challenge failed"}`,
@@ -820,7 +689,6 @@ async function quickVerify(config, credentials) {
820
689
  return {
821
690
  identityVerified: result.identityVerified,
822
691
  policyAllowed: result.policyAllowed,
823
- accessLevel: result.accessLevel,
824
692
  reason: result.denialReasons?.[0]
825
693
  };
826
694
  }
@@ -1850,7 +1718,6 @@ function defaultOnDenied(result, _req, res) {
1850
1718
  error: {
1851
1719
  code: !result.identityVerified ? "UNAUTHORIZED" : "INSUFFICIENT_ACCESS",
1852
1720
  message: result.denialReasons?.[0] || "Access denied",
1853
- accessLevel: result.accessLevel,
1854
1721
  guidance: result.guidance,
1855
1722
  // Round-10: aggregated per-dimension detail + correlation handle.
1856
1723
  failures: result.failures,
@@ -1966,11 +1833,11 @@ function createMiddleware(options) {
1966
1833
  }
1967
1834
  const wellKnownUrls = config.apiBaseUrl ? await getWellKnownUrls(config.apiBaseUrl).catch(() => void 0) : void 0;
1968
1835
  const credentials = customExtractCredentials ? customExtractCredentials(req) : defaultExtractCredentials(req);
1969
- const shouldEnforce = routeConfig.minAccessLevel !== "none";
1970
- if (routeConfig.minAccessLevel === "none" && (!config.evaluateAlwaysIfCredentialed || !credentials.astraId)) {
1836
+ const shouldEnforce = !routeConfig.observe;
1837
+ if (routeConfig.observe && (!config.evaluateAlwaysIfCredentialed || !credentials.astraId)) {
1971
1838
  if (config.setPassThroughHeader) {
1972
1839
  res.setHeader("X-Astra-Gateway-Mode", "unenforced");
1973
- res.setHeader("X-Astra-Gateway-Reason", "route-none");
1840
+ res.setHeader("X-Astra-Gateway-Reason", "route-observe");
1974
1841
  }
1975
1842
  beaconPassThrough?.(req);
1976
1843
  return next();
@@ -2007,7 +1874,6 @@ function createMiddleware(options) {
2007
1874
  const result2 = {
2008
1875
  identityVerified: false,
2009
1876
  policyAllowed: false,
2010
- accessLevel: "none",
2011
1877
  denialReasons: preCheckFailures.map((f) => f.message),
2012
1878
  guidance: {
2013
1879
  message: "Request exceeds counterparty-defined PDLSS limits.",
@@ -2170,7 +2036,6 @@ function createMiddleware(options) {
2170
2036
  const result = {
2171
2037
  identityVerified: false,
2172
2038
  policyAllowed: false,
2173
- accessLevel: "none",
2174
2039
  denialReasons: [`Verification middleware internal error: ${errorClass}`],
2175
2040
  failures: [
2176
2041
  {
@@ -2499,7 +2364,7 @@ function createMiddleware2(options) {
2499
2364
  beaconPassThrough?.(request, pathname);
2500
2365
  return NextResponse.next();
2501
2366
  }
2502
- if (routeConfig.minAccessLevel === "none") {
2367
+ if (routeConfig.observe) {
2503
2368
  beaconPassThrough?.(request, pathname);
2504
2369
  return NextResponse.next();
2505
2370
  }
@@ -2529,7 +2394,6 @@ function createMiddleware2(options) {
2529
2394
  const preCheckResult = {
2530
2395
  identityVerified: false,
2531
2396
  policyAllowed: false,
2532
- accessLevel: "none",
2533
2397
  denialReasons: preCheckFailures.map((f) => f.message),
2534
2398
  guidance: {
2535
2399
  message: "Request exceeds counterparty-defined PDLSS limits.",
@@ -2667,7 +2531,6 @@ function createMiddleware2(options) {
2667
2531
  }
2668
2532
  response.headers.set("X-AstraSync-Identity-Verified", result.identityVerified.toString());
2669
2533
  response.headers.set("X-AstraSync-Policy-Allowed", result.policyAllowed.toString());
2670
- response.headers.set("X-AstraSync-Access-Level", result.accessLevel);
2671
2534
  if (result.agent) {
2672
2535
  response.headers.set("X-AstraSync-Agent-Id", result.agent.astraId);
2673
2536
  }
@@ -2683,9 +2546,7 @@ var sdk_exports = {};
2683
2546
  __export(sdk_exports, {
2684
2547
  VerificationGatewayClient: () => VerificationGatewayClient,
2685
2548
  createClient: () => createClient,
2686
- getCapabilities: () => getCapabilities,
2687
2549
  getTrustLevel: () => getTrustLevel,
2688
- hasMinimumAccess: () => hasMinimumAccess,
2689
2550
  verifyOnce: () => verifyOnce
2690
2551
  });
2691
2552
  var VerificationGatewayClient = class {
@@ -2693,7 +2554,6 @@ var VerificationGatewayClient = class {
2693
2554
  this.config = {
2694
2555
  apiBaseUrl: options.apiBaseUrl,
2695
2556
  apiKey: options.apiKey,
2696
- defaultAccessLevel: options.defaultAccessLevel,
2697
2557
  minTrustScore: options.minTrustScore,
2698
2558
  minTrustScoreForFull: options.minTrustScoreForFull,
2699
2559
  cacheTtl: options.cacheTtl,
@@ -2742,26 +2602,6 @@ var VerificationGatewayClient = class {
2742
2602
  async quickVerify(credentials) {
2743
2603
  return this.executeWithRetry(() => quickVerify(this.config, credentials));
2744
2604
  }
2745
- /**
2746
- * Check if an agent has a specific access level.
2747
- *
2748
- * @deprecated 3.2.0 — the access-level band is informational only; it no
2749
- * longer gates in the middleware adapters (post-3.1.0 feedback #1). This
2750
- * explicit opt-in query still works, but prefer gating on the server-side
2751
- * policy decision (identity + policy + trust) or per-route `minTrustScore`.
2752
- * Explicit per-route condition→constraint rules are the Phase-2 successor.
2753
- */
2754
- async hasAccess(credentials, requiredLevel) {
2755
- const result = await this.quickVerify(credentials);
2756
- return hasMinimumAccess(result.accessLevel, requiredLevel);
2757
- }
2758
- /**
2759
- * Get capabilities for a verified agent
2760
- */
2761
- async getCapabilities(credentials) {
2762
- const result = await this.quickVerify(credentials);
2763
- return getCapabilities(result.accessLevel);
2764
- }
2765
2605
  /**
2766
2606
  * Verify a specific ASTRA-ID
2767
2607
  */
@@ -5492,18 +5332,13 @@ function mcpToPdlss(parsed, requestPath, headerPurpose, headerAction, toolGate)
5492
5332
  }
5493
5333
  return { purpose, action, resource, purposeSource, actionSource };
5494
5334
  }
5495
- function mcpRiskTier(parsed) {
5496
- if (parsed.isInitialize || parsed.method === "notifications/initialized") return "none";
5497
- if (parsed.isIntrospection) return "none";
5498
- if (parsed.method === "resources/read") return "read-only";
5499
- if (parsed.isToolCall) return "standard";
5500
- return "standard";
5335
+ function mcpDefaultEnforced(parsed) {
5336
+ if (parsed.isInitialize || parsed.method === "notifications/initialized") return false;
5337
+ if (parsed.isIntrospection) return false;
5338
+ return true;
5501
5339
  }
5502
5340
 
5503
5341
  // src/adapters/mcp.ts
5504
- function normalizeToolGate(gate) {
5505
- return typeof gate === "string" ? { minAccessLevel: gate } : gate;
5506
- }
5507
5342
  function readSingleHeader(value) {
5508
5343
  if (typeof value === "string") return value;
5509
5344
  if (Array.isArray(value)) return value[0];
@@ -5556,7 +5391,6 @@ function defaultMcpDenied(result, req, res) {
5556
5391
  code: !result.identityVerified ? -32e3 : -32001,
5557
5392
  message: result.denialReasons?.[0] ?? "Access denied",
5558
5393
  data: {
5559
- accessLevel: result.accessLevel,
5560
5394
  guidance: result.guidance,
5561
5395
  // Round-10: aggregated per-dimension detail + correlation handle.
5562
5396
  failures: result.failures,
@@ -5569,20 +5403,19 @@ function defaultMcpDenied(result, req, res) {
5569
5403
  }
5570
5404
  });
5571
5405
  }
5572
- function resolveMinAccessLevel(parsed, opts) {
5406
+ function resolveGate(parsed, opts) {
5573
5407
  if (!parsed.toolName) {
5574
- if (opts.methodGates && opts.methodGates[parsed.method] !== void 0) {
5575
- return { level: opts.methodGates[parsed.method], source: "methodGate" };
5408
+ const methodGate = opts.methodGates?.[parsed.method];
5409
+ if (methodGate !== void 0) {
5410
+ return methodGate === "observe" ? { enforce: false, source: "methodGate" } : { enforce: true, config: methodGate, source: "methodGate" };
5576
5411
  }
5577
- return { level: "none", source: "discovery_default" };
5412
+ return { enforce: false, source: "discovery_default" };
5578
5413
  }
5579
- if (opts.toolGates && opts.toolGates[parsed.toolName] !== void 0) {
5580
- return {
5581
- level: normalizeToolGate(opts.toolGates[parsed.toolName]).minAccessLevel,
5582
- source: "toolGate"
5583
- };
5414
+ const toolGate = opts.toolGates?.[parsed.toolName];
5415
+ if (toolGate !== void 0) {
5416
+ return toolGate === "observe" ? { enforce: false, source: "toolGate" } : { enforce: true, config: toolGate, source: "toolGate" };
5584
5417
  }
5585
- return { level: mcpRiskTier(parsed), source: "tier" };
5418
+ return { enforce: mcpDefaultEnforced(parsed), source: "tier" };
5586
5419
  }
5587
5420
  function createMcpMiddleware(options) {
5588
5421
  const {
@@ -5602,15 +5435,6 @@ function createMcpMiddleware(options) {
5602
5435
  prefetchWellKnown(config.apiBaseUrl).catch(() => {
5603
5436
  });
5604
5437
  }
5605
- if (toolGates) {
5606
- for (const [toolName, gate] of Object.entries(toolGates)) {
5607
- if (typeof gate === "string") {
5608
- console.warn(
5609
- `[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: '...' }.`
5610
- );
5611
- }
5612
- }
5613
- }
5614
5438
  return async (req, res, next) => {
5615
5439
  try {
5616
5440
  if (skip) return next();
@@ -5659,7 +5483,7 @@ function createMcpMiddleware(options) {
5659
5483
  return next();
5660
5484
  }
5661
5485
  }
5662
- const { level: minAccessLevel } = resolveMinAccessLevel(parsed, {
5486
+ const gateDecision = resolveGate(parsed, {
5663
5487
  toolGates,
5664
5488
  methodGates
5665
5489
  });
@@ -5668,16 +5492,15 @@ function createMcpMiddleware(options) {
5668
5492
  req.query
5669
5493
  );
5670
5494
  if (effectiveAstraId) credentials.astraId = effectiveAstraId;
5671
- const shouldEnforce = minAccessLevel !== "none";
5672
- if (minAccessLevel === "none" && (!config.evaluateAlwaysIfCredentialed || !credentials.astraId)) {
5495
+ const shouldEnforce = gateDecision.enforce;
5496
+ if (!shouldEnforce && (!config.evaluateAlwaysIfCredentialed || !credentials.astraId)) {
5673
5497
  if (config.setPassThroughHeader) {
5674
5498
  res.setHeader("X-Astra-Gateway-Mode", "unenforced");
5675
- res.setHeader("X-Astra-Gateway-Reason", "mcp-tier-none");
5499
+ res.setHeader("X-Astra-Gateway-Reason", "mcp-observe");
5676
5500
  }
5677
5501
  return next();
5678
5502
  }
5679
- const rawGate = parsed.toolName && toolGates?.[parsed.toolName];
5680
- const gate = rawGate ? normalizeToolGate(rawGate) : void 0;
5503
+ const gate = gateDecision.config;
5681
5504
  const headerPurpose = readSingleHeader(req.headers["x-astra-purpose"]);
5682
5505
  const headerAction = readSingleHeader(req.headers["x-astra-action"]);
5683
5506
  const pdlss = mcpToPdlss(
@@ -5813,7 +5636,6 @@ function createMcpMiddleware(options) {
5813
5636
  const result = {
5814
5637
  identityVerified: false,
5815
5638
  policyAllowed: false,
5816
- accessLevel: "none",
5817
5639
  denialReasons: [`MCP middleware internal error: ${errorClass}`],
5818
5640
  failures: [
5819
5641
  {
@@ -6568,8 +6390,6 @@ function detectRuntime(userAgent) {
6568
6390
  return void 0;
6569
6391
  }
6570
6392
  export {
6571
- ACCESS_LEVEL_DESCRIPTIONS,
6572
- ACCESS_LEVEL_HIERARCHY,
6573
6393
  AgentClient,
6574
6394
  AstraSync,
6575
6395
  AstraSyncError,
@@ -6577,7 +6397,6 @@ export {
6577
6397
  CAPTURE_SCHEMA_VERSION,
6578
6398
  ChallengeHandler,
6579
6399
  DEFAULT_EDGE_CONFIG,
6580
- DEFAULT_TRUST_THRESHOLDS,
6581
6400
  KYDRequiredError,
6582
6401
  MAX_HEADERS,
6583
6402
  MAX_HEADER_VALUE_BYTES,
@@ -6604,7 +6423,6 @@ export {
6604
6423
  deriveConnectionFromHeaders,
6605
6424
  detectPlatformFingerprint,
6606
6425
  detectRuntime,
6607
- determineAccessLevel,
6608
6426
  express_exports as express,
6609
6427
  extractApiKeyFormat,
6610
6428
  extractCredentials,
@@ -6612,14 +6430,11 @@ export {
6612
6430
  extractPlatformHeaders,
6613
6431
  fetchEdgeConfig,
6614
6432
  fetchRoutes,
6615
- getAccessLevelForScore,
6616
6433
  getCachedWellKnownUrls,
6617
- getCapabilities,
6618
6434
  getEdgeConfig,
6619
6435
  getTrustLevel,
6620
6436
  getWellKnownUrls,
6621
6437
  hasCredentials,
6622
- hasMinimumAccess,
6623
6438
  isEdgeConfig,
6624
6439
  isVerifiedHopValidFor,
6625
6440
  matchEdgePathRule,