@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.
- package/README.md +27 -17
- package/dist/adapters/express.d.mts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.js +477 -240
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +477 -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 +20 -6
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +20 -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 +460 -239
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +460 -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 +80 -23
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +80 -23
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +1 -1
- package/dist/agent/index.mjs.map +1 -1
- package/dist/bin/astrasync-claude-hook.js +55 -11
- package/dist/bin/astrasync-codex-hook.js +55 -11
- package/dist/bin/astrasync-guard.js +55 -11
- package/dist/bin/astrasync.js +288 -33
- package/dist/browser/background.js +50 -6
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +60 -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 +55 -11
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +65 -11
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +55 -11
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +65 -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 +93 -10
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +91 -10
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/gateway/gateway.js +50 -6
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +60 -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 +1314 -34
- package/dist/index.d.ts +1314 -34
- package/dist/index.js +5116 -2612
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5063 -2614
- 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-C_b4QTyO.d.ts → types-DtJjlW4O.d.ts} +104 -10
- package/dist/{types-BCkwBA84.d.mts → types-Dxf9DBpr.d.mts} +106 -12
- package/dist/{types-BCkwBA84.d.ts → types-Dxf9DBpr.d.ts} +106 -12
- package/dist/{types-DlshIIR-.d.mts → types-Eg6VoBNH.d.mts} +104 -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 +20 -6
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +20 -6
- package/dist/verify.mjs.map +1 -1
- package/package.json +1 -1
package/dist/edge-core/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = "5.
|
|
2
|
+
var SDK_VERSION = "5.15.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
|
-
|
|
41
|
-
return new RegExp(`^${escaped}$`, "i");
|
|
63
|
+
return routePatternToRegExp(pattern, { caseInsensitive: true }) ?? /$^/;
|
|
42
64
|
}
|
|
43
65
|
|
|
44
66
|
// src/metadata-capture.ts
|
|
@@ -683,6 +705,7 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
683
705
|
if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
|
|
684
706
|
if (requestData.commercePhase) body.commercePhase = requestData.commercePhase;
|
|
685
707
|
if (requestData.checkoutSessionId) body.checkoutSessionId = requestData.checkoutSessionId;
|
|
708
|
+
if (requestData.checkoutJwt) body.checkoutJwt = requestData.checkoutJwt;
|
|
686
709
|
if (requestData.checkoutItems) body.checkoutItems = requestData.checkoutItems;
|
|
687
710
|
if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
|
|
688
711
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
@@ -833,7 +856,8 @@ async function verify(config, request, options) {
|
|
|
833
856
|
"[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
857
|
);
|
|
835
858
|
}
|
|
836
|
-
|
|
859
|
+
const uncacheable = Boolean(request.commerceArtifacts);
|
|
860
|
+
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
837
861
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
838
862
|
if (cached) {
|
|
839
863
|
if (mergedConfig.debug) {
|
|
@@ -914,7 +938,10 @@ async function verify(config, request, options) {
|
|
|
914
938
|
// MERCHANT caller only (bridge callers strip it before the agent plane).
|
|
915
939
|
settlementToken: apiResponse.settlementToken,
|
|
916
940
|
// 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
|
|
917
|
-
fulfilment: apiResponse.fulfilment
|
|
941
|
+
fulfilment: apiResponse.fulfilment,
|
|
942
|
+
mandates: apiResponse.mandates,
|
|
943
|
+
kyaToken: apiResponse.kyaToken,
|
|
944
|
+
aep: apiResponse.aep
|
|
918
945
|
};
|
|
919
946
|
return result2;
|
|
920
947
|
}
|
|
@@ -924,7 +951,10 @@ async function verify(config, request, options) {
|
|
|
924
951
|
trustScore: apiResponse.agent.trustScore,
|
|
925
952
|
trustLevel: getTrustLevel(apiResponse.agent.trustScore),
|
|
926
953
|
blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
|
|
927
|
-
status: apiResponse.agent.agentStatus
|
|
954
|
+
status: apiResponse.agent.agentStatus,
|
|
955
|
+
...apiResponse.agent.protocolIdentities && {
|
|
956
|
+
protocolIdentities: apiResponse.agent.protocolIdentities
|
|
957
|
+
}
|
|
928
958
|
} : void 0;
|
|
929
959
|
const developer = apiResponse.developer ? {
|
|
930
960
|
astradId: apiResponse.developer.kyaOwnerId,
|
|
@@ -975,7 +1005,11 @@ async function verify(config, request, options) {
|
|
|
975
1005
|
settlementOutcome: apiResponse.settlementOutcome,
|
|
976
1006
|
settlementToken: apiResponse.settlementToken,
|
|
977
1007
|
// 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
|
|
978
|
-
fulfilment: apiResponse.fulfilment
|
|
1008
|
+
fulfilment: apiResponse.fulfilment,
|
|
1009
|
+
// 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
|
|
1010
|
+
mandates: apiResponse.mandates,
|
|
1011
|
+
kyaToken: apiResponse.kyaToken,
|
|
1012
|
+
aep: apiResponse.aep
|
|
979
1013
|
};
|
|
980
1014
|
if (result.recommendation === "deny") {
|
|
981
1015
|
result.policyAllowed = false;
|
|
@@ -995,7 +1029,9 @@ async function verify(config, request, options) {
|
|
|
995
1029
|
}
|
|
996
1030
|
const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
|
|
997
1031
|
if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
|
|
998
|
-
|
|
1032
|
+
if (!uncacheable) {
|
|
1033
|
+
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
1034
|
+
}
|
|
999
1035
|
}
|
|
1000
1036
|
return result;
|
|
1001
1037
|
}
|
|
@@ -1194,7 +1230,7 @@ function detectCommerce(req, host) {
|
|
|
1194
1230
|
};
|
|
1195
1231
|
}
|
|
1196
1232
|
}
|
|
1197
|
-
if (authHeader && /^Payment\s+/i.test(authHeader)) {
|
|
1233
|
+
if (authHeader && /^Payment\s+/i.test(authHeader) || headerValue(req, "payment-authorization")) {
|
|
1198
1234
|
return {
|
|
1199
1235
|
protocol: "mpp",
|
|
1200
1236
|
artifacts: {
|
|
@@ -1209,7 +1245,7 @@ function detectCommerce(req, host) {
|
|
|
1209
1245
|
evidence: truncated
|
|
1210
1246
|
};
|
|
1211
1247
|
}
|
|
1212
|
-
if (headerValue(req, "x-payment")) {
|
|
1248
|
+
if (headerValue(req, "payment-signature") || headerValue(req, "x-payment")) {
|
|
1213
1249
|
return {
|
|
1214
1250
|
protocol: "x402",
|
|
1215
1251
|
artifacts: {
|
|
@@ -1871,6 +1907,7 @@ function outcomeFromVerifyResult(classification, result) {
|
|
|
1871
1907
|
outcome.reasons = ["step-up approval required"];
|
|
1872
1908
|
outcome.stepUp = {
|
|
1873
1909
|
pollUrl: result.stepUpApproval?.pollUrl,
|
|
1910
|
+
approvalUrl: result.stepUpApproval?.approvalUrl,
|
|
1874
1911
|
expiresAt: result.stepUpApproval?.expiresAt
|
|
1875
1912
|
};
|
|
1876
1913
|
return outcome;
|
|
@@ -2016,6 +2053,20 @@ async function evaluateEdgeRequest(options, req, config, apiKey) {
|
|
|
2016
2053
|
if (classification.tier === "human" || classification.tier === "self") {
|
|
2017
2054
|
return { policy, classification, application: passUntouched() };
|
|
2018
2055
|
}
|
|
2056
|
+
const tls = checkMinTls(req, config.minTls);
|
|
2057
|
+
if (tls) {
|
|
2058
|
+
if (policy.mode === "enforce") {
|
|
2059
|
+
options.log?.(
|
|
2060
|
+
"info",
|
|
2061
|
+
`TLS ${tls.negotiated} below ${tls.minimum}: ${req.method} ${req.uri}`
|
|
2062
|
+
);
|
|
2063
|
+
return { policy, classification, application: tlsUpgradeRequired(tls) };
|
|
2064
|
+
}
|
|
2065
|
+
options.log?.(
|
|
2066
|
+
"info",
|
|
2067
|
+
`[OBSERVE] would have required TLS ${tls.minimum} (got ${tls.negotiated}): ${req.method} ${req.uri}`
|
|
2068
|
+
);
|
|
2069
|
+
}
|
|
2019
2070
|
const outcome = await runTier(options, req, classification, policy, apiKey, {
|
|
2020
2071
|
sampling: policy.sampling ?? config.sampling,
|
|
2021
2072
|
queryValueAllowlist: config.queryValueAllowlist
|
|
@@ -2040,6 +2091,34 @@ async function evaluateEdgeRequest(options, req, config, apiKey) {
|
|
|
2040
2091
|
return { policy, application: passUntouched() };
|
|
2041
2092
|
}
|
|
2042
2093
|
}
|
|
2094
|
+
function negotiatedTlsVersion(req) {
|
|
2095
|
+
const raw = req.connection?.tlsVersion ?? headerValue(req, "cloudfront-viewer-tls");
|
|
2096
|
+
const m = raw ? /^TLSv(1(?:\.\d)?)/i.exec(raw) : null;
|
|
2097
|
+
return m ? m[1] === "1" ? "1.0" : m[1] : null;
|
|
2098
|
+
}
|
|
2099
|
+
function checkMinTls(req, minTls) {
|
|
2100
|
+
if (!minTls) return null;
|
|
2101
|
+
const negotiated = negotiatedTlsVersion(req);
|
|
2102
|
+
if (!negotiated) return null;
|
|
2103
|
+
return Number(negotiated) < Number(minTls) ? { minimum: minTls, negotiated } : null;
|
|
2104
|
+
}
|
|
2105
|
+
function tlsUpgradeRequired(v) {
|
|
2106
|
+
return {
|
|
2107
|
+
action: "respond",
|
|
2108
|
+
status: 426,
|
|
2109
|
+
headers: {
|
|
2110
|
+
"content-type": "application/json",
|
|
2111
|
+
upgrade: `TLS/${v.minimum}`,
|
|
2112
|
+
connection: "Upgrade"
|
|
2113
|
+
},
|
|
2114
|
+
bodyJson: {
|
|
2115
|
+
error: "tls_version_too_low",
|
|
2116
|
+
minimum: `TLS ${v.minimum}`,
|
|
2117
|
+
negotiated: `TLS ${v.negotiated}`,
|
|
2118
|
+
message: `This endpoint requires TLS ${v.minimum} or later for agent requests. Reconnect with TLS ${v.minimum}.`
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
}
|
|
2043
2122
|
export {
|
|
2044
2123
|
ASAT_HEADERS,
|
|
2045
2124
|
BeaconBuffer,
|
|
@@ -2049,12 +2128,14 @@ export {
|
|
|
2049
2128
|
buildManualReviewBody,
|
|
2050
2129
|
buildObservedMetadata,
|
|
2051
2130
|
buildVerificationRequest,
|
|
2131
|
+
checkMinTls,
|
|
2052
2132
|
classify,
|
|
2053
2133
|
detectCommerce,
|
|
2054
2134
|
emitBeacon,
|
|
2055
2135
|
evaluateEdgeRequest,
|
|
2056
2136
|
getBeaconBuffer,
|
|
2057
2137
|
headerValue,
|
|
2138
|
+
negotiatedTlsVersion,
|
|
2058
2139
|
outcomeFromVerifyResult,
|
|
2059
2140
|
passUntouched,
|
|
2060
2141
|
requestUrl,
|