@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.
- package/README.md +36 -18
- package/dist/adapters/express.d.mts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.js +492 -240
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +492 -240
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.d.ts +1 -1
- package/dist/adapters/mcp.js +23 -6
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +23 -6
- package/dist/adapters/mcp.mjs.map +1 -1
- package/dist/adapters/nextjs.d.mts +1 -1
- package/dist/adapters/nextjs.d.ts +1 -1
- package/dist/adapters/nextjs.js +475 -239
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +475 -239
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +18 -10
- package/dist/adapters/sdk.d.ts +18 -10
- package/dist/adapters/sdk.js +83 -23
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +83 -23
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.d.mts +69 -54
- package/dist/agent/index.d.ts +69 -54
- package/dist/agent/index.js +24 -14
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +24 -14
- package/dist/agent/index.mjs.map +1 -1
- package/dist/bin/astrasync-claude-hook.js +58 -11
- package/dist/bin/astrasync-codex-hook.js +58 -11
- package/dist/bin/astrasync-guard.js +177 -11
- package/dist/bin/astrasync.js +433 -38
- package/dist/browser/background.js +53 -6
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +63 -6
- package/dist/browser/background.mjs.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/index.mjs.map +1 -1
- package/dist/codex/index.js +58 -11
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +68 -11
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +58 -11
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +68 -11
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/edge-config.d.mts +31 -2
- package/dist/edge-config.d.ts +31 -2
- package/dist/edge-config.js +35 -5
- package/dist/edge-config.js.map +1 -1
- package/dist/edge-config.mjs +32 -4
- package/dist/edge-config.mjs.map +1 -1
- package/dist/edge-core/index.d.mts +11 -2
- package/dist/edge-core/index.d.ts +11 -2
- package/dist/edge-core/index.js +97 -11
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +95 -11
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/gateway/gateway.js +53 -6
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +63 -6
- package/dist/gateway/gateway.mjs.map +1 -1
- package/dist/git-trigger/git-hooks.d.mts +1 -1
- package/dist/git-trigger/git-hooks.d.ts +1 -1
- package/dist/index.d.mts +1407 -88
- package/dist/index.d.ts +1407 -88
- package/dist/index.js +5148 -2616
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5094 -2618
- package/dist/index.mjs.map +1 -1
- package/dist/registration/index.d.mts +28 -2
- package/dist/registration/index.d.ts +28 -2
- package/dist/registration/index.js +18 -3
- package/dist/registration/index.js.map +1 -1
- package/dist/registration/index.mjs +15 -2
- package/dist/registration/index.mjs.map +1 -1
- package/dist/transport/index.d.mts +7 -5
- package/dist/transport/index.d.ts +7 -5
- package/dist/transport/index.js +61 -5
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +67 -11
- package/dist/transport/index.mjs.map +1 -1
- package/dist/{types-BCkwBA84.d.mts → types-Blz520bR.d.mts} +116 -12
- package/dist/{types-BCkwBA84.d.ts → types-Blz520bR.d.ts} +116 -12
- package/dist/{types-C_b4QTyO.d.ts → types-Bm1QvGqI.d.ts} +114 -10
- package/dist/{types-DlshIIR-.d.mts → types-DBe4hgfT.d.mts} +114 -10
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/verify.d.mts +1 -1
- package/dist/verify.d.ts +1 -1
- package/dist/verify.js +23 -6
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +23 -6
- package/dist/verify.mjs.map +1 -1
- package/package.json +1 -1
package/dist/edge-core/index.js
CHANGED
|
@@ -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.
|
|
51
|
+
var SDK_VERSION = "5.16.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
|
-
|
|
88
|
-
return new RegExp(`^${escaped}$`, "i");
|
|
112
|
+
return routePatternToRegExp(pattern, { caseInsensitive: true }) ?? /$^/;
|
|
89
113
|
}
|
|
90
114
|
|
|
91
115
|
// src/metadata-capture.ts
|
|
@@ -514,6 +538,8 @@ function getCacheKey(request, counterpartyId) {
|
|
|
514
538
|
request.durationRequired ?? "",
|
|
515
539
|
request.invocationProtocol || "",
|
|
516
540
|
request.enableRuntimeChallenge ? "1" : "0",
|
|
541
|
+
// 5.16.0: route policy changes the verdict (owners / challenge).
|
|
542
|
+
request.routePolicy ? JSON.stringify(request.routePolicy) : "",
|
|
517
543
|
// callerMetadata fields contribute to risk model; include the ones
|
|
518
544
|
// backend reads. sourceIp/userAgent/forwardedFor change per-request
|
|
519
545
|
// so their inclusion effectively forces a re-check for any varying
|
|
@@ -720,6 +746,7 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
720
746
|
if (requestData.subAgentDepth !== void 0) body.subAgentDepth = requestData.subAgentDepth;
|
|
721
747
|
if (requestData.enableRuntimeChallenge)
|
|
722
748
|
body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
|
|
749
|
+
if (requestData.routePolicy) body.routePolicy = requestData.routePolicy;
|
|
723
750
|
if (requestData.createSession) body.createSession = requestData.createSession;
|
|
724
751
|
if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
|
|
725
752
|
if (requestData.counterpartyType) body.counterpartyType = requestData.counterpartyType;
|
|
@@ -730,6 +757,7 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
730
757
|
if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
|
|
731
758
|
if (requestData.commercePhase) body.commercePhase = requestData.commercePhase;
|
|
732
759
|
if (requestData.checkoutSessionId) body.checkoutSessionId = requestData.checkoutSessionId;
|
|
760
|
+
if (requestData.checkoutJwt) body.checkoutJwt = requestData.checkoutJwt;
|
|
733
761
|
if (requestData.checkoutItems) body.checkoutItems = requestData.checkoutItems;
|
|
734
762
|
if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
|
|
735
763
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
@@ -880,7 +908,8 @@ async function verify(config, request, options) {
|
|
|
880
908
|
"[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
909
|
);
|
|
882
910
|
}
|
|
883
|
-
|
|
911
|
+
const uncacheable = Boolean(request.commerceArtifacts);
|
|
912
|
+
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
884
913
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
885
914
|
if (cached) {
|
|
886
915
|
if (mergedConfig.debug) {
|
|
@@ -961,7 +990,10 @@ async function verify(config, request, options) {
|
|
|
961
990
|
// MERCHANT caller only (bridge callers strip it before the agent plane).
|
|
962
991
|
settlementToken: apiResponse.settlementToken,
|
|
963
992
|
// 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
|
|
964
|
-
fulfilment: apiResponse.fulfilment
|
|
993
|
+
fulfilment: apiResponse.fulfilment,
|
|
994
|
+
mandates: apiResponse.mandates,
|
|
995
|
+
kyaToken: apiResponse.kyaToken,
|
|
996
|
+
aep: apiResponse.aep
|
|
965
997
|
};
|
|
966
998
|
return result2;
|
|
967
999
|
}
|
|
@@ -971,7 +1003,10 @@ async function verify(config, request, options) {
|
|
|
971
1003
|
trustScore: apiResponse.agent.trustScore,
|
|
972
1004
|
trustLevel: getTrustLevel(apiResponse.agent.trustScore),
|
|
973
1005
|
blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
|
|
974
|
-
status: apiResponse.agent.agentStatus
|
|
1006
|
+
status: apiResponse.agent.agentStatus,
|
|
1007
|
+
...apiResponse.agent.protocolIdentities && {
|
|
1008
|
+
protocolIdentities: apiResponse.agent.protocolIdentities
|
|
1009
|
+
}
|
|
975
1010
|
} : void 0;
|
|
976
1011
|
const developer = apiResponse.developer ? {
|
|
977
1012
|
astradId: apiResponse.developer.kyaOwnerId,
|
|
@@ -1022,7 +1057,11 @@ async function verify(config, request, options) {
|
|
|
1022
1057
|
settlementOutcome: apiResponse.settlementOutcome,
|
|
1023
1058
|
settlementToken: apiResponse.settlementToken,
|
|
1024
1059
|
// 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
|
|
1025
|
-
fulfilment: apiResponse.fulfilment
|
|
1060
|
+
fulfilment: apiResponse.fulfilment,
|
|
1061
|
+
// 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
|
|
1062
|
+
mandates: apiResponse.mandates,
|
|
1063
|
+
kyaToken: apiResponse.kyaToken,
|
|
1064
|
+
aep: apiResponse.aep
|
|
1026
1065
|
};
|
|
1027
1066
|
if (result.recommendation === "deny") {
|
|
1028
1067
|
result.policyAllowed = false;
|
|
@@ -1042,7 +1081,9 @@ async function verify(config, request, options) {
|
|
|
1042
1081
|
}
|
|
1043
1082
|
const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
|
|
1044
1083
|
if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
|
|
1045
|
-
|
|
1084
|
+
if (!uncacheable) {
|
|
1085
|
+
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
1086
|
+
}
|
|
1046
1087
|
}
|
|
1047
1088
|
return result;
|
|
1048
1089
|
}
|
|
@@ -1209,7 +1250,7 @@ function detectCommerce(req, host) {
|
|
|
1209
1250
|
evidence: { hasTimestamp: Boolean(acpTimestamp), ...truncated }
|
|
1210
1251
|
};
|
|
1211
1252
|
}
|
|
1212
|
-
if (/\/checkout[-_]sessions(\/|$)/.test(req.uri)) {
|
|
1253
|
+
if (/\/checkout[-_]sessions(\/|$)/.test(req.uri) && headerValue(req, "ucp-agent")) {
|
|
1213
1254
|
return {
|
|
1214
1255
|
protocol: "ucp",
|
|
1215
1256
|
artifacts: { ucpRequest: { method, url, ...jsonBody && { body: jsonBody } } },
|
|
@@ -1241,7 +1282,7 @@ function detectCommerce(req, host) {
|
|
|
1241
1282
|
};
|
|
1242
1283
|
}
|
|
1243
1284
|
}
|
|
1244
|
-
if (authHeader && /^Payment\s+/i.test(authHeader)) {
|
|
1285
|
+
if (authHeader && /^Payment\s+/i.test(authHeader) || headerValue(req, "payment-authorization")) {
|
|
1245
1286
|
return {
|
|
1246
1287
|
protocol: "mpp",
|
|
1247
1288
|
artifacts: {
|
|
@@ -1256,7 +1297,7 @@ function detectCommerce(req, host) {
|
|
|
1256
1297
|
evidence: truncated
|
|
1257
1298
|
};
|
|
1258
1299
|
}
|
|
1259
|
-
if (headerValue(req, "x-payment")) {
|
|
1300
|
+
if (headerValue(req, "payment-signature") || headerValue(req, "x-payment")) {
|
|
1260
1301
|
return {
|
|
1261
1302
|
protocol: "x402",
|
|
1262
1303
|
artifacts: {
|
|
@@ -1918,6 +1959,7 @@ function outcomeFromVerifyResult(classification, result) {
|
|
|
1918
1959
|
outcome.reasons = ["step-up approval required"];
|
|
1919
1960
|
outcome.stepUp = {
|
|
1920
1961
|
pollUrl: result.stepUpApproval?.pollUrl,
|
|
1962
|
+
approvalUrl: result.stepUpApproval?.approvalUrl,
|
|
1921
1963
|
expiresAt: result.stepUpApproval?.expiresAt
|
|
1922
1964
|
};
|
|
1923
1965
|
return outcome;
|
|
@@ -2063,6 +2105,20 @@ async function evaluateEdgeRequest(options, req, config, apiKey) {
|
|
|
2063
2105
|
if (classification.tier === "human" || classification.tier === "self") {
|
|
2064
2106
|
return { policy, classification, application: passUntouched() };
|
|
2065
2107
|
}
|
|
2108
|
+
const tls = checkMinTls(req, config.minTls);
|
|
2109
|
+
if (tls) {
|
|
2110
|
+
if (policy.mode === "enforce") {
|
|
2111
|
+
options.log?.(
|
|
2112
|
+
"info",
|
|
2113
|
+
`TLS ${tls.negotiated} below ${tls.minimum}: ${req.method} ${req.uri}`
|
|
2114
|
+
);
|
|
2115
|
+
return { policy, classification, application: tlsUpgradeRequired(tls) };
|
|
2116
|
+
}
|
|
2117
|
+
options.log?.(
|
|
2118
|
+
"info",
|
|
2119
|
+
`[OBSERVE] would have required TLS ${tls.minimum} (got ${tls.negotiated}): ${req.method} ${req.uri}`
|
|
2120
|
+
);
|
|
2121
|
+
}
|
|
2066
2122
|
const outcome = await runTier(options, req, classification, policy, apiKey, {
|
|
2067
2123
|
sampling: policy.sampling ?? config.sampling,
|
|
2068
2124
|
queryValueAllowlist: config.queryValueAllowlist
|
|
@@ -2087,6 +2143,34 @@ async function evaluateEdgeRequest(options, req, config, apiKey) {
|
|
|
2087
2143
|
return { policy, application: passUntouched() };
|
|
2088
2144
|
}
|
|
2089
2145
|
}
|
|
2146
|
+
function negotiatedTlsVersion(req) {
|
|
2147
|
+
const raw = req.connection?.tlsVersion ?? headerValue(req, "cloudfront-viewer-tls");
|
|
2148
|
+
const m = raw ? /^TLSv(1(?:\.\d)?)/i.exec(raw) : null;
|
|
2149
|
+
return m ? m[1] === "1" ? "1.0" : m[1] : null;
|
|
2150
|
+
}
|
|
2151
|
+
function checkMinTls(req, minTls) {
|
|
2152
|
+
if (!minTls) return null;
|
|
2153
|
+
const negotiated = negotiatedTlsVersion(req);
|
|
2154
|
+
if (!negotiated) return null;
|
|
2155
|
+
return Number(negotiated) < Number(minTls) ? { minimum: minTls, negotiated } : null;
|
|
2156
|
+
}
|
|
2157
|
+
function tlsUpgradeRequired(v) {
|
|
2158
|
+
return {
|
|
2159
|
+
action: "respond",
|
|
2160
|
+
status: 426,
|
|
2161
|
+
headers: {
|
|
2162
|
+
"content-type": "application/json",
|
|
2163
|
+
upgrade: `TLS/${v.minimum}`,
|
|
2164
|
+
connection: "Upgrade"
|
|
2165
|
+
},
|
|
2166
|
+
bodyJson: {
|
|
2167
|
+
error: "tls_version_too_low",
|
|
2168
|
+
minimum: `TLS ${v.minimum}`,
|
|
2169
|
+
negotiated: `TLS ${v.negotiated}`,
|
|
2170
|
+
message: `This endpoint requires TLS ${v.minimum} or later for agent requests. Reconnect with TLS ${v.minimum}.`
|
|
2171
|
+
}
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2090
2174
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2091
2175
|
0 && (module.exports = {
|
|
2092
2176
|
ASAT_HEADERS,
|
|
@@ -2097,12 +2181,14 @@ async function evaluateEdgeRequest(options, req, config, apiKey) {
|
|
|
2097
2181
|
buildManualReviewBody,
|
|
2098
2182
|
buildObservedMetadata,
|
|
2099
2183
|
buildVerificationRequest,
|
|
2184
|
+
checkMinTls,
|
|
2100
2185
|
classify,
|
|
2101
2186
|
detectCommerce,
|
|
2102
2187
|
emitBeacon,
|
|
2103
2188
|
evaluateEdgeRequest,
|
|
2104
2189
|
getBeaconBuffer,
|
|
2105
2190
|
headerValue,
|
|
2191
|
+
negotiatedTlsVersion,
|
|
2106
2192
|
outcomeFromVerifyResult,
|
|
2107
2193
|
passUntouched,
|
|
2108
2194
|
requestUrl,
|