@astrasyncai/verification-gateway 5.14.0 → 5.15.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 (98) hide show
  1. package/README.md +27 -17
  2. package/dist/adapters/express.d.mts +1 -1
  3. package/dist/adapters/express.d.ts +1 -1
  4. package/dist/adapters/express.js +477 -240
  5. package/dist/adapters/express.js.map +1 -1
  6. package/dist/adapters/express.mjs +477 -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 +20 -6
  11. package/dist/adapters/mcp.js.map +1 -1
  12. package/dist/adapters/mcp.mjs +20 -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 +460 -239
  17. package/dist/adapters/nextjs.js.map +1 -1
  18. package/dist/adapters/nextjs.mjs +460 -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 +80 -23
  23. package/dist/adapters/sdk.js.map +1 -1
  24. package/dist/adapters/sdk.mjs +80 -23
  25. package/dist/adapters/sdk.mjs.map +1 -1
  26. package/dist/agent/index.js +1 -1
  27. package/dist/agent/index.js.map +1 -1
  28. package/dist/agent/index.mjs +1 -1
  29. package/dist/agent/index.mjs.map +1 -1
  30. package/dist/bin/astrasync-claude-hook.js +55 -11
  31. package/dist/bin/astrasync-codex-hook.js +55 -11
  32. package/dist/bin/astrasync-guard.js +55 -11
  33. package/dist/bin/astrasync.js +288 -33
  34. package/dist/browser/background.js +50 -6
  35. package/dist/browser/background.js.map +1 -1
  36. package/dist/browser/background.mjs +60 -6
  37. package/dist/browser/background.mjs.map +1 -1
  38. package/dist/cli/index.js +1 -1
  39. package/dist/cli/index.js.map +1 -1
  40. package/dist/cli/index.mjs +1 -1
  41. package/dist/cli/index.mjs.map +1 -1
  42. package/dist/codex/index.js +55 -11
  43. package/dist/codex/index.js.map +1 -1
  44. package/dist/codex/index.mjs +65 -11
  45. package/dist/codex/index.mjs.map +1 -1
  46. package/dist/cursor/extension.js +55 -11
  47. package/dist/cursor/extension.js.map +1 -1
  48. package/dist/cursor/extension.mjs +65 -11
  49. package/dist/cursor/extension.mjs.map +1 -1
  50. package/dist/edge-config.d.mts +31 -2
  51. package/dist/edge-config.d.ts +31 -2
  52. package/dist/edge-config.js +35 -5
  53. package/dist/edge-config.js.map +1 -1
  54. package/dist/edge-config.mjs +32 -4
  55. package/dist/edge-config.mjs.map +1 -1
  56. package/dist/edge-core/index.d.mts +11 -2
  57. package/dist/edge-core/index.d.ts +11 -2
  58. package/dist/edge-core/index.js +93 -10
  59. package/dist/edge-core/index.js.map +1 -1
  60. package/dist/edge-core/index.mjs +91 -10
  61. package/dist/edge-core/index.mjs.map +1 -1
  62. package/dist/gateway/gateway.js +50 -6
  63. package/dist/gateway/gateway.js.map +1 -1
  64. package/dist/gateway/gateway.mjs +60 -6
  65. package/dist/gateway/gateway.mjs.map +1 -1
  66. package/dist/git-trigger/git-hooks.d.mts +1 -1
  67. package/dist/git-trigger/git-hooks.d.ts +1 -1
  68. package/dist/index.d.mts +1314 -34
  69. package/dist/index.d.ts +1314 -34
  70. package/dist/index.js +5116 -2612
  71. package/dist/index.js.map +1 -1
  72. package/dist/index.mjs +5063 -2614
  73. package/dist/index.mjs.map +1 -1
  74. package/dist/registration/index.d.mts +28 -2
  75. package/dist/registration/index.d.ts +28 -2
  76. package/dist/registration/index.js +18 -3
  77. package/dist/registration/index.js.map +1 -1
  78. package/dist/registration/index.mjs +15 -2
  79. package/dist/registration/index.mjs.map +1 -1
  80. package/dist/transport/index.d.mts +7 -5
  81. package/dist/transport/index.d.ts +7 -5
  82. package/dist/transport/index.js +61 -5
  83. package/dist/transport/index.js.map +1 -1
  84. package/dist/transport/index.mjs +67 -11
  85. package/dist/transport/index.mjs.map +1 -1
  86. package/dist/{types-C_b4QTyO.d.ts → types-DtJjlW4O.d.ts} +104 -10
  87. package/dist/{types-BCkwBA84.d.mts → types-Dxf9DBpr.d.mts} +106 -12
  88. package/dist/{types-BCkwBA84.d.ts → types-Dxf9DBpr.d.ts} +106 -12
  89. package/dist/{types-DlshIIR-.d.mts → types-Eg6VoBNH.d.mts} +104 -10
  90. package/dist/ui/index.d.mts +1 -1
  91. package/dist/ui/index.d.ts +1 -1
  92. package/dist/verify.d.mts +1 -1
  93. package/dist/verify.d.ts +1 -1
  94. package/dist/verify.js +20 -6
  95. package/dist/verify.js.map +1 -1
  96. package/dist/verify.mjs +20 -6
  97. package/dist/verify.mjs.map +1 -1
  98. package/package.json +1 -1
