-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Browser based fingerprinting | ||
* | ||
* @class Fingerprinting | ||
*/ | ||
class Fingerprinting { | ||
/** | ||
* Check user agent string for usual browsers. | ||
* | ||
* @return {boolean} | ||
* @memberof Fingerprinting | ||
*/ | ||
isUsualBrowserBasedOnUa(){ | ||
const ua = navigator.userAgent; | ||
const isUsualBrowser = ua.includes("Chrome") | ||
|| ua.includes("Firefox") | ||
|| ua.includes("Safari") | ||
|| ua.includes("Edge") | ||
|| ua.includes("Opera") | ||
|| ua.includes("OPR") | ||
|| ua.includes("MSIE") | ||
|| ua.includes("Trident"); | ||
return isUsualBrowser; | ||
} | ||
|
||
/** | ||
* Check if browser is headless. | ||
* | ||
* @return {boolean} | ||
* @memberof Fingerprinting | ||
*/ | ||
isNotHeadless(){ | ||
const isHeadless = !!navigator.webdriver // @ts-ignore | ||
|| !!window.chrome | ||
|| !!navigator.languages | ||
|| navigator.userAgent.toLowerCase().includes("headless"); | ||
return !isHeadless; | ||
} | ||
|
||
/** | ||
* Check if canvas is supported. | ||
* | ||
* @return {boolean} | ||
* @memberof Fingerprinting | ||
*/ | ||
isCanvasSupported(){ | ||
const canvas = document.createElement("canvas"); | ||
const gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl"); | ||
return !!gl; | ||
} | ||
|
||
// more to come | ||
} | ||
|
||
export default Fingerprinting; |