@astrasyncai/verification-gateway 5.19.0 → 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 +83 -0
- package/README.md +51 -2
- package/dist/adapter-interface/interface.d.mts +2 -2
- package/dist/adapter-interface/interface.d.ts +2 -2
- package/dist/adapters/express.d.mts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.js +65 -16
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +65 -16
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +23 -1
- package/dist/adapters/mcp.d.ts +23 -1
- package/dist/adapters/mcp.js +91 -16
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +91 -16
- 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 +57 -11
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +57 -11
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +58 -2
- package/dist/adapters/sdk.d.ts +58 -2
- package/dist/adapters/sdk.js +124 -11
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +124 -11
- 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 +49 -11
- package/dist/bin/astrasync-codex-hook.js +49 -11
- package/dist/bin/astrasync-guard.js +49 -11
- package/dist/bin/astrasync.js +51 -12
- package/dist/browser/background.js +49 -11
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +49 -11
- 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 +49 -11
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +49 -11
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +49 -11
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +49 -11
- 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 +49 -11
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +49 -11
- 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 +49 -11
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +49 -11
- 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 +168 -8
- package/dist/index.d.ts +168 -8
- package/dist/index.js +229 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +226 -31
- 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 +1 -1
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +1 -1
- 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-DqWPkiYl.d.mts → types-CxjqmPl-.d.mts} +25 -1
- package/dist/{types-DqWPkiYl.d.ts → types-CxjqmPl-.d.ts} +25 -1
- package/dist/{types-BoGjyon0.d.mts → types-D37aSQ9c.d.mts} +25 -1
- package/dist/{types-CfBpm3w5.d.mts → types-Djpz-L0w.d.mts} +1 -1
- package/dist/{types-eWyZuz-3.d.ts → types-Dn8tXnei.d.ts} +25 -1
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/verify.d.mts +28 -3
- package/dist/verify.d.ts +28 -3
- package/dist/verify.js +71 -11
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +69 -11
- package/dist/verify.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -452,7 +452,7 @@ function routePolicyOf(route) {
|
|
|
452
452
|
}
|
|
453
453
|
|
|
454
454
|
// src/version.ts
|
|
455
|
-
var SDK_VERSION = "5.
|
|
455
|
+
var SDK_VERSION = "5.20.0";
|
|
456
456
|
|
|
457
457
|
// src/http.ts
|
|
458
458
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -967,6 +967,9 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
967
967
|
if (requestData.enableRuntimeChallenge)
|
|
968
968
|
body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
|
|
969
969
|
if (requestData.routePolicy) body.routePolicy = requestData.routePolicy;
|
|
970
|
+
if (config.actingProof?.connectorToken) {
|
|
971
|
+
body.actingProof = { connectorToken: config.actingProof.connectorToken };
|
|
972
|
+
}
|
|
970
973
|
if (requestData.approvalHeldByRoute) body.approvalHeldByRoute = true;
|
|
971
974
|
if (requestData.createSession) body.createSession = requestData.createSession;
|
|
972
975
|
if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
|
|
@@ -1134,22 +1137,46 @@ async function verify(config, request, options) {
|
|
|
1134
1137
|
"[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."
|
|
1135
1138
|
);
|
|
1136
1139
|
}
|
|
1137
|
-
const uncacheable = Boolean(request.commerceArtifacts);
|
|
1140
|
+
const uncacheable = Boolean(request.commerceArtifacts) || Boolean(mergedConfig.actingProof);
|
|
1138
1141
|
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
1139
1142
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
1140
1143
|
if (cached) {
|
|
1141
1144
|
if (mergedConfig.debug) {
|
|
1142
1145
|
console.log("[VerificationGateway] Returning cached result");
|
|
1143
1146
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1147
|
+
return sharedVerdict(cached, request);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
1151
|
+
const key = getCacheKey(request, mergedConfig.counterpartyId);
|
|
1152
|
+
const pending = inflightVerifies.get(key);
|
|
1153
|
+
if (pending) return sharedVerdict(await pending, request);
|
|
1154
|
+
const flight = verifyViaApi(mergedConfig, request, urls, uncacheable);
|
|
1155
|
+
inflightVerifies.set(key, flight);
|
|
1156
|
+
try {
|
|
1157
|
+
return await flight;
|
|
1158
|
+
} finally {
|
|
1159
|
+
inflightVerifies.delete(key);
|
|
1151
1160
|
}
|
|
1152
1161
|
}
|
|
1162
|
+
return verifyViaApi(mergedConfig, request, urls, uncacheable);
|
|
1163
|
+
}
|
|
1164
|
+
var inflightVerifies = /* @__PURE__ */ new Map();
|
|
1165
|
+
var sharedVerdicts = /* @__PURE__ */ new WeakSet();
|
|
1166
|
+
function isSharedVerdict(result) {
|
|
1167
|
+
return sharedVerdicts.has(result);
|
|
1168
|
+
}
|
|
1169
|
+
function sharedVerdict(source, request) {
|
|
1170
|
+
const hit = { ...source };
|
|
1171
|
+
if (request.attemptId) {
|
|
1172
|
+
hit.attemptId = request.attemptId;
|
|
1173
|
+
} else {
|
|
1174
|
+
delete hit.attemptId;
|
|
1175
|
+
}
|
|
1176
|
+
sharedVerdicts.add(hit);
|
|
1177
|
+
return hit;
|
|
1178
|
+
}
|
|
1179
|
+
async function verifyViaApi(mergedConfig, request, urls, uncacheable) {
|
|
1153
1180
|
const enrichedRequest = { ...request };
|
|
1154
1181
|
if (!enrichedRequest.counterpartyUrl && mergedConfig.counterpartyUrl) {
|
|
1155
1182
|
enrichedRequest.counterpartyUrl = mergedConfig.counterpartyUrl;
|
|
@@ -1228,7 +1255,9 @@ async function verify(config, request, options) {
|
|
|
1228
1255
|
fulfilment: apiResponse.fulfilment,
|
|
1229
1256
|
mandates: apiResponse.mandates,
|
|
1230
1257
|
kyaToken: apiResponse.kyaToken,
|
|
1231
|
-
aep: apiResponse.aep
|
|
1258
|
+
aep: apiResponse.aep,
|
|
1259
|
+
// 5.20.0 (round 29.1): non-fatal integration warnings (e.g. events_url_missing).
|
|
1260
|
+
warnings: apiResponse.warnings
|
|
1232
1261
|
};
|
|
1233
1262
|
return result2;
|
|
1234
1263
|
}
|
|
@@ -1296,7 +1325,9 @@ async function verify(config, request, options) {
|
|
|
1296
1325
|
// 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
|
|
1297
1326
|
mandates: apiResponse.mandates,
|
|
1298
1327
|
kyaToken: apiResponse.kyaToken,
|
|
1299
|
-
aep: apiResponse.aep
|
|
1328
|
+
aep: apiResponse.aep,
|
|
1329
|
+
// 5.20.0 (round 29.1): non-fatal integration warnings (e.g. events_url_missing).
|
|
1330
|
+
warnings: apiResponse.warnings
|
|
1300
1331
|
};
|
|
1301
1332
|
if (result.recommendation === "deny") {
|
|
1302
1333
|
result.policyAllowed = false;
|
|
@@ -1322,8 +1353,18 @@ async function verify(config, request, options) {
|
|
|
1322
1353
|
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
1323
1354
|
}
|
|
1324
1355
|
}
|
|
1356
|
+
notifyVerificationListeners(request, result);
|
|
1325
1357
|
return result;
|
|
1326
1358
|
}
|
|
1359
|
+
var verificationListeners = /* @__PURE__ */ new Set();
|
|
1360
|
+
function notifyVerificationListeners(request, result) {
|
|
1361
|
+
for (const listener of verificationListeners) {
|
|
1362
|
+
try {
|
|
1363
|
+
listener(result, request);
|
|
1364
|
+
} catch {
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1327
1368
|
async function recordDecision(config, sessionId, decision, reason) {
|
|
1328
1369
|
const headers = { "Content-Type": "application/json" };
|
|
1329
1370
|
if (config.apiKey) {
|
|
@@ -1346,6 +1387,7 @@ async function fetchRoutes(config, counterpartyId, options = {}) {
|
|
|
1346
1387
|
headers["X-API-Key"] = config.apiKey;
|
|
1347
1388
|
}
|
|
1348
1389
|
try {
|
|
1390
|
+
headers["X-AstraSync-SDK-Version"] = SDK_VERSION;
|
|
1349
1391
|
const response = await sdkFetch(
|
|
1350
1392
|
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes` + (options.codeGates?.length ? `?codeGates=${options.codeGates.map(encodeURIComponent).join(",")}` : ""),
|
|
1351
1393
|
{ method: "GET", headers }
|
|
@@ -1360,6 +1402,13 @@ async function fetchRoutes(config, counterpartyId, options = {}) {
|
|
|
1360
1402
|
return null;
|
|
1361
1403
|
}
|
|
1362
1404
|
const body = await response.json();
|
|
1405
|
+
const type = body.data?.counterpartyType;
|
|
1406
|
+
if (typeof type === "string" && options.onEndpointType) {
|
|
1407
|
+
try {
|
|
1408
|
+
options.onEndpointType(type);
|
|
1409
|
+
} catch {
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1363
1412
|
return body.data?.routes ?? [];
|
|
1364
1413
|
} catch {
|
|
1365
1414
|
return null;
|
|
@@ -2638,14 +2687,14 @@ function createMiddleware(options) {
|
|
|
2638
2687
|
res.setHeader("X-Astra-Gateway-Mode", "enforced");
|
|
2639
2688
|
res.setHeader("X-Astra-Gateway-Reason", "evaluated-not-enforced");
|
|
2640
2689
|
}
|
|
2641
|
-
if (shouldRecordDecisions && sessionId) {
|
|
2690
|
+
if (shouldRecordDecisions && sessionId && !isSharedVerdict(result)) {
|
|
2642
2691
|
recordDecision(config, sessionId, "granted").catch(() => {
|
|
2643
2692
|
});
|
|
2644
2693
|
}
|
|
2645
2694
|
return next();
|
|
2646
2695
|
}
|
|
2647
2696
|
if (!result.policyAllowed) {
|
|
2648
|
-
if (shouldRecordDecisions && sessionId) {
|
|
2697
|
+
if (shouldRecordDecisions && sessionId && !isSharedVerdict(result)) {
|
|
2649
2698
|
recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
|
|
2650
2699
|
});
|
|
2651
2700
|
}
|
|
@@ -2658,7 +2707,7 @@ function createMiddleware(options) {
|
|
|
2658
2707
|
}
|
|
2659
2708
|
if (requiresHumanApproval(result)) {
|
|
2660
2709
|
annotateApprovalRequired(result);
|
|
2661
|
-
if (shouldRecordDecisions && sessionId) {
|
|
2710
|
+
if (shouldRecordDecisions && sessionId && !isSharedVerdict(result)) {
|
|
2662
2711
|
recordDecision(config, sessionId, "denied", result.denialReasons?.[0]).catch(() => {
|
|
2663
2712
|
});
|
|
2664
2713
|
}
|
|
@@ -2683,7 +2732,7 @@ function createMiddleware(options) {
|
|
|
2683
2732
|
documentationUrl: wellKnownUrls.documentationUrl
|
|
2684
2733
|
};
|
|
2685
2734
|
}
|
|
2686
|
-
if (shouldRecordDecisions && sessionId) {
|
|
2735
|
+
if (shouldRecordDecisions && sessionId && !isSharedVerdict(result)) {
|
|
2687
2736
|
recordDecision(config, sessionId, "denied", trustFailure.message).catch(() => {
|
|
2688
2737
|
});
|
|
2689
2738
|
}
|
|
@@ -2692,7 +2741,7 @@ function createMiddleware(options) {
|
|
|
2692
2741
|
return;
|
|
2693
2742
|
}
|
|
2694
2743
|
}
|
|
2695
|
-
if (shouldRecordDecisions && sessionId) {
|
|
2744
|
+
if (shouldRecordDecisions && sessionId && !isSharedVerdict(result)) {
|
|
2696
2745
|
recordDecision(config, sessionId, "granted").catch(() => {
|
|
2697
2746
|
});
|
|
2698
2747
|
}
|