@@ -28,12 +28,14 @@ __export(edge_core_exports, {
28
28
  buildManualReviewBody: () => buildManualReviewBody,
29
29
  buildObservedMetadata: () => buildObservedMetadata,
30
30
  buildVerificationRequest: () => buildVerificationRequest,
31
+ checkMinTls: () => checkMinTls,
31
32
  classify: () => classify,
32
33
  detectCommerce: () => detectCommerce,
33
34
  emitBeacon: () => emitBeacon,
34
35
  evaluateEdgeRequest: () => evaluateEdgeRequest,
35
36
  getBeaconBuffer: () => getBeaconBuffer,
36
37
  headerValue: () => headerValue,
38
+ negotiatedTlsVersion: () => negotiatedTlsVersion,
37
39
  outcomeFromVerifyResult: () => outcomeFromVerifyResult,
38
40
  passUntouched: () => passUntouched,
39
41
  requestUrl: () => requestUrl,
@@ -46,7 +48,7 @@ __export(edge_core_exports, {
46
48
  module.exports = __toCommonJS(edge_core_exports);
47
49
 
48
50
  // src/version.ts
49
- var SDK_VERSION = "5.14.0";
51
+ var SDK_VERSION = "5.15.0";
50
52
 
51
53
  // src/http.ts
52
54
  var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
@@ -66,6 +68,29 @@ function withUserAgent(initHeaders) {
66
68
  }
67
69
  var sdkFetch = (input, init) => fetch(input, { ...init, headers: withUserAgent(init?.headers) });
68
70
 
71
+ // src/route-pattern.ts
72
+ function routePatternToRegExp(pattern, opts = {}) {
73
+ let source = "";
74
+ for (let i = 0; i < pattern.length; i++) {
75
+ const ch = pattern[i];
76
+ if (ch === "*") {
77
+ source += ".*";
78
+ } else if (ch === ":" && /[A-Za-z_]/.test(pattern[i + 1] ?? "") && (i === 0 || pattern[i - 1] === "/")) {
79
+ let j = i + 1;
80
+ while (j < pattern.length && /[A-Za-z0-9_]/.test(pattern[j])) j++;
81
+ source += "[^/]+";
82
+ i = j - 1;
83
+ } else {
84
+ source += ch.replace(/[.+?^${}()|[\]\\/]/g, "\\$&");
85
+ }
86
+ }
87
+ try {
88
+ return new RegExp(`^${source}$`, opts.caseInsensitive ? "i" : "");
89
+ } catch {
90
+ return null;
91
+ }
92
+ }
93
+
69
94
  // src/edge-config.ts
70
95
  var DEFAULT_EDGE_CONFIG = Object.freeze({
71
96
  version: 1,
@@ -84,8 +109,7 @@ function matchEdgePathRule(rules, path) {
84
109
  return void 0;
85
110
  }
86
111
  function globToRegExp(pattern) {
87
- const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
88
- return new RegExp(`^${escaped}$`, "i");
112
+ return routePatternToRegExp(pattern, { caseInsensitive: true }) ?? /$^/;
89
113
  }
90
114
 
91
115
  // src/metadata-capture.ts
@@ -730,6 +754,7 @@ async function callVerifyAccessAPI(config, request) {
730
754
  if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
731
755
  if (requestData.commercePhase) body.commercePhase = requestData.commercePhase;
732
756
  if (requestData.checkoutSessionId) body.checkoutSessionId = requestData.checkoutSessionId;
757
+ if (requestData.checkoutJwt) body.checkoutJwt = requestData.checkoutJwt;
733
758
  if (requestData.checkoutItems) body.checkoutItems = requestData.checkoutItems;
734
759
  if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
735
760
  if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
@@ -880,7 +905,8 @@ async function verify(config, request, options) {
880
905
  "[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."
881
906
  );
882
907
  }
883
- if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache) {
908
+ const uncacheable = Boolean(request.commerceArtifacts);
909
+ if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
884
910
  const cached = getCachedResult(request, mergedConfig.counterpartyId);
885
911
  if (cached) {
886
912
  if (mergedConfig.debug) {
@@ -961,7 +987,10 @@ async function verify(config, request, options) {
961
987
  // MERCHANT caller only (bridge callers strip it before the agent plane).
962
988
  settlementToken: apiResponse.settlementToken,
963
989
  // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
964
- fulfilment: apiResponse.fulfilment
990
+ fulfilment: apiResponse.fulfilment,
991
+ mandates: apiResponse.mandates,
992
+ kyaToken: apiResponse.kyaToken,
993
+ aep: apiResponse.aep
965
994
  };
966
995
  return result2;
967
996
  }
@@ -971,7 +1000,10 @@ async function verify(config, request, options) {
971
1000
  trustScore: apiResponse.agent.trustScore,
972
1001
  trustLevel: getTrustLevel(apiResponse.agent.trustScore),
973
1002
  blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
974
- status: apiResponse.agent.agentStatus
1003
+ status: apiResponse.agent.agentStatus,
1004
+ ...apiResponse.agent.protocolIdentities && {
1005
+ protocolIdentities: apiResponse.agent.protocolIdentities
1006
+ }
975
1007
  } : void 0;
976
1008
  const developer = apiResponse.developer ? {
977
1009
  astradId: apiResponse.developer.kyaOwnerId,
@@ -1022,7 +1054,11 @@ async function verify(config, request, options) {
1022
1054
  settlementOutcome: apiResponse.settlementOutcome,
1023
1055
  settlementToken: apiResponse.settlementToken,
1024
1056
  // 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
1025
- fulfilment: apiResponse.fulfilment
1057
+ fulfilment: apiResponse.fulfilment,
1058
+ // 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
1059
+ mandates: apiResponse.mandates,
1060
+ kyaToken: apiResponse.kyaToken,
1061
+ aep: apiResponse.aep
1026
1062
  };
1027
1063
  if (result.recommendation === "deny") {
1028
1064
  result.policyAllowed = false;
@@ -1042,7 +1078,9 @@ async function verify(config, request, options) {
1042
1078
  }
1043
1079
  const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
1044
1080
  if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
1045
- cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
1081
+ if (!uncacheable) {
1082
+ cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
1083
+ }
1046
1084
  }
1047
1085
  return result;
1048
1086
  }
@@ -1241,7 +1279,7 @@ function detectCommerce(req, host) {
1241
1279
  };
1242
1280
  }
1243
1281
  }
1244
- if (authHeader && /^Payment\s+/i.test(authHeader)) {
1282
+ if (authHeader && /^Payment\s+/i.test(authHeader) || headerValue(req, "payment-authorization")) {
1245
1283
  return {
1246
1284
  protocol: "mpp",
1247
1285
  artifacts: {
@@ -1256,7 +1294,7 @@ function detectCommerce(req, host) {
1256
1294
  evidence: truncated
1257
1295
  };
1258
1296
  }
1259
- if (headerValue(req, "x-payment")) {
1297
+ if (headerValue(req, "payment-signature") || headerValue(req, "x-payment")) {
1260
1298
  return {
1261
1299
  protocol: "x402",
1262
1300
  artifacts: {
@@ -1918,6 +1956,7 @@ function outcomeFromVerifyResult(classification, result) {
1918
1956
  outcome.reasons = ["step-up approval required"];
1919
1957
  outcome.stepUp = {
1920
1958
  pollUrl: result.stepUpApproval?.pollUrl,
1959
+ approvalUrl: result.stepUpApproval?.approvalUrl,
1921
1960
  expiresAt: result.stepUpApproval?.expiresAt
1922
1961
  };
1923
1962
  return outcome;
@@ -2063,6 +2102,20 @@ async function evaluateEdgeRequest(options, req, config, apiKey) {
2063
2102
  if (classification.tier === "human" || classification.tier === "self") {
2064
2103
  return { policy, classification, application: passUntouched() };
2065
2104
  }
2105
+ const tls = checkMinTls(req, config.minTls);
2106
+ if (tls) {
2107
+ if (policy.mode === "enforce") {
2108
+ options.log?.(
2109
+ "info",
2110
+ `TLS ${tls.negotiated} below ${tls.minimum}: ${req.method} ${req.uri}`
2111
+ );
2112
+ return { policy, classification, application: tlsUpgradeRequired(tls) };
2113
+ }
2114
+ options.log?.(
2115
+ "info",
2116
+ `[OBSERVE] would have required TLS ${tls.minimum} (got ${tls.negotiated}): ${req.method} ${req.uri}`
2117
+ );
2118
+ }
2066
2119
  const outcome = await runTier(options, req, classification, policy, apiKey, {
2067
2120
  sampling: policy.sampling ?? config.sampling,
2068
2121
  queryValueAllowlist: config.queryValueAllowlist
@@ -2087,6 +2140,34 @@ async function evaluateEdgeRequest(options, req, config, apiKey) {
2087
2140
  return { policy, application: passUntouched() };
2088
2141
  }
2089
2142
  }
2143
+ function negotiatedTlsVersion(req) {
2144
+ const raw = req.connection?.tlsVersion ?? headerValue(req, "cloudfront-viewer-tls");
2145
+ const m = raw ? /^TLSv(1(?:\.\d)?)/i.exec(raw) : null;
2146
+ return m ? m[1] === "1" ? "1.0" : m[1] : null;
2147
+ }
2148
+ function checkMinTls(req, minTls) {
2149
+ if (!minTls) return null;
2150
+ const negotiated = negotiatedTlsVersion(req);
2151
+ if (!negotiated) return null;
2152
+ return Number(negotiated) < Number(minTls) ? { minimum: minTls, negotiated } : null;
2153
+ }
2154
+ function tlsUpgradeRequired(v) {
2155
+ return {
2156
+ action: "respond",
2157
+ status: 426,
2158
+ headers: {
2159
+ "content-type": "application/json",
2160
+ upgrade: `TLS/${v.minimum}`,
2161
+ connection: "Upgrade"
2162
+ },
2163
+ bodyJson: {
2164
+ error: "tls_version_too_low",
2165
+ minimum: `TLS ${v.minimum}`,
2166
+ negotiated: `TLS ${v.negotiated}`,
2167
+ message: `This endpoint requires TLS ${v.minimum} or later for agent requests. Reconnect with TLS ${v.minimum}.`
2168
+ }
2169
+ };
2170
+ }
2090
2171
  // Annotate the CommonJS export names for ESM import in node:
2091
2172
  0 && (module.exports = {
2092
2173
  ASAT_HEADERS,
@@ -2097,12 +2178,14 @@ async function evaluateEdgeRequest(options, req, config, apiKey) {
2097
2178
  buildManualReviewBody,
2098
2179
  buildObservedMetadata,
2099
2180
  buildVerificationRequest,
2181
+ checkMinTls,
2100
2182
  classify,
2101
2183
  detectCommerce,
2102
2184
  emitBeacon,
2103
2185
  evaluateEdgeRequest,
2104
2186
  getBeaconBuffer,
2105
2187
  headerValue,
2188
+ negotiatedTlsVersion,
2106
2189
  outcomeFromVerifyResult,
2107
2190
  passUntouched,
2108
2191
  requestUrl,