@astrasyncai/verification-gateway 5.14.0 → 5.15.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 +27 -17
- package/dist/adapters/express.d.mts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.js +477 -240
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +477 -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 +20 -6
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +20 -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 +460 -239
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +460 -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 +80 -23
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +80 -23
- package/dist/adapters/sdk.mjs.map +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 +55 -11
- package/dist/bin/astrasync-codex-hook.js +55 -11
- package/dist/bin/astrasync-guard.js +55 -11
- package/dist/bin/astrasync.js +288 -33
- package/dist/browser/background.js +50 -6
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +60 -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 +55 -11
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +65 -11
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +55 -11
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +65 -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 +93 -10
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +91 -10
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/gateway/gateway.js +50 -6
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +60 -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 +1314 -34
- package/dist/index.d.ts +1314 -34
- package/dist/index.js +5116 -2612
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5063 -2614
- 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-C_b4QTyO.d.ts → types-DtJjlW4O.d.ts} +104 -10
- package/dist/{types-BCkwBA84.d.mts → types-Dxf9DBpr.d.mts} +106 -12
- package/dist/{types-BCkwBA84.d.ts → types-Dxf9DBpr.d.ts} +106 -12
- package/dist/{types-DlshIIR-.d.mts → types-Eg6VoBNH.d.mts} +104 -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 +20 -6
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +20 -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.15.0";
|
|
3
3
|
|
|
4
4
|
// src/http.ts
|
|
5
5
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -344,6 +344,7 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
344
344
|
if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
|
|
345
345
|
if (requestData.commercePhase) body.commercePhase = requestData.commercePhase;
|
|
346
346
|
if (requestData.checkoutSessionId) body.checkoutSessionId = requestData.checkoutSessionId;
|
|
347
|
+
if (requestData.checkoutJwt) body.checkoutJwt = requestData.checkoutJwt;
|
|
347
348
|
if (requestData.checkoutItems) body.checkoutItems = requestData.checkoutItems;
|
|
348
349
|
if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
|
|
349
350
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
@@ -494,7 +495,8 @@ async function verify(config, request, options) {
|
|
|
494
495
|
"[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
496
|
);
|
|
496
497
|
}
|
|
497
|
-
|
|
498
|
+
const uncacheable = Boolean(request.commerceArtifacts);
|
|
499
|
+
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
498
500
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
499
501
|
if (cached) {
|
|
500
502
|
if (mergedConfig.debug) {
|
|
@@ -575,7 +577,10 @@ async function verify(config, request, options) {
|
|
|
575
577
|
// MERCHANT caller only (bridge callers strip it before the agent plane).
|
|
576
578
|
settlementToken: apiResponse.settlementToken,
|
|
577
579
|
// 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
|
|
578
|
-
fulfilment: apiResponse.fulfilment
|
|
580
|
+
fulfilment: apiResponse.fulfilment,
|
|
581
|
+
mandates: apiResponse.mandates,
|
|
582
|
+
kyaToken: apiResponse.kyaToken,
|
|
583
|
+
aep: apiResponse.aep
|
|
579
584
|
};
|
|
580
585
|
return result2;
|
|
581
586
|
}
|
|
@@ -585,7 +590,10 @@ async function verify(config, request, options) {
|
|
|
585
590
|
trustScore: apiResponse.agent.trustScore,
|
|
586
591
|
trustLevel: getTrustLevel(apiResponse.agent.trustScore),
|
|
587
592
|
blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
|
|
588
|
-
status: apiResponse.agent.agentStatus
|
|
593
|
+
status: apiResponse.agent.agentStatus,
|
|
594
|
+
...apiResponse.agent.protocolIdentities && {
|
|
595
|
+
protocolIdentities: apiResponse.agent.protocolIdentities
|
|
596
|
+
}
|
|
589
597
|
} : void 0;
|
|
590
598
|
const developer = apiResponse.developer ? {
|
|
591
599
|
astradId: apiResponse.developer.kyaOwnerId,
|
|
@@ -636,7 +644,11 @@ async function verify(config, request, options) {
|
|
|
636
644
|
settlementOutcome: apiResponse.settlementOutcome,
|
|
637
645
|
settlementToken: apiResponse.settlementToken,
|
|
638
646
|
// 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
|
|
639
|
-
fulfilment: apiResponse.fulfilment
|
|
647
|
+
fulfilment: apiResponse.fulfilment,
|
|
648
|
+
// 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
|
|
649
|
+
mandates: apiResponse.mandates,
|
|
650
|
+
kyaToken: apiResponse.kyaToken,
|
|
651
|
+
aep: apiResponse.aep
|
|
640
652
|
};
|
|
641
653
|
if (result.recommendation === "deny") {
|
|
642
654
|
result.policyAllowed = false;
|
|
@@ -656,7 +668,9 @@ async function verify(config, request, options) {
|
|
|
656
668
|
}
|
|
657
669
|
const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
|
|
658
670
|
if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
|
|
659
|
-
|
|
671
|
+
if (!uncacheable) {
|
|
672
|
+
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
673
|
+
}
|
|
660
674
|
}
|
|
661
675
|
return result;
|
|
662
676
|
}
|
|
@@ -676,6 +690,24 @@ async function quickVerify(config, credentials) {
|
|
|
676
690
|
};
|
|
677
691
|
}
|
|
678
692
|
|
|
693
|
+
// src/registration/errors.ts
|
|
694
|
+
var AstraSyncError = class extends Error {
|
|
695
|
+
constructor(message, statusCode, code) {
|
|
696
|
+
super(message);
|
|
697
|
+
this.name = "AstraSyncError";
|
|
698
|
+
this.statusCode = statusCode;
|
|
699
|
+
this.code = code;
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
var SettlementReportError = class extends AstraSyncError {
|
|
703
|
+
constructor(message, statusCode, code, issues) {
|
|
704
|
+
super(message, statusCode, code);
|
|
705
|
+
this.name = "SettlementReportError";
|
|
706
|
+
this.issues = issues;
|
|
707
|
+
this.retryable = statusCode === 0 || statusCode === 429 || statusCode >= 500;
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
|
|
679
711
|
// src/adapters/sdk.ts
|
|
680
712
|
var VerificationGatewayClient = class {
|
|
681
713
|
constructor(options) {
|
|
@@ -783,6 +815,7 @@ var VerificationGatewayClient = class {
|
|
|
783
815
|
commercePhase: "confirm",
|
|
784
816
|
checkoutSessionId: options.checkoutSessionId,
|
|
785
817
|
checkoutItems: options.checkoutItems,
|
|
818
|
+
...options.checkoutJwt && { checkoutJwt: options.checkoutJwt },
|
|
786
819
|
...options.attemptId && { attemptId: options.attemptId },
|
|
787
820
|
buyerEmail: options.buyerEmail,
|
|
788
821
|
counterpartyUrl: options.counterpartyUrl,
|
|
@@ -796,28 +829,52 @@ var VerificationGatewayClient = class {
|
|
|
796
829
|
);
|
|
797
830
|
}
|
|
798
831
|
/**
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
* /orders and the agent's poll surface reconcile.
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
*
|
|
832
|
+
* Report a settlement outcome back to the platform. 5.14.1: AstraSync never
|
|
833
|
+
* charges — EVERY merchant settles the orders it is handed (card token,
|
|
834
|
+
* stablecoin voucher, or a protocol-native credential) and reports here, so
|
|
835
|
+
* the buyer's dashboard, /orders and the agent's poll surface reconcile.
|
|
836
|
+
* Identify the order by the confirm's `sessionId` or the `orderId` from
|
|
837
|
+
* `settlementOutcome`. A settled card charge carries `processorRef` (pi_…);
|
|
838
|
+
* a settled stablecoin transfer carries `txHash` (+ `chainId`). Amounts must
|
|
839
|
+
* match the order EXACTLY (integer minor units) or the report is rejected
|
|
840
|
+
* whole (409 amount_mismatch). Replays of the same terminal state are safe.
|
|
806
841
|
*/
|
|
807
842
|
async reportSettlement(options) {
|
|
843
|
+
if (!options.sessionId && !options.orderId) {
|
|
844
|
+
throw new SettlementReportError(
|
|
845
|
+
"reportSettlement needs sessionId or orderId",
|
|
846
|
+
400,
|
|
847
|
+
"VALIDATION"
|
|
848
|
+
);
|
|
849
|
+
}
|
|
808
850
|
const base = this.config.apiBaseUrl.replace(/\/+$/, "");
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
851
|
+
let res;
|
|
852
|
+
try {
|
|
853
|
+
res = await sdkFetch(`${base}/merchant/settlements/report`, {
|
|
854
|
+
method: "POST",
|
|
855
|
+
headers: {
|
|
856
|
+
"Content-Type": "application/json",
|
|
857
|
+
// Same auth pair as every backend call the SDK makes (verify.ts).
|
|
858
|
+
...this.config.apiKey ? { Authorization: `Bearer ${this.config.apiKey}`, "X-API-Key": this.config.apiKey } : {}
|
|
859
|
+
},
|
|
860
|
+
body: JSON.stringify(options)
|
|
861
|
+
});
|
|
862
|
+
} catch (err) {
|
|
863
|
+
throw new SettlementReportError(
|
|
864
|
+
`reportSettlement failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
865
|
+
0,
|
|
866
|
+
"network_error"
|
|
867
|
+
);
|
|
868
|
+
}
|
|
818
869
|
const json = await res.json().catch(() => ({}));
|
|
819
870
|
if (!res.ok || !json.success || !json.data) {
|
|
820
|
-
|
|
871
|
+
const code = json.code ?? json.error ?? "unknown_error";
|
|
872
|
+
throw new SettlementReportError(
|
|
873
|
+
`reportSettlement failed (${res.status}): ${code}`,
|
|
874
|
+
res.status,
|
|
875
|
+
code,
|
|
876
|
+
json.issues
|
|
877
|
+
);
|
|
821
878
|
}
|
|
822
879
|
return json.data;
|
|
823
880
|
}
|