@astrasyncai/verification-gateway 5.14.0 → 5.16.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/README.md +36 -18
- package/dist/adapters/express.d.mts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.js +492 -240
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +492 -240
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/mcp.d.mts +1 -1
- package/dist/adapters/mcp.d.ts +1 -1
- package/dist/adapters/mcp.js +23 -6
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +23 -6
- 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 +475 -239
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +475 -239
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +18 -10
- package/dist/adapters/sdk.d.ts +18 -10
- package/dist/adapters/sdk.js +83 -23
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +83 -23
- package/dist/adapters/sdk.mjs.map +1 -1
- package/dist/agent/index.d.mts +69 -54
- package/dist/agent/index.d.ts +69 -54
- package/dist/agent/index.js +24 -14
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +24 -14
- package/dist/agent/index.mjs.map +1 -1
- package/dist/bin/astrasync-claude-hook.js +58 -11
- package/dist/bin/astrasync-codex-hook.js +58 -11
- package/dist/bin/astrasync-guard.js +177 -11
- package/dist/bin/astrasync.js +433 -38
- package/dist/browser/background.js +53 -6
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +63 -6
- 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 +58 -11
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +68 -11
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +58 -11
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +68 -11
- package/dist/cursor/extension.mjs.map +1 -1
- package/dist/edge-config.d.mts +31 -2
- package/dist/edge-config.d.ts +31 -2
- package/dist/edge-config.js +35 -5
- package/dist/edge-config.js.map +1 -1
- package/dist/edge-config.mjs +32 -4
- package/dist/edge-config.mjs.map +1 -1
- package/dist/edge-core/index.d.mts +11 -2
- package/dist/edge-core/index.d.ts +11 -2
- package/dist/edge-core/index.js +97 -11
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +95 -11
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/gateway/gateway.js +53 -6
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +63 -6
- 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 +1407 -88
- package/dist/index.d.ts +1407 -88
- package/dist/index.js +5148 -2616
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5094 -2618
- package/dist/index.mjs.map +1 -1
- package/dist/registration/index.d.mts +28 -2
- package/dist/registration/index.d.ts +28 -2
- package/dist/registration/index.js +18 -3
- package/dist/registration/index.js.map +1 -1
- package/dist/registration/index.mjs +15 -2
- package/dist/registration/index.mjs.map +1 -1
- package/dist/transport/index.d.mts +7 -5
- package/dist/transport/index.d.ts +7 -5
- package/dist/transport/index.js +61 -5
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +67 -11
- package/dist/transport/index.mjs.map +1 -1
- package/dist/{types-BCkwBA84.d.mts → types-Blz520bR.d.mts} +116 -12
- package/dist/{types-BCkwBA84.d.ts → types-Blz520bR.d.ts} +116 -12
- package/dist/{types-C_b4QTyO.d.ts → types-Bm1QvGqI.d.ts} +114 -10
- package/dist/{types-DlshIIR-.d.mts → types-DBe4hgfT.d.mts} +114 -10
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/verify.d.mts +1 -1
- package/dist/verify.d.ts +1 -1
- package/dist/verify.js +23 -6
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +23 -6
- package/dist/verify.mjs.map +1 -1
- package/package.json +1 -1
package/dist/adapters/sdk.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = "5.
|
|
2
|
+
var SDK_VERSION = "5.16.0";
|
|
3
3
|
|
|
4
4
|
// src/http.ts
|
|
5
5
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -159,6 +159,8 @@ function getCacheKey(request, counterpartyId) {
|
|
|
159
159
|
request.durationRequired ?? "",
|
|
160
160
|
request.invocationProtocol || "",
|
|
161
161
|
request.enableRuntimeChallenge ? "1" : "0",
|
|
162
|
+
// 5.16.0: route policy changes the verdict (owners / challenge).
|
|
163
|
+
request.routePolicy ? JSON.stringify(request.routePolicy) : "",
|
|
162
164
|
// callerMetadata fields contribute to risk model; include the ones
|
|
163
165
|
// backend reads. sourceIp/userAgent/forwardedFor change per-request
|
|
164
166
|
// so their inclusion effectively forces a re-check for any varying
|
|
@@ -334,6 +336,7 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
334
336
|
if (requestData.subAgentDepth !== void 0) body.subAgentDepth = requestData.subAgentDepth;
|
|
335
337
|
if (requestData.enableRuntimeChallenge)
|
|
336
338
|
body.enableRuntimeChallenge = requestData.enableRuntimeChallenge;
|
|
339
|
+
if (requestData.routePolicy) body.routePolicy = requestData.routePolicy;
|
|
337
340
|
if (requestData.createSession) body.createSession = requestData.createSession;
|
|
338
341
|
if (requestData.durationRequired) body.durationRequired = requestData.durationRequired;
|
|
339
342
|
if (requestData.counterpartyType) body.counterpartyType = requestData.counterpartyType;
|
|
@@ -344,6 +347,7 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
344
347
|
if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
|
|
345
348
|
if (requestData.commercePhase) body.commercePhase = requestData.commercePhase;
|
|
346
349
|
if (requestData.checkoutSessionId) body.checkoutSessionId = requestData.checkoutSessionId;
|
|
350
|
+
if (requestData.checkoutJwt) body.checkoutJwt = requestData.checkoutJwt;
|
|
347
351
|
if (requestData.checkoutItems) body.checkoutItems = requestData.checkoutItems;
|
|
348
352
|
if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
|
|
349
353
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
@@ -494,7 +498,8 @@ async function verify(config, request, options) {
|
|
|
494
498
|
"[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."
|
|
495
499
|
);
|
|
496
500
|
}
|
|
497
|
-
|
|
501
|
+
const uncacheable = Boolean(request.commerceArtifacts);
|
|
502
|
+
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
498
503
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
499
504
|
if (cached) {
|
|
500
505
|
if (mergedConfig.debug) {
|
|
@@ -575,7 +580,10 @@ async function verify(config, request, options) {
|
|
|
575
580
|
// MERCHANT caller only (bridge callers strip it before the agent plane).
|
|
576
581
|
settlementToken: apiResponse.settlementToken,
|
|
577
582
|
// 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
|
|
578
|
-
fulfilment: apiResponse.fulfilment
|
|
583
|
+
fulfilment: apiResponse.fulfilment,
|
|
584
|
+
mandates: apiResponse.mandates,
|
|
585
|
+
kyaToken: apiResponse.kyaToken,
|
|
586
|
+
aep: apiResponse.aep
|
|
579
587
|
};
|
|
580
588
|
return result2;
|
|
581
589
|
}
|
|
@@ -585,7 +593,10 @@ async function verify(config, request, options) {
|
|
|
585
593
|
trustScore: apiResponse.agent.trustScore,
|
|
586
594
|
trustLevel: getTrustLevel(apiResponse.agent.trustScore),
|
|
587
595
|
blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
|
|
588
|
-
status: apiResponse.agent.agentStatus
|
|
596
|
+
status: apiResponse.agent.agentStatus,
|
|
597
|
+
...apiResponse.agent.protocolIdentities && {
|
|
598
|
+
protocolIdentities: apiResponse.agent.protocolIdentities
|
|
599
|
+
}
|
|
589
600
|
} : void 0;
|
|
590
601
|
const developer = apiResponse.developer ? {
|
|
591
602
|
astradId: apiResponse.developer.kyaOwnerId,
|
|
@@ -636,7 +647,11 @@ async function verify(config, request, options) {
|
|
|
636
647
|
settlementOutcome: apiResponse.settlementOutcome,
|
|
637
648
|
settlementToken: apiResponse.settlementToken,
|
|
638
649
|
// 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
|
|
639
|
-
fulfilment: apiResponse.fulfilment
|
|
650
|
+
fulfilment: apiResponse.fulfilment,
|
|
651
|
+
// 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
|
|
652
|
+
mandates: apiResponse.mandates,
|
|
653
|
+
kyaToken: apiResponse.kyaToken,
|
|
654
|
+
aep: apiResponse.aep
|
|
640
655
|
};
|
|
641
656
|
if (result.recommendation === "deny") {
|
|
642
657
|
result.policyAllowed = false;
|
|
@@ -656,7 +671,9 @@ async function verify(config, request, options) {
|
|
|
656
671
|
}
|
|
657
672
|
const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
|
|
658
673
|
if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
|
|
659
|
-
|
|
674
|
+
if (!uncacheable) {
|
|
675
|
+
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
676
|
+
}
|
|
660
677
|
}
|
|
661
678
|
return result;
|
|
662
679
|
}
|
|
@@ -676,6 +693,24 @@ async function quickVerify(config, credentials) {
|
|
|
676
693
|
};
|
|
677
694
|
}
|
|
678
695
|
|
|
696
|
+
// src/registration/errors.ts
|
|
697
|
+
var AstraSyncError = class extends Error {
|
|
698
|
+
constructor(message, statusCode, code) {
|
|
699
|
+
super(message);
|
|
700
|
+
this.name = "AstraSyncError";
|
|
701
|
+
this.statusCode = statusCode;
|
|
702
|
+
this.code = code;
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
var SettlementReportError = class extends AstraSyncError {
|
|
706
|
+
constructor(message, statusCode, code, issues) {
|
|
707
|
+
super(message, statusCode, code);
|
|
708
|
+
this.name = "SettlementReportError";
|
|
709
|
+
this.issues = issues;
|
|
710
|
+
this.retryable = statusCode === 0 || statusCode === 429 || statusCode >= 500;
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
|
|
679
714
|
// src/adapters/sdk.ts
|
|
680
715
|
var VerificationGatewayClient = class {
|
|
681
716
|
constructor(options) {
|
|
@@ -783,6 +818,7 @@ var VerificationGatewayClient = class {
|
|
|
783
818
|
commercePhase: "confirm",
|
|
784
819
|
checkoutSessionId: options.checkoutSessionId,
|
|
785
820
|
checkoutItems: options.checkoutItems,
|
|
821
|
+
...options.checkoutJwt && { checkoutJwt: options.checkoutJwt },
|
|
786
822
|
...options.attemptId && { attemptId: options.attemptId },
|
|
787
823
|
buyerEmail: options.buyerEmail,
|
|
788
824
|
counterpartyUrl: options.counterpartyUrl,
|
|
@@ -796,28 +832,52 @@ var VerificationGatewayClient = class {
|
|
|
796
832
|
);
|
|
797
833
|
}
|
|
798
834
|
/**
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
* /orders and the agent's poll surface reconcile.
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
*
|
|
835
|
+
* Report a settlement outcome back to the platform. 5.14.1: AstraSync never
|
|
836
|
+
* charges — EVERY merchant settles the orders it is handed (card token,
|
|
837
|
+
* stablecoin voucher, or a protocol-native credential) and reports here, so
|
|
838
|
+
* the buyer's dashboard, /orders and the agent's poll surface reconcile.
|
|
839
|
+
* Identify the order by the confirm's `sessionId` or the `orderId` from
|
|
840
|
+
* `settlementOutcome`. A settled card charge carries `processorRef` (pi_…);
|
|
841
|
+
* a settled stablecoin transfer carries `txHash` (+ `chainId`). Amounts must
|
|
842
|
+
* match the order EXACTLY (integer minor units) or the report is rejected
|
|
843
|
+
* whole (409 amount_mismatch). Replays of the same terminal state are safe.
|
|
806
844
|
*/
|
|
807
845
|
async reportSettlement(options) {
|
|
846
|
+
if (!options.sessionId && !options.orderId) {
|
|
847
|
+
throw new SettlementReportError(
|
|
848
|
+
"reportSettlement needs sessionId or orderId",
|
|
849
|
+
400,
|
|
850
|
+
"VALIDATION"
|
|
851
|
+
);
|
|
852
|
+
}
|
|
808
853
|
const base = this.config.apiBaseUrl.replace(/\/+$/, "");
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
854
|
+
let res;
|
|
855
|
+
try {
|
|
856
|
+
res = await sdkFetch(`${base}/merchant/settlements/report`, {
|
|
857
|
+
method: "POST",
|
|
858
|
+
headers: {
|
|
859
|
+
"Content-Type": "application/json",
|
|
860
|
+
// Same auth pair as every backend call the SDK makes (verify.ts).
|
|
861
|
+
...this.config.apiKey ? { Authorization: `Bearer ${this.config.apiKey}`, "X-API-Key": this.config.apiKey } : {}
|
|
862
|
+
},
|
|
863
|
+
body: JSON.stringify(options)
|
|
864
|
+
});
|
|
865
|
+
} catch (err) {
|
|
866
|
+
throw new SettlementReportError(
|
|
867
|
+
`reportSettlement failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
868
|
+
0,
|
|
869
|
+
"network_error"
|
|
870
|
+
);
|
|
871
|
+
}
|
|
818
872
|
const json = await res.json().catch(() => ({}));
|
|
819
873
|
if (!res.ok || !json.success || !json.data) {
|
|
820
|
-
|
|
874
|
+
const code = json.code ?? json.error ?? "unknown_error";
|
|
875
|
+
throw new SettlementReportError(
|
|
876
|
+
`reportSettlement failed (${res.status}): ${code}`,
|
|
877
|
+
res.status,
|
|
878
|
+
code,
|
|
879
|
+
json.issues
|
|
880
|
+
);
|
|
821
881
|
}
|
|
822
882
|
return json.data;
|
|
823
883
|
}
|