diff --git a/.circleci/config.yml b/.circleci/config.yml index 2f6b886..d9536ad 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,14 @@ version: 2.1 +commands: + browsers: + steps: + - run: | + wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - + echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list.d/google-chrome.list + sudo apt update + sudo apt install -y google-chrome-stable xvfb + sudo apt install firefox + - run: npm run build workflows: test: jobs: @@ -17,11 +27,10 @@ workflows: matrix: parameters: image: - - circleci/node:10 - - circleci/node:12 - - circleci/node:14 - - circleci/node:16 - - circleci/node:17 + - cimg/node:12.22 + - cimg/node:14.18 + - cimg/node:16.15 + - cimg/node:18.0 requires: - build - publish: @@ -50,12 +59,13 @@ workflows: jobs: build: docker: - - image: circleci/node:16-browsers + - image: cimg/node:lts-browsers steps: - checkout - run: git submodule update --init --recursive - run: node -v - run: npm i + - browsers - run: npm run build - persist_to_workspace: root: . @@ -64,7 +74,7 @@ jobs: tests: working_directory: ~/project docker: - - image: circleci/node:16-browsers + - image: cimg/node:lts-browsers steps: - run: node -v - attach_workspace: @@ -79,7 +89,7 @@ jobs: parameters: image: description: docker image - default: circleci/node:latest + default: cimg/node:latest type: string working_directory: ~/project docker: @@ -93,17 +103,16 @@ jobs: - when: condition: matches: - pattern: "circleci/node:1[2-7]" + pattern: "cimg/node:1[2-8]-.*" value: << parameters.image >> steps: - run: npm run esm publish: working_directory: ~/project docker: - - image: circleci/node:16-browsers + - image: cimg/node:lts-browsers steps: - checkout - - run: git submodule update --init --recursive - run: name: Stop if remote tag already exists command: | @@ -118,7 +127,7 @@ jobs: command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc - attach_workspace: at: . - - run: npm run authors + - browsers - run: npm publish - run: name: Add git tag @@ -127,11 +136,11 @@ jobs: pages: working_directory: ~/project docker: - - image: circleci/node:16 + - image: cimg/node:lts steps: - checkout - - run: git submodule update --init --recursive - - run: npm i + - attach_workspace: + at: . - run: npm run page - run: name: Copy circleci config @@ -142,7 +151,7 @@ jobs: periodic: working_directory: ~/project docker: - - image: circleci/node:16-browsers + - image: cimg/node:lts-browsers steps: - checkout - run: git submodule update --init --recursive diff --git a/.nvmrc b/.nvmrc index b6a7d89..3c03207 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -16 +18 diff --git a/.rollup.js b/.rollup.js index 935c488..d3ff07f 100644 --- a/.rollup.js +++ b/.rollup.js @@ -1,6 +1,7 @@ const { join } = require('path') -const json = require('@rollup/plugin-json') const { babel } = require('@rollup/plugin-babel') +const { importAssertionsPlugin } = require('rollup-plugin-import-assert') +const { importAssertions } = require('acorn-import-assertions') module.exports = [ { @@ -22,9 +23,10 @@ module.exports = [ sourcemapFile: join(__dirname, [ 'index', ext, 'map' ].join('.')), preferConst: false }, + acornInjectPlugins: [ importAssertions ], plugins: [ - json({ compact: true }), - babel({ babelHelpers: 'bundled' }) + babel({ babelHelpers: 'bundled' }), + importAssertionsPlugin() ] }) ) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4699860..5cb1b9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## [3.4.7](https://github.com/omrilotan/isbot/compare/v3.4.6...v3.4.7) +- Add Zoom Webhook + ## [3.4.6](https://github.com/omrilotan/isbot/compare/v3.4.5...v3.4.6) - Add nodejs native agent (undici) - Add random long string diff --git a/README.md b/README.md index 70b594f..e4c4402 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![](https://img.shields.io/circleci/build/github/omrilotan/isbot?style=flat-square)](https://circleci.com/gh/omrilotan/isbot) [![](https://img.shields.io/npm/dt/isbot?style=flat-square)](https://www.npmjs.com/package/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/librariesio/sourcerank/npm/isbot?style=flat-square)](https://libraries.io/npm/isbot) [![](https://badges.openbase.io/js/rating/isbot.svg)](https://openbase.io/js/isbot#rate) [![](https://deepscan.io/api/teams/14776/projects/17857/branches/423729/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=14776&pid=17857&bid=423729) +[![](https://img.shields.io/librariesio/sourcerank/npm/isbot?style=flat-square)](https://libraries.io/npm/isbot) [![](https://badges.openbase.io/js/rating/isbot.svg)](https://openbase.io/js/isbot#rate) Detect bots/crawlers/spiders using the user agent string. diff --git a/babel.config.json b/babel.config.json index 06eecf4..7c510c2 100644 --- a/babel.config.json +++ b/babel.config.json @@ -7,5 +7,7 @@ } ] ], - "plugins": [] + "plugins": [ + "@babel/plugin-syntax-import-assertions" + ] } diff --git a/fixtures/browsers.yml b/fixtures/browsers.yml index 78aab07..ddeb925 100644 --- a/fixtures/browsers.yml +++ b/fixtures/browsers.yml @@ -12,9 +12,12 @@ Amazon 4K Fire TV: Amiga: - Amiga-AWeb/3.4.167SE - AmigaOS 4.0 AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94 Tablet Safari/537.36) + - AmigaVoyager/3.2 (AmigaOS/MC680x0) - AmigaVoyager/3.4.4 (MorphOS/PPC native) - IBrowse/2.4demo (AmigaOS 3.9; 68K) - IBrowse/2.5.4demo (Amiga; AmigaOS 3.1.4; Build 25.96 68K) + - IBrowse/2.5.5 (Amiga; MorphOS 3.16; Build 25.99 68K) + - IBrowse/2.55 (AmigaOS 3.2) - Mozilla/5.0 (Amiga; PowerPC AmigaOS 4.1; Odyssey Web Browser; rv:1.23) AppleWebKit/538.1 (KHTML, like Gecko) OWB/1.23 Safari/538.1 - Mozilla/5.0 (AmigaOs; 4.0; en-US; rv:1.8.1.21pre) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.666.4147.105 Safari/537.36 - Mozilla/5.0 (compatible; IBrowse 2.5.3; AmigaOS 3.1.2) @@ -22,13 +25,8 @@ Amiga: - Mozilla/6.0 (compatible; Amiga-AWeb) - Mozilla/6.0 (compatible; MSIE 7.01; Amiga-AWeb) - Mozilla/6.0 (Macintosh; U; Amiga-AWeb) Safari 2.9 - - Voyager3/AmigaoS3.1 -Amiga Aweb: - Mozilla/6.0 (Macintosh; U; Amiga-AWeb) Safari 3.1 -Amiga IBrowse: - - IBrowse/2.55 (AmigaOS 3.2) -Amiga Voyager: - - AmigaVoyager/3.2 (AmigaOS/MC680x0) + - Voyager3/AmigaoS3.1 Amigo: - Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.74 Safari/537.36 MRCHROME Android: @@ -346,6 +344,8 @@ Motorola Internet: - MOT-VE240/00.72 UP.Browser/7.2.7.5.548 (GUI) MMP/2.0 Novarra-Vision/8.0 Mozilla Android Components: - MozacFetch/49.0.20200702190156 +Naver Whale: + - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.57 Whale/3.14.133.23 Safari/537.36 NCSA Mosaic: - NCSA_Mosaic/2.7b5 (X11;Linux 2.6.7 i686) libwww/2.12 modified NetFront: diff --git a/fixtures/crawlers.yml b/fixtures/crawlers.yml index c57f414..d1a8324 100644 --- a/fixtures/crawlers.yml +++ b/fixtures/crawlers.yml @@ -126,15 +126,19 @@ Censys: - Mozilla/5.0 (compatible; CensysInspect/1.1; +https://about.censys.io/) CF-UC: - CF-UC User Agent v.1d.374049 +Chrome Headless: + - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/100.0.4896.88 Safari/537.36 + - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/83.0.4103.61 Safari/537.36 + - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/92.0.4512.0 Safari/537.36 ClamAV Website Scanner: - ClamAV 0.95.3 - "ClamAV/0.101.5 (OS: linux-gnu, ARCH: x86_64, CPU: x86_64)" Cliqzbot: - Cliqzbot/0.1 (+http://cliqz.com/company/cliqzbot) -CloudFlare Always Online: +CloudFlare: - Mozilla/5.0 (compatible; CloudFlare-AlwaysOnline/1.0; +http://www.cloudflare.com/always-online) AppleWebKit/534.34 -CloudFlare AMP Fetcher: - Mozilla/5.0 (compatible; Cloudflare-AMP/1.0; +https://amp.cloudflare.com/doc/fetcher.html) AppleWebKit/534.34 + - "Mozilla/5.0 (compatible;Cloudflare-Healthchecks/1.0;+https://www.cloudflare.com/; healthcheck-id: f867e0e43eca7aa4)" Collectd: - collectd/5.5.1 CommaFeed: @@ -440,10 +444,9 @@ Nagios check_http: - check_http/v1.5 (nagios-plugins 1.5) NalezenCzBot: - NalezenCzBot/1.0 (http://www.nalezen.cz/about-crawler) -Naver: - - Mozilla/5.0 (compatible; Yeti/1.1; +http://naver.me/spd) +Naver Search: + - Mozilla/5.0 (Linux; Android 12; SM-G975N Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/90.0.4430.232 Whale/1.0.0.0 Crosswalk/26.90.3.21 Mobile Safari/537.36 NAVER(inapp; search; 1010; 11.11.3) - Mozilla/5.0 (Linux; Android 8.0.0; SM-N950N Build/R16NW; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/79.0.3945.88 Mobile Safari/537.36 NAVER(inapp; search; 1000; 11.8.4; 11) - - Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.0 Safari/537.36 (compatible; Yeti/1.1; +http://naver.me/spd) nbertaupete95: - Mozilla/5.0/Firefox/42.0 - nbertaupete95(at)gmail.com Netcraft Survey Bot: @@ -800,9 +803,9 @@ Yandex: - Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots) Yandex Bot: - Mozilla/5.0 (compatible; YandexVerticals/1.0; http://yandex.com/bots) -Yeti: +Yeti (Naver): - Mozilla/5.0 (compatible; yeti/1.1; +http://naver.me/spd) -Yeti/Naverbot: + - Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.0 Safari/537.36 (compatible; Yeti/1.1; +http://naver.me/spd) - Yeti/1.1 (Naver Corp.; http://help.naver.com/robots/) Youdao Bot: - Mozilla/5.0 (compatible; YoudaoBot/1.0; http://www.youdao.com/help/webmaster/spider/; ) @@ -816,7 +819,9 @@ Ze List: - zelist.ro feed parser (+http://www.zelist.ro) Zookabot: - Zookabot/2.5;++http://zookabot.com -Zoom: +Zoom Webhook: + - Zoom Marketplace/1.0a +ZoomBot (seozoom.it): - zoombot (linkbot 1.0 http://suite.seozoom.it/bot.html) ZumBot: - ZumBot/1.0 (ZUM Search; http://help.zum.com/inquiry) diff --git a/fixtures/downloads b/fixtures/downloads index 9b66246..30a4a30 160000 --- a/fixtures/downloads +++ b/fixtures/downloads @@ -1 +1 @@ -Subproject commit 9b66246bb25475a73f51bf9872c9d05091ff63dd +Subproject commit 30a4a302961771d57d6ab6e1f0cdc7420882b383 diff --git a/package.json b/package.json index e196372..b03f159 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "isbot", - "version": "3.4.6", + "version": "3.4.7", "description": "🤖 detect bots/crawlers/spiders via the user agent.", "keywords": [ "bot", @@ -68,11 +68,12 @@ }, "devDependencies": { "@babel/eslint-parser": "^7.17.0", + "@babel/plugin-syntax-import-assertions": "^7.16.7", "@babel/preset-env": "^7.16.11", "@lets/wait": "^2.0.2", "@rollup/plugin-babel": "^5.3.1", - "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^13.2.1", + "acorn-import-assertions": "^1.8.0", "eslint-plugin-log": "^1.2.6", "form-data": "^4.0.0", "karma": "^6.3.18", @@ -81,12 +82,13 @@ "karma-firefox-launcher": "^2.1.1", "karma-mocha": "^2.0.1", "karma-mocha-reporter": "^2.2.5", - "mocha": "^9.2.2", + "mocha": "^10.0.0", "pug": "^3.0.0", "remark-cli": "^10.0.0", "remark-preset-lint-recommended": "^6.0.0", "rollup": "^2.70.2", - "standard": "^16.0.3", + "rollup-plugin-import-assert": "^2.1.0", + "standard": "^17.0.0", "stdline": "^1.0.0", "typescript": "^4.6.3", "user-agents": "^1.0.990", diff --git a/page/script.js b/page/script.js index dc0de62..396cff5 100644 --- a/page/script.js +++ b/page/script.js @@ -1,4 +1,4 @@ -import isbot from '../src/index.js' +import isbot from '..' import { amend } from '../src/amend/index.js' import list from '../src/list.json' @@ -28,24 +28,32 @@ import list from '../src/list.json' timer = setTimeout(check, 200, value) } - function showMatch (output, ua) { - const pattern = document.createElement('kbd') - pattern.appendChild( - document.createTextNode(isbot.matches(ua)?.pop()) - ) - output.appendChild( - document.createTextNode( - 'I think so, yes\nThe pattern that was matched is: ' - ) - ) - output.appendChild(pattern) + function append (parent, tag, string) { + if (tag) { + const ele = document.createElement('kbd') + ele.appendChild(document.createTextNode(string)) + parent.appendChild(ele) + } else { + parent.appendChild(document.createTextNode(string)) + } } - function noMatch (output) { - output.appendChild( - document.createTextNode( - 'I don\'t think so, no\nI could not find a pattern I recognise' - ) - ) + + function details (ua) { + const fragment = document.createDocumentFragment() + const is = isbot(ua) + const found = is && isbot.find(ua) + const pattern = found + ? isbot.matches(ua)?.find(pattern => new RegExp(pattern, 'i').test(found)) + : null + + is + ? append(fragment, null, 'I think so, yes\n') + : append(fragment, null, 'I don\'t think so, no\nI could not find a pattern I recognise') + found && append(fragment, null, 'The substring ') + found && append(fragment, 'kbd', found) + pattern && append(fragment, null, ' matches the pattern ') + pattern && append(fragment, 'kbd', pattern) + return fragment } function check (value = textarea.innerHTML) { @@ -62,9 +70,7 @@ import list from '../src/list.json' return } - isbot(value) - ? showMatch(output, value) - : noMatch(output) + output.appendChild(details(value)) output.className = '' setTimeout(() => { output.className = 'highlight' }, 100) diff --git a/src/isbot/index.js b/src/isbot/index.js index 234524d..b93fd05 100644 --- a/src/isbot/index.js +++ b/src/isbot/index.js @@ -1,4 +1,4 @@ -import list from '../list.json' +import list from '../list.json' assert { type: 'json' } import { amend } from '../amend/index.js' amend(list) @@ -12,12 +12,12 @@ export class Isbot { /** * @type {string[]} */ - #list; + #list /** * @type {RegExp} */ - #pattern; + #pattern constructor (patterns) { this.#list = patterns || list.slice() diff --git a/src/list.json b/src/list.json index 2b25bd2..ecbb42c 100644 --- a/src/list.json +++ b/src/list.json @@ -114,6 +114,7 @@ "^yandex", "^zdm/\\d", "^zeushdthree", + "^zoom\\smarketplace/", "adbeat\\.com", "appinsights", "archive", diff --git a/tests/browser/rollup.js b/tests/browser/rollup.js index 96c553b..1c4efbf 100644 --- a/tests/browser/rollup.js +++ b/tests/browser/rollup.js @@ -1,6 +1,5 @@ const { join } = require('path') const { nodeResolve } = require('@rollup/plugin-node-resolve') -const json = require('@rollup/plugin-json') module.exports = { input: join(__dirname, 'spec.js'), @@ -10,7 +9,6 @@ module.exports = { name: 'isbot' }, plugins: [ - json(), nodeResolve({ browser: true }) ] } diff --git a/tests/efficiency/spec.js b/tests/efficiency/spec.js index 335d527..c04116b 100644 --- a/tests/efficiency/spec.js +++ b/tests/efficiency/spec.js @@ -2,8 +2,8 @@ import { strict } from 'assert' import wait from '@lets/wait' -import list from '../../src/list.json' -import fixtures from '../../fixtures/index.json' +import list from '../../src/list.json' assert { type: 'json' } +import fixtures from '../../fixtures/index.json' assert { type: 'json' } import stdline from 'stdline' const { fail } = strict diff --git a/tests/specs/spec.js b/tests/specs/spec.js index 9423400..cd8faa7 100644 --- a/tests/specs/spec.js +++ b/tests/specs/spec.js @@ -2,7 +2,7 @@ import { strict as assert } from 'assert' import isbot from '../../src/index.js' -import fixtures from '../../fixtures/index.json' +import fixtures from '../../fixtures/index.json' assert { type: 'json' } const { browsers = [], crawlers = [] } = fixtures