@astrasyncai/verification-gateway 4.4.0 → 4.5.1

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 (79) hide show
  1. package/dist/adapters/express.js +14 -10
  2. package/dist/adapters/express.js.map +1 -1
  3. package/dist/adapters/express.mjs +14 -10
  4. package/dist/adapters/express.mjs.map +1 -1
  5. package/dist/adapters/mcp.d.mts +3 -394
  6. package/dist/adapters/mcp.d.ts +3 -394
  7. package/dist/adapters/mcp.js +12 -9
  8. package/dist/adapters/mcp.js.map +1 -1
  9. package/dist/adapters/mcp.mjs +12 -9
  10. package/dist/adapters/mcp.mjs.map +1 -1
  11. package/dist/adapters/nextjs.js +15 -11
  12. package/dist/adapters/nextjs.js.map +1 -1
  13. package/dist/adapters/nextjs.mjs +15 -11
  14. package/dist/adapters/nextjs.mjs.map +1 -1
  15. package/dist/adapters/sdk.js +10 -7
  16. package/dist/adapters/sdk.js.map +1 -1
  17. package/dist/adapters/sdk.mjs +10 -7
  18. package/dist/adapters/sdk.mjs.map +1 -1
  19. package/dist/agent/index.js +1 -1
  20. package/dist/agent/index.js.map +1 -1
  21. package/dist/agent/index.mjs +1 -1
  22. package/dist/agent/index.mjs.map +1 -1
  23. package/dist/bin/astrasync-claude-hook.js +10 -7
  24. package/dist/bin/astrasync-codex-hook.js +10 -7
  25. package/dist/bin/astrasync-guard.js +10 -7
  26. package/dist/bin/astrasync.js +11 -7
  27. package/dist/browser/background.js +10 -7
  28. package/dist/browser/background.js.map +1 -1
  29. package/dist/browser/background.mjs +10 -7
  30. package/dist/browser/background.mjs.map +1 -1
  31. package/dist/cli/index.js +1 -1
  32. package/dist/cli/index.js.map +1 -1
  33. package/dist/cli/index.mjs +1 -1
  34. package/dist/cli/index.mjs.map +1 -1
  35. package/dist/codex/index.js +10 -7
  36. package/dist/codex/index.js.map +1 -1
  37. package/dist/codex/index.mjs +10 -7
  38. package/dist/codex/index.mjs.map +1 -1
  39. package/dist/cursor/extension.js +10 -7
  40. package/dist/cursor/extension.js.map +1 -1
  41. package/dist/cursor/extension.mjs +10 -7
  42. package/dist/cursor/extension.mjs.map +1 -1
  43. package/dist/edge-config.d.mts +11 -4
  44. package/dist/edge-config.d.ts +11 -4
  45. package/dist/edge-config.js +1 -1
  46. package/dist/edge-config.js.map +1 -1
  47. package/dist/edge-config.mjs +1 -1
  48. package/dist/edge-config.mjs.map +1 -1
  49. package/dist/edge-core/index.d.mts +21 -7
  50. package/dist/edge-core/index.d.ts +21 -7
  51. package/dist/edge-core/index.js +75 -15
  52. package/dist/edge-core/index.js.map +1 -1
  53. package/dist/edge-core/index.mjs +75 -15
  54. package/dist/edge-core/index.mjs.map +1 -1
  55. package/dist/gateway/gateway.js +10 -7
  56. package/dist/gateway/gateway.js.map +1 -1
  57. package/dist/gateway/gateway.mjs +10 -7
  58. package/dist/gateway/gateway.mjs.map +1 -1
  59. package/dist/index.d.mts +3 -3
  60. package/dist/index.d.ts +3 -3
  61. package/dist/index.js +30 -15
  62. package/dist/index.js.map +1 -1
  63. package/dist/index.mjs +25 -15
  64. package/dist/index.mjs.map +1 -1
  65. package/dist/mcp--DgKOwfu.d.ts +396 -0
  66. package/dist/mcp-BgBJu4Jl.d.mts +396 -0
  67. package/dist/registration/index.js +2 -1
  68. package/dist/registration/index.js.map +1 -1
  69. package/dist/registration/index.mjs +2 -1
  70. package/dist/registration/index.mjs.map +1 -1
  71. package/dist/transport/index.js +1 -1
  72. package/dist/transport/index.js.map +1 -1
  73. package/dist/transport/index.mjs +1 -1
  74. package/dist/transport/index.mjs.map +1 -1
  75. package/dist/verify.js +10 -7
  76. package/dist/verify.js.map +1 -1
  77. package/dist/verify.mjs +10 -7
  78. package/dist/verify.mjs.map +1 -1
  79. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var SDK_VERSION = "4.4.0";
