@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/verify.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = "5.
|
|
2
|
+
var SDK_VERSION = "5.20.0";
|
|
3
3
|
|
|
4
4
|
// src/http.ts
|
|
5
5
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -180,7 +180,12 @@ function getCacheKey(request, counterpartyId) {
|
|
|
180
180
|
// its start_checkout quote was served the cached quote-leg grant (no
|
|
181
181
|
// settlementOutcome) and never reached the backend. Same F-A1-07 bug class.
|
|
182
182
|
request.commercePhase || "",
|
|
183
|
-
request.checkoutSessionId || ""
|
|
183
|
+
request.checkoutSessionId || "",
|
|
184
|
+
// 5.19.0: a route_config purpose claim is checked server-side against
|
|
185
|
+
// the stored rule for this method + path, so it changes the verdict.
|
|
186
|
+
request.purposeSource || "",
|
|
187
|
+
request.requestMethod || "",
|
|
188
|
+
request.requestPath || ""
|
|
184
189
|
].join("|");
|
|
185
190
|
}
|
|
186
191
|
function getCachedResult(request, counterpartyId) {
|
|
@@ -205,6 +210,7 @@ function cacheResult(request, result, configuredTtl, counterpartyId) {
|
|
|
205
210
|
}
|
|
206
211
|
function clearCache() {
|
|
207
212
|
verificationCache.clear();
|
|
213
|
+
inflightVerifies.clear();
|
|
208
214
|
}
|
|
209
215
|
function extractCredentials(headers, query) {
|
|
210
216
|
const credentials = {};
|
|
@@ -378,6 +384,9 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
378
384
|
if (requestData.enableRuntimeChallenge)
|
|
379
385
|
body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
|
|
380
386
|
if (requestData.routePolicy) body.routePolicy = requestData.routePolicy;
|
|
387
|
+
if (config.actingProof?.connectorToken) {
|
|
388
|
+
body.actingProof = { connectorToken: config.actingProof.connectorToken };
|
|
389
|
+
}
|
|
381
390
|
if (requestData.approvalHeldByRoute) body.approvalHeldByRoute = true;
|
|
382
391
|
if (requestData.createSession) body.createSession = requestData.createSession;
|
|
383
392
|
if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
|
|
@@ -394,6 +403,11 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
394
403
|
if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
|
|
395
404
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
396
405
|
if (requestData.attemptId) body.attemptId = requestData.attemptId;
|
|
406
|
+
if (requestData.purposeSource) body.purposeSource = requestData.purposeSource;
|
|
407
|
+
if (requestData.agentArtifacts) body.agentArtifacts = requestData.agentArtifacts;
|
|
408
|
+
if (requestData.metadata) body.metadata = requestData.metadata;
|
|
409
|
+
if (requestData.requestMethod) body.requestMethod = requestData.requestMethod;
|
|
410
|
+
if (requestData.requestPath) body.requestPath = requestData.requestPath;
|
|
397
411
|
if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
|
|
398
412
|
body.sdkVersion = SDK_VERSION;
|
|
399
413
|
if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
|
|
@@ -540,22 +554,46 @@ async function verify(config, request, options) {
|
|
|
540
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."
|
|
541
555
|
);
|
|
542
556
|
}
|
|
543
|
-
const uncacheable = Boolean(request.commerceArtifacts);
|
|
557
|
+
const uncacheable = Boolean(request.commerceArtifacts) || Boolean(mergedConfig.actingProof);
|
|
544
558
|
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
545
559
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
546
560
|
if (cached) {
|
|
547
561
|
if (mergedConfig.debug) {
|
|
548
562
|
console.log("[VerificationGateway] Returning cached result");
|
|
549
563
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
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);
|
|
557
577
|
}
|
|
558
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) {
|
|
559
597
|
const enrichedRequest = { ...request };
|
|
560
598
|
if (!enrichedRequest.counterpartyUrl && mergedConfig.counterpartyUrl) {
|
|
561
599
|
enrichedRequest.counterpartyUrl = mergedConfig.counterpartyUrl;
|
|
@@ -583,9 +621,18 @@ async function verify(config, request, options) {
|
|
|
583
621
|
if (!apiResponse.access?.allowed) {
|
|
584
622
|
const aggregatedFailures = apiResponse.access?.failures;
|
|
585
623
|
const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
|
|
624
|
+
const denyAgent = idVerifiedFromBackend && apiResponse.agent ? {
|
|
625
|
+
astraId: apiResponse.agent.astraId,
|
|
626
|
+
name: apiResponse.agent.name,
|
|
627
|
+
trustScore: apiResponse.agent.trustScore,
|
|
628
|
+
trustLevel: getTrustLevel(apiResponse.agent.trustScore),
|
|
629
|
+
blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
|
|
630
|
+
status: apiResponse.agent.agentStatus
|
|
631
|
+
} : void 0;
|
|
586
632
|
const result2 = {
|
|
587
633
|
identityVerified: idVerifiedFromBackend,
|
|
588
634
|
policyAllowed: false,
|
|
635
|
+
...denyAgent && { agent: denyAgent },
|
|
589
636
|
// 3.6.0: the server now emits top-level denialReasons on every deny
|
|
590
637
|
// path — prefer it verbatim; the failure-message reconstruction remains
|
|
591
638
|
// as the fallback for older backends.
|
|
@@ -625,7 +672,9 @@ async function verify(config, request, options) {
|
|
|
625
672
|
fulfilment: apiResponse.fulfilment,
|
|
626
673
|
mandates: apiResponse.mandates,
|
|
627
674
|
kyaToken: apiResponse.kyaToken,
|
|
628
|
-
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
|
|
629
678
|
};
|
|
630
679
|
return result2;
|
|
631
680
|
}
|
|
@@ -693,7 +742,9 @@ async function verify(config, request, options) {
|
|
|
693
742
|
// 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
|
|
694
743
|
mandates: apiResponse.mandates,
|
|
695
744
|
kyaToken: apiResponse.kyaToken,
|
|
696
|
-
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
|
|
697
748
|
};
|
|
698
749
|
if (result.recommendation === "deny") {
|
|
699
750
|
result.policyAllowed = false;
|
|
@@ -719,8 +770,24 @@ async function verify(config, request, options) {
|
|
|
719
770
|
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
720
771
|
}
|
|
721
772
|
}
|
|
773
|
+
notifyVerificationListeners(request, result);
|
|
722
774
|
return result;
|
|
723
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
|
+
}
|
|
724
791
|
async function recordDecision(config, sessionId, decision, reason) {
|
|
725
792
|
const headers = { "Content-Type": "application/json" };
|
|
726
793
|
if (config.apiKey) {
|
|
@@ -777,7 +844,7 @@ async function reportAttempt(config, report, options = {}) {
|
|
|
777
844
|
}
|
|
778
845
|
var ATTEMPT_REPORT_MAX_RETRY_DELAY_MS = 2e3;
|
|
779
846
|
var refusedPolicyReads = /* @__PURE__ */ new Set();
|
|
780
|
-
async function fetchRoutes(config, counterpartyId) {
|
|
847
|
+
async function fetchRoutes(config, counterpartyId, options = {}) {
|
|
781
848
|
if (!counterpartyId) return null;
|
|
782
849
|
const headers = { "Content-Type": "application/json" };
|
|
783
850
|
if (config.apiKey) {
|
|
@@ -785,8 +852,9 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
785
852
|
headers["X-API-Key"] = config.apiKey;
|
|
786
853
|
}
|
|
787
854
|
try {
|
|
855
|
+
headers["X-AstraSync-SDK-Version"] = SDK_VERSION;
|
|
788
856
|
const response = await sdkFetch(
|
|
789
|
-
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes
|
|
857
|
+
`${config.apiBaseUrl}/endpoints/${encodeURIComponent(counterpartyId)}/routes` + (options.codeGates?.length ? `?codeGates=${options.codeGates.map(encodeURIComponent).join(",")}` : ""),
|
|
790
858
|
{ method: "GET", headers }
|
|
791
859
|
);
|
|
792
860
|
if (!response.ok) {
|
|
@@ -799,6 +867,13 @@ async function fetchRoutes(config, counterpartyId) {
|
|
|
799
867
|
return null;
|
|
800
868
|
}
|
|
801
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
|
+
}
|
|
802
877
|
return body.data?.routes ?? [];
|
|
803
878
|
} catch {
|
|
804
879
|
return null;
|
|
@@ -867,6 +942,8 @@ export {
|
|
|
867
942
|
extractCredentials,
|
|
868
943
|
fetchRoutes,
|
|
869
944
|
hasCredentials,
|
|
945
|
+
isSharedVerdict,
|
|
946
|
+
onVerificationResult,
|
|
870
947
|
parseRetryAfterMs,
|
|
871
948
|
quickVerify,
|
|
872
949
|
recordDecision,
|