is-antibot 2.6.0 → 2.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.d.ts +1 -0
- package/src/index.js +19 -3
- package/src/providers.json +1 -0
- package/src/schema.json +9 -0
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.6.
|
|
5
|
+
"version": "2.6.1",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -345,9 +345,14 @@ const compileDetection = detection => {
|
|
|
345
345
|
throw new TypeError('An asn detection cannot be gated by statusCodes')
|
|
346
346
|
}
|
|
347
347
|
const compiled = DETECTION_COMPILERS[detection.type](detection)
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
348
|
+
return gateByHeaders(
|
|
349
|
+
gateByStatusCodes(compiled, statusCodes),
|
|
350
|
+
detection.unlessHeaders
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const gateByStatusCodes = (compiled, statusCodes) => {
|
|
355
|
+
if (!Array.isArray(statusCodes) || statusCodes.length === 0) return compiled
|
|
351
356
|
const allowed = new Set(statusCodes)
|
|
352
357
|
const innerMatches = compiled.matches
|
|
353
358
|
return {
|
|
@@ -356,6 +361,17 @@ const compileDetection = detection => {
|
|
|
356
361
|
}
|
|
357
362
|
}
|
|
358
363
|
|
|
364
|
+
const gateByHeaders = (compiled, unlessHeaders) => {
|
|
365
|
+
if (!Array.isArray(unlessHeaders) || unlessHeaders.length === 0) { return compiled }
|
|
366
|
+
const innerMatches = compiled.matches
|
|
367
|
+
const isVetoed = ({ getHeader }) =>
|
|
368
|
+
unlessHeaders.some(name => getHeader(name) != null)
|
|
369
|
+
return {
|
|
370
|
+
...compiled,
|
|
371
|
+
matches: context => innerMatches(context) && !isVetoed(context)
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
359
375
|
const escapeRegExp = value => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
360
376
|
|
|
361
377
|
const compileAnyLiteral = (providers, type) =>
|
package/src/providers.json
CHANGED
package/src/schema.json
CHANGED
|
@@ -98,6 +98,15 @@
|
|
|
98
98
|
"minItems": 1,
|
|
99
99
|
"description": "When set, the detection matches only if the response status code equals one of these values (AND with the detection's rules)."
|
|
100
100
|
},
|
|
101
|
+
"unlessHeaders": {
|
|
102
|
+
"type": "array",
|
|
103
|
+
"items": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"minLength": 1
|
|
106
|
+
},
|
|
107
|
+
"minItems": 1,
|
|
108
|
+
"description": "Response headers whose presence vetoes the detection, whatever their value. For origins that state why they refused (e.g. x-failure-reason: failure-expired on an expired signed URL) behind an edge that otherwise looks like a block."
|
|
109
|
+
},
|
|
101
110
|
"rules": {
|
|
102
111
|
"type": "array",
|
|
103
112
|
"minItems": 1,
|