@webdecoy/client 0.27.0 → 0.29.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.d.mts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +120 -45
- package/dist/index.mjs +120 -45
- package/dist/webdecoy.global.js +4 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -116,14 +116,17 @@ declare class InvisibleSession {
|
|
|
116
116
|
private startTime;
|
|
117
117
|
private lastScore;
|
|
118
118
|
private listeners;
|
|
119
|
+
private challengeRequest;
|
|
120
|
+
private scoring;
|
|
119
121
|
constructor(options?: InvisibleOptions);
|
|
120
122
|
private _init;
|
|
121
|
-
private
|
|
123
|
+
private serverOrigin;
|
|
122
124
|
private _attachListeners;
|
|
123
125
|
private _attachToForms;
|
|
124
126
|
/** Score the session, then resubmit the form the listener cancelled. */
|
|
125
127
|
private _scoreThenSubmit;
|
|
126
128
|
execute(action?: string): Promise<VerifyResponse>;
|
|
129
|
+
private _collectAndScore;
|
|
127
130
|
private _score;
|
|
128
131
|
private _clientSideScore;
|
|
129
132
|
getScore(): (VerifyResponse & {
|
|
@@ -174,12 +177,14 @@ declare const WebDecoyCaptcha: WebDecoyCaptchaAPI;
|
|
|
174
177
|
*/
|
|
175
178
|
|
|
176
179
|
declare class PoWManager {
|
|
180
|
+
private readonly challengeOrigin;
|
|
177
181
|
private workers;
|
|
178
182
|
challenge: Challenge | null;
|
|
179
183
|
solution: PoWSolution | null;
|
|
180
184
|
private solving;
|
|
181
185
|
private solvePromise;
|
|
182
186
|
private startTime;
|
|
187
|
+
constructor(challengeOrigin?: () => string | null);
|
|
183
188
|
/**
|
|
184
189
|
* Inline Web Worker for PoW computation. Each worker scans a disjoint nonce
|
|
185
190
|
* slice via `(startNonce + k*stride)`, so N workers explore the space N-way.
|
|
@@ -290,16 +295,23 @@ declare class BehavioralCollector {
|
|
|
290
295
|
lastMouseTime: number | null;
|
|
291
296
|
lastVelocity: number | null;
|
|
292
297
|
eventDeltas: number[];
|
|
293
|
-
|
|
298
|
+
private readonly pendingKeyHolds?;
|
|
299
|
+
private keyHoldSamples;
|
|
300
|
+
private keyHoldTotalMs;
|
|
301
|
+
constructor(options?: {
|
|
302
|
+
collectKeyHolds?: boolean;
|
|
303
|
+
});
|
|
294
304
|
recordMouseMove(e: MouseEvent): void;
|
|
295
305
|
recordMouseDown(e: MouseEvent): void;
|
|
296
306
|
recordMouseUp(_e: MouseEvent): void;
|
|
297
307
|
recordScroll(_e: Event): void;
|
|
298
308
|
recordKeyEvent(e: KeyboardEvent): void;
|
|
309
|
+
private recordKeyHold;
|
|
299
310
|
recordTouch(e: TouchEvent): void;
|
|
300
311
|
recordPointer(e: PointerEvent): void;
|
|
301
312
|
recordFocus(e: FocusEvent): void;
|
|
302
313
|
analyze(): Record<string, unknown>;
|
|
314
|
+
private analyzeScrolling;
|
|
303
315
|
_analyzeTouchPoints(touches: TouchSample[]): Record<string, unknown>;
|
|
304
316
|
_analyzePointerPoints(points: PointerSample[]): Record<string, unknown>;
|
|
305
317
|
analyzeClick(clickX: number, clickY: number, targetRect: DOMRect): Record<string, unknown>;
|
|
@@ -471,6 +483,7 @@ declare class FormAnalyzer {
|
|
|
471
483
|
_recordProgrammaticSubmit(_form: HTMLFormElement): void;
|
|
472
484
|
_recordSubmit(_e: SubmitEvent): void;
|
|
473
485
|
analyze(): Record<string, unknown>;
|
|
486
|
+
private getTextareaStats;
|
|
474
487
|
recordPaste(e: ClipboardEvent): void;
|
|
475
488
|
}
|
|
476
489
|
declare function getFormAnalyzer(): FormAnalyzer;
|
package/dist/index.d.ts
CHANGED
|
@@ -116,14 +116,17 @@ declare class InvisibleSession {
|
|
|
116
116
|
private startTime;
|
|
117
117
|
private lastScore;
|
|
118
118
|
private listeners;
|
|
119
|
+
private challengeRequest;
|
|
120
|
+
private scoring;
|
|
119
121
|
constructor(options?: InvisibleOptions);
|
|
120
122
|
private _init;
|
|
121
|
-
private
|
|
123
|
+
private serverOrigin;
|
|
122
124
|
private _attachListeners;
|
|
123
125
|
private _attachToForms;
|
|
124
126
|
/** Score the session, then resubmit the form the listener cancelled. */
|
|
125
127
|
private _scoreThenSubmit;
|
|
126
128
|
execute(action?: string): Promise<VerifyResponse>;
|
|
129
|
+
private _collectAndScore;
|
|
127
130
|
private _score;
|
|
128
131
|
private _clientSideScore;
|
|
129
132
|
getScore(): (VerifyResponse & {
|
|
@@ -174,12 +177,14 @@ declare const WebDecoyCaptcha: WebDecoyCaptchaAPI;
|
|
|
174
177
|
*/
|
|
175
178
|
|
|
176
179
|
declare class PoWManager {
|
|
180
|
+
private readonly challengeOrigin;
|
|
177
181
|
private workers;
|
|
178
182
|
challenge: Challenge | null;
|
|
179
183
|
solution: PoWSolution | null;
|
|
180
184
|
private solving;
|
|
181
185
|
private solvePromise;
|
|
182
186
|
private startTime;
|
|
187
|
+
constructor(challengeOrigin?: () => string | null);
|
|
183
188
|
/**
|
|
184
189
|
* Inline Web Worker for PoW computation. Each worker scans a disjoint nonce
|
|
185
190
|
* slice via `(startNonce + k*stride)`, so N workers explore the space N-way.
|
|
@@ -290,16 +295,23 @@ declare class BehavioralCollector {
|
|
|
290
295
|
lastMouseTime: number | null;
|
|
291
296
|
lastVelocity: number | null;
|
|
292
297
|
eventDeltas: number[];
|
|
293
|
-
|
|
298
|
+
private readonly pendingKeyHolds?;
|
|
299
|
+
private keyHoldSamples;
|
|
300
|
+
private keyHoldTotalMs;
|
|
301
|
+
constructor(options?: {
|
|
302
|
+
collectKeyHolds?: boolean;
|
|
303
|
+
});
|
|
294
304
|
recordMouseMove(e: MouseEvent): void;
|
|
295
305
|
recordMouseDown(e: MouseEvent): void;
|
|
296
306
|
recordMouseUp(_e: MouseEvent): void;
|
|
297
307
|
recordScroll(_e: Event): void;
|
|
298
308
|
recordKeyEvent(e: KeyboardEvent): void;
|
|
309
|
+
private recordKeyHold;
|
|
299
310
|
recordTouch(e: TouchEvent): void;
|
|
300
311
|
recordPointer(e: PointerEvent): void;
|
|
301
312
|
recordFocus(e: FocusEvent): void;
|
|
302
313
|
analyze(): Record<string, unknown>;
|
|
314
|
+
private analyzeScrolling;
|
|
303
315
|
_analyzeTouchPoints(touches: TouchSample[]): Record<string, unknown>;
|
|
304
316
|
_analyzePointerPoints(points: PointerSample[]): Record<string, unknown>;
|
|
305
317
|
analyzeClick(clickX: number, clickY: number, targetRect: DOMRect): Record<string, unknown>;
|
|
@@ -471,6 +483,7 @@ declare class FormAnalyzer {
|
|
|
471
483
|
_recordProgrammaticSubmit(_form: HTMLFormElement): void;
|
|
472
484
|
_recordSubmit(_e: SubmitEvent): void;
|
|
473
485
|
analyze(): Record<string, unknown>;
|
|
486
|
+
private getTextareaStats;
|
|
474
487
|
recordPaste(e: ClipboardEvent): void;
|
|
475
488
|
}
|
|
476
489
|
declare function getFormAnalyzer(): FormAnalyzer;
|
package/dist/index.js
CHANGED
|
@@ -46,8 +46,15 @@ __export(src_exports, {
|
|
|
46
46
|
module.exports = __toCommonJS(src_exports);
|
|
47
47
|
|
|
48
48
|
// src/collectors/behavioral.ts
|
|
49
|
+
var MAX_PENDING_KEY_HOLDS = 64;
|
|
50
|
+
var MAX_KEY_HOLD_SAMPLES = 200;
|
|
51
|
+
var MAX_KEY_HOLD_MS = 2e3;
|
|
52
|
+
var KEY_HOLD_MODIFIERS = /* @__PURE__ */ new Set(["Alt", "CapsLock", "Control", "Meta", "NumLock", "ScrollLock", "Shift"]);
|
|
49
53
|
var BehavioralCollector = class {
|
|
50
|
-
constructor() {
|
|
54
|
+
constructor(options = {}) {
|
|
55
|
+
this.keyHoldSamples = 0;
|
|
56
|
+
this.keyHoldTotalMs = 0;
|
|
57
|
+
if (options.collectKeyHolds) this.pendingKeyHolds = /* @__PURE__ */ new Map();
|
|
51
58
|
this.mousePositions = [];
|
|
52
59
|
this.mouseVelocities = [];
|
|
53
60
|
this.mouseAccelerations = [];
|
|
@@ -116,12 +123,38 @@ var BehavioralCollector = class {
|
|
|
116
123
|
if (this.scrollEvents.length > 100) this.scrollEvents.shift();
|
|
117
124
|
}
|
|
118
125
|
recordKeyEvent(e) {
|
|
126
|
+
const now = performance.now();
|
|
119
127
|
this.keyEvents.push({
|
|
120
128
|
type: e.type,
|
|
121
129
|
keyLength: e.key ? e.key.length : 0,
|
|
122
130
|
// Don't store actual keys
|
|
123
|
-
t:
|
|
131
|
+
t: now
|
|
124
132
|
});
|
|
133
|
+
this.recordKeyHold(e, now);
|
|
134
|
+
}
|
|
135
|
+
recordKeyHold(e, now) {
|
|
136
|
+
var _a, _b;
|
|
137
|
+
const pending = this.pendingKeyHolds;
|
|
138
|
+
const code = e.code;
|
|
139
|
+
if (!pending || this.keyHoldSamples >= MAX_KEY_HOLD_SAMPLES || !code || code === "Unidentified") {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const target = (_b = (_a = e.composedPath) == null ? void 0 : _a.call(e)[0]) != null ? _b : e.target;
|
|
143
|
+
const excluded = e.isComposing || KEY_HOLD_MODIFIERS.has(e.key) || target instanceof Element && target.matches('textarea, input[type="password"]');
|
|
144
|
+
if (e.type === "keydown" && !e.repeat) {
|
|
145
|
+
pending.delete(code);
|
|
146
|
+
if (!excluded && pending.size < MAX_PENDING_KEY_HOLDS) pending.set(code, now);
|
|
147
|
+
} else if (e.type === "keyup") {
|
|
148
|
+
const started = pending.get(code);
|
|
149
|
+
pending.delete(code);
|
|
150
|
+
if (started === void 0 || excluded) return;
|
|
151
|
+
const duration = now - started;
|
|
152
|
+
if (duration > 0 && duration < MAX_KEY_HOLD_MS) {
|
|
153
|
+
this.keyHoldSamples++;
|
|
154
|
+
this.keyHoldTotalMs += duration;
|
|
155
|
+
if (this.keyHoldSamples === MAX_KEY_HOLD_SAMPLES) pending.clear();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
125
158
|
}
|
|
126
159
|
recordTouch(e) {
|
|
127
160
|
const touches = e.touches && e.touches.length ? e.touches : e.changedTouches;
|
|
@@ -168,8 +201,9 @@ var BehavioralCollector = class {
|
|
|
168
201
|
const positions = this.mousePositions;
|
|
169
202
|
const velocities = this.mouseVelocities;
|
|
170
203
|
const accelerations = this.mouseAccelerations;
|
|
204
|
+
const keyHolds = this.keyHoldSamples > 0 ? { keyHoldSamples: this.keyHoldSamples, keyHoldAvg: this.keyHoldTotalMs / this.keyHoldSamples } : {};
|
|
171
205
|
if (positions.length < 10) {
|
|
172
|
-
return this._getEmptyAnalysis();
|
|
206
|
+
return { ...this._getEmptyAnalysis(), ...keyHolds };
|
|
173
207
|
}
|
|
174
208
|
let avgVelocity = 0;
|
|
175
209
|
let velocityVariance = 0;
|
|
@@ -225,16 +259,30 @@ var BehavioralCollector = class {
|
|
|
225
259
|
eventDeltas: this.eventDeltas.slice(-50),
|
|
226
260
|
eventDeltaVariance,
|
|
227
261
|
mouseEventRate,
|
|
228
|
-
|
|
262
|
+
...this.analyzeScrolling(),
|
|
229
263
|
keyEvents: this.keyEvents.length,
|
|
230
264
|
touchEvents: this.touchEvents.length,
|
|
231
265
|
focusEvents: this.focusEvents.length,
|
|
232
266
|
clickData: this.clickData,
|
|
233
267
|
interactionDuration: Date.now() - this.startTime,
|
|
234
268
|
...touchAnalysis,
|
|
235
|
-
...pointerAnalysis
|
|
269
|
+
...pointerAnalysis,
|
|
270
|
+
...keyHolds
|
|
236
271
|
};
|
|
237
272
|
}
|
|
273
|
+
analyzeScrolling() {
|
|
274
|
+
const events = this.scrollEvents;
|
|
275
|
+
const samples = events.length;
|
|
276
|
+
if (samples < 2) return { scrollEvents: samples };
|
|
277
|
+
let maxStep = 0;
|
|
278
|
+
for (let i = 1; i < samples; i++) {
|
|
279
|
+
const previous = events[i - 1];
|
|
280
|
+
const current = events[i];
|
|
281
|
+
const step = Math.abs(current.x - previous.x) + Math.abs(current.y - previous.y);
|
|
282
|
+
maxStep = Math.max(maxStep, step);
|
|
283
|
+
}
|
|
284
|
+
return { scrollEvents: samples, scrollMorphology: { samples, maxStep } };
|
|
285
|
+
}
|
|
238
286
|
_analyzeTouchPoints(touches) {
|
|
239
287
|
if (!touches || touches.length === 0) {
|
|
240
288
|
return {
|
|
@@ -455,7 +503,7 @@ var BehavioralCollector = class {
|
|
|
455
503
|
eventDeltas: [],
|
|
456
504
|
eventDeltaVariance: 0,
|
|
457
505
|
mouseEventRate: 0,
|
|
458
|
-
|
|
506
|
+
...this.analyzeScrolling(),
|
|
459
507
|
keyEvents: this.keyEvents.length,
|
|
460
508
|
touchEvents: this.touchEvents.length,
|
|
461
509
|
focusEvents: this.focusEvents.length,
|
|
@@ -1077,7 +1125,9 @@ var EnvironmentalCollector = class {
|
|
|
1077
1125
|
hasArial: detectedFonts.includes("Arial"),
|
|
1078
1126
|
hasTimesNewRoman: detectedFonts.includes("Times New Roman"),
|
|
1079
1127
|
hasSegoeUI: detectedFonts.includes("Segoe UI"),
|
|
1128
|
+
hasCalibri: detectedFonts.includes("Calibri"),
|
|
1080
1129
|
hasSFPro: detectedFonts.includes("SF Pro"),
|
|
1130
|
+
hasMenlo: detectedFonts.includes("Menlo"),
|
|
1081
1131
|
hasDejaVuSans: detectedFonts.includes("DejaVu Sans"),
|
|
1082
1132
|
supported: true
|
|
1083
1133
|
};
|
|
@@ -1356,6 +1406,7 @@ var FormAnalyzer = class {
|
|
|
1356
1406
|
});
|
|
1357
1407
|
document.addEventListener("keydown", (e) => this._recordTextareaKey(e), { passive: true });
|
|
1358
1408
|
document.addEventListener("keyup", (e) => this._recordTextareaKey(e), { passive: true });
|
|
1409
|
+
document.addEventListener("paste", (e) => this.recordPaste(e), { passive: true });
|
|
1359
1410
|
document.addEventListener("submit", (e) => this._recordSubmit(e), { capture: true });
|
|
1360
1411
|
this._interceptFormSubmit();
|
|
1361
1412
|
}
|
|
@@ -1379,22 +1430,7 @@ var FormAnalyzer = class {
|
|
|
1379
1430
|
_recordTextareaKey(e) {
|
|
1380
1431
|
const target = e.target;
|
|
1381
1432
|
if ((target == null ? void 0 : target.tagName) !== "TEXTAREA") return;
|
|
1382
|
-
const
|
|
1383
|
-
if (!this.textareaStats.has(textareaId)) {
|
|
1384
|
-
this.textareaStats.set(textareaId, {
|
|
1385
|
-
keydowns: [],
|
|
1386
|
-
keyups: [],
|
|
1387
|
-
intervals: [],
|
|
1388
|
-
lastKeyTime: null,
|
|
1389
|
-
inputWithoutKey: 0,
|
|
1390
|
-
pasteCount: 0,
|
|
1391
|
-
dwellTimes: [],
|
|
1392
|
-
rollovers: 0,
|
|
1393
|
-
activeKeyCount: 0,
|
|
1394
|
-
pendingKeydowns: []
|
|
1395
|
-
});
|
|
1396
|
-
}
|
|
1397
|
-
const stats = this.textareaStats.get(textareaId);
|
|
1433
|
+
const stats = this.getTextareaStats(target);
|
|
1398
1434
|
const now = performance.now();
|
|
1399
1435
|
const isModifier = ["Shift", "Control", "Alt", "Meta", "CapsLock", "NumLock", "ScrollLock"].includes(e.key);
|
|
1400
1436
|
if (e.type === "keydown") {
|
|
@@ -1533,21 +1569,35 @@ var FormAnalyzer = class {
|
|
|
1533
1569
|
textareaKeyboard: Object.keys(textareaAnalysis).length > 0 ? textareaAnalysis : null
|
|
1534
1570
|
};
|
|
1535
1571
|
}
|
|
1536
|
-
|
|
1572
|
+
getTextareaStats(target) {
|
|
1573
|
+
const id = target.id || target.name || "unnamed";
|
|
1574
|
+
const existing = this.textareaStats.get(id);
|
|
1575
|
+
if (existing) return existing;
|
|
1576
|
+
const stats = {
|
|
1577
|
+
keydowns: [],
|
|
1578
|
+
keyups: [],
|
|
1579
|
+
intervals: [],
|
|
1580
|
+
lastKeyTime: null,
|
|
1581
|
+
inputWithoutKey: 0,
|
|
1582
|
+
pasteCount: 0,
|
|
1583
|
+
dwellTimes: [],
|
|
1584
|
+
rollovers: 0,
|
|
1585
|
+
activeKeyCount: 0,
|
|
1586
|
+
pendingKeydowns: []
|
|
1587
|
+
};
|
|
1588
|
+
this.textareaStats.set(id, stats);
|
|
1589
|
+
return stats;
|
|
1590
|
+
}
|
|
1537
1591
|
recordPaste(e) {
|
|
1538
1592
|
const target = e.target;
|
|
1539
1593
|
if ((target == null ? void 0 : target.tagName) !== "TEXTAREA") return;
|
|
1540
|
-
|
|
1541
|
-
if (this.textareaStats.has(textareaId)) {
|
|
1542
|
-
this.textareaStats.get(textareaId).pasteCount++;
|
|
1543
|
-
}
|
|
1594
|
+
this.getTextareaStats(target).pasteCount++;
|
|
1544
1595
|
}
|
|
1545
1596
|
};
|
|
1546
1597
|
var globalFormAnalyzer = null;
|
|
1547
1598
|
function getFormAnalyzer() {
|
|
1548
1599
|
if (!globalFormAnalyzer) {
|
|
1549
1600
|
globalFormAnalyzer = new FormAnalyzer();
|
|
1550
|
-
document.addEventListener("paste", (e) => globalFormAnalyzer.recordPaste(e), { passive: true });
|
|
1551
1601
|
}
|
|
1552
1602
|
return globalFormAnalyzer;
|
|
1553
1603
|
}
|
|
@@ -1643,7 +1693,8 @@ function setBasePath(path) {
|
|
|
1643
1693
|
|
|
1644
1694
|
// src/pow.ts
|
|
1645
1695
|
var PoWManager = class {
|
|
1646
|
-
constructor() {
|
|
1696
|
+
constructor(challengeOrigin = getServerUrl) {
|
|
1697
|
+
this.challengeOrigin = challengeOrigin;
|
|
1647
1698
|
this.workers = [];
|
|
1648
1699
|
this.challenge = null;
|
|
1649
1700
|
this.solution = null;
|
|
@@ -1717,7 +1768,7 @@ var PoWManager = class {
|
|
|
1717
1768
|
this.workers = [];
|
|
1718
1769
|
}
|
|
1719
1770
|
async fetchChallenge(siteKey) {
|
|
1720
|
-
const serverUrl2 =
|
|
1771
|
+
const serverUrl2 = this.challengeOrigin();
|
|
1721
1772
|
if (!serverUrl2) {
|
|
1722
1773
|
return this._generateLocalChallenge();
|
|
1723
1774
|
}
|
|
@@ -1729,7 +1780,12 @@ var PoWManager = class {
|
|
|
1729
1780
|
console.warn(`PoW challenge fetch failed (status ${response.status}), using local challenge`);
|
|
1730
1781
|
return this._generateLocalChallenge();
|
|
1731
1782
|
}
|
|
1732
|
-
|
|
1783
|
+
const { id, challengeId: legacyId, ...data } = await response.json();
|
|
1784
|
+
const challengeId = legacyId != null ? legacyId : id;
|
|
1785
|
+
if (typeof challengeId !== "string" || challengeId.length === 0) {
|
|
1786
|
+
throw new Error("PoW challenge response is missing an ID");
|
|
1787
|
+
}
|
|
1788
|
+
this.challenge = { ...data, challengeId };
|
|
1733
1789
|
return this.challenge;
|
|
1734
1790
|
} catch (e) {
|
|
1735
1791
|
console.warn("PoW challenge fetch failed, using local challenge:", e);
|
|
@@ -1848,7 +1904,7 @@ var CaptchaWidget = class {
|
|
|
1848
1904
|
options
|
|
1849
1905
|
);
|
|
1850
1906
|
this.id = "webdecoy_" + Math.random().toString(36).slice(2, 11);
|
|
1851
|
-
this.behavioral = new BehavioralCollector();
|
|
1907
|
+
this.behavioral = new BehavioralCollector({ collectKeyHolds: true });
|
|
1852
1908
|
this.environmental = new EnvironmentalCollector();
|
|
1853
1909
|
this.temporal = new TemporalCollector();
|
|
1854
1910
|
this.sensor = new SensorCollector();
|
|
@@ -2111,7 +2167,7 @@ var CaptchaWidget = class {
|
|
|
2111
2167
|
reset() {
|
|
2112
2168
|
this.verified = false;
|
|
2113
2169
|
this.token = null;
|
|
2114
|
-
this.behavioral = new BehavioralCollector();
|
|
2170
|
+
this.behavioral = new BehavioralCollector({ collectKeyHolds: true });
|
|
2115
2171
|
this.temporal = new TemporalCollector();
|
|
2116
2172
|
if (this.sensor) this.sensor.detach();
|
|
2117
2173
|
this.sensor = new SensorCollector();
|
|
@@ -2132,6 +2188,8 @@ var InvisibleSession = class {
|
|
|
2132
2188
|
constructor(options) {
|
|
2133
2189
|
this.lastScore = null;
|
|
2134
2190
|
this.listeners = [];
|
|
2191
|
+
this.challengeRequest = null;
|
|
2192
|
+
this.scoring = null;
|
|
2135
2193
|
this.options = Object.assign(
|
|
2136
2194
|
{
|
|
2137
2195
|
siteKey: null,
|
|
@@ -2144,11 +2202,11 @@ var InvisibleSession = class {
|
|
|
2144
2202
|
options
|
|
2145
2203
|
);
|
|
2146
2204
|
this.id = "webdecoy_inv_" + Math.random().toString(36).slice(2, 11);
|
|
2147
|
-
this.behavioral = new BehavioralCollector();
|
|
2205
|
+
this.behavioral = new BehavioralCollector({ collectKeyHolds: true });
|
|
2148
2206
|
this.environmental = new EnvironmentalCollector();
|
|
2149
2207
|
this.temporal = new TemporalCollector();
|
|
2150
2208
|
this.sensor = new SensorCollector();
|
|
2151
|
-
this.powManager = new PoWManager();
|
|
2209
|
+
this.powManager = new PoWManager(() => this.serverOrigin());
|
|
2152
2210
|
this.startTime = Date.now();
|
|
2153
2211
|
this._init();
|
|
2154
2212
|
}
|
|
@@ -2160,14 +2218,10 @@ var InvisibleSession = class {
|
|
|
2160
2218
|
document.addEventListener("keydown", recordFirst, { once: true });
|
|
2161
2219
|
document.addEventListener("scroll", recordFirst, { once: true });
|
|
2162
2220
|
if (this.options.autoScore) this._attachToForms();
|
|
2163
|
-
|
|
2221
|
+
this.challengeRequest = this.powManager.fetchChallenge(this.options.siteKey);
|
|
2164
2222
|
}
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
await this.powManager.fetchChallenge(this.options.siteKey);
|
|
2168
|
-
} catch (e) {
|
|
2169
|
-
console.warn("PoW challenge fetch failed:", e);
|
|
2170
|
-
}
|
|
2223
|
+
serverOrigin() {
|
|
2224
|
+
return this.options.serverUrl || getServerUrl();
|
|
2171
2225
|
}
|
|
2172
2226
|
_attachListeners() {
|
|
2173
2227
|
const handlers = {
|
|
@@ -2229,6 +2283,16 @@ var InvisibleSession = class {
|
|
|
2229
2283
|
}
|
|
2230
2284
|
}
|
|
2231
2285
|
async execute(action = "") {
|
|
2286
|
+
const run = () => this._collectAndScore(action);
|
|
2287
|
+
const score = this.scoring ? this.scoring.then(run, run) : run();
|
|
2288
|
+
this.scoring = score;
|
|
2289
|
+
try {
|
|
2290
|
+
return await score;
|
|
2291
|
+
} finally {
|
|
2292
|
+
if (this.scoring === score) this.scoring = null;
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
async _collectAndScore(action) {
|
|
2232
2296
|
var _a;
|
|
2233
2297
|
const elapsed = Date.now() - this.startTime;
|
|
2234
2298
|
if (elapsed < this.options.minCollectionTime) {
|
|
@@ -2243,6 +2307,11 @@ var InvisibleSession = class {
|
|
|
2243
2307
|
]);
|
|
2244
2308
|
const formAnalysis = getFormAnalyzer().analyze();
|
|
2245
2309
|
const sensorData = this.sensor.analyze();
|
|
2310
|
+
let challenge = await ((_a = this.challengeRequest) != null ? _a : this.powManager.fetchChallenge(this.options.siteKey));
|
|
2311
|
+
this.challengeRequest = null;
|
|
2312
|
+
if (challenge.expiresAt <= Date.now()) {
|
|
2313
|
+
challenge = await this.powManager.fetchChallenge(this.options.siteKey);
|
|
2314
|
+
}
|
|
2246
2315
|
const signals = {
|
|
2247
2316
|
behavioral: behavioralData,
|
|
2248
2317
|
environmental: { ...envData, rafConsistency: rafData, ...asyncEnvData, sensor: sensorData },
|
|
@@ -2252,7 +2321,7 @@ var InvisibleSession = class {
|
|
|
2252
2321
|
sessionId: this.id,
|
|
2253
2322
|
siteKey: this.options.siteKey,
|
|
2254
2323
|
action,
|
|
2255
|
-
challengeNonce:
|
|
2324
|
+
challengeNonce: challenge.nonce || null,
|
|
2256
2325
|
timestamp: Date.now(),
|
|
2257
2326
|
userAgent: navigator.userAgent,
|
|
2258
2327
|
screenSize: `${screen.width}x${screen.height}`,
|
|
@@ -2264,7 +2333,12 @@ var InvisibleSession = class {
|
|
|
2264
2333
|
};
|
|
2265
2334
|
const signalsJson = JSON.stringify(signals);
|
|
2266
2335
|
const signalsHash = await sha256(signalsJson);
|
|
2267
|
-
|
|
2336
|
+
let powSolution;
|
|
2337
|
+
try {
|
|
2338
|
+
powSolution = await this.powManager.solveWithSignalsHash(this.options.siteKey, signalsHash);
|
|
2339
|
+
} finally {
|
|
2340
|
+
this.powManager.reset();
|
|
2341
|
+
}
|
|
2268
2342
|
const powTiming = {
|
|
2269
2343
|
duration: powSolution.duration,
|
|
2270
2344
|
iterations: powSolution.iterations,
|
|
@@ -2275,11 +2349,12 @@ var InvisibleSession = class {
|
|
|
2275
2349
|
return result;
|
|
2276
2350
|
}
|
|
2277
2351
|
async _score(signals, action, powSolution, signalsJson, signalsHash, powTiming) {
|
|
2278
|
-
const url = this.
|
|
2352
|
+
const url = this.serverOrigin();
|
|
2279
2353
|
if (!url) return this._clientSideScore(signals);
|
|
2280
2354
|
try {
|
|
2281
2355
|
const response = await fetch(url + getBasePath() + "/score", {
|
|
2282
2356
|
method: "POST",
|
|
2357
|
+
credentials: "same-origin",
|
|
2283
2358
|
headers: { "Content-Type": "application/json" },
|
|
2284
2359
|
body: JSON.stringify({
|
|
2285
2360
|
siteKey: this.options.siteKey,
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// src/collectors/behavioral.ts
|
|
2
|
+
var MAX_PENDING_KEY_HOLDS = 64;
|
|
3
|
+
var MAX_KEY_HOLD_SAMPLES = 200;
|
|
4
|
+
var MAX_KEY_HOLD_MS = 2e3;
|
|
5
|
+
var KEY_HOLD_MODIFIERS = /* @__PURE__ */ new Set(["Alt", "CapsLock", "Control", "Meta", "NumLock", "ScrollLock", "Shift"]);
|
|
2
6
|
var BehavioralCollector = class {
|
|
3
|
-
constructor() {
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.keyHoldSamples = 0;
|
|
9
|
+
this.keyHoldTotalMs = 0;
|
|
10
|
+
if (options.collectKeyHolds) this.pendingKeyHolds = /* @__PURE__ */ new Map();
|
|
4
11
|
this.mousePositions = [];
|
|
5
12
|
this.mouseVelocities = [];
|
|
6
13
|
this.mouseAccelerations = [];
|
|
@@ -69,12 +76,38 @@ var BehavioralCollector = class {
|
|
|
69
76
|
if (this.scrollEvents.length > 100) this.scrollEvents.shift();
|
|
70
77
|
}
|
|
71
78
|
recordKeyEvent(e) {
|
|
79
|
+
const now = performance.now();
|
|
72
80
|
this.keyEvents.push({
|
|
73
81
|
type: e.type,
|
|
74
82
|
keyLength: e.key ? e.key.length : 0,
|
|
75
83
|
// Don't store actual keys
|
|
76
|
-
t:
|
|
84
|
+
t: now
|
|
77
85
|
});
|
|
86
|
+
this.recordKeyHold(e, now);
|
|
87
|
+
}
|
|
88
|
+
recordKeyHold(e, now) {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
const pending = this.pendingKeyHolds;
|
|
91
|
+
const code = e.code;
|
|
92
|
+
if (!pending || this.keyHoldSamples >= MAX_KEY_HOLD_SAMPLES || !code || code === "Unidentified") {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const target = (_b = (_a = e.composedPath) == null ? void 0 : _a.call(e)[0]) != null ? _b : e.target;
|
|
96
|
+
const excluded = e.isComposing || KEY_HOLD_MODIFIERS.has(e.key) || target instanceof Element && target.matches('textarea, input[type="password"]');
|
|
97
|
+
if (e.type === "keydown" && !e.repeat) {
|
|
98
|
+
pending.delete(code);
|
|
99
|
+
if (!excluded && pending.size < MAX_PENDING_KEY_HOLDS) pending.set(code, now);
|
|
100
|
+
} else if (e.type === "keyup") {
|
|
101
|
+
const started = pending.get(code);
|
|
102
|
+
pending.delete(code);
|
|
103
|
+
if (started === void 0 || excluded) return;
|
|
104
|
+
const duration = now - started;
|
|
105
|
+
if (duration > 0 && duration < MAX_KEY_HOLD_MS) {
|
|
106
|
+
this.keyHoldSamples++;
|
|
107
|
+
this.keyHoldTotalMs += duration;
|
|
108
|
+
if (this.keyHoldSamples === MAX_KEY_HOLD_SAMPLES) pending.clear();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
78
111
|
}
|
|
79
112
|
recordTouch(e) {
|
|
80
113
|
const touches = e.touches && e.touches.length ? e.touches : e.changedTouches;
|
|
@@ -121,8 +154,9 @@ var BehavioralCollector = class {
|
|
|
121
154
|
const positions = this.mousePositions;
|
|
122
155
|
const velocities = this.mouseVelocities;
|
|
123
156
|
const accelerations = this.mouseAccelerations;
|
|
157
|
+
const keyHolds = this.keyHoldSamples > 0 ? { keyHoldSamples: this.keyHoldSamples, keyHoldAvg: this.keyHoldTotalMs / this.keyHoldSamples } : {};
|
|
124
158
|
if (positions.length < 10) {
|
|
125
|
-
return this._getEmptyAnalysis();
|
|
159
|
+
return { ...this._getEmptyAnalysis(), ...keyHolds };
|
|
126
160
|
}
|
|
127
161
|
let avgVelocity = 0;
|
|
128
162
|
let velocityVariance = 0;
|
|
@@ -178,16 +212,30 @@ var BehavioralCollector = class {
|
|
|
178
212
|
eventDeltas: this.eventDeltas.slice(-50),
|
|
179
213
|
eventDeltaVariance,
|
|
180
214
|
mouseEventRate,
|
|
181
|
-
|
|
215
|
+
...this.analyzeScrolling(),
|
|
182
216
|
keyEvents: this.keyEvents.length,
|
|
183
217
|
touchEvents: this.touchEvents.length,
|
|
184
218
|
focusEvents: this.focusEvents.length,
|
|
185
219
|
clickData: this.clickData,
|
|
186
220
|
interactionDuration: Date.now() - this.startTime,
|
|
187
221
|
...touchAnalysis,
|
|
188
|
-
...pointerAnalysis
|
|
222
|
+
...pointerAnalysis,
|
|
223
|
+
...keyHolds
|
|
189
224
|
};
|
|
190
225
|
}
|
|
226
|
+
analyzeScrolling() {
|
|
227
|
+
const events = this.scrollEvents;
|
|
228
|
+
const samples = events.length;
|
|
229
|
+
if (samples < 2) return { scrollEvents: samples };
|
|
230
|
+
let maxStep = 0;
|
|
231
|
+
for (let i = 1; i < samples; i++) {
|
|
232
|
+
const previous = events[i - 1];
|
|
233
|
+
const current = events[i];
|
|
234
|
+
const step = Math.abs(current.x - previous.x) + Math.abs(current.y - previous.y);
|
|
235
|
+
maxStep = Math.max(maxStep, step);
|
|
236
|
+
}
|
|
237
|
+
return { scrollEvents: samples, scrollMorphology: { samples, maxStep } };
|
|
238
|
+
}
|
|
191
239
|
_analyzeTouchPoints(touches) {
|
|
192
240
|
if (!touches || touches.length === 0) {
|
|
193
241
|
return {
|
|
@@ -408,7 +456,7 @@ var BehavioralCollector = class {
|
|
|
408
456
|
eventDeltas: [],
|
|
409
457
|
eventDeltaVariance: 0,
|
|
410
458
|
mouseEventRate: 0,
|
|
411
|
-
|
|
459
|
+
...this.analyzeScrolling(),
|
|
412
460
|
keyEvents: this.keyEvents.length,
|
|
413
461
|
touchEvents: this.touchEvents.length,
|
|
414
462
|
focusEvents: this.focusEvents.length,
|
|
@@ -1030,7 +1078,9 @@ var EnvironmentalCollector = class {
|
|
|
1030
1078
|
hasArial: detectedFonts.includes("Arial"),
|
|
1031
1079
|
hasTimesNewRoman: detectedFonts.includes("Times New Roman"),
|
|
1032
1080
|
hasSegoeUI: detectedFonts.includes("Segoe UI"),
|
|
1081
|
+
hasCalibri: detectedFonts.includes("Calibri"),
|
|
1033
1082
|
hasSFPro: detectedFonts.includes("SF Pro"),
|
|
1083
|
+
hasMenlo: detectedFonts.includes("Menlo"),
|
|
1034
1084
|
hasDejaVuSans: detectedFonts.includes("DejaVu Sans"),
|
|
1035
1085
|
supported: true
|
|
1036
1086
|
};
|
|
@@ -1309,6 +1359,7 @@ var FormAnalyzer = class {
|
|
|
1309
1359
|
});
|
|
1310
1360
|
document.addEventListener("keydown", (e) => this._recordTextareaKey(e), { passive: true });
|
|
1311
1361
|
document.addEventListener("keyup", (e) => this._recordTextareaKey(e), { passive: true });
|
|
1362
|
+
document.addEventListener("paste", (e) => this.recordPaste(e), { passive: true });
|
|
1312
1363
|
document.addEventListener("submit", (e) => this._recordSubmit(e), { capture: true });
|
|
1313
1364
|
this._interceptFormSubmit();
|
|
1314
1365
|
}
|
|
@@ -1332,22 +1383,7 @@ var FormAnalyzer = class {
|
|
|
1332
1383
|
_recordTextareaKey(e) {
|
|
1333
1384
|
const target = e.target;
|
|
1334
1385
|
if ((target == null ? void 0 : target.tagName) !== "TEXTAREA") return;
|
|
1335
|
-
const
|
|
1336
|
-
if (!this.textareaStats.has(textareaId)) {
|
|
1337
|
-
this.textareaStats.set(textareaId, {
|
|
1338
|
-
keydowns: [],
|
|
1339
|
-
keyups: [],
|
|
1340
|
-
intervals: [],
|
|
1341
|
-
lastKeyTime: null,
|
|
1342
|
-
inputWithoutKey: 0,
|
|
1343
|
-
pasteCount: 0,
|
|
1344
|
-
dwellTimes: [],
|
|
1345
|
-
rollovers: 0,
|
|
1346
|
-
activeKeyCount: 0,
|
|
1347
|
-
pendingKeydowns: []
|
|
1348
|
-
});
|
|
1349
|
-
}
|
|
1350
|
-
const stats = this.textareaStats.get(textareaId);
|
|
1386
|
+
const stats = this.getTextareaStats(target);
|
|
1351
1387
|
const now = performance.now();
|
|
1352
1388
|
const isModifier = ["Shift", "Control", "Alt", "Meta", "CapsLock", "NumLock", "ScrollLock"].includes(e.key);
|
|
1353
1389
|
if (e.type === "keydown") {
|
|
@@ -1486,21 +1522,35 @@ var FormAnalyzer = class {
|
|
|
1486
1522
|
textareaKeyboard: Object.keys(textareaAnalysis).length > 0 ? textareaAnalysis : null
|
|
1487
1523
|
};
|
|
1488
1524
|
}
|
|
1489
|
-
|
|
1525
|
+
getTextareaStats(target) {
|
|
1526
|
+
const id = target.id || target.name || "unnamed";
|
|
1527
|
+
const existing = this.textareaStats.get(id);
|
|
1528
|
+
if (existing) return existing;
|
|
1529
|
+
const stats = {
|
|
1530
|
+
keydowns: [],
|
|
1531
|
+
keyups: [],
|
|
1532
|
+
intervals: [],
|
|
1533
|
+
lastKeyTime: null,
|
|
1534
|
+
inputWithoutKey: 0,
|
|
1535
|
+
pasteCount: 0,
|
|
1536
|
+
dwellTimes: [],
|
|
1537
|
+
rollovers: 0,
|
|
1538
|
+
activeKeyCount: 0,
|
|
1539
|
+
pendingKeydowns: []
|
|
1540
|
+
};
|
|
1541
|
+
this.textareaStats.set(id, stats);
|
|
1542
|
+
return stats;
|
|
1543
|
+
}
|
|
1490
1544
|
recordPaste(e) {
|
|
1491
1545
|
const target = e.target;
|
|
1492
1546
|
if ((target == null ? void 0 : target.tagName) !== "TEXTAREA") return;
|
|
1493
|
-
|
|
1494
|
-
if (this.textareaStats.has(textareaId)) {
|
|
1495
|
-
this.textareaStats.get(textareaId).pasteCount++;
|
|
1496
|
-
}
|
|
1547
|
+
this.getTextareaStats(target).pasteCount++;
|
|
1497
1548
|
}
|
|
1498
1549
|
};
|
|
1499
1550
|
var globalFormAnalyzer = null;
|
|
1500
1551
|
function getFormAnalyzer() {
|
|
1501
1552
|
if (!globalFormAnalyzer) {
|
|
1502
1553
|
globalFormAnalyzer = new FormAnalyzer();
|
|
1503
|
-
document.addEventListener("paste", (e) => globalFormAnalyzer.recordPaste(e), { passive: true });
|
|
1504
1554
|
}
|
|
1505
1555
|
return globalFormAnalyzer;
|
|
1506
1556
|
}
|
|
@@ -1596,7 +1646,8 @@ function setBasePath(path) {
|
|
|
1596
1646
|
|
|
1597
1647
|
// src/pow.ts
|
|
1598
1648
|
var PoWManager = class {
|
|
1599
|
-
constructor() {
|
|
1649
|
+
constructor(challengeOrigin = getServerUrl) {
|
|
1650
|
+
this.challengeOrigin = challengeOrigin;
|
|
1600
1651
|
this.workers = [];
|
|
1601
1652
|
this.challenge = null;
|
|
1602
1653
|
this.solution = null;
|
|
@@ -1670,7 +1721,7 @@ var PoWManager = class {
|
|
|
1670
1721
|
this.workers = [];
|
|
1671
1722
|
}
|
|
1672
1723
|
async fetchChallenge(siteKey) {
|
|
1673
|
-
const serverUrl2 =
|
|
1724
|
+
const serverUrl2 = this.challengeOrigin();
|
|
1674
1725
|
if (!serverUrl2) {
|
|
1675
1726
|
return this._generateLocalChallenge();
|
|
1676
1727
|
}
|
|
@@ -1682,7 +1733,12 @@ var PoWManager = class {
|
|
|
1682
1733
|
console.warn(`PoW challenge fetch failed (status ${response.status}), using local challenge`);
|
|
1683
1734
|
return this._generateLocalChallenge();
|
|
1684
1735
|
}
|
|
1685
|
-
|
|
1736
|
+
const { id, challengeId: legacyId, ...data } = await response.json();
|
|
1737
|
+
const challengeId = legacyId != null ? legacyId : id;
|
|
1738
|
+
if (typeof challengeId !== "string" || challengeId.length === 0) {
|
|
1739
|
+
throw new Error("PoW challenge response is missing an ID");
|
|
1740
|
+
}
|
|
1741
|
+
this.challenge = { ...data, challengeId };
|
|
1686
1742
|
return this.challenge;
|
|
1687
1743
|
} catch (e) {
|
|
1688
1744
|
console.warn("PoW challenge fetch failed, using local challenge:", e);
|
|
@@ -1801,7 +1857,7 @@ var CaptchaWidget = class {
|
|
|
1801
1857
|
options
|
|
1802
1858
|
);
|
|
1803
1859
|
this.id = "webdecoy_" + Math.random().toString(36).slice(2, 11);
|
|
1804
|
-
this.behavioral = new BehavioralCollector();
|
|
1860
|
+
this.behavioral = new BehavioralCollector({ collectKeyHolds: true });
|
|
1805
1861
|
this.environmental = new EnvironmentalCollector();
|
|
1806
1862
|
this.temporal = new TemporalCollector();
|
|
1807
1863
|
this.sensor = new SensorCollector();
|
|
@@ -2064,7 +2120,7 @@ var CaptchaWidget = class {
|
|
|
2064
2120
|
reset() {
|
|
2065
2121
|
this.verified = false;
|
|
2066
2122
|
this.token = null;
|
|
2067
|
-
this.behavioral = new BehavioralCollector();
|
|
2123
|
+
this.behavioral = new BehavioralCollector({ collectKeyHolds: true });
|
|
2068
2124
|
this.temporal = new TemporalCollector();
|
|
2069
2125
|
if (this.sensor) this.sensor.detach();
|
|
2070
2126
|
this.sensor = new SensorCollector();
|
|
@@ -2085,6 +2141,8 @@ var InvisibleSession = class {
|
|
|
2085
2141
|
constructor(options) {
|
|
2086
2142
|
this.lastScore = null;
|
|
2087
2143
|
this.listeners = [];
|
|
2144
|
+
this.challengeRequest = null;
|
|
2145
|
+
this.scoring = null;
|
|
2088
2146
|
this.options = Object.assign(
|
|
2089
2147
|
{
|
|
2090
2148
|
siteKey: null,
|
|
@@ -2097,11 +2155,11 @@ var InvisibleSession = class {
|
|
|
2097
2155
|
options
|
|
2098
2156
|
);
|
|
2099
2157
|
this.id = "webdecoy_inv_" + Math.random().toString(36).slice(2, 11);
|
|
2100
|
-
this.behavioral = new BehavioralCollector();
|
|
2158
|
+
this.behavioral = new BehavioralCollector({ collectKeyHolds: true });
|
|
2101
2159
|
this.environmental = new EnvironmentalCollector();
|
|
2102
2160
|
this.temporal = new TemporalCollector();
|
|
2103
2161
|
this.sensor = new SensorCollector();
|
|
2104
|
-
this.powManager = new PoWManager();
|
|
2162
|
+
this.powManager = new PoWManager(() => this.serverOrigin());
|
|
2105
2163
|
this.startTime = Date.now();
|
|
2106
2164
|
this._init();
|
|
2107
2165
|
}
|
|
@@ -2113,14 +2171,10 @@ var InvisibleSession = class {
|
|
|
2113
2171
|
document.addEventListener("keydown", recordFirst, { once: true });
|
|
2114
2172
|
document.addEventListener("scroll", recordFirst, { once: true });
|
|
2115
2173
|
if (this.options.autoScore) this._attachToForms();
|
|
2116
|
-
|
|
2174
|
+
this.challengeRequest = this.powManager.fetchChallenge(this.options.siteKey);
|
|
2117
2175
|
}
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
await this.powManager.fetchChallenge(this.options.siteKey);
|
|
2121
|
-
} catch (e) {
|
|
2122
|
-
console.warn("PoW challenge fetch failed:", e);
|
|
2123
|
-
}
|
|
2176
|
+
serverOrigin() {
|
|
2177
|
+
return this.options.serverUrl || getServerUrl();
|
|
2124
2178
|
}
|
|
2125
2179
|
_attachListeners() {
|
|
2126
2180
|
const handlers = {
|
|
@@ -2182,6 +2236,16 @@ var InvisibleSession = class {
|
|
|
2182
2236
|
}
|
|
2183
2237
|
}
|
|
2184
2238
|
async execute(action = "") {
|
|
2239
|
+
const run = () => this._collectAndScore(action);
|
|
2240
|
+
const score = this.scoring ? this.scoring.then(run, run) : run();
|
|
2241
|
+
this.scoring = score;
|
|
2242
|
+
try {
|
|
2243
|
+
return await score;
|
|
2244
|
+
} finally {
|
|
2245
|
+
if (this.scoring === score) this.scoring = null;
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
async _collectAndScore(action) {
|
|
2185
2249
|
var _a;
|
|
2186
2250
|
const elapsed = Date.now() - this.startTime;
|
|
2187
2251
|
if (elapsed < this.options.minCollectionTime) {
|
|
@@ -2196,6 +2260,11 @@ var InvisibleSession = class {
|
|
|
2196
2260
|
]);
|
|
2197
2261
|
const formAnalysis = getFormAnalyzer().analyze();
|
|
2198
2262
|
const sensorData = this.sensor.analyze();
|
|
2263
|
+
let challenge = await ((_a = this.challengeRequest) != null ? _a : this.powManager.fetchChallenge(this.options.siteKey));
|
|
2264
|
+
this.challengeRequest = null;
|
|
2265
|
+
if (challenge.expiresAt <= Date.now()) {
|
|
2266
|
+
challenge = await this.powManager.fetchChallenge(this.options.siteKey);
|
|
2267
|
+
}
|
|
2199
2268
|
const signals = {
|
|
2200
2269
|
behavioral: behavioralData,
|
|
2201
2270
|
environmental: { ...envData, rafConsistency: rafData, ...asyncEnvData, sensor: sensorData },
|
|
@@ -2205,7 +2274,7 @@ var InvisibleSession = class {
|
|
|
2205
2274
|
sessionId: this.id,
|
|
2206
2275
|
siteKey: this.options.siteKey,
|
|
2207
2276
|
action,
|
|
2208
|
-
challengeNonce:
|
|
2277
|
+
challengeNonce: challenge.nonce || null,
|
|
2209
2278
|
timestamp: Date.now(),
|
|
2210
2279
|
userAgent: navigator.userAgent,
|
|
2211
2280
|
screenSize: `${screen.width}x${screen.height}`,
|
|
@@ -2217,7 +2286,12 @@ var InvisibleSession = class {
|
|
|
2217
2286
|
};
|
|
2218
2287
|
const signalsJson = JSON.stringify(signals);
|
|
2219
2288
|
const signalsHash = await sha256(signalsJson);
|
|
2220
|
-
|
|
2289
|
+
let powSolution;
|
|
2290
|
+
try {
|
|
2291
|
+
powSolution = await this.powManager.solveWithSignalsHash(this.options.siteKey, signalsHash);
|
|
2292
|
+
} finally {
|
|
2293
|
+
this.powManager.reset();
|
|
2294
|
+
}
|
|
2221
2295
|
const powTiming = {
|
|
2222
2296
|
duration: powSolution.duration,
|
|
2223
2297
|
iterations: powSolution.iterations,
|
|
@@ -2228,11 +2302,12 @@ var InvisibleSession = class {
|
|
|
2228
2302
|
return result;
|
|
2229
2303
|
}
|
|
2230
2304
|
async _score(signals, action, powSolution, signalsJson, signalsHash, powTiming) {
|
|
2231
|
-
const url = this.
|
|
2305
|
+
const url = this.serverOrigin();
|
|
2232
2306
|
if (!url) return this._clientSideScore(signals);
|
|
2233
2307
|
try {
|
|
2234
2308
|
const response = await fetch(url + getBasePath() + "/score", {
|
|
2235
2309
|
method: "POST",
|
|
2310
|
+
credentials: "same-origin",
|
|
2236
2311
|
headers: { "Content-Type": "application/json" },
|
|
2237
2312
|
body: JSON.stringify({
|
|
2238
2313
|
siteKey: this.options.siteKey,
|
package/dist/webdecoy.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var WebDecoyCaptchaBundle=(()=>{var G=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Ee=Object.prototype.hasOwnProperty;var xe=(o,e)=>{for(var t in e)G(o,t,{get:e[t],enumerable:!0})},Te=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of _e(e))!Ee.call(o,r)&&r!==t&&G(o,r,{get:()=>e[r],enumerable:!(n=be(e,r))||n.enumerable});return o};var ke=o=>Te(G({},"__esModule",{value:!0}),o);var Ne={};xe(Ne,{WebDecoyCaptcha:()=>U,createClearanceFetch:()=>ne,readClearanceChallenge:()=>V});var k=class{constructor(){this.mousePositions=[],this.mouseVelocities=[],this.mouseAccelerations=[],this.scrollEvents=[],this.keyEvents=[],this.touchEvents=[],this.touchMultiTouchSeen=!1,this.touchIdentifiers=new Set,this.pointerPoints=[],this.focusEvents=[],this.clickData=null,this.startTime=Date.now(),this.lastMousePos=null,this.lastMouseTime=null,this.lastVelocity=null,this.eventDeltas=[]}recordMouseMove(e){let t=performance.now(),n={x:e.clientX,y:e.clientY,t};if(this.mousePositions.push(n),this.lastMousePos&&this.lastMouseTime){let r=t-this.lastMouseTime;if(r>0){let i=e.clientX-this.lastMousePos.x,s=e.clientY-this.lastMousePos.y,c=Math.sqrt(i*i+s*s)/r;if(this.mouseVelocities.push({v:c,t}),this.eventDeltas.push(r),this.lastVelocity!==null){let l=(c-this.lastVelocity)/r;this.mouseAccelerations.push({a:l,t})}this.lastVelocity=c}}this.lastMousePos={x:e.clientX,y:e.clientY},this.lastMouseTime=t,this.mousePositions.length>500&&(this.mousePositions.shift(),this.mouseVelocities.length>500&&this.mouseVelocities.shift(),this.mouseAccelerations.length>500&&this.mouseAccelerations.shift())}recordMouseDown(e){this.clickData={x:e.clientX,y:e.clientY,button:e.button,downTime:performance.now()}}recordMouseUp(e){this.clickData&&(this.clickData.upTime=performance.now(),this.clickData.holdDuration=this.clickData.upTime-this.clickData.downTime)}recordScroll(e){this.scrollEvents.push({x:window.scrollX,y:window.scrollY,t:performance.now()}),this.scrollEvents.length>100&&this.scrollEvents.shift()}recordKeyEvent(e){this.keyEvents.push({type:e.type,keyLength:e.key?e.key.length:0,t:performance.now()})}recordTouch(e){let t=e.touches&&e.touches.length?e.touches:e.changedTouches;if(!t||t.length===0)return;t.length>1&&(this.touchMultiTouchSeen=!0);let n=t[0];typeof n.identifier=="number"&&this.touchIdentifiers.add(n.identifier),this.touchEvents.push({x:n.clientX,y:n.clientY,t:performance.now(),force:typeof n.force=="number"?n.force:0,radiusX:typeof n.radiusX=="number"?n.radiusX:0,radiusY:typeof n.radiusY=="number"?n.radiusY:0,rotationAngle:typeof n.rotationAngle=="number"?n.rotationAngle:0,identifier:typeof n.identifier=="number"?n.identifier:-1,touchCount:t.length}),this.touchEvents.length>500&&this.touchEvents.shift()}recordPointer(e){this.pointerPoints.push({x:e.clientX,y:e.clientY,t:performance.now(),type:e.type,pressure:typeof e.pressure=="number"?e.pressure:0,tiltX:typeof e.tiltX=="number"?e.tiltX:0,tiltY:typeof e.tiltY=="number"?e.tiltY:0,tangentialPressure:typeof e.tangentialPressure=="number"?e.tangentialPressure:0,pointerType:e.pointerType||"unknown"}),this.pointerPoints.length>500&&this.pointerPoints.shift()}recordFocus(e){var t;this.focusEvents.push({type:e.type,target:(t=e.target)==null?void 0:t.tagName,t:performance.now()})}analyze(){let e=this.mousePositions,t=this.mouseVelocities,n=this.mouseAccelerations;if(e.length<10)return this._getEmptyAnalysis();let r=0,i=0;t.length>0&&(r=t.reduce((v,d)=>v+d.v,0)/t.length,i=t.reduce((v,d)=>v+Math.pow(d.v-r,2),0)/t.length);let s=0,a=0;if(n.length>0){s=n.reduce((m,v)=>m+v.a,0)/n.length;for(let m=1;m<n.length;m++)Math.sign(n[m].a)!==Math.sign(n[m-1].a)&&a++}let c=this._detectMicroTremor(e),l=this._calculateStraightLineRatio(e),u=0;for(let m=1;m<e.length;m++){let v=Math.abs(e[m].x-e[m-1].x),d=Math.abs(e[m].y-e[m-1].y);v<3&&d<3&&(v>0||d>0)&&u++}let h=this._countDirectionChanges(e),g=this._variance(this.eventDeltas),f=e.length>1?e.length/((e[e.length-1].t-e[0].t)/1e3):0,p=0;for(let m=1;m<e.length;m++){let v=e[m].x-e[m-1].x,d=e[m].y-e[m-1].y;p+=Math.sqrt(v*v+d*d)}let y=this._analyzeTouchPoints(this.touchEvents),w=this._analyzePointerPoints(this.pointerPoints);return{totalPoints:e.length,trajectoryLength:p,avgVelocity:r,velocityVariance:i,avgAcceleration:s,accelerationChanges:a,microTremorScore:c,straightLineRatio:l,microMovements:u,directionChanges:h,eventDeltas:this.eventDeltas.slice(-50),eventDeltaVariance:g,mouseEventRate:f,scrollEvents:this.scrollEvents.length,keyEvents:this.keyEvents.length,touchEvents:this.touchEvents.length,focusEvents:this.focusEvents.length,clickData:this.clickData,interactionDuration:Date.now()-this.startTime,...y,...w}}_analyzeTouchPoints(e){if(!e||e.length===0)return{touchTotalPoints:0,touchTrajectoryLength:0,touchAvgVelocity:0,touchVelocityVariance:0,touchMicroTremorScore:0,touchStraightLineRatio:0,touchDirectionChanges:0,touchForceMin:0,touchForceMax:0,touchForceVariance:0,touchRadiusMin:0,touchRadiusMax:0,touchRadiusVariance:0,touchMultiTouchSeen:this.touchMultiTouchSeen,touchUniqueIdentifiers:this.touchIdentifiers.size,touchForceAllZero:!1,touchForceAllOne:!1};let t=0,n=[];for(let l=1;l<e.length;l++){let u=e[l].x-e[l-1].x,h=e[l].y-e[l-1].y,g=Math.sqrt(u*u+h*h);t+=g;let f=e[l].t-e[l-1].t;f>0&&n.push(g/f)}let r=n.length>0?n.reduce((l,u)=>l+u,0)/n.length:0,i=e.map(l=>l.force),s=e.map(l=>Math.max(l.radiusX||0,l.radiusY||0)),a=i.length>0&&i.every(l=>l===0),c=i.length>0&&i.every(l=>l===1);return{touchTotalPoints:e.length,touchTrajectoryLength:t,touchAvgVelocity:r,touchVelocityVariance:this._variance(n),touchMicroTremorScore:this._detectMicroTremor(e),touchStraightLineRatio:this._calculateStraightLineRatio(e),touchDirectionChanges:this._countDirectionChanges(e),touchForceMin:i.length>0?Math.min(...i):0,touchForceMax:i.length>0?Math.max(...i):0,touchForceVariance:this._variance(i),touchRadiusMin:s.length>0?Math.min(...s):0,touchRadiusMax:s.length>0?Math.max(...s):0,touchRadiusVariance:this._variance(s),touchMultiTouchSeen:this.touchMultiTouchSeen,touchUniqueIdentifiers:this.touchIdentifiers.size,touchForceAllZero:a,touchForceAllOne:c}}_analyzePointerPoints(e){if(!e||e.length===0)return{pointerEvents:0,pointerAvgPressure:0,pointerPressureVariance:0,pointerMaxTilt:0,pointerHasNonMouseType:!1,pointerTypes:[]};let t=e.map(s=>s.pressure),n=t.length>0?t.reduce((s,a)=>s+a,0)/t.length:0,r=0,i=new Set;for(let s of e){let a=Math.abs(s.tiltX||0)+Math.abs(s.tiltY||0);a>r&&(r=a),s.pointerType&&i.add(s.pointerType)}return{pointerEvents:e.length,pointerAvgPressure:n,pointerPressureVariance:this._variance(t),pointerMaxTilt:r,pointerHasNonMouseType:Array.from(i).some(s=>s!=="mouse"&&s!=="unknown"),pointerTypes:Array.from(i)}}analyzeClick(e,t,n){let r=this.mousePositions;if(r.length<5)return this._getEmptyClickAnalysis();let i=r.slice(-20),s=n.left+n.width/2,a=n.top+n.height/2,c=Math.sqrt(Math.pow(e-s,2)+Math.pow(t-a,2)),l=0,u=0;for(let d=1;d<r.length;d++){let b=Math.sqrt(Math.pow(r[d].x-r[d-1].x,2)+Math.pow(r[d].y-r[d-1].y,2));u+=b,r[d].x>=n.left&&r[d].x<=n.right&&r[d].y>=n.top&&r[d].y<=n.bottom||(l+=b)}let h=u>0?l/u:0,g=0,f=!1,p=!1;for(let d of i){let b=d.x>=n.left&&d.x<=n.right&&d.y>=n.top&&d.y<=n.bottom;f&&!b&&(p=!0),p&&b&&(g++,p=!1),f=b}let y=0;for(let d=i.length-1;d>=0;d--){let b=i[d],P=b.x>=n.left&&b.x<=n.right&&b.y>=n.top&&b.y<=n.bottom;if(P&&d<i.length-1)y=i[i.length-1].t-b.t;else if(!P)break}let w=Math.sqrt(Math.pow(i[i.length-1].x-i[0].x,2)+Math.pow(i[i.length-1].y-i[0].y,2)),m=0;for(let d=1;d<i.length;d++)m+=Math.sqrt(Math.pow(i[d].x-i[d-1].x,2)+Math.pow(i[d].y-i[d-1].y,2));let v=m>0?w/m:1;return{clickPrecision:c,explorationRatio:h,overshootCorrections:g,hoverTime:y,approachDirectness:v,approachPoints:i.length}}_detectMicroTremor(e){if(e.length<20)return .5;let t=5,n=0;for(let i=t;i<e.length-t;i++){let s=0,a=0;for(let l=i-t;l<=i+t;l++)s+=e[l].x,a+=e[l].y;s/=t*2+1,a/=t*2+1;let c=Math.sqrt(Math.pow(e[i].x-s,2)+Math.pow(e[i].y-a,2));n+=c}let r=n/(e.length-t*2);return Math.min(1,r/2)}_calculateStraightLineRatio(e){if(e.length<3)return 0;let t=0,n=0;for(let r=2;r<e.length;r++){let i=e[r-2],s=e[r-1],a=e[r],c=Math.atan2(s.y-i.y,s.x-i.x),l=Math.atan2(a.y-s.y,a.x-s.x),u=Math.abs(l-c);n++,u<.1&&t++}return n>0?t/n:0}_countDirectionChanges(e){let t=0;for(let n=2;n<e.length;n++){let r=Math.atan2(e[n-1].y-e[n-2].y,e[n-1].x-e[n-2].x),i=Math.atan2(e[n].y-e[n-1].y,e[n].x-e[n-1].x);Math.abs(i-r)>Math.PI/6&&t++}return t}_variance(e){if(e.length===0)return 0;let t=e.reduce((n,r)=>n+r,0)/e.length;return e.reduce((n,r)=>n+Math.pow(r-t,2),0)/e.length}_getEmptyAnalysis(){return{totalPoints:0,trajectoryLength:0,avgVelocity:0,velocityVariance:0,avgAcceleration:0,accelerationChanges:0,microTremorScore:.5,straightLineRatio:0,microMovements:0,directionChanges:0,eventDeltas:[],eventDeltaVariance:0,mouseEventRate:0,scrollEvents:this.scrollEvents.length,keyEvents:this.keyEvents.length,touchEvents:this.touchEvents.length,focusEvents:this.focusEvents.length,clickData:this.clickData,interactionDuration:Date.now()-this.startTime,...this._analyzeTouchPoints(this.touchEvents),...this._analyzePointerPoints(this.pointerPoints)}}_getEmptyClickAnalysis(){return{clickPrecision:0,explorationRatio:0,overshootCorrections:0,hoverTime:0,approachDirectness:1,approachPoints:0}}};var T=class{collect(){return{webdriver:this._detectWebdriver(),automationFlags:this._getAutomationFlags(),cdp:this._detectCDP(),playwright:this._detectPlaywright(),canvasHash:this._getCanvasHash(),webglInfo:this._getWebGLInfo(),audioInfo:this._getAudioInfo(),headlessIndicators:this._getHeadlessIndicators(),screen:this._getScreenInfo(),navigator:this._getNavigatorInfo(),jsExecutionTime:this._measureJSExecution(),mathFingerprint:this._getMathFingerprint(),errorFingerprint:this._getErrorFingerprint(),domRectFingerprint:this._getDOMRectFingerprint(),cssMediaQueries:this._getCSSMediaQueries(),permissionsInfo:this._getPermissionsInfo(),fontsInfo:this._getFontsInfo(),lieDetection:this._getLieDetection()}}async collectAsync(){let[e,t,n]=await Promise.all([this._getSpeechInfo(),this._getWebRTCInfo(),this._checkWorkerConsistency()]);return{speechInfo:e,webrtcInfo:t,workerConsistency:n}}_detectWebdriver(){let e=navigator,t=window;return!!(e.webdriver||t.document.__webdriver_evaluate||t.document.__selenium_evaluate||t.document.__webdriver_script_fn||t.document.__webdriver_script_func||t.document.__webdriver_script_function||t.document.$cdc_asdjflasutopfhvcZLmcfl_||t.document.$wdc_||t._Selenium_IDE_Recorder||t._phantom||t.__nightmare||t.callPhantom||t._phantom)}_getAutomationFlags(){let e=navigator,t=window;return{webdriver:!!e.webdriver,domAutomation:!!t.domAutomation,domAutomationController:!!t.domAutomationController,_selenium:!!t._selenium,__webdriver_script_fn:!!t.__webdriver_script_fn,__driver_evaluate:!!t.__driver_evaluate,__webdriver_evaluate:!!t.__webdriver_evaluate,__fxdriver_evaluate:!!t.__fxdriver_evaluate,__driver_unwrapped:!!t.__driver_unwrapped,__webdriver_unwrapped:!!t.__webdriver_unwrapped,__fxdriver_unwrapped:!!t.__fxdriver_unwrapped,_Selenium_IDE_Recorder:!!t._Selenium_IDE_Recorder,calledSelenium:!!t.calledSelenium,$chrome_asyncScriptInfo:!!t.$chrome_asyncScriptInfo,$cdc_asdjflasutopfhvcZLmcfl_:!!t.$cdc_asdjflasutopfhvcZLmcfl_,_phantom:!!t._phantom,callPhantom:!!t.callPhantom,__nightmare:!!t.__nightmare,__lastWatirAlert:!!t.__lastWatirAlert,__lastWatirConfirm:!!t.__lastWatirConfirm,__lastWatirPrompt:!!t.__lastWatirPrompt,plugins:navigator.plugins?navigator.plugins.length:0,languages:navigator.languages&&navigator.languages.length>0,mimeTypes:navigator.mimeTypes?navigator.mimeTypes.length:0,cookieEnabled:navigator.cookieEnabled,doNotTrack:navigator.doNotTrack,chrome:!!t.chrome,chromeRuntime:!!(t.chrome&&t.chrome.runtime&&t.chrome.runtime.id),permissionsAPI:!!navigator.permissions}}_detectPlaywright(){try{let e=[];Object.getOwnPropertyNames(window).filter(i=>i.startsWith("__pw")||i.startsWith("__playwright")).length>0&&e.push("playwright_globals");let n=Object.getPrototypeOf(navigator);return Object.getOwnPropertyDescriptor(n,"webdriver")||e.push("webdriver_deleted"),{detected:e.length>0,signals:e}}catch{return{detected:!1,signals:[]}}}_detectCDP(){try{let e=[];Object.keys(window).filter(n=>n.startsWith("cdc_")).length>0&&e.push("chromedriver_cdc"),"__webdriver_evaluate"in window&&e.push("selenium_evaluate"),"__driver_evaluate"in window&&e.push("selenium_driver_evaluate"),"__webdriver_unwrapped"in window&&e.push("selenium_unwrapped"),"__driver_unwrapped"in window&&e.push("selenium_driver_unwrapped"),"__selenium_evaluate"in window&&e.push("selenium_direct"),"__fxdriver_evaluate"in window&&e.push("firefox_driver"),"__fxdriver_unwrapped"in window&&e.push("firefox_driver_unwrapped"),"__puppeteer_evaluation_script__"in window&&e.push("puppeteer_eval"),document.__webdriver_script_fn&&e.push("cdp_script_injection");try{let n=Object.getOwnPropertyDescriptor(navigator,"webdriver");n&&typeof n.get=="function"&&n.get.toString().indexOf("[native code]")===-1&&e.push("webdriver_getter_modified")}catch{}return{detected:e.length>0,signals:e}}catch{return{detected:!1,signals:[]}}}_getCanvasHash(){try{let e=document.createElement("canvas");e.width=200,e.height=50;let t=e.getContext("2d");t.textBaseline="top",t.font="14px Arial",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText("FCaptcha",2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText("FCaptcha",4,17);let n=e.toDataURL(),r=0;for(let i=0;i<n.length;i++)r=(r<<5)-r+n.charCodeAt(i),r=r&r;return{hash:r.toString(16),dataLength:n.length,supported:!0}}catch{return{error:!0,supported:!1}}}_getWebGLInfo(){try{let e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return{supported:!1};let n=t.getExtension("WEBGL_debug_renderer_info"),r=n?t.getParameter(n.UNMASKED_VENDOR_WEBGL):"unknown",i=n?t.getParameter(n.UNMASKED_RENDERER_WEBGL):"unknown",s=i.toLowerCase(),a=s.includes("swiftshader")||s.includes("llvmpipe")||s.includes("softpipe")||s.includes("virtualbox")||s.includes("vmware");return{supported:!0,vendor:r,renderer:i,version:t.getParameter(t.VERSION),shadingVersion:t.getParameter(t.SHADING_LANGUAGE_VERSION),suspiciousRenderer:a}}catch{return{supported:!1,error:!0}}}_getAudioInfo(){try{let e=window,t=e.AudioContext||e.webkitAudioContext;if(!t)return{supported:!1};let n=new t,r={supported:!0,sampleRate:n.sampleRate,state:n.state,baseLatency:n.baseLatency};return n.close().catch(()=>{}),r}catch{return{supported:!1,error:!0}}}_getLieDetection(){try{let e=window,t=[],n=i=>{try{return typeof i=="function"&&i.toString().indexOf("[native code]")===-1}catch{return!1}},r=(i,s)=>{n(i)&&t.push(s)};r(Function.prototype.toString,"Function.prototype.toString"),r(navigator.permissions&&navigator.permissions.query,"navigator.permissions.query"),r(e.Notification&&e.Notification.requestPermission,"Notification.requestPermission"),r(e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype.toDataURL,"HTMLCanvasElement.toDataURL"),r(e.WebGLRenderingContext&&e.WebGLRenderingContext.prototype.getParameter,"WebGLRenderingContext.getParameter"),r(navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices,"mediaDevices.enumerateDevices");try{let i=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(navigator),"webdriver")||Object.getOwnPropertyDescriptor(navigator,"webdriver");i&&typeof i.get=="function"&&i.get.toString().indexOf("[native code]")===-1&&t.push("navigator.webdriver getter")}catch{}return{supported:!0,patched:t,patchedCount:t.length}}catch{return{supported:!1}}}_getHeadlessIndicators(){let e=navigator;return{hasOuterDimensions:window.outerWidth>0&&window.outerHeight>0,innerEqualsOuter:window.innerWidth===window.outerWidth&&window.innerHeight===window.outerHeight,screenColorDepth:window.screen.colorDepth,screenPixelDepth:window.screen.pixelDepth,connectionType:e.connection?e.connection.type:"unknown",connectionRtt:e.connection?e.connection.rtt:-1,notificationPermission:typeof Notification!="undefined"?Notification.permission:"unsupported",hasBattery:"getBattery"in navigator,hasCredentials:"credentials"in navigator,hasMediaDevices:"mediaDevices"in navigator}}_getScreenInfo(){return{width:screen.width,height:screen.height,colorDepth:screen.colorDepth,pixelRatio:window.devicePixelRatio,availWidth:screen.availWidth,availHeight:screen.availHeight,innerWidth:window.innerWidth,innerHeight:window.innerHeight}}_getNavigatorInfo(){var t;let e=navigator;return{language:navigator.language,languageCount:((t=navigator.languages)==null?void 0:t.length)||0,platform:navigator.platform,hardwareConcurrency:navigator.hardwareConcurrency,deviceMemory:e.deviceMemory,maxTouchPoints:navigator.maxTouchPoints||0,vendor:navigator.vendor,userAgent:navigator.userAgent,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:new Date().getTimezoneOffset()}}_measureJSExecution(){let e={},t=performance.now(),n=0;for(let s=0;s<1e3;s++)n+=Math.sqrt(s)*Math.sin(s);e.mathOps=performance.now()-t,e.mathSink=n,t=performance.now();let r=[];for(let s=0;s<1e3;s++)r.push(s);e.arrayOps=performance.now()-t,e.arrayLen=r.length,t=performance.now();let i="";for(let s=0;s<100;s++)i+="a";return e.stringOps=performance.now()-t,e.stringLen=i.length,e}async measureRAFConsistency(){return new Promise(e=>{let t=[],n=0,r=10;function i(s){if(t.push(s),n++,n<r)requestAnimationFrame(i);else{let a=[];for(let u=1;u<t.length;u++)a.push(t[u]-t[u-1]);let c=a.reduce((u,h)=>u+h,0)/a.length,l=a.reduce((u,h)=>u+Math.pow(h-c,2),0)/a.length;e({avgFrameTime:c,frameTimeVariance:l,frames:r})}}requestAnimationFrame(i)})}_getMathFingerprint(){try{let e={acos:Math.acos(.123456789),acosh:Math.acosh(1e308),asin:Math.asin(.123456789),asinh:Math.asinh(1),atanh:Math.atanh(.5),cbrt:Math.cbrt(100),cosh:Math.cosh(1),expm1:Math.expm1(1),log1p:Math.log1p(10),sinh:Math.sinh(1),tan:Math.tan(-1e308),tanh:Math.tanh(1),pow:Math.pow(Math.PI,-100),sin:Math.sin(Math.PI)},t=Object.values(e).map(r=>String(r)).join(","),n=0;for(let r=0;r<t.length;r++)n=(n<<5)-n+t.charCodeAt(r),n=n&n;return{hash:n.toString(16),sinPi:e.sin,tanLarge:e.tan,supported:!0}}catch{return{supported:!1,error:!0}}}_getErrorFingerprint(){try{let e={};try{null.foo}catch(r){e.typeError=r.message}try{[].length=-1}catch(r){e.rangeError=r.message}try{decodeURIComponent("%")}catch(r){e.uriError=r.message}try{({}).undefinedMethod()}catch(r){e.refTypeError=r.message}let t=Object.values(e).join("|"),n=0;for(let r=0;r<t.length;r++)n=(n<<5)-n+t.charCodeAt(r),n=n&n;return{hash:n.toString(16),typeError:e.typeError,supported:!0}}catch{return{supported:!1,error:!0}}}_getDOMRectFingerprint(){try{let e=document.createElement("div");e.style.cssText="position:absolute;left:-9999px;font-size:16px;font-family:Arial,sans-serif;";let t=document.createElement("span");t.textContent="FCaptcha Test String 123",e.appendChild(t);let n=document.createElement("span");n.style.cssText="letter-spacing:1px;word-spacing:2px;",n.textContent="WWWW 0000",e.appendChild(n),document.body.appendChild(e);let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),s=document.createRange();s.selectNode(t);let a=s.getBoundingClientRect();document.body.removeChild(e);let l=[r.width,r.height,r.x,r.y,i.width,i.height,a.width,a.height].map(h=>h.toFixed(6)).join(","),u=0;for(let h=0;h<l.length;h++)u=(u<<5)-u+l.charCodeAt(h),u=u&u;return{hash:u.toString(16),rectAWidth:r.width,rectBWidth:i.width,rangeWidth:a.width,supported:!0}}catch{return{supported:!1,error:!0}}}_getCSSMediaQueries(){try{return{...{prefersColorScheme:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",prefersReducedMotion:window.matchMedia("(prefers-reduced-motion: reduce)").matches,prefersReducedTransparency:window.matchMedia("(prefers-reduced-transparency: reduce)").matches,prefersContrast:window.matchMedia("(prefers-contrast: more)").matches?"more":window.matchMedia("(prefers-contrast: less)").matches?"less":"no-preference",anyHover:window.matchMedia("(any-hover: hover)").matches,anyPointer:window.matchMedia("(any-pointer: fine)").matches?"fine":window.matchMedia("(any-pointer: coarse)").matches?"coarse":"none",hover:window.matchMedia("(hover: hover)").matches,pointer:window.matchMedia("(pointer: fine)").matches?"fine":window.matchMedia("(pointer: coarse)").matches?"coarse":"none",colorGamut:window.matchMedia("(color-gamut: p3)").matches?"p3":window.matchMedia("(color-gamut: srgb)").matches?"srgb":"none",displayMode:window.matchMedia("(display-mode: standalone)").matches?"standalone":window.matchMedia("(display-mode: fullscreen)").matches?"fullscreen":"browser",orientation:window.matchMedia("(orientation: portrait)").matches?"portrait":"landscape",dynamicRange:window.matchMedia("(dynamic-range: high)").matches?"high":"standard",forcedColors:window.matchMedia("(forced-colors: active)").matches},supported:!0}}catch{return{supported:!1,error:!0}}}_getPermissionsInfo(){try{return{hasPermissionsAPI:"permissions"in navigator,hasClipboard:"clipboard"in navigator,hasShare:"share"in navigator,hasCredentials:"credentials"in navigator,hasBluetooth:"bluetooth"in navigator,hasUsb:"usb"in navigator,hasSerial:"serial"in navigator,hasHid:"hid"in navigator,hasXR:"xr"in navigator,hasGeolocation:"geolocation"in navigator,hasMIDI:"requestMIDIAccess"in navigator,supported:!0}}catch{return{supported:!1,error:!0}}}_getFontsInfo(){try{let e=["monospace","sans-serif","serif"],t=["Arial","Helvetica","Times New Roman","Courier New","Georgia","Verdana","Trebuchet MS","Comic Sans MS","Impact","Lucida Console","Menlo","Monaco","SF Pro","Helvetica Neue","Segoe UI","Consolas","Calibri","Cambria","DejaVu Sans","Liberation Sans","Ubuntu","Cantarell","MS Gothic","Meiryo","SimHei","Microsoft YaHei"],n=document.createElement("canvas");n.width=400,n.height=40;let r=n.getContext("2d"),i="mmMWWLLiiff00",s="72px",a={};for(let h of e)r.font=s+" "+h,a[h]=r.measureText(i).width;let c=[];for(let h of t){let g=!1;for(let f of e)if(r.font=s+' "'+h+'", '+f,r.measureText(i).width!==a[f]){g=!0;break}g&&c.push(h)}let l=c.join(","),u=0;for(let h=0;h<l.length;h++)u=(u<<5)-u+l.charCodeAt(h),u=u&u;return{hash:u.toString(16),count:c.length,hasArial:c.includes("Arial"),hasTimesNewRoman:c.includes("Times New Roman"),hasSegoeUI:c.includes("Segoe UI"),hasSFPro:c.includes("SF Pro"),hasDejaVuSans:c.includes("DejaVu Sans"),supported:!0}}catch{return{supported:!1,error:!0}}}async _getSpeechInfo(){try{if(!("speechSynthesis"in window))return{supported:!1};let t=await new Promise(c=>{let l=speechSynthesis.getVoices();if(l.length>0){c(l);return}let u=setTimeout(()=>c([]),1e3);speechSynthesis.onvoiceschanged=()=>{clearTimeout(u),c(speechSynthesis.getVoices())}}),n=t.filter(c=>c.localService),r=t.find(c=>c.default),i=[...new Set(t.map(c=>c.lang))],s=t.map(c=>c.name).sort().join(","),a=0;for(let c=0;c<s.length;c++)a=(a<<5)-a+s.charCodeAt(c),a=a&a;return{hash:a.toString(16),totalVoices:t.length,localVoices:n.length,languages:i.length,defaultVoiceLang:(r==null?void 0:r.lang)||null,hasGoogleVoices:t.some(c=>c.name.includes("Google")),hasMicrosoftVoices:t.some(c=>c.name.includes("Microsoft")),hasAppleVoices:t.some(c=>c.name.includes("Samantha")||c.name.includes("Alex")),supported:!0}}catch{return{supported:!1,error:!0}}}async _getWebRTCInfo(){try{let e={supported:"RTCPeerConnection"in window,mediaDevices:{supported:!1},localIPs:[]};if(!e.supported)return e;if(navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices)try{let t=await navigator.mediaDevices.enumerateDevices();e.mediaDevices={supported:!0,audioInputs:t.filter(n=>n.kind==="audioinput").length,audioOutputs:t.filter(n=>n.kind==="audiooutput").length,videoInputs:t.filter(n=>n.kind==="videoinput").length,totalDevices:t.length}}catch{e.mediaDevices={supported:!1,error:!0}}try{let t=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]}),n=new Set;t.onicecandidate=r=>{if(r.candidate){let i=r.candidate.candidate,s=/([0-9]{1,3}\.){3}[0-9]{1,3}/g,a=i.match(s);a&&a.forEach(c=>{(c.startsWith("192.168.")||c.startsWith("10.")||c.startsWith("172.")||c.startsWith("169.254."))&&n.add(c)})}},t.createDataChannel(""),await t.createOffer().then(r=>t.setLocalDescription(r)),await new Promise(r=>setTimeout(r,500)),e.localIPs=Array.from(n),e.hasLocalIP=n.size>0,t.close()}catch{e.localIPError=!0}return e}catch{return{supported:!1,error:!0}}}async _checkWorkerConsistency(){try{if(typeof Worker=="undefined")return{supported:!1};let e=navigator,t=`
|
|
1
|
+
"use strict";var WebDecoyCaptchaBundle=(()=>{var X=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Ee=Object.prototype.hasOwnProperty;var Se=(r,e)=>{for(var t in e)X(r,t,{get:e[t],enumerable:!0})},xe=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _e(e))!Ee.call(r,o)&&o!==t&&X(r,o,{get:()=>e[o],enumerable:!(n=be(e,o))||n.enumerable});return r};var Me=r=>xe(X({},"__esModule",{value:!0}),r);var je={};Se(je,{WebDecoyCaptcha:()=>U,createClearanceFetch:()=>ne,readClearanceChallenge:()=>W});var ke=new Set(["Alt","CapsLock","Control","Meta","NumLock","ScrollLock","Shift"]),M=class{constructor(e={}){this.keyHoldSamples=0;this.keyHoldTotalMs=0;e.collectKeyHolds&&(this.pendingKeyHolds=new Map),this.mousePositions=[],this.mouseVelocities=[],this.mouseAccelerations=[],this.scrollEvents=[],this.keyEvents=[],this.touchEvents=[],this.touchMultiTouchSeen=!1,this.touchIdentifiers=new Set,this.pointerPoints=[],this.focusEvents=[],this.clickData=null,this.startTime=Date.now(),this.lastMousePos=null,this.lastMouseTime=null,this.lastVelocity=null,this.eventDeltas=[]}recordMouseMove(e){let t=performance.now(),n={x:e.clientX,y:e.clientY,t};if(this.mousePositions.push(n),this.lastMousePos&&this.lastMouseTime){let o=t-this.lastMouseTime;if(o>0){let i=e.clientX-this.lastMousePos.x,s=e.clientY-this.lastMousePos.y,c=Math.sqrt(i*i+s*s)/o;if(this.mouseVelocities.push({v:c,t}),this.eventDeltas.push(o),this.lastVelocity!==null){let l=(c-this.lastVelocity)/o;this.mouseAccelerations.push({a:l,t})}this.lastVelocity=c}}this.lastMousePos={x:e.clientX,y:e.clientY},this.lastMouseTime=t,this.mousePositions.length>500&&(this.mousePositions.shift(),this.mouseVelocities.length>500&&this.mouseVelocities.shift(),this.mouseAccelerations.length>500&&this.mouseAccelerations.shift())}recordMouseDown(e){this.clickData={x:e.clientX,y:e.clientY,button:e.button,downTime:performance.now()}}recordMouseUp(e){this.clickData&&(this.clickData.upTime=performance.now(),this.clickData.holdDuration=this.clickData.upTime-this.clickData.downTime)}recordScroll(e){this.scrollEvents.push({x:window.scrollX,y:window.scrollY,t:performance.now()}),this.scrollEvents.length>100&&this.scrollEvents.shift()}recordKeyEvent(e){let t=performance.now();this.keyEvents.push({type:e.type,keyLength:e.key?e.key.length:0,t}),this.recordKeyHold(e,t)}recordKeyHold(e,t){var a,c;let n=this.pendingKeyHolds,o=e.code;if(!n||this.keyHoldSamples>=200||!o||o==="Unidentified")return;let i=(c=(a=e.composedPath)==null?void 0:a.call(e)[0])!=null?c:e.target,s=e.isComposing||ke.has(e.key)||i instanceof Element&&i.matches('textarea, input[type="password"]');if(e.type==="keydown"&&!e.repeat)n.delete(o),!s&&n.size<64&&n.set(o,t);else if(e.type==="keyup"){let l=n.get(o);if(n.delete(o),l===void 0||s)return;let u=t-l;u>0&&u<2e3&&(this.keyHoldSamples++,this.keyHoldTotalMs+=u,this.keyHoldSamples===200&&n.clear())}}recordTouch(e){let t=e.touches&&e.touches.length?e.touches:e.changedTouches;if(!t||t.length===0)return;t.length>1&&(this.touchMultiTouchSeen=!0);let n=t[0];typeof n.identifier=="number"&&this.touchIdentifiers.add(n.identifier),this.touchEvents.push({x:n.clientX,y:n.clientY,t:performance.now(),force:typeof n.force=="number"?n.force:0,radiusX:typeof n.radiusX=="number"?n.radiusX:0,radiusY:typeof n.radiusY=="number"?n.radiusY:0,rotationAngle:typeof n.rotationAngle=="number"?n.rotationAngle:0,identifier:typeof n.identifier=="number"?n.identifier:-1,touchCount:t.length}),this.touchEvents.length>500&&this.touchEvents.shift()}recordPointer(e){this.pointerPoints.push({x:e.clientX,y:e.clientY,t:performance.now(),type:e.type,pressure:typeof e.pressure=="number"?e.pressure:0,tiltX:typeof e.tiltX=="number"?e.tiltX:0,tiltY:typeof e.tiltY=="number"?e.tiltY:0,tangentialPressure:typeof e.tangentialPressure=="number"?e.tangentialPressure:0,pointerType:e.pointerType||"unknown"}),this.pointerPoints.length>500&&this.pointerPoints.shift()}recordFocus(e){var t;this.focusEvents.push({type:e.type,target:(t=e.target)==null?void 0:t.tagName,t:performance.now()})}analyze(){let e=this.mousePositions,t=this.mouseVelocities,n=this.mouseAccelerations,o=this.keyHoldSamples>0?{keyHoldSamples:this.keyHoldSamples,keyHoldAvg:this.keyHoldTotalMs/this.keyHoldSamples}:{};if(e.length<10)return{...this._getEmptyAnalysis(),...o};let i=0,s=0;t.length>0&&(i=t.reduce((d,f)=>d+f.v,0)/t.length,s=t.reduce((d,f)=>d+Math.pow(f.v-i,2),0)/t.length);let a=0,c=0;if(n.length>0){a=n.reduce((m,d)=>m+d.a,0)/n.length;for(let m=1;m<n.length;m++)Math.sign(n[m].a)!==Math.sign(n[m-1].a)&&c++}let l=this._detectMicroTremor(e),u=this._calculateStraightLineRatio(e),h=0;for(let m=1;m<e.length;m++){let d=Math.abs(e[m].x-e[m-1].x),f=Math.abs(e[m].y-e[m-1].y);d<3&&f<3&&(d>0||f>0)&&h++}let p=this._countDirectionChanges(e),v=this._variance(this.eventDeltas),g=e.length>1?e.length/((e[e.length-1].t-e[0].t)/1e3):0,y=0;for(let m=1;m<e.length;m++){let d=e[m].x-e[m-1].x,f=e[m].y-e[m-1].y;y+=Math.sqrt(d*d+f*f)}let w=this._analyzeTouchPoints(this.touchEvents),_=this._analyzePointerPoints(this.pointerPoints);return{totalPoints:e.length,trajectoryLength:y,avgVelocity:i,velocityVariance:s,avgAcceleration:a,accelerationChanges:c,microTremorScore:l,straightLineRatio:u,microMovements:h,directionChanges:p,eventDeltas:this.eventDeltas.slice(-50),eventDeltaVariance:v,mouseEventRate:g,...this.analyzeScrolling(),keyEvents:this.keyEvents.length,touchEvents:this.touchEvents.length,focusEvents:this.focusEvents.length,clickData:this.clickData,interactionDuration:Date.now()-this.startTime,...w,..._,...o}}analyzeScrolling(){let e=this.scrollEvents,t=e.length;if(t<2)return{scrollEvents:t};let n=0;for(let o=1;o<t;o++){let i=e[o-1],s=e[o],a=Math.abs(s.x-i.x)+Math.abs(s.y-i.y);n=Math.max(n,a)}return{scrollEvents:t,scrollMorphology:{samples:t,maxStep:n}}}_analyzeTouchPoints(e){if(!e||e.length===0)return{touchTotalPoints:0,touchTrajectoryLength:0,touchAvgVelocity:0,touchVelocityVariance:0,touchMicroTremorScore:0,touchStraightLineRatio:0,touchDirectionChanges:0,touchForceMin:0,touchForceMax:0,touchForceVariance:0,touchRadiusMin:0,touchRadiusMax:0,touchRadiusVariance:0,touchMultiTouchSeen:this.touchMultiTouchSeen,touchUniqueIdentifiers:this.touchIdentifiers.size,touchForceAllZero:!1,touchForceAllOne:!1};let t=0,n=[];for(let l=1;l<e.length;l++){let u=e[l].x-e[l-1].x,h=e[l].y-e[l-1].y,p=Math.sqrt(u*u+h*h);t+=p;let v=e[l].t-e[l-1].t;v>0&&n.push(p/v)}let o=n.length>0?n.reduce((l,u)=>l+u,0)/n.length:0,i=e.map(l=>l.force),s=e.map(l=>Math.max(l.radiusX||0,l.radiusY||0)),a=i.length>0&&i.every(l=>l===0),c=i.length>0&&i.every(l=>l===1);return{touchTotalPoints:e.length,touchTrajectoryLength:t,touchAvgVelocity:o,touchVelocityVariance:this._variance(n),touchMicroTremorScore:this._detectMicroTremor(e),touchStraightLineRatio:this._calculateStraightLineRatio(e),touchDirectionChanges:this._countDirectionChanges(e),touchForceMin:i.length>0?Math.min(...i):0,touchForceMax:i.length>0?Math.max(...i):0,touchForceVariance:this._variance(i),touchRadiusMin:s.length>0?Math.min(...s):0,touchRadiusMax:s.length>0?Math.max(...s):0,touchRadiusVariance:this._variance(s),touchMultiTouchSeen:this.touchMultiTouchSeen,touchUniqueIdentifiers:this.touchIdentifiers.size,touchForceAllZero:a,touchForceAllOne:c}}_analyzePointerPoints(e){if(!e||e.length===0)return{pointerEvents:0,pointerAvgPressure:0,pointerPressureVariance:0,pointerMaxTilt:0,pointerHasNonMouseType:!1,pointerTypes:[]};let t=e.map(s=>s.pressure),n=t.length>0?t.reduce((s,a)=>s+a,0)/t.length:0,o=0,i=new Set;for(let s of e){let a=Math.abs(s.tiltX||0)+Math.abs(s.tiltY||0);a>o&&(o=a),s.pointerType&&i.add(s.pointerType)}return{pointerEvents:e.length,pointerAvgPressure:n,pointerPressureVariance:this._variance(t),pointerMaxTilt:o,pointerHasNonMouseType:Array.from(i).some(s=>s!=="mouse"&&s!=="unknown"),pointerTypes:Array.from(i)}}analyzeClick(e,t,n){let o=this.mousePositions;if(o.length<5)return this._getEmptyClickAnalysis();let i=o.slice(-20),s=n.left+n.width/2,a=n.top+n.height/2,c=Math.sqrt(Math.pow(e-s,2)+Math.pow(t-a,2)),l=0,u=0;for(let d=1;d<o.length;d++){let f=Math.sqrt(Math.pow(o[d].x-o[d-1].x,2)+Math.pow(o[d].y-o[d-1].y,2));u+=f,o[d].x>=n.left&&o[d].x<=n.right&&o[d].y>=n.top&&o[d].y<=n.bottom||(l+=f)}let h=u>0?l/u:0,p=0,v=!1,g=!1;for(let d of i){let f=d.x>=n.left&&d.x<=n.right&&d.y>=n.top&&d.y<=n.bottom;v&&!f&&(g=!0),g&&f&&(p++,g=!1),v=f}let y=0;for(let d=i.length-1;d>=0;d--){let f=i[d],P=f.x>=n.left&&f.x<=n.right&&f.y>=n.top&&f.y<=n.bottom;if(P&&d<i.length-1)y=i[i.length-1].t-f.t;else if(!P)break}let w=Math.sqrt(Math.pow(i[i.length-1].x-i[0].x,2)+Math.pow(i[i.length-1].y-i[0].y,2)),_=0;for(let d=1;d<i.length;d++)_+=Math.sqrt(Math.pow(i[d].x-i[d-1].x,2)+Math.pow(i[d].y-i[d-1].y,2));let m=_>0?w/_:1;return{clickPrecision:c,explorationRatio:h,overshootCorrections:p,hoverTime:y,approachDirectness:m,approachPoints:i.length}}_detectMicroTremor(e){if(e.length<20)return .5;let t=5,n=0;for(let i=t;i<e.length-t;i++){let s=0,a=0;for(let l=i-t;l<=i+t;l++)s+=e[l].x,a+=e[l].y;s/=t*2+1,a/=t*2+1;let c=Math.sqrt(Math.pow(e[i].x-s,2)+Math.pow(e[i].y-a,2));n+=c}let o=n/(e.length-t*2);return Math.min(1,o/2)}_calculateStraightLineRatio(e){if(e.length<3)return 0;let t=0,n=0;for(let o=2;o<e.length;o++){let i=e[o-2],s=e[o-1],a=e[o],c=Math.atan2(s.y-i.y,s.x-i.x),l=Math.atan2(a.y-s.y,a.x-s.x),u=Math.abs(l-c);n++,u<.1&&t++}return n>0?t/n:0}_countDirectionChanges(e){let t=0;for(let n=2;n<e.length;n++){let o=Math.atan2(e[n-1].y-e[n-2].y,e[n-1].x-e[n-2].x),i=Math.atan2(e[n].y-e[n-1].y,e[n].x-e[n-1].x);Math.abs(i-o)>Math.PI/6&&t++}return t}_variance(e){if(e.length===0)return 0;let t=e.reduce((n,o)=>n+o,0)/e.length;return e.reduce((n,o)=>n+Math.pow(o-t,2),0)/e.length}_getEmptyAnalysis(){return{totalPoints:0,trajectoryLength:0,avgVelocity:0,velocityVariance:0,avgAcceleration:0,accelerationChanges:0,microTremorScore:.5,straightLineRatio:0,microMovements:0,directionChanges:0,eventDeltas:[],eventDeltaVariance:0,mouseEventRate:0,...this.analyzeScrolling(),keyEvents:this.keyEvents.length,touchEvents:this.touchEvents.length,focusEvents:this.focusEvents.length,clickData:this.clickData,interactionDuration:Date.now()-this.startTime,...this._analyzeTouchPoints(this.touchEvents),...this._analyzePointerPoints(this.pointerPoints)}}_getEmptyClickAnalysis(){return{clickPrecision:0,explorationRatio:0,overshootCorrections:0,hoverTime:0,approachDirectness:1,approachPoints:0}}};var x=class{collect(){return{webdriver:this._detectWebdriver(),automationFlags:this._getAutomationFlags(),cdp:this._detectCDP(),playwright:this._detectPlaywright(),canvasHash:this._getCanvasHash(),webglInfo:this._getWebGLInfo(),audioInfo:this._getAudioInfo(),headlessIndicators:this._getHeadlessIndicators(),screen:this._getScreenInfo(),navigator:this._getNavigatorInfo(),jsExecutionTime:this._measureJSExecution(),mathFingerprint:this._getMathFingerprint(),errorFingerprint:this._getErrorFingerprint(),domRectFingerprint:this._getDOMRectFingerprint(),cssMediaQueries:this._getCSSMediaQueries(),permissionsInfo:this._getPermissionsInfo(),fontsInfo:this._getFontsInfo(),lieDetection:this._getLieDetection()}}async collectAsync(){let[e,t,n]=await Promise.all([this._getSpeechInfo(),this._getWebRTCInfo(),this._checkWorkerConsistency()]);return{speechInfo:e,webrtcInfo:t,workerConsistency:n}}_detectWebdriver(){let e=navigator,t=window;return!!(e.webdriver||t.document.__webdriver_evaluate||t.document.__selenium_evaluate||t.document.__webdriver_script_fn||t.document.__webdriver_script_func||t.document.__webdriver_script_function||t.document.$cdc_asdjflasutopfhvcZLmcfl_||t.document.$wdc_||t._Selenium_IDE_Recorder||t._phantom||t.__nightmare||t.callPhantom||t._phantom)}_getAutomationFlags(){let e=navigator,t=window;return{webdriver:!!e.webdriver,domAutomation:!!t.domAutomation,domAutomationController:!!t.domAutomationController,_selenium:!!t._selenium,__webdriver_script_fn:!!t.__webdriver_script_fn,__driver_evaluate:!!t.__driver_evaluate,__webdriver_evaluate:!!t.__webdriver_evaluate,__fxdriver_evaluate:!!t.__fxdriver_evaluate,__driver_unwrapped:!!t.__driver_unwrapped,__webdriver_unwrapped:!!t.__webdriver_unwrapped,__fxdriver_unwrapped:!!t.__fxdriver_unwrapped,_Selenium_IDE_Recorder:!!t._Selenium_IDE_Recorder,calledSelenium:!!t.calledSelenium,$chrome_asyncScriptInfo:!!t.$chrome_asyncScriptInfo,$cdc_asdjflasutopfhvcZLmcfl_:!!t.$cdc_asdjflasutopfhvcZLmcfl_,_phantom:!!t._phantom,callPhantom:!!t.callPhantom,__nightmare:!!t.__nightmare,__lastWatirAlert:!!t.__lastWatirAlert,__lastWatirConfirm:!!t.__lastWatirConfirm,__lastWatirPrompt:!!t.__lastWatirPrompt,plugins:navigator.plugins?navigator.plugins.length:0,languages:navigator.languages&&navigator.languages.length>0,mimeTypes:navigator.mimeTypes?navigator.mimeTypes.length:0,cookieEnabled:navigator.cookieEnabled,doNotTrack:navigator.doNotTrack,chrome:!!t.chrome,chromeRuntime:!!(t.chrome&&t.chrome.runtime&&t.chrome.runtime.id),permissionsAPI:!!navigator.permissions}}_detectPlaywright(){try{let e=[];Object.getOwnPropertyNames(window).filter(i=>i.startsWith("__pw")||i.startsWith("__playwright")).length>0&&e.push("playwright_globals");let n=Object.getPrototypeOf(navigator);return Object.getOwnPropertyDescriptor(n,"webdriver")||e.push("webdriver_deleted"),{detected:e.length>0,signals:e}}catch{return{detected:!1,signals:[]}}}_detectCDP(){try{let e=[];Object.keys(window).filter(n=>n.startsWith("cdc_")).length>0&&e.push("chromedriver_cdc"),"__webdriver_evaluate"in window&&e.push("selenium_evaluate"),"__driver_evaluate"in window&&e.push("selenium_driver_evaluate"),"__webdriver_unwrapped"in window&&e.push("selenium_unwrapped"),"__driver_unwrapped"in window&&e.push("selenium_driver_unwrapped"),"__selenium_evaluate"in window&&e.push("selenium_direct"),"__fxdriver_evaluate"in window&&e.push("firefox_driver"),"__fxdriver_unwrapped"in window&&e.push("firefox_driver_unwrapped"),"__puppeteer_evaluation_script__"in window&&e.push("puppeteer_eval"),document.__webdriver_script_fn&&e.push("cdp_script_injection");try{let n=Object.getOwnPropertyDescriptor(navigator,"webdriver");n&&typeof n.get=="function"&&n.get.toString().indexOf("[native code]")===-1&&e.push("webdriver_getter_modified")}catch{}return{detected:e.length>0,signals:e}}catch{return{detected:!1,signals:[]}}}_getCanvasHash(){try{let e=document.createElement("canvas");e.width=200,e.height=50;let t=e.getContext("2d");t.textBaseline="top",t.font="14px Arial",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText("FCaptcha",2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText("FCaptcha",4,17);let n=e.toDataURL(),o=0;for(let i=0;i<n.length;i++)o=(o<<5)-o+n.charCodeAt(i),o=o&o;return{hash:o.toString(16),dataLength:n.length,supported:!0}}catch{return{error:!0,supported:!1}}}_getWebGLInfo(){try{let e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return{supported:!1};let n=t.getExtension("WEBGL_debug_renderer_info"),o=n?t.getParameter(n.UNMASKED_VENDOR_WEBGL):"unknown",i=n?t.getParameter(n.UNMASKED_RENDERER_WEBGL):"unknown",s=i.toLowerCase(),a=s.includes("swiftshader")||s.includes("llvmpipe")||s.includes("softpipe")||s.includes("virtualbox")||s.includes("vmware");return{supported:!0,vendor:o,renderer:i,version:t.getParameter(t.VERSION),shadingVersion:t.getParameter(t.SHADING_LANGUAGE_VERSION),suspiciousRenderer:a}}catch{return{supported:!1,error:!0}}}_getAudioInfo(){try{let e=window,t=e.AudioContext||e.webkitAudioContext;if(!t)return{supported:!1};let n=new t,o={supported:!0,sampleRate:n.sampleRate,state:n.state,baseLatency:n.baseLatency};return n.close().catch(()=>{}),o}catch{return{supported:!1,error:!0}}}_getLieDetection(){try{let e=window,t=[],n=i=>{try{return typeof i=="function"&&i.toString().indexOf("[native code]")===-1}catch{return!1}},o=(i,s)=>{n(i)&&t.push(s)};o(Function.prototype.toString,"Function.prototype.toString"),o(navigator.permissions&&navigator.permissions.query,"navigator.permissions.query"),o(e.Notification&&e.Notification.requestPermission,"Notification.requestPermission"),o(e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype.toDataURL,"HTMLCanvasElement.toDataURL"),o(e.WebGLRenderingContext&&e.WebGLRenderingContext.prototype.getParameter,"WebGLRenderingContext.getParameter"),o(navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices,"mediaDevices.enumerateDevices");try{let i=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(navigator),"webdriver")||Object.getOwnPropertyDescriptor(navigator,"webdriver");i&&typeof i.get=="function"&&i.get.toString().indexOf("[native code]")===-1&&t.push("navigator.webdriver getter")}catch{}return{supported:!0,patched:t,patchedCount:t.length}}catch{return{supported:!1}}}_getHeadlessIndicators(){let e=navigator;return{hasOuterDimensions:window.outerWidth>0&&window.outerHeight>0,innerEqualsOuter:window.innerWidth===window.outerWidth&&window.innerHeight===window.outerHeight,screenColorDepth:window.screen.colorDepth,screenPixelDepth:window.screen.pixelDepth,connectionType:e.connection?e.connection.type:"unknown",connectionRtt:e.connection?e.connection.rtt:-1,notificationPermission:typeof Notification!="undefined"?Notification.permission:"unsupported",hasBattery:"getBattery"in navigator,hasCredentials:"credentials"in navigator,hasMediaDevices:"mediaDevices"in navigator}}_getScreenInfo(){return{width:screen.width,height:screen.height,colorDepth:screen.colorDepth,pixelRatio:window.devicePixelRatio,availWidth:screen.availWidth,availHeight:screen.availHeight,innerWidth:window.innerWidth,innerHeight:window.innerHeight}}_getNavigatorInfo(){var t;let e=navigator;return{language:navigator.language,languageCount:((t=navigator.languages)==null?void 0:t.length)||0,platform:navigator.platform,hardwareConcurrency:navigator.hardwareConcurrency,deviceMemory:e.deviceMemory,maxTouchPoints:navigator.maxTouchPoints||0,vendor:navigator.vendor,userAgent:navigator.userAgent,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:new Date().getTimezoneOffset()}}_measureJSExecution(){let e={},t=performance.now(),n=0;for(let s=0;s<1e3;s++)n+=Math.sqrt(s)*Math.sin(s);e.mathOps=performance.now()-t,e.mathSink=n,t=performance.now();let o=[];for(let s=0;s<1e3;s++)o.push(s);e.arrayOps=performance.now()-t,e.arrayLen=o.length,t=performance.now();let i="";for(let s=0;s<100;s++)i+="a";return e.stringOps=performance.now()-t,e.stringLen=i.length,e}async measureRAFConsistency(){return new Promise(e=>{let t=[],n=0,o=10;function i(s){if(t.push(s),n++,n<o)requestAnimationFrame(i);else{let a=[];for(let u=1;u<t.length;u++)a.push(t[u]-t[u-1]);let c=a.reduce((u,h)=>u+h,0)/a.length,l=a.reduce((u,h)=>u+Math.pow(h-c,2),0)/a.length;e({avgFrameTime:c,frameTimeVariance:l,frames:o})}}requestAnimationFrame(i)})}_getMathFingerprint(){try{let e={acos:Math.acos(.123456789),acosh:Math.acosh(1e308),asin:Math.asin(.123456789),asinh:Math.asinh(1),atanh:Math.atanh(.5),cbrt:Math.cbrt(100),cosh:Math.cosh(1),expm1:Math.expm1(1),log1p:Math.log1p(10),sinh:Math.sinh(1),tan:Math.tan(-1e308),tanh:Math.tanh(1),pow:Math.pow(Math.PI,-100),sin:Math.sin(Math.PI)},t=Object.values(e).map(o=>String(o)).join(","),n=0;for(let o=0;o<t.length;o++)n=(n<<5)-n+t.charCodeAt(o),n=n&n;return{hash:n.toString(16),sinPi:e.sin,tanLarge:e.tan,supported:!0}}catch{return{supported:!1,error:!0}}}_getErrorFingerprint(){try{let e={};try{null.foo}catch(o){e.typeError=o.message}try{[].length=-1}catch(o){e.rangeError=o.message}try{decodeURIComponent("%")}catch(o){e.uriError=o.message}try{({}).undefinedMethod()}catch(o){e.refTypeError=o.message}let t=Object.values(e).join("|"),n=0;for(let o=0;o<t.length;o++)n=(n<<5)-n+t.charCodeAt(o),n=n&n;return{hash:n.toString(16),typeError:e.typeError,supported:!0}}catch{return{supported:!1,error:!0}}}_getDOMRectFingerprint(){try{let e=document.createElement("div");e.style.cssText="position:absolute;left:-9999px;font-size:16px;font-family:Arial,sans-serif;";let t=document.createElement("span");t.textContent="FCaptcha Test String 123",e.appendChild(t);let n=document.createElement("span");n.style.cssText="letter-spacing:1px;word-spacing:2px;",n.textContent="WWWW 0000",e.appendChild(n),document.body.appendChild(e);let o=t.getBoundingClientRect(),i=n.getBoundingClientRect(),s=document.createRange();s.selectNode(t);let a=s.getBoundingClientRect();document.body.removeChild(e);let l=[o.width,o.height,o.x,o.y,i.width,i.height,a.width,a.height].map(h=>h.toFixed(6)).join(","),u=0;for(let h=0;h<l.length;h++)u=(u<<5)-u+l.charCodeAt(h),u=u&u;return{hash:u.toString(16),rectAWidth:o.width,rectBWidth:i.width,rangeWidth:a.width,supported:!0}}catch{return{supported:!1,error:!0}}}_getCSSMediaQueries(){try{return{...{prefersColorScheme:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",prefersReducedMotion:window.matchMedia("(prefers-reduced-motion: reduce)").matches,prefersReducedTransparency:window.matchMedia("(prefers-reduced-transparency: reduce)").matches,prefersContrast:window.matchMedia("(prefers-contrast: more)").matches?"more":window.matchMedia("(prefers-contrast: less)").matches?"less":"no-preference",anyHover:window.matchMedia("(any-hover: hover)").matches,anyPointer:window.matchMedia("(any-pointer: fine)").matches?"fine":window.matchMedia("(any-pointer: coarse)").matches?"coarse":"none",hover:window.matchMedia("(hover: hover)").matches,pointer:window.matchMedia("(pointer: fine)").matches?"fine":window.matchMedia("(pointer: coarse)").matches?"coarse":"none",colorGamut:window.matchMedia("(color-gamut: p3)").matches?"p3":window.matchMedia("(color-gamut: srgb)").matches?"srgb":"none",displayMode:window.matchMedia("(display-mode: standalone)").matches?"standalone":window.matchMedia("(display-mode: fullscreen)").matches?"fullscreen":"browser",orientation:window.matchMedia("(orientation: portrait)").matches?"portrait":"landscape",dynamicRange:window.matchMedia("(dynamic-range: high)").matches?"high":"standard",forcedColors:window.matchMedia("(forced-colors: active)").matches},supported:!0}}catch{return{supported:!1,error:!0}}}_getPermissionsInfo(){try{return{hasPermissionsAPI:"permissions"in navigator,hasClipboard:"clipboard"in navigator,hasShare:"share"in navigator,hasCredentials:"credentials"in navigator,hasBluetooth:"bluetooth"in navigator,hasUsb:"usb"in navigator,hasSerial:"serial"in navigator,hasHid:"hid"in navigator,hasXR:"xr"in navigator,hasGeolocation:"geolocation"in navigator,hasMIDI:"requestMIDIAccess"in navigator,supported:!0}}catch{return{supported:!1,error:!0}}}_getFontsInfo(){try{let e=["monospace","sans-serif","serif"],t=["Arial","Helvetica","Times New Roman","Courier New","Georgia","Verdana","Trebuchet MS","Comic Sans MS","Impact","Lucida Console","Menlo","Monaco","SF Pro","Helvetica Neue","Segoe UI","Consolas","Calibri","Cambria","DejaVu Sans","Liberation Sans","Ubuntu","Cantarell","MS Gothic","Meiryo","SimHei","Microsoft YaHei"],n=document.createElement("canvas");n.width=400,n.height=40;let o=n.getContext("2d"),i="mmMWWLLiiff00",s="72px",a={};for(let h of e)o.font=s+" "+h,a[h]=o.measureText(i).width;let c=[];for(let h of t){let p=!1;for(let v of e)if(o.font=s+' "'+h+'", '+v,o.measureText(i).width!==a[v]){p=!0;break}p&&c.push(h)}let l=c.join(","),u=0;for(let h=0;h<l.length;h++)u=(u<<5)-u+l.charCodeAt(h),u=u&u;return{hash:u.toString(16),count:c.length,hasArial:c.includes("Arial"),hasTimesNewRoman:c.includes("Times New Roman"),hasSegoeUI:c.includes("Segoe UI"),hasCalibri:c.includes("Calibri"),hasSFPro:c.includes("SF Pro"),hasMenlo:c.includes("Menlo"),hasDejaVuSans:c.includes("DejaVu Sans"),supported:!0}}catch{return{supported:!1,error:!0}}}async _getSpeechInfo(){try{if(!("speechSynthesis"in window))return{supported:!1};let t=await new Promise(c=>{let l=speechSynthesis.getVoices();if(l.length>0){c(l);return}let u=setTimeout(()=>c([]),1e3);speechSynthesis.onvoiceschanged=()=>{clearTimeout(u),c(speechSynthesis.getVoices())}}),n=t.filter(c=>c.localService),o=t.find(c=>c.default),i=[...new Set(t.map(c=>c.lang))],s=t.map(c=>c.name).sort().join(","),a=0;for(let c=0;c<s.length;c++)a=(a<<5)-a+s.charCodeAt(c),a=a&a;return{hash:a.toString(16),totalVoices:t.length,localVoices:n.length,languages:i.length,defaultVoiceLang:(o==null?void 0:o.lang)||null,hasGoogleVoices:t.some(c=>c.name.includes("Google")),hasMicrosoftVoices:t.some(c=>c.name.includes("Microsoft")),hasAppleVoices:t.some(c=>c.name.includes("Samantha")||c.name.includes("Alex")),supported:!0}}catch{return{supported:!1,error:!0}}}async _getWebRTCInfo(){try{let e={supported:"RTCPeerConnection"in window,mediaDevices:{supported:!1},localIPs:[]};if(!e.supported)return e;if(navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices)try{let t=await navigator.mediaDevices.enumerateDevices();e.mediaDevices={supported:!0,audioInputs:t.filter(n=>n.kind==="audioinput").length,audioOutputs:t.filter(n=>n.kind==="audiooutput").length,videoInputs:t.filter(n=>n.kind==="videoinput").length,totalDevices:t.length}}catch{e.mediaDevices={supported:!1,error:!0}}try{let t=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"}]}),n=new Set;t.onicecandidate=o=>{if(o.candidate){let i=o.candidate.candidate,s=/([0-9]{1,3}\.){3}[0-9]{1,3}/g,a=i.match(s);a&&a.forEach(c=>{(c.startsWith("192.168.")||c.startsWith("10.")||c.startsWith("172.")||c.startsWith("169.254."))&&n.add(c)})}},t.createDataChannel(""),await t.createOffer().then(o=>t.setLocalDescription(o)),await new Promise(o=>setTimeout(o,500)),e.localIPs=Array.from(n),e.hasLocalIP=n.size>0,t.close()}catch{e.localIPError=!0}return e}catch{return{supported:!1,error:!0}}}async _checkWorkerConsistency(){try{if(typeof Worker=="undefined")return{supported:!1};let e=navigator,t=`
|
|
2
2
|
self.onmessage = function() {
|
|
3
3
|
const data = {
|
|
4
4
|
userAgent: navigator.userAgent,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
};
|
|
13
13
|
self.postMessage(data);
|
|
14
14
|
};
|
|
15
|
-
`,n=new Blob([t],{type:"application/javascript"}),
|
|
15
|
+
`,n=new Blob([t],{type:"application/javascript"}),o=new Worker(URL.createObjectURL(n)),i=await new Promise((c,l)=>{let u=setTimeout(()=>l(new Error("timeout")),2e3);o.onmessage=h=>{clearTimeout(u),c(h.data)},o.onerror=()=>{clearTimeout(u),l(new Error("worker error"))},o.postMessage("collect")});o.terminate();let s={userAgent:navigator.userAgent,language:navigator.language,languages:navigator.languages?Array.from(navigator.languages):[],platform:navigator.platform,hardwareConcurrency:navigator.hardwareConcurrency,deviceMemory:e.deviceMemory,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:new Date().getTimezoneOffset()},a=[];return i.userAgent!==s.userAgent&&a.push("userAgent"),i.language!==s.language&&a.push("language"),i.platform!==s.platform&&a.push("platform"),i.hardwareConcurrency!==s.hardwareConcurrency&&a.push("hardwareConcurrency"),i.deviceMemory!==s.deviceMemory&&a.push("deviceMemory"),i.timezone!==s.timezone&&a.push("timezone"),i.timezoneOffset!==s.timezoneOffset&&a.push("timezoneOffset"),JSON.stringify(i.languages)!==JSON.stringify(s.languages)&&a.push("languages"),{supported:!0,consistent:a.length===0,mismatches:a,mismatchCount:a.length}}catch{return{supported:!1,error:!0}}}};var D=class{constructor(){this.motionEvents=[],this.orientationEvents=[],this._motionHandler=e=>this._recordMotion(e),this._orientationHandler=e=>this._recordOrientation(e),this._attached=!1}attach(){if(!this._attached){this._attached=!0;try{window.addEventListener("devicemotion",this._motionHandler,{passive:!0}),window.addEventListener("deviceorientation",this._orientationHandler,{passive:!0})}catch{}}}detach(){if(this._attached){this._attached=!1;try{window.removeEventListener("devicemotion",this._motionHandler),window.removeEventListener("deviceorientation",this._orientationHandler)}catch{}}}_recordMotion(e){let t=e.accelerationIncludingGravity||e.acceleration||{};this.motionEvents.push({x:typeof t.x=="number"?t.x:0,y:typeof t.y=="number"?t.y:0,z:typeof t.z=="number"?t.z:0,t:performance.now()}),this.motionEvents.length>300&&this.motionEvents.shift()}_recordOrientation(e){this.orientationEvents.push({alpha:typeof e.alpha=="number"?e.alpha:0,beta:typeof e.beta=="number"?e.beta:0,gamma:typeof e.gamma=="number"?e.gamma:0,t:performance.now()}),this.orientationEvents.length>300&&this.orientationEvents.shift()}analyze(){let e=this.motionEvents,t=this.orientationEvents,n=0,o=0;if(e.length>1){let s=e.map(a=>Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z));o=s.reduce((a,c)=>a+c,0)/s.length,n=s.reduce((a,c)=>a+(c-o)*(c-o),0)/s.length}let i=0;if(t.length>1){let s=t.map(c=>Math.abs(c.beta)+Math.abs(c.gamma)),a=s.reduce((c,l)=>c+l,0)/s.length;i=s.reduce((c,l)=>c+(l-a)*(l-a),0)/s.length}return{motionEventCount:e.length,motionAccelAvg:o,motionAccelVariance:n,orientationEventCount:t.length,orientationVariance:i,hasSensorSupport:typeof window.DeviceMotionEvent!="undefined"}}};var G=class{constructor(){this.pageLoadTime=performance.now(),this.firstInteractionTime=null,this.lastInteractionTime=null,this.totalEvents=0,this.eventLog=[],this.textareaStats=new Map,this.submitData=null,this._setupListeners()}_setupListeners(){["mousedown","keydown","touchstart","scroll"].forEach(t=>{document.addEventListener(t,n=>this._recordInteraction(n),{passive:!0})}),document.addEventListener("keydown",t=>this._recordTextareaKey(t),{passive:!0}),document.addEventListener("keyup",t=>this._recordTextareaKey(t),{passive:!0}),document.addEventListener("paste",t=>this.recordPaste(t),{passive:!0}),document.addEventListener("submit",t=>this._recordSubmit(t),{capture:!0}),this._interceptFormSubmit()}_recordInteraction(e){var n;let t=performance.now();this.firstInteractionTime===null&&(this.firstInteractionTime=t),this.lastInteractionTime=t,this.totalEvents++,this.eventLog.push({type:e.type,time:t,target:((n=e.target)==null?void 0:n.tagName)||"unknown"}),this.eventLog.length>50&&this.eventLog.shift()}_recordTextareaKey(e){let t=e.target;if((t==null?void 0:t.tagName)!=="TEXTAREA")return;let n=this.getTextareaStats(t),o=performance.now(),i=["Shift","Control","Alt","Meta","CapsLock","NumLock","ScrollLock"].includes(e.key);if(e.type==="keydown")n.keydowns.push(o),n.lastKeyTime!==null&&n.intervals.push(o-n.lastKeyTime),n.lastKeyTime=o,!i&&!e.repeat&&(n.activeKeyCount>0&&n.rollovers++,n.activeKeyCount++,n.pendingKeydowns.push(o)),n.keydowns.length>200&&n.keydowns.shift(),n.intervals.length>200&&n.intervals.shift();else if(e.type==="keyup"&&(n.keyups.push(o),n.keyups.length>200&&n.keyups.shift(),!i&&n.activeKeyCount>0&&(n.activeKeyCount--,n.pendingKeydowns.length>0))){let s=n.pendingKeydowns.shift(),a=o-s;a>0&&a<2e3&&(n.dwellTimes.push(a),n.dwellTimes.length>100&&n.dwellTimes.shift())}}_interceptFormSubmit(){let e=n=>this._recordProgrammaticSubmit(n),t=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(...n){return e(this),t.apply(this,n)}}_recordProgrammaticSubmit(e){let t=performance.now();this.submitData={method:"programmatic",time:t,timeSincePageLoad:t-this.pageLoadTime,timeSinceFirstInteraction:this.firstInteractionTime?t-this.firstInteractionTime:null,timeSinceLastInteraction:this.lastInteractionTime?t-this.lastInteractionTime:null,eventsBeforeSubmit:this.totalEvents,hadTriggerEvent:!1}}_recordSubmit(e){let t=performance.now(),n=this.eventLog.slice(-5),o=n.find(a=>a.type==="keydown"&&t-a.time<100),i=n.find(a=>a.type==="mousedown"&&t-a.time<100),s="unknown";o?s="keyboard":i?s="mouse":this.submitData||(s="programmatic_click"),(!this.submitData||this.submitData.method==="programmatic")&&(this.submitData={method:s,time:t,timeSincePageLoad:t-this.pageLoadTime,timeSinceFirstInteraction:this.firstInteractionTime?t-this.firstInteractionTime:null,timeSinceLastInteraction:this.lastInteractionTime?t-this.lastInteractionTime:null,eventsBeforeSubmit:this.totalEvents,hadTriggerEvent:s==="keyboard"||s==="mouse"})}analyze(){let e=performance.now(),t={};return this.textareaStats.forEach((o,i)=>{let s=o.intervals,a=0,c=0;s.length>0&&(a=s.reduce((l,u)=>l+u,0)/s.length,c=s.reduce((l,u)=>l+Math.pow(u-a,2),0)/s.length),t[i]={keyCount:o.keydowns.length,avgKeyInterval:a,keyIntervalVariance:c,keydownUpRatio:o.keyups.length>0?o.keydowns.length/o.keyups.length:0,pasteCount:o.pasteCount,intervals:o.intervals.slice(-100),dwellTimes:o.dwellTimes.slice(-100),rollovers:o.rollovers}}),document.querySelectorAll("textarea").forEach(o=>{let i=o.id||o.name||"unnamed",s=(o.value||"").length;s>0&&(t[i]?(t[i].contentLength=s,t[i].noKeyboardEvents=t[i].keyCount===0):t[i]={keyCount:0,avgKeyInterval:0,keyIntervalVariance:0,keydownUpRatio:0,pasteCount:0,contentLength:s,noKeyboardEvents:!0})}),{pageLoadToFirstInteraction:this.firstInteractionTime?this.firstInteractionTime-this.pageLoadTime:null,pageLoadToNow:e-this.pageLoadTime,totalInteractionEvents:this.totalEvents,submit:this.submitData||{method:"none",eventsBeforeSubmit:this.totalEvents,hadTriggerEvent:!1},textareaKeyboard:Object.keys(t).length>0?t:null}}getTextareaStats(e){let t=e.id||e.name||"unnamed",n=this.textareaStats.get(t);if(n)return n;let o={keydowns:[],keyups:[],intervals:[],lastKeyTime:null,inputWithoutKey:0,pasteCount:0,dwellTimes:[],rollovers:0,activeKeyCount:0,pendingKeydowns:[]};return this.textareaStats.set(t,o),o}recordPaste(e){let t=e.target;(t==null?void 0:t.tagName)==="TEXTAREA"&&this.getTextareaStats(t).pasteCount++}},Y=null;function O(){return Y||(Y=new G),Y}typeof document!="undefined"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>O()):O());async function C(r){let e=new TextEncoder().encode(r),t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}var R=class{constructor(){this.firstInteractionTime=null;this.powResult=null;this.pageLoadTime=performance.now()}recordFirstInteraction(){this.firstInteractionTime||(this.firstInteractionTime=performance.now())}async performProofOfWork(e=4){let t=`${Date.now()}:${Math.random().toString(36).slice(2)}`,n="0".repeat(e),o=performance.now(),i=0,s=0;for(;;){let a=await C(`${t}:${i}`);if(s++,a.startsWith(n))return this.powResult={prefix:t,nonce:i,hash:a,iterations:s,duration:performance.now()-o,difficulty:e},this.powResult;i++,s%1e3===0&&await new Promise(c=>setTimeout(c,0))}}collect(e){let t={};if(performance.timing){let n=performance.timing;t.dnsLookup=n.domainLookupEnd-n.domainLookupStart,t.tcpConnection=n.connectEnd-n.connectStart,t.serverResponse=n.responseEnd-n.requestStart,t.domLoad=n.domContentLoadedEventEnd-n.navigationStart,t.fullLoad=n.loadEventEnd-n.navigationStart}return{pageLoadToFirstInteraction:this.firstInteractionTime?this.firstInteractionTime-this.pageLoadTime:null,firstInteractionToClick:this.firstInteractionTime&&e?e-this.firstInteractionTime:null,totalSessionTime:performance.now()-this.pageLoadTime,performanceTiming:t,pow:this.powResult}}};var se=null,ae="/__webdecoy";function k(){return se}function B(r){se=r}function F(){return ae}function ce(r){ae=r.replace(/\/$/,"")}var K=class{constructor(e=k){this.challengeOrigin=e;this.workers=[];this.challenge=null;this.solution=null;this.solving=!1;this.solvePromise=null;this.startTime=null}_createWorker(){let e=`
|
|
16
16
|
async function sha256(message) {
|
|
17
17
|
const msgBuffer = new TextEncoder().encode(message);
|
|
18
18
|
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
`,t=new Blob([e],{type:"application/javascript"});return new Worker(URL.createObjectURL(t))}_threadCount(){let e=typeof navigator!="undefined"&&navigator.hardwareConcurrency||1;return Math.max(1,Math.floor(e/2))}_terminateWorkers(){for(let e of this.workers)try{e.terminate()}catch{}this.workers=[]}async fetchChallenge(e){let t=
|
|
57
|
+
`,t=new Blob([e],{type:"application/javascript"});return new Worker(URL.createObjectURL(t))}_threadCount(){let e=typeof navigator!="undefined"&&navigator.hardwareConcurrency||1;return Math.max(1,Math.floor(e/2))}_terminateWorkers(){for(let e of this.workers)try{e.terminate()}catch{}this.workers=[]}async fetchChallenge(e){let t=this.challengeOrigin();if(!t)return this._generateLocalChallenge();try{let n=await fetch(`${t}${F()}/challenge?siteKey=${encodeURIComponent(e||"default")}`);if(!n.ok)return console.warn(`PoW challenge fetch failed (status ${n.status}), using local challenge`),this._generateLocalChallenge();let{id:o,challengeId:i,...s}=await n.json(),a=i!=null?i:o;if(typeof a!="string"||a.length===0)throw new Error("PoW challenge response is missing an ID");return this.challenge={...s,challengeId:a},this.challenge}catch(n){return console.warn("PoW challenge fetch failed, using local challenge:",n),this._generateLocalChallenge()}}_generateLocalChallenge(){let e=Math.random().toString(36).slice(2)+Date.now().toString(36);return this.challenge={challengeId:e,prefix:`${e}:${Date.now()}:4`,difficulty:4,expiresAt:Date.now()+3e5,local:!0},this.challenge}async startSolving(e){return this._solve(e,null)}async solveWithSignalsHash(e,t){return this._solve(e,t)}async _solve(e,t){if(this.solving&&this.solvePromise)return this.solvePromise;this.challenge||await this.fetchChallenge(e);let n=this.challenge;return this.solving=!0,this.startTime=performance.now(),this.solvePromise=new Promise((o,i)=>{let s=this._threadCount(),a=!1,c=(l,u)=>{a||(a=!0,this.solving=!1,this._terminateWorkers(),l(u))};for(let l=0;l<s;l++){let u=this._createWorker();u.onmessage=h=>{h.data.found&&(this.solution={challengeId:n.challengeId,nonce:h.data.nonce,hash:h.data.hash,iterations:h.data.iterations,duration:h.data.duration,difficulty:n.difficulty,signalsHash:t||null,local:n.local||!1},c(o,this.solution))},u.onerror=h=>{c(i,h)},u.postMessage({prefix:n.prefix,difficulty:n.difficulty,signalsHash:t||null,startNonce:l,stride:s,batchSize:5e3}),this.workers.push(u)}}),this.solvePromise}async getSolution(e){return this.solution?this.solution:this.solving&&this.solvePromise?this.solvePromise:this.startSolving(e)}reset(){this._terminateWorkers(),this.challenge=null,this.solution=null,this.solving=!1,this.solvePromise=null}},J=null;function le(){return J||(J=new K),J}var H=class{constructor(e,t){this.token=null;this.verified=!1;let n=typeof e=="string"?document.getElementById(e):e;if(!n)throw new Error("WebDecoy captcha: container element not found");this.container=n,this.options=Object.assign({siteKey:null,theme:"light",size:"normal",callback:null,errorCallback:null,expiredCallback:null,powDifficulty:4},t),this.id="webdecoy_"+Math.random().toString(36).slice(2,11),this.behavioral=new M({collectKeyHolds:!0}),this.environmental=new x,this.temporal=new R,this.sensor=new D,this.powManager=le(),this._init()}_init(){this._createWidget(),this._attachListeners(),this._fetchChallenge()}async _fetchChallenge(){try{await this.powManager.fetchChallenge(this.options.siteKey)}catch(e){console.warn("PoW challenge fetch failed:",e)}}_createWidget(){let e=this.options.theme==="dark";this.container.innerHTML=`
|
|
58
58
|
<div class="webdecoy-widget ${e?"webdecoy-dark":""}" id="${this.id}">
|
|
59
59
|
<style>
|
|
60
60
|
.webdecoy-widget {
|
|
@@ -113,4 +113,4 @@
|
|
|
113
113
|
<span class="webdecoy-brand">WebDecoy</span>
|
|
114
114
|
</div>
|
|
115
115
|
</div>
|
|
116
|
-
`,this.checkbox=this.container.querySelector(".webdecoy-checkbox"),this.spinner=this.container.querySelector(".webdecoy-spinner"),this.label=this.container.querySelector(".webdecoy-label"),this.status=this.container.querySelector(".webdecoy-status")}_setStatus(e,t){this.label.textContent=e,this.status.textContent=t}_attachListeners(){document.addEventListener("mousemove",t=>this.behavioral.recordMouseMove(t),{passive:!0}),document.addEventListener("mousedown",t=>this.behavioral.recordMouseDown(t),{passive:!0}),document.addEventListener("mouseup",t=>this.behavioral.recordMouseUp(t),{passive:!0}),document.addEventListener("scroll",t=>this.behavioral.recordScroll(t),{passive:!0}),document.addEventListener("keydown",t=>this.behavioral.recordKeyEvent(t),{passive:!0}),document.addEventListener("keyup",t=>this.behavioral.recordKeyEvent(t),{passive:!0}),document.addEventListener("touchstart",t=>this.behavioral.recordTouch(t),{passive:!0}),document.addEventListener("touchmove",t=>this.behavioral.recordTouch(t),{passive:!0}),document.addEventListener("pointermove",t=>this.behavioral.recordPointer(t),{passive:!0}),document.addEventListener("pointerdown",t=>this.behavioral.recordPointer(t),{passive:!0}),document.addEventListener("pointerup",t=>this.behavioral.recordPointer(t),{passive:!0}),document.addEventListener("focus",t=>this.behavioral.recordFocus(t),{passive:!0,capture:!0}),document.addEventListener("blur",t=>this.behavioral.recordFocus(t),{passive:!0,capture:!0}),this.sensor.attach();let e=()=>this.temporal.recordFirstInteraction();document.addEventListener("mousemove",e,{once:!0}),document.addEventListener("touchstart",e,{once:!0}),document.addEventListener("keydown",e,{once:!0}),this.checkbox.addEventListener("click",t=>{this._handleClick(t)}),this.checkbox.addEventListener("keydown",t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this._handleClick(t))})}async _handleClick(e){var r,i,s;if(this.verified||this.checkbox.classList.contains("loading"))return;let t=performance.now(),n=this.checkbox.getBoundingClientRect();this.checkbox.classList.add("loading"),this.spinner.style.display="block",this.checkbox.setAttribute("aria-busy","true"),this.checkbox.setAttribute("aria-disabled","true"),this._setStatus("Verifying...","Verifying, please wait.");try{let a=this.behavioral.analyze(),c="clientX"in e?e.clientX:n.left,l="clientY"in e?e.clientY:n.top,u=this.behavioral.analyzeClick(c,l,n),h=this.environmental.collect(),[g,f]=await Promise.all([this.environmental.measureRAFConsistency(),this.environmental.collectAsync()]),p=this.temporal.collect(t),y=O().analyze(),w=this.sensor.analyze(),m={behavioral:{...a,...u},environmental:{...h,rafConsistency:g,...f,sensor:w},temporal:p,formAnalysis:y,meta:{widgetId:this.id,siteKey:this.options.siteKey,challengeNonce:((r=this.powManager.challenge)==null?void 0:r.nonce)||null,timestamp:Date.now(),userAgent:navigator.userAgent,screenSize:`${screen.width}x${screen.height}`,viewportSize:`${window.innerWidth}x${window.innerHeight}`,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}},v=JSON.stringify(m),d=await C(v),b=await this.powManager.solveWithSignalsHash(this.options.siteKey,d),P={duration:b.duration,iterations:b.iterations,difficulty:b.difficulty},L=await this._verify(m,b,v,d,P);L.success?this._showSuccess((i=L.token)!=null?i:""):this._showFailure((s=L.message)!=null?s:void 0)}catch(a){console.error("WebDecoy captcha error:",a),this._showFailure("Verification failed. Please try again.")}}async _verify(e,t,n,r,i){let s=S();if(!s)return this._clientSideVerify(e);try{return await(await fetch(s+F()+"/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteKey:this.options.siteKey,signals:e,signalsJson:n||null,powSolution:t?{challengeId:t.challengeId,nonce:t.nonce,hash:t.hash,signalsHash:r||null}:null,powTiming:i||null})})).json()}catch{return console.warn("Server unavailable, using client-side verification"),this._clientSideVerify(e)}}_clientSideVerify(e){let t=0,n=e.behavioral,r=e.environmental,i=e.temporal,s=(n.touchEvents||0)>=3,a=(n.keyEvents||0)>0&&n.totalPoints===0;n.totalPoints<5&&n.trajectoryLength<10&&!s&&!a?t+=.35:n.totalPoints<10&&!s&&!a&&n.trajectoryLength<30&&(t+=.15),n.microTremorScore<.2&&(t+=.12),n.velocityVariance<.03&&(t+=.1),n.explorationRatio<.05&&(t+=.08),n.overshootCorrections===0&&n.trajectoryLength>100&&(t+=.05),n.clickPrecision<2&&(t+=.05),n.straightLineRatio>.8&&(t+=.08),n.microMovements<5&&n.totalPoints>50&&(t+=.06),r.webdriver&&(t+=.25),r.automationFlags&&r.automationFlags.plugins===0&&(t+=.05),r.webglInfo&&r.webglInfo.suspiciousRenderer&&(t+=.1),r.headlessIndicators&&!r.headlessIndicators.hasOuterDimensions&&(t+=.12),r.headlessIndicators&&r.headlessIndicators.innerEqualsOuter&&(t+=.05),i.pow&&i.pow.duration<50&&(t+=.1),n.eventDeltaVariance<3&&(t+=.08),n.interactionDuration<300&&(t+=.07);let c=t<.5;return{success:c,score:t,token:c?btoa(JSON.stringify({timestamp:Date.now(),score:t,id:this.id})):null,message:c?null:"Verification failed"}}_showSuccess(e){this.verified=!0,this.token=e,this.checkbox.classList.remove("loading"),this.checkbox.classList.add("verified"),this.checkbox.setAttribute("aria-checked","true"),this.checkbox.removeAttribute("aria-busy"),this.spinner.style.display="none",this._setStatus("Verified","Verified."),this.options.callback&&this.options.callback(e),this.container.dispatchEvent(new CustomEvent("webdecoy:verified",{detail:{token:e}}))}_showFailure(e){this.checkbox.classList.remove("loading"),this.checkbox.classList.add("failed"),this.checkbox.removeAttribute("aria-busy"),this.checkbox.removeAttribute("aria-disabled"),this.spinner.style.display="none";let t=e||"Verification failed";this._setStatus(t,`${t} Press Space or Enter on the checkbox to try again.`),this.options.errorCallback&&this.options.errorCallback(e),setTimeout(()=>this.checkbox.classList.remove("failed"),3e3)}getToken(){return this.token}reset(){this.verified=!1,this.token=null,this.behavioral=new k,this.temporal=new R,this.sensor&&this.sensor.detach(),this.sensor=new D,this.sensor.attach(),this.powManager.reset(),this.checkbox.classList.remove("verified","failed","loading"),this.checkbox.setAttribute("aria-checked","false"),this.checkbox.removeAttribute("aria-busy"),this.checkbox.removeAttribute("aria-disabled"),this.spinner.style.display="none",this._setStatus("I'm not a robot",""),this._fetchChallenge()}};var K=class{constructor(e){this.lastScore=null;this.listeners=[];this.options=Object.assign({siteKey:null,serverUrl:null,minCollectionTime:2e3,autoScore:!0,scoreThreshold:.5,powDifficulty:3},e),this.id="webdecoy_inv_"+Math.random().toString(36).slice(2,11),this.behavioral=new k,this.environmental=new T,this.temporal=new R,this.sensor=new D,this.powManager=new H,this.startTime=Date.now(),this._init()}_init(){this._attachListeners();let e=()=>this.temporal.recordFirstInteraction();document.addEventListener("mousemove",e,{once:!0}),document.addEventListener("touchstart",e,{once:!0}),document.addEventListener("keydown",e,{once:!0}),document.addEventListener("scroll",e,{once:!0}),this.options.autoScore&&this._attachToForms(),this._fetchChallenge()}async _fetchChallenge(){try{await this.powManager.fetchChallenge(this.options.siteKey)}catch(e){console.warn("PoW challenge fetch failed:",e)}}_attachListeners(){let e={mousemove:t=>this.behavioral.recordMouseMove(t),mousedown:t=>this.behavioral.recordMouseDown(t),mouseup:t=>this.behavioral.recordMouseUp(t),scroll:t=>this.behavioral.recordScroll(t),keydown:t=>this.behavioral.recordKeyEvent(t),keyup:t=>this.behavioral.recordKeyEvent(t),touchmove:t=>this.behavioral.recordTouch(t),touchstart:t=>this.behavioral.recordTouch(t),pointermove:t=>this.behavioral.recordPointer(t),pointerdown:t=>this.behavioral.recordPointer(t),pointerup:t=>this.behavioral.recordPointer(t),focus:t=>this.behavioral.recordFocus(t),blur:t=>this.behavioral.recordFocus(t)};for(let[t,n]of Object.entries(e)){let r=t==="focus"||t==="blur"?{passive:!0,capture:!0}:{passive:!0};document.addEventListener(t,n,r),this.listeners.push({event:t,handler:n,opts:r})}this.sensor.attach()}_attachToForms(){document.addEventListener("submit",e=>{let t=e.target;if(t.dataset.webdecoyIgnore)return;let n=t.querySelector('input[name="webdecoy_token"]');n||(n=document.createElement("input"),n.type="hidden",n.name="webdecoy_token",t.appendChild(n)),!this.lastScore||Date.now()-this.lastScore.timestamp>6e4?(e.preventDefault(),this._scoreThenSubmit(t,n)):n.value=this.lastScore.token||""})}async _scoreThenSubmit(e,t){try{let n=await this.execute(e.dataset.webdecoyAction||"form_submit");t.value=n.token||"",n.success?e.submit():document.dispatchEvent(new CustomEvent("webdecoy:blocked",{detail:{score:n.score,form:e}}))}catch(n){console.error("WebDecoy captcha error:",n),e.submit()}}async execute(e=""){var w;let t=Date.now()-this.startTime;t<this.options.minCollectionTime&&await new Promise(m=>setTimeout(m,this.options.minCollectionTime-t));let n=this.behavioral.analyze(),r=this.environmental.collect(),i=this.temporal.collect(Date.now()),[s,a]=await Promise.all([this.environmental.measureRAFConsistency(),this.environmental.collectAsync()]),c=O().analyze(),l=this.sensor.analyze(),u={behavioral:n,environmental:{...r,rafConsistency:s,...a,sensor:l},temporal:i,formAnalysis:c,meta:{sessionId:this.id,siteKey:this.options.siteKey,action:e,challengeNonce:((w=this.powManager.challenge)==null?void 0:w.nonce)||null,timestamp:Date.now(),userAgent:navigator.userAgent,screenSize:`${screen.width}x${screen.height}`,viewportSize:`${window.innerWidth}x${window.innerHeight}`,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,sessionDuration:Date.now()-this.startTime,invisible:!0}},h=JSON.stringify(u),g=await C(h),f=await this.powManager.solveWithSignalsHash(this.options.siteKey,g),p={duration:f.duration,iterations:f.iterations,difficulty:f.difficulty},y=await this._score(u,e,f,h,g,p);return this.lastScore={...y,timestamp:Date.now()},y}async _score(e,t,n,r,i,s){let a=this.options.serverUrl||S();if(!a)return this._clientSideScore(e);try{return await(await fetch(a+F()+"/score",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteKey:this.options.siteKey,signals:e,signalsJson:r||null,action:t,powSolution:n?{challengeId:n.challengeId,nonce:n.nonce,hash:n.hash,signalsHash:i||null}:null,powTiming:s||null})})).json()}catch{return console.warn("WebDecoy server unavailable, using client-side scoring"),this._clientSideScore(e)}}_clientSideScore(e){let t=0,n=e.behavioral,r=e.environmental,i=e.temporal,s=e.meta,a=(n.touchEvents||0)>=3,c=(n.keyEvents||0)>0&&n.totalPoints===0;n.totalPoints<5&&n.trajectoryLength<10&&!a&&!c?t+=.35:n.totalPoints<10&&!a&&!c&&n.trajectoryLength<30&&(t+=.15),n.microTremorScore<.2&&(t+=.12),n.velocityVariance<.03&&(t+=.1),n.totalPoints<10&&s.sessionDuration>5e3&&(t+=.08),n.scrollEvents===0&&n.keyEvents===0&&s.sessionDuration>1e4&&(t+=.06),n.eventDeltaVariance<3&&(t+=.08),n.straightLineRatio>.8&&(t+=.08),r.webdriver&&(t+=.25),r.automationFlags&&r.automationFlags.plugins===0&&(t+=.06),r.headlessIndicators&&!r.headlessIndicators.hasOuterDimensions&&(t+=.12),r.webglInfo&&r.webglInfo.suspiciousRenderer&&(t+=.1),i.pow&&i.pow.duration<30&&(t+=.1),s.sessionDuration<500&&(t+=.12),s.sessionDuration<1e3&&n.totalPoints<5&&(t+=.15);let l=t<this.options.scoreThreshold;return{success:l,score:Math.min(1,t),action:s.action,token:l?btoa(JSON.stringify({timestamp:Date.now(),score:t,action:s.action,id:this.id})):null}}getScore(){return this.lastScore}destroy(){for(let{event:e,handler:t,opts:n}of this.listeners)document.removeEventListener(e,t,n);this.listeners=[],this.powManager&&this.powManager.reset()}};var U={widgets:new Map,get serverUrl(){return S()},set serverUrl(o){q(o)},configure(o){o.serverUrl&&q(o.serverUrl),o.basePath&&ce(o.basePath)},render(o,e){let t=new W(o,e);return this.widgets.set(t.id,t),t.id},getResponse(o){let e=this.widgets.get(o);return e&&e instanceof W?e.getToken():null},reset(o){let e=this.widgets.get(o);e instanceof W&&e.reset()},invisible(o){let e=new K(o);return this.widgets.set(e.id,e),e},async execute(o,e={}){let t=new K({siteKey:o,serverUrl:S(),minCollectionTime:e.minTime||1e3,autoScore:!1,powDifficulty:e.powDifficulty||3}),n=await t.execute(e.action||"");return t.destroy(),n},getSignals(){return{environmental:new T().collect()}},autoInit(){document.querySelectorAll("[data-webdecoy]").forEach(o=>{let e=o.dataset.sitekey||o.dataset.webdecoy,t=o.dataset.theme||"light",n=o.dataset.endpoint,r=o.dataset.callback,i=r?window[r]:void 0;n&&q(n),this.render(o,{siteKey:e,theme:t,callback:i!=null?i:null})})}};var Se=24,Me=8,Ce=750,Pe=1500;function E(o){return typeof o=="number"&&Number.isFinite(o)?o:0}function ue(o){let e=o.mousePositions;return!e||e.length<2?0:Math.max(0,Math.round(e[e.length-1].t-e[0].t))}function he(o){let e=o.mousePositions.length>=Se&&ue(o)>=Ce,t=o.touchEvents.length>=Me;return e||t}function Le(o){if(!he(o))return null;let e=o.analyze(),t=o.clickData;return{samples:E(e.totalPoints),duration_ms:ue(o),tremor:E(e.microTremorScore),straight_ratio:E(e.straightLineRatio),velocity_var:E(e.velocityVariance),delta_var:E(e.eventDeltaVariance),dir_changes:E(e.directionChanges),micro_moves:E(e.microMovements),hold_ms:E(t==null?void 0:t.holdDuration),touch_points:E(e.touchTotalPoints),touch_force_var:E(e.touchForceVariance),pointer_nonmouse:e.pointerHasNonMouseType===!0,scrolls:E(e.scrollEvents),keys:E(e.keyEvents)}}function de(o){if(typeof document=="undefined")return()=>{};let e=new k,t=null,n=!1,r={mousemove:a=>e.recordMouseMove(a),mousedown:a=>e.recordMouseDown(a),mouseup:a=>e.recordMouseUp(a),scroll:a=>e.recordScroll(a),keydown:a=>e.recordKeyEvent(a),touchstart:a=>e.recordTouch(a),touchmove:a=>e.recordTouch(a),pointerdown:a=>e.recordPointer(a)},i=()=>{if(!n){n=!0,t&&clearTimeout(t);for(let[a,c]of Object.entries(r))document.removeEventListener(a,c)}},s=()=>{n||t||he(e)&&(t=setTimeout(()=>{t=null;let a=Le(e);i(),a&&o(a)},Pe))};for(let[a,c]of Object.entries(r)){let l=u=>{c(u),s()};r[a]=l,document.addEventListener(a,l,{passive:!0})}return i}var Z="wd_clearance",Ae="wdfp1",fe="https://ingest.webdecoy.com";async function De(o){let e=o.canvasHash,t=e&&e.supported?String(e.hash):"na",n=o.webglInfo,r=n&&n.supported?String(n.renderer)+"~"+String(n.vendor):"na",i=`${screen.width}x${screen.height}x${screen.colorDepth}`,s="na";try{s=Intl.DateTimeFormat().resolvedOptions().timeZone||"na"}catch{}let a=navigator.platform||"na",c=navigator.language||"na";return C([Ae,t,r,i,s,a,c].join("|"))}var Q=12e4,N=6e4;function me(o,e,t){let n=Math.min(Q,Math.max(0,e)/3);return o-n*(1+t/2)}var Re=18e5,Ie=1e4;async function Oe(o,e,t,n,r){let i=new AbortController,s=setTimeout(()=>i.abort(),Ie);try{let a=await fetch(o.replace(/\/$/,"")+"/api/v1/clearance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({aid:e,fp:t,scope:n,ua:navigator.userAgent,webdriver:navigator.webdriver===!0,headless:/HeadlessChrome/.test(navigator.userAgent),...r?{behavior:r}:{}}),signal:i.signal});if(!a.ok)return null;let c=await a.json();if(c.granted&&c.token){let l=c.expires_in;return{token:c.token,expiresIn:typeof l=="number"&&Number.isFinite(l)&&l>0?Math.min(l,1800):1800}}if(c.granted===!1)return{denied:!0}}catch{}finally{clearTimeout(s)}return null}function ge(o){for(let e of document.cookie.split(";")){let t=e.indexOf("=");if(!(t<0)&&e.slice(0,t).trim()===o)return e.slice(t+1).trim()||null}return null}function Fe(o,e){document.cookie=`${Z}=${o}; path=/; secure; samesite=lax; max-age=${e}`}function We(o){let e=window.requestIdleCallback;typeof e=="function"?e.call(window,o,{timeout:1200}):setTimeout(o,1200)}var ee=!1;function ve(){return document.visibilityState==="hidden"||typeof navigator!="undefined"&&navigator.onLine===!1}function pe(o){o.failures++,o.failedAway=ve();let e=Math.min(3e5,N*Math.pow(2,Math.min(o.failures-1,3)));o.retryAt=Date.now()+e,z(o,e)}function Ve(o){ve()||(o.failedAway&&(o.failedAway=!1,o.retryAt=0),$(o))}var _;function He(o){try{let e=o.split(".")[0];if(e.length>8192)return Date.now()+N+Q;let t=e.replace(/-/g,"+").replace(/_/g,"/"),n=JSON.parse(atob(t)).exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return Math.min(n*1e3,Date.now()+Re)}catch{}return Date.now()+N+Q}function z(o,e){o.timer!==void 0&&clearTimeout(o.timer),!(o!==_||o.stopped)&&(o.timer=setTimeout(()=>{o.timer=void 0,$(o)},Math.max(1e3,e)))}async function $(o){if(o!==_||o.stopped||o.running)return;let e=ge(Z);if(e!==o.token&&(o.token=e,o.expiresAt=e?He(e):0,o.renewAt=me(o.expiresAt,o.expiresAt-Date.now(),o.spread)),o.retryAt>Date.now()){z(o,o.retryAt-Date.now());return}if(!o.behavior&&e&&o.renewAt>Date.now()){z(o,Math.min(N,o.renewAt-Date.now()));return}o.running=!0;let t=o.behavior;o.behavior=void 0;try{o.fingerprint||(o.fingerprint=(async()=>{let i=new T;return De({canvasHash:i._getCanvasHash(),webglInfo:i._getWebGLInfo()})})());let n=await o.fingerprint,r=await Oe(o.opts.ingestUrl||fe,o.opts.siteKey,n,o.opts.scope||"",t||o.lastBehavior);if(o!==_)return;r&&"token"in r?(Fe(r.token,r.expiresIn),o.token=ge(Z),o.expiresAt=Date.now()+r.expiresIn*1e3,o.renewAt=me(o.expiresAt,r.expiresIn*1e3,o.spread),o.failures=0,o.failedAway=!1,t&&(o.lastBehavior=t),o.retryAt=0,z(o,Math.min(N,o.renewAt-Date.now()))):r&&"denied"in r?(o.stopped=!0,o.timer!==void 0&&clearTimeout(o.timer)):pe(o)}catch{o.fingerprint=void 0,pe(o)}finally{o.running=!1,o.behavior&&!o.stopped&&o===_&&z(o,1e3)}}function Ke(o){ee||(ee=!0,de(e=>{o!==_||o.stopped||(o.behavior=e,$(o))}))}function ye(o){if(!o.siteKey||typeof document=="undefined")return;let e=o.ingestUrl||fe,t=JSON.stringify([e.replace(/\/$/,""),o.siteKey,o.scope||""]);if(!_||_.key!==t){_&&(_.timer!==void 0&&clearTimeout(_.timer),document.removeEventListener("visibilitychange",_.wake),typeof window!="undefined"&&window.removeEventListener("online",_.wake)),ee=!1;let n={key:t,opts:{...o},token:null,expiresAt:0,renewAt:0,retryAt:0,running:!1,stopped:!1,failures:0,failedAway:!1,spread:Math.random(),wake:()=>Ve(n)};_=n,document.addEventListener("visibilitychange",n.wake),typeof window!="undefined"&&window.addEventListener("online",n.wake),We(()=>{$(n)})}o.behavior!==!1&&Ke(_)}var Ue=["missing","invalid","insufficient-trust","revoked","crawler-refused","agent-impersonation","denied"],ze=["missing","invalid","insufficient-trust"];function V(o){if(o.status!==403||o.headers.get("x-wd-clearance")!=="challenged"||o.headers.get("x-wd-challenge")!=="1")return null;let e=o.headers.get("x-wd-challenge-reason"),t=o.headers.get("x-wd-challenge-recoverable");return!e||!Ue.includes(e)||t!=="true"&&t!=="false"?null:{version:1,reason:e,recoverable:t==="true"&&ze.includes(e)}}function j(o){var e;return(e=o.reason)!=null?e:new DOMException("The operation was aborted","AbortError")}function te(o,e){return new Promise((t,n)=>{if(e.aborted){n(j(e));return}let r=()=>n(j(e));e.addEventListener("abort",r,{once:!0}),o.then(t,n).finally(()=>e.removeEventListener("abort",r))})}function ne(o){var c,l;let e=new URL(o.origin);if(!["http:","https:"].includes(e.protocol)||e.username||e.password||e.pathname!=="/"||e.search||e.hash)throw new TypeError("A protected HTTP(S) origin is required");let t=e.origin,n=(c=o.timeoutMs)!=null?c:1e4;if(!Number.isFinite(n)||n<1||n>6e4)throw new RangeError("timeoutMs must be between 1 and 60000");let r=(l=o.fetch)!=null?l:globalThis.fetch.bind(globalThis),i;function s(u,h,g,f){var p;try{(p=o.onEvent)==null||p.call(o,{type:u,origin:t,method:h,challenge:g,status:f})}catch{}}function a(u){if(!i){let h=new AbortController,g={controller:h,users:0,promise:Promise.resolve(!1)};i=g;let f=setTimeout(()=>h.abort(new DOMException("Clearance recovery timed out","TimeoutError")),n);h.signal.addEventListener("abort",()=>clearTimeout(f),{once:!0});let p=Promise.resolve().then(()=>o.recover({origin:t,challenge:u,signal:h.signal}));g.promise=te(p,h.signal).then(w=>w===!0,()=>!1);let y=()=>{clearTimeout(f),i===g&&(i=void 0)};p.then(y,y)}return i.users++,i}return async(u,h)=>{var ie;let g=((ie=h==null?void 0:h.method)!=null?ie:u instanceof Request?u.method:"GET").toUpperCase();if(g!=="GET"&&g!=="HEAD"){let x=await r(u,h),X=u instanceof Request?u.url:String(u),I=new URL(X,typeof document!="undefined"?document.baseURI:void 0),A=V(x);return A&&I.origin===t&&!x.redirected&&(!x.url||new URL(x.url).origin===t)&&s("challenge-served",g,A,x.status),x}let f=u instanceof Request?u:new URL(String(u),typeof document!="undefined"?document.baseURI:void 0).href,p=new Request(f,h),y=await r(p),w=V(y);if(!w||new URL(p.url).origin!==t||y.redirected||y.url&&new URL(y.url).origin!==t)return y;s("challenge-served",g,w,y.status);let m=typeof location!="undefined"?location.origin:t;if(!w.recoverable||p.credentials==="omit"||m!==t&&p.credentials!=="include"||typeof navigator!="undefined"&&navigator.onLine===!1||typeof AbortSignal.any!="function")return y;if(p.signal.aborted)throw j(p.signal);let v=new AbortController,d=!1,b=()=>v.abort(j(p.signal));p.signal.addEventListener("abort",b,{once:!0});let P=setTimeout(()=>{d=!0,v.abort(new DOMException("Clearance recovery timed out","TimeoutError"))},n),L=a(w);s("recovery-attempted",g,w);let re=!1,oe=()=>{re||(re=!0,--L.users===0&&L.controller.abort())};try{let x=await te(L.promise,v.signal);if(oe(),!x||v.signal.aborted)return s("recovery-failed",g,w),y;let X=AbortSignal.any([p.signal,v.signal]),I=await te(r(new Request(p,{signal:X})),v.signal),A=V(I);return s("enforcement-outcome",g,A!=null?A:w,I.status),s(A?"recovery-failed":"recovery-succeeded",g,w,I.status),I}catch(x){if(s("recovery-failed",g,w),p.signal.aborted)throw j(p.signal);if(d)return y;throw x}finally{oe(),clearTimeout(P),p.signal.removeEventListener("abort",b)}}}var M=document.currentScript;window.WebDecoyCaptcha=U;window.WebDecoyClearance={createClearanceFetch:ne,readClearanceChallenge:V};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>U.autoInit()):U.autoInit();var we=M==null?void 0:M.getAttribute("data-site-key");we&&ye({siteKey:we,ingestUrl:(M==null?void 0:M.getAttribute("data-ingest"))||void 0,scope:(M==null?void 0:M.getAttribute("data-scope"))||void 0});return ke(Ne);})();
|
|
116
|
+
`,this.checkbox=this.container.querySelector(".webdecoy-checkbox"),this.spinner=this.container.querySelector(".webdecoy-spinner"),this.label=this.container.querySelector(".webdecoy-label"),this.status=this.container.querySelector(".webdecoy-status")}_setStatus(e,t){this.label.textContent=e,this.status.textContent=t}_attachListeners(){document.addEventListener("mousemove",t=>this.behavioral.recordMouseMove(t),{passive:!0}),document.addEventListener("mousedown",t=>this.behavioral.recordMouseDown(t),{passive:!0}),document.addEventListener("mouseup",t=>this.behavioral.recordMouseUp(t),{passive:!0}),document.addEventListener("scroll",t=>this.behavioral.recordScroll(t),{passive:!0}),document.addEventListener("keydown",t=>this.behavioral.recordKeyEvent(t),{passive:!0}),document.addEventListener("keyup",t=>this.behavioral.recordKeyEvent(t),{passive:!0}),document.addEventListener("touchstart",t=>this.behavioral.recordTouch(t),{passive:!0}),document.addEventListener("touchmove",t=>this.behavioral.recordTouch(t),{passive:!0}),document.addEventListener("pointermove",t=>this.behavioral.recordPointer(t),{passive:!0}),document.addEventListener("pointerdown",t=>this.behavioral.recordPointer(t),{passive:!0}),document.addEventListener("pointerup",t=>this.behavioral.recordPointer(t),{passive:!0}),document.addEventListener("focus",t=>this.behavioral.recordFocus(t),{passive:!0,capture:!0}),document.addEventListener("blur",t=>this.behavioral.recordFocus(t),{passive:!0,capture:!0}),this.sensor.attach();let e=()=>this.temporal.recordFirstInteraction();document.addEventListener("mousemove",e,{once:!0}),document.addEventListener("touchstart",e,{once:!0}),document.addEventListener("keydown",e,{once:!0}),this.checkbox.addEventListener("click",t=>{this._handleClick(t)}),this.checkbox.addEventListener("keydown",t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this._handleClick(t))})}async _handleClick(e){var o,i,s;if(this.verified||this.checkbox.classList.contains("loading"))return;let t=performance.now(),n=this.checkbox.getBoundingClientRect();this.checkbox.classList.add("loading"),this.spinner.style.display="block",this.checkbox.setAttribute("aria-busy","true"),this.checkbox.setAttribute("aria-disabled","true"),this._setStatus("Verifying...","Verifying, please wait.");try{let a=this.behavioral.analyze(),c="clientX"in e?e.clientX:n.left,l="clientY"in e?e.clientY:n.top,u=this.behavioral.analyzeClick(c,l,n),h=this.environmental.collect(),[p,v]=await Promise.all([this.environmental.measureRAFConsistency(),this.environmental.collectAsync()]),g=this.temporal.collect(t),y=O().analyze(),w=this.sensor.analyze(),_={behavioral:{...a,...u},environmental:{...h,rafConsistency:p,...v,sensor:w},temporal:g,formAnalysis:y,meta:{widgetId:this.id,siteKey:this.options.siteKey,challengeNonce:((o=this.powManager.challenge)==null?void 0:o.nonce)||null,timestamp:Date.now(),userAgent:navigator.userAgent,screenSize:`${screen.width}x${screen.height}`,viewportSize:`${window.innerWidth}x${window.innerHeight}`,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}},m=JSON.stringify(_),d=await C(m),f=await this.powManager.solveWithSignalsHash(this.options.siteKey,d),P={duration:f.duration,iterations:f.iterations,difficulty:f.difficulty},L=await this._verify(_,f,m,d,P);L.success?this._showSuccess((i=L.token)!=null?i:""):this._showFailure((s=L.message)!=null?s:void 0)}catch(a){console.error("WebDecoy captcha error:",a),this._showFailure("Verification failed. Please try again.")}}async _verify(e,t,n,o,i){let s=k();if(!s)return this._clientSideVerify(e);try{return await(await fetch(s+F()+"/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteKey:this.options.siteKey,signals:e,signalsJson:n||null,powSolution:t?{challengeId:t.challengeId,nonce:t.nonce,hash:t.hash,signalsHash:o||null}:null,powTiming:i||null})})).json()}catch{return console.warn("Server unavailable, using client-side verification"),this._clientSideVerify(e)}}_clientSideVerify(e){let t=0,n=e.behavioral,o=e.environmental,i=e.temporal,s=(n.touchEvents||0)>=3,a=(n.keyEvents||0)>0&&n.totalPoints===0;n.totalPoints<5&&n.trajectoryLength<10&&!s&&!a?t+=.35:n.totalPoints<10&&!s&&!a&&n.trajectoryLength<30&&(t+=.15),n.microTremorScore<.2&&(t+=.12),n.velocityVariance<.03&&(t+=.1),n.explorationRatio<.05&&(t+=.08),n.overshootCorrections===0&&n.trajectoryLength>100&&(t+=.05),n.clickPrecision<2&&(t+=.05),n.straightLineRatio>.8&&(t+=.08),n.microMovements<5&&n.totalPoints>50&&(t+=.06),o.webdriver&&(t+=.25),o.automationFlags&&o.automationFlags.plugins===0&&(t+=.05),o.webglInfo&&o.webglInfo.suspiciousRenderer&&(t+=.1),o.headlessIndicators&&!o.headlessIndicators.hasOuterDimensions&&(t+=.12),o.headlessIndicators&&o.headlessIndicators.innerEqualsOuter&&(t+=.05),i.pow&&i.pow.duration<50&&(t+=.1),n.eventDeltaVariance<3&&(t+=.08),n.interactionDuration<300&&(t+=.07);let c=t<.5;return{success:c,score:t,token:c?btoa(JSON.stringify({timestamp:Date.now(),score:t,id:this.id})):null,message:c?null:"Verification failed"}}_showSuccess(e){this.verified=!0,this.token=e,this.checkbox.classList.remove("loading"),this.checkbox.classList.add("verified"),this.checkbox.setAttribute("aria-checked","true"),this.checkbox.removeAttribute("aria-busy"),this.spinner.style.display="none",this._setStatus("Verified","Verified."),this.options.callback&&this.options.callback(e),this.container.dispatchEvent(new CustomEvent("webdecoy:verified",{detail:{token:e}}))}_showFailure(e){this.checkbox.classList.remove("loading"),this.checkbox.classList.add("failed"),this.checkbox.removeAttribute("aria-busy"),this.checkbox.removeAttribute("aria-disabled"),this.spinner.style.display="none";let t=e||"Verification failed";this._setStatus(t,`${t} Press Space or Enter on the checkbox to try again.`),this.options.errorCallback&&this.options.errorCallback(e),setTimeout(()=>this.checkbox.classList.remove("failed"),3e3)}getToken(){return this.token}reset(){this.verified=!1,this.token=null,this.behavioral=new M({collectKeyHolds:!0}),this.temporal=new R,this.sensor&&this.sensor.detach(),this.sensor=new D,this.sensor.attach(),this.powManager.reset(),this.checkbox.classList.remove("verified","failed","loading"),this.checkbox.setAttribute("aria-checked","false"),this.checkbox.removeAttribute("aria-busy"),this.checkbox.removeAttribute("aria-disabled"),this.spinner.style.display="none",this._setStatus("I'm not a robot",""),this._fetchChallenge()}};var V=class{constructor(e){this.lastScore=null;this.listeners=[];this.challengeRequest=null;this.scoring=null;this.options=Object.assign({siteKey:null,serverUrl:null,minCollectionTime:2e3,autoScore:!0,scoreThreshold:.5,powDifficulty:3},e),this.id="webdecoy_inv_"+Math.random().toString(36).slice(2,11),this.behavioral=new M({collectKeyHolds:!0}),this.environmental=new x,this.temporal=new R,this.sensor=new D,this.powManager=new K(()=>this.serverOrigin()),this.startTime=Date.now(),this._init()}_init(){this._attachListeners();let e=()=>this.temporal.recordFirstInteraction();document.addEventListener("mousemove",e,{once:!0}),document.addEventListener("touchstart",e,{once:!0}),document.addEventListener("keydown",e,{once:!0}),document.addEventListener("scroll",e,{once:!0}),this.options.autoScore&&this._attachToForms(),this.challengeRequest=this.powManager.fetchChallenge(this.options.siteKey)}serverOrigin(){return this.options.serverUrl||k()}_attachListeners(){let e={mousemove:t=>this.behavioral.recordMouseMove(t),mousedown:t=>this.behavioral.recordMouseDown(t),mouseup:t=>this.behavioral.recordMouseUp(t),scroll:t=>this.behavioral.recordScroll(t),keydown:t=>this.behavioral.recordKeyEvent(t),keyup:t=>this.behavioral.recordKeyEvent(t),touchmove:t=>this.behavioral.recordTouch(t),touchstart:t=>this.behavioral.recordTouch(t),pointermove:t=>this.behavioral.recordPointer(t),pointerdown:t=>this.behavioral.recordPointer(t),pointerup:t=>this.behavioral.recordPointer(t),focus:t=>this.behavioral.recordFocus(t),blur:t=>this.behavioral.recordFocus(t)};for(let[t,n]of Object.entries(e)){let o=t==="focus"||t==="blur"?{passive:!0,capture:!0}:{passive:!0};document.addEventListener(t,n,o),this.listeners.push({event:t,handler:n,opts:o})}this.sensor.attach()}_attachToForms(){document.addEventListener("submit",e=>{let t=e.target;if(t.dataset.webdecoyIgnore)return;let n=t.querySelector('input[name="webdecoy_token"]');n||(n=document.createElement("input"),n.type="hidden",n.name="webdecoy_token",t.appendChild(n)),!this.lastScore||Date.now()-this.lastScore.timestamp>6e4?(e.preventDefault(),this._scoreThenSubmit(t,n)):n.value=this.lastScore.token||""})}async _scoreThenSubmit(e,t){try{let n=await this.execute(e.dataset.webdecoyAction||"form_submit");t.value=n.token||"",n.success?e.submit():document.dispatchEvent(new CustomEvent("webdecoy:blocked",{detail:{score:n.score,form:e}}))}catch(n){console.error("WebDecoy captcha error:",n),e.submit()}}async execute(e=""){let t=()=>this._collectAndScore(e),n=this.scoring?this.scoring.then(t,t):t();this.scoring=n;try{return await n}finally{this.scoring===n&&(this.scoring=null)}}async _collectAndScore(e){var _;let t=Date.now()-this.startTime;t<this.options.minCollectionTime&&await new Promise(m=>setTimeout(m,this.options.minCollectionTime-t));let n=this.behavioral.analyze(),o=this.environmental.collect(),i=this.temporal.collect(Date.now()),[s,a]=await Promise.all([this.environmental.measureRAFConsistency(),this.environmental.collectAsync()]),c=O().analyze(),l=this.sensor.analyze(),u=await((_=this.challengeRequest)!=null?_:this.powManager.fetchChallenge(this.options.siteKey));this.challengeRequest=null,u.expiresAt<=Date.now()&&(u=await this.powManager.fetchChallenge(this.options.siteKey));let h={behavioral:n,environmental:{...o,rafConsistency:s,...a,sensor:l},temporal:i,formAnalysis:c,meta:{sessionId:this.id,siteKey:this.options.siteKey,action:e,challengeNonce:u.nonce||null,timestamp:Date.now(),userAgent:navigator.userAgent,screenSize:`${screen.width}x${screen.height}`,viewportSize:`${window.innerWidth}x${window.innerHeight}`,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,sessionDuration:Date.now()-this.startTime,invisible:!0}},p=JSON.stringify(h),v=await C(p),g;try{g=await this.powManager.solveWithSignalsHash(this.options.siteKey,v)}finally{this.powManager.reset()}let y={duration:g.duration,iterations:g.iterations,difficulty:g.difficulty},w=await this._score(h,e,g,p,v,y);return this.lastScore={...w,timestamp:Date.now()},w}async _score(e,t,n,o,i,s){let a=this.serverOrigin();if(!a)return this._clientSideScore(e);try{return await(await fetch(a+F()+"/score",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteKey:this.options.siteKey,signals:e,signalsJson:o||null,action:t,powSolution:n?{challengeId:n.challengeId,nonce:n.nonce,hash:n.hash,signalsHash:i||null}:null,powTiming:s||null})})).json()}catch{return console.warn("WebDecoy server unavailable, using client-side scoring"),this._clientSideScore(e)}}_clientSideScore(e){let t=0,n=e.behavioral,o=e.environmental,i=e.temporal,s=e.meta,a=(n.touchEvents||0)>=3,c=(n.keyEvents||0)>0&&n.totalPoints===0;n.totalPoints<5&&n.trajectoryLength<10&&!a&&!c?t+=.35:n.totalPoints<10&&!a&&!c&&n.trajectoryLength<30&&(t+=.15),n.microTremorScore<.2&&(t+=.12),n.velocityVariance<.03&&(t+=.1),n.totalPoints<10&&s.sessionDuration>5e3&&(t+=.08),n.scrollEvents===0&&n.keyEvents===0&&s.sessionDuration>1e4&&(t+=.06),n.eventDeltaVariance<3&&(t+=.08),n.straightLineRatio>.8&&(t+=.08),o.webdriver&&(t+=.25),o.automationFlags&&o.automationFlags.plugins===0&&(t+=.06),o.headlessIndicators&&!o.headlessIndicators.hasOuterDimensions&&(t+=.12),o.webglInfo&&o.webglInfo.suspiciousRenderer&&(t+=.1),i.pow&&i.pow.duration<30&&(t+=.1),s.sessionDuration<500&&(t+=.12),s.sessionDuration<1e3&&n.totalPoints<5&&(t+=.15);let l=t<this.options.scoreThreshold;return{success:l,score:Math.min(1,t),action:s.action,token:l?btoa(JSON.stringify({timestamp:Date.now(),score:t,action:s.action,id:this.id})):null}}getScore(){return this.lastScore}destroy(){for(let{event:e,handler:t,opts:n}of this.listeners)document.removeEventListener(e,t,n);this.listeners=[],this.powManager&&this.powManager.reset()}};var U={widgets:new Map,get serverUrl(){return k()},set serverUrl(r){B(r)},configure(r){r.serverUrl&&B(r.serverUrl),r.basePath&&ce(r.basePath)},render(r,e){let t=new H(r,e);return this.widgets.set(t.id,t),t.id},getResponse(r){let e=this.widgets.get(r);return e&&e instanceof H?e.getToken():null},reset(r){let e=this.widgets.get(r);e instanceof H&&e.reset()},invisible(r){let e=new V(r);return this.widgets.set(e.id,e),e},async execute(r,e={}){let t=new V({siteKey:r,serverUrl:k(),minCollectionTime:e.minTime||1e3,autoScore:!1,powDifficulty:e.powDifficulty||3}),n=await t.execute(e.action||"");return t.destroy(),n},getSignals(){return{environmental:new x().collect()}},autoInit(){document.querySelectorAll("[data-webdecoy]").forEach(r=>{let e=r.dataset.sitekey||r.dataset.webdecoy,t=r.dataset.theme||"light",n=r.dataset.endpoint,o=r.dataset.callback,i=o?window[o]:void 0;n&&B(n),this.render(r,{siteKey:e,theme:t,callback:i!=null?i:null})})}};var Te=24,Ce=8,Pe=750,Le=1500;function E(r){return typeof r=="number"&&Number.isFinite(r)?r:0}function ue(r){let e=r.mousePositions;return!e||e.length<2?0:Math.max(0,Math.round(e[e.length-1].t-e[0].t))}function he(r){let e=r.mousePositions.length>=Te&&ue(r)>=Pe,t=r.touchEvents.length>=Ce;return e||t}function Ae(r){if(!he(r))return null;let e=r.analyze(),t=r.clickData;return{samples:E(e.totalPoints),duration_ms:ue(r),tremor:E(e.microTremorScore),straight_ratio:E(e.straightLineRatio),velocity_var:E(e.velocityVariance),delta_var:E(e.eventDeltaVariance),dir_changes:E(e.directionChanges),micro_moves:E(e.microMovements),hold_ms:E(t==null?void 0:t.holdDuration),touch_points:E(e.touchTotalPoints),touch_force_var:E(e.touchForceVariance),pointer_nonmouse:e.pointerHasNonMouseType===!0,scrolls:E(e.scrollEvents),keys:E(e.keyEvents)}}function de(r){if(typeof document=="undefined")return()=>{};let e=new M,t=null,n=!1,o={mousemove:a=>e.recordMouseMove(a),mousedown:a=>e.recordMouseDown(a),mouseup:a=>e.recordMouseUp(a),scroll:a=>e.recordScroll(a),keydown:a=>e.recordKeyEvent(a),touchstart:a=>e.recordTouch(a),touchmove:a=>e.recordTouch(a),pointerdown:a=>e.recordPointer(a)},i=()=>{if(!n){n=!0,t&&clearTimeout(t);for(let[a,c]of Object.entries(o))document.removeEventListener(a,c)}},s=()=>{n||t||he(e)&&(t=setTimeout(()=>{t=null;let a=Ae(e);i(),a&&r(a)},Le))};for(let[a,c]of Object.entries(o)){let l=u=>{c(u),s()};o[a]=l,document.addEventListener(a,l,{passive:!0})}return i}var Z="wd_clearance",De="wdfp1",fe="https://ingest.webdecoy.com";async function Re(r){let e=r.canvasHash,t=e&&e.supported?String(e.hash):"na",n=r.webglInfo,o=n&&n.supported?String(n.renderer)+"~"+String(n.vendor):"na",i=`${screen.width}x${screen.height}x${screen.colorDepth}`,s="na";try{s=Intl.DateTimeFormat().resolvedOptions().timeZone||"na"}catch{}let a=navigator.platform||"na",c=navigator.language||"na";return C([De,t,o,i,s,a,c].join("|"))}var Q=12e4,z=6e4;function me(r,e,t){let n=Math.min(Q,Math.max(0,e)/3);return r-n*(1+t/2)}var Ie=18e5,Oe=1e4;async function Fe(r,e,t,n,o){let i=new AbortController,s=setTimeout(()=>i.abort(),Oe);try{let a=await fetch(r.replace(/\/$/,"")+"/api/v1/clearance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({aid:e,fp:t,scope:n,ua:navigator.userAgent,webdriver:navigator.webdriver===!0,headless:/HeadlessChrome/.test(navigator.userAgent),...o?{behavior:o}:{}}),signal:i.signal});if(!a.ok)return null;let c=await a.json();if(c.granted&&c.token){let l=c.expires_in;return{token:c.token,expiresIn:typeof l=="number"&&Number.isFinite(l)&&l>0?Math.min(l,1800):1800}}if(c.granted===!1)return{denied:!0}}catch{}finally{clearTimeout(s)}return null}function ge(r){for(let e of document.cookie.split(";")){let t=e.indexOf("=");if(!(t<0)&&e.slice(0,t).trim()===r)return e.slice(t+1).trim()||null}return null}function He(r,e){document.cookie=`${Z}=${r}; path=/; secure; samesite=lax; max-age=${e}`}function We(r){let e=window.requestIdleCallback;typeof e=="function"?e.call(window,r,{timeout:1200}):setTimeout(r,1200)}var ee=!1;function ve(){return document.visibilityState==="hidden"||typeof navigator!="undefined"&&navigator.onLine===!1}function pe(r){r.failures++,r.failedAway=ve();let e=Math.min(3e5,z*Math.pow(2,Math.min(r.failures-1,3)));r.retryAt=Date.now()+e,N(r,e)}function Ke(r){ve()||(r.failedAway&&(r.failedAway=!1,r.retryAt=0),q(r))}var b;function Ve(r){try{let e=r.split(".")[0];if(e.length>8192)return Date.now()+z+Q;let t=e.replace(/-/g,"+").replace(/_/g,"/"),n=JSON.parse(atob(t)).exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return Math.min(n*1e3,Date.now()+Ie)}catch{}return Date.now()+z+Q}function N(r,e){r.timer!==void 0&&clearTimeout(r.timer),!(r!==b||r.stopped)&&(r.timer=setTimeout(()=>{r.timer=void 0,q(r)},Math.max(1e3,e)))}async function q(r){if(r!==b||r.stopped||r.running)return;let e=ge(Z);if(e!==r.token&&(r.token=e,r.expiresAt=e?Ve(e):0,r.renewAt=me(r.expiresAt,r.expiresAt-Date.now(),r.spread)),r.retryAt>Date.now()){N(r,r.retryAt-Date.now());return}if(!r.behavior&&e&&r.renewAt>Date.now()){N(r,Math.min(z,r.renewAt-Date.now()));return}r.running=!0;let t=r.behavior;r.behavior=void 0;try{r.fingerprint||(r.fingerprint=(async()=>{let i=new x;return Re({canvasHash:i._getCanvasHash(),webglInfo:i._getWebGLInfo()})})());let n=await r.fingerprint,o=await Fe(r.opts.ingestUrl||fe,r.opts.siteKey,n,r.opts.scope||"",t||r.lastBehavior);if(r!==b)return;o&&"token"in o?(He(o.token,o.expiresIn),r.token=ge(Z),r.expiresAt=Date.now()+o.expiresIn*1e3,r.renewAt=me(r.expiresAt,o.expiresIn*1e3,r.spread),r.failures=0,r.failedAway=!1,t&&(r.lastBehavior=t),r.retryAt=0,N(r,Math.min(z,r.renewAt-Date.now()))):o&&"denied"in o?(r.stopped=!0,r.timer!==void 0&&clearTimeout(r.timer)):pe(r)}catch{r.fingerprint=void 0,pe(r)}finally{r.running=!1,r.behavior&&!r.stopped&&r===b&&N(r,1e3)}}function Ue(r){ee||(ee=!0,de(e=>{r!==b||r.stopped||(r.behavior=e,q(r))}))}function ye(r){if(!r.siteKey||typeof document=="undefined")return;let e=r.ingestUrl||fe,t=JSON.stringify([e.replace(/\/$/,""),r.siteKey,r.scope||""]);if(!b||b.key!==t){b&&(b.timer!==void 0&&clearTimeout(b.timer),document.removeEventListener("visibilitychange",b.wake),typeof window!="undefined"&&window.removeEventListener("online",b.wake)),ee=!1;let n={key:t,opts:{...r},token:null,expiresAt:0,renewAt:0,retryAt:0,running:!1,stopped:!1,failures:0,failedAway:!1,spread:Math.random(),wake:()=>Ke(n)};b=n,document.addEventListener("visibilitychange",n.wake),typeof window!="undefined"&&window.addEventListener("online",n.wake),We(()=>{q(n)})}r.behavior!==!1&&Ue(b)}var Ne=["missing","invalid","insufficient-trust","revoked","crawler-refused","agent-impersonation","denied"],ze=["missing","invalid","insufficient-trust"];function W(r){if(r.status!==403||r.headers.get("x-wd-clearance")!=="challenged"||r.headers.get("x-wd-challenge")!=="1")return null;let e=r.headers.get("x-wd-challenge-reason"),t=r.headers.get("x-wd-challenge-recoverable");return!e||!Ne.includes(e)||t!=="true"&&t!=="false"?null:{version:1,reason:e,recoverable:t==="true"&&ze.includes(e)}}function j(r){var e;return(e=r.reason)!=null?e:new DOMException("The operation was aborted","AbortError")}function te(r,e){return new Promise((t,n)=>{if(e.aborted){n(j(e));return}let o=()=>n(j(e));e.addEventListener("abort",o,{once:!0}),r.then(t,n).finally(()=>e.removeEventListener("abort",o))})}function ne(r){var c,l;let e=new URL(r.origin);if(!["http:","https:"].includes(e.protocol)||e.username||e.password||e.pathname!=="/"||e.search||e.hash)throw new TypeError("A protected HTTP(S) origin is required");let t=e.origin,n=(c=r.timeoutMs)!=null?c:1e4;if(!Number.isFinite(n)||n<1||n>6e4)throw new RangeError("timeoutMs must be between 1 and 60000");let o=(l=r.fetch)!=null?l:globalThis.fetch.bind(globalThis),i;function s(u,h,p,v){var g;try{(g=r.onEvent)==null||g.call(r,{type:u,origin:t,method:h,challenge:p,status:v})}catch{}}function a(u){if(!i){let h=new AbortController,p={controller:h,users:0,promise:Promise.resolve(!1)};i=p;let v=setTimeout(()=>h.abort(new DOMException("Clearance recovery timed out","TimeoutError")),n);h.signal.addEventListener("abort",()=>clearTimeout(v),{once:!0});let g=Promise.resolve().then(()=>r.recover({origin:t,challenge:u,signal:h.signal}));p.promise=te(g,h.signal).then(w=>w===!0,()=>!1);let y=()=>{clearTimeout(v),i===p&&(i=void 0)};g.then(y,y)}return i.users++,i}return async(u,h)=>{var ie;let p=((ie=h==null?void 0:h.method)!=null?ie:u instanceof Request?u.method:"GET").toUpperCase();if(p!=="GET"&&p!=="HEAD"){let S=await o(u,h),$=u instanceof Request?u.url:String(u),I=new URL($,typeof document!="undefined"?document.baseURI:void 0),A=W(S);return A&&I.origin===t&&!S.redirected&&(!S.url||new URL(S.url).origin===t)&&s("challenge-served",p,A,S.status),S}let v=u instanceof Request?u:new URL(String(u),typeof document!="undefined"?document.baseURI:void 0).href,g=new Request(v,h),y=await o(g),w=W(y);if(!w||new URL(g.url).origin!==t||y.redirected||y.url&&new URL(y.url).origin!==t)return y;s("challenge-served",p,w,y.status);let _=typeof location!="undefined"?location.origin:t;if(!w.recoverable||g.credentials==="omit"||_!==t&&g.credentials!=="include"||typeof navigator!="undefined"&&navigator.onLine===!1||typeof AbortSignal.any!="function")return y;if(g.signal.aborted)throw j(g.signal);let m=new AbortController,d=!1,f=()=>m.abort(j(g.signal));g.signal.addEventListener("abort",f,{once:!0});let P=setTimeout(()=>{d=!0,m.abort(new DOMException("Clearance recovery timed out","TimeoutError"))},n),L=a(w);s("recovery-attempted",p,w);let oe=!1,re=()=>{oe||(oe=!0,--L.users===0&&L.controller.abort())};try{let S=await te(L.promise,m.signal);if(re(),!S||m.signal.aborted)return s("recovery-failed",p,w),y;let $=AbortSignal.any([g.signal,m.signal]),I=await te(o(new Request(g,{signal:$})),m.signal),A=W(I);return s("enforcement-outcome",p,A!=null?A:w,I.status),s(A?"recovery-failed":"recovery-succeeded",p,w,I.status),I}catch(S){if(s("recovery-failed",p,w),g.signal.aborted)throw j(g.signal);if(d)return y;throw S}finally{re(),clearTimeout(P),g.signal.removeEventListener("abort",f)}}}var T=document.currentScript;window.WebDecoyCaptcha=U;window.WebDecoyClearance={createClearanceFetch:ne,readClearanceChallenge:W};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>U.autoInit()):U.autoInit();var we=T==null?void 0:T.getAttribute("data-site-key");we&&ye({siteKey:we,ingestUrl:(T==null?void 0:T.getAttribute("data-ingest"))||void 0,scope:(T==null?void 0:T.getAttribute("data-scope"))||void 0});return Me(je);})();
|