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