@astrasyncai/verification-gateway 5.18.1 → 5.19.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 +149 -0
- package/README.md +168 -4
- package/dist/adapters/express.d.mts +9 -1
- package/dist/adapters/express.d.ts +9 -1
- package/dist/adapters/express.js +96 -37
- package/dist/adapters/express.js.map +1 -1
- package/dist/adapters/express.mjs +96 -37
- 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 +80 -9
- package/dist/adapters/mcp.d.ts +80 -9
- package/dist/adapters/mcp.js +153 -5
- package/dist/adapters/mcp.js.map +1 -1
- package/dist/adapters/mcp.mjs +151 -5
- 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 +41 -4
- package/dist/adapters/nextjs.js.map +1 -1
- package/dist/adapters/nextjs.mjs +41 -4
- package/dist/adapters/nextjs.mjs.map +1 -1
- package/dist/adapters/sdk.d.mts +44 -1
- package/dist/adapters/sdk.d.ts +44 -1
- package/dist/adapters/sdk.js +76 -2
- package/dist/adapters/sdk.js.map +1 -1
- package/dist/adapters/sdk.mjs +76 -2
- 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 +46 -6
- package/dist/bin/astrasync-codex-hook.js +46 -6
- package/dist/bin/astrasync-guard.js +46 -6
- package/dist/bin/astrasync.js +77 -5
- package/dist/browser/background.js +46 -6
- package/dist/browser/background.js.map +1 -1
- package/dist/browser/background.mjs +46 -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 +46 -6
- package/dist/codex/index.js.map +1 -1
- package/dist/codex/index.mjs +46 -6
- package/dist/codex/index.mjs.map +1 -1
- package/dist/cursor/extension.js +46 -6
- package/dist/cursor/extension.js.map +1 -1
- package/dist/cursor/extension.mjs +46 -6
- 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 +21 -2
- package/dist/edge-core/index.js.map +1 -1
- package/dist/edge-core/index.mjs +21 -2
- package/dist/edge-core/index.mjs.map +1 -1
- package/dist/gateway/gateway.js +46 -6
- package/dist/gateway/gateway.js.map +1 -1
- package/dist/gateway/gateway.mjs +46 -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 +541 -29
- package/dist/index.d.ts +541 -29
- package/dist/index.js +1171 -183
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1157 -173
- package/dist/index.mjs.map +1 -1
- 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.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-3ObBpsnf.d.mts → types-BoGjyon0.d.mts} +81 -2
- package/dist/{types-Cns4l8gX.d.mts → types-DqWPkiYl.d.mts} +90 -12
- package/dist/{types-Cns4l8gX.d.ts → types-DqWPkiYl.d.ts} +90 -12
- package/dist/{types-BoxZEYPS.d.ts → types-eWyZuz-3.d.ts} +81 -2
- package/dist/ui/index.d.mts +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/verify.d.mts +23 -2
- package/dist/verify.d.ts +23 -2
- package/dist/verify.js +23 -4
- package/dist/verify.js.map +1 -1
- package/dist/verify.mjs +23 -4
- 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/adapters/sdk.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = "5.
|
|
2
|
+
var SDK_VERSION = "5.19.0";
|
|
3
3
|
|
|
4
4
|
// src/http.ts
|
|
5
5
|
var SDK_USER_AGENT = `astrasync-sdk/${SDK_VERSION}`;
|
|
@@ -177,7 +177,12 @@ function getCacheKey(request, counterpartyId) {
|
|
|
177
177
|
// its start_checkout quote was served the cached quote-leg grant (no
|
|
178
178
|
// settlementOutcome) and never reached the backend. Same F-A1-07 bug class.
|
|
179
179
|
request.commercePhase || "",
|
|
180
|
-
request.checkoutSessionId || ""
|
|
180
|
+
request.checkoutSessionId || "",
|
|
181
|
+
// 5.19.0: a route_config purpose claim is checked server-side against
|
|
182
|
+
// the stored rule for this method + path, so it changes the verdict.
|
|
183
|
+
request.purposeSource || "",
|
|
184
|
+
request.requestMethod || "",
|
|
185
|
+
request.requestPath || ""
|
|
181
186
|
].join("|");
|
|
182
187
|
}
|
|
183
188
|
function getCachedResult(request, counterpartyId) {
|
|
@@ -354,6 +359,11 @@ async function callVerifyAccessAPI(config, request) {
|
|
|
354
359
|
if (requestData.buyerEmail) body.buyerEmail = requestData.buyerEmail;
|
|
355
360
|
if (requestData.commerceArtifacts) body.commerceArtifacts = requestData.commerceArtifacts;
|
|
356
361
|
if (requestData.attemptId) body.attemptId = requestData.attemptId;
|
|
362
|
+
if (requestData.purposeSource) body.purposeSource = requestData.purposeSource;
|
|
363
|
+
if (requestData.agentArtifacts) body.agentArtifacts = requestData.agentArtifacts;
|
|
364
|
+
if (requestData.metadata) body.metadata = requestData.metadata;
|
|
365
|
+
if (requestData.requestMethod) body.requestMethod = requestData.requestMethod;
|
|
366
|
+
if (requestData.requestPath) body.requestPath = requestData.requestPath;
|
|
357
367
|
if (requestData.considerationSet) body.considerationSet = requestData.considerationSet;
|
|
358
368
|
body.sdkVersion = SDK_VERSION;
|
|
359
369
|
if (requestData.callerMetadata || requestData.clientIp || requestData.userAgent) {
|
|
@@ -543,9 +553,18 @@ async function verify(config, request, options) {
|
|
|
543
553
|
if (!apiResponse.access?.allowed) {
|
|
544
554
|
const aggregatedFailures = apiResponse.access?.failures;
|
|
545
555
|
const idVerifiedFromBackend = apiResponse.verificationContext?.idVerified === true && !aggregatedFailures?.some((f) => REJECTED_IDENTITY_DIMENSIONS.has(f.dimension));
|
|
556
|
+
const denyAgent = idVerifiedFromBackend && apiResponse.agent ? {
|
|
557
|
+
astraId: apiResponse.agent.astraId,
|
|
558
|
+
name: apiResponse.agent.name,
|
|
559
|
+
trustScore: apiResponse.agent.trustScore,
|
|
560
|
+
trustLevel: getTrustLevel(apiResponse.agent.trustScore),
|
|
561
|
+
blockchainAnchored: apiResponse.agent.blockchainStatus === "anchored",
|
|
562
|
+
status: apiResponse.agent.agentStatus
|
|
563
|
+
} : void 0;
|
|
546
564
|
const result2 = {
|
|
547
565
|
identityVerified: idVerifiedFromBackend,
|
|
548
566
|
policyAllowed: false,
|
|
567
|
+
...denyAgent && { agent: denyAgent },
|
|
549
568
|
// 3.6.0: the server now emits top-level denialReasons on every deny
|
|
550
569
|
// path — prefer it verbatim; the failure-message reconstruction remains
|
|
551
570
|
// as the fallback for older backends.
|
|
@@ -716,6 +735,7 @@ var SettlementReportError = class extends AstraSyncError {
|
|
|
716
735
|
};
|
|
717
736
|
|
|
718
737
|
// src/adapters/sdk.ts
|
|
738
|
+
var warnedPhaselessValue = false;
|
|
719
739
|
var VerificationGatewayClient = class {
|
|
720
740
|
constructor(options) {
|
|
721
741
|
this.config = {
|
|
@@ -747,9 +767,16 @@ var VerificationGatewayClient = class {
|
|
|
747
767
|
apiKey: options.apiKey,
|
|
748
768
|
jwt: options.jwt
|
|
749
769
|
};
|
|
770
|
+
if (options.transactionValue && !options.commercePhase && !warnedPhaselessValue) {
|
|
771
|
+
warnedPhaselessValue = true;
|
|
772
|
+
console.warn(
|
|
773
|
+
"[astrasync] verify() with a transactionValue and no commercePhase is a purchase leg: it records a pending order and redeems a matching owner approval. Use quoteCheckout() for a price / limit check (commercePhase 'quote') and confirmCheckout() for the purchase. The default becomes 'quote' in 6.0."
|
|
774
|
+
);
|
|
775
|
+
}
|
|
750
776
|
return this.executeWithRetry(
|
|
751
777
|
() => verify(this.config, {
|
|
752
778
|
credentials,
|
|
779
|
+
...options.commercePhase && { commercePhase: options.commercePhase },
|
|
753
780
|
purpose: options.purpose,
|
|
754
781
|
action: options.action,
|
|
755
782
|
resourceType: options.resourceType,
|
|
@@ -765,6 +792,43 @@ var VerificationGatewayClient = class {
|
|
|
765
792
|
})
|
|
766
793
|
);
|
|
767
794
|
}
|
|
795
|
+
/**
|
|
796
|
+
* 5.19.0: the QUOTE leg of a checkout — a price / limit check before the
|
|
797
|
+
* purchase. Sends `commercePhase: 'quote'`: verify-access evaluates the
|
|
798
|
+
* agent's policy at this value and tells you whether a purchase would be
|
|
799
|
+
* granted, held for the owner's approval, or denied, but records no order,
|
|
800
|
+
* moves no money and never redeems an approval. Always reaches the backend
|
|
801
|
+
* (no verdict cache).
|
|
802
|
+
*
|
|
803
|
+
* Quotes count toward limit-probing detection: a run of rising quotes is
|
|
804
|
+
* how an agent (or a merchant) maps a spending limit. Quote what the buyer
|
|
805
|
+
* asked for, not a ladder of values.
|
|
806
|
+
*/
|
|
807
|
+
async quoteCheckout(options) {
|
|
808
|
+
const credentials = {
|
|
809
|
+
astraId: options.astraId,
|
|
810
|
+
apiKey: options.apiKey,
|
|
811
|
+
jwt: options.jwt
|
|
812
|
+
};
|
|
813
|
+
return this.executeWithRetry(
|
|
814
|
+
() => verify(
|
|
815
|
+
this.config,
|
|
816
|
+
{
|
|
817
|
+
credentials,
|
|
818
|
+
purpose: options.purpose ?? "shopping",
|
|
819
|
+
action: options.action ?? "shopping.purchase",
|
|
820
|
+
transactionValue: options.transactionValue,
|
|
821
|
+
currency: options.currency,
|
|
822
|
+
commercePhase: "quote",
|
|
823
|
+
...options.checkoutSessionId && { checkoutSessionId: options.checkoutSessionId },
|
|
824
|
+
...options.attemptId && { attemptId: options.attemptId },
|
|
825
|
+
counterpartyUrl: options.counterpartyUrl,
|
|
826
|
+
counterpartyType: options.counterpartyType
|
|
827
|
+
},
|
|
828
|
+
{ bypassCache: true }
|
|
829
|
+
)
|
|
830
|
+
);
|
|
831
|
+
}
|
|
768
832
|
/**
|
|
769
833
|
* 5.4.0 (astra-pay): confirm-leg of a checkout — the ONLY call that may fire
|
|
770
834
|
* first-party charge-at-redeem (server-side settlement on the owner's saved
|
|
@@ -803,6 +867,14 @@ var VerificationGatewayClient = class {
|
|
|
803
867
|
* is matched to — and only to — this confirm. A held cart's approval is
|
|
804
868
|
* bound to its checkout session and exact value; a confirm for any other
|
|
805
869
|
* cart is held for its own approval.
|
|
870
|
+
*
|
|
871
|
+
* 5.19.0 checkout kits: pass the kit's `agentArtifacts` (the inbound agent
|
|
872
|
+
* request — signed RFC 9421 headers with the public URL and raw-body
|
|
873
|
+
* digest, or `{ unsigned: true }`) and `metadata` (`{ kitSessionId,
|
|
874
|
+
* protocol }`) from the `verifyPurchase` context. The platform attributes
|
|
875
|
+
* the confirm to the agent from the artifacts, and stores the metadata on
|
|
876
|
+
* any approval this confirm creates so the approval event
|
|
877
|
+
* (`handleApprovalEvents`) can find the kit session.
|
|
806
878
|
*/
|
|
807
879
|
async confirmCheckout(options) {
|
|
808
880
|
const credentials = {
|
|
@@ -825,6 +897,8 @@ var VerificationGatewayClient = class {
|
|
|
825
897
|
...options.checkoutJwt && { checkoutJwt: options.checkoutJwt },
|
|
826
898
|
...options.attemptId && { attemptId: options.attemptId },
|
|
827
899
|
buyerEmail: options.buyerEmail,
|
|
900
|
+
...options.agentArtifacts && { agentArtifacts: options.agentArtifacts },
|
|
901
|
+
...options.metadata && { metadata: options.metadata },
|
|
828
902
|
counterpartyUrl: options.counterpartyUrl,
|
|
829
903
|
counterpartyType: options.counterpartyType
|
|
830
904
|
},
|