@astrasyncai/verification-gateway 5.14.0 → 5.16.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 (100) hide show
  1. package/README.md +36 -18
  2. package/dist/adapters/express.d.mts +1 -1
  3. package/dist/adapters/express.d.ts +1 -1
  4. package/dist/adapters/express.js +492 -240
  5. package/dist/adapters/express.js.map +1 -1
  6. package/dist/adapters/express.mjs +492 -240
  7. package/dist/adapters/express.mjs.map +1 -1
  8. package/dist/adapters/mcp.d.mts +1 -1
  9. package/dist/adapters/mcp.d.ts +1 -1
  10. package/dist/adapters/mcp.js +23 -6
  11. package/dist/adapters/mcp.js.map +1 -1
  12. package/dist/adapters/mcp.mjs +23 -6
  13. package/dist/adapters/mcp.mjs.map +1 -1
  14. package/dist/adapters/nextjs.d.mts +1 -1
  15. package/dist/adapters/nextjs.d.ts +1 -1
  16. package/dist/adapters/nextjs.js +475 -239
  17. package/dist/adapters/nextjs.js.map +1 -1
  18. package/dist/adapters/nextjs.mjs +475 -239
  19. package/dist/adapters/nextjs.mjs.map +1 -1
  20. package/dist/adapters/sdk.d.mts +18 -10
  21. package/dist/adapters/sdk.d.ts +18 -10
  22. package/dist/adapters/sdk.js +83 -23
  23. package/dist/adapters/sdk.js.map +1 -1
  24. package/dist/adapters/sdk.mjs +83 -23
  25. package/dist/adapters/sdk.mjs.map +1 -1
  26. package/dist/agent/index.d.mts +69 -54
  27. package/dist/agent/index.d.ts +69 -54
  28. package/dist/agent/index.js +24 -14
  29. package/dist/agent/index.js.map +1 -1
  30. package/dist/agent/index.mjs +24 -14
  31. package/dist/agent/index.mjs.map +1 -1
  32. package/dist/bin/astrasync-claude-hook.js +58 -11
  33. package/dist/bin/astrasync-codex-hook.js +58 -11
  34. package/dist/bin/astrasync-guard.js +177 -11
  35. package/dist/bin/astrasync.js +433 -38
  36. package/dist/browser/background.js +53 -6
  37. package/dist/browser/background.js.map +1 -1
  38. package/dist/browser/background.mjs +63 -6
  39. package/dist/browser/background.mjs.map +1 -1
  40. package/dist/cli/index.js +1 -1
  41. package/dist/cli/index.js.map +1 -1
  42. package/dist/cli/index.mjs +1 -1
  43. package/dist/cli/index.mjs.map +1 -1
  44. package/dist/codex/index.js +58 -11
  45. package/dist/codex/index.js.map +1 -1
  46. package/dist/codex/index.mjs +68 -11
  47. package/dist/codex/index.mjs.map +1 -1
  48. package/dist/cursor/extension.js +58 -11
  49. package/dist/cursor/extension.js.map +1 -1
  50. package/dist/cursor/extension.mjs +68 -11
  51. package/dist/cursor/extension.mjs.map +1 -1
  52. package/dist/edge-config.d.mts +31 -2
  53. package/dist/edge-config.d.ts +31 -2
  54. package/dist/edge-config.js +35 -5
  55. package/dist/edge-config.js.map +1 -1
  56. package/dist/edge-config.mjs +32 -4
  57. package/dist/edge-config.mjs.map +1 -1
  58. package/dist/edge-core/index.d.mts +11 -2
  59. package/dist/edge-core/index.d.ts +11 -2
  60. package/dist/edge-core/index.js +97 -11
  61. package/dist/edge-core/index.js.map +1 -1
  62. package/dist/edge-core/index.mjs +95 -11
  63. package/dist/edge-core/index.mjs.map +1 -1
  64. package/dist/gateway/gateway.js +53 -6
  65. package/dist/gateway/gateway.js.map +1 -1
  66. package/dist/gateway/gateway.mjs +63 -6
  67. package/dist/gateway/gateway.mjs.map +1 -1
  68. package/dist/git-trigger/git-hooks.d.mts +1 -1
  69. package/dist/git-trigger/git-hooks.d.ts +1 -1
  70. package/dist/index.d.mts +1407 -88
  71. package/dist/index.d.ts +1407 -88
  72. package/dist/index.js +5148 -2616
  73. package/dist/index.js.map +1 -1
  74. package/dist/index.mjs +5094 -2618
  75. package/dist/index.mjs.map +1 -1
  76. package/dist/registration/index.d.mts +28 -2
  77. package/dist/registration/index.d.ts +28 -2
  78. package/dist/registration/index.js +18 -3
  79. package/dist/registration/index.js.map +1 -1
  80. package/dist/registration/index.mjs +15 -2
  81. package/dist/registration/index.mjs.map +1 -1
  82. package/dist/transport/index.d.mts +7 -5
  83. package/dist/transport/index.d.ts +7 -5
  84. package/dist/transport/index.js +61 -5
  85. package/dist/transport/index.js.map +1 -1
  86. package/dist/transport/index.mjs +67 -11
  87. package/dist/transport/index.mjs.map +1 -1
  88. package/dist/{types-BCkwBA84.d.mts → types-Blz520bR.d.mts} +116 -12
  89. package/dist/{types-BCkwBA84.d.ts → types-Blz520bR.d.ts} +116 -12
  90. package/dist/{types-C_b4QTyO.d.ts → types-Bm1QvGqI.d.ts} +114 -10
  91. package/dist/{types-DlshIIR-.d.mts → types-DBe4hgfT.d.mts} +114 -10
  92. package/dist/ui/index.d.mts +1 -1
  93. package/dist/ui/index.d.ts +1 -1
  94. package/dist/verify.d.mts +1 -1
  95. package/dist/verify.d.ts +1 -1
  96. package/dist/verify.js +23 -6
  97. package/dist/verify.js.map +1 -1
  98. package/dist/verify.mjs +23 -6
  99. package/dist/verify.mjs.map +1 -1
  100. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var SDK_VERSION = "5.14.0";
