@agent-score/commerce 2.7.6 → 2.7.7
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/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/identity/express.js +1 -1
- package/dist/identity/express.mjs +1 -1
- package/dist/identity/fastify.js +1 -1
- package/dist/identity/fastify.mjs +1 -1
- package/dist/identity/hono.js +1 -1
- package/dist/identity/hono.mjs +1 -1
- package/dist/identity/nextjs.js +1 -1
- package/dist/identity/nextjs.mjs +1 -1
- package/dist/identity/web.js +1 -1
- package/dist/identity/web.mjs +1 -1
- package/dist/index.js +177 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +177 -63
- package/dist/index.mjs.map +1 -1
- package/dist/stripe-multichain/index.js +173 -59
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs +173 -59
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/package.json +9 -8
package/dist/core.js
CHANGED
|
@@ -227,7 +227,7 @@ function createAgentScoreCore(options) {
|
|
|
227
227
|
} = options;
|
|
228
228
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
229
229
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
230
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
230
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
231
231
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
232
232
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
233
233
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/core.mjs
CHANGED
|
@@ -209,7 +209,7 @@ function createAgentScoreCore(options) {
|
|
|
209
209
|
} = options;
|
|
210
210
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
211
211
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
212
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
212
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
213
213
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
214
214
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
215
215
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/express.js
CHANGED
|
@@ -920,7 +920,7 @@ function createAgentScoreCore(options) {
|
|
|
920
920
|
} = options;
|
|
921
921
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
922
922
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
923
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
923
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
924
924
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
925
925
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
926
926
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
|
@@ -892,7 +892,7 @@ function createAgentScoreCore(options) {
|
|
|
892
892
|
} = options;
|
|
893
893
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
894
894
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
895
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
895
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
896
896
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
897
897
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
898
898
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/fastify.js
CHANGED
|
@@ -921,7 +921,7 @@ function createAgentScoreCore(options) {
|
|
|
921
921
|
} = options;
|
|
922
922
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
923
923
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
924
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
924
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
925
925
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
926
926
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
927
927
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
|
@@ -892,7 +892,7 @@ function createAgentScoreCore(options) {
|
|
|
892
892
|
} = options;
|
|
893
893
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
894
894
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
895
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
895
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
896
896
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
897
897
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
898
898
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/hono.js
CHANGED
|
@@ -901,7 +901,7 @@ function createAgentScoreCore(options) {
|
|
|
901
901
|
} = options;
|
|
902
902
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
903
903
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
904
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
904
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
905
905
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
906
906
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
907
907
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/hono.mjs
CHANGED
|
@@ -873,7 +873,7 @@ function createAgentScoreCore(options) {
|
|
|
873
873
|
} = options;
|
|
874
874
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
875
875
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
876
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
876
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
877
877
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
878
878
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
879
879
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/nextjs.js
CHANGED
|
@@ -922,7 +922,7 @@ function createAgentScoreCore(options) {
|
|
|
922
922
|
} = options;
|
|
923
923
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
924
924
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
925
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
925
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
926
926
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
927
927
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
928
928
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/nextjs.mjs
CHANGED
|
@@ -897,7 +897,7 @@ function createAgentScoreCore(options) {
|
|
|
897
897
|
} = options;
|
|
898
898
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
899
899
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
900
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
900
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
901
901
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
902
902
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
903
903
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/web.js
CHANGED
|
@@ -898,7 +898,7 @@ function createAgentScoreCore(options) {
|
|
|
898
898
|
} = options;
|
|
899
899
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
900
900
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
901
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
901
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
902
902
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
903
903
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
904
904
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/identity/web.mjs
CHANGED
|
@@ -873,7 +873,7 @@ function createAgentScoreCore(options) {
|
|
|
873
873
|
} = options;
|
|
874
874
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
875
875
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
876
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
876
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
877
877
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
878
878
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
879
879
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
package/dist/index.js
CHANGED
|
@@ -24,11 +24,11 @@ var __export = (target, all) => {
|
|
|
24
24
|
for (var name in all)
|
|
25
25
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
26
|
};
|
|
27
|
-
var __copyProps = (to,
|
|
28
|
-
if (
|
|
29
|
-
for (let key of __getOwnPropNames(
|
|
27
|
+
var __copyProps = (to, from10, except, desc) => {
|
|
28
|
+
if (from10 && typeof from10 === "object" || typeof from10 === "function") {
|
|
29
|
+
for (let key of __getOwnPropNames(from10))
|
|
30
30
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
-
__defProp(to, key, { get: () =>
|
|
31
|
+
__defProp(to, key, { get: () => from10[key], enumerable: !(desc = __getOwnPropDesc(from10, key)) || desc.enumerable });
|
|
32
32
|
}
|
|
33
33
|
return to;
|
|
34
34
|
};
|
|
@@ -19871,10 +19871,16 @@ var init_Errors2 = __esm({
|
|
|
19871
19871
|
methodUnsupported: "Use a supported wallet to pay for this resource using one of the supported payment methods returned in the WWW-Authenticate header. See https://mpp.dev/tools/wallet.md"
|
|
19872
19872
|
};
|
|
19873
19873
|
PaymentError = class extends Error {
|
|
19874
|
+
/** Safe method-specific context for diagnostics and relay responses. */
|
|
19875
|
+
details;
|
|
19874
19876
|
/** HTTP status code. */
|
|
19875
19877
|
status = 402;
|
|
19876
19878
|
/** Actionable hint for resolving the error (RFC 9457 extension member). */
|
|
19877
19879
|
hint;
|
|
19880
|
+
constructor(message, options = {}) {
|
|
19881
|
+
super(message);
|
|
19882
|
+
this.details = options.details;
|
|
19883
|
+
}
|
|
19878
19884
|
/** Converts the error to RFC 9457 Problem Details format. */
|
|
19879
19885
|
toProblemDetails(challengeId) {
|
|
19880
19886
|
return {
|
|
@@ -19882,6 +19888,7 @@ var init_Errors2 = __esm({
|
|
|
19882
19888
|
title: this.title,
|
|
19883
19889
|
status: this.status,
|
|
19884
19890
|
detail: this.message,
|
|
19891
|
+
...this.details && Object.keys(this.details).length > 0 && { details: this.details },
|
|
19885
19892
|
...this.hint && { hint: this.hint },
|
|
19886
19893
|
...challengeId && { challengeId }
|
|
19887
19894
|
};
|
|
@@ -19915,8 +19922,10 @@ var init_Errors2 = __esm({
|
|
|
19915
19922
|
title = "Verification Failed";
|
|
19916
19923
|
type = "https://paymentauth.org/problems/verification-failed";
|
|
19917
19924
|
constructor(options = {}) {
|
|
19918
|
-
const { reason } = options;
|
|
19919
|
-
super(reason ? `Payment verification failed: ${reason}.` : "Payment verification failed."
|
|
19925
|
+
const { details, reason } = options;
|
|
19926
|
+
super(reason ? `Payment verification failed: ${reason}.` : "Payment verification failed.", {
|
|
19927
|
+
details
|
|
19928
|
+
});
|
|
19920
19929
|
}
|
|
19921
19930
|
};
|
|
19922
19931
|
PaymentActionRequiredError = class extends PaymentError {
|
|
@@ -20148,7 +20157,7 @@ var version3;
|
|
|
20148
20157
|
var init_version2 = __esm({
|
|
20149
20158
|
"node_modules/viem/_esm/errors/version.js"() {
|
|
20150
20159
|
"use strict";
|
|
20151
|
-
version3 = "2.55.
|
|
20160
|
+
version3 = "2.55.8";
|
|
20152
20161
|
}
|
|
20153
20162
|
});
|
|
20154
20163
|
|
|
@@ -20633,60 +20642,93 @@ var init_isAddress = __esm({
|
|
|
20633
20642
|
}
|
|
20634
20643
|
});
|
|
20635
20644
|
|
|
20636
|
-
// node_modules/viem/_esm/
|
|
20637
|
-
|
|
20638
|
-
|
|
20639
|
-
|
|
20640
|
-
|
|
20641
|
-
init_base();
|
|
20642
|
-
InvalidDecimalNumberError = class extends BaseError3 {
|
|
20643
|
-
constructor({ value }) {
|
|
20644
|
-
super(`Number \`${value}\` is not a valid decimal number.`, {
|
|
20645
|
-
name: "InvalidDecimalNumberError"
|
|
20646
|
-
});
|
|
20647
|
-
}
|
|
20648
|
-
};
|
|
20649
|
-
}
|
|
20650
|
-
});
|
|
20651
|
-
|
|
20652
|
-
// node_modules/viem/_esm/utils/unit/parseUnits.js
|
|
20653
|
-
function parseUnits(value, decimals) {
|
|
20654
|
-
if (!/^(-?)([0-9]*)\.?([0-9]*)$/.test(value))
|
|
20645
|
+
// node_modules/viem/_esm/utils/unit/Value.js
|
|
20646
|
+
function from6(value, decimals = 0) {
|
|
20647
|
+
if (!Number.isInteger(decimals) || decimals < 0)
|
|
20648
|
+
throw new InvalidDecimalsError({ decimals });
|
|
20649
|
+
if (!/^-?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)$/.test(value))
|
|
20655
20650
|
throw new InvalidDecimalNumberError({ value });
|
|
20656
|
-
let [integer2, fraction = "0"] = value.split(".");
|
|
20651
|
+
let [integer2 = "", fraction = "0"] = value.split(".");
|
|
20657
20652
|
const negative = integer2.startsWith("-");
|
|
20658
20653
|
if (negative)
|
|
20659
20654
|
integer2 = integer2.slice(1);
|
|
20655
|
+
if (integer2 === "")
|
|
20656
|
+
integer2 = "0";
|
|
20660
20657
|
fraction = fraction.replace(/(0+)$/, "");
|
|
20661
20658
|
if (decimals === 0) {
|
|
20662
|
-
if (
|
|
20659
|
+
if (fraction.length > 0 && Number.parseInt(fraction[0], 10) >= 5)
|
|
20663
20660
|
integer2 = `${BigInt(integer2) + 1n}`;
|
|
20664
20661
|
fraction = "";
|
|
20665
20662
|
} else if (fraction.length > decimals) {
|
|
20666
|
-
const
|
|
20667
|
-
|
|
20668
|
-
|
|
20669
|
-
|
|
20670
|
-
|
|
20671
|
-
|
|
20672
|
-
|
|
20673
|
-
|
|
20674
|
-
|
|
20675
|
-
|
|
20676
|
-
|
|
20677
|
-
fraction =
|
|
20678
|
-
integer2 = `${BigInt(integer2) + 1n}`;
|
|
20663
|
+
const left = fraction.slice(0, decimals);
|
|
20664
|
+
const roundDigit = Number.parseInt(fraction.slice(decimals, decimals + 1), 10);
|
|
20665
|
+
if (roundDigit >= 5) {
|
|
20666
|
+
const carried = carry(left);
|
|
20667
|
+
if (carried.length > decimals) {
|
|
20668
|
+
fraction = carried.slice(1);
|
|
20669
|
+
integer2 = `${BigInt(integer2) + 1n}`;
|
|
20670
|
+
} else {
|
|
20671
|
+
fraction = carried;
|
|
20672
|
+
}
|
|
20673
|
+
} else {
|
|
20674
|
+
fraction = left;
|
|
20679
20675
|
}
|
|
20680
|
-
fraction = fraction.slice(0, decimals);
|
|
20681
20676
|
} else {
|
|
20682
20677
|
fraction = fraction.padEnd(decimals, "0");
|
|
20683
20678
|
}
|
|
20684
20679
|
return BigInt(`${negative ? "-" : ""}${integer2}${fraction}`);
|
|
20685
20680
|
}
|
|
20681
|
+
function carry(digits) {
|
|
20682
|
+
const out = digits.split("");
|
|
20683
|
+
let i = out.length - 1;
|
|
20684
|
+
while (i >= 0) {
|
|
20685
|
+
const d = Number.parseInt(out[i], 10) + 1;
|
|
20686
|
+
if (d < 10) {
|
|
20687
|
+
out[i] = String(d);
|
|
20688
|
+
return out.join("");
|
|
20689
|
+
}
|
|
20690
|
+
out[i] = "0";
|
|
20691
|
+
i--;
|
|
20692
|
+
}
|
|
20693
|
+
return `1${out.join("")}`;
|
|
20694
|
+
}
|
|
20695
|
+
var InvalidDecimalNumberError, InvalidDecimalsError;
|
|
20696
|
+
var init_Value2 = __esm({
|
|
20697
|
+
"node_modules/viem/_esm/utils/unit/Value.js"() {
|
|
20698
|
+
"use strict";
|
|
20699
|
+
InvalidDecimalNumberError = class extends Error {
|
|
20700
|
+
constructor({ value }) {
|
|
20701
|
+
super(`Value \`${value}\` is not a valid decimal number.`);
|
|
20702
|
+
Object.defineProperty(this, "name", {
|
|
20703
|
+
enumerable: true,
|
|
20704
|
+
configurable: true,
|
|
20705
|
+
writable: true,
|
|
20706
|
+
value: "Value.InvalidDecimalNumberError"
|
|
20707
|
+
});
|
|
20708
|
+
}
|
|
20709
|
+
};
|
|
20710
|
+
InvalidDecimalsError = class extends Error {
|
|
20711
|
+
constructor({ decimals }) {
|
|
20712
|
+
super(`\`decimals\` must be a non-negative integer. Got \`${decimals}\`.`);
|
|
20713
|
+
Object.defineProperty(this, "name", {
|
|
20714
|
+
enumerable: true,
|
|
20715
|
+
configurable: true,
|
|
20716
|
+
writable: true,
|
|
20717
|
+
value: "Value.InvalidDecimalsError"
|
|
20718
|
+
});
|
|
20719
|
+
}
|
|
20720
|
+
};
|
|
20721
|
+
}
|
|
20722
|
+
});
|
|
20723
|
+
|
|
20724
|
+
// node_modules/viem/_esm/utils/unit/parseUnits.js
|
|
20725
|
+
function parseUnits(value, decimals) {
|
|
20726
|
+
return from6(value, decimals);
|
|
20727
|
+
}
|
|
20686
20728
|
var init_parseUnits = __esm({
|
|
20687
20729
|
"node_modules/viem/_esm/utils/unit/parseUnits.js"() {
|
|
20688
20730
|
"use strict";
|
|
20689
|
-
|
|
20731
|
+
init_Value2();
|
|
20690
20732
|
}
|
|
20691
20733
|
});
|
|
20692
20734
|
|
|
@@ -20910,13 +20952,70 @@ var init_Chains = __esm({
|
|
|
20910
20952
|
// node_modules/mppx/dist/Method.js
|
|
20911
20953
|
var Method_exports = {};
|
|
20912
20954
|
__export(Method_exports, {
|
|
20913
|
-
|
|
20955
|
+
broadcastCredential: () => broadcastCredential,
|
|
20956
|
+
from: () => from7,
|
|
20957
|
+
selectServerMethod: () => selectServerMethod,
|
|
20914
20958
|
toClient: () => toClient,
|
|
20915
|
-
toServer: () => toServer
|
|
20959
|
+
toServer: () => toServer,
|
|
20960
|
+
validateCredential: () => validateCredential
|
|
20916
20961
|
});
|
|
20917
|
-
function
|
|
20962
|
+
function from7(method) {
|
|
20918
20963
|
return method;
|
|
20919
20964
|
}
|
|
20965
|
+
async function validateCredential(methods, input) {
|
|
20966
|
+
const prepared = prepareCredential(methods, input);
|
|
20967
|
+
if (!prepared.method.validate)
|
|
20968
|
+
throw new VerificationFailedError({
|
|
20969
|
+
details: { intent: prepared.method.intent, method: prepared.method.name },
|
|
20970
|
+
reason: `${prepared.method.name}/${prepared.method.intent} does not support non-mutating credential validation`
|
|
20971
|
+
});
|
|
20972
|
+
return prepared.method.validate({
|
|
20973
|
+
credential: prepared.credential,
|
|
20974
|
+
request: prepared.request
|
|
20975
|
+
});
|
|
20976
|
+
}
|
|
20977
|
+
async function broadcastCredential(methods, input) {
|
|
20978
|
+
const prepared = prepareCredential(methods, input);
|
|
20979
|
+
const { method } = prepared;
|
|
20980
|
+
if (method.broadcast && method.validate)
|
|
20981
|
+
await method.validate({ credential: prepared.credential, request: prepared.request });
|
|
20982
|
+
const broadcast = method.broadcast ?? method.verify;
|
|
20983
|
+
return broadcast({ credential: prepared.credential, request: prepared.request });
|
|
20984
|
+
}
|
|
20985
|
+
function prepareCredential(methods, input) {
|
|
20986
|
+
const credential = typeof input === "string" ? deserialize3(input) : input;
|
|
20987
|
+
const candidates = methods.filter((method2) => method2.name === credential.challenge.method && method2.intent === credential.challenge.intent);
|
|
20988
|
+
const method = selectServerMethod(candidates, credential.challenge);
|
|
20989
|
+
if (!method)
|
|
20990
|
+
throw new InvalidChallengeError({
|
|
20991
|
+
id: credential.challenge.id,
|
|
20992
|
+
reason: `no registered method for ${credential.challenge.method}/${credential.challenge.intent}`
|
|
20993
|
+
});
|
|
20994
|
+
assert5(credential.challenge.expires, credential.challenge.id);
|
|
20995
|
+
let payload;
|
|
20996
|
+
try {
|
|
20997
|
+
payload = method.schema.credential.payload.parse(credential.payload);
|
|
20998
|
+
} catch (error51) {
|
|
20999
|
+
throw new InvalidPayloadError(error51 instanceof Error ? { reason: error51.message } : {});
|
|
21000
|
+
}
|
|
21001
|
+
return {
|
|
21002
|
+
credential: { ...credential, payload },
|
|
21003
|
+
method,
|
|
21004
|
+
request: credential.challenge.request
|
|
21005
|
+
};
|
|
21006
|
+
}
|
|
21007
|
+
function selectServerMethod(methods, challenge) {
|
|
21008
|
+
if (methods.length <= 1)
|
|
21009
|
+
return methods[0];
|
|
21010
|
+
if (challenge.method !== Methods.tempo || challenge.intent !== Intents.session)
|
|
21011
|
+
return methods[0];
|
|
21012
|
+
const sessionProtocol = getMethodDetail(challenge.request.methodDetails, MethodDetailKeys.sessionProtocol);
|
|
21013
|
+
if (sessionProtocol === void 0 || sessionProtocol === SessionProtocols.v1)
|
|
21014
|
+
return methods.find((method) => method.alias === "sessionLegacy") ?? methods[0];
|
|
21015
|
+
if (sessionProtocol === SessionProtocols.v2)
|
|
21016
|
+
return methods.find((method) => method.alias === void 0) ?? methods[0];
|
|
21017
|
+
return void 0;
|
|
21018
|
+
}
|
|
20920
21019
|
function toClient(method, options) {
|
|
20921
21020
|
const { canHandleChallenge, context, createCredential } = options;
|
|
20922
21021
|
return {
|
|
@@ -20927,7 +21026,16 @@ function toClient(method, options) {
|
|
|
20927
21026
|
};
|
|
20928
21027
|
}
|
|
20929
21028
|
function toServer(method, options) {
|
|
20930
|
-
const { alias, authorize, defaults, extensions, html, preflight, request, respond, stableBinding, transport, verify: verify3 } = options;
|
|
21029
|
+
const { alias, authorize, defaults, extensions, html, preflight, request, respond, broadcast, stableBinding, transport, validate: validate4, verify: verify3 } = options;
|
|
21030
|
+
const effectiveVerify = verify3 ?? (async (parameters) => {
|
|
21031
|
+
if (validate4)
|
|
21032
|
+
await validate4(parameters);
|
|
21033
|
+
if (!broadcast)
|
|
21034
|
+
throw new VerificationFailedError({
|
|
21035
|
+
reason: `${method.name}/${method.intent} does not support credential broadcast`
|
|
21036
|
+
});
|
|
21037
|
+
return broadcast(parameters);
|
|
21038
|
+
});
|
|
20931
21039
|
return {
|
|
20932
21040
|
...method,
|
|
20933
21041
|
alias,
|
|
@@ -20938,14 +21046,20 @@ function toServer(method, options) {
|
|
|
20938
21046
|
preflight,
|
|
20939
21047
|
request,
|
|
20940
21048
|
respond,
|
|
21049
|
+
broadcast,
|
|
20941
21050
|
stableBinding,
|
|
20942
21051
|
transport,
|
|
20943
|
-
|
|
21052
|
+
validate: validate4,
|
|
21053
|
+
verify: effectiveVerify
|
|
20944
21054
|
};
|
|
20945
21055
|
}
|
|
20946
21056
|
var init_Method = __esm({
|
|
20947
21057
|
"node_modules/mppx/dist/Method.js"() {
|
|
20948
21058
|
"use strict";
|
|
21059
|
+
init_Constants();
|
|
21060
|
+
init_Credential();
|
|
21061
|
+
init_Errors2();
|
|
21062
|
+
init_Expires();
|
|
20949
21063
|
}
|
|
20950
21064
|
});
|
|
20951
21065
|
|
|
@@ -21074,7 +21188,7 @@ var init_Methods = __esm({
|
|
|
21074
21188
|
init_Method();
|
|
21075
21189
|
init_zod();
|
|
21076
21190
|
init_Types();
|
|
21077
|
-
charge =
|
|
21191
|
+
charge = from7({
|
|
21078
21192
|
name: paymentMethod,
|
|
21079
21193
|
intent: chargeIntent,
|
|
21080
21194
|
schema: {
|
|
@@ -21166,15 +21280,15 @@ var Receipt_exports = {};
|
|
|
21166
21280
|
__export(Receipt_exports, {
|
|
21167
21281
|
Schema: () => Schema2,
|
|
21168
21282
|
deserialize: () => deserialize4,
|
|
21169
|
-
from: () =>
|
|
21283
|
+
from: () => from8,
|
|
21170
21284
|
fromResponse: () => fromResponse2,
|
|
21171
21285
|
serialize: () => serialize4
|
|
21172
21286
|
});
|
|
21173
21287
|
function deserialize4(encoded) {
|
|
21174
21288
|
const json2 = Base64_exports.toString(encoded);
|
|
21175
|
-
return
|
|
21289
|
+
return from8(JSON.parse(json2));
|
|
21176
21290
|
}
|
|
21177
|
-
function
|
|
21291
|
+
function from8(parameters) {
|
|
21178
21292
|
return Schema2.parse(parameters);
|
|
21179
21293
|
}
|
|
21180
21294
|
function serialize4(receipt) {
|
|
@@ -21217,12 +21331,12 @@ var init_Receipt = __esm({
|
|
|
21217
21331
|
var Store_exports = {};
|
|
21218
21332
|
__export(Store_exports, {
|
|
21219
21333
|
cloudflare: () => cloudflare,
|
|
21220
|
-
from: () =>
|
|
21334
|
+
from: () => from9,
|
|
21221
21335
|
memory: () => memory,
|
|
21222
21336
|
redis: () => redis,
|
|
21223
21337
|
upstash: () => upstash
|
|
21224
21338
|
});
|
|
21225
|
-
function
|
|
21339
|
+
function from9(store, options) {
|
|
21226
21340
|
return withKeyPrefix(store, options?.keyPrefix);
|
|
21227
21341
|
}
|
|
21228
21342
|
function withKeyPrefix(store, keyPrefix = "") {
|
|
@@ -21233,7 +21347,7 @@ function withKeyPrefix(store, keyPrefix = "") {
|
|
|
21233
21347
|
return cached2;
|
|
21234
21348
|
const backing = store;
|
|
21235
21349
|
const prefixedKey = (key) => `${keyPrefix}${key}`;
|
|
21236
|
-
const prefixed =
|
|
21350
|
+
const prefixed = from9({
|
|
21237
21351
|
async get(key) {
|
|
21238
21352
|
return backing.get(prefixedKey(key));
|
|
21239
21353
|
},
|
|
@@ -21270,7 +21384,7 @@ function wrapJsonUpdate(update) {
|
|
|
21270
21384
|
};
|
|
21271
21385
|
}
|
|
21272
21386
|
function cloudflare(kv, options) {
|
|
21273
|
-
return
|
|
21387
|
+
return from9({
|
|
21274
21388
|
async get(key) {
|
|
21275
21389
|
const raw = await kv.get(key);
|
|
21276
21390
|
if (raw == null)
|
|
@@ -21288,7 +21402,7 @@ function cloudflare(kv, options) {
|
|
|
21288
21402
|
}
|
|
21289
21403
|
function memory(options) {
|
|
21290
21404
|
const store = /* @__PURE__ */ new Map();
|
|
21291
|
-
return
|
|
21405
|
+
return from9({
|
|
21292
21406
|
async get(key) {
|
|
21293
21407
|
const raw = store.get(key);
|
|
21294
21408
|
if (raw === void 0)
|
|
@@ -21313,7 +21427,7 @@ function memory(options) {
|
|
|
21313
21427
|
}, options);
|
|
21314
21428
|
}
|
|
21315
21429
|
function redis(client, options) {
|
|
21316
|
-
return
|
|
21430
|
+
return from9({
|
|
21317
21431
|
async get(key) {
|
|
21318
21432
|
const raw = await client.get(key);
|
|
21319
21433
|
if (raw == null)
|
|
@@ -21330,7 +21444,7 @@ function redis(client, options) {
|
|
|
21330
21444
|
}, options);
|
|
21331
21445
|
}
|
|
21332
21446
|
function upstash(redis2, options) {
|
|
21333
|
-
return
|
|
21447
|
+
return from9({
|
|
21334
21448
|
async get(key) {
|
|
21335
21449
|
return await redis2.get(key);
|
|
21336
21450
|
},
|
|
@@ -22710,7 +22824,7 @@ function createAgentScoreCore(options) {
|
|
|
22710
22824
|
} = options;
|
|
22711
22825
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
22712
22826
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
22713
|
-
const defaultUa = `@agent-score/commerce@${"2.7.
|
|
22827
|
+
const defaultUa = `@agent-score/commerce@${"2.7.7"}`;
|
|
22714
22828
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
22715
22829
|
const sdk = new import_sdk.AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
22716
22830
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
|
@@ -23072,9 +23186,9 @@ async function extractPaymentSigner(request, x402PaymentHeader) {
|
|
|
23072
23186
|
try {
|
|
23073
23187
|
const decoded = atob(x402PaymentHeader);
|
|
23074
23188
|
const parsed = JSON.parse(decoded);
|
|
23075
|
-
const
|
|
23076
|
-
if (typeof
|
|
23077
|
-
return { address:
|
|
23189
|
+
const from10 = parsed?.payload?.authorization?.from;
|
|
23190
|
+
if (typeof from10 === "string" && /^0x[0-9a-fA-F]{40}$/.test(from10)) {
|
|
23191
|
+
return { address: from10.toLowerCase(), network: "evm" };
|
|
23078
23192
|
}
|
|
23079
23193
|
} catch (err) {
|
|
23080
23194
|
console.warn("[gate] x402 signer extraction failed:", err instanceof Error ? err.message : err);
|