@relai-fi/x402 0.5.32 → 0.5.34

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.cjs CHANGED
@@ -510,18 +510,12 @@ async function createStripeDepositAddress(secretKey, amountUsdCents, network = "
510
510
  var Relai = class {
511
511
  constructor(config) {
512
512
  this.feePayerCache = /* @__PURE__ */ new Map();
513
- this.pluginsInitialized = false;
513
+ this.pluginInitPromise = null;
514
514
  this.network = config.network;
515
515
  this.facilitatorUrl = config.facilitatorUrl || RELAI_FACILITATOR_URL;
516
516
  this.plugins = config.plugins ?? [];
517
- if (this.plugins.length > 0) {
518
- this.initPlugins().catch((err) => {
519
- console.warn("[Relai] Plugin initialization error (non-blocking):", err);
520
- });
521
- }
522
517
  }
523
- async initPlugins() {
524
- if (this.pluginsInitialized) return;
518
+ async runPluginInit() {
525
519
  for (const plugin of this.plugins) {
526
520
  if (plugin.onInit) {
527
521
  try {
@@ -531,7 +525,6 @@ var Relai = class {
531
525
  }
532
526
  }
533
527
  }
534
- this.pluginsInitialized = true;
535
528
  }
536
529
  /**
537
530
  * Get feePayer address for a network (cached)
@@ -623,6 +616,10 @@ var Relai = class {
623
616
  const integritasMode = integritasFlow === "single" ? "single_signature_fee_included" : integritasFlow === "dual" ? "dual_signature_split" : void 0;
624
617
  const paymentHeader = req.headers["x-payment"] || req.headers["payment-signature"] || req.headers["x-payment-signature"];
625
618
  if (!paymentHeader && self.plugins.length > 0) {
619
+ if (!self.pluginInitPromise) {
620
+ self.pluginInitPromise = self.runPluginInit();
621
+ }
622
+ await self.pluginInitPromise;
626
623
  const pluginCtx = {
627
624
  network,
628
625
  price: resolvedPrice,
@@ -737,14 +734,16 @@ var Relai = class {
737
734
  asset,
738
735
  payTo: settlePayTo,
739
736
  maxTimeoutSeconds: options.maxTimeoutSeconds || 60,
740
- ...integritasEnabled ? {
741
- extra: {
742
- integritasEnabled: true,
743
- ...integritasFlow ? { integritasFlow } : {},
744
- ...integritasMode ? { integritasMode } : {},
745
- ...integritasFlow === "single" ? { integritasSingleSignature: true } : {}
746
- }
747
- } : {}
737
+ extra: {
738
+ name: tokenName,
739
+ version: tokenVersion,
740
+ decimals: tokenDecimals,
741
+ symbol: token.symbol,
742
+ ...integritasEnabled ? { integritasEnabled: true } : {},
743
+ ...integritasFlow ? { integritasFlow } : {},
744
+ ...integritasMode ? { integritasMode } : {},
745
+ ...integritasFlow === "single" ? { integritasSingleSignature: true } : {}
746
+ }
748
747
  };
749
748
  const settleUrl = `${self.facilitatorUrl}/settle`;
750
749
  const settleRes = await fetch(settleUrl, {