scratch – Diff between revs 58 and 125
?pathlinks?
Rev 58 | Rev 125 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | /* |
1 | /* |
|
2 | * Fingerprintjs2 1.5.0 - Modern & flexible browser fingerprint library v2 |
2 | * Fingerprintjs2 1.5.1 - Modern & flexible browser fingerprint library v2 |
|
3 | * https://github.com/Valve/fingerprintjs2 |
3 | * https://github.com/Valve/fingerprintjs2 |
|
4 | * Copyright (c) 2015 Valentin Vasilyev (valentin.vasilyev@outlook.com) |
4 | * Copyright (c) 2015 Valentin Vasilyev (valentin.vasilyev@outlook.com) |
|
5 | * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. |
5 | * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. |
|
6 | * |
6 | * |
|
7 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
7 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
Line 22... | Line 22... | |||
22 | else if (typeof module !== "undefined" && module.exports) { module.exports = definition(); } |
22 | else if (typeof module !== "undefined" && module.exports) { module.exports = definition(); } |
|
23 | else if (context.exports) { context.exports = definition(); } |
23 | else if (context.exports) { context.exports = definition(); } |
|
24 | else { context[name] = definition(); } |
24 | else { context[name] = definition(); } |
|
25 | })("Fingerprint2", this, function() { |
25 | })("Fingerprint2", this, function() { |
|
26 | "use strict"; |
26 | "use strict"; |
|
27 | // This will only be polyfilled for IE8 and older |
- | ||
28 | // Taken from Mozilla MDC |
- | ||
29 | if (!Array.prototype.indexOf) { |
- | ||
30 | Array.prototype.indexOf = function(searchElement, fromIndex) { |
- | ||
31 | var k; |
- | ||
32 | if (this == null) { |
- | ||
33 | throw new TypeError("'this' is null or undefined"); |
- | ||
34 | } |
- | ||
35 | var O = Object(this); |
- | ||
36 | var len = O.length >>> 0; |
- | ||
37 | if (len === 0) { |
- | ||
38 | return -1; |
- | ||
39 | } |
- | ||
40 | var n = +fromIndex || 0; |
- | ||
41 | if (Math.abs(n) === Infinity) { |
- | ||
42 | n = 0; |
- | ||
43 | } |
- | ||
44 | if (n >= len) { |
- | ||
45 | return -1; |
- | ||
46 | } |
- | ||
47 | k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); |
- | ||
48 | while (k < len) { |
- | ||
49 | if (k in O && O[k] === searchElement) { |
- | ||
50 | return k; |
- | ||
51 | } |
- | ||
52 | k++; |
- | ||
53 | } |
- | ||
54 | return -1; |
- | ||
55 | }; |
- | ||
56 | } |
- | ||
57 | var Fingerprint2 = function(options) { |
27 | var Fingerprint2 = function(options) { |
|
Line 58... | Line 28... | |||
58 | |
28 | |
|
59 | if (!(this instanceof Fingerprint2)) { |
29 | if (!(this instanceof Fingerprint2)) { |
|
60 | return new Fingerprint2(options); |
30 | return new Fingerprint2(options); |
|
Line 79... | Line 49... | |||
79 | target[k] = source[k]; |
49 | target[k] = source[k]; |
|
80 | } |
50 | } |
|
81 | } |
51 | } |
|
82 | return target; |
52 | return target; |
|
83 | }, |
53 | }, |
|
84 | log: function(msg){ |
- | ||
85 | if(window.console){ |
- | ||
86 | console.log(msg); |
- | ||
87 | } |
- | ||
88 | }, |
- | ||
89 | get: function(done){ |
54 | get: function(done){ |
|
90 | var keys = []; |
55 | var keys = []; |
|
91 | keys = this.userAgentKey(keys); |
56 | keys = this.userAgentKey(keys); |
|
92 | keys = this.languageKey(keys); |
57 | keys = this.languageKey(keys); |
|
93 | keys = this.colorDepthKey(keys); |
58 | keys = this.colorDepthKey(keys); |
|
Line 111... | Line 76... | |||
111 | keys = this.hasLiedLanguagesKey(keys); |
76 | keys = this.hasLiedLanguagesKey(keys); |
|
112 | keys = this.hasLiedResolutionKey(keys); |
77 | keys = this.hasLiedResolutionKey(keys); |
|
113 | keys = this.hasLiedOsKey(keys); |
78 | keys = this.hasLiedOsKey(keys); |
|
114 | keys = this.hasLiedBrowserKey(keys); |
79 | keys = this.hasLiedBrowserKey(keys); |
|
115 | keys = this.touchSupportKey(keys); |
80 | keys = this.touchSupportKey(keys); |
|
- | 81 | keys = this.customEntropyFunction(keys); |
||
116 | var that = this; |
82 | var that = this; |
|
117 | this.fontsKey(keys, function(newKeys){ |
83 | this.fontsKey(keys, function(newKeys){ |
|
118 | var values = []; |
84 | var values = []; |
|
119 | that.each(newKeys, function(pair) { |
85 | that.each(newKeys, function(pair) { |
|
120 | var value = pair.value; |
86 | var value = pair.value; |
|
Line 125... | Line 91... | |||
125 | }); |
91 | }); |
|
126 | var murmur = that.x64hash128(values.join("~~~"), 31); |
92 | var murmur = that.x64hash128(values.join("~~~"), 31); |
|
127 | return done(murmur, newKeys); |
93 | return done(murmur, newKeys); |
|
128 | }); |
94 | }); |
|
129 | }, |
95 | }, |
|
- | 96 | customEntropyFunction: function (keys) { |
||
- | 97 | if (typeof this.options.customFunction === "function") { |
||
- | 98 | keys.push({key: "custom", value: this.options.customFunction()}); |
||
- | 99 | } |
||
- | 100 | return keys; |
||
- | 101 | }, |
||
130 | userAgentKey: function(keys) { |
102 | userAgentKey: function(keys) { |
|
131 | if(!this.options.excludeUserAgent) { |
103 | if(!this.options.excludeUserAgent) { |
|
132 | keys.push({key: "user_agent", value: this.getUserAgent()}); |
104 | keys.push({key: "user_agent", value: this.getUserAgent()}); |
|
133 | } |
105 | } |
|
134 | return keys; |
106 | return keys; |
|
Line 258... | Line 230... | |||
258 | } |
230 | } |
|
259 | return keys; |
231 | return keys; |
|
260 | }, |
232 | }, |
|
261 | webglKey: function(keys) { |
233 | webglKey: function(keys) { |
|
262 | if(this.options.excludeWebGL) { |
234 | if(this.options.excludeWebGL) { |
|
263 | if(typeof NODEBUG === "undefined"){ |
- | ||
264 | this.log("Skipping WebGL fingerprinting per excludeWebGL configuration option"); |
- | ||
265 | } |
- | ||
266 | return keys; |
235 | return keys; |
|
267 | } |
236 | } |
|
268 | if(!this.isWebGlSupported()) { |
237 | if(!this.isWebGlSupported()) { |
|
269 | if(typeof NODEBUG === "undefined"){ |
- | ||
270 | this.log("Skipping WebGL fingerprinting because it is not supported in this browser"); |
- | ||
271 | } |
- | ||
272 | return keys; |
238 | return keys; |
|
273 | } |
239 | } |
|
274 | keys.push({key: "webgl", value: this.getWebglFp()}); |
240 | keys.push({key: "webgl", value: this.getWebglFp()}); |
|
275 | return keys; |
241 | return keys; |
|
276 | }, |
242 | }, |
|
Line 311... | Line 277... | |||
311 | return this.jsFontsKey(keys, done); |
277 | return this.jsFontsKey(keys, done); |
|
312 | }, |
278 | }, |
|
313 | // flash fonts (will increase fingerprinting time 20X to ~ 130-150ms) |
279 | // flash fonts (will increase fingerprinting time 20X to ~ 130-150ms) |
|
314 | flashFontsKey: function(keys, done) { |
280 | flashFontsKey: function(keys, done) { |
|
315 | if(this.options.excludeFlashFonts) { |
281 | if(this.options.excludeFlashFonts) { |
|
316 | if(typeof NODEBUG === "undefined"){ |
- | ||
317 | this.log("Skipping flash fonts detection per excludeFlashFonts configuration option"); |
- | ||
318 | } |
- | ||
319 | return done(keys); |
282 | return done(keys); |
|
320 | } |
283 | } |
|
321 | // we do flash if swfobject is loaded |
284 | // we do flash if swfobject is loaded |
|
322 | if(!this.hasSwfObjectLoaded()){ |
285 | if(!this.hasSwfObjectLoaded()){ |
|
323 | if(typeof NODEBUG === "undefined"){ |
- | ||
324 | this.log("Swfobject is not detected, Flash fonts enumeration is skipped"); |
- | ||
325 | } |
- | ||
326 | return done(keys); |
286 | return done(keys); |
|
327 | } |
287 | } |
|
328 | if(!this.hasMinFlashInstalled()){ |
288 | if(!this.hasMinFlashInstalled()){ |
|
329 | if(typeof NODEBUG === "undefined"){ |
- | ||
330 | this.log("Flash is not installed, skipping Flash fonts enumeration"); |
- | ||
331 | } |
- | ||
332 | return done(keys); |
289 | return done(keys); |
|
333 | } |
290 | } |
|
334 | if(typeof this.options.swfPath === "undefined"){ |
291 | if(typeof this.options.swfPath === "undefined"){ |
|
335 | if(typeof NODEBUG === "undefined"){ |
- | ||
336 | this.log("To use Flash fonts detection, you must pass a valid swfPath option, skipping Flash fonts enumeration"); |
- | ||
337 | } |
- | ||
338 | return done(keys); |
292 | return done(keys); |
|
339 | } |
293 | } |
|
340 | this.loadSwfAndDetectFonts(function(fonts){ |
294 | this.loadSwfAndDetectFonts(function(fonts){ |
|
341 | keys.push({key: "swf_fonts", value: fonts.join(";")}); |
295 | keys.push({key: "swf_fonts", value: fonts.join(";")}); |
|
342 | done(keys); |
296 | done(keys); |
|
Line 828... | Line 782... | |||
828 | result.push("webgl version:" + gl.getParameter(gl.VERSION)); |
782 | result.push("webgl version:" + gl.getParameter(gl.VERSION)); |
|
Line 829... | Line 783... | |||
829 | |
783 | |
|
830 | try { |
784 | try { |
|
831 | // Add the unmasked vendor and unmasked renderer if the debug_renderer_info extension is available |
785 | // Add the unmasked vendor and unmasked renderer if the debug_renderer_info extension is available |
|
832 | var extensionDebugRendererInfo = gl.getExtension("WEBGL_debug_renderer_info"); |
786 | var extensionDebugRendererInfo = gl.getExtension("WEBGL_debug_renderer_info"); |
|
833 | if (!extensionDebugRendererInfo) { |
- | ||
834 | if (typeof NODEBUG === "undefined") { |
- | ||
835 | this.log("WebGL fingerprinting is incomplete, because your browser does not have the extension WEBGL_debug_renderer_info"); |
- | ||
836 | } |
- | ||
837 | } else { |
787 | if (extensionDebugRendererInfo) { |
|
838 | result.push("webgl unmasked vendor:" + gl.getParameter(extensionDebugRendererInfo.UNMASKED_VENDOR_WEBGL)); |
788 | result.push("webgl unmasked vendor:" + gl.getParameter(extensionDebugRendererInfo.UNMASKED_VENDOR_WEBGL)); |
|
839 | result.push("webgl unmasked renderer:" + gl.getParameter(extensionDebugRendererInfo.UNMASKED_RENDERER_WEBGL)); |
789 | result.push("webgl unmasked renderer:" + gl.getParameter(extensionDebugRendererInfo.UNMASKED_RENDERER_WEBGL)); |
|
840 | } |
790 | } |
|
Line 841... | Line 791... | |||
841 | } catch(e) { /* squelch */ } |
791 | } catch(e) { /* squelch */ } |
|
842 | |
- | ||
843 | if (!gl.getShaderPrecisionFormat) { |
- | ||
844 | if (typeof NODEBUG === "undefined") { |
- | ||
845 | this.log("WebGL fingerprinting is incomplete, because your browser does not support getShaderPrecisionFormat"); |
792 | |
|
846 | } |
793 | if (!gl.getShaderPrecisionFormat) { |
|
Line 847... | Line 794... | |||
847 | return result.join("~"); |
794 | return result.join("~"); |
|
848 | } |
795 | } |
|
Line 1325... | Line 1272... | |||
1325 | h1 = this.x64Add(h1, h2); |
1272 | h1 = this.x64Add(h1, h2); |
|
1326 | h2 = this.x64Add(h2, h1); |
1273 | h2 = this.x64Add(h2, h1); |
|
1327 | return ("00000000" + (h1[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h1[1] >>> 0).toString(16)).slice(-8) + ("00000000" + (h2[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h2[1] >>> 0).toString(16)).slice(-8); |
1274 | return ("00000000" + (h1[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h1[1] >>> 0).toString(16)).slice(-8) + ("00000000" + (h2[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h2[1] >>> 0).toString(16)).slice(-8); |
|
1328 | } |
1275 | } |
|
1329 | }; |
1276 | }; |
|
1330 | Fingerprint2.VERSION = "1.5.0"; |
1277 | Fingerprint2.VERSION = "1.5.1"; |
|
1331 | return Fingerprint2; |
1278 | return Fingerprint2; |
|
1332 | }); |
1279 | }); |