@astrasyncai/verification-gateway 5.18.1 → 5.20.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/CHANGELOG.md +232 -0
- package/README.md +217 -4
- package/dist/adapter-interface/interface.d.mts +2 -2
- package/dist/adapter-interface/interface.d.ts +2 -2
- package/dist/adapters/express.d.mts +9 -1
- package/dist/adapters/express.d.ts +9 -1
- package/dist/adapters/express.js +160 -52
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +160 -52
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/http-pdlss.d.mts +7 -1
- package/dist/adapters/http-pdlss.d.ts +7 -1
- package/dist/adapters/http-pdlss.js +18 -2
- package/dist/adapters/http-pdlss.js.map +1 -1
- package/dist/adapters/http-pdlss.mjs +16 -1
- package/dist/adapters/http-pdlss.mjs.map +1 -1
- package/dist/adapters/kit-express.d.mts +93 -1
- package/dist/adapters/kit-express.d.ts +93 -1
- package/dist/adapters/kit-express.js +181 -2
- package/dist/adapters/kit-express.js.map +1 -1
- package/dist/adapters/kit-express.mjs +180 -2
- package/dist/adapters/kit-express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +102 -9
- package/dist/adapters/mcp.d.ts +102 -9
- package/dist/adapters/mcp.js +242 -19
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +240 -19
- 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 +97 -14
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +97 -14
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +101 -2
- package/dist/adapters/sdk.d.ts +101 -2
- package/dist/adapters/sdk.js +199 -12
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +199 -12
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.d.mts +1 -1
- package/dist/agent/index.d.ts +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 +94 -16
- package/dist/bin/astrasync-codex-hook.js +94 -16
- package/dist/bin/astrasync-guard.js +94 -16
- package/dist/bin/astrasync.js +127 -16
- package/dist/browser/background.js +94 -16
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +94 -16
- 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 +94 -16
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +94 -16
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +94 -16
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +94 -16
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/edge-config.d.mts +1 -1
- package/dist/edge-config.d.ts +1 -1
- package/dist/edge-config.js +1 -1
- package/dist/edge-config.js.map +1 -1
- package/dist/edge-config.mjs +1 -1
- package/dist/edge-config.mjs.map +1 -1
- package/dist/edge-core/index.d.mts +1 -1
- package/dist/edge-core/index.d.ts +1 -1
- package/dist/edge-core/index.js +69 -12
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +69 -12
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/gateway/gateway.d.mts +2 -2
- package/dist/gateway/gateway.d.ts +2 -2
- package/dist/gateway/gateway.js +94 -16
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +94 -16
- 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 +706 -34
- package/dist/index.d.ts +706 -34
- package/dist/index.js +1391 -205
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1374 -195
- package/dist/index.mjs.map +1 -1
- package/dist/local-evaluator/evaluator.d.mts +2 -2
- package/dist/local-evaluator/evaluator.d.ts +2 -2
- package/dist/registration/index.d.mts +11 -2
- package/dist/registration/index.d.ts +11 -2
- package/dist/registration/index.js +1 -1
- package/dist/registration/index.js.map +1 -1
- package/dist/registration/index.mjs +1 -1
- package/dist/registration/index.mjs.map +1 -1
- package/dist/transport/index.d.mts +1 -1
- package/dist/transport/index.d.ts +1 -1
- package/dist/transport/index.js +3 -2
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +3 -2
- package/dist/transport/index.mjs.map +1 -1
- package/dist/{types-BRz2U0Pn.d.ts → types-B_HLhZ9n.d.ts} +1 -1
- package/dist/{types-BfILnheI.d.mts → types-CU17R4Nr.d.mts} +11 -0
- package/dist/{types-BfILnheI.d.ts → types-CU17R4Nr.d.ts} +11 -0
- package/dist/{types-Cns4l8gX.d.mts → types-CxjqmPl-.d.mts} +115 -13
- package/dist/{types-Cns4l8gX.d.ts → types-CxjqmPl-.d.ts} +115 -13
- package/dist/{types-3ObBpsnf.d.mts → types-D37aSQ9c.d.mts} +106 -3
- package/dist/{types-CfBpm3w5.d.mts → types-Djpz-L0w.d.mts} +1 -1
- package/dist/{types-BoxZEYPS.d.ts → types-Dn8tXnei.d.ts} +106 -3
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/verify.d.mts +50 -4
- package/dist/verify.d.ts +50 -4
- package/dist/verify.js +93 -14
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +91 -14
- package/dist/verify.mjs.map +1 -1
- package/dist/webhooks.d.mts +16 -3
- package/dist/webhooks.d.ts +16 -3
- package/dist/webhooks.js +24 -13
- package/dist/webhooks.js.map +1 -1
- package/dist/webhooks.mjs +24 -13
- package/dist/webhooks.mjs.map +1 -1
- package/package.json +1 -1
package/dist/adapters/nextjs.mjs
CHANGED
|
@@ -434,7 +434,7 @@ function routePolicyOf(route) {
|
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
// src/version.ts
|
|
437
|
-
var SDK_VERSION = "5.
|
|
437
|
+
var SDK_VERSION = "5.20.0";
|
|
438
438
|
|
|
439
439
|
// src/http.ts
|
|
440
440
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -700,7 +700,12 @@ function getCacheKey(request, counterpartyId) {
|
|
|
700
700
|
// its start_checkout quote was served the cached quote-leg grant (no
|
|
701
701
|
// settlementOutcome) and never reached the backend. Same F-A1-07 bug class.
|
|
702
702
|
request.commercePhase || "",
|
|
703
|
-
request.checkoutSessionId || ""
|
|
703
|
+
request.checkoutSessionId || "",
|
|
704
|
+
// 5.19.0: a route_config purpose claim is checked server-side against
|
|
705
|
+
// the stored rule for this method + path, so it changes the verdict.
|
|
706
|
+
request.purposeSource || "",
|
|
707
|
+
request.requestMethod || "",
|
|
708
|
+
request.requestPath || ""
|
|
704
709
|
].join("|");
|
|
705
710
|
}
|
|
706
711
|
function getCachedResult(request, counterpartyId) {
|
|
@@ -892,6 +897,9 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
892
897
|
if (requestData.enableRuntimeChallenge)
|
|
893
898
|
body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
|
|
894
899
|
if (requestData.routePolicy) body.routePolicy = requestData.routePolicy;
|
|
900
|
+
if (config.actingProof?.connectorToken) {
|
|
901
|
+
body.actingProof = { connectorToken: config.actingProof.connectorToken };
|
|
902
|
+
}
|
|
895
903
|
if (requestData.approvalHeldByRoute) body.approvalHeldByRoute = true;
|
|
896
904
|
if (requestData.createSession) body.createSession = requestData.createSession;
|
|
897
905
|
if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
|
|
@@ -908,6 +916,11 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
908
916
|
if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
|
|
909
917
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
910
918
|
if (requestData.attemptId) body.attemptId = requestData.attemptId;
|
|
919
|
+
if (requestData.purposeSource) body.purposeSource = requestData.purposeSource;
|
|
920
|
+
if (requestData.agentArtifacts) body.agentArtifacts = requestData.agentArtifacts;
|
|
921
|
+
if (requestData.metadata) body.metadata = requestData.metadata;
|
|
922
|
+
if (requestData.requestMethod) body.requestMethod = requestData.requestMethod;
|
|
923
|
+
if (requestData.requestPath) body.requestPath = requestData.requestPath;
|
|
911
924
|
if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
|
|
912
925
|
body.sdkVersion = SDK_VERSION;
|
|
913
926
|
if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
|
|
@@ -1054,22 +1067,43 @@ async function verify(config, request, options) {
|
|
|
1054
1067
|
"[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."
|
|
1055
1068
|
);
|
|
1056
1069
|
}
|
|
1057
|
-
const uncacheable = Boolean(request.commerceArtifacts);
|
|
1070
|
+
const uncacheable = Boolean(request.commerceArtifacts) || Boolean(mergedConfig.actingProof);
|
|
1058
1071
|
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
1059
1072
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
1060
1073
|
if (cached) {
|
|
1061
1074
|
if (mergedConfig.debug) {
|
|
1062
1075
|
console.log("[VerificationGateway] Returning cached result");
|
|
1063
1076
|
}
|
|
1064
|
-
|
|
1065
|
-
if (request.attemptId) {
|
|
1066
|
-
hit.attemptId = request.attemptId;
|
|
1067
|
-
} else {
|
|
1068
|
-
delete hit.attemptId;
|
|
1069
|
-
}
|
|
1070
|
-
return hit;
|
|
1077
|
+
return sharedVerdict(cached, request);
|
|
1071
1078
|
}
|
|
1072
1079
|
}
|
|
1080
|
+
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
1081
|
+
const key = getCacheKey(request, mergedConfig.counterpartyId);
|
|
1082
|
+
const pending = inflightVerifies.get(key);
|
|
1083
|
+
if (pending) return sharedVerdict(await pending, request);
|
|
1084
|
+
const flight = verifyViaApi(mergedConfig, request, urls, uncacheable);
|
|
1085
|
+
inflightVerifies.set(key, flight);
|
|
1086
|
+
try {
|
|
1087
|
+
return await flight;
|
|
1088
|
+
} finally {
|
|
1089
|
+
inflightVerifies.delete(key);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
return verifyViaApi(mergedConfig, request, urls, uncacheable);
|
|
1093
|
+
}
|
|
1094
|
+
var inflightVerifies = /* @__PURE__ */ new Map();
|
|
1095
|
+
var sharedVerdicts = /* @__PURE__ */ new WeakSet();
|
|
1096
|
+
function sharedVerdict(source, request) {
|
|
1097
|
+
const hit = { ...source };
|
|
1098
|
+
if (request.attemptId) {
|
|
1099
|
+
hit.attemptId = request.attemptId;
|
|
1100
|
+
} else {
|
|
1101
|
+
delete hit.attemptId;
|
|
1102
|
+
}
|
|
1103
|
+
sharedVerdicts.add(hit);
|
|
1104
|
+
return hit;
|
|
1105
|
+
}
|
|
1106
|
+
async function verifyViaApi(mergedConfig, request, urls, uncacheable) {
|
|
1073
1107
|
const enrichedRequest = { ...request };
|
|
1074
1108
|
if (!enrichedRequest.counterpartyUrl && mergedConfig.counterpartyUrl) {
|
|
1075
1109
|
enrichedRequest.counterpartyUrl = mergedConfig.counterpartyUrl;
|
|
@@ -1097,9 +1131,18 @@ async function verify(config, request, options) {
|
|
|
1097
1131
|
if (!apiResponse.access?.allowed) {
|
|
1098
1132
|
const aggregatedFailures = apiResponse.access?.failures;
|
|
1099
1133
|
const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
|
|
1134
|
+
const denyAgent = idVerifiedFromBackend && apiResponse.agent ? {
|
|
1135
|
+
astraId: apiResponse.agent.astraId,
|
|
1136
|
+
name: apiResponse.agent.name,
|
|
1137
|
+
trustScore: apiResponse.agent.trustScore,
|
|
1138
|
+
trustLevel: getTrustLevel(apiResponse.agent.trustScore),
|
|
1139
|
+
blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
|
|
1140
|
+
status: apiResponse.agent.agentStatus
|
|
1141
|
+
} : void 0;
|
|
1100
1142
|
const result2 = {
|
|
1101
1143
|
identityVerified: idVerifiedFromBackend,
|
|
1102
1144
|
policyAllowed: false,
|
|
1145
|
+
...denyAgent && { agent: denyAgent },
|
|
1103
1146
|
// 3.6.0: the server now emits top-level denialReasons on every deny
|
|
1104
1147
|
// path — prefer it verbatim; the failure-message reconstruction remains
|
|
1105
1148
|
// as the fallback for older backends.
|
|
@@ -1139,7 +1182,9 @@ async function verify(config, request, options) {
|
|
|
1139
1182
|
fulfilment: apiResponse.fulfilment,
|
|
1140
1183
|
mandates: apiResponse.mandates,
|
|
1141
1184
|
kyaToken: apiResponse.kyaToken,
|
|
1142
|
-
aep: apiResponse.aep
|
|
1185
|
+
aep: apiResponse.aep,
|
|
1186
|
+
// 5.20.0 (round 29.1): non-fatal integration warnings (e.g. events_url_missing).
|
|
1187
|
+
warnings: apiResponse.warnings
|
|
1143
1188
|
};
|
|
1144
1189
|
return result2;
|
|
1145
1190
|
}
|
|
@@ -1207,7 +1252,9 @@ async function verify(config, request, options) {
|
|
|
1207
1252
|
// 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
|
|
1208
1253
|
mandates: apiResponse.mandates,
|
|
1209
1254
|
kyaToken: apiResponse.kyaToken,
|
|
1210
|
-
aep: apiResponse.aep
|
|
1255
|
+
aep: apiResponse.aep,
|
|
1256
|
+
// 5.20.0 (round 29.1): non-fatal integration warnings (e.g. events_url_missing).
|
|
1257
|
+
warnings: apiResponse.warnings
|
|
1211
1258
|
};
|
|
1212
1259
|
if (result.recommendation === "deny") {
|
|
1213
1260
|
result.policyAllowed = false;
|
|
@@ -1233,10 +1280,20 @@ async function verify(config, request, options) {
|
|
|
1233
1280
|
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
1234
1281
|
}
|
|
1235
1282
|
}
|
|
1283
|
+
notifyVerificationListeners(request, result);
|
|
1236
1284
|
return result;
|
|
1237
1285
|
}
|
|
1286
|
+
var verificationListeners = /* @__PURE__ */ new Set();
|
|
1287
|
+
function notifyVerificationListeners(request, result) {
|
|
1288
|
+
for (const listener of verificationListeners) {
|
|
1289
|
+
try {
|
|
1290
|
+
listener(result, request);
|
|
1291
|
+
} catch {
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1238
1295
|
var refusedPolicyReads = /* @__PURE__ */ new Set();
|
|
1239
|
-
async function fetchRoutes(config, counterpartyId) {
|
|
1296
|
+
async function fetchRoutes(config, counterpartyId, options = {}) {
|
|
1240
1297
|
if (!counterpartyId) return null;
|
|
1241
1298
|
const headers = { "Content-Type": "application/json" };
|
|
1242
1299
|
if (config.apiKey) {
|
|
@@ -1244,8 +1301,9 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
1244
1301
|
headers["X-API-Key"] = config.apiKey;
|
|
1245
1302
|
}
|
|
1246
1303
|
try {
|
|
1304
|
+
headers["X-AstraSync-SDK-Version"] = SDK_VERSION;
|
|
1247
1305
|
const response = await sdkFetch(
|
|
1248
|
-
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes
|
|
1306
|
+
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes` + (options.codeGates?.length ? `?codeGates=${options.codeGates.map(encodeURIComponent).join(",")}` : ""),
|
|
1249
1307
|
{ method: "GET", headers }
|
|
1250
1308
|
);
|
|
1251
1309
|
if (!response.ok) {
|
|
@@ -1258,6 +1316,13 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
1258
1316
|
return null;
|
|
1259
1317
|
}
|
|
1260
1318
|
const body = await response.json();
|
|
1319
|
+
const type = body.data?.counterpartyType;
|
|
1320
|
+
if (typeof type === "string" && options.onEndpointType) {
|
|
1321
|
+
try {
|
|
1322
|
+
options.onEndpointType(type);
|
|
1323
|
+
} catch {
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1261
1326
|
return body.data?.routes ?? [];
|
|
1262
1327
|
} catch {
|
|
1263
1328
|
return null;
|
|
@@ -2078,6 +2143,20 @@ function resolveHttpPdlss(input) {
|
|
|
2078
2143
|
}
|
|
2079
2144
|
return { purpose, action, purposeSource, actionSource };
|
|
2080
2145
|
}
|
|
2146
|
+
function wirePurposeSource(source) {
|
|
2147
|
+
switch (source) {
|
|
2148
|
+
case "route_config":
|
|
2149
|
+
return "route_config";
|
|
2150
|
+
case "header":
|
|
2151
|
+
case "legacy_header":
|
|
2152
|
+
case "query":
|
|
2153
|
+
return "header";
|
|
2154
|
+
case "custom_extractor":
|
|
2155
|
+
return "body";
|
|
2156
|
+
default:
|
|
2157
|
+
return "default";
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2081
2160
|
|
|
2082
2161
|
// src/adapters/approval-gate.ts
|
|
2083
2162
|
var APPROVAL_REASON = "Transaction is above the autonomous limit and requires human approval. The agent owner can approve or deny this transaction in the AstraSync dashboard.";
|
|
@@ -2509,6 +2588,10 @@ function createMiddleware(options) {
|
|
|
2509
2588
|
...commerceArtifacts && { commerceArtifacts },
|
|
2510
2589
|
purpose,
|
|
2511
2590
|
action: pdlssPair.action,
|
|
2591
|
+
// 5.19.0: route purpose claim + request line (checked server-side).
|
|
2592
|
+
purposeSource: wirePurposeSource(pdlssPair.purposeSource),
|
|
2593
|
+
requestMethod: request.method,
|
|
2594
|
+
requestPath: pathname,
|
|
2512
2595
|
resource: pathname,
|
|
2513
2596
|
counterpartyUrl,
|
|
2514
2597
|
counterpartyType: config.counterpartyType || "website",
|