Skip to content

Commit

Permalink
Merge pull request #109 from fingerprintjs/dev
Browse files Browse the repository at this point in the history
Updates for pro agent (#108)
  • Loading branch information
xnerhu authored Dec 21, 2022
2 parents 2408877 + e2606ad commit 7bac77c
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 179 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.2.0",
"version": "1.3.0",
"description": "botd is a browser library for JavaScript bot detection",
"keywords": [
"bot",
Expand Down
4 changes: 3 additions & 1 deletion playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
<div id="result-text">Detecting...</div>
</div>
<div id="error-container" class="medium-container">
<pre id="error-message">Lorem ipsum dolor sit amet consectetur adipisicing elit. Reiciendis, suscipit assumenda dicta, iste, eius possimus sunt asperiores debitis quam voluptatum deleniti obcaecati facere nisi deserunt reprehenderit nobis sapiente explicabo non.</pre>
<pre id="error-message">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Reiciendis, suscipit assumenda dicta, iste, eius possimus sunt asperiores debitis quam voluptatum deleniti obcaecati facere nisi deserunt reprehenderit nobis sapiente explicabo non.</pre
>
</div>
<div class="medium-container content-card">
<div class="logs-top-bar">
Expand Down
28 changes: 13 additions & 15 deletions playground/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
--accent-dark-color: rgb(140, 39, 3);
--error-color: #b3261e;
--font-family: 'Fira Mono', monospace;
--font-family-consolas: Consolas, "Liberation Mono", Menlo, Courier, monospace;
--font-family-consolas: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
}


body {
width: 100%;
height: 100%;
Expand All @@ -27,7 +26,6 @@ body {
box-sizing: border-box;
}


.container {
width: calc(100% - 128px);
max-width: 1536px;
Expand Down Expand Up @@ -90,15 +88,15 @@ body {
margin-top: 32px;
}

#navbar .logo {
#navbar .logo {
margin-top: 0;
width: 256px;
}

#navbar #navbar-chevron {
transform: rotate(90deg);
}

#navbar #playground-actions {
margin-left: 0;
margin: 32px 0px;
Expand Down Expand Up @@ -139,14 +137,15 @@ h2 {
transition: 0.15s;
}

.github-card:active, .github-card:focus {
.github-card:active,
.github-card:focus {
background-color: rgba(0, 0, 0, 0.12);
transition: 0.15s;
}

.github-card::before {
display: block;
content: "";
content: '';
width: 32px;
height: 32px;
background-image: url(../resources/github_icon.svg);
Expand Down Expand Up @@ -177,7 +176,6 @@ h2 {
font-weight: 600;
}


.orange-button {
background-color: var(--accent-color);
color: #fff;
Expand All @@ -190,11 +188,15 @@ h2 {
background-color: transparent;
}

.orange-button:hover, .orange-button:active, .orange-button:focus {
.orange-button:hover,
.orange-button:active,
.orange-button:focus {
background-color: var(--accent-dark-color);
}

.orange-button-outlined:hover, .orange-button-outlined:active, .orange-button-outlined:focus {
.orange-button-outlined:hover,
.orange-button-outlined:active,
.orange-button-outlined:focus {
background-color: rgba(240, 68, 5, 0.12);
}

Expand All @@ -208,7 +210,6 @@ h2 {
padding: var(--content-card-padding);
}


#result {
overflow: hidden;
margin: 96px auto;
Expand All @@ -219,7 +220,6 @@ h2 {
--bot-icon-url: url(../resources/robot-off-outline.svg);
}


.result-detected {
--bot-icon-color: #f44336 !important;
--bot-icon-url: url(../resources/robot-outline.svg) !important;
Expand All @@ -230,7 +230,6 @@ h2 {
--bot-icon-url: url(../resources/alert-circle-outline.svg) !important;
}


.result-bot-icon-container {
width: 128px;
height: 128px;
Expand All @@ -241,7 +240,7 @@ h2 {
}

.result-bot-icon-container::before {
content: "";
content: '';
display: block;
background-color: var(--bot-icon-color);
opacity: 0.08;
Expand Down Expand Up @@ -276,7 +275,6 @@ h2 {
transition: 0.2s color;
}


.logs-content {
background-color: #282c34;
color: #fff;
Expand Down
9 changes: 0 additions & 9 deletions src/detectors/document_attributes.ts

This file was deleted.

9 changes: 9 additions & 0 deletions src/detectors/document_element_keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { BotKind, ComponentDict, DetectorResponse, State } from '../types'
import { includes } from '../utils/misc'

export function detectDocumentAttributes({ documentElementKeys }: ComponentDict): DetectorResponse {
if (documentElementKeys.state !== State.Success) return false
if (includes(documentElementKeys.value, 'selenium', 'webdriver', 'driver')) {
return BotKind.Selenium
}
}
2 changes: 1 addition & 1 deletion src/detectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { detectAppVersion } from './app_version'
import { detectDocumentAttributes } from './document_attributes'
import { detectDocumentAttributes } from './document_element_keys'
import { detectDocumentProperties } from './document_properties'
import { detectErrorTrace } from './error_trace'
import { detectEvalLengthInconsistency } from './eval_length'
Expand Down
11 changes: 0 additions & 11 deletions src/sources/device_memory.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/sources/document_element_attributes.ts

This file was deleted.

12 changes: 12 additions & 0 deletions src/sources/document_element_keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { BotdError, State } from '../types'

export default function getDocumentElementKeys(): string[] {
if (document.documentElement === undefined) {
throw new BotdError(State.Undefined, 'document.documentElement is undefined')
}
const { documentElement } = document
if (typeof documentElement.getAttributeNames !== 'function') {
throw new BotdError(State.NotFunction, 'document.documentElement.getAttributeNames is not a function')
}
return documentElement.getAttributeNames()
}
10 changes: 0 additions & 10 deletions src/sources/hardware_concurrency.ts

This file was deleted.

18 changes: 2 additions & 16 deletions src/sources/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import getAppVersion from './app_version'
import getDeviceMemory from './device_memory'
import getDocumentAttributes from './document_element_attributes'
import getDocumentElementKeys from './document_element_keys'
import getDocumentProperties from './document_properties'
import getErrorTrace from './error_trace'
import getEvalLength from './eval_length'
import getFunctionBind from './function_bind'
import getHardwareConcurrency from './hardware_concurrency'
import getLanguages from './languages'
import areMimeTypesConsistent from './mime_types_consistence'
import getNotificationPermissions from './notification_permissions'
import getOsCpu from './os_cpu'
import getPlatform from './platform'
import getPluginsArray from './plugins_array'
import getPluginsLength from './plugins_length'
import getProcess, { ProcessPayload } from './process'
import getProductSub from './product_sub'
import getRTT from './rtt'
import getScreenResolution from './screen_resolution'
import getTouchSupport from './touch_support'
import getUserAgent from './user_agent'
import getVendor from './vendor'
import getWebDriver from './webdriver'
import getWebGL from './webgl'
import getWindowExternal from './window_external'
Expand All @@ -42,18 +35,11 @@ export const sources = {
webDriver: getWebDriver,
languages: getLanguages,
notificationPermissions: getNotificationPermissions,
documentAttributes: getDocumentAttributes,
documentElementKeys: getDocumentElementKeys,
functionBind: getFunctionBind,
process: getProcess,
documentProps: getDocumentProperties,
windowProps: getWindowProperties,
osCpu: getOsCpu,
deviceMemory: getDeviceMemory,
screenResolution: getScreenResolution,
hardwareConcurrency: getHardwareConcurrency,
platform: getPlatform,
touchSupport: getTouchSupport,
vendor: getVendor,
}

export { WindowSizePayload, ProcessPayload }
2 changes: 1 addition & 1 deletion src/sources/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function getLanguages(): string[][] {
if (Array.isArray(n.languages)) {
const browserEngine = getBrowserEngineKind()
// Starting from Chromium 86, there is only a single value in `navigator.language` in Incognito mode:
// the value of `navigator.language`. Therefore the value is ignored in this browser.
// the value of `navigator.language`. Therefore, the value is ignored in this browser.
if (!(browserEngine === BrowserEngineKind.Chromium && isChromium86OrNewer())) {
result.push(n.languages)
}
Expand Down
9 changes: 0 additions & 9 deletions src/sources/os_cpu.ts

This file was deleted.

23 changes: 0 additions & 23 deletions src/sources/platform.ts

This file was deleted.

21 changes: 0 additions & 21 deletions src/sources/screen_resolution.ts

This file was deleted.

44 changes: 0 additions & 44 deletions src/sources/touch_support.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/sources/vendor.ts

This file was deleted.

0 comments on commit 7bac77c

Please sign in to comment.