@zauthx402/sdk 0.1.10 → 0.1.14

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.
@@ -4045,6 +4045,14 @@ var ZauthClient = class {
4045
4045
  * Queue an event for batched submission
4046
4046
  */
4047
4047
  queueEvent(event) {
4048
+ const MAX_QUEUE_SIZE = 500;
4049
+ if (this.eventQueue.length >= MAX_QUEUE_SIZE) {
4050
+ this.log("Event queue full, dropping oldest event", { queueSize: this.eventQueue.length });
4051
+ this.eventQueue.shift();
4052
+ }
4053
+ if ("body" in event && event.body && JSON.stringify(event.body).length > 1e4) {
4054
+ event.body = { _truncated: true, _originalSize: JSON.stringify(event.body).length };
4055
+ }
4048
4056
  this.eventQueue.push(event);
4049
4057
  this.log("Event queued", { type: event.type, eventId: event.eventId, queueSize: this.eventQueue.length });
4050
4058
  if (this.eventQueue.length >= this.config.batching.maxBatchSize) {
@@ -4080,9 +4088,13 @@ var ZauthClient = class {
4080
4088
  try {
4081
4089
  await this.submitBatch(events);
4082
4090
  } catch (error) {
4083
- if (this.config.batching.retry) {
4091
+ const errorMsg = error.message || "";
4092
+ const isPayloadTooLarge = errorMsg.includes("413");
4093
+ if (this.config.batching.retry && !isPayloadTooLarge) {
4084
4094
  this.log("Batch failed, re-queuing events", { count: events.length });
4085
4095
  this.eventQueue.unshift(...events);
4096
+ } else if (isPayloadTooLarge) {
4097
+ this.log("Batch payload too large, dropping events", { count: events.length });
4086
4098
  }
4087
4099
  } finally {
4088
4100
  this.isFlushing = false;
@@ -4540,7 +4552,8 @@ function decodePaymentHeader(paymentHeader) {
4540
4552
  if (!payer && parsed.payload?.transaction) {
4541
4553
  payer = extractSolanaFeePayer(parsed.payload.transaction);
4542
4554
  }
4543
- const amount = parsed.payload?.authorization?.value || // x402 V2
4555
+ const amount = parsed.payload?.authorization?.value || // x402 V2 EVM
4556
+ parsed.accepted?.amount || // x402 V2 (accepted payment requirements)
4544
4557
  parsed.amount || parsed.payload?.amount || null;
4545
4558
  let network = parsed.payload?.authorization?.network || // x402 V2 EVM
4546
4559
  parsed.network || parsed.payload?.network || null;
@@ -4790,8 +4803,8 @@ var RefundExecutor = class {
4790
4803
  this.log("Refund executor not enabled");
4791
4804
  return;
4792
4805
  }
4793
- if (!this.config.signer && !this.config.privateKey) {
4794
- this.log("Refund executor requires signer or privateKey");
4806
+ if (!this.config.signer && !this.config.privateKey && !this.config.solanaPrivateKey) {
4807
+ this.log("Refund executor requires signer, privateKey, or solanaPrivateKey");
4795
4808
  return;
4796
4809
  }
4797
4810
  this.log("Starting refund executor (WebSocket mode)", {
@@ -5280,7 +5293,7 @@ function createZauthMiddleware(options) {
5280
5293
  const includePatterns = options.includeRoutes?.map((p) => new RegExp(p)) || [];
5281
5294
  const excludePatterns = options.excludeRoutes?.map((p) => new RegExp(p)) || [];
5282
5295
  let refundExecutor;
5283
- if (config.refund.enabled && (config.refund.signer || config.refund.privateKey)) {
5296
+ if (config.refund.enabled && (config.refund.signer || config.refund.privateKey || config.refund.solanaPrivateKey)) {
5284
5297
  refundExecutor = createRefundExecutor(client, config.refund, config.debug);
5285
5298
  refundExecutor.start();
5286
5299
  if (config.debug) {
@@ -5406,11 +5419,11 @@ function createZauthMiddleware(options) {
5406
5419
  let paymentResponse = reqPaymentInfo || headerPaymentResponse;
5407
5420
  if (facilitatorResponse?.payer) {
5408
5421
  const defaultAmount = options.defaultPaymentAmountUsdc;
5422
+ const decodedAmountUsdc = decodedPayment?.amount ? baseUnitsToUsdc(decodedPayment.amount) : null;
5409
5423
  paymentResponse = {
5410
5424
  transactionHash: facilitatorResponse.transaction || null,
5411
- amountPaid: null,
5412
- // Amount not in facilitator response
5413
- amountPaidUsdc: defaultAmount || null,
5425
+ amountPaid: decodedPayment?.amount || null,
5426
+ amountPaidUsdc: decodedAmountUsdc || defaultAmount || null,
5414
5427
  network: facilitatorResponse.network || "base",
5415
5428
  payTo: null,
5416
5429
  asset: "USDC",