is-antibot 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +9 -9
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "is-antibot",
|
|
3
3
|
"description": "Identify if a response is an antibot challenge from CloudFlare, Akamai, DataDome, Vercel, PerimeterX, Shape Security, and more, including CAPTCHA providers like reCAPTCHA and hCaptcha.",
|
|
4
4
|
"homepage": "https://github.com/microlinkhq/is-antibot",
|
|
5
|
-
"version": "1.6.
|
|
5
|
+
"version": "1.6.1",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./src/index.js"
|
|
8
8
|
},
|
package/src/index.js
CHANGED
|
@@ -20,7 +20,7 @@ const createGetHeader = headers =>
|
|
|
20
20
|
const createTestPattern = value => {
|
|
21
21
|
if (!value) return () => false
|
|
22
22
|
const lowerValue = value.toLowerCase()
|
|
23
|
-
return
|
|
23
|
+
return pattern => {
|
|
24
24
|
if (pattern instanceof RegExp) {
|
|
25
25
|
try {
|
|
26
26
|
return pattern.test(value)
|
|
@@ -28,14 +28,6 @@ const createTestPattern = value => {
|
|
|
28
28
|
return false
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
if (isRegex) {
|
|
33
|
-
try {
|
|
34
|
-
return new RegExp(pattern, 'i').test(value)
|
|
35
|
-
} catch {
|
|
36
|
-
return false
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
31
|
return lowerValue.includes(pattern.toLowerCase())
|
|
40
32
|
}
|
|
41
33
|
}
|
|
@@ -406,6 +398,14 @@ const detect = ({ headers = {}, html = '', url = '', statusCode } = {}) => {
|
|
|
406
398
|
return byStatusCode('linkedin')
|
|
407
399
|
}
|
|
408
400
|
|
|
401
|
+
// Instagram: login page redirect indicates bot detection
|
|
402
|
+
if (
|
|
403
|
+
parseUrl(url).domain === 'instagram.com' &&
|
|
404
|
+
hasAnyHtml([/<title>\s*Login\s*[•·]\s*Instagram\s*<\/title>/i])
|
|
405
|
+
) {
|
|
406
|
+
return byHtml('instagram')
|
|
407
|
+
}
|
|
408
|
+
|
|
409
409
|
// YouTube: empty title pattern indicates a degraded response requiring BotGuard JS attestation
|
|
410
410
|
// Normal pages have `<title>Video Title - YouTube</title>`, bots get `<title> - YouTube</title>`
|
|
411
411
|
if (hasAnyHtml([/<title>\s*-\s*YouTube<\/title>/i])) {
|