@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
|
@@ -23,11 +23,11 @@ var __export = (target, all) => {
|
|
|
23
23
|
for (var name in all)
|
|
24
24
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
25
|
};
|
|
26
|
-
var __copyProps = (to,
|
|
27
|
-
if (
|
|
28
|
-
for (let key of __getOwnPropNames(
|
|
26
|
+
var __copyProps = (to, from10, except, desc) => {
|
|
27
|
+
if (from10 && typeof from10 === "object" || typeof from10 === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from10))
|
|
29
29
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
-
__defProp(to, key, { get: () =>
|
|
30
|
+
__defProp(to, key, { get: () => from10[key], enumerable: !(desc = __getOwnPropDesc(from10, key)) || desc.enumerable });
|
|
31
31
|
}
|
|
32
32
|
return to;
|
|
33
33
|
};
|
|
@@ -19242,10 +19242,16 @@ var init_Errors2 = __esm({
|
|
|
19242
19242
|
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"
|
|
19243
19243
|
};
|
|
19244
19244
|
PaymentError = class extends Error {
|
|
19245
|
+
/** Safe method-specific context for diagnostics and relay responses. */
|
|
19246
|
+
details;
|
|
19245
19247
|
/** HTTP status code. */
|
|
19246
19248
|
status = 402;
|
|
19247
19249
|
/** Actionable hint for resolving the error (RFC 9457 extension member). */
|
|
19248
19250
|
hint;
|
|
19251
|
+
constructor(message, options = {}) {
|
|
19252
|
+
super(message);
|
|
19253
|
+
this.details = options.details;
|
|
19254
|
+
}
|
|
19249
19255
|
/** Converts the error to RFC 9457 Problem Details format. */
|
|
19250
19256
|
toProblemDetails(challengeId) {
|
|
19251
19257
|
return {
|
|
@@ -19253,6 +19259,7 @@ var init_Errors2 = __esm({
|
|
|
19253
19259
|
title: this.title,
|
|
19254
19260
|
status: this.status,
|
|
19255
19261
|
detail: this.message,
|
|
19262
|
+
...this.details && Object.keys(this.details).length > 0 && { details: this.details },
|
|
19256
19263
|
...this.hint && { hint: this.hint },
|
|
19257
19264
|
...challengeId && { challengeId }
|
|
19258
19265
|
};
|
|
@@ -19286,8 +19293,10 @@ var init_Errors2 = __esm({
|
|
|
19286
19293
|
title = "Verification Failed";
|
|
19287
19294
|
type = "https://paymentauth.org/problems/verification-failed";
|
|
19288
19295
|
constructor(options = {}) {
|
|
19289
|
-
const { reason } = options;
|
|
19290
|
-
super(reason ? `Payment verification failed: ${reason}.` : "Payment verification failed."
|
|
19296
|
+
const { details, reason } = options;
|
|
19297
|
+
super(reason ? `Payment verification failed: ${reason}.` : "Payment verification failed.", {
|
|
19298
|
+
details
|
|
19299
|
+
});
|
|
19291
19300
|
}
|
|
19292
19301
|
};
|
|
19293
19302
|
PaymentActionRequiredError = class extends PaymentError {
|
|
@@ -19519,7 +19528,7 @@ var version3;
|
|
|
19519
19528
|
var init_version2 = __esm({
|
|
19520
19529
|
"node_modules/viem/_esm/errors/version.js"() {
|
|
19521
19530
|
"use strict";
|
|
19522
|
-
version3 = "2.55.
|
|
19531
|
+
version3 = "2.55.8";
|
|
19523
19532
|
}
|
|
19524
19533
|
});
|
|
19525
19534
|
|
|
@@ -20004,60 +20013,93 @@ var init_isAddress = __esm({
|
|
|
20004
20013
|
}
|
|
20005
20014
|
});
|
|
20006
20015
|
|
|
20007
|
-
// node_modules/viem/_esm/
|
|
20008
|
-
|
|
20009
|
-
|
|
20010
|
-
|
|
20011
|
-
|
|
20012
|
-
init_base();
|
|
20013
|
-
InvalidDecimalNumberError = class extends BaseError3 {
|
|
20014
|
-
constructor({ value }) {
|
|
20015
|
-
super(`Number \`${value}\` is not a valid decimal number.`, {
|
|
20016
|
-
name: "InvalidDecimalNumberError"
|
|
20017
|
-
});
|
|
20018
|
-
}
|
|
20019
|
-
};
|
|
20020
|
-
}
|
|
20021
|
-
});
|
|
20022
|
-
|
|
20023
|
-
// node_modules/viem/_esm/utils/unit/parseUnits.js
|
|
20024
|
-
function parseUnits(value, decimals) {
|
|
20025
|
-
if (!/^(-?)([0-9]*)\.?([0-9]*)$/.test(value))
|
|
20016
|
+
// node_modules/viem/_esm/utils/unit/Value.js
|
|
20017
|
+
function from6(value, decimals = 0) {
|
|
20018
|
+
if (!Number.isInteger(decimals) || decimals < 0)
|
|
20019
|
+
throw new InvalidDecimalsError({ decimals });
|
|
20020
|
+
if (!/^-?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)$/.test(value))
|
|
20026
20021
|
throw new InvalidDecimalNumberError({ value });
|
|
20027
|
-
let [integer2, fraction = "0"] = value.split(".");
|
|
20022
|
+
let [integer2 = "", fraction = "0"] = value.split(".");
|
|
20028
20023
|
const negative = integer2.startsWith("-");
|
|
20029
20024
|
if (negative)
|
|
20030
20025
|
integer2 = integer2.slice(1);
|
|
20026
|
+
if (integer2 === "")
|
|
20027
|
+
integer2 = "0";
|
|
20031
20028
|
fraction = fraction.replace(/(0+)$/, "");
|
|
20032
20029
|
if (decimals === 0) {
|
|
20033
|
-
if (
|
|
20030
|
+
if (fraction.length > 0 && Number.parseInt(fraction[0], 10) >= 5)
|
|
20034
20031
|
integer2 = `${BigInt(integer2) + 1n}`;
|
|
20035
20032
|
fraction = "";
|
|
20036
20033
|
} else if (fraction.length > decimals) {
|
|
20037
|
-
const
|
|
20038
|
-
|
|
20039
|
-
|
|
20040
|
-
|
|
20041
|
-
|
|
20042
|
-
|
|
20043
|
-
|
|
20044
|
-
|
|
20045
|
-
|
|
20046
|
-
|
|
20047
|
-
|
|
20048
|
-
fraction =
|
|
20049
|
-
integer2 = `${BigInt(integer2) + 1n}`;
|
|
20034
|
+
const left = fraction.slice(0, decimals);
|
|
20035
|
+
const roundDigit = Number.parseInt(fraction.slice(decimals, decimals + 1), 10);
|
|
20036
|
+
if (roundDigit >= 5) {
|
|
20037
|
+
const carried = carry(left);
|
|
20038
|
+
if (carried.length > decimals) {
|
|
20039
|
+
fraction = carried.slice(1);
|
|
20040
|
+
integer2 = `${BigInt(integer2) + 1n}`;
|
|
20041
|
+
} else {
|
|
20042
|
+
fraction = carried;
|
|
20043
|
+
}
|
|
20044
|
+
} else {
|
|
20045
|
+
fraction = left;
|
|
20050
20046
|
}
|
|
20051
|
-
fraction = fraction.slice(0, decimals);
|
|
20052
20047
|
} else {
|
|
20053
20048
|
fraction = fraction.padEnd(decimals, "0");
|
|
20054
20049
|
}
|
|
20055
20050
|
return BigInt(`${negative ? "-" : ""}${integer2}${fraction}`);
|
|
20056
20051
|
}
|
|
20052
|
+
function carry(digits) {
|
|
20053
|
+
const out = digits.split("");
|
|
20054
|
+
let i = out.length - 1;
|
|
20055
|
+
while (i >= 0) {
|
|
20056
|
+
const d = Number.parseInt(out[i], 10) + 1;
|
|
20057
|
+
if (d < 10) {
|
|
20058
|
+
out[i] = String(d);
|
|
20059
|
+
return out.join("");
|
|
20060
|
+
}
|
|
20061
|
+
out[i] = "0";
|
|
20062
|
+
i--;
|
|
20063
|
+
}
|
|
20064
|
+
return `1${out.join("")}`;
|
|
20065
|
+
}
|
|
20066
|
+
var InvalidDecimalNumberError, InvalidDecimalsError;
|
|
20067
|
+
var init_Value2 = __esm({
|
|
20068
|
+
"node_modules/viem/_esm/utils/unit/Value.js"() {
|
|
20069
|
+
"use strict";
|
|
20070
|
+
InvalidDecimalNumberError = class extends Error {
|
|
20071
|
+
constructor({ value }) {
|
|
20072
|
+
super(`Value \`${value}\` is not a valid decimal number.`);
|
|
20073
|
+
Object.defineProperty(this, "name", {
|
|
20074
|
+
enumerable: true,
|
|
20075
|
+
configurable: true,
|
|
20076
|
+
writable: true,
|
|
20077
|
+
value: "Value.InvalidDecimalNumberError"
|
|
20078
|
+
});
|
|
20079
|
+
}
|
|
20080
|
+
};
|
|
20081
|
+
InvalidDecimalsError = class extends Error {
|
|
20082
|
+
constructor({ decimals }) {
|
|
20083
|
+
super(`\`decimals\` must be a non-negative integer. Got \`${decimals}\`.`);
|
|
20084
|
+
Object.defineProperty(this, "name", {
|
|
20085
|
+
enumerable: true,
|
|
20086
|
+
configurable: true,
|
|
20087
|
+
writable: true,
|
|
20088
|
+
value: "Value.InvalidDecimalsError"
|
|
20089
|
+
});
|
|
20090
|
+
}
|
|
20091
|
+
};
|
|
20092
|
+
}
|
|
20093
|
+
});
|
|
20094
|
+
|
|
20095
|
+
// node_modules/viem/_esm/utils/unit/parseUnits.js
|
|
20096
|
+
function parseUnits(value, decimals) {
|
|
20097
|
+
return from6(value, decimals);
|
|
20098
|
+
}
|
|
20057
20099
|
var init_parseUnits = __esm({
|
|
20058
20100
|
"node_modules/viem/_esm/utils/unit/parseUnits.js"() {
|
|
20059
20101
|
"use strict";
|
|
20060
|
-
|
|
20102
|
+
init_Value2();
|
|
20061
20103
|
}
|
|
20062
20104
|
});
|
|
20063
20105
|
|
|
@@ -20281,13 +20323,70 @@ var init_Chains = __esm({
|
|
|
20281
20323
|
// node_modules/mppx/dist/Method.js
|
|
20282
20324
|
var Method_exports = {};
|
|
20283
20325
|
__export(Method_exports, {
|
|
20284
|
-
|
|
20326
|
+
broadcastCredential: () => broadcastCredential,
|
|
20327
|
+
from: () => from7,
|
|
20328
|
+
selectServerMethod: () => selectServerMethod,
|
|
20285
20329
|
toClient: () => toClient,
|
|
20286
|
-
toServer: () => toServer
|
|
20330
|
+
toServer: () => toServer,
|
|
20331
|
+
validateCredential: () => validateCredential
|
|
20287
20332
|
});
|
|
20288
|
-
function
|
|
20333
|
+
function from7(method) {
|
|
20289
20334
|
return method;
|
|
20290
20335
|
}
|
|
20336
|
+
async function validateCredential(methods, input) {
|
|
20337
|
+
const prepared = prepareCredential(methods, input);
|
|
20338
|
+
if (!prepared.method.validate)
|
|
20339
|
+
throw new VerificationFailedError({
|
|
20340
|
+
details: { intent: prepared.method.intent, method: prepared.method.name },
|
|
20341
|
+
reason: `${prepared.method.name}/${prepared.method.intent} does not support non-mutating credential validation`
|
|
20342
|
+
});
|
|
20343
|
+
return prepared.method.validate({
|
|
20344
|
+
credential: prepared.credential,
|
|
20345
|
+
request: prepared.request
|
|
20346
|
+
});
|
|
20347
|
+
}
|
|
20348
|
+
async function broadcastCredential(methods, input) {
|
|
20349
|
+
const prepared = prepareCredential(methods, input);
|
|
20350
|
+
const { method } = prepared;
|
|
20351
|
+
if (method.broadcast && method.validate)
|
|
20352
|
+
await method.validate({ credential: prepared.credential, request: prepared.request });
|
|
20353
|
+
const broadcast = method.broadcast ?? method.verify;
|
|
20354
|
+
return broadcast({ credential: prepared.credential, request: prepared.request });
|
|
20355
|
+
}
|
|
20356
|
+
function prepareCredential(methods, input) {
|
|
20357
|
+
const credential = typeof input === "string" ? deserialize3(input) : input;
|
|
20358
|
+
const candidates = methods.filter((method2) => method2.name === credential.challenge.method && method2.intent === credential.challenge.intent);
|
|
20359
|
+
const method = selectServerMethod(candidates, credential.challenge);
|
|
20360
|
+
if (!method)
|
|
20361
|
+
throw new InvalidChallengeError({
|
|
20362
|
+
id: credential.challenge.id,
|
|
20363
|
+
reason: `no registered method for ${credential.challenge.method}/${credential.challenge.intent}`
|
|
20364
|
+
});
|
|
20365
|
+
assert5(credential.challenge.expires, credential.challenge.id);
|
|
20366
|
+
let payload;
|
|
20367
|
+
try {
|
|
20368
|
+
payload = method.schema.credential.payload.parse(credential.payload);
|
|
20369
|
+
} catch (error51) {
|
|
20370
|
+
throw new InvalidPayloadError(error51 instanceof Error ? { reason: error51.message } : {});
|
|
20371
|
+
}
|
|
20372
|
+
return {
|
|
20373
|
+
credential: { ...credential, payload },
|
|
20374
|
+
method,
|
|
20375
|
+
request: credential.challenge.request
|
|
20376
|
+
};
|
|
20377
|
+
}
|
|
20378
|
+
function selectServerMethod(methods, challenge) {
|
|
20379
|
+
if (methods.length <= 1)
|
|
20380
|
+
return methods[0];
|
|
20381
|
+
if (challenge.method !== Methods.tempo || challenge.intent !== Intents.session)
|
|
20382
|
+
return methods[0];
|
|
20383
|
+
const sessionProtocol = getMethodDetail(challenge.request.methodDetails, MethodDetailKeys.sessionProtocol);
|
|
20384
|
+
if (sessionProtocol === void 0 || sessionProtocol === SessionProtocols.v1)
|
|
20385
|
+
return methods.find((method) => method.alias === "sessionLegacy") ?? methods[0];
|
|
20386
|
+
if (sessionProtocol === SessionProtocols.v2)
|
|
20387
|
+
return methods.find((method) => method.alias === void 0) ?? methods[0];
|
|
20388
|
+
return void 0;
|
|
20389
|
+
}
|
|
20291
20390
|
function toClient(method, options) {
|
|
20292
20391
|
const { canHandleChallenge, context, createCredential } = options;
|
|
20293
20392
|
return {
|
|
@@ -20298,7 +20397,16 @@ function toClient(method, options) {
|
|
|
20298
20397
|
};
|
|
20299
20398
|
}
|
|
20300
20399
|
function toServer(method, options) {
|
|
20301
|
-
const { alias, authorize, defaults, extensions, html, preflight, request, respond, stableBinding, transport, verify: verify3 } = options;
|
|
20400
|
+
const { alias, authorize, defaults, extensions, html, preflight, request, respond, broadcast, stableBinding, transport, validate: validate4, verify: verify3 } = options;
|
|
20401
|
+
const effectiveVerify = verify3 ?? (async (parameters) => {
|
|
20402
|
+
if (validate4)
|
|
20403
|
+
await validate4(parameters);
|
|
20404
|
+
if (!broadcast)
|
|
20405
|
+
throw new VerificationFailedError({
|
|
20406
|
+
reason: `${method.name}/${method.intent} does not support credential broadcast`
|
|
20407
|
+
});
|
|
20408
|
+
return broadcast(parameters);
|
|
20409
|
+
});
|
|
20302
20410
|
return {
|
|
20303
20411
|
...method,
|
|
20304
20412
|
alias,
|
|
@@ -20309,14 +20417,20 @@ function toServer(method, options) {
|
|
|
20309
20417
|
preflight,
|
|
20310
20418
|
request,
|
|
20311
20419
|
respond,
|
|
20420
|
+
broadcast,
|
|
20312
20421
|
stableBinding,
|
|
20313
20422
|
transport,
|
|
20314
|
-
|
|
20423
|
+
validate: validate4,
|
|
20424
|
+
verify: effectiveVerify
|
|
20315
20425
|
};
|
|
20316
20426
|
}
|
|
20317
20427
|
var init_Method = __esm({
|
|
20318
20428
|
"node_modules/mppx/dist/Method.js"() {
|
|
20319
20429
|
"use strict";
|
|
20430
|
+
init_Constants();
|
|
20431
|
+
init_Credential();
|
|
20432
|
+
init_Errors2();
|
|
20433
|
+
init_Expires();
|
|
20320
20434
|
}
|
|
20321
20435
|
});
|
|
20322
20436
|
|
|
@@ -20445,7 +20559,7 @@ var init_Methods = __esm({
|
|
|
20445
20559
|
init_Method();
|
|
20446
20560
|
init_zod();
|
|
20447
20561
|
init_Types();
|
|
20448
|
-
charge =
|
|
20562
|
+
charge = from7({
|
|
20449
20563
|
name: paymentMethod,
|
|
20450
20564
|
intent: chargeIntent,
|
|
20451
20565
|
schema: {
|
|
@@ -20537,15 +20651,15 @@ var Receipt_exports = {};
|
|
|
20537
20651
|
__export(Receipt_exports, {
|
|
20538
20652
|
Schema: () => Schema2,
|
|
20539
20653
|
deserialize: () => deserialize4,
|
|
20540
|
-
from: () =>
|
|
20654
|
+
from: () => from8,
|
|
20541
20655
|
fromResponse: () => fromResponse2,
|
|
20542
20656
|
serialize: () => serialize4
|
|
20543
20657
|
});
|
|
20544
20658
|
function deserialize4(encoded) {
|
|
20545
20659
|
const json2 = Base64_exports.toString(encoded);
|
|
20546
|
-
return
|
|
20660
|
+
return from8(JSON.parse(json2));
|
|
20547
20661
|
}
|
|
20548
|
-
function
|
|
20662
|
+
function from8(parameters) {
|
|
20549
20663
|
return Schema2.parse(parameters);
|
|
20550
20664
|
}
|
|
20551
20665
|
function serialize4(receipt) {
|
|
@@ -20588,12 +20702,12 @@ var init_Receipt = __esm({
|
|
|
20588
20702
|
var Store_exports = {};
|
|
20589
20703
|
__export(Store_exports, {
|
|
20590
20704
|
cloudflare: () => cloudflare,
|
|
20591
|
-
from: () =>
|
|
20705
|
+
from: () => from9,
|
|
20592
20706
|
memory: () => memory,
|
|
20593
20707
|
redis: () => redis,
|
|
20594
20708
|
upstash: () => upstash
|
|
20595
20709
|
});
|
|
20596
|
-
function
|
|
20710
|
+
function from9(store, options) {
|
|
20597
20711
|
return withKeyPrefix(store, options?.keyPrefix);
|
|
20598
20712
|
}
|
|
20599
20713
|
function withKeyPrefix(store, keyPrefix = "") {
|
|
@@ -20604,7 +20718,7 @@ function withKeyPrefix(store, keyPrefix = "") {
|
|
|
20604
20718
|
return cached2;
|
|
20605
20719
|
const backing = store;
|
|
20606
20720
|
const prefixedKey = (key) => `${keyPrefix}${key}`;
|
|
20607
|
-
const prefixed =
|
|
20721
|
+
const prefixed = from9({
|
|
20608
20722
|
async get(key) {
|
|
20609
20723
|
return backing.get(prefixedKey(key));
|
|
20610
20724
|
},
|
|
@@ -20641,7 +20755,7 @@ function wrapJsonUpdate(update) {
|
|
|
20641
20755
|
};
|
|
20642
20756
|
}
|
|
20643
20757
|
function cloudflare(kv, options) {
|
|
20644
|
-
return
|
|
20758
|
+
return from9({
|
|
20645
20759
|
async get(key) {
|
|
20646
20760
|
const raw = await kv.get(key);
|
|
20647
20761
|
if (raw == null)
|
|
@@ -20659,7 +20773,7 @@ function cloudflare(kv, options) {
|
|
|
20659
20773
|
}
|
|
20660
20774
|
function memory(options) {
|
|
20661
20775
|
const store = /* @__PURE__ */ new Map();
|
|
20662
|
-
return
|
|
20776
|
+
return from9({
|
|
20663
20777
|
async get(key) {
|
|
20664
20778
|
const raw = store.get(key);
|
|
20665
20779
|
if (raw === void 0)
|
|
@@ -20684,7 +20798,7 @@ function memory(options) {
|
|
|
20684
20798
|
}, options);
|
|
20685
20799
|
}
|
|
20686
20800
|
function redis(client, options) {
|
|
20687
|
-
return
|
|
20801
|
+
return from9({
|
|
20688
20802
|
async get(key) {
|
|
20689
20803
|
const raw = await client.get(key);
|
|
20690
20804
|
if (raw == null)
|
|
@@ -20701,7 +20815,7 @@ function redis(client, options) {
|
|
|
20701
20815
|
}, options);
|
|
20702
20816
|
}
|
|
20703
20817
|
function upstash(redis2, options) {
|
|
20704
|
-
return
|
|
20818
|
+
return from9({
|
|
20705
20819
|
async get(key) {
|
|
20706
20820
|
return await redis2.get(key);
|
|
20707
20821
|
},
|