@zaplier/sdk 1.1.9 → 1.2.0

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
@@ -6217,18 +6217,16 @@ class ResourceSpoofTransport {
6217
6217
  * Elysia WebSocket Transport (Native WebSocket for anti-adblock)
6218
6218
  */
6219
6219
  class ElysiaWebSocketTransport {
6220
- constructor(baseUrl) {
6220
+ constructor(baseUrl, token) {
6221
6221
  this.name = 'elysia-websocket';
6222
6222
  this.available = typeof WebSocket !== 'undefined';
6223
6223
  this.connected = false;
6224
- this.token = '';
6225
6224
  this.baseUrl = baseUrl;
6225
+ this.token = token;
6226
6226
  }
6227
6227
  async send(data, endpoint) {
6228
6228
  const start = Date.now();
6229
6229
  try {
6230
- // Extract token from data (passed from SDK)
6231
- this.token = data.token || '';
6232
6230
  if (!this.token) {
6233
6231
  throw new Error('Missing token for WebSocket connection');
6234
6232
  }
@@ -6294,7 +6292,7 @@ class ElysiaWebSocketTransport {
6294
6292
  this.connected = true;
6295
6293
  resolve();
6296
6294
  };
6297
- this.ws.onerror = (error) => {
6295
+ this.ws.onerror = () => {
6298
6296
  this.connected = false;
6299
6297
  reject(new Error('WebSocket connection failed'));
6300
6298
  };
@@ -6331,7 +6329,7 @@ class SocketIOTransport {
6331
6329
  this.connected = false;
6332
6330
  this.baseUrl = baseUrl;
6333
6331
  }
6334
- async send(data, endpoint) {
6332
+ async send(data, _endpoint) {
6335
6333
  const start = Date.now();
6336
6334
  if (!this.available) {
6337
6335
  return { success: false, method: this.name, error: 'WebRTC not available' };
@@ -6424,7 +6422,7 @@ class WebRTCTransport {
6424
6422
  this.available = typeof globalThis.RTCPeerConnection !== 'undefined';
6425
6423
  this.connected = false;
6426
6424
  }
6427
- async send(data, endpoint) {
6425
+ async send(data, _endpoint) {
6428
6426
  const start = Date.now();
6429
6427
  if (!this.available) {
6430
6428
  return { success: false, method: this.name, error: 'WebRTC not available' };
@@ -6496,7 +6494,7 @@ class WebRTCTransport {
6496
6494
  * Main Anti-Adblock Manager
6497
6495
  */
6498
6496
  class AntiAdblockManager {
6499
- constructor(baseUrl, config = {}) {
6497
+ constructor(baseUrl, token, config = {}) {
6500
6498
  this.transports = [];
6501
6499
  this.stats = {
6502
6500
  totalRequests: 0,
@@ -6505,6 +6503,7 @@ class AntiAdblockManager {
6505
6503
  methodFailures: new Map()
6506
6504
  };
6507
6505
  this.baseUrl = baseUrl;
6506
+ this.token = token;
6508
6507
  this.config = {
6509
6508
  enabled: true,
6510
6509
  methods: ['elysia-websocket', 'fetch', 'resource'], // Elysia WebSocket as primary
@@ -6517,7 +6516,7 @@ class AntiAdblockManager {
6517
6516
  }
6518
6517
  initializeTransports() {
6519
6518
  const transportMap = {
6520
- 'elysia-websocket': () => new ElysiaWebSocketTransport(this.baseUrl),
6519
+ 'elysia-websocket': () => new ElysiaWebSocketTransport(this.baseUrl, this.token),
6521
6520
  socketio: () => new SocketIOTransport(this.baseUrl),
6522
6521
  fetch: () => new FetchTransport(),
6523
6522
  resource: () => new ResourceSpoofTransport(this.baseUrl),
@@ -7763,7 +7762,8 @@ class ZaplierSDK {
7763
7762
  */
7764
7763
  initializeAntiAdblock() {
7765
7764
  try {
7766
- this.antiAdblockManager = new AntiAdblockManager(this.config.apiEndpoint, {
7765
+ this.antiAdblockManager = new AntiAdblockManager(this.config.apiEndpoint, this.config.token, // Pass token to anti-adblock manager
7766
+ {
7767
7767
  enabled: true,
7768
7768
  methods: ["elysia-websocket", "fetch", "resource"], // Elysia WebSocket as primary
7769
7769
  fallbackDelay: 100,