@zauthx402/sdk 0.1.12 → 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.
package/dist/index.js CHANGED
@@ -4047,6 +4047,14 @@ var ZauthClient = class {
4047
4047
  * Queue an event for batched submission
4048
4048
  */
4049
4049
  queueEvent(event) {
4050
+ const MAX_QUEUE_SIZE = 500;
4051
+ if (this.eventQueue.length >= MAX_QUEUE_SIZE) {
4052
+ this.log("Event queue full, dropping oldest event", { queueSize: this.eventQueue.length });
4053
+ this.eventQueue.shift();
4054
+ }
4055
+ if ("body" in event && event.body && JSON.stringify(event.body).length > 1e4) {
4056
+ event.body = { _truncated: true, _originalSize: JSON.stringify(event.body).length };
4057
+ }
4050
4058
  this.eventQueue.push(event);
4051
4059
  this.log("Event queued", { type: event.type, eventId: event.eventId, queueSize: this.eventQueue.length });
4052
4060
  if (this.eventQueue.length >= this.config.batching.maxBatchSize) {
@@ -4082,9 +4090,13 @@ var ZauthClient = class {
4082
4090
  try {
4083
4091
  await this.submitBatch(events);
4084
4092
  } catch (error) {
4085
- if (this.config.batching.retry) {
4093
+ const errorMsg = error.message || "";
4094
+ const isPayloadTooLarge = errorMsg.includes("413");
4095
+ if (this.config.batching.retry && !isPayloadTooLarge) {
4086
4096
  this.log("Batch failed, re-queuing events", { count: events.length });
4087
4097
  this.eventQueue.unshift(...events);
4098
+ } else if (isPayloadTooLarge) {
4099
+ this.log("Batch payload too large, dropping events", { count: events.length });
4088
4100
  }
4089
4101
  } finally {
4090
4102
  this.isFlushing = false;
@@ -5063,8 +5075,8 @@ var RefundExecutor = class {
5063
5075
  this.log("Refund executor not enabled");
5064
5076
  return;
5065
5077
  }
5066
- if (!this.config.signer && !this.config.privateKey) {
5067
- this.log("Refund executor requires signer or privateKey");
5078
+ if (!this.config.signer && !this.config.privateKey && !this.config.solanaPrivateKey) {
5079
+ this.log("Refund executor requires signer, privateKey, or solanaPrivateKey");
5068
5080
  return;
5069
5081
  }
5070
5082
  this.log("Starting refund executor (WebSocket mode)", {
@@ -5553,7 +5565,7 @@ function createZauthMiddleware(options) {
5553
5565
  const includePatterns = options.includeRoutes?.map((p) => new RegExp(p)) || [];
5554
5566
  const excludePatterns = options.excludeRoutes?.map((p) => new RegExp(p)) || [];
5555
5567
  let refundExecutor;
5556
- if (config.refund.enabled && (config.refund.signer || config.refund.privateKey)) {
5568
+ if (config.refund.enabled && (config.refund.signer || config.refund.privateKey || config.refund.solanaPrivateKey)) {
5557
5569
  refundExecutor = createRefundExecutor(client, config.refund, config.debug);
5558
5570
  refundExecutor.start();
5559
5571
  if (config.debug) {