Server: Phase 2 (REVIEW not respected yet)
This commit is contained in:
1 parent
5d16ded553
commit
142b47674d
4271 files changed
+1203269
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
omrilotan (https://github.com/omrilotan)
|
||||
gorangajic (https://github.com/gorangajic)
|
||||
deedeeh (https://github.com/deedeeh)
|
||||
dependabot[bot] (https://github.com/apps/dependabot)
|
||||
itayganor (https://github.com/itayganor)
|
||||
franzmoro (https://github.com/franzmoro)
|
||||
webinista (https://github.com/webinista)
|
||||
LeaVerou (https://github.com/LeaVerou)
|
||||
maximn (https://github.com/maximn)
|
||||
rynmsh (https://github.com/rynmsh)
|
||||
oskarrisberg (https://github.com/oskarrisberg)
|
||||
ArkadyFukzon (https://github.com/ArkadyFukzon)
|
||||
viraptor (https://github.com/viraptor)
|
||||
timbowhite (https://github.com/timbowhite)
|
||||
chinesedfan (https://github.com/chinesedfan)
|
||||
deadlypants1973 (https://github.com/deadlypants1973)
|
||||
dependabot-preview[bot] (https://github.com/apps/dependabot-preview)
|
||||
drewbard (https://github.com/drewbard)
|
||||
interisti (https://github.com/interisti)
|
||||
kieranstartup (https://github.com/kieranstartup)
|
||||
orangeflame (https://github.com/orangeflame)
|
||||
lirantal (https://github.com/lirantal)
|
||||
migara (https://github.com/migara)
|
||||
neraks (https://github.com/neraks)
|
||||
niftylettuce (https://github.com/niftylettuce)
|
||||
wcho (https://github.com/wcho)
|
||||
simonecorsi (https://github.com/simonecorsi)
|
||||
0x7f (https://github.com/0x7f)
|
||||
mhluska (https://github.com/mhluska)
|
||||
hijarian (https://github.com/hijarian)
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
# Unlicense
|
||||
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
# isbot 🤖/👨🦰
|
||||
|
||||
[](https://www.npmjs.com/package/isbot) [](https://circleci.com/gh/omrilotan/isbot) [](https://github.com/omrilotan/isbot/graphs/commit-activity) [](https://www.npmjs.com/package/isbot) [](https://www.jsdelivr.com/package/npm/isbot)
|
||||
|
||||
[](https://isbot.js.org)
|
||||
|
||||
Identify bots, crawlers, and spiders using the user agent string.
|
||||
|
||||
## Usage
|
||||
|
||||
Install
|
||||
|
||||
```sh
|
||||
npm i isbot
|
||||
```
|
||||
|
||||
Straightforward usage
|
||||
|
||||
```ts
|
||||
import { isBot } from "isbot";
|
||||
|
||||
// Request
|
||||
isBot(request.headers.get("User-Agent"));
|
||||
|
||||
// Nodejs HTTP
|
||||
isBot(request.getHeader("User-Agent"));
|
||||
|
||||
// ExpressJS
|
||||
isBot(req.get("user-agent"));
|
||||
|
||||
// Browser
|
||||
isBot(navigator.userAgent);
|
||||
|
||||
// User Agent string
|
||||
isBot(
|
||||
"Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
|
||||
); // true
|
||||
|
||||
isBot(
|
||||
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36",
|
||||
); // false
|
||||
```
|
||||
|
||||
Use JSDeliver CDN you can import to the browser directly
|
||||
|
||||
> See specific versions and instructions [https://www.jsdelivr.com/package/npm/isbot](https://www.jsdelivr.com/package/npm/isbot)
|
||||
|
||||
ESM
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { isBot } from "https://cdn.jsdelivr.net/npm/isbot@5/+esm";
|
||||
isBot(navigator.userAgent);
|
||||
</script>
|
||||
```
|
||||
|
||||
UMD
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/isbot@5"></script>
|
||||
<script>
|
||||
// isBot is now global
|
||||
isBot(navigator.userAgent);
|
||||
</script>
|
||||
```
|
||||
|
||||
## All named imports
|
||||
|
||||
| import | Type | Description |
|
||||
| ------------------- | -------------------------------- | ---------------------------------------------------------------------------- |
|
||||
| isBot | _(string?): boolean_ | Check if the user agent is a bot |
|
||||
| isBotNaive | _(string?): boolean_ | Check if the user agent is a bot using a naive pattern (less accurate) |
|
||||
| getPattern | (): _RegExp_ | The regular expression used to identify bots |
|
||||
| list | _string[]_ | List of all individual pattern parts |
|
||||
| findBotMatch | _(string?): string \| null_ | The substring matched by the regular expression |
|
||||
| findBotMatches | _(string?): string[]_ | All substrings matched by the regular expression |
|
||||
| findBotPattern | _(string?): string \| null_ | The regular expression used to identify bot substring in the user agent |
|
||||
| findBotPatterns | _(string?): string[]_ | All regular expressions used to identify bot substrings in the user agent |
|
||||
| createIsBot | _(RegExp): (string?): boolean_ | Create a custom isBot function |
|
||||
| createIsBotFromList | _(string[]): (string?): boolean_ | Create a custom isBot function from a list of string representation patterns |
|
||||
|
||||
## Example usages of helper functions
|
||||
|
||||
Create a custom `isBot` that does not consider Chrome Lighthouse user agent as bots.
|
||||
|
||||
```ts
|
||||
import { createIsBotFromList, findBotPatterns, list } from "isbot";
|
||||
|
||||
const ChromeLighthouseUserAgentStrings: string[] = [
|
||||
"mozilla/5.0 (macintosh; intel mac os x 10_15_7) applewebkit/537.36 (khtml, like gecko) chrome/94.0.4590.2 safari/537.36 chrome-lighthouse",
|
||||
"mozilla/5.0 (linux; android 7.0; moto g (4)) applewebkit/537.36 (khtml, like gecko) chrome/94.0.4590.2 mobile safari/537.36 chrome-lighthouse",
|
||||
];
|
||||
const patternsToRemove = new Set<string>(
|
||||
ChromeLighthouseUserAgentStrings.map(findBotPatterns).flat(),
|
||||
);
|
||||
const isbot: (ua: string) => boolean = createIsBotFromList(
|
||||
list.filter(
|
||||
(record: string): boolean => patternsToRemove.has(record) === false,
|
||||
),
|
||||
);
|
||||
```
|
||||
|
||||
Create a custom isBot that considers another pattern as a bot, which is not included in the package originally.
|
||||
|
||||
```ts
|
||||
import { createIsBotFromList, list } from "isbot";
|
||||
|
||||
const isBot = createIsBotFromList(list.concat("shmulik"));
|
||||
```
|
||||
|
||||
## Definitions
|
||||
|
||||
- **Bot.** Autonomous program imitating or replacing some aspect of a human behaviour, performing repetitive tasks much faster than human users could.
|
||||
- **Good bot.** Automated programs who visit websites in order to collect useful information. Web crawlers, site scrapers, stress testers, preview builders and other programs are welcomed on most websites because they serve purposes of mutual benefits.
|
||||
- **Bad bot.** Programs which are designed to perform malicious actions, ultimately hurting businesses. Testing credential databases, DDoS attacks, spam bots.
|
||||
|
||||
## Clarifications
|
||||
|
||||
### What does "isBot" do?
|
||||
|
||||
This package aims to identify "Good bots". Those who voluntarily identify themselves by setting a unique, preferably descriptive, user agent, usually by setting a dedicated request header.
|
||||
|
||||
### What doesn't "isBot" do?
|
||||
|
||||
It does not try to recognise malicious bots or programs disguising themselves as real users.
|
||||
|
||||
### Why would I want to identify good bots?
|
||||
|
||||
Recognising good bots such as web crawlers is useful for multiple purposes. Although it is not recommended to serve different content to web crawlers like Googlebot, you can still elect to
|
||||
|
||||
- Flag pageviews to consider with **business analysis**.
|
||||
- Prefer to serve cached content and **relieve service load**.
|
||||
- Omit third party solutions' code (tags, pixels) and **reduce costs**.
|
||||
|
||||
> It is not recommended to **whitelist** requests for any reason based on user agent header only. Instead, other methods of identification can be added such as [reverse dns lookup](https://www.npmjs.com/package/reverse-dns-lookup).
|
||||
|
||||
## How `isBot` maintains accuracy
|
||||
|
||||
`isBot` is an asset when it can most accurately identify bots by the user agent string. It uses expansive and regularly updated lists of user agent strings to create a regular expression that matches bots and only bots.
|
||||
|
||||
And above everything else, it is maintained by a community of contributers who help keep the list up to date.
|
||||
|
||||
### Fallback
|
||||
|
||||
The pattern uses lookbehind methods which are not supported in all environments. A fallback is provided for environments that do not support lookbehind. The fallback is less accurate. The test suite includes a percentage of false positives and false negatives which is deemed acceptable for the fallback: 1% false positive and 75% bot coverage.
|
||||
|
||||
## Data sources
|
||||
|
||||
We use external data sources on top of our own lists to keep up to date
|
||||
|
||||
### Crawlers user agents
|
||||
|
||||
- [Kikobeats/top-crawler-agents](https://github.com/Kikobeats/top-crawler-agents/blob/master/index.json)
|
||||
- [matomo.org](https://github.com/matomo-org/device-detector/blob/master/Tests/fixtures/bots.yml)
|
||||
- [monperrus/crawler-user-agents](https://github.com/monperrus/crawler-user-agents/blob/master/crawler-user-agents.json)
|
||||
- [myip.ms](https://www.myip.ms/files/bots/live_webcrawlers.txt)
|
||||
- [stephenafamo/isbot](https://github.com/stephenafamo/isbot/blob/main/crawler-user-agents.json)
|
||||
- [user-agents.net](https://user-agents.net/bots)
|
||||
- [ua-parser-js](https://github.com/faisalman/ua-parser-js/blob/master/test/data/ua/extension/crawler.json)
|
||||
- A Manual list
|
||||
|
||||
### Non bot user agents
|
||||
|
||||
- [user-agents npm package](https://www.npmjs.com/package/user-agents)
|
||||
- A Manual list
|
||||
|
||||
Missing something? Please [open an issue](https://github.com/omrilotan/isbot/issues/new/choose)
|
||||
|
||||
## Major releases breaking changes ([full changelog](./CHANGELOG.md))
|
||||
|
||||
### Not yet scheduled: **Next Version (6)**
|
||||
|
||||
Drop support to legacy names. Use the following table to update your code:
|
||||
|
||||
| Old Name | New Name |
|
||||
| ------------------- | ------------------- |
|
||||
| isbot | isBot |
|
||||
| isbotNaive | isBotNaive |
|
||||
| createIsbot | createIsBot |
|
||||
| createIsbotFromList | createIsBotFromList |
|
||||
| isbotMatch | findBotMatch |
|
||||
| isbotMatches | findBotMatches |
|
||||
| isbotPattern | findBotPattern |
|
||||
| isbotPatterns | findBotPatterns |
|
||||
|
||||
### [**Version 5**](https://github.com/omrilotan/isbot/releases/tag/v5.0.0)
|
||||
|
||||
Remove named export "pattern" from the interface, instead use "getPattern" method
|
||||
|
||||
### [**Version 4**](https://github.com/omrilotan/isbot/releases/tag/v4.0.0)
|
||||
|
||||
Remove `isbot` function default export in favour of a named export.
|
||||
|
||||
```ts
|
||||
import { isbot } from "isbot";
|
||||
```
|
||||
|
||||
### [**Version 3**](https://github.com/omrilotan/isbot/releases/tag/v3.0.0)
|
||||
|
||||
Remove testing for node 6 and 8
|
||||
|
||||
### [**Version 2**](https://github.com/omrilotan/isbot/releases/tag/v2.0.0)
|
||||
|
||||
Change return value for isbot: `true` instead of matched string
|
||||
|
||||
### [**Version 1**](https://github.com/omrilotan/isbot/releases/tag/v1.0.0)
|
||||
|
||||
No functional change
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
(()=>{var a=(e,t)=>()=>(e&&(t=e(e=0)),t);var c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var s,i=a(()=>{s=" daum[ /]| deusu/|(?:^|[^g])news(?!sapphire)|(?<! channel/|google/)google(?!(?:wv|app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!cam)scan|(?<!lib)http|24x7|;\\s\\w+;$|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\b\\w+/1\\.0;|\\bbw/|\\bdlc\\b|\\bort/|\\bperl\\b|\\btime/|\\||^[<\\(;]|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[\\w\\-]+/[\\w]+$|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^\\w+/\\d\\.\\d\\s\\([\\w@]+\\)$|^active|^ad muncher|^amaya|^apache/|^avsdevicesdk/|^azure|^biglotron|^blackbox exporter|^bot|^clamav[ /]|^claude-code/|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^exodusmovement|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\((?:compatible;)?(?:\\s?[\\w\\d-.]+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^ps_daily/|^python|^rank|^read|^reed|^remove\\.bg/|^rest|^rss|^snapchat|^sora |^space bison|^stape/|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|abuse|advisor|agent\\b|analyzer|archive|ask jeeves/teoma|attracta|audit|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|collapsify\\b|convertify|cookiehubverify/|crawl|cursor/|cypress/|dareboost|datanyze|dejaclick|detect|discovery|dmbrowser|download|exaleadcloudview|feed|firephp|foregenix|functionize|grab|hardenize\\b|headless|hotjar|httrack|hubspot marketing grader|ibisbrowser|infrawatch|insight|inspect|iplabel|java(?!;)|library|linkcheck|linktiger|mail\\.ru/|manager|manus-user/|marketgoo/|measure|monitor\\b|neustar wpm|node\\b|nutch|offbyone|openvas|optimize|pageburst|pagespeed|parser|phantomjs|pingdom|playwright|powermarks|preview|productfinder|prospectingstudio|proxy|ptst[ /]\\d|radar|readable/|retriever|rexx;|rigor|rss\\b|scrape|securityheaders|selenium|server|silktide|sindup/|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|testlocally|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|watchtowr|webglance|webkit2png|whatcms/|xtate/"});function l(){if(o instanceof RegExp)return o;try{o=new RegExp(s,"i")}catch(e){o=p}return o}function r(e){return b(e)&&l().test(e)}var p,o,b,n=a(()=>{i();p=/bot|crawl|http|lighthouse|scan|search|spider/i;b=e=>typeof e=="string"&&e!==""});var d=c(()=>{n();["isbot","isBot"].forEach(e=>{if(typeof globalThis=="object"){Object.defineProperty(globalThis,e,{value:r,enumerable:!1,configurable:!0});return}if(typeof window=="object"){Object.defineProperty(window,e,{value:r,enumerable:!1,configurable:!0});return}if(typeof global=="object"){Object.defineProperty(global,e,{value:r,enumerable:!1,configurable:!0});return}typeof self=="object"&&Object.defineProperty(self,e,{value:r,enumerable:!1,configurable:!0})})});d();})();
|
||||
//# sourceMappingURL=browser.global.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["src/pattern.ts","src/index.ts","src/browser.ts"],"sourcesContent":["export const fullPattern: string = \" daum\\[ \\/\\]| deusu\\/|\\(\\?:\\^\\|\\[\\^g\\]\\)news\\(\\?!sapphire\\)|\\(\\?<! channel\\/\\|google\\/\\)google\\(\\?!\\(\\?:wv\\|app\\|\\/google\\| pixel\\)\\)|\\(\\?<! cu\\)bots\\?\\(\\?:\\\\b\\|_\\)|\\(\\?<!cam\\)scan|\\(\\?<!lib\\)http|24x7|;\\\\s\\\\w\\+;\\$|@\\[a-z\\]\\[\\\\w-\\]\\+\\\\\\.|\\\\\\(\\\\\\)|\\\\\\.com\\\\b|\\\\b\\\\w\\+\\/1\\\\\\.0;|\\\\bbw\\/|\\\\bdlc\\\\b|\\\\bort\\/|\\\\bperl\\\\b|\\\\btime\\/|\\\\\\||\\^\\[<\\\\\\(;\\]|\\^\\[\\\\w \\\\\\.\\\\-\\\\\\(\\?:\\\\\\):%\\]\\+\\(\\?:\\/v\\?\\\\d\\+\\(\\?:\\\\\\.\\\\d\\+\\)\\?\\(\\?:\\\\\\.\\\\d\\{1,10\\}\\)\\*\\?\\)\\?\\(\\?:,\\|\\$\\)|\\^\\[\\\\w\\\\-\\]\\+\\/\\[\\\\w\\]\\+\\$|\\^\\[\\^ \\]\\{50,\\}\\$|\\^\\\\d\\+\\\\b|\\^\\\\w\\*search\\\\b|\\^\\\\w\\+\\/\\[\\\\w\\\\\\(\\\\\\)\\]\\*\\$|\\^\\\\w\\+\\/\\\\d\\\\\\.\\\\d\\\\s\\\\\\(\\[\\\\w@\\]\\+\\\\\\)\\$|\\^active|\\^ad muncher|\\^amaya|\\^apache\\/|\\^avsdevicesdk\\/|\\^azure|\\^biglotron|\\^blackbox exporter|\\^bot|\\^clamav\\[ \\/\\]|\\^claude-code\\/|\\^client\\/|\\^cobweb\\/|\\^custom|\\^ddg\\[_-\\]android|\\^discourse|\\^dispatch\\/\\\\d|\\^downcast\\/|\\^duckduckgo|\\^email|\\^exodusmovement|\\^facebook|\\^getright\\/|\\^gozilla\\/|\\^hobbit|\\^hotzonu|\\^hwcdn\\/|\\^igetter\\/|\\^jeode\\/|\\^jetty\\/|\\^jigsaw|\\^microsoft bits|\\^movabletype|\\^mozilla\\/\\\\d\\\\\\.\\\\d\\\\s\\[\\\\w\\\\\\.-\\]\\+\\$|\\^mozilla\\/\\\\d\\\\\\.\\\\d\\\\s\\\\\\(\\(\\?:compatible;\\)\\?\\(\\?:\\\\s\\?\\[\\\\w\\\\d-\\.\\]\\+\\\\\\/\\\\d\\+\\\\\\.\\\\d\\+\\)\\?\\\\\\)\\$|\\^navermailapp|\\^netsurf|\\^offline|\\^openai\\/|\\^owler|\\^php|\\^postman|\\^ps_daily\\/|\\^python|\\^rank|\\^read|\\^reed|\\^remove\\\\\\.bg\\/|\\^rest|\\^rss|\\^snapchat|\\^sora |\\^space bison|\\^stape\\/|\\^svn|\\^swcd |\\^taringa|\\^thumbor\\/|\\^track|\\^w3c|\\^webbandit\\/|\\^webcopier|\\^wget|\\^whatsapp|\\^wordpress|\\^xenu link sleuth|\\^yahoo|\\^yandex|\\^zdm\\/\\\\d|\\^zoom marketplace\\/|abuse|advisor|agent\\\\b|analyzer|archive|ask jeeves\\/teoma|attracta|audit|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|collapsify\\\\b|convertify|cookiehubverify\\/|crawl|cursor\\/|cypress\\/|dareboost|datanyze|dejaclick|detect|discovery|dmbrowser|download|exaleadcloudview|feed|firephp|foregenix|functionize|grab|hardenize\\\\b|headless|hotjar|httrack|hubspot marketing grader|ibisbrowser|infrawatch|insight|inspect|iplabel|java\\(\\?!;\\)|library|linkcheck|linktiger|mail\\\\\\.ru\\/|manager|manus-user\\/|marketgoo\\/|measure|monitor\\\\b|neustar wpm|node\\\\b|nutch|offbyone|openvas|optimize|pageburst|pagespeed|parser|phantomjs|pingdom|playwright|powermarks|preview|productfinder|prospectingstudio|proxy|ptst\\[ \\/\\]\\\\d|radar|readable\\/|retriever|rexx;|rigor|rss\\\\b|scrape|securityheaders|selenium|server|silktide|sindup\\/|sogou|sparkler\\/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|testlocally|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|watchtowr|webglance|webkit2png|whatcms\\/|xtate\\/\";\n","import patternsList from \"./patterns.json\";\nimport { fullPattern } from \"./pattern.ts\";\n\n/**\n * Naive bot pattern.\n */\nconst naivePattern = /bot|crawl|http|lighthouse|scan|search|spider/i;\n\nlet pattern: RegExp;\nexport function getPattern(): RegExp {\n\tif (pattern instanceof RegExp) {\n\t\treturn pattern;\n\t}\n\ttry {\n\t\t// Build this RegExp dynamically to avoid syntax errors in older engines.\n\t\tpattern = new RegExp(fullPattern, \"i\");\n\t} catch (error) {\n\t\tpattern = naivePattern;\n\t}\n\treturn pattern;\n}\n\nconst isNonEmptyString = (value: unknown): value is string =>\n\ttypeof value === \"string\" && value !== \"\";\n\n/**\n * A list of bot identifiers to be used in a regular expression against user agent strings.\n */\nexport const list: string[] = patternsList;\n\n/**\n * Check if the given user agent includes a bot pattern.\n */\nexport function isBot(userAgent?: string | null): boolean {\n\treturn isNonEmptyString(userAgent) && getPattern().test(userAgent);\n}\n\n/**\n * Check if the given user agent includes a bot pattern. Naive implementation (less accurate).\n */\nexport const isBotNaive: typeof isBot = (userAgent) =>\n\tisNonEmptyString(userAgent) && naivePattern.test(userAgent);\n\n/**\n * Create a custom isBot function with a custom pattern.\n */\nexport const createIsBot: (customPattern: RegExp) => typeof isBot =\n\t(customPattern) => (userAgent) =>\n\t\tisNonEmptyString(userAgent) && customPattern.test(userAgent);\n\n/**\n * Create a custom isBot function with a custom pattern.\n */\nexport const createIsBotFromList = (list: string[]): typeof isBot => {\n\tconst pattern = new RegExp(list.join(\"|\"), \"i\");\n\treturn (userAgent) => isNonEmptyString(userAgent) && pattern.test(userAgent);\n};\n\n/**\n * Find the first part of the user agent that matches a bLine truncated
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
declare function getPattern(): RegExp;
|
||||
/**
|
||||
* A list of bot identifiers to be used in a regular expression against user agent strings.
|
||||
*/
|
||||
declare const list: string[];
|
||||
/**
|
||||
* Check if the given user agent includes a bot pattern.
|
||||
*/
|
||||
declare function isBot(userAgent?: string | null): boolean;
|
||||
/**
|
||||
* Check if the given user agent includes a bot pattern. Naive implementation (less accurate).
|
||||
*/
|
||||
declare const isBotNaive: typeof isBot;
|
||||
/**
|
||||
* Create a custom isBot function with a custom pattern.
|
||||
*/
|
||||
declare const createIsBot: (customPattern: RegExp) => typeof isBot;
|
||||
/**
|
||||
* Create a custom isBot function with a custom pattern.
|
||||
*/
|
||||
declare const createIsBotFromList: (list: string[]) => typeof isBot;
|
||||
/**
|
||||
* Find the first part of the user agent that matches a bot pattern.
|
||||
*/
|
||||
declare const findBotMatch: (userAgent: Parameters<typeof isBot>[0]) => string | null;
|
||||
/**
|
||||
* Find all parts of the user agent that match a bot pattern.
|
||||
*/
|
||||
declare const findBotMatches: (userAgent: Parameters<typeof isBot>[0]) => string[];
|
||||
/**
|
||||
* Find the first bot pattern that match the given user agent.
|
||||
*/
|
||||
declare const findBotPattern: (userAgent: Parameters<typeof isBot>[0]) => string | null;
|
||||
/**
|
||||
* Find all bot patterns that match the given user agent.
|
||||
*/
|
||||
declare const findBotPatterns: (userAgent: Parameters<typeof isBot>[0]) => string[];
|
||||
/**
|
||||
* Check if the given user agent includes a bot pattern.
|
||||
*/
|
||||
declare const isbot: typeof isBot;
|
||||
/**
|
||||
* Check if the given user agent includes a bot pattern. Naive implementation (less accurate).
|
||||
*/
|
||||
declare const isbotNaive: typeof isBot;
|
||||
/**
|
||||
* Create a custom isBot function with a custom pattern.
|
||||
*/
|
||||
declare const createIsbot: (customPattern: RegExp) => typeof isBot;
|
||||
/**
|
||||
* Create a custom isBot function with a custom pattern.
|
||||
*/
|
||||
declare const createIsbotFromList: (list: string[]) => typeof isBot;
|
||||
/**
|
||||
* Find the first part of the user agent that matches a bot pattern.
|
||||
*/
|
||||
declare const isbotMatch: (userAgent: Parameters<typeof isBot>[0]) => string | null;
|
||||
/**
|
||||
* Find all parts of the user agent that match a bot pattern.
|
||||
*/
|
||||
declare const isbotMatches: (userAgent: Parameters<typeof isBot>[0]) => string[];
|
||||
/**
|
||||
* Find the first bot pattern that match the given user agent.
|
||||
*/
|
||||
declare const isbotPattern: (userAgent: Parameters<typeof isBot>[0]) => string | null;
|
||||
/**
|
||||
* Find all bot patterns that match the given user agent.
|
||||
*/
|
||||
declare const isbotPatterns: (userAgent: Parameters<typeof isBot>[0]) => string[];
|
||||
|
||||
export { createIsBot, createIsBotFromList, createIsbot, createIsbotFromList, findBotMatch, findBotMatches, findBotPattern, findBotPatterns, getPattern, isBot, isBotNaive, isbot, isbotMatch, isbotMatches, isbotNaive, isbotPattern, isbotPatterns, list };
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
declare function getPattern(): RegExp;
|
||||
/**
|
||||
* A list of bot identifiers to be used in a regular expression against user agent strings.
|
||||
*/
|
||||
declare const list: string[];
|
||||
/**
|
||||
* Check if the given user agent includes a bot pattern.
|
||||
*/
|
||||
declare function isBot(userAgent?: string | null): boolean;
|
||||
/**
|
||||
* Check if the given user agent includes a bot pattern. Naive implementation (less accurate).
|
||||
*/
|
||||
declare const isBotNaive: typeof isBot;
|
||||
/**
|
||||
* Create a custom isBot function with a custom pattern.
|
||||
*/
|
||||
declare const createIsBot: (customPattern: RegExp) => typeof isBot;
|
||||
/**
|
||||
* Create a custom isBot function with a custom pattern.
|
||||
*/
|
||||
declare const createIsBotFromList: (list: string[]) => typeof isBot;
|
||||
/**
|
||||
* Find the first part of the user agent that matches a bot pattern.
|
||||
*/
|
||||
declare const findBotMatch: (userAgent: Parameters<typeof isBot>[0]) => string | null;
|
||||
/**
|
||||
* Find all parts of the user agent that match a bot pattern.
|
||||
*/
|
||||
declare const findBotMatches: (userAgent: Parameters<typeof isBot>[0]) => string[];
|
||||
/**
|
||||
* Find the first bot pattern that match the given user agent.
|
||||
*/
|
||||
declare const findBotPattern: (userAgent: Parameters<typeof isBot>[0]) => string | null;
|
||||
/**
|
||||
* Find all bot patterns that match the given user agent.
|
||||
*/
|
||||
declare const findBotPatterns: (userAgent: Parameters<typeof isBot>[0]) => string[];
|
||||
/**
|
||||
* Check if the given user agent includes a bot pattern.
|
||||
*/
|
||||
declare const isbot: typeof isBot;
|
||||
/**
|
||||
* Check if the given user agent includes a bot pattern. Naive implementation (less accurate).
|
||||
*/
|
||||
declare const isbotNaive: typeof isBot;
|
||||
/**
|
||||
* Create a custom isBot function with a custom pattern.
|
||||
*/
|
||||
declare const createIsbot: (customPattern: RegExp) => typeof isBot;
|
||||
/**
|
||||
* Create a custom isBot function with a custom pattern.
|
||||
*/
|
||||
declare const createIsbotFromList: (list: string[]) => typeof isBot;
|
||||
/**
|
||||
* Find the first part of the user agent that matches a bot pattern.
|
||||
*/
|
||||
declare const isbotMatch: (userAgent: Parameters<typeof isBot>[0]) => string | null;
|
||||
/**
|
||||
* Find all parts of the user agent that match a bot pattern.
|
||||
*/
|
||||
declare const isbotMatches: (userAgent: Parameters<typeof isBot>[0]) => string[];
|
||||
/**
|
||||
* Find the first bot pattern that match the given user agent.
|
||||
*/
|
||||
declare const isbotPattern: (userAgent: Parameters<typeof isBot>[0]) => string | null;
|
||||
/**
|
||||
* Find all bot patterns that match the given user agent.
|
||||
*/
|
||||
declare const isbotPatterns: (userAgent: Parameters<typeof isBot>[0]) => string[];
|
||||
|
||||
export { createIsBot, createIsBotFromList, createIsbot, createIsbotFromList, findBotMatch, findBotMatches, findBotPattern, findBotPatterns, getPattern, isBot, isBotNaive, isbot, isbotMatch, isbotMatches, isbotNaive, isbotPattern, isbotPatterns, list };
|
||||
+323
@@ -0,0 +1,323 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
createIsBot: () => createIsBot,
|
||||
createIsBotFromList: () => createIsBotFromList,
|
||||
createIsbot: () => createIsbot,
|
||||
createIsbotFromList: () => createIsbotFromList,
|
||||
findBotMatch: () => findBotMatch,
|
||||
findBotMatches: () => findBotMatches,
|
||||
findBotPattern: () => findBotPattern,
|
||||
findBotPatterns: () => findBotPatterns,
|
||||
getPattern: () => getPattern,
|
||||
isBot: () => isBot,
|
||||
isBotNaive: () => isBotNaive,
|
||||
isbot: () => isbot,
|
||||
isbotMatch: () => isbotMatch,
|
||||
isbotMatches: () => isbotMatches,
|
||||
isbotNaive: () => isbotNaive,
|
||||
isbotPattern: () => isbotPattern,
|
||||
isbotPatterns: () => isbotPatterns,
|
||||
list: () => list
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
|
||||
// src/patterns.json
|
||||
var patterns_default = [
|
||||
" daum[ /]",
|
||||
" deusu/",
|
||||
"(?:^|[^g])news(?!sapphire)",
|
||||
"(?<! channel/|google/)google(?!(?:wv|app|/google| pixel))",
|
||||
"(?<! cu)bots?(?:\\b|_)",
|
||||
"(?<!cam)scan",
|
||||
"(?<!lib)http",
|
||||
"24x7",
|
||||
";\\s\\w+;$",
|
||||
"@[a-z][\\w-]+\\.",
|
||||
"\\(\\)",
|
||||
"\\.com\\b",
|
||||
"\\b\\w+/1\\.0;",
|
||||
"\\bbw/",
|
||||
"\\bdlc\\b",
|
||||
"\\bort/",
|
||||
"\\bperl\\b",
|
||||
"\\btime/",
|
||||
"\\|",
|
||||
"^[<\\(;]",
|
||||
"^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)",
|
||||
"^[\\w\\-]+/[\\w]+$",
|
||||
"^[^ ]{50,}$",
|
||||
"^\\d+\\b",
|
||||
"^\\w*search\\b",
|
||||
"^\\w+/[\\w\\(\\)]*$",
|
||||
"^\\w+/\\d\\.\\d\\s\\([\\w@]+\\)$",
|
||||
"^active",
|
||||
"^ad muncher",
|
||||
"^amaya",
|
||||
"^apache/",
|
||||
"^avsdevicesdk/",
|
||||
"^azure",
|
||||
"^biglotron",
|
||||
"^blackbox exporter",
|
||||
"^bot",
|
||||
"^clamav[ /]",
|
||||
"^claude-code/",
|
||||
"^client/",
|
||||
"^cobweb/",
|
||||
"^custom",
|
||||
"^ddg[_-]android",
|
||||
"^discourse",
|
||||
"^dispatch/\\d",
|
||||
"^downcast/",
|
||||
"^duckduckgo",
|
||||
"^email",
|
||||
"^exodusmovement",
|
||||
"^facebook",
|
||||
"^getright/",
|
||||
"^gozilla/",
|
||||
"^hobbit",
|
||||
"^hotzonu",
|
||||
"^hwcdn/",
|
||||
"^igetter/",
|
||||
"^jeode/",
|
||||
"^jetty/",
|
||||
"^jigsaw",
|
||||
"^microsoft bits",
|
||||
"^movabletype",
|
||||
"^mozilla/\\d\\.\\d\\s[\\w\\.-]+$",
|
||||
"^mozilla/\\d\\.\\d\\s\\((?:compatible;)?(?:\\s?[\\w\\d-.]+\\/\\d+\\.\\d+)?\\)$",
|
||||
"^navermailapp",
|
||||
"^netsurf",
|
||||
"^offline",
|
||||
"^openai/",
|
||||
"^owler",
|
||||
"^php",
|
||||
"^postman",
|
||||
"^ps_daily/",
|
||||
"^python",
|
||||
"^rank",
|
||||
"^read",
|
||||
"^reed",
|
||||
"^remove\\.bg/",
|
||||
"^rest",
|
||||
"^rss",
|
||||
"^snapchat",
|
||||
"^sora ",
|
||||
"^space bison",
|
||||
"^stape/",
|
||||
"^svn",
|
||||
"^swcd ",
|
||||
"^taringa",
|
||||
"^thumbor/",
|
||||
"^track",
|
||||
"^w3c",
|
||||
"^webbandit/",
|
||||
"^webcopier",
|
||||
"^wget",
|
||||
"^whatsapp",
|
||||
"^wordpress",
|
||||
"^xenu link sleuth",
|
||||
"^yahoo",
|
||||
"^yandex",
|
||||
"^zdm/\\d",
|
||||
"^zoom marketplace/",
|
||||
"abuse",
|
||||
"advisor",
|
||||
"agent\\b",
|
||||
"analyzer",
|
||||
"archive",
|
||||
"ask jeeves/teoma",
|
||||
"attracta",
|
||||
"audit",
|
||||
"bluecoat drtr",
|
||||
"browsex",
|
||||
"burpcollaborator",
|
||||
"capture",
|
||||
"catch",
|
||||
"check\\b",
|
||||
"checker",
|
||||
"chrome-lighthouse",
|
||||
"chromeframe",
|
||||
"classifier",
|
||||
"cloudflare",
|
||||
"collapsify\\b",
|
||||
"convertify",
|
||||
"cookiehubverify/",
|
||||
"crawl",
|
||||
"cursor/",
|
||||
"cypress/",
|
||||
"dareboost",
|
||||
"datanyze",
|
||||
"dejaclick",
|
||||
"detect",
|
||||
"discovery",
|
||||
"dmbrowser",
|
||||
"download",
|
||||
"exaleadcloudview",
|
||||
"feed",
|
||||
"firephp",
|
||||
"foregenix",
|
||||
"functionize",
|
||||
"grab",
|
||||
"hardenize\\b",
|
||||
"headless",
|
||||
"hotjar",
|
||||
"httrack",
|
||||
"hubspot marketing grader",
|
||||
"ibisbrowser",
|
||||
"infrawatch",
|
||||
"insight",
|
||||
"inspect",
|
||||
"iplabel",
|
||||
"java(?!;)",
|
||||
"library",
|
||||
"linkcheck",
|
||||
"linktiger",
|
||||
"mail\\.ru/",
|
||||
"manager",
|
||||
"manus-user/",
|
||||
"marketgoo/",
|
||||
"measure",
|
||||
"monitor\\b",
|
||||
"neustar wpm",
|
||||
"node\\b",
|
||||
"nutch",
|
||||
"offbyone",
|
||||
"openvas",
|
||||
"optimize",
|
||||
"pageburst",
|
||||
"pagespeed",
|
||||
"parser",
|
||||
"phantomjs",
|
||||
"pingdom",
|
||||
"playwright",
|
||||
"powermarks",
|
||||
"preview",
|
||||
"productfinder",
|
||||
"prospectingstudio",
|
||||
"proxy",
|
||||
"ptst[ /]\\d",
|
||||
"radar",
|
||||
"readable/",
|
||||
"retriever",
|
||||
"rexx;",
|
||||
"rigor",
|
||||
"rss\\b",
|
||||
"scrape",
|
||||
"securityheaders",
|
||||
"selenium",
|
||||
"server",
|
||||
"silktide",
|
||||
"sindup/",
|
||||
"sogou",
|
||||
"sparkler/",
|
||||
"speedcurve",
|
||||
"spider",
|
||||
"splash",
|
||||
"statuscake",
|
||||
"supercleaner",
|
||||
"synapse",
|
||||
"synthetic",
|
||||
"testlocally",
|
||||
"tools",
|
||||
"torrent",
|
||||
"transcoder",
|
||||
"url",
|
||||
"validator",
|
||||
"virtuoso",
|
||||
"wappalyzer",
|
||||
"watchtowr",
|
||||
"webglance",
|
||||
"webkit2png",
|
||||
"whatcms/",
|
||||
"xtate/"
|
||||
];
|
||||
|
||||
// src/pattern.ts
|
||||
var fullPattern = " daum[ /]| deusu/|(?:^|[^g])news(?!sapphire)|(?<! channel/|google/)google(?!(?:wv|app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!cam)scan|(?<!lib)http|24x7|;\\s\\w+;$|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\b\\w+/1\\.0;|\\bbw/|\\bdlc\\b|\\bort/|\\bperl\\b|\\btime/|\\||^[<\\(;]|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[\\w\\-]+/[\\w]+$|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^\\w+/\\d\\.\\d\\s\\([\\w@]+\\)$|^active|^ad muncher|^amaya|^apache/|^avsdevicesdk/|^azure|^biglotron|^blackbox exporter|^bot|^clamav[ /]|^claude-code/|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^exodusmovement|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\((?:compatible;)?(?:\\s?[\\w\\d-.]+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^ps_daily/|^python|^rank|^read|^reed|^remove\\.bg/|^rest|^rss|^snapchat|^sora |^space bison|^stape/|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|abuse|advisor|agent\\b|analyzer|archive|ask jeeves/teoma|attracta|audit|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|collapsify\\b|convertify|cookiehubverify/|crawl|cursor/|cypress/|dareboost|datanyze|dejaclick|detect|discovery|dmbrowser|download|exaleadcloudview|feed|firephp|foregenix|functionize|grab|hardenize\\b|headless|hotjar|httrack|hubspot marketing grader|ibisbrowser|infrawatch|insight|inspect|iplabel|java(?!;)|library|linkcheck|linktiger|mail\\.ru/|manager|manus-user/|marketgoo/|measure|monitor\\b|neustar wpm|node\\b|nutch|offbyone|openvas|optimize|pageburst|pagespeed|parser|phantomjs|pingdom|playwright|powermarks|preview|productfinder|prospectingstudio|proxy|ptst[ /]\\d|radar|readable/|retriever|rexx;|rigor|rss\\b|scrape|securityheaders|selenium|server|silktide|sindup/|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|testlocally|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|watchtowr|webglance|webkit2png|whatcms/|xtate/";
|
||||
|
||||
// src/index.ts
|
||||
var naivePattern = /bot|crawl|http|lighthouse|scan|search|spider/i;
|
||||
var pattern;
|
||||
function getPattern() {
|
||||
if (pattern instanceof RegExp) {
|
||||
return pattern;
|
||||
}
|
||||
try {
|
||||
pattern = new RegExp(fullPattern, "i");
|
||||
} catch (error) {
|
||||
pattern = naivePattern;
|
||||
}
|
||||
return pattern;
|
||||
}
|
||||
var isNonEmptyString = (value) => typeof value === "string" && value !== "";
|
||||
var list = patterns_default;
|
||||
function isBot(userAgent) {
|
||||
return isNonEmptyString(userAgent) && getPattern().test(userAgent);
|
||||
}
|
||||
var isBotNaive = (userAgent) => isNonEmptyString(userAgent) && naivePattern.test(userAgent);
|
||||
var createIsBot = (customPattern) => (userAgent) => isNonEmptyString(userAgent) && customPattern.test(userAgent);
|
||||
var createIsBotFromList = (list2) => {
|
||||
const pattern2 = new RegExp(list2.join("|"), "i");
|
||||
return (userAgent) => isNonEmptyString(userAgent) && pattern2.test(userAgent);
|
||||
};
|
||||
var findBotMatch = (userAgent) => {
|
||||
var _a, _b;
|
||||
return (_b = (_a = userAgent == null ? void 0 : userAgent.match(getPattern())) == null ? void 0 : _a[0]) != null ? _b : null;
|
||||
};
|
||||
var findBotMatches = (userAgent) => list.map((part) => {
|
||||
var _a;
|
||||
return (_a = userAgent == null ? void 0 : userAgent.match(new RegExp(part, "i"))) == null ? void 0 : _a[0];
|
||||
}).filter(isNonEmptyString);
|
||||
var findBotPattern = (userAgent) => {
|
||||
var _a;
|
||||
return userAgent ? (_a = list.find((pattern2) => new RegExp(pattern2, "i").test(userAgent))) != null ? _a : null : null;
|
||||
};
|
||||
var findBotPatterns = (userAgent) => userAgent ? list.filter((pattern2) => new RegExp(pattern2, "i").test(userAgent)) : [];
|
||||
var isbot = isBot;
|
||||
var isbotNaive = isBotNaive;
|
||||
var createIsbot = createIsBot;
|
||||
var createIsbotFromList = createIsBotFromList;
|
||||
var isbotMatch = findBotMatch;
|
||||
var isbotMatches = findBotMatches;
|
||||
var isbotPattern = findBotPattern;
|
||||
var isbotPatterns = findBotPatterns;
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
createIsBot,
|
||||
createIsBotFromList,
|
||||
createIsbot,
|
||||
createIsbotFromList,
|
||||
findBotMatch,
|
||||
findBotMatches,
|
||||
findBotPattern,
|
||||
findBotPatterns,
|
||||
getPattern,
|
||||
isBot,
|
||||
isBotNaive,
|
||||
isbot,
|
||||
isbotMatch,
|
||||
isbotMatches,
|
||||
isbotNaive,
|
||||
isbotPattern,
|
||||
isbotPatterns,
|
||||
list
|
||||
});
|
||||
+280
@@ -0,0 +1,280 @@
|
||||
// src/patterns.json
|
||||
var patterns_default = [
|
||||
" daum[ /]",
|
||||
" deusu/",
|
||||
"(?:^|[^g])news(?!sapphire)",
|
||||
"(?<! channel/|google/)google(?!(?:wv|app|/google| pixel))",
|
||||
"(?<! cu)bots?(?:\\b|_)",
|
||||
"(?<!cam)scan",
|
||||
"(?<!lib)http",
|
||||
"24x7",
|
||||
";\\s\\w+;$",
|
||||
"@[a-z][\\w-]+\\.",
|
||||
"\\(\\)",
|
||||
"\\.com\\b",
|
||||
"\\b\\w+/1\\.0;",
|
||||
"\\bbw/",
|
||||
"\\bdlc\\b",
|
||||
"\\bort/",
|
||||
"\\bperl\\b",
|
||||
"\\btime/",
|
||||
"\\|",
|
||||
"^[<\\(;]",
|
||||
"^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)",
|
||||
"^[\\w\\-]+/[\\w]+$",
|
||||
"^[^ ]{50,}$",
|
||||
"^\\d+\\b",
|
||||
"^\\w*search\\b",
|
||||
"^\\w+/[\\w\\(\\)]*$",
|
||||
"^\\w+/\\d\\.\\d\\s\\([\\w@]+\\)$",
|
||||
"^active",
|
||||
"^ad muncher",
|
||||
"^amaya",
|
||||
"^apache/",
|
||||
"^avsdevicesdk/",
|
||||
"^azure",
|
||||
"^biglotron",
|
||||
"^blackbox exporter",
|
||||
"^bot",
|
||||
"^clamav[ /]",
|
||||
"^claude-code/",
|
||||
"^client/",
|
||||
"^cobweb/",
|
||||
"^custom",
|
||||
"^ddg[_-]android",
|
||||
"^discourse",
|
||||
"^dispatch/\\d",
|
||||
"^downcast/",
|
||||
"^duckduckgo",
|
||||
"^email",
|
||||
"^exodusmovement",
|
||||
"^facebook",
|
||||
"^getright/",
|
||||
"^gozilla/",
|
||||
"^hobbit",
|
||||
"^hotzonu",
|
||||
"^hwcdn/",
|
||||
"^igetter/",
|
||||
"^jeode/",
|
||||
"^jetty/",
|
||||
"^jigsaw",
|
||||
"^microsoft bits",
|
||||
"^movabletype",
|
||||
"^mozilla/\\d\\.\\d\\s[\\w\\.-]+$",
|
||||
"^mozilla/\\d\\.\\d\\s\\((?:compatible;)?(?:\\s?[\\w\\d-.]+\\/\\d+\\.\\d+)?\\)$",
|
||||
"^navermailapp",
|
||||
"^netsurf",
|
||||
"^offline",
|
||||
"^openai/",
|
||||
"^owler",
|
||||
"^php",
|
||||
"^postman",
|
||||
"^ps_daily/",
|
||||
"^python",
|
||||
"^rank",
|
||||
"^read",
|
||||
"^reed",
|
||||
"^remove\\.bg/",
|
||||
"^rest",
|
||||
"^rss",
|
||||
"^snapchat",
|
||||
"^sora ",
|
||||
"^space bison",
|
||||
"^stape/",
|
||||
"^svn",
|
||||
"^swcd ",
|
||||
"^taringa",
|
||||
"^thumbor/",
|
||||
"^track",
|
||||
"^w3c",
|
||||
"^webbandit/",
|
||||
"^webcopier",
|
||||
"^wget",
|
||||
"^whatsapp",
|
||||
"^wordpress",
|
||||
"^xenu link sleuth",
|
||||
"^yahoo",
|
||||
"^yandex",
|
||||
"^zdm/\\d",
|
||||
"^zoom marketplace/",
|
||||
"abuse",
|
||||
"advisor",
|
||||
"agent\\b",
|
||||
"analyzer",
|
||||
"archive",
|
||||
"ask jeeves/teoma",
|
||||
"attracta",
|
||||
"audit",
|
||||
"bluecoat drtr",
|
||||
"browsex",
|
||||
"burpcollaborator",
|
||||
"capture",
|
||||
"catch",
|
||||
"check\\b",
|
||||
"checker",
|
||||
"chrome-lighthouse",
|
||||
"chromeframe",
|
||||
"classifier",
|
||||
"cloudflare",
|
||||
"collapsify\\b",
|
||||
"convertify",
|
||||
"cookiehubverify/",
|
||||
"crawl",
|
||||
"cursor/",
|
||||
"cypress/",
|
||||
"dareboost",
|
||||
"datanyze",
|
||||
"dejaclick",
|
||||
"detect",
|
||||
"discovery",
|
||||
"dmbrowser",
|
||||
"download",
|
||||
"exaleadcloudview",
|
||||
"feed",
|
||||
"firephp",
|
||||
"foregenix",
|
||||
"functionize",
|
||||
"grab",
|
||||
"hardenize\\b",
|
||||
"headless",
|
||||
"hotjar",
|
||||
"httrack",
|
||||
"hubspot marketing grader",
|
||||
"ibisbrowser",
|
||||
"infrawatch",
|
||||
"insight",
|
||||
"inspect",
|
||||
"iplabel",
|
||||
"java(?!;)",
|
||||
"library",
|
||||
"linkcheck",
|
||||
"linktiger",
|
||||
"mail\\.ru/",
|
||||
"manager",
|
||||
"manus-user/",
|
||||
"marketgoo/",
|
||||
"measure",
|
||||
"monitor\\b",
|
||||
"neustar wpm",
|
||||
"node\\b",
|
||||
"nutch",
|
||||
"offbyone",
|
||||
"openvas",
|
||||
"optimize",
|
||||
"pageburst",
|
||||
"pagespeed",
|
||||
"parser",
|
||||
"phantomjs",
|
||||
"pingdom",
|
||||
"playwright",
|
||||
"powermarks",
|
||||
"preview",
|
||||
"productfinder",
|
||||
"prospectingstudio",
|
||||
"proxy",
|
||||
"ptst[ /]\\d",
|
||||
"radar",
|
||||
"readable/",
|
||||
"retriever",
|
||||
"rexx;",
|
||||
"rigor",
|
||||
"rss\\b",
|
||||
"scrape",
|
||||
"securityheaders",
|
||||
"selenium",
|
||||
"server",
|
||||
"silktide",
|
||||
"sindup/",
|
||||
"sogou",
|
||||
"sparkler/",
|
||||
"speedcurve",
|
||||
"spider",
|
||||
"splash",
|
||||
"statuscake",
|
||||
"supercleaner",
|
||||
"synapse",
|
||||
"synthetic",
|
||||
"testlocally",
|
||||
"tools",
|
||||
"torrent",
|
||||
"transcoder",
|
||||
"url",
|
||||
"validator",
|
||||
"virtuoso",
|
||||
"wappalyzer",
|
||||
"watchtowr",
|
||||
"webglance",
|
||||
"webkit2png",
|
||||
"whatcms/",
|
||||
"xtate/"
|
||||
];
|
||||
|
||||
// src/pattern.ts
|
||||
var fullPattern = " daum[ /]| deusu/|(?:^|[^g])news(?!sapphire)|(?<! channel/|google/)google(?!(?:wv|app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!cam)scan|(?<!lib)http|24x7|;\\s\\w+;$|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\b\\w+/1\\.0;|\\bbw/|\\bdlc\\b|\\bort/|\\bperl\\b|\\btime/|\\||^[<\\(;]|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[\\w\\-]+/[\\w]+$|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^\\w+/\\d\\.\\d\\s\\([\\w@]+\\)$|^active|^ad muncher|^amaya|^apache/|^avsdevicesdk/|^azure|^biglotron|^blackbox exporter|^bot|^clamav[ /]|^claude-code/|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^exodusmovement|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\((?:compatible;)?(?:\\s?[\\w\\d-.]+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^ps_daily/|^python|^rank|^read|^reed|^remove\\.bg/|^rest|^rss|^snapchat|^sora |^space bison|^stape/|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|abuse|advisor|agent\\b|analyzer|archive|ask jeeves/teoma|attracta|audit|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|collapsify\\b|convertify|cookiehubverify/|crawl|cursor/|cypress/|dareboost|datanyze|dejaclick|detect|discovery|dmbrowser|download|exaleadcloudview|feed|firephp|foregenix|functionize|grab|hardenize\\b|headless|hotjar|httrack|hubspot marketing grader|ibisbrowser|infrawatch|insight|inspect|iplabel|java(?!;)|library|linkcheck|linktiger|mail\\.ru/|manager|manus-user/|marketgoo/|measure|monitor\\b|neustar wpm|node\\b|nutch|offbyone|openvas|optimize|pageburst|pagespeed|parser|phantomjs|pingdom|playwright|powermarks|preview|productfinder|prospectingstudio|proxy|ptst[ /]\\d|radar|readable/|retriever|rexx;|rigor|rss\\b|scrape|securityheaders|selenium|server|silktide|sindup/|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|testlocally|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|watchtowr|webglance|webkit2png|whatcms/|xtate/";
|
||||
|
||||
// src/index.ts
|
||||
var naivePattern = /bot|crawl|http|lighthouse|scan|search|spider/i;
|
||||
var pattern;
|
||||
function getPattern() {
|
||||
if (pattern instanceof RegExp) {
|
||||
return pattern;
|
||||
}
|
||||
try {
|
||||
pattern = new RegExp(fullPattern, "i");
|
||||
} catch (error) {
|
||||
pattern = naivePattern;
|
||||
}
|
||||
return pattern;
|
||||
}
|
||||
var isNonEmptyString = (value) => typeof value === "string" && value !== "";
|
||||
var list = patterns_default;
|
||||
function isBot(userAgent) {
|
||||
return isNonEmptyString(userAgent) && getPattern().test(userAgent);
|
||||
}
|
||||
var isBotNaive = (userAgent) => isNonEmptyString(userAgent) && naivePattern.test(userAgent);
|
||||
var createIsBot = (customPattern) => (userAgent) => isNonEmptyString(userAgent) && customPattern.test(userAgent);
|
||||
var createIsBotFromList = (list2) => {
|
||||
const pattern2 = new RegExp(list2.join("|"), "i");
|
||||
return (userAgent) => isNonEmptyString(userAgent) && pattern2.test(userAgent);
|
||||
};
|
||||
var findBotMatch = (userAgent) => {
|
||||
var _a, _b;
|
||||
return (_b = (_a = userAgent == null ? void 0 : userAgent.match(getPattern())) == null ? void 0 : _a[0]) != null ? _b : null;
|
||||
};
|
||||
var findBotMatches = (userAgent) => list.map((part) => {
|
||||
var _a;
|
||||
return (_a = userAgent == null ? void 0 : userAgent.match(new RegExp(part, "i"))) == null ? void 0 : _a[0];
|
||||
}).filter(isNonEmptyString);
|
||||
var findBotPattern = (userAgent) => {
|
||||
var _a;
|
||||
return userAgent ? (_a = list.find((pattern2) => new RegExp(pattern2, "i").test(userAgent))) != null ? _a : null : null;
|
||||
};
|
||||
var findBotPatterns = (userAgent) => userAgent ? list.filter((pattern2) => new RegExp(pattern2, "i").test(userAgent)) : [];
|
||||
var isbot = isBot;
|
||||
var isbotNaive = isBotNaive;
|
||||
var createIsbot = createIsBot;
|
||||
var createIsbotFromList = createIsBotFromList;
|
||||
var isbotMatch = findBotMatch;
|
||||
var isbotMatches = findBotMatches;
|
||||
var isbotPattern = findBotPattern;
|
||||
var isbotPatterns = findBotPatterns;
|
||||
export {
|
||||
createIsBot,
|
||||
createIsBotFromList,
|
||||
createIsbot,
|
||||
createIsbotFromList,
|
||||
findBotMatch,
|
||||
findBotMatches,
|
||||
findBotPattern,
|
||||
findBotPatterns,
|
||||
getPattern,
|
||||
isBot,
|
||||
isBotNaive,
|
||||
isbot,
|
||||
isbotMatch,
|
||||
isbotMatches,
|
||||
isbotNaive,
|
||||
isbotPattern,
|
||||
isbotPatterns,
|
||||
list
|
||||
};
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"name": "isbot",
|
||||
"version": "5.2.2",
|
||||
"description": "🤖/👨🦰 Recognise bots/crawlers/spiders using the user agent string.",
|
||||
"keywords": [
|
||||
"bot",
|
||||
"crawlers",
|
||||
"spiders",
|
||||
"googlebot",
|
||||
"useragent",
|
||||
"user agent parsing",
|
||||
"🤖"
|
||||
],
|
||||
"license": "Unlicense",
|
||||
"homepage": "https://isbot.js.org",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/omrilotan/isbot.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"files": [
|
||||
"./browser.global*",
|
||||
"./index*",
|
||||
"./AUTHORS"
|
||||
],
|
||||
"type": "commonjs",
|
||||
"main": "./index.js",
|
||||
"module": "./index.mjs",
|
||||
"browser": "./index.mjs",
|
||||
"jsdelivr": "./browser.global.js",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"browser": {
|
||||
"import": "./index.mjs",
|
||||
"require": "./index.js"
|
||||
},
|
||||
"node": {
|
||||
"import": "./index.mjs",
|
||||
"require": "./index.js"
|
||||
},
|
||||
"import": "./index.mjs",
|
||||
"require": "./index.js",
|
||||
"default": "./index.js"
|
||||
}
|
||||
},
|
||||
"sideEffects": false,
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"prepare": "./scripts/prepare/index.js",
|
||||
"build": "./scripts/build/procedure.sh",
|
||||
"format": "./scripts/format/procedure.sh",
|
||||
"test": "./scripts/test/procedure.sh",
|
||||
"prepublishOnly": "./scripts/prepublish/procedure.sh",
|
||||
"prestart": "npm ls parcel-bundler --depth=0 >/dev/null 2>&1 || npm i parcel-bundler --no-save",
|
||||
"start": "npx --no-install parcel-bundler page/index.pug --out-dir docs",
|
||||
"prepage": "npm ls parcel-bundler --depth=0 >/dev/null 2>&1 || npm i parcel-bundler --no-save",
|
||||
"page": "npx --no-install parcel-bundler build page/index.pug --out-dir docs --public-url ./",
|
||||
"maintenance": "npm update && npm run prepare -- --force && npm run format && npm t"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^30.0.0",
|
||||
"jest": "^30.0.2",
|
||||
"prettier": "^3.6.0",
|
||||
"pug": "^3.0.3",
|
||||
"stdline": "^2.1.0",
|
||||
"ts-jest": "^29.4.0",
|
||||
"tsup": "^8.5.1",
|
||||
"typescript": "^6.0.2",
|
||||
"user-agents": "^2.1.4",
|
||||
"yaml": "^2.8.0"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user