facinet 2.1.0 → 2.1.2

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/browser.js CHANGED
@@ -22567,8 +22567,9 @@ var CHAINS = {
22567
22567
  };
22568
22568
  var Facinet = class _Facinet {
22569
22569
  constructor(config = {}) {
22570
+ const apiUrl = (config.apiUrl || "https://x402-avalanche-chi.vercel.app").replace(/\/$/, "");
22570
22571
  this.config = {
22571
- apiUrl: config.apiUrl || "https://x402-avalanche-chi.vercel.app",
22572
+ apiUrl,
22572
22573
  privateKey: config.privateKey || "",
22573
22574
  network: config.network || "avalanche",
22574
22575
  rpcUrl: config.rpcUrl || ""
@@ -22620,6 +22621,8 @@ var Facinet = class _Facinet {
22620
22621
  );
22621
22622
  }
22622
22623
  }
22624
+ payerAddress = getAddress(payerAddress);
22625
+ const recipientAddress = getAddress(params.recipient);
22623
22626
  const facilitator = await this.selectRandomFacilitator();
22624
22627
  const amount = BigInt(parseFloat(params.amount) * 1e6);
22625
22628
  const validAfter = Math.floor(Date.now() / 1e3) - 60;
@@ -22646,8 +22649,9 @@ var Facinet = class _Facinet {
22646
22649
  };
22647
22650
  const value = {
22648
22651
  from: payerAddress,
22649
- to: params.recipient,
22650
- // Payment goes to merchant's address!
22652
+ // Checksummed
22653
+ to: recipientAddress,
22654
+ // Checksummed - Payment goes to merchant's address!
22651
22655
  value: amount,
22652
22656
  validAfter,
22653
22657
  validBefore,
@@ -22663,7 +22667,9 @@ var Facinet = class _Facinet {
22663
22667
  primaryType: "TransferWithAuthorization",
22664
22668
  message: {
22665
22669
  from: payerAddress,
22666
- to: params.recipient,
22670
+ // Checksummed
22671
+ to: recipientAddress,
22672
+ // Checksummed
22667
22673
  value: amount.toString(),
22668
22674
  // BigInt to decimal string
22669
22675
  validAfter: validAfter.toString(),
@@ -22679,14 +22685,32 @@ var Facinet = class _Facinet {
22679
22685
  method: "eth_signTypedData_v4",
22680
22686
  params: [payerAddress, jsonMessage]
22681
22687
  });
22688
+ console.log("\u{1F510} Browser signature created:", {
22689
+ signature,
22690
+ signatureLength: signature.length,
22691
+ payerAddress
22692
+ });
22682
22693
  } else {
22683
22694
  throw new Error("No signing method available");
22684
22695
  }
22696
+ console.log("\u{1F4DD} Final authorization:", {
22697
+ from: payerAddress,
22698
+ // Checksummed
22699
+ to: recipientAddress,
22700
+ // Checksummed
22701
+ value: amount.toString(),
22702
+ validAfter: validAfter.toString(),
22703
+ validBefore: validBefore.toString(),
22704
+ nonce,
22705
+ signature: signature?.slice(0, 20) + "..."
22706
+ });
22685
22707
  const paymentPayload = {
22686
22708
  signature,
22687
22709
  authorization: {
22688
22710
  from: payerAddress,
22689
- to: params.recipient,
22711
+ // Checksummed
22712
+ to: recipientAddress,
22713
+ // Checksummed
22690
22714
  value: amount.toString(),
22691
22715
  validAfter: validAfter.toString(),
22692
22716
  validBefore: validBefore.toString(),
@@ -22714,7 +22738,9 @@ var Facinet = class _Facinet {
22714
22738
  },
22715
22739
  payment: {
22716
22740
  from: payerAddress,
22717
- to: params.recipient,
22741
+ // Checksummed
22742
+ to: recipientAddress,
22743
+ // Checksummed
22718
22744
  amount: params.amount,
22719
22745
  network: this.config.network
22720
22746
  }