@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.esm.js CHANGED
@@ -6213,18 +6213,16 @@ class ResourceSpoofTransport {
6213
6213
  * Elysia WebSocket Transport (Native WebSocket for anti-adblock)
6214
6214
  */
6215
6215
  class ElysiaWebSocketTransport {
6216
- constructor(baseUrl) {
6216
+ constructor(baseUrl, token) {
6217
6217
  this.name = 'elysia-websocket';
6218
6218
  this.available = typeof WebSocket !== 'undefined';
6219
6219
  this.connected = false;
6220
- this.token = '';
6221
6220
  this.baseUrl = baseUrl;
6221
+ this.token = token;
6222
6222
  }
6223
6223
  async send(data, endpoint) {
6224
6224
  const start = Date.now();
6225
6225
  try {
6226
- // Extract token from data (passed from SDK)
6227
- this.token = data.token || '';
6228
6226
  if (!this.token) {
6229
6227
  throw new Error('Missing token for WebSocket connection');
6230
6228
  }
@@ -6290,7 +6288,7 @@ class ElysiaWebSocketTransport {
6290
6288
  this.connected = true;
6291
6289
  resolve();
6292
6290
  };
6293
- this.ws.onerror = (error) => {
6291
+ this.ws.onerror = () => {
6294
6292
  this.connected = false;
6295
6293
  reject(new Error('WebSocket connection failed'));
6296
6294
  };
@@ -6327,7 +6325,7 @@ class SocketIOTransport {
6327
6325
  this.connected = false;
6328
6326
  this.baseUrl = baseUrl;
6329
6327
  }
6330
- async send(data, endpoint) {
6328
+ async send(data, _endpoint) {
6331
6329
  const start = Date.now();
6332
6330
  if (!this.available) {
6333
6331
  return { success: false, method: this.name, error: 'WebRTC not available' };
@@ -6420,7 +6418,7 @@ class WebRTCTransport {
6420
6418
  this.available = typeof globalThis.RTCPeerConnection !== 'undefined';
6421
6419
  this.connected = false;
6422
6420
  }
6423
- async send(data, endpoint) {
6421
+ async send(data, _endpoint) {
6424
6422
  const start = Date.now();
6425
6423
  if (!this.available) {
6426
6424
  return { success: false, method: this.name, error: 'WebRTC not available' };
@@ -6492,7 +6490,7 @@ class WebRTCTransport {
6492
6490
  * Main Anti-Adblock Manager
6493
6491
  */
6494
6492
  class AntiAdblockManager {
6495
- constructor(baseUrl, config = {}) {
6493
+ constructor(baseUrl, token, config = {}) {
6496
6494
  this.transports = [];
6497
6495
  this.stats = {
6498
6496
  totalRequests: 0,
@@ -6501,6 +6499,7 @@ class AntiAdblockManager {
6501
6499
  methodFailures: new Map()
6502
6500
  };
6503
6501
  this.baseUrl = baseUrl;
6502
+ this.token = token;
6504
6503
  this.config = {
6505
6504
  enabled: true,
6506
6505
  methods: ['elysia-websocket', 'fetch', 'resource'], // Elysia WebSocket as primary
@@ -6513,7 +6512,7 @@ class AntiAdblockManager {
6513
6512
  }
6514
6513
  initializeTransports() {
6515
6514
  const transportMap = {
6516
- 'elysia-websocket': () => new ElysiaWebSocketTransport(this.baseUrl),
6515
+ 'elysia-websocket': () => new ElysiaWebSocketTransport(this.baseUrl, this.token),
6517
6516
  socketio: () => new SocketIOTransport(this.baseUrl),
6518
6517
  fetch: () => new FetchTransport(),
6519
6518
  resource: () => new ResourceSpoofTransport(this.baseUrl),
@@ -7759,7 +7758,8 @@ class ZaplierSDK {
7759
7758
  */
7760
7759
  initializeAntiAdblock() {
7761
7760
  try {
7762
- this.antiAdblockManager = new AntiAdblockManager(this.config.apiEndpoint, {
7761
+ this.antiAdblockManager = new AntiAdblockManager(this.config.apiEndpoint, this.config.token, // Pass token to anti-adblock manager
7762
+ {
7763
7763
  enabled: true,
7764
7764
  methods: ["elysia-websocket", "fetch", "resource"], // Elysia WebSocket as primary
7765
7765
  fallbackDelay: 100,