moltspay 0.8.4 → 0.8.6
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/cli/index.js +17 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +17 -5
- package/dist/cli/index.mjs.map +1 -1
- package/dist/client/index.js +17 -5
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +17 -5
- package/dist/client/index.mjs.map +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -30918,9 +30918,13 @@ var MoltsPayClient = class {
|
|
|
30918
30918
|
let requirements;
|
|
30919
30919
|
try {
|
|
30920
30920
|
const decoded = Buffer.from(paymentRequiredHeader, "base64").toString("utf-8");
|
|
30921
|
-
|
|
30922
|
-
if (
|
|
30923
|
-
requirements =
|
|
30921
|
+
const parsed = JSON.parse(decoded);
|
|
30922
|
+
if (Array.isArray(parsed)) {
|
|
30923
|
+
requirements = parsed;
|
|
30924
|
+
} else if (parsed.accepts && Array.isArray(parsed.accepts)) {
|
|
30925
|
+
requirements = parsed.accepts;
|
|
30926
|
+
} else {
|
|
30927
|
+
requirements = [parsed];
|
|
30924
30928
|
}
|
|
30925
30929
|
} catch {
|
|
30926
30930
|
throw new Error("Invalid x-payment-required header");
|
|
@@ -30931,10 +30935,18 @@ var MoltsPayClient = class {
|
|
|
30931
30935
|
if (!req) {
|
|
30932
30936
|
throw new Error(`No matching payment option for ${network}`);
|
|
30933
30937
|
}
|
|
30934
|
-
const
|
|
30938
|
+
const amountRaw = req.amount || req.maxAmountRequired;
|
|
30939
|
+
if (!amountRaw) {
|
|
30940
|
+
throw new Error("Missing amount in payment requirements");
|
|
30941
|
+
}
|
|
30942
|
+
const amount = Number(amountRaw) / 1e6;
|
|
30935
30943
|
this.checkLimits(amount);
|
|
30936
30944
|
console.log(`[MoltsPay] Signing payment: $${amount} USDC (gasless)`);
|
|
30937
|
-
const
|
|
30945
|
+
const payTo = req.payTo || req.resource;
|
|
30946
|
+
if (!payTo) {
|
|
30947
|
+
throw new Error("Missing payTo address in payment requirements");
|
|
30948
|
+
}
|
|
30949
|
+
const authorization = await this.signEIP3009(payTo, amount, chain2);
|
|
30938
30950
|
const payload = {
|
|
30939
30951
|
x402Version: X402_VERSION2,
|
|
30940
30952
|
scheme: "exact",
|