From 1b09675bb9f1f3dc370cb1d27fdb5440f50d664e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julio=20Napuri=CC=81?= Date: Thu, 4 Aug 2016 12:21:43 -0500 Subject: [PATCH 01/37] Fixing getSystemLanguage function detection --- src/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index 2632b1c..dbe48ad 100644 --- a/src/client.js +++ b/src/client.js @@ -618,7 +618,7 @@ // Get System Language. Return a string containing the system language. getSystemLanguage: function() { - return navigator.systemLanguage; + return navigator.systemLanguage || window.navigator.language; }, // From 25959dc6e9b10faa17f935788c58faf541beb4cc Mon Sep 17 00:00:00 2001 From: Nick Arnold Date: Wed, 13 Sep 2017 16:00:22 -0600 Subject: [PATCH 02/37] minor source documentation fix --- src/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index 2632b1c..61039ce 100644 --- a/src/client.js +++ b/src/client.js @@ -48,7 +48,7 @@ // // client.getSoftwareVersion(); // client.getBrowserData(); -// client.getFingerPrint(); +// client.getFingerprint(); // client.getCustomFingerprint(...); // // client.getUserAgent(); From e05d6b3bc5e16b7039d1edb5d509b086c74224a8 Mon Sep 17 00:00:00 2001 From: alexeystadnikov-okta Date: Wed, 23 May 2018 16:08:52 +0300 Subject: [PATCH 03/37] Fix exception if navigator does not have mimeTypes attribute --- src/client.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/client.js b/src/client.js index 6907cba..3f4e2b0 100644 --- a/src/client.js +++ b/src/client.js @@ -523,7 +523,7 @@ // Is Mime Types. Check if a mime type is installed. isMimeTypes: function() { - if (navigator.mimeTypes.length) { + if (navigator.mimeTypes && navigator.mimeTypes.length) { return true; } return false; @@ -533,11 +533,13 @@ getMimeTypes: function() { var mimeTypeList = ""; - for (var i = 0; i < navigator.mimeTypes.length; i++) { - if (i == navigator.mimeTypes.length - 1) { - mimeTypeList += navigator.mimeTypes[i].description; - } else { - mimeTypeList += navigator.mimeTypes[i].description + ", "; + if(navigator.mimeTypes) { + for (var i = 0; i < navigator.mimeTypes.length; i++) { + if (i == navigator.mimeTypes.length - 1) { + mimeTypeList += navigator.mimeTypes[i].description; + } else { + mimeTypeList += navigator.mimeTypes[i].description + ", "; + } } } return mimeTypeList; From bae1972a96b6fe1c10a78d3588c4686030a8c128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julio=20Napuri=CC=81?= Date: Thu, 2 Aug 2018 18:50:07 -0500 Subject: [PATCH 04/37] Fix getTimeZone for across browsers support --- src/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.js b/src/client.js index 6907cba..6b16700 100644 --- a/src/client.js +++ b/src/client.js @@ -604,7 +604,7 @@ // Get Time Zone. Return a string containing the time zone. getTimeZone: function() { var rightNow = new Date(); - return String(String(rightNow).split("(")[1]).split(")")[0]; + return String(-(rightNow.getTimezoneOffset()/60)); }, // From 741c73ba1238f88bfb1cea0ef326805130ccc4e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julio=20Napuri=CC=81?= Date: Thu, 2 Aug 2018 21:26:36 -0500 Subject: [PATCH 05/37] Add 2 digits support to getTimeZone --- src/client.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/client.js b/src/client.js index 6b16700..cb438d2 100644 --- a/src/client.js +++ b/src/client.js @@ -603,8 +603,18 @@ // Get Time Zone. Return a string containing the time zone. getTimeZone: function() { - var rightNow = new Date(); - return String(-(rightNow.getTimezoneOffset()/60)); + var rightNow, myNumber, formattedNumber, result; + rightNow = new Date(); + myNumber = String(-(rightNow.getTimezoneOffset() / 60)); + if (myNumber < 0) { + myNumber = myNumber * -1; + formattedNumber = ("0" + myNumber).slice(-2); + result = "-" + formattedNumber; + } else { + formattedNumber = ("0" + myNumber).slice(-2); + result = "+" + formattedNumber; + } + return result; }, // From 15b66d31c5f17fd94ff4cc5c38ce91d3696cec11 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Fri, 16 Oct 2020 11:53:51 +0200 Subject: [PATCH 06/37] Migrate to webpack-based build, fix broken bundle - use Webpack to fix broken CommonJS bundling - update dev dependencies - use ua-parser-js from npm instead of a vendored copy - fix Karma to work with Webpack build --- .drone.yml | 3 +- .eslintignore | 2 + .eslintrc.js | 14 + .gitignore | 8 + README.md | 9 +- bower.json | 14 +- dist/client.min.js | 95 +- dist/client.min.js.map | 1 + gulpfile.js | 15 - karma/aircover.conf.js | 71 +- karma/base.conf.js | 56 + karma/drone.conf.js | 92 +- karma/local.conf.js | 67 +- package-lock.json | 9321 ++++++++++++++++++++++ package.json | 52 +- scripts/build.sh | 33 - scripts/test.js | 19 - specs/.eslintrc.js | 8 + specs/{ClientJSpec.js => client.spec.js} | 56 +- src/.eslintrc.js | 10 + src/client.js | 25 +- src/vendor/deployJava.js | 2 +- src/vendor/fontdetect.js | 2 +- src/vendor/murmurhash3.js | 4 +- src/vendor/swfobject.js | 2 +- src/vendor/ua-parser.js | 882 -- webpack.config.js | 32 + 27 files changed, 9654 insertions(+), 1241 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.js create mode 100644 dist/client.min.js.map delete mode 100644 gulpfile.js create mode 100644 karma/base.conf.js create mode 100644 package-lock.json delete mode 100644 scripts/build.sh delete mode 100644 scripts/test.js create mode 100644 specs/.eslintrc.js rename specs/{ClientJSpec.js => client.spec.js} (73%) create mode 100644 src/.eslintrc.js delete mode 100644 src/vendor/ua-parser.js create mode 100644 webpack.config.js diff --git a/.drone.yml b/.drone.yml index ef96530..dd9cf9a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,8 +6,7 @@ build: commands: - export BUILD_NUMBER=$DRONE_BUILD_NUMBER - npm install --quiet - - npm install --quiet -g karma-cli - - npm test + - npm run test:drone publish: coverage: diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..908c337 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +src/vendor +dist diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..339c3a5 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = { + root: true, + parserOptions: { + ecmaVersion: 2018, + sourceType: 'script', + }, + extends: ['eslint:recommended'], + env: { + node: true, + browser: true, + }, +}; diff --git a/.gitignore b/.gitignore index bd08181..f4ae9d7 100644 --- a/.gitignore +++ b/.gitignore @@ -94,3 +94,11 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk + +## +# Editors/IDEs +## + +# VSCode + Plugins +.history +.vscode diff --git a/README.md b/README.md index ffbc067..64c90f6 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,11 @@ Below is an example of how to generate and display a fingerprint: ```javascript // Create a new ClientJS object + +// in a browser: var client = new ClientJS(); +// or in a CommonJS environment: +var client = require('clientjs').ClientJS; // Get the client's fingerprint id var fingerprint = client.getFingerprint(); @@ -190,15 +194,12 @@ Once cloned, install all dependencies. ClientJS uses [Karma](https://karma-runne ```shell # Install dependencies $ npm install - -# If you want tu run karma from the command line -$ npm install -g karma-cli ``` Run Karma and enjoy coding! ```shell -$ karma start +$ npm test ``` Thanks for contributing to ClientJS! Please report any bug [here](https://github.com/jackspirou/clientjs/issues). diff --git a/bower.json b/bower.json index dd9a283..d4bcfc0 100644 --- a/bower.json +++ b/bower.json @@ -3,12 +3,18 @@ "version": "0.1.11", "main": ["dist/client.min.js"], "ignore": [ - ".travis.yml", + ".drone.sec", + ".drone.yml", ".gitignore", - "build", - "grunt.js", + ".travis.yml", + "justrelease.yml", + "karma", "LICENSE", "node_modules", - "package.json" + "package-lock.json", + "package.json", + "scripts", + "specs", + "webpack.config.js" ] } diff --git a/dist/client.min.js b/dist/client.min.js index 4848ade..91458e8 100644 --- a/dist/client.min.js +++ b/dist/client.min.js @@ -1,81 +1,14 @@ -(function(f){var d,e,p=function(){d=(new (window.UAParser||exports.UAParser)).getResult();e=new Detector;return this};p.prototype={getSoftwareVersion:function(){return"0.1.11"},getBrowserData:function(){return d},getFingerprint:function(){var b=d.ua,c=this.getScreenPrint(),a=this.getPlugins(),g=this.getFonts(),n=this.isLocalStorage(),f=this.isSessionStorage(),h=this.getTimeZone(),u=this.getLanguage(),m=this.getSystemLanguage(),e=this.isCookie(),C=this.getCanvasPrint();return murmurhash3_32_gc(b+"|"+ -c+"|"+a+"|"+g+"|"+n+"|"+f+"|"+h+"|"+u+"|"+m+"|"+e+"|"+C,256)},getCustomFingerprint:function(){for(var b="",c=0;c 1.0",2,15);c.fillStyle="rgba(102, 204, 0, 0.7)";c.fillText("ClientJS,org 1.0",4,17);return b.toDataURL()}};"object"=== -typeof module&&"undefined"!==typeof exports&&(module.exports=p);f.ClientJS=p})(window);var deployJava=function(){function f(a){c.debug&&(console.log?console.log(a):alert(a))}function d(a){if(null==a||0==a.length)return"http://java.com/dt-redirect";"&"==a.charAt(0)&&(a=a.substring(1,a.length));return"http://java.com/dt-redirect?"+a}var e=["id","class","title","style"];"classid codebase codetype data type archive declare standby height width usemap name tabindex align border hspace vspace".split(" ").concat(e,["lang","dir"],"onclick ondblclick onmousedown onmouseup onmouseover onmousemove onmouseout onkeypress onkeydown onkeyup".split(" ")); -var p="codebase code name archive object width height alt align hspace vspace".split(" ").concat(e),b;try{b=-1!=document.location.protocol.indexOf("http")?"//java.com/js/webstart.png":"http://java.com/js/webstart.png"}catch(a){b="http://java.com/js/webstart.png"}var c={debug:null,version:"20120801",firefoxJavaVersion:null,myInterval:null,preInstallJREList:null,returnPage:null,brand:null,locale:null,installType:null,EAInstallEnabled:!1,EarlyAccessURL:null,oldMimeType:"application/npruntime-scriptable-plugin;DeploymentToolkit", -mimeType:"application/java-deployment-toolkit",launchButtonPNG:b,browserName:null,browserName2:null,getJREs:function(){var a=[];if(this.isPluginInstalled())for(var g=this.getPlugin().jvms,b=0;b'}d||(c+='');h&&(b+=' code="dummy"');document.write(b+">\n"+c+"\n")},versionCheck:function(a){var g=0,b=a.match("^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?(\\*|\\+)?$");if(null!=b){for(var c=a=!1,h=[],d=1;dh.length&&(c=!1,a=!0);g=this.getJREs();for(d=0;d':"Netscape Family"==c&&(d='');"undefined"==document.body||null==document.body? -(document.write(d),document.location=b):(a=document.createElement("div"),a.id="div1",a.style.position="relative",a.style.left="-10000px",a.style.margin="0px auto",a.className="dynamicDiv",a.innerHTML=d,document.body.appendChild(a))},createWebStartLaunchButtonEx:function(a,b){null==this.returnPage&&(this.returnPage=a);document.write('')}, -createWebStartLaunchButton:function(a,b){null==this.returnPage&&(this.returnPage=a);document.write('')},launch:function(a){document.location=a;return!0},isPluginInstalled:function(){var a= -this.getPlugin();return a&&a.jvms?!0:!1},isAutoUpdateEnabled:function(){return this.isPluginInstalled()?this.getPlugin().isAutoUpdateEnabled():!1},setAutoUpdateEnabled:function(){return this.isPluginInstalled()?this.getPlugin().setAutoUpdateEnabled():!1},setInstallerType:function(a){this.installType=a;return this.isPluginInstalled()?this.getPlugin().setInstallerType(a):!1},setAdditionalPackages:function(a){return this.isPluginInstalled()?this.getPlugin().setAdditionalPackages(a):!1},setEarlyAccess:function(a){this.EAInstallEnabled= -a},isPlugin2:function(){if(this.isPluginInstalled()&&this.versionCheck("1.6.0_10+"))try{return this.getPlugin().isPlugin2()}catch(a){}return!1},allowPlugin:function(){this.getBrowser();return"Safari"!=this.browserName2&&"Opera"!=this.browserName2},getPlugin:function(){this.refresh();var a=null;this.allowPlugin()&&(a=document.getElementById("deployJavaPlugin"));return a},compareVersionToPattern:function(a,b,c,d){if(void 0==a||void 0==b)return!1;var h=a.match("^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$"); -if(null!=h){var f=0;a=[];for(var m=1;mb[m])break}return!0}for(m=0;m "+a);-1!=a.indexOf("msie")&&-1==a.indexOf("opera")?this.browserName2=this.browserName= -"MSIE":-1!=a.indexOf("iphone")?(this.browserName="Netscape Family",this.browserName2="iPhone"):-1!=a.indexOf("firefox")&&-1==a.indexOf("opera")?(this.browserName="Netscape Family",this.browserName2="Firefox"):-1!=a.indexOf("chrome")?(this.browserName="Netscape Family",this.browserName2="Chrome"):-1!=a.indexOf("safari")?(this.browserName="Netscape Family",this.browserName2="Safari"):-1!=a.indexOf("mozilla")&&-1==a.indexOf("opera")?(this.browserName="Netscape Family",this.browserName2="Other"):-1!= -a.indexOf("opera")?(this.browserName="Netscape Family",this.browserName2="Opera"):(this.browserName="?",this.browserName2="unknown");f("[getBrowser()] Detected browser name:"+this.browserName+", "+this.browserName2)}return this.browserName},testUsingActiveX:function(a){a="JavaWebStart.isInstalled."+a+".0";if("undefined"==typeof ActiveXObject||!ActiveXObject)return f("[testUsingActiveX()] Browser claims to be IE, but no ActiveXObject object?"),!1;try{return null!=new ActiveXObject(a)}catch(b){return!1}}, -testForMSVM:function(){if("undefined"!=typeof oClientCaps){var a=oClientCaps.getComponentVersion("{08B0E5C0-4FCB-11CF-AAA5-00401C608500}","ComponentID");return""==a||"5,0,5000,0"==a?!1:!0}return!1},testUsingMimeTypes:function(a){if(!navigator.mimeTypes)return f("[testUsingMimeTypes()] Browser claims to be Netscape family, but no mimeTypes[] array?"),!1;for(var b=0;bd[0]?!0:c[0]d[1]?!0:c[1]d[2]?!0:c[2]'):"Netscape Family"==a&&this.allowPlugin()&&this.writeEmbedTag()},refresh:function(){navigator.plugins.refresh(!1);"Netscape Family"==this.getBrowser()&&this.allowPlugin()&&null== -document.getElementById("deployJavaPlugin")&&this.writeEmbedTag()},writeEmbedTag:function(){var a=!1;if(null!=navigator.mimeTypes){for(var b=0;b