bexxcv 1.0.8 → 1.0.9
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/README.md +42 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/pagehooks.d.ts +6 -0
- package/dist/pagehooks.js +19 -0
- package/dist/plugins/brake.d.ts +8 -0
- package/dist/plugins/brake.js +74 -0
- package/dist/plugins/cocoon.d.ts +5 -0
- package/dist/plugins/cocoon.js +17 -0
- package/dist/plugins/dodge.d.ts +21 -0
- package/dist/plugins/dodge.js +102 -0
- package/dist/plugins/gauntlet.d.ts +20 -0
- package/dist/plugins/gauntlet.js +119 -0
- package/dist/plugins/index.d.ts +27 -0
- package/dist/plugins/index.js +55 -0
- package/dist/plugins/lens.d.ts +20 -0
- package/dist/plugins/lens.js +89 -0
- package/dist/plugins/stash.d.ts +8 -0
- package/dist/plugins/stash.js +108 -0
- package/dist/plugins/types.d.ts +13 -0
- package/dist/plugins/types.js +49 -0
- package/dist/plugins/veneer.d.ts +5 -0
- package/dist/plugins/veneer.js +37 -0
- package/dist/plugins/wiretap.d.ts +26 -0
- package/dist/plugins/wiretap.js +123 -0
- package/dist/schema.js +85 -0
- package/dist/sync_api.d.ts +3 -1
- package/dist/sync_api.js +9 -1
- package/dist/turnstile.d.ts +12 -0
- package/dist/turnstile.js +70 -13
- package/dist/uam.d.ts +4 -0
- package/dist/uam.js +32 -6
- package/package.json +1 -1
package/dist/uam.js
CHANGED
|
@@ -13,7 +13,24 @@ const CHALLENGE_TITLES = [
|
|
|
13
13
|
];
|
|
14
14
|
const WATCHED = new WeakSet();
|
|
15
15
|
const BUSY = new WeakSet();
|
|
16
|
-
|
|
16
|
+
const MITIGATED = new WeakMap();
|
|
17
|
+
const TRACKED = new WeakSet();
|
|
18
|
+
export function trackMitigation(page) {
|
|
19
|
+
if (TRACKED.has(page))
|
|
20
|
+
return;
|
|
21
|
+
TRACKED.add(page);
|
|
22
|
+
page.on("response", (response) => {
|
|
23
|
+
const request = response.request();
|
|
24
|
+
if (!request.isNavigationRequest())
|
|
25
|
+
return;
|
|
26
|
+
if (request.frame() !== page.mainFrame())
|
|
27
|
+
return;
|
|
28
|
+
MITIGATED.set(page, response.headers()["cf-mitigated"] === "challenge");
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export async function isChallenge(page) {
|
|
32
|
+
if (MITIGATED.get(page))
|
|
33
|
+
return true;
|
|
17
34
|
const title = (await page.title().catch(() => "")).toLowerCase();
|
|
18
35
|
return CHALLENGE_TITLES.some((t) => title.includes(t));
|
|
19
36
|
}
|
|
@@ -26,7 +43,7 @@ async function cookieValue(page, name) {
|
|
|
26
43
|
return null;
|
|
27
44
|
}
|
|
28
45
|
}
|
|
29
|
-
async function humanActivity(page) {
|
|
46
|
+
export async function humanActivity(page, scale = 1) {
|
|
30
47
|
let width = 1280;
|
|
31
48
|
let height = 720;
|
|
32
49
|
const view = page.viewportSize();
|
|
@@ -47,18 +64,19 @@ async function humanActivity(page) {
|
|
|
47
64
|
width = 1280;
|
|
48
65
|
}
|
|
49
66
|
}
|
|
50
|
-
const moves = Math.floor(between(4, 8));
|
|
67
|
+
const moves = Math.max(1, Math.floor(between(4, 8) * scale));
|
|
51
68
|
for (let i = 0; i < moves; i++) {
|
|
52
69
|
await page.mouse.move(between(width * 0.1, width * 0.9), between(height * 0.1, height * 0.9), { steps: Math.floor(between(6, 14)) });
|
|
53
70
|
await sleep(between(250, 650));
|
|
54
71
|
}
|
|
55
|
-
const scrolls = Math.floor(between(2, 5));
|
|
72
|
+
const scrolls = Math.max(1, Math.floor(between(2, 5) * scale));
|
|
56
73
|
for (let i = 0; i < scrolls; i++) {
|
|
57
74
|
await page.mouse.wheel(0, between(60, 180));
|
|
58
75
|
await sleep(between(400, 900));
|
|
59
76
|
}
|
|
60
77
|
}
|
|
61
78
|
export async function waitForUam(page, options = {}) {
|
|
79
|
+
trackMitigation(page);
|
|
62
80
|
const timeout = options.timeout ?? 30000;
|
|
63
81
|
const start = Date.now();
|
|
64
82
|
let challenged = false;
|
|
@@ -66,6 +84,13 @@ export async function waitForUam(page, options = {}) {
|
|
|
66
84
|
while (Date.now() - start < timeout && !page.isClosed()) {
|
|
67
85
|
if (await isChallenge(page)) {
|
|
68
86
|
challenged = true;
|
|
87
|
+
if (options.assist) {
|
|
88
|
+
const acted = await options.assist(page).catch(() => false);
|
|
89
|
+
if (acted) {
|
|
90
|
+
await sleep(1500);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
69
94
|
try {
|
|
70
95
|
await humanActivity(page);
|
|
71
96
|
}
|
|
@@ -90,12 +115,12 @@ export async function waitForUam(page, options = {}) {
|
|
|
90
115
|
return { challenged: false, bypassed: true, cookie };
|
|
91
116
|
}
|
|
92
117
|
try {
|
|
93
|
-
await humanActivity(page);
|
|
118
|
+
await humanActivity(page, 0.4);
|
|
94
119
|
}
|
|
95
120
|
catch {
|
|
96
121
|
await sleep(500);
|
|
97
122
|
}
|
|
98
|
-
await sleep(
|
|
123
|
+
await sleep(2000);
|
|
99
124
|
const second = await cookieValue(page, "cf_clearance");
|
|
100
125
|
const retrySecond = await cookieValue(page, "cf_chl_rc_ni");
|
|
101
126
|
if (second === cookie && !retrySecond) {
|
|
@@ -120,6 +145,7 @@ export function watchUam(page, options = {}) {
|
|
|
120
145
|
if (WATCHED.has(page))
|
|
121
146
|
return;
|
|
122
147
|
WATCHED.add(page);
|
|
148
|
+
trackMitigation(page);
|
|
123
149
|
const interval = options.interval ?? 1500;
|
|
124
150
|
const timeout = options.timeout ?? 30000;
|
|
125
151
|
const waitOnGoto = options.waitOnGoto ?? true;
|