@naturalcycles/js-lib 14.262.0 → 14.263.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/dist/bot.js +2 -1
- package/dist-esm/bot.js +2 -1
- package/package.json +15 -15
- package/src/bot.ts +4 -1
package/dist/bot.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.BotReason = exports.BotDetectionService = void 0;
|
|
6
6
|
const env_1 = require("./env");
|
|
7
|
+
const botRegex = /bot|spider|crawl|headless|electron|phantom|slimer|proximic|cincraw|snapchat|slurp|MicrosoftPreview/i;
|
|
7
8
|
/**
|
|
8
9
|
* Service to detect bots and CDP (Chrome DevTools Protocol).
|
|
9
10
|
*
|
|
@@ -40,7 +41,7 @@ class BotDetectionService {
|
|
|
40
41
|
const { userAgent } = navigator;
|
|
41
42
|
if (!userAgent)
|
|
42
43
|
return BotReason.NoUserAgent;
|
|
43
|
-
if (
|
|
44
|
+
if (botRegex.test(userAgent)) {
|
|
44
45
|
return BotReason.UserAgent;
|
|
45
46
|
}
|
|
46
47
|
if (navigator.webdriver) {
|
package/dist-esm/bot.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Relevant material:
|
|
2
2
|
// https://deviceandbrowserinfo.com/learning_zone/articles/detecting-headless-chrome-puppeteer-2024
|
|
3
3
|
import { isServerSide } from './env';
|
|
4
|
+
const botRegex = /bot|spider|crawl|headless|electron|phantom|slimer|proximic|cincraw|snapchat|slurp|MicrosoftPreview/i;
|
|
4
5
|
/**
|
|
5
6
|
* Service to detect bots and CDP (Chrome DevTools Protocol).
|
|
6
7
|
*
|
|
@@ -37,7 +38,7 @@ export class BotDetectionService {
|
|
|
37
38
|
const { userAgent } = navigator;
|
|
38
39
|
if (!userAgent)
|
|
39
40
|
return BotReason.NoUserAgent;
|
|
40
|
-
if (
|
|
41
|
+
if (botRegex.test(userAgent)) {
|
|
41
42
|
return BotReason.UserAgent;
|
|
42
43
|
}
|
|
43
44
|
if (navigator.webdriver) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.263.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky",
|
|
6
6
|
"build": "dev-lib build-esm-cjs",
|
|
@@ -16,22 +16,22 @@
|
|
|
16
16
|
"docs-preview": "vitepress preview docs"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"tslib": "^2
|
|
20
|
-
"zod": "^3
|
|
19
|
+
"tslib": "^2",
|
|
20
|
+
"zod": "^3"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@naturalcycles/bench-lib": "^3
|
|
24
|
-
"@naturalcycles/dev-lib": "^15
|
|
25
|
-
"@naturalcycles/nodejs-lib": "^13
|
|
26
|
-
"@naturalcycles/time-lib": "^3
|
|
27
|
-
"@types/crypto-js": "^4
|
|
28
|
-
"@types/node": "^22
|
|
29
|
-
"@types/semver": "^7
|
|
30
|
-
"crypto-js": "^4
|
|
31
|
-
"jest": "^29
|
|
32
|
-
"prettier": "^3
|
|
33
|
-
"vitepress": "^1
|
|
34
|
-
"vue": "^3
|
|
23
|
+
"@naturalcycles/bench-lib": "^3",
|
|
24
|
+
"@naturalcycles/dev-lib": "^15",
|
|
25
|
+
"@naturalcycles/nodejs-lib": "^13",
|
|
26
|
+
"@naturalcycles/time-lib": "^3",
|
|
27
|
+
"@types/crypto-js": "^4",
|
|
28
|
+
"@types/node": "^22",
|
|
29
|
+
"@types/semver": "^7",
|
|
30
|
+
"crypto-js": "^4",
|
|
31
|
+
"jest": "^29",
|
|
32
|
+
"prettier": "^3",
|
|
33
|
+
"vitepress": "^1",
|
|
34
|
+
"vue": "^3"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
37
|
"dist",
|
package/src/bot.ts
CHANGED
|
@@ -19,6 +19,9 @@ export interface BotDetectionServiceCfg {
|
|
|
19
19
|
treatCDPAsBotReason?: boolean
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
const botRegex =
|
|
23
|
+
/bot|spider|crawl|headless|electron|phantom|slimer|proximic|cincraw|snapchat|slurp|MicrosoftPreview/i
|
|
24
|
+
|
|
22
25
|
/**
|
|
23
26
|
* Service to detect bots and CDP (Chrome DevTools Protocol).
|
|
24
27
|
*
|
|
@@ -60,7 +63,7 @@ export class BotDetectionService {
|
|
|
60
63
|
const { userAgent } = navigator
|
|
61
64
|
if (!userAgent) return BotReason.NoUserAgent
|
|
62
65
|
|
|
63
|
-
if (
|
|
66
|
+
if (botRegex.test(userAgent)) {
|
|
64
67
|
return BotReason.UserAgent
|
|
65
68
|
}
|
|
66
69
|
|