fingerprintjs-rails 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,23 @@
|
|
1
1
|
/*
|
2
|
-
* fingerprintJS 0.
|
2
|
+
* fingerprintJS 0.5.0 - Fast browser fingerprint library
|
3
3
|
* https://github.com/Valve/fingerprintjs
|
4
4
|
* Copyright (c) 2013 Valentin Vasilyev (iamvalentin@gmail.com)
|
5
5
|
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
|
6
6
|
*/
|
7
|
-
/*jslint browser: true, indent: 2 */
|
8
|
-
(function(scope) {
|
7
|
+
/*jslint browser: true, indent: 2, maxerr: 50, maxlen: 120 */
|
8
|
+
(function (scope) {
|
9
9
|
'use strict';
|
10
10
|
|
11
|
-
var Fingerprint = function(options){
|
12
|
-
var nativeForEach
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
var Fingerprint = function (options) {
|
12
|
+
var nativeForEach, nativeMap;
|
13
|
+
nativeForEach = Array.prototype.forEach;
|
14
|
+
nativeMap = Array.prototype.map;
|
15
|
+
|
16
|
+
this.each = function (obj, iterator, context) {
|
17
|
+
if (obj === null) {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
if (nativeForEach && obj.forEach === nativeForEach) {
|
17
21
|
obj.forEach(iterator, context);
|
18
22
|
} else if (obj.length === +obj.length) {
|
19
23
|
for (var i = 0, l = obj.length; i < l; i++) {
|
@@ -27,6 +31,7 @@
|
|
27
31
|
}
|
28
32
|
}
|
29
33
|
};
|
34
|
+
|
30
35
|
this.map = function(obj, iterator, context) {
|
31
36
|
var results = [];
|
32
37
|
// Not using strict equality so that this acts as a
|
@@ -38,21 +43,29 @@
|
|
38
43
|
});
|
39
44
|
return results;
|
40
45
|
};
|
41
|
-
|
46
|
+
|
47
|
+
if (typeof options == 'object'){
|
42
48
|
this.hasher = options.hasher;
|
49
|
+
this.screen_resolution = options.screen_resolution;
|
43
50
|
this.canvas = options.canvas;
|
51
|
+
this.ie_activex = options.ie_activex;
|
44
52
|
} else if(typeof options == 'function'){
|
45
53
|
this.hasher = options;
|
46
54
|
}
|
47
55
|
};
|
48
56
|
|
49
57
|
Fingerprint.prototype = {
|
50
|
-
|
51
58
|
get: function(){
|
52
59
|
var keys = [];
|
53
60
|
keys.push(navigator.userAgent);
|
54
61
|
keys.push(navigator.language);
|
55
62
|
keys.push(screen.colorDepth);
|
63
|
+
if (this.screen_resolution) {
|
64
|
+
var resolution = this.getScreenResolution();
|
65
|
+
if (typeof resolution !== 'undefined'){ // headless browsers, such as phantomjs
|
66
|
+
keys.push(this.getScreenResolution().join('x'));
|
67
|
+
}
|
68
|
+
}
|
56
69
|
keys.push(new Date().getTimezoneOffset());
|
57
70
|
keys.push(this.hasSessionStorage());
|
58
71
|
keys.push(this.hasLocalStorage());
|
@@ -62,13 +75,7 @@
|
|
62
75
|
keys.push(navigator.cpuClass);
|
63
76
|
keys.push(navigator.platform);
|
64
77
|
keys.push(navigator.doNotTrack);
|
65
|
-
|
66
|
-
var mimeTypes = this.map(p, function(mt){
|
67
|
-
return [mt.type, mt.suffixes].join('~');
|
68
|
-
}).join(',');
|
69
|
-
return [p.name, p.description, mimeTypes].join('::');
|
70
|
-
}, this).join(';');
|
71
|
-
keys.push(pluginsString);
|
78
|
+
keys.push(this.getPluginsString());
|
72
79
|
if(this.canvas && this.isCanvasSupported()){
|
73
80
|
keys.push(this.getCanvasFingerprint());
|
74
81
|
}
|
@@ -145,7 +152,7 @@
|
|
145
152
|
},
|
146
153
|
|
147
154
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=781447
|
148
|
-
hasLocalStorage: function(){
|
155
|
+
hasLocalStorage: function () {
|
149
156
|
try{
|
150
157
|
return !!scope.localStorage;
|
151
158
|
} catch(e) {
|
@@ -153,7 +160,7 @@
|
|
153
160
|
}
|
154
161
|
},
|
155
162
|
|
156
|
-
hasSessionStorage: function(){
|
163
|
+
hasSessionStorage: function () {
|
157
164
|
try{
|
158
165
|
return !!scope.sessionStorage;
|
159
166
|
} catch(e) {
|
@@ -161,12 +168,72 @@
|
|
161
168
|
}
|
162
169
|
},
|
163
170
|
|
164
|
-
isCanvasSupported: function(){
|
171
|
+
isCanvasSupported: function () {
|
165
172
|
var elem = document.createElement('canvas');
|
166
173
|
return !!(elem.getContext && elem.getContext('2d'));
|
167
174
|
},
|
168
175
|
|
169
|
-
|
176
|
+
isIE: function () {
|
177
|
+
if(navigator.appName === 'Microsoft Internet Explorer') {
|
178
|
+
return true;
|
179
|
+
} else if(navigator.appName === 'Netscape' && /Trident/.test(navigator.userAgent)){// IE 11
|
180
|
+
return true;
|
181
|
+
}
|
182
|
+
return false;
|
183
|
+
},
|
184
|
+
|
185
|
+
getPluginsString: function () {
|
186
|
+
if(this.isIE()){
|
187
|
+
return this.getIEPluginsString();
|
188
|
+
} else {
|
189
|
+
return this.getRegularPluginsString();
|
190
|
+
}
|
191
|
+
},
|
192
|
+
|
193
|
+
getRegularPluginsString: function () {
|
194
|
+
return this.map(navigator.plugins, function (p) {
|
195
|
+
var mimeTypes = this.map(p, function(mt){
|
196
|
+
return [mt.type, mt.suffixes].join('~');
|
197
|
+
}).join(',');
|
198
|
+
return [p.name, p.description, mimeTypes].join('::');
|
199
|
+
}, this).join(';');
|
200
|
+
},
|
201
|
+
|
202
|
+
getIEPluginsString: function () {
|
203
|
+
var names = ['ShockwaveFlash.ShockwaveFlash',//flash plugin
|
204
|
+
'AcroPDF.PDF', // Adobe PDF reader 7+
|
205
|
+
'PDF.PdfCtrl', // Adobe PDF reader 6 and earlier, brrr
|
206
|
+
'QuickTime.QuickTime', // QuickTime
|
207
|
+
// 5 versions of real players
|
208
|
+
'rmocx.RealPlayer G2 Control',
|
209
|
+
'rmocx.RealPlayer G2 Control.1',
|
210
|
+
'RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)',
|
211
|
+
'RealVideo.RealVideo(tm) ActiveX Control (32-bit)',
|
212
|
+
'RealPlayer',
|
213
|
+
'SWCtl.SWCtl', // ShockWave player
|
214
|
+
'WMPlayer.OCX', // Windows media player
|
215
|
+
'AgControl.AgControl', // Silverlight
|
216
|
+
'Skype.Detection'];
|
217
|
+
if(this.ie_activex && scope.ActiveXObject){
|
218
|
+
// starting to detect plugins in IE
|
219
|
+
return this.map(names, function(name){
|
220
|
+
try{
|
221
|
+
new ActiveXObject(name);
|
222
|
+
return name;
|
223
|
+
} catch(e){
|
224
|
+
return null;
|
225
|
+
}
|
226
|
+
}).join(';');
|
227
|
+
} else {
|
228
|
+
return ""; // behavior prior version 0.5.0, not breaking backwards compat.
|
229
|
+
}
|
230
|
+
},
|
231
|
+
|
232
|
+
getScreenResolution: function () {
|
233
|
+
return [screen.height, screen.width];
|
234
|
+
},
|
235
|
+
|
236
|
+
getCanvasFingerprint: function () {
|
170
237
|
var canvas = document.createElement('canvas');
|
171
238
|
var ctx = canvas.getContext('2d');
|
172
239
|
// https://www.browserleaks.com/canvas#how-does-it-work
|
@@ -184,6 +251,7 @@
|
|
184
251
|
}
|
185
252
|
};
|
186
253
|
|
254
|
+
|
187
255
|
if (typeof module === 'object' && typeof exports === 'object') {
|
188
256
|
module.exports = Fingerprint;
|
189
257
|
}
|
@@ -1 +1 @@
|
|
1
|
-
!function(t){"use strict";var e=function(t){var e=Array.prototype.forEach,
|
1
|
+
!function(t){"use strict";var e=function(t){var e,n;e=Array.prototype.forEach,n=Array.prototype.map,this.each=function(t,n,r){if(null!==t)if(e&&t.forEach===e)t.forEach(n,r);else if(t.length===+t.length){for(var i=0,a=t.length;a>i;i++)if(n.call(r,t[i],i,t)==={})return}else for(var o in t)if(t.hasOwnProperty(o)&&n.call(r,t[o],o,t)==={})return},this.map=function(t,e,r){var i=[];return null==t?i:n&&t.map===n?t.map(e,r):(this.each(t,function(t,n,a){i[i.length]=e.call(r,t,n,a)}),i)},"object"==typeof t?(this.hasher=t.hasher,this.screen_resolution=t.screen_resolution,this.canvas=t.canvas,this.ie_activex=t.ie_activex):"function"==typeof t&&(this.hasher=t)};e.prototype={get:function(){var t=[];if(t.push(navigator.userAgent),t.push(navigator.language),t.push(screen.colorDepth),this.screen_resolution){var e=this.getScreenResolution();"undefined"!=typeof e&&t.push(this.getScreenResolution().join("x"))}return t.push((new Date).getTimezoneOffset()),t.push(this.hasSessionStorage()),t.push(this.hasLocalStorage()),t.push(!!window.indexedDB),t.push(typeof document.body.addBehavior),t.push(typeof window.openDatabase),t.push(navigator.cpuClass),t.push(navigator.platform),t.push(navigator.doNotTrack),t.push(this.getPluginsString()),this.canvas&&this.isCanvasSupported()&&t.push(this.getCanvasFingerprint()),this.hasher?this.hasher(t.join("###"),31):this.murmurhash3_32_gc(t.join("###"),31)},murmurhash3_32_gc:function(t,e){var n,r,i,a,o,s,c,h;for(n=3&t.length,r=t.length-n,i=e,o=3432918353,s=461845907,h=0;r>h;)c=255&t.charCodeAt(h)|(255&t.charCodeAt(++h))<<8|(255&t.charCodeAt(++h))<<16|(255&t.charCodeAt(++h))<<24,++h,c=4294967295&(65535&c)*o+((65535&(c>>>16)*o)<<16),c=c<<15|c>>>17,c=4294967295&(65535&c)*s+((65535&(c>>>16)*s)<<16),i^=c,i=i<<13|i>>>19,a=4294967295&5*(65535&i)+((65535&5*(i>>>16))<<16),i=(65535&a)+27492+((65535&(a>>>16)+58964)<<16);switch(c=0,n){case 3:c^=(255&t.charCodeAt(h+2))<<16;case 2:c^=(255&t.charCodeAt(h+1))<<8;case 1:c^=255&t.charCodeAt(h),c=4294967295&(65535&c)*o+((65535&(c>>>16)*o)<<16),c=c<<15|c>>>17,c=4294967295&(65535&c)*s+((65535&(c>>>16)*s)<<16),i^=c}return i^=t.length,i^=i>>>16,i=4294967295&2246822507*(65535&i)+((65535&2246822507*(i>>>16))<<16),i^=i>>>13,i=4294967295&3266489909*(65535&i)+((65535&3266489909*(i>>>16))<<16),i^=i>>>16,i>>>0},hasLocalStorage:function(){try{return!!t.localStorage}catch(e){return!0}},hasSessionStorage:function(){try{return!!t.sessionStorage}catch(e){return!0}},isCanvasSupported:function(){var t=document.createElement("canvas");return!(!t.getContext||!t.getContext("2d"))},isIE:function(){return"Microsoft Internet Explorer"===navigator.appName?!0:"Netscape"===navigator.appName&&/Trident/.test(navigator.userAgent)?!0:!1},getPluginsString:function(){return this.isIE()?this.getIEPluginsString():this.getRegularPluginsString()},getRegularPluginsString:function(){return this.map(navigator.plugins,function(t){var e=this.map(t,function(t){return[t.type,t.suffixes].join("~")}).join(",");return[t.name,t.description,e].join("::")},this).join(";")},getIEPluginsString:function(){var e=["ShockwaveFlash.ShockwaveFlash","AcroPDF.PDF","PDF.PdfCtrl","QuickTime.QuickTime","rmocx.RealPlayer G2 Control","rmocx.RealPlayer G2 Control.1","RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)","RealVideo.RealVideo(tm) ActiveX Control (32-bit)","RealPlayer","SWCtl.SWCtl","WMPlayer.OCX","AgControl.AgControl","Skype.Detection"];return this.ie_activex&&t.ActiveXObject?this.map(e,function(t){try{return new ActiveXObject(t),t}catch(e){return null}}).join(";"):""},getScreenResolution:function(){return[screen.height,screen.width]},getCanvasFingerprint:function(){var t=document.createElement("canvas"),e=t.getContext("2d"),n="http://valve.github.io";return e.textBaseline="top",e.font="14px 'Arial'",e.textBaseline="alphabetic",e.fillStyle="#f60",e.fillRect(125,1,62,20),e.fillStyle="#069",e.fillText(n,2,15),e.fillStyle="rgba(102, 204, 0, 0.7)",e.fillText(n,4,17),t.toDataURL()}},"object"==typeof module&&"object"==typeof exports&&(module.exports=e),t.Fingerprint=e}(window);
|
data/fingerprintjs-rails.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "fingerprintjs-rails"
|
7
|
-
gem.version = "0.
|
7
|
+
gem.version = "0.5.0"
|
8
8
|
gem.authors = ["Valentin Vasilyev"]
|
9
9
|
gem.email = ["iamvalentin@gmail.com"]
|
10
10
|
gem.description = "fingerprintjs for rails asset pipeline"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fingerprintjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: fingerprintjs for rails asset pipeline
|
15
15
|
email:
|