@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as next_server from 'next/server';
|
|
2
2
|
import { NextRequest } from 'next/server';
|
|
3
|
-
import { N as NextJsMiddlewareOptions } from '../types-
|
|
3
|
+
import { N as NextJsMiddlewareOptions } from '../types-CxjqmPl-.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Create Next.js middleware for agent verification.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as next_server from 'next/server';
|
|
2
2
|
import { NextRequest } from 'next/server';
|
|
3
|
-
import { N as NextJsMiddlewareOptions } from '../types-
|
|
3
|
+
import { N as NextJsMiddlewareOptions } from '../types-CxjqmPl-.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Create Next.js middleware for agent verification.
|
package/dist/adapters/nextjs.js
CHANGED
|
@@ -471,7 +471,7 @@ function routePolicyOf(route) {
|
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
// src/version.ts
|
|
474
|
-
var SDK_VERSION = "5.
|
|
474
|
+
var SDK_VERSION = "5.20.0";
|
|
475
475
|
|
|
476
476
|
// src/http.ts
|
|
477
477
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -737,7 +737,12 @@ function getCacheKey(request, counterpartyId) {
|
|
|
737
737
|
// its start_checkout quote was served the cached quote-leg grant (no
|
|
738
738
|
// settlementOutcome) and never reached the backend. Same F-A1-07 bug class.
|
|
739
739
|
request.commercePhase || "",
|
|
740
|
-
request.checkoutSessionId || ""
|
|
740
|
+
request.checkoutSessionId || "",
|
|
741
|
+
// 5.19.0: a route_config purpose claim is checked server-side against
|
|
742
|
+
// the stored rule for this method + path, so it changes the verdict.
|
|
743
|
+
request.purposeSource || "",
|
|
744
|
+
request.requestMethod || "",
|
|
745
|
+
request.requestPath || ""
|
|
741
746
|
].join("|");
|
|
742
747
|
}
|
|
743
748
|
function getCachedResult(request, counterpartyId) {
|
|
@@ -929,6 +934,9 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
929
934
|
if (requestData.enableRuntimeChallenge)
|
|
930
935
|
body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
|
|
931
936
|
if (requestData.routePolicy) body.routePolicy = requestData.routePolicy;
|
|
937
|
+
if (config.actingProof?.connectorToken) {
|
|
938
|
+
body.actingProof = { connectorToken: config.actingProof.connectorToken };
|
|
939
|
+
}
|
|
932
940
|
if (requestData.approvalHeldByRoute) body.approvalHeldByRoute = true;
|
|
933
941
|
if (requestData.createSession) body.createSession = requestData.createSession;
|
|
934
942
|
if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
|
|
@@ -945,6 +953,11 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
945
953
|
if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
|
|
946
954
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
947
955
|
if (requestData.attemptId) body.attemptId = requestData.attemptId;
|
|
956
|
+
if (requestData.purposeSource) body.purposeSource = requestData.purposeSource;
|
|
957
|
+
if (requestData.agentArtifacts) body.agentArtifacts = requestData.agentArtifacts;
|
|
958
|
+
if (requestData.metadata) body.metadata = requestData.metadata;
|
|
959
|
+
if (requestData.requestMethod) body.requestMethod = requestData.requestMethod;
|
|
960
|
+
if (requestData.requestPath) body.requestPath = requestData.requestPath;
|
|
948
961
|
if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
|
|
949
962
|
body.sdkVersion = SDK_VERSION;
|
|
950
963
|
if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
|
|
@@ -1091,22 +1104,43 @@ async function verify(config, request, options) {
|
|
|
1091
1104
|
"[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."
|
|
1092
1105
|
);
|
|
1093
1106
|
}
|
|
1094
|
-
const uncacheable = Boolean(request.commerceArtifacts);
|
|
1107
|
+
const uncacheable = Boolean(request.commerceArtifacts) || Boolean(mergedConfig.actingProof);
|
|
1095
1108
|
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
1096
1109
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
1097
1110
|
if (cached) {
|
|
1098
1111
|
if (mergedConfig.debug) {
|
|
1099
1112
|
console.log("[VerificationGateway] Returning cached result");
|
|
1100
1113
|
}
|
|
1101
|
-
|
|
1102
|
-
if (request.attemptId) {
|
|
1103
|
-
hit.attemptId = request.attemptId;
|
|
1104
|
-
} else {
|
|
1105
|
-
delete hit.attemptId;
|
|
1106
|
-
}
|
|
1107
|
-
return hit;
|
|
1114
|
+
return sharedVerdict(cached, request);
|
|
1108
1115
|
}
|
|
1109
1116
|
}
|
|
1117
|
+
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
1118
|
+
const key = getCacheKey(request, mergedConfig.counterpartyId);
|
|
1119
|
+
const pending = inflightVerifies.get(key);
|
|
1120
|
+
if (pending) return sharedVerdict(await pending, request);
|
|
1121
|
+
const flight = verifyViaApi(mergedConfig, request, urls, uncacheable);
|
|
1122
|
+
inflightVerifies.set(key, flight);
|
|
1123
|
+
try {
|
|
1124
|
+
return await flight;
|
|
1125
|
+
} finally {
|
|
1126
|
+
inflightVerifies.delete(key);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
return verifyViaApi(mergedConfig, request, urls, uncacheable);
|
|
1130
|
+
}
|
|
1131
|
+
var inflightVerifies = /* @__PURE__ */ new Map();
|
|
1132
|
+
var sharedVerdicts = /* @__PURE__ */ new WeakSet();
|
|
1133
|
+
function sharedVerdict(source, request) {
|
|
1134
|
+
const hit = { ...source };
|
|
1135
|
+
if (request.attemptId) {
|
|
1136
|
+
hit.attemptId = request.attemptId;
|
|
1137
|
+
} else {
|
|
1138
|
+
delete hit.attemptId;
|
|
1139
|
+
}
|
|
1140
|
+
sharedVerdicts.add(hit);
|
|
1141
|
+
return hit;
|
|
1142
|
+
}
|
|
1143
|
+
async function verifyViaApi(mergedConfig, request, urls, uncacheable) {
|
|
1110
1144
|
const enrichedRequest = { ...request };
|
|
1111
1145
|
if (!enrichedRequest.counterpartyUrl && mergedConfig.counterpartyUrl) {
|
|
1112
1146
|
enrichedRequest.counterpartyUrl = mergedConfig.counterpartyUrl;
|
|
@@ -1134,9 +1168,18 @@ async function verify(config, request, options) {
|
|
|
1134
1168
|
if (!apiResponse.access?.allowed) {
|
|
1135
1169
|
const aggregatedFailures = apiResponse.access?.failures;
|
|
1136
1170
|
const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
|
|
1171
|
+
const denyAgent = idVerifiedFromBackend && apiResponse.agent ? {
|
|
1172
|
+
astraId: apiResponse.agent.astraId,
|
|
1173
|
+
name: apiResponse.agent.name,
|
|
1174
|
+
trustScore: apiResponse.agent.trustScore,
|
|
1175
|
+
trustLevel: getTrustLevel(apiResponse.agent.trustScore),
|
|
1176
|
+
blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
|
|
1177
|
+
status: apiResponse.agent.agentStatus
|
|
1178
|
+
} : void 0;
|
|
1137
1179
|
const result2 = {
|
|
1138
1180
|
identityVerified: idVerifiedFromBackend,
|
|
1139
1181
|
policyAllowed: false,
|
|
1182
|
+
...denyAgent && { agent: denyAgent },
|
|
1140
1183
|
// 3.6.0: the server now emits top-level denialReasons on every deny
|
|
1141
1184
|
// path — prefer it verbatim; the failure-message reconstruction remains
|
|
1142
1185
|
// as the fallback for older backends.
|
|
@@ -1176,7 +1219,9 @@ async function verify(config, request, options) {
|
|
|
1176
1219
|
fulfilment: apiResponse.fulfilment,
|
|
1177
1220
|
mandates: apiResponse.mandates,
|
|
1178
1221
|
kyaToken: apiResponse.kyaToken,
|
|
1179
|
-
aep: apiResponse.aep
|
|
1222
|
+
aep: apiResponse.aep,
|
|
1223
|
+
// 5.20.0 (round 29.1): non-fatal integration warnings (e.g. events_url_missing).
|
|
1224
|
+
warnings: apiResponse.warnings
|
|
1180
1225
|
};
|
|
1181
1226
|
return result2;
|
|
1182
1227
|
}
|
|
@@ -1244,7 +1289,9 @@ async function verify(config, request, options) {
|
|
|
1244
1289
|
// 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
|
|
1245
1290
|
mandates: apiResponse.mandates,
|
|
1246
1291
|
kyaToken: apiResponse.kyaToken,
|
|
1247
|
-
aep: apiResponse.aep
|
|
1292
|
+
aep: apiResponse.aep,
|
|
1293
|
+
// 5.20.0 (round 29.1): non-fatal integration warnings (e.g. events_url_missing).
|
|
1294
|
+
warnings: apiResponse.warnings
|
|
1248
1295
|
};
|
|
1249
1296
|
if (result.recommendation === "deny") {
|
|
1250
1297
|
result.policyAllowed = false;
|
|
@@ -1270,10 +1317,20 @@ async function verify(config, request, options) {
|
|
|
1270
1317
|
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
1271
1318
|
}
|
|
1272
1319
|
}
|
|
1320
|
+
notifyVerificationListeners(request, result);
|
|
1273
1321
|
return result;
|
|
1274
1322
|
}
|
|
1323
|
+
var verificationListeners = /* @__PURE__ */ new Set();
|
|
1324
|
+
function notifyVerificationListeners(request, result) {
|
|
1325
|
+
for (const listener of verificationListeners) {
|
|
1326
|
+
try {
|
|
1327
|
+
listener(result, request);
|
|
1328
|
+
} catch {
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1275
1332
|
var refusedPolicyReads = /* @__PURE__ */ new Set();
|
|
1276
|
-
async function fetchRoutes(config, counterpartyId) {
|
|
1333
|
+
async function fetchRoutes(config, counterpartyId, options = {}) {
|
|
1277
1334
|
if (!counterpartyId) return null;
|
|
1278
1335
|
const headers = { "Content-Type": "application/json" };
|
|
1279
1336
|
if (config.apiKey) {
|
|
@@ -1281,8 +1338,9 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
1281
1338
|
headers["X-API-Key"] = config.apiKey;
|
|
1282
1339
|
}
|
|
1283
1340
|
try {
|
|
1341
|
+
headers["X-AstraSync-SDK-Version"] = SDK_VERSION;
|
|
1284
1342
|
const response = await sdkFetch(
|
|
1285
|
-
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes
|
|
1343
|
+
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes` + (options.codeGates?.length ? `?codeGates=${options.codeGates.map(encodeURIComponent).join(",")}` : ""),
|
|
1286
1344
|
{ method: "GET", headers }
|
|
1287
1345
|
);
|
|
1288
1346
|
if (!response.ok) {
|
|
@@ -1295,6 +1353,13 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
1295
1353
|
return null;
|
|
1296
1354
|
}
|
|
1297
1355
|
const body = await response.json();
|
|
1356
|
+
const type = body.data?.counterpartyType;
|
|
1357
|
+
if (typeof type === "string" && options.onEndpointType) {
|
|
1358
|
+
try {
|
|
1359
|
+
options.onEndpointType(type);
|
|
1360
|
+
} catch {
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1298
1363
|
return body.data?.routes ?? [];
|
|
1299
1364
|
} catch {
|
|
1300
1365
|
return null;
|
|
@@ -2115,6 +2180,20 @@ function resolveHttpPdlss(input) {
|
|
|
2115
2180
|
}
|
|
2116
2181
|
return { purpose, action, purposeSource, actionSource };
|
|
2117
2182
|
}
|
|
2183
|
+
function wirePurposeSource(source) {
|
|
2184
|
+
switch (source) {
|
|
2185
|
+
case "route_config":
|
|
2186
|
+
return "route_config";
|
|
2187
|
+
case "header":
|
|
2188
|
+
case "legacy_header":
|
|
2189
|
+
case "query":
|
|
2190
|
+
return "header";
|
|
2191
|
+
case "custom_extractor":
|
|
2192
|
+
return "body";
|
|
2193
|
+
default:
|
|
2194
|
+
return "default";
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2118
2197
|
|
|
2119
2198
|
// src/adapters/approval-gate.ts
|
|
2120
2199
|
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.";
|
|
@@ -2546,6 +2625,10 @@ function createMiddleware(options) {
|
|
|
2546
2625
|
...commerceArtifacts && { commerceArtifacts },
|
|
2547
2626
|
purpose,
|
|
2548
2627
|
action: pdlssPair.action,
|
|
2628
|
+
// 5.19.0: route purpose claim + request line (checked server-side).
|
|
2629
|
+
purposeSource: wirePurposeSource(pdlssPair.purposeSource),
|
|
2630
|
+
requestMethod: request.method,
|
|
2631
|
+
requestPath: pathname,
|
|
2549
2632
|
resource: pathname,
|
|
2550
2633
|
counterpartyUrl,
|
|
2551
2634
|
counterpartyType: config.counterpartyType || "website",
|