is-antibot 2.5.19 → 2.5.20
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 +3 -4
- package/src/index.js +29 -7
- package/src/providers.json +8 -8
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "is-antibot",
|
|
3
3
|
"description": "Detect antibot protection from 30+ providers — Cloudflare, Akamai, DataDome, PerimeterX, and more.",
|
|
4
4
|
"homepage": "https://antibot.microlink.io/",
|
|
5
|
-
"version": "2.5.
|
|
5
|
+
"version": "2.5.20",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
@@ -85,8 +85,7 @@
|
|
|
85
85
|
"src"
|
|
86
86
|
],
|
|
87
87
|
"scripts": {
|
|
88
|
-
"
|
|
89
|
-
"bench:compare": "node bench/detect.js HEAD HEAD~1",
|
|
88
|
+
"benchmark": "node benchmark/index.js",
|
|
90
89
|
"build": "gulp build",
|
|
91
90
|
"clean": "rm -rf node_modules",
|
|
92
91
|
"contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
|
|
@@ -116,7 +115,7 @@
|
|
|
116
115
|
},
|
|
117
116
|
"c8": {
|
|
118
117
|
"exclude": [
|
|
119
|
-
"
|
|
118
|
+
"benchmark/**",
|
|
120
119
|
"coverage/**",
|
|
121
120
|
"docs/**",
|
|
122
121
|
"gulpfile.js",
|
package/src/index.js
CHANGED
|
@@ -69,9 +69,16 @@ const createTestPattern = value => {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const createCompiledTestPattern = value => {
|
|
72
|
+
const createCompiledTestPattern = (value, anyLiteral) => {
|
|
73
73
|
if (!value) return () => false
|
|
74
74
|
const lowerValue = value.toLowerCase()
|
|
75
|
+
let hasAnyLiteral
|
|
76
|
+
const containsLiteral = literal => {
|
|
77
|
+
if (hasAnyLiteral === undefined) {
|
|
78
|
+
hasAnyLiteral = !anyLiteral || anyLiteral.test(lowerValue)
|
|
79
|
+
}
|
|
80
|
+
return hasAnyLiteral && lowerValue.indexOf(literal) !== -1
|
|
81
|
+
}
|
|
75
82
|
return pattern => {
|
|
76
83
|
const inner =
|
|
77
84
|
pattern && pattern.type === OPEN_GRAPH ? pattern.pattern : pattern
|
|
@@ -79,7 +86,7 @@ const createCompiledTestPattern = value => {
|
|
|
79
86
|
if (inner instanceof RegExp) {
|
|
80
87
|
matched = inner.test(value)
|
|
81
88
|
} else if (inner && inner.type === 'contains') {
|
|
82
|
-
matched =
|
|
89
|
+
matched = containsLiteral(inner.value)
|
|
83
90
|
} else if (inner) {
|
|
84
91
|
matched = lowerValue.indexOf(String(inner).toLowerCase()) !== -1
|
|
85
92
|
}
|
|
@@ -324,14 +331,29 @@ const compileDetection = detection => {
|
|
|
324
331
|
}
|
|
325
332
|
}
|
|
326
333
|
|
|
327
|
-
const
|
|
328
|
-
|
|
334
|
+
const escapeRegExp = value => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
335
|
+
|
|
336
|
+
const compileAnyLiteral = (providers, type) =>
|
|
337
|
+
new RegExp(
|
|
338
|
+
providers
|
|
339
|
+
.flatMap(provider => provider.detections)
|
|
340
|
+
.filter(detection => detection.type === type)
|
|
341
|
+
.flatMap(detection => detection.rules)
|
|
342
|
+
.filter(rule => rule.contains !== undefined)
|
|
343
|
+
.map(rule => escapeRegExp(rule.contains.toLowerCase()))
|
|
344
|
+
.join('|')
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
const compileProviders = ({ providers = [] } = {}) => ({
|
|
348
|
+
providers: providers.map(provider => ({
|
|
329
349
|
name: provider.name,
|
|
330
350
|
detections: provider.detections.map(compileDetection)
|
|
331
|
-
}))
|
|
351
|
+
})),
|
|
352
|
+
anyHtmlLiteral: compileAnyLiteral(providers, 'html')
|
|
353
|
+
})
|
|
332
354
|
|
|
333
355
|
const detectWithProviders = (
|
|
334
|
-
compiledProviders,
|
|
356
|
+
{ providers: compiledProviders, anyHtmlLiteral },
|
|
335
357
|
{ headers = {}, html = '', url = '', statusCode } = {}
|
|
336
358
|
) => {
|
|
337
359
|
const getHeader = createGetHeader(headers)
|
|
@@ -342,7 +364,7 @@ const detectWithProviders = (
|
|
|
342
364
|
}
|
|
343
365
|
return hasCookieImpl(patterns)
|
|
344
366
|
}
|
|
345
|
-
const htmlHas = createCompiledTestPattern(html)
|
|
367
|
+
const htmlHas = createCompiledTestPattern(html, anyHtmlLiteral)
|
|
346
368
|
const urlHas = createCompiledTestPattern(url)
|
|
347
369
|
const headerNames = getHeaderNames(headers)
|
|
348
370
|
const hasUrl = Boolean(url)
|
package/src/providers.json
CHANGED
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"technique": "javascript",
|
|
163
163
|
"rules": [
|
|
164
164
|
{
|
|
165
|
-
"regex": "^(?=[\\s\\S]
|
|
165
|
+
"regex": "^(?=[\\s\\S]*?window\\._pxAppId)(?=[\\s\\S]*?(?:px-captcha|/captcha/captcha\\.js|_pxAction|<title\\b[^>]*>\\s*Robot or human\\??\\s*<\\/title>))",
|
|
166
166
|
"flags": "i"
|
|
167
167
|
},
|
|
168
168
|
{
|
|
@@ -503,7 +503,7 @@
|
|
|
503
503
|
"technique": "captcha",
|
|
504
504
|
"rules": [
|
|
505
505
|
{
|
|
506
|
-
"regex": "^(?=[\\s\\S]
|
|
506
|
+
"regex": "^(?=[\\s\\S]*?\\sid=[\"']captcha-form[\"'])(?=[\\s\\S]*?g-recaptcha)",
|
|
507
507
|
"flags": "i"
|
|
508
508
|
}
|
|
509
509
|
]
|
|
@@ -567,7 +567,7 @@
|
|
|
567
567
|
"technique": "captcha",
|
|
568
568
|
"rules": [
|
|
569
569
|
{
|
|
570
|
-
"regex": "^(?=[\\s\\S]
|
|
570
|
+
"regex": "^(?=[\\s\\S]*?\\bh-captcha(?!-response))(?=[\\s\\S]*?(?:Verify you are (?:a )?human|Attention Required))",
|
|
571
571
|
"flags": "i"
|
|
572
572
|
}
|
|
573
573
|
]
|
|
@@ -610,7 +610,7 @@
|
|
|
610
610
|
"technique": "captcha",
|
|
611
611
|
"rules": [
|
|
612
612
|
{
|
|
613
|
-
"regex": "^(?=[\\s\\S]
|
|
613
|
+
"regex": "^(?=[\\s\\S]*?arkoselabs\\.com)(?=[\\s\\S]*?(?:Verify you are (?:a )?human|Attention Required|enforcement\\.js))",
|
|
614
614
|
"flags": "i"
|
|
615
615
|
}
|
|
616
616
|
]
|
|
@@ -676,7 +676,7 @@
|
|
|
676
676
|
"technique": "captcha",
|
|
677
677
|
"rules": [
|
|
678
678
|
{
|
|
679
|
-
"regex": "^(?=[\\s\\S]
|
|
679
|
+
"regex": "^(?=[\\s\\S]*?cf-turnstile)(?=[\\s\\S]*?(?:Just a moment|Attention Required|Verify you are (?:a )?human))",
|
|
680
680
|
"flags": "i"
|
|
681
681
|
}
|
|
682
682
|
]
|
|
@@ -720,7 +720,7 @@
|
|
|
720
720
|
"technique": "captcha",
|
|
721
721
|
"rules": [
|
|
722
722
|
{
|
|
723
|
-
"regex": "^(?=[\\s\\S]
|
|
723
|
+
"regex": "^(?=[\\s\\S]*?frc-captcha)(?=[\\s\\S]*?(?:Verify you are (?:a )?human|Attention Required|Please verify))",
|
|
724
724
|
"flags": "i"
|
|
725
725
|
}
|
|
726
726
|
]
|
|
@@ -789,7 +789,7 @@
|
|
|
789
789
|
"technique": "captcha",
|
|
790
790
|
"rules": [
|
|
791
791
|
{
|
|
792
|
-
"regex": "^(?=[\\s\\S]
|
|
792
|
+
"regex": "^(?=[\\s\\S]*?(?:TencentCaptcha|turing\\.captcha))(?=[\\s\\S]*?(?:请点击按钮开始验证|请完成安全验证|tcaptcha_transform))",
|
|
793
793
|
"flags": "i"
|
|
794
794
|
}
|
|
795
795
|
]
|
|
@@ -1042,7 +1042,7 @@
|
|
|
1042
1042
|
"technique": "javascript",
|
|
1043
1043
|
"rules": [
|
|
1044
1044
|
{
|
|
1045
|
-
"regex": "^(?=[\\s\\S]
|
|
1045
|
+
"regex": "^(?=[\\s\\S]*?_fs-ch-)(?=[\\s\\S]*?<title\\b[^>]*>\\s*Client Challenge\\s*<\\/title>)",
|
|
1046
1046
|
"flags": "i"
|
|
1047
1047
|
}
|
|
1048
1048
|
]
|