{"name":"isbot","version":"2.5.6","keywords":["bot","crawlers","spiders","googlebot","useragent"],"author":{"name":"Goran Gajic"},"license":"MIT","_id":"isbot@2.5.6","homepage":"https://github.com/gorangajic/isbot","bugs":{"url":"https://github.com/gorangajic/isbot/issues"},"dist":{"shasum":"26e242bcbccda791cb4662d795b953f1185e6669","tarball":"http://registry-npm.ywwl.com/isbot/download/isbot-2.5.6.tgz","fileCount":6,"integrity":"sha512-60bkIhmWb+HA/JLDB2K4zZhXX/z36cF83B/2gGQos4kA51/AlWf3+2K7WpjuBHDfX8v9ciW0zA8aHOKHUMbxJQ==","signatures":[{"sig":"MEUCIQD5nf/lCkBLZc/ZUUmmfszH87/29Wqw1sqAADHTuSO32QIgeTMUhDMXSc9ZE0aNy5jSJ1xR6V1iBa2Vk7NtXOyWD00=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":21484,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeQumOCRA9TVsSAnZWagAAJtsP/1xufdeOQOumvFS2sugD\nlfSvn5q9nTutu4CDjbKVCIqjeVXV2LENl4zP1deMRx0hi6jfnZompgxFekQm\nL4MP/haEeQu/eiUgCWulgM4c6OUrBJsDUCT4XxcdBszYoKnCoWcS8m9/C1GU\nxaAHwlhhoakjok2LqdOf/ihXs/Iqa3NqtgBmqtCpLPZ0GcS/6RWRH98rEPDD\nywZE48IAl0m1TVM+1yHxKwkIwR4u7ETIY05uDyOH45nQpz0SIcw3oFxVsbrF\nz1ZTNomk5xXBOjSzdrQU6ai9vVlsclaB6CFRbNdqWR16iUNF1Qh3rd0To521\n58Jxo5nVVDBP0jvs/H6y4GCCZ+1LasiuenkF5GJiGEEA5Vya8O0CXRV6+XWb\n6xhfcMTepsxZWWQw936ZAUcO1dLerV5jm3OrVjpt3uCr7+iIsjS2+k8nQSuh\nX4V5tBpjqcWNrB/qLzKS/oA/CLNN0MIqlE77ycXbiJHN43GCTIt7s811S9W+\n9o+O7i3B3C+fKYquMzVeJU1zyj3blLHeAj4y9RY/D1fRGOR7P3mHj7UOYU90\niVYlvTc1X+bmeN5cGhBOsR6WU8dy6VpJrDyAue8iPuI9D3qLElNjc+vgtKpl\nUYG2Lsl4XOMJS+AoEcHqIouy+XRQmUH61+JMufbRHSBREMBtV612ztu2p3lr\nE1+W\r\n=fUkO\r\n-----END PGP SIGNATURE-----\r\n","size":9127,"noattachment":false,"key":"/isbot/-/isbot-2.5.6.tgz"},"main":"index.js","types":"index.d.ts","engines":{"node":">=6"},"gitHead":"88c3c3f16bd4193f44193f0f8f7ca5c923fd6b25","scripts":{"ts":"tsc","lint":"standard","sort":"./scripts/sort.js","test":"mocha tests/*.js --exclude 'tests/.*'","browser":"karma start .karma.js","prepare":"./scripts/download-crawlers-json.sh","prebrowser":"rollup --config .rollup.js"},"_npmUser":{"name":"omrilotan","email":"omri@hamadgera.com"},"repository":{"url":"git+https://github.com/gorangajic/isbot.git","type":"git"},"_npmVersion":"6.13.6","description":"detects bots/crawlers/spiders via the user agent.","directories":{},"_nodeVersion":"13.8.0","_hasShrinkwrap":false,"devDependencies":{"karma":"^4.4.1","mocha":"^5.2.0","rollup":"^1.31.0","standard":"^14.3.1","karma-cli":"^2.0.0","typescript":"^3.7.5","karma-mocha":"^1.3.0","user-agents":"^1.0.519","eslint-plugin-log":"^1.2.3","@rollup/plugin-json":"^4.0.2","karma-mocha-reporter":"^2.2.5","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^1.3.0","@rollup/plugin-commonjs":"^11.0.2"},"_npmOperationalInternal":{"tmp":"tmp/isbot_2.5.6_1581443469806_0.25096058487750383","host":"s3://npm-registry-packages"},"readme":"# isbot 🤖/👨‍🦰\n\n[![](https://img.shields.io/npm/v/isbot?style=flat-square)](https://www.npmjs.com/package/isbot) [![](https://img.shields.io/circleci/build/github/omrilotan/isbot?style=flat-square)](https://circleci.com/gh/omrilotan/isbot) [![](https://img.shields.io/github/last-commit/omrilotan/isbot?style=flat-square)](https://github.com/omrilotan/isbot/graphs/commit-activity) [![](https://img.shields.io/npm/dt/isbot?style=flat-square)](https://www.npmjs.com/package/isbot) [![](https://data.jsdelivr.com/v1/package/npm/isbot/badge)](https://www.jsdelivr.com/package/npm/isbot)\n\n[![](./page/isbot.svg)](https://isbot.js.org)\n\nIdentify bots, crawlers, and spiders using the user agent string.\n\n## Usage\n\nInstall\n\n```sh\nnpm i isbot\n```\n\nStraightforward usage\n\n```ts\nimport { isbot } from \"isbot\";\n\n// Nodejs HTTP\nisbot(request.getHeader(\"User-Agent\"));\n\n// ExpressJS\nisbot(req.get(\"user-agent\"));\n\n// Browser\nisbot(navigator.userAgent);\n\n// User Agent string\nisbot(\n  \"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)\",\n); // true\n\nisbot(\n  \"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36\",\n); // false\n```\n\nUse JSDeliver CDN you can import to the browser directly\n\n> See specific versions and instructions [https://www.jsdelivr.com/package/npm/isbot](https://www.jsdelivr.com/package/npm/isbot)\n\nESM\n\n```html\n<script type=\"module\">\n  import { isbot } from \"https://cdn.jsdelivr.net/npm/isbot@5/+esm\";\n  isbot(navigator.userAgent);\n</script>\n```\n\nUMD\n\n```html\n<script src=\"https://cdn.jsdelivr.net/npm/isbot@5\"></script>\n<script>\n  // isbot is now global\n  isbot(navigator.userAgent);\n</script>\n```\n\n## All named imports\n\n| import              | Type                             | Description                                                                  |\n| ------------------- | -------------------------------- | ---------------------------------------------------------------------------- |\n| isbot               | _(string?): boolean_             | Check if the user agent is a bot                                             |\n| isbotNaive          | _(string?): boolean_             | Check if the user agent is a bot using a naive pattern (less accurate)       |\n| getPattern          | (): _RegExp_                     | The regular expression used to identify bots                                 |\n| list                | _string[]_                       | List of all individual pattern parts                                         |\n| isbotMatch          | _(string?): string \\| null_      | The substring matched by the regular expression                              |\n| isbotMatches        | _(string?): string[]_            | All substrings matched by the regular expression                             |\n| isbotPattern        | _(string?): string \\| null_      | The regular expression used to identify bot substring in the user agent      |\n| isbotPatterns       | _(string?): string[]_            | All regular expressions used to identify bot substrings in the user agent    |\n| createIsbot         | _(RegExp): (string?): boolean_   | Create a custom isbot function                                               |\n| createIsbotFromList | _(string[]): (string?): boolean_ | Create a custom isbot function from a list of string representation patterns |\n\n## Example usages of helper functions\n\nCreate a custom `isbot` that does not consider Chrome Lighthouse user agent as bots.\n\n```ts\nimport { createIsbotFromList, isbotMatches, list } from \"isbot\";\n\nconst ChromeLighthouseUserAgentStrings: string[] = [\n  \"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\",\n  \"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\",\n];\nconst patternsToRemove = new Set<string>(\n  ChromeLighthouseUserAgentStrings.map(isbotMatches).flat(),\n);\nconst isbot: (ua: string) => boolean = createIsbotFromList(\n  list.filter(\n    (record: string): boolean => patternsToRemove.has(record) === false,\n  ),\n);\n```\n\nCreate a custom isbot that considers another pattern as a bot, which is not included in the package originally.\n\n```ts\nimport { createIsbotFromList, list } from \"isbot\";\n\nconst isbot = createIsbotFromList(list.concat(\"shmulik\"));\n```\n\n## Definitions\n\n- **Bot.** Autonomous program imitating or replacing some aspect of a human behaviour, performing repetitive tasks much faster than human users could.\n- **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.\n- **Bad bot.** Programs which are designed to perform malicious actions, ultimately hurting businesses. Testing credential databases, DDoS attacks, spam bots.\n\n## Clarifications\n\n### What does \"isbot\" do?\n\nThis 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.\n\n### What doesn't \"isbot\" do?\n\nIt does not try to recognise malicious bots or programs disguising themselves as real users.\n\n### Why would I want to identify good bots?\n\nRecognising 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\n\n- Flag pageviews to consider with **business analysis**.\n- Prefer to serve cached content and **relieve service load**.\n- Omit third party solutions' code (tags, pixels) and **reduce costs**.\n\n> 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).\n\n## How `isbot` maintains accuracy\n\n> `isbot`'s prized possession is the accurate identification of bots using a regular expression. It uses expansive and regularly updated lists of user agent strings to create a regular expression that matches bots and only bots.\n>\n> This is done by using a lookbehind pattern which is not supported in all environments. A fallback is provided for environments that do not support lookbehind which 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.\n\n## Data sources\n\nWe use external data sources on top of our own lists to keep up to date\n\n### Crawlers user agents\n\n- [user-agents.net](https://user-agents.net/bots)\n- [monperrus/crawler-user-agents](https://github.com/monperrus/crawler-user-agents/blob/master/crawler-user-agents.json)\n- [Kikobeats/top-crawler-agents](https://github.com/Kikobeats/top-crawler-agents/blob/master/index.json)\n- [myip.ms](https://www.myip.ms/files/bots/live_webcrawlers.txt)\n- [matomo.org](https://github.com/matomo-org/device-detector/blob/master/Tests/fixtures/bots.yml)\n- A Manual list\n\n### Non bot user agents\n\n- [user-agents npm package](https://www.npmjs.com/package/user-agents)\n- A Manual list\n\nMissing something? Please [open an issue](https://github.com/omrilotan/isbot/issues/new/choose)\n\n## Major releases breaking changes ([full changelog](./CHANGELOG.md))\n\n### [**Version 5**](https://github.com/omrilotan/isbot/releases/tag/v5.0.0)\n\nRemove named export \"pattern\" from the interface, instead use \"getPattern\" method\n\n### [**Version 4**](https://github.com/omrilotan/isbot/releases/tag/v4.0.0)\n\nRemove `isbot` function default export in favour of a named export.\n\n```ts\nimport { isbot } from \"isbot\";\n```\n\n### [**Version 3**](https://github.com/omrilotan/isbot/releases/tag/v3.0.0)\n\nRemove testing for node 6 and 8\n\n### [**Version 2**](https://github.com/omrilotan/isbot/releases/tag/v2.0.0)\n\nChange return value for isbot: `true` instead of matched string\n\n### [**Version 1**](https://github.com/omrilotan/isbot/releases/tag/v1.0.0)\n\nNo functional change\n","publish_time":1581443470041,"maintainers":[{"name":"omrilotan","email":"omrilotan@hotmail.com"},{"name":"gorangajic","email":"fero.null@gmail.com"}],"_cnpm_publish_time":1581443470041,"dist-tags":{"latest":"5.2.3","legacy":"3.8.0"}}