2
+ var SDK_VERSION = "5.16.0";
3
3
 
4
4
  // src/http.ts
5
5
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -19,6 +19,29 @@ function withUserAgent(initHeaders) {
19
19
  }
20
20
  var sdkFetch = (input, init) => fetch(input, { ...init, headers: withUserAgent(init?.headers) });
21
21
 
22
+ // src/route-pattern.ts
23
+ function routePatternToRegExp(pattern, opts = {}) {
24
+ let source = "";
25
+ for (let i = 0; i < pattern.length; i++) {
26
+ const ch = pattern[i];
27
+ if (ch === "*") {
28
+ source += ".*";
29
+ } else if (ch === ":" && /[A-Za-z_]/.test(pattern[i + 1] ?? "") && (i === 0 || pattern[i - 1] === "/")) {
30
+ let j = i + 1;
31
+ while (j < pattern.length && /[A-Za-z0-9_]/.test(pattern[j])) j++;
32
+ source += "[^/]+";
33
+ i = j - 1;
34
+ } else {
35
+ source += ch.replace(/[.+?^${}()|[\]\\/]/g, "\\$&");
36
+ }
37
+ }
38
+ try {
39
+ return new RegExp(`^${source}$`, opts.caseInsensitive ? "i" : "");
40
+ } catch {
41
+ return null;
42
+ }
43
+ }
44
+
22
45
  // src/edge-config.ts
