Skip to content

Commit

Permalink
fix: Replace runtime enum BotKind with plain object (#136)
Browse files Browse the repository at this point in the history
* fix: Remove runtime enum for BotKind

* fix: Keep API safe

* docs: Note about object

* bump version to 1.6.2

---------

Co-authored-by: xnerhu <[email protected]>
  • Loading branch information
dj-stormtrooper and xnerhu authored Aug 3, 2023
1 parent d65e38d commit 75ebd43
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fingerprintjs/botd",
"version": "1.6.1",
"version": "1.6.2",
"description": "botd is a browser library for JavaScript bot detection",
"keywords": [
"bot",
Expand Down
46 changes: 25 additions & 21 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,31 @@ export const enum State {
* @readonly
* @enum {string}
*/
export enum BotKind {
Awesomium = 'awesomium',
Cef = 'cef',
CefSharp = 'cefsharp',
CoachJS = 'coachjs',
Electron = 'electron',
FMiner = 'fminer',
Geb = 'geb',
NightmareJS = 'nightmarejs',
Phantomas = 'phantomas',
PhantomJS = 'phantomjs',
Rhino = 'rhino',
Selenium = 'selenium',
Sequentum = 'sequentum',
SlimerJS = 'slimerjs',
WebDriverIO = 'webdriverio',

WebDriver = 'webdriver',
HeadlessChrome = 'headless_chrome',
Unknown = 'unknown',
}
export const BotKind = {
// Object is used instead of Typescript enum to avoid emitting IIFE which might be affected by further tree-shaking.
// See example of compiled enums https://stackoverflow.com/q/47363996)
Awesomium: 'awesomium',
Cef: 'cef',
CefSharp: 'cefsharp',
CoachJS: 'coachjs',
Electron: 'electron',
FMiner: 'fminer',
Geb: 'geb',
NightmareJS: 'nightmarejs',
Phantomas: 'phantomas',
PhantomJS: 'phantomjs',
Rhino: 'rhino',
Selenium: 'selenium',
Sequentum: 'sequentum',
SlimerJS: 'slimerjs',
WebDriverIO: 'webdriverio',

WebDriver: 'webdriver',
HeadlessChrome: 'headless_chrome',
Unknown: 'unknown',
} as const

export type BotKind = typeof BotKind[keyof typeof BotKind]

export type DetectorResponse = boolean | BotKind | undefined

Expand Down

0 comments on commit 75ebd43

Please sign in to comment.