moltspay 0.8.6 → 0.8.8

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/index.mjs CHANGED
@@ -30355,20 +30355,34 @@ var USDC_DOMAIN = {
30355
30355
  version: "2"
30356
30356
  };
30357
30357
  function loadEnvFiles() {
30358
- try {
30359
- const dotenv = __require("dotenv");
30360
- const envPaths = [
30361
- path2.join(process.cwd(), ".env"),
30362
- path2.join(process.env.HOME || "", ".moltspay", ".env")
30363
- ];
30364
- for (const envPath of envPaths) {
30365
- if (existsSync(envPath)) {
30366
- dotenv.config({ path: envPath });
30358
+ const envPaths = [
30359
+ path2.join(process.cwd(), ".env"),
30360
+ path2.join(process.env.HOME || "", ".moltspay", ".env")
30361
+ ];
30362
+ for (const envPath of envPaths) {
30363
+ if (existsSync(envPath)) {
30364
+ try {
30365
+ const content = readFileSync(envPath, "utf-8");
30366
+ for (const line of content.split("\n")) {
30367
+ const trimmed = line.trim();
30368
+ if (!trimmed || trimmed.startsWith("#")) continue;
30369
+ const eqIndex = trimmed.indexOf("=");
30370
+ if (eqIndex === -1) continue;
30371
+ const key = trimmed.slice(0, eqIndex).trim();
30372
+ let value = trimmed.slice(eqIndex + 1).trim();
30373
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
30374
+ value = value.slice(1, -1);
30375
+ }
30376
+ if (!process.env[key]) {
30377
+ process.env[key] = value;
30378
+ }
30379
+ }
30367
30380
  console.log(`[MoltsPay] Loaded config from ${envPath}`);
30368
30381
  break;
30382
+ } catch (err) {
30383
+ console.warn(`[MoltsPay] Failed to load ${envPath}:`, err);
30369
30384
  }
30370
30385
  }
30371
- } catch {
30372
30386
  }
30373
30387
  }
30374
30388
  function getCDPConfig() {
@@ -30949,9 +30963,17 @@ var MoltsPayClient = class {
30949
30963
  const authorization = await this.signEIP3009(payTo, amount, chain2);
30950
30964
  const payload = {
30951
30965
  x402Version: X402_VERSION2,
30952
- scheme: "exact",
30953
- network,
30954
- payload: authorization
30966
+ payload: authorization,
30967
+ // v2 requires 'accepted' field with the requirements being fulfilled
30968
+ accepted: {
30969
+ scheme: "exact",
30970
+ network,
30971
+ asset: req.asset || chain2.usdc,
30972
+ amount: amountRaw,
30973
+ payTo,
30974
+ maxTimeoutSeconds: req.maxTimeoutSeconds || 300,
30975
+ extra: req.extra || { name: "USD Coin", version: "2" }
30976
+ }
30955
30977
  };
30956
30978
  const paymentHeader = Buffer.from(JSON.stringify(payload)).toString("base64");
30957
30979
  console.log(`[MoltsPay] Sending request with payment...`);