23
46
  var DEFAULT_EDGE_CONFIG = Object.freeze({
24
47
  version: 1,
@@ -37,8 +60,7 @@ function matchEdgePathRule(rules, path) {
37
60
  return void 0;
38
61
  }
39
62
  function globToRegExp(pattern) {
40
- const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
41
- return new RegExp(`^${escaped}$`, "i");
63
+ return routePatternToRegExp(pattern, { caseInsensitive: true }) ?? /$^/;
42
64
  }
43
65
 
44
66
  // src/metadata-capture.ts
@@ -467,6 +489,8 @@ function getCacheKey(request, counterpartyId) {
467
489
  request.durationRequired ?? "",
468
490
  request.invocationProtocol || "",
469
491
  request.enableRuntimeChallenge ? "1" : "0",
492
+ // 5.16.0: route policy changes the verdict (owners / challenge).
493
+ request.routePolicy ? JSON.stringify(request.routePolicy) : "",
470
494
  // callerMetadata fields contribute to risk model; include the ones
471
495
  // backend reads. sourceIp/userAgent/forwardedFor change per-request
472
496
  // so their inclusion effectively forces a re-check for any varying
@@ -673,6 +697,7 @@ async function callVerifyAccessAPI(config, request) {
673
697
  if (requestData.subAgentDepth !== void 0) body.subAgentDepth = requestData.subAgentDepth;
674
698
  if (requestData.enableRuntimeChallenge)
675
699
  body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
700
+ if (requestData.routePolicy) body.routePolicy = requestData.routePolicy;
676
701
  if (requestData.createSession) body.createSession = requestData.createSession;
677
702
  if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
678
703
  if (requestData.counterpartyType) body.counterpartyType = requestData.counterpartyType;
@@ -683,6 +708,7 @@ async function callVerifyAccessAPI(config, request) {
683
708
  if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
684
709
  if (requestData.commercePhase) body.commercePhase = requestData.commercePhase;
685
710
  if (requestData.checkoutSessionId) body.checkoutSessionId = requestData.checkoutSessionId;
711
+ if (requestData.checkoutJwt) body.checkoutJwt = requestData.checkoutJwt;
686
712
  if (requestData.checkoutItems) body.checkoutItems = requestData.checkoutItems;
687
713
  if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
688
714
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
@@ -833,7 +859,8 @@ async function verify(config, request, options) {
833
859
  "[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."
834
860
  );
835
861
  }
836
- if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache) {
862
+ const uncacheable = Boolean(request.commerceArtifacts);
863
+ if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
837
864
  const cached = getCachedResult(request, mergedConfig.counterpartyId);
838
865
  if (cached) {
839
866
  if (mergedConfig.debug) {
@@ -914,7 +941,10 @@ async function verify(config, request, options) {
914
941
  // MERCHANT caller only (bridge callers strip it before the agent plane).
915
942
  settlementToken: apiResponse.settlementToken,
916
943
  // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
917
- fulfilment: apiResponse.fulfilment
944
+ fulfilment: apiResponse.fulfilment,
945
+ mandates: apiResponse.mandates,
946
+ kyaToken: apiResponse.kyaToken,
947
+ aep: apiResponse.aep
918
948
  };
919
949
  return result2;
920
950
  }
@@ -924,7 +954,10 @@ async function verify(config, request, options) {
924
954
  trustScore: apiResponse.agent.trustScore,
925
955
  trustLevel: getTrustLevel(apiResponse.agent.trustScore),
926
956
  blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
927
- status: apiResponse.agent.agentStatus
957
+ status: apiResponse.agent.agentStatus,
958
+ ...apiResponse.agent.protocolIdentities && {
959
+ protocolIdentities: apiResponse.agent.protocolIdentities
960
+ }
928
961
  } : void 0;
929
962
  const developer = apiResponse.developer ? {
930
963
  astradId: apiResponse.developer.kyaOwnerId,
@@ -975,7 +1008,11 @@ async function verify(config, request, options) {
975
1008
  settlementOutcome: apiResponse.settlementOutcome,
976
1009
  settlementToken: apiResponse.settlementToken,
977
1010
  // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
978
- fulfilment: apiResponse.fulfilment
1011
+ fulfilment: apiResponse.fulfilment,
1012
+ // 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
1013
+ mandates: apiResponse.mandates,
1014
+ kyaToken: apiResponse.kyaToken,
1015
+ aep: apiResponse.aep
979
1016
  };
980
1017
  if (result.recommendation === "deny") {
981
1018
  result.policyAllowed = false;
@@ -995,7 +1032,9 @@ async function verify(config, request, options) {
995
1032
  }
996
1033
  const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
997
1034
  if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
998
- cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
1035
+ if (!uncacheable) {
1036
+ cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
1037
+ }
999
1038
  }
1000
1039
  return result;
1001
1040
  }
@@ -1162,7 +1201,7 @@ function detectCommerce(req, host) {
1162
1201
  evidence: { hasTimestamp: Boolean(acpTimestamp), ...truncated }
1163
1202
  };
1164
1203
  }
1165
- if (/\/checkout[-_]sessions(\/|$)/.test(req.uri)) {
1204
+ if (/\/checkout[-_]sessions(\/|$)/.test(req.uri) && headerValue(req, "ucp-agent")) {
1166
1205
  return {
1167
1206
  protocol: "ucp",
1168
1207
  artifacts: { ucpRequest: { method, url, ...jsonBody && { body: jsonBody } } },
@@ -1194,7 +1233,7 @@ function detectCommerce(req, host) {
1194
1233
  };
1195
1234
  }
1196
1235
  }
1197
- if (authHeader && /^Payment\s+/i.test(authHeader)) {
1236
+ if (authHeader && /^Payment\s+/i.test(authHeader) || headerValue(req, "payment-authorization")) {
1198
1237
  return {
1199
1238
  protocol: "mpp",
1200
1239
  artifacts: {
@@ -1209,7 +1248,7 @@ function detectCommerce(req, host) {
1209
1248
  evidence: truncated
1210
1249
  };
1211
1250
  }
1212
- if (headerValue(req, "x-payment")) {
1251
+ if (headerValue(req, "payment-signature") || headerValue(req, "x-payment")) {
1213
1252
  return {
1214
1253
  protocol: "x402",
1215
1254
  artifacts: {
@@ -1871,6 +1910,7 @@ function outcomeFromVerifyResult(classification, result) {
1871
1910
  outcome.reasons = ["step-up approval required"];
1872
1911
  outcome.stepUp = {
1873
1912
  pollUrl: result.stepUpApproval?.pollUrl,
1913
+ approvalUrl: result.stepUpApproval?.approvalUrl,
1874
1914
  expiresAt: result.stepUpApproval?.expiresAt
1875
1915
  };
1876
1916
  return outcome;
@@ -2016,6 +2056,20 @@ async function evaluateEdgeRequest(options, req, config, apiKey) {
2016
2056
  if (classification.tier === "human" || classification.tier === "self") {
2017
2057
  return { policy, classification, application: passUntouched() };
2018
2058
  }
2059
+ const tls = checkMinTls(req, config.minTls);
2060
+ if (tls) {
2061
+ if (policy.mode === "enforce") {
2062
+ options.log?.(
2063
+ "info",
2064
+ `TLS ${tls.negotiated} below ${tls.minimum}: ${req.method} ${req.uri}`
2065
+ );
2066
+ return { policy, classification, application: tlsUpgradeRequired(tls) };
2067
+ }
2068
+ options.log?.(
2069
+ "info",
2070
+ `[OBSERVE] would have required TLS ${tls.minimum} (got ${tls.negotiated}): ${req.method} ${req.uri}`
2071
+ );
2072
+ }
2019
2073
  const outcome = await runTier(options, req, classification, policy, apiKey, {
2020
2074
  sampling: policy.sampling ?? config.sampling,
2021
2075
  queryValueAllowlist: config.queryValueAllowlist
@@ -2040,6 +2094,34 @@ async function evaluateEdgeRequest(options, req, config, apiKey) {
2040
2094
  return { policy, application: passUntouched() };
2041
2095
  }
2042
2096
  }
2097
+ function negotiatedTlsVersion(req) {
2098
+ const raw = req.connection?.tlsVersion ?? headerValue(req, "cloudfront-viewer-tls");
2099
+ const m = raw ? /^TLSv(1(?:\.\d)?)/i.exec(raw) : null;
2100
+ return m ? m[1] === "1" ? "1.0" : m[1] : null;
2101
+ }
2102
+ function checkMinTls(req, minTls) {
2103
+ if (!minTls) return null;
2104
+ const negotiated = negotiatedTlsVersion(req);
2105
+ if (!negotiated) return null;
2106
+ return Number(negotiated) < Number(minTls) ? { minimum: minTls, negotiated } : null;
2107
+ }
2108
+ function tlsUpgradeRequired(v) {
2109
+ return {
2110
+ action: "respond",
2111
+ status: 426,
2112
+ headers: {
2113
+ "content-type": "application/json",
2114
+ upgrade: `TLS/${v.minimum}`,
2115
+ connection: "Upgrade"
2116
+ },
2117
+ bodyJson: {
2118
+ error: "tls_version_too_low",
2119
+ minimum: `TLS ${v.minimum}`,
2120
+ negotiated: `TLS ${v.negotiated}`,
2121
+ message: `This endpoint requires TLS ${v.minimum} or later for agent requests. Reconnect with TLS ${v.minimum}.`
2122
+ }
2123
+ };
2124
+ }
2043
2125
  export {
2044
2126
  ASAT_HEADERS,
2045
2127
  BeaconBuffer,
@@ -2049,12 +2131,14 @@ export {
2049
2131
  buildManualReviewBody,
2050
2132
  buildObservedMetadata,
2051
2133
  buildVerificationRequest,
2134
+ checkMinTls,
2052
2135
  classify,
2053
2136
  detectCommerce,
2054
2137
  emitBeacon,
2055
2138
  evaluateEdgeRequest,
2056
2139
  getBeaconBuffer,
2057
2140
  headerValue,
2141
+ negotiatedTlsVersion,
2058
2142
  outcomeFromVerifyResult,
2059
2143
  passUntouched,
2060
2144
  requestUrl,