@astrasyncai/verification-gateway 5.13.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 +504 -249
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +504 -249
- 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 +487 -248
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +487 -248
- 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 +82 -20
- package/dist/bin/astrasync-codex-hook.js +82 -20
- package/dist/bin/astrasync-guard.js +82 -20
- package/dist/bin/astrasync.js +316 -43
- package/dist/browser/background.js +77 -15
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +87 -15
- 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 +82 -20
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +92 -20
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +82 -20
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +92 -20
- 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 +43 -6
- package/dist/edge-core/index.d.ts +43 -6
- package/dist/edge-core/index.js +120 -19
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +118 -19
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/gateway/gateway.js +77 -15
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +87 -15
- 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 +5143 -2621
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5090 -2623
- 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.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TrustLevel, S as SDKOptions, d as VerificationResult, c as VerificationRequest } from '../types-
|
|
1
|
+
import { T as TrustLevel, S as SDKOptions, d as VerificationResult, c as VerificationRequest } from '../types-Dxf9DBpr.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* AstraSync Universal Verification Gateway — Trust Level helpers.
|
|
@@ -118,6 +118,8 @@ declare class VerificationGatewayClient {
|
|
|
118
118
|
currency?: string;
|
|
119
119
|
checkoutSessionId?: string;
|
|
120
120
|
checkoutItems?: VerificationRequest['checkoutItems'];
|
|
121
|
+
/** 5.15.0: your signed checkout (AP2 checkout_jwt) — returns `mandates` at AP2 merchants. */
|
|
122
|
+
checkoutJwt?: string;
|
|
121
123
|
/** 5.12.0: the `att_…` attempt-chain id from the bridge handoff body. */
|
|
122
124
|
attemptId?: string;
|
|
123
125
|
/** 5.6.0: alternate receipt/delivery email (transit-only) — omit to let
|
|
@@ -127,21 +129,27 @@ declare class VerificationGatewayClient {
|
|
|
127
129
|
counterpartyType?: string;
|
|
128
130
|
}): Promise<VerificationResult>;
|
|
129
131
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* /orders and the agent's poll surface reconcile.
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
132
|
+
* Report a settlement outcome back to the platform. 5.14.1: AstraSync never
|
|
133
|
+
* charges — EVERY merchant settles the orders it is handed (card token,
|
|
134
|
+
* stablecoin voucher, or a protocol-native credential) and reports here, so
|
|
135
|
+
* the buyer's dashboard, /orders and the agent's poll surface reconcile.
|
|
136
|
+
* Identify the order by the confirm's `sessionId` or the `orderId` from
|
|
137
|
+
* `settlementOutcome`. A settled card charge carries `processorRef` (pi_…);
|
|
138
|
+
* a settled stablecoin transfer carries `txHash` (+ `chainId`). Amounts must
|
|
139
|
+
* match the order EXACTLY (integer minor units) or the report is rejected
|
|
140
|
+
* whole (409 amount_mismatch). Replays of the same terminal state are safe.
|
|
137
141
|
*/
|
|
138
142
|
reportSettlement(options: {
|
|
139
|
-
sessionId
|
|
143
|
+
sessionId?: string;
|
|
144
|
+
orderId?: string;
|
|
140
145
|
status: 'settled' | 'declined' | 'failed';
|
|
141
146
|
amountMinor: number;
|
|
142
147
|
currency: string;
|
|
143
|
-
/** Stripe PaymentIntent id —
|
|
148
|
+
/** Stripe PaymentIntent id (card) — this or `txHash` is required when settled. */
|
|
144
149
|
processorRef?: string;
|
|
150
|
+
/** Stablecoin transfer transaction hash (0x…, 32 bytes). */
|
|
151
|
+
txHash?: string;
|
|
152
|
+
chainId?: number;
|
|
145
153
|
failureCode?: string;
|
|
146
154
|
}): Promise<{
|
|
147
155
|
orderId: string;
|
package/dist/adapters/sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TrustLevel, S as SDKOptions, d as VerificationResult, c as VerificationRequest } from '../types-
|
|
1
|
+
import { T as TrustLevel, S as SDKOptions, d as VerificationResult, c as VerificationRequest } from '../types-Dxf9DBpr.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* AstraSync Universal Verification Gateway — Trust Level helpers.
|
|
@@ -118,6 +118,8 @@ declare class VerificationGatewayClient {
|
|
|
118
118
|
currency?: string;
|
|
119
119
|
checkoutSessionId?: string;
|
|
120
120
|
checkoutItems?: VerificationRequest['checkoutItems'];
|
|
121
|
+
/** 5.15.0: your signed checkout (AP2 checkout_jwt) — returns `mandates` at AP2 merchants. */
|
|
122
|
+
checkoutJwt?: string;
|
|
121
123
|
/** 5.12.0: the `att_…` attempt-chain id from the bridge handoff body. */
|
|
122
124
|
attemptId?: string;
|
|
123
125
|
/** 5.6.0: alternate receipt/delivery email (transit-only) — omit to let
|
|
@@ -127,21 +129,27 @@ declare class VerificationGatewayClient {
|
|
|
127
129
|
counterpartyType?: string;
|
|
128
130
|
}): Promise<VerificationResult>;
|
|
129
131
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* /orders and the agent's poll surface reconcile.
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
132
|
+
* Report a settlement outcome back to the platform. 5.14.1: AstraSync never
|
|
133
|
+
* charges — EVERY merchant settles the orders it is handed (card token,
|
|
134
|
+
* stablecoin voucher, or a protocol-native credential) and reports here, so
|
|
135
|
+
* the buyer's dashboard, /orders and the agent's poll surface reconcile.
|
|
136
|
+
* Identify the order by the confirm's `sessionId` or the `orderId` from
|
|
137
|
+
* `settlementOutcome`. A settled card charge carries `processorRef` (pi_…);
|
|
138
|
+
* a settled stablecoin transfer carries `txHash` (+ `chainId`). Amounts must
|
|
139
|
+
* match the order EXACTLY (integer minor units) or the report is rejected
|
|
140
|
+
* whole (409 amount_mismatch). Replays of the same terminal state are safe.
|
|
137
141
|
*/
|
|
138
142
|
reportSettlement(options: {
|
|
139
|
-
sessionId
|
|
143
|
+
sessionId?: string;
|
|
144
|
+
orderId?: string;
|
|
140
145
|
status: 'settled' | 'declined' | 'failed';
|
|
141
146
|
amountMinor: number;
|
|
142
147
|
currency: string;
|
|
143
|
-
/** Stripe PaymentIntent id —
|
|
148
|
+
/** Stripe PaymentIntent id (card) — this or `txHash` is required when settled. */
|
|
144
149
|
processorRef?: string;
|
|
150
|
+
/** Stablecoin transfer transaction hash (0x…, 32 bytes). */
|
|
151
|
+
txHash?: string;
|
|
152
|
+
chainId?: number;
|
|
145
153
|
failureCode?: string;
|
|
146
154
|
}): Promise<{
|
|
147
155
|
orderId: string;
|
package/dist/adapters/sdk.js
CHANGED
|
@@ -28,7 +28,7 @@ __export(sdk_exports, {
|
|
|
28
28
|
module.exports = __toCommonJS(sdk_exports);
|
|
29
29
|
|
|
30
30
|
// src/version.ts
|
|
31
|
-
var SDK_VERSION = "5.
|
|
31
|
+
var SDK_VERSION = "5.15.0";
|
|
32
32
|
|
|
33
33
|
// src/http.ts
|
|
34
34
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -373,6 +373,7 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
373
373
|
if (requestData.invocationProtocol) body.invocationProtocol = requestData.invocationProtocol;
|
|
374
374
|
if (requestData.commercePhase) body.commercePhase = requestData.commercePhase;
|
|
375
375
|
if (requestData.checkoutSessionId) body.checkoutSessionId = requestData.checkoutSessionId;
|
|
376
|
+
if (requestData.checkoutJwt) body.checkoutJwt = requestData.checkoutJwt;
|
|
376
377
|
if (requestData.checkoutItems) body.checkoutItems = requestData.checkoutItems;
|
|
377
378
|
if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
|
|
378
379
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
@@ -523,7 +524,8 @@ async function verify(config, request, options) {
|
|
|
523
524
|
"[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."
|
|
524
525
|
);
|
|
525
526
|
}
|
|
526
|
-
|
|
527
|
+
const uncacheable = Boolean(request.commerceArtifacts);
|
|
528
|
+
if (mergedConfig.cacheTtl !== 0 && !options?.bypassCache && !uncacheable) {
|
|
527
529
|
const cached = getCachedResult(request, mergedConfig.counterpartyId);
|
|
528
530
|
if (cached) {
|
|
529
531
|
if (mergedConfig.debug) {
|
|
@@ -604,7 +606,10 @@ async function verify(config, request, options) {
|
|
|
604
606
|
// MERCHANT caller only (bridge callers strip it before the agent plane).
|
|
605
607
|
settlementToken: apiResponse.settlementToken,
|
|
606
608
|
// 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
|
|
607
|
-
fulfilment: apiResponse.fulfilment
|
|
609
|
+
fulfilment: apiResponse.fulfilment,
|
|
610
|
+
mandates: apiResponse.mandates,
|
|
611
|
+
kyaToken: apiResponse.kyaToken,
|
|
612
|
+
aep: apiResponse.aep
|
|
608
613
|
};
|
|
609
614
|
return result2;
|
|
610
615
|
}
|
|
@@ -614,7 +619,10 @@ async function verify(config, request, options) {
|
|
|
614
619
|
trustScore: apiResponse.agent.trustScore,
|
|
615
620
|
trustLevel: getTrustLevel(apiResponse.agent.trustScore),
|
|
616
621
|
blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
|
|
617
|
-
status: apiResponse.agent.agentStatus
|
|
622
|
+
status: apiResponse.agent.agentStatus,
|
|
623
|
+
...apiResponse.agent.protocolIdentities && {
|
|
624
|
+
protocolIdentities: apiResponse.agent.protocolIdentities
|
|
625
|
+
}
|
|
618
626
|
} : void 0;
|
|
619
627
|
const developer = apiResponse.developer ? {
|
|
620
628
|
astradId: apiResponse.developer.kyaOwnerId,
|
|
@@ -665,7 +673,11 @@ async function verify(config, request, options) {
|
|
|
665
673
|
settlementOutcome: apiResponse.settlementOutcome,
|
|
666
674
|
settlementToken: apiResponse.settlementToken,
|
|
667
675
|
// 5.6.0: fulfilment contact — merchant-only lane, same strip rule.
|
|
668
|
-
fulfilment: apiResponse.fulfilment
|
|
676
|
+
fulfilment: apiResponse.fulfilment,
|
|
677
|
+
// 5.15.0: merchant-lane AP2 mandates + KYAPay identity token.
|
|
678
|
+
mandates: apiResponse.mandates,
|
|
679
|
+
kyaToken: apiResponse.kyaToken,
|
|
680
|
+
aep: apiResponse.aep
|
|
669
681
|
};
|
|
670
682
|
if (result.recommendation === "deny") {
|
|
671
683
|
result.policyAllowed = false;
|
|
@@ -685,7 +697,9 @@ async function verify(config, request, options) {
|
|
|
685
697
|
}
|
|
686
698
|
const escalates = result.requiresStepUp === true || result.requiresApproval === true || result.recommendation === "step_up_required";
|
|
687
699
|
if (mergedConfig.cacheTtl !== 0 && result.recommendation !== "deny" && !escalates) {
|
|
688
|
-
|
|
700
|
+
if (!uncacheable) {
|
|
701
|
+
cacheResult(request, result, mergedConfig.cacheTtl, mergedConfig.counterpartyId);
|
|
702
|
+
}
|
|
689
703
|
}
|
|
690
704
|
return result;
|
|
691
705
|
}
|
|
@@ -705,6 +719,24 @@ async function quickVerify(config, credentials) {
|
|
|
705
719
|
};
|
|
706
720
|
}
|
|
707
721
|
|
|
722
|
+
// src/registration/errors.ts
|
|
723
|
+
var AstraSyncError = class extends Error {
|
|
724
|
+
constructor(message, statusCode, code) {
|
|
725
|
+
super(message);
|
|
726
|
+
this.name = "AstraSyncError";
|
|
727
|
+
this.statusCode = statusCode;
|
|
728
|
+
this.code = code;
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
var SettlementReportError = class extends AstraSyncError {
|
|
732
|
+
constructor(message, statusCode, code, issues) {
|
|
733
|
+
super(message, statusCode, code);
|
|
734
|
+
this.name = "SettlementReportError";
|
|
735
|
+
this.issues = issues;
|
|
736
|
+
this.retryable = statusCode === 0 || statusCode === 429 || statusCode >= 500;
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
|
|
708
740
|
// src/adapters/sdk.ts
|
|
709
741
|
var VerificationGatewayClient = class {
|
|
710
742
|
constructor(options) {
|
|
@@ -812,6 +844,7 @@ var VerificationGatewayClient = class {
|
|
|
812
844
|
commercePhase: "confirm",
|
|
813
845
|
checkoutSessionId: options.checkoutSessionId,
|
|
814
846
|
checkoutItems: options.checkoutItems,
|
|
847
|
+
...options.checkoutJwt && { checkoutJwt: options.checkoutJwt },
|
|
815
848
|
...options.attemptId && { attemptId: options.attemptId },
|
|
816
849
|
buyerEmail: options.buyerEmail,
|
|
817
850
|
counterpartyUrl: options.counterpartyUrl,
|
|
@@ -825,28 +858,52 @@ var VerificationGatewayClient = class {
|
|
|
825
858
|
);
|
|
826
859
|
}
|
|
827
860
|
/**
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
*
|
|
831
|
-
* /orders and the agent's poll surface reconcile.
|
|
832
|
-
*
|
|
833
|
-
*
|
|
834
|
-
*
|
|
861
|
+
* Report a settlement outcome back to the platform. 5.14.1: AstraSync never
|
|
862
|
+
* charges — EVERY merchant settles the orders it is handed (card token,
|
|
863
|
+
* stablecoin voucher, or a protocol-native credential) and reports here, so
|
|
864
|
+
* the buyer's dashboard, /orders and the agent's poll surface reconcile.
|
|
865
|
+
* Identify the order by the confirm's `sessionId` or the `orderId` from
|
|
866
|
+
* `settlementOutcome`. A settled card charge carries `processorRef` (pi_…);
|
|
867
|
+
* a settled stablecoin transfer carries `txHash` (+ `chainId`). Amounts must
|
|
868
|
+
* match the order EXACTLY (integer minor units) or the report is rejected
|
|
869
|
+
* whole (409 amount_mismatch). Replays of the same terminal state are safe.
|
|
835
870
|
*/
|
|
836
871
|
async reportSettlement(options) {
|
|
872
|
+
if (!options.sessionId && !options.orderId) {
|
|
873
|
+
throw new SettlementReportError(
|
|
874
|
+
"reportSettlement needs sessionId or orderId",
|
|
875
|
+
400,
|
|
876
|
+
"VALIDATION"
|
|
877
|
+
);
|
|
878
|
+
}
|
|
837
879
|
const base = this.config.apiBaseUrl.replace(/\/+$/, "");
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
880
|
+
let res;
|
|
881
|
+
try {
|
|
882
|
+
res = await sdkFetch(`${base}/merchant/settlements/report`, {
|
|
883
|
+
method: "POST",
|
|
884
|
+
headers: {
|
|
885
|
+
"Content-Type": "application/json",
|
|
886
|
+
// Same auth pair as every backend call the SDK makes (verify.ts).
|
|
887
|
+
...this.config.apiKey ? { Authorization: `Bearer ${this.config.apiKey}`, "X-API-Key": this.config.apiKey } : {}
|
|
888
|
+
},
|
|
889
|
+
body: JSON.stringify(options)
|
|
890
|
+
});
|
|
891
|
+
} catch (err) {
|
|
892
|
+
throw new SettlementReportError(
|
|
893
|
+
`reportSettlement failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
894
|
+
0,
|
|
895
|
+
"network_error"
|
|
896
|
+
);
|
|
897
|
+
}
|
|
847
898
|
const json = await res.json().catch(() => ({}));
|
|
848
899
|
if (!res.ok || !json.success || !json.data) {
|
|
849
|
-
|
|
900
|
+
const code = json.code ?? json.error ?? "unknown_error";
|
|
901
|
+
throw new SettlementReportError(
|
|
902
|
+
`reportSettlement failed (${res.status}): ${code}`,
|
|
903
|
+
res.status,
|
|
904
|
+
code,
|
|
905
|
+
json.issues
|
|
906
|
+
);
|
|
850
907
|
}
|
|
851
908
|
return json.data;
|
|
852
909
|
}
|