@astrasyncai/verification-gateway 5.19.0 → 5.21.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 +130 -0
- package/README.md +53 -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 +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 +35 -2
- package/dist/adapters/sdk.d.ts +35 -2
- package/dist/adapters/sdk.js +110 -11
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +110 -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 +50 -12
- package/dist/bin/astrasync-codex-hook.js +50 -12
- package/dist/bin/astrasync-guard.js +50 -12
- package/dist/bin/astrasync.js +65 -13
- package/dist/browser/background.js +50 -12
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +50 -12
- 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 +50 -12
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +50 -12
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +50 -12
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +50 -12
- 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 +50 -12
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +50 -12
- 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 +286 -8
- package/dist/index.d.ts +286 -8
- package/dist/index.js +532 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +522 -49
- 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-BoGjyon0.d.mts → types-B4zhOAlq.d.mts} +30 -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-eWyZuz-3.d.ts → types-CtBXnWuV.d.ts} +30 -1
- package/dist/{types-DqWPkiYl.d.mts → types-DHHyXtuZ.d.mts} +30 -1
- package/dist/{types-DqWPkiYl.d.ts → types-DHHyXtuZ.d.ts} +30 -1
- package/dist/{types-CfBpm3w5.d.mts → types-Djpz-L0w.d.mts} +1 -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
package/dist/verify.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = "5.
|
|
2
|
+
var SDK_VERSION = "5.21.0";
|
|
3
3
|
|
|
4
4
|
// src/http.ts
|
|
5
5
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -210,6 +210,7 @@ function cacheResult(request, result, configuredTtl, counterpartyId) {
|
|
|
210
210
|
}
|
|
211
211
|
function clearCache() {
|
|
212
212
|
verificationCache.clear();
|
|
213
|
+
inflightVerifies.clear();
|
|
213
214
|
}
|
|
214
215
|
function extractCredentials(headers, query) {
|
|
215
216
|
const credentials = {};
|
|
@@ -383,6 +384,9 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
383
384
|
if (requestData.enableRuntimeChallenge)
|
|
384
385
|
body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
|
|
385
386
|
if (requestData.routePolicy) body.routePolicy = requestData.routePolicy;
|
|
387
|
+
if (config.actingProof?.connectorToken) {
|
|
388
|
+
body.actingProof = { connectorToken: config.actingProof.connectorToken };
|
|
389
|
+
}
|
|
386
390
|
if (requestData.approvalHeldByRoute) body.approvalHeldByRoute = true;
|
|
387
391
|
if (requestData.createSession) body.createSession = requestData.createSession;
|
|
388
392
|
if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
|
|
@@ -550,22 +554,46 @@ async function verify(config, request, options) {
|
|
|
550
554
|
"[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."
|
|
551
555
|
);
|
|
552
556
|
}
|
|
553
|
-
const uncacheable = Boolean(request.commerceArtifacts);
|
|
557
|
+
const uncacheable = Boolean(request.commerceArtifacts) || Boolean(mergedConfig.actingProof);
|
|
554
558
|
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
555
559
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
556
560
|
if (cached) {
|
|
557
561
|
if (mergedConfig.debug) {
|
|
558
562
|
console.log("[VerificationGateway] Returning cached result");
|
|
559
563
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
564
|
+
return sharedVerdict(cached, request);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
568
|
+
const key = getCacheKey(request, mergedConfig.counterpartyId);
|
|
569
|
+
const pending = inflightVerifies.get(key);
|
|
570
|
+
if (pending) return sharedVerdict(await pending, request);
|
|
571
|
+
const flight = verifyViaApi(mergedConfig, request, urls, uncacheable);
|
|
572
|
+
inflightVerifies.set(key, flight);
|
|
573
|
+
try {
|
|
574
|
+
return await flight;
|
|
575
|
+
} finally {
|
|
576
|
+
inflightVerifies.delete(key);
|
|
567
577
|
}
|
|
568
578
|
}
|
|
579
|
+
return verifyViaApi(mergedConfig, request, urls, uncacheable);
|
|
580
|
+
}
|
|
581
|
+
var inflightVerifies = /* @__PURE__ */ new Map();
|
|
582
|
+
var sharedVerdicts = /* @__PURE__ */ new WeakSet();
|
|
583
|
+
function isSharedVerdict(result) {
|
|
584
|
+
return sharedVerdicts.has(result);
|
|
585
|
+
}
|
|
586
|
+
function sharedVerdict(source, request) {
|
|
587
|
+
const hit = { ...source };
|
|
588
|
+
if (request.attemptId) {
|
|
589
|
+
hit.attemptId = request.attemptId;
|
|
590
|
+
} else {
|
|
591
|
+
delete hit.attemptId;
|
|
592
|
+
}
|
|
593
|
+
sharedVerdicts.add(hit);
|
|
594
|
+
return hit;
|
|
595
|
+
}
|
|
596
|
+
async function verifyViaApi(mergedConfig, request, urls, uncacheable) {
|
|
569
597
|
const enrichedRequest = { ...request };
|
|
570
598
|
if (!enrichedRequest.counterpartyUrl && mergedConfig.counterpartyUrl) {
|
|
571
599
|
enrichedRequest.counterpartyUrl = mergedConfig.counterpartyUrl;
|
|
@@ -644,7 +672,9 @@ async function verify(config, request, options) {
|
|
|
644
672
|
fulfilment: apiResponse.fulfilment,
|
|
645
673
|
mandates: apiResponse.mandates,
|
|
646
674
|
kyaToken: apiResponse.kyaToken,
|
|
647
|
-
aep: apiResponse.aep
|
|
675
|
+
aep: apiResponse.aep,
|
|
676
|
+
// 5.20.0 (round 29.1): non-fatal integration warnings (e.g. events_url_missing).
|
|
677
|
+
warnings: apiResponse.warnings
|
|
648
678
|
};
|
|
649
679
|
return result2;
|
|
650
680
|
}
|
|
@@ -712,7 +742,9 @@ async function verify(config, request, options) {
|
|
|
712
742
|
// 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
|
|
713
743
|
mandates: apiResponse.mandates,
|
|
714
744
|
kyaToken: apiResponse.kyaToken,
|
|
715
|
-
aep: apiResponse.aep
|
|
745
|
+
aep: apiResponse.aep,
|
|
746
|
+
// 5.20.0 (round 29.1): non-fatal integration warnings (e.g. events_url_missing).
|
|
747
|
+
warnings: apiResponse.warnings
|
|
716
748
|
};
|
|
717
749
|
if (result.recommendation === "deny") {
|
|
718
750
|
result.policyAllowed = false;
|
|
@@ -738,8 +770,24 @@ async function verify(config, request, options) {
|
|
|
738
770
|
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
739
771
|
}
|
|
740
772
|
}
|
|
773
|
+
notifyVerificationListeners(request, result);
|
|
741
774
|
return result;
|
|
742
775
|
}
|
|
776
|
+
var verificationListeners = /* @__PURE__ */ new Set();
|
|
777
|
+
function onVerificationResult(listener) {
|
|
778
|
+
verificationListeners.add(listener);
|
|
779
|
+
return () => {
|
|
780
|
+
verificationListeners.delete(listener);
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
function notifyVerificationListeners(request, result) {
|
|
784
|
+
for (const listener of verificationListeners) {
|
|
785
|
+
try {
|
|
786
|
+
listener(result, request);
|
|
787
|
+
} catch {
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
743
791
|
async function recordDecision(config, sessionId, decision, reason) {
|
|
744
792
|
const headers = { "Content-Type": "application/json" };
|
|
745
793
|
if (config.apiKey) {
|
|
@@ -804,6 +852,7 @@ async function fetchRoutes(config, counterpartyId, options = {}) {
|
|
|
804
852
|
headers["X-API-Key"] = config.apiKey;
|
|
805
853
|
}
|
|
806
854
|
try {
|
|
855
|
+
headers["X-AstraSync-SDK-Version"] = SDK_VERSION;
|
|
807
856
|
const response = await sdkFetch(
|
|
808
857
|
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes` + (options.codeGates?.length ? `?codeGates=${options.codeGates.map(encodeURIComponent).join(",")}` : ""),
|
|
809
858
|
{ method: "GET", headers }
|
|
@@ -818,6 +867,13 @@ async function fetchRoutes(config, counterpartyId, options = {}) {
|
|
|
818
867
|
return null;
|
|
819
868
|
}
|
|
820
869
|
const body = await response.json();
|
|
870
|
+
const type = body.data?.counterpartyType;
|
|
871
|
+
if (typeof type === "string" && options.onEndpointType) {
|
|
872
|
+
try {
|
|
873
|
+
options.onEndpointType(type);
|
|
874
|
+
} catch {
|
|
875
|
+
}
|
|
876
|
+
}
|
|
821
877
|
return body.data?.routes ?? [];
|
|
822
878
|
} catch {
|
|
823
879
|
return null;
|
|
@@ -886,6 +942,8 @@ export {
|
|
|
886
942
|
extractCredentials,
|
|
887
943
|
fetchRoutes,
|
|
888
944
|
hasCredentials,
|
|
945
|
+
isSharedVerdict,
|
|
946
|
+
onVerificationResult,
|
|
889
947
|
parseRetryAfterMs,
|
|
890
948
|
quickVerify,
|
|
891
949
|
recordDecision,
|