@zaplier/sdk 1.1.9 → 1.2.1
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 +19 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +19 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/sdk.js +19 -12
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.min.js +1 -1
- package/dist/src/modules/anti-adblock.d.ts +5 -4
- package/dist/src/modules/anti-adblock.d.ts.map +1 -1
- package/dist/src/sdk.d.ts.map +1 -1
- package/package.json +1 -1
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
|
}
|
|
@@ -6255,15 +6253,22 @@
|
|
|
6255
6253
|
}
|
|
6256
6254
|
};
|
|
6257
6255
|
this.ws?.addEventListener('message', messageHandler);
|
|
6258
|
-
// Send the tracking data
|
|
6256
|
+
// Send the complete tracking data payload (includes fingerprintHash, stableCoreHash, etc.)
|
|
6259
6257
|
this.ws?.send(JSON.stringify({
|
|
6258
|
+
// Include all data from the SDK payload
|
|
6259
|
+
...data,
|
|
6260
|
+
// Override/ensure essential fields for WebSocket transport
|
|
6260
6261
|
eventId: data.eventId || crypto.randomUUID(),
|
|
6261
6262
|
sessionId: data.sessionId || data.s,
|
|
6262
6263
|
eventType: data.eventType || data.type || 'websocket_event',
|
|
6263
6264
|
eventName: data.eventName || data.name,
|
|
6264
6265
|
url: data.url,
|
|
6265
6266
|
userAgent: data.userAgent || navigator.userAgent,
|
|
6266
|
-
timestamp: new Date().toISOString()
|
|
6267
|
+
timestamp: new Date().toISOString(),
|
|
6268
|
+
// Ensure these critical fields are included for identity resolution
|
|
6269
|
+
fingerprintHash: data.fingerprintHash,
|
|
6270
|
+
stableCoreHash: data.stableCoreHash,
|
|
6271
|
+
stableCoreVector: data.stableCoreVector
|
|
6267
6272
|
}));
|
|
6268
6273
|
// Timeout after 5 seconds
|
|
6269
6274
|
setTimeout(() => {
|
|
@@ -6296,7 +6301,7 @@
|
|
|
6296
6301
|
this.connected = true;
|
|
6297
6302
|
resolve();
|
|
6298
6303
|
};
|
|
6299
|
-
this.ws.onerror = (
|
|
6304
|
+
this.ws.onerror = () => {
|
|
6300
6305
|
this.connected = false;
|
|
6301
6306
|
reject(new Error('WebSocket connection failed'));
|
|
6302
6307
|
};
|
|
@@ -6333,7 +6338,7 @@
|
|
|
6333
6338
|
this.connected = false;
|
|
6334
6339
|
this.baseUrl = baseUrl;
|
|
6335
6340
|
}
|
|
6336
|
-
async send(data,
|
|
6341
|
+
async send(data, _endpoint) {
|
|
6337
6342
|
const start = Date.now();
|
|
6338
6343
|
if (!this.available) {
|
|
6339
6344
|
return { success: false, method: this.name, error: 'WebRTC not available' };
|
|
@@ -6426,7 +6431,7 @@
|
|
|
6426
6431
|
this.available = typeof globalThis.RTCPeerConnection !== 'undefined';
|
|
6427
6432
|
this.connected = false;
|
|
6428
6433
|
}
|
|
6429
|
-
async send(data,
|
|
6434
|
+
async send(data, _endpoint) {
|
|
6430
6435
|
const start = Date.now();
|
|
6431
6436
|
if (!this.available) {
|
|
6432
6437
|
return { success: false, method: this.name, error: 'WebRTC not available' };
|
|
@@ -6498,7 +6503,7 @@
|
|
|
6498
6503
|
* Main Anti-Adblock Manager
|
|
6499
6504
|
*/
|
|
6500
6505
|
class AntiAdblockManager {
|
|
6501
|
-
constructor(baseUrl, config = {}) {
|
|
6506
|
+
constructor(baseUrl, token, config = {}) {
|
|
6502
6507
|
this.transports = [];
|
|
6503
6508
|
this.stats = {
|
|
6504
6509
|
totalRequests: 0,
|
|
@@ -6507,6 +6512,7 @@
|
|
|
6507
6512
|
methodFailures: new Map()
|
|
6508
6513
|
};
|
|
6509
6514
|
this.baseUrl = baseUrl;
|
|
6515
|
+
this.token = token;
|
|
6510
6516
|
this.config = {
|
|
6511
6517
|
enabled: true,
|
|
6512
6518
|
methods: ['elysia-websocket', 'fetch', 'resource'], // Elysia WebSocket as primary
|
|
@@ -6519,7 +6525,7 @@
|
|
|
6519
6525
|
}
|
|
6520
6526
|
initializeTransports() {
|
|
6521
6527
|
const transportMap = {
|
|
6522
|
-
'elysia-websocket': () => new ElysiaWebSocketTransport(this.baseUrl),
|
|
6528
|
+
'elysia-websocket': () => new ElysiaWebSocketTransport(this.baseUrl, this.token),
|
|
6523
6529
|
socketio: () => new SocketIOTransport(this.baseUrl),
|
|
6524
6530
|
fetch: () => new FetchTransport(),
|
|
6525
6531
|
resource: () => new ResourceSpoofTransport(this.baseUrl),
|
|
@@ -7765,7 +7771,8 @@
|
|
|
7765
7771
|
*/
|
|
7766
7772
|
initializeAntiAdblock() {
|
|
7767
7773
|
try {
|
|
7768
|
-
this.antiAdblockManager = new AntiAdblockManager(this.config.apiEndpoint,
|
|
7774
|
+
this.antiAdblockManager = new AntiAdblockManager(this.config.apiEndpoint, this.config.token, // Pass token to anti-adblock manager
|
|
7775
|
+
{
|
|
7769
7776
|
enabled: true,
|
|
7770
7777
|
methods: ["elysia-websocket", "fetch", "resource"], // Elysia WebSocket as primary
|
|
7771
7778
|
fallbackDelay: 100,
|