2
+ var SDK_VERSION = "4.5.1";
3
3
 
4
4
  // src/http.ts
5
5
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -789,12 +789,15 @@ async function verify(config, request, options) {
789
789
  const verificationContext = apiResponse.verificationContext;
790
790
  const accessLevel = apiResponse.access?.accessLevel ?? "standard";
791
791
  const result = {
792
- // Round-18 G4: backend allowed access. Identity is verified (we resolved
793
- // the caller to an agent) and policy passed all gates. Read idVerified
794
- // from verificationContext for symmetry with the deny branch; default true
795
- // on success path since `access.allowed === true` implies identity was
796
- // resolvable (anonymous-allow paths flow through createGuidanceResponse).
797
- identityVerified: apiResponse.verificationContext?.idVerified !== false,
792
+ // 4.5.0 (probe F1): read idVerified from verificationContext with the
793
+ // SAME absent⇒false default as the deny branch. The previous `!== false`
794
+ // default manufactured `identityVerified: true` for anonymous
795
+ // allow_full/allow_partial/audit responses (which allow access but omit
796
+ // verificationContext entirely) — the "anonymous caller labelled
797
+ // verified" defect. Every authenticated success response has carried
798
+ // `verificationContext.idVerified: true` since v2.2.4, so a truth claim
799
+ // this load-bearing must never be defaulted on.
800
+ identityVerified: apiResponse.verificationContext?.idVerified === true,
798
801
  policyAllowed: true,
799
802
  accessLevel,
800
803
  agent,
@@ -1045,6 +1048,7 @@ function detectCommerce(req, host) {
1045
1048
 
1046
1049
  // src/edge-core/classify.ts
1047
1050
  var STATIC_EXTENSIONS = /\.(css|js|mjs|map|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|otf|eot|mp4|webm|pdf|txt|xml)$/i;
1051
+ var SELF_UA_PATTERN = /^astrasync-sdk\//i;
1048
1052
  var BOT_UA_PATTERN = /curl|wget|python-requests|python-urllib|node-fetch|axios|got|okhttp|go-http-client|libwww|httpie|java\/|ruby|php|scrapy|headless|phantomjs|selenium|playwright|puppeteer|bot|crawler|spider|slurp/i;
1049
1053
  var BROWSER_UA_PATTERN = /mozilla\/\d/i;
1050
1054
  function resolvePolicy(config, path) {
@@ -1061,6 +1065,9 @@ function resolvePolicy(config, path) {
1061
1065
  }
1062
1066
  function classify(req, host, depth) {
1063
1067
  const userAgent = headerValue(req, "user-agent") ?? "";
1068
+ if (SELF_UA_PATTERN.test(userAgent)) {
1069
+ return { tier: "self" };
1070
+ }
1064
1071
  const credentials = extractCredentials(req.headers, {});
1065
1072
  if (credentials.astraId || credentials.apiKey || credentials.jwt) {
1066
1073
  return { tier: "verified", protocol: "x-astra" };
@@ -1091,7 +1098,7 @@ function classify(req, host, depth) {
1091
1098
  }
1092
1099
  return { tier: "human" };
1093
1100
  }
1094
- var _patterns = { STATIC_EXTENSIONS, BOT_UA_PATTERN, BROWSER_UA_PATTERN };
1101
+ var _patterns = { STATIC_EXTENSIONS, BOT_UA_PATTERN, BROWSER_UA_PATTERN, SELF_UA_PATTERN };
1095
1102
 
1096
1103
  // src/edge-core/messaging.ts
1097
1104
  var PROTOCOL_MESSAGES = {
@@ -1131,6 +1138,20 @@ function buildDenyBody(outcome, apiBaseUrl) {
1131
1138
  }
1132
1139
  };
1133
1140
  }
1141
+ function buildUnavailableBody(outcome) {
1142
+ return {
1143
+ success: false,
1144
+ error: {
1145
+ code: "VERIFICATION_UNAVAILABLE",
1146
+ message: "Agent verification is temporarily unavailable and this path enforces verification. Your identity was not evaluated and no denial was recorded \u2014 retry with exponential backoff.",
1147
+ failures: outcome.reasons,
1148
+ ...outcome.correlationId && { correlationId: outcome.correlationId },
1149
+ guidance: {
1150
+ message: "Retry the request with exponential backoff; the condition is transient."
1151
+ }
1152
+ }
1153
+ };
1154
+ }
1134
1155
  function buildManualReviewBody(outcome) {
1135
1156
  return {
1136
1157
  success: false,
@@ -1173,6 +1194,14 @@ function applyOutcome(options, outcome, policy) {
1173
1194
  }
1174
1195
  switch (outcome.decision) {
1175
1196
  case "deny":
1197
+ if (outcome.unavailable) {
1198
+ return {
1199
+ action: "respond",
1200
+ status: 503,
1201
+ headers: { "Retry-After": "30" },
1202
+ bodyJson: buildUnavailableBody(outcome)
1203
+ };
1204
+ }
1176
1205
  return {
1177
1206
  action: "respond",
1178
1207
  status: 403,
@@ -1411,6 +1440,17 @@ function outcomeFromVerifyResult(classification, result) {
1411
1440
  };
1412
1441
  return outcome;
1413
1442
  }
1443
+ function unavailableOutcome(classification, policy, reason, correlationId) {
1444
+ const outcome = baseOutcome(classification);
1445
+ outcome.unavailable = true;
1446
+ outcome.reasons = [reason];
1447
+ if (correlationId) outcome.correlationId = correlationId;
1448
+ if (policy.mode === "enforce") outcome.decision = "deny";
1449
+ return outcome;
1450
+ }
1451
+ function isApiErrorResult(result) {
1452
+ return (result.failures ?? []).some((f) => f.dimension === "verify_access.api_error") === true && !result.misconfigured;
1453
+ }
1414
1454
  async function runTier(options, req, classification, policy, apiKey, sampling) {
1415
1455
  const budgets = options.budgets ?? {};
1416
1456
  const beaconMs = budgets.beaconMs ?? 300;
@@ -1437,9 +1477,19 @@ async function runTier(options, req, classification, policy, apiKey, sampling) {
1437
1477
  verifyMs
1438
1478
  );
1439
1479
  if (!result) {
1440
- const outcome = baseOutcome(classification);
1441
- outcome.reasons = ["verify-access unreachable within budget \u2014 fail-open"];
1442
- return outcome;
1480
+ return unavailableOutcome(
1481
+ classification,
1482
+ policy,
1483
+ "verify-access unreachable within budget"
1484
+ );
1485
+ }
1486
+ if (isApiErrorResult(result)) {
1487
+ return unavailableOutcome(
1488
+ classification,
1489
+ policy,
1490
+ result.denialReasons?.[0] ?? "verify-access api error",
1491
+ result.correlationId
1492
+ );
1443
1493
  }
1444
1494
  return outcomeFromVerifyResult(classification, result);
1445
1495
  }
@@ -1450,9 +1500,19 @@ async function runTier(options, req, classification, policy, apiKey, sampling) {
1450
1500
  verifyMs
1451
1501
  );
1452
1502
  if (!result) {
1453
- const outcome2 = baseOutcome(classification);
1454
- outcome2.reasons = ["verify-access unreachable within budget \u2014 fail-open"];
1455
- return outcome2;
1503
+ return unavailableOutcome(
1504
+ classification,
1505
+ policy,
1506
+ "verify-access unreachable within budget"
1507
+ );
1508
+ }
1509
+ if (isApiErrorResult(result)) {
1510
+ return unavailableOutcome(
1511
+ classification,
1512
+ policy,
1513
+ result.denialReasons?.[0] ?? "verify-access api error",
1514
+ result.correlationId
1515
+ );
1456
1516
  }
1457
1517
  return outcomeFromVerifyResult(classification, result);
1458
1518
  }
@@ -1494,7 +1554,7 @@ async function evaluateEdgeRequest(options, req, config, apiKey) {
1494
1554
  if (policy.skip) return { policy, application: passUntouched() };
1495
1555
  const host = headerValue(req, "x-forwarded-host") ?? headerValue(req, "host") ?? new URL(options.counterpartyUrl).host;
1496
1556
  const classification = classify(req, host, policy.depth);
1497
- if (classification.tier === "human") {
1557
+ if (classification.tier === "human" || classification.tier === "self") {
1498
1558
  return { policy, classification, application: passUntouched() };
1499
1559
  }
1500
1560
  const outcome = await runTier(options, req, classification, policy, apiKey, config.sampling);