fingerprintjs-rails 0.3.2 → 0.4.1
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,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* fingerprintJS 0.
|
2
|
+
* fingerprintJS 0.4.1 - 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.
|
@@ -8,7 +8,7 @@
|
|
8
8
|
(function(scope) {
|
9
9
|
'use strict';
|
10
10
|
|
11
|
-
var Fingerprint = function(
|
11
|
+
var Fingerprint = function(options){
|
12
12
|
var nativeForEach = Array.prototype.forEach;
|
13
13
|
var nativeMap = Array.prototype.map;
|
14
14
|
this.each = function(obj, iterator, context) {
|
@@ -38,9 +38,11 @@
|
|
38
38
|
});
|
39
39
|
return results;
|
40
40
|
};
|
41
|
-
|
42
|
-
|
43
|
-
this.
|
41
|
+
if(typeof options == 'object'){
|
42
|
+
this.hasher = options.hasher;
|
43
|
+
this.canvas = options.canvas;
|
44
|
+
} else if(typeof options == 'function'){
|
45
|
+
this.hasher = options;
|
44
46
|
}
|
45
47
|
};
|
46
48
|
|
@@ -67,6 +69,9 @@
|
|
67
69
|
return [p.name, p.description, mimeTypes].join('::');
|
68
70
|
}, this).join(';');
|
69
71
|
keys.push(pluginsString);
|
72
|
+
if(this.canvas && this.isCanvasSupported()){
|
73
|
+
keys.push(this.getCanvasFingerprint());
|
74
|
+
}
|
70
75
|
if(this.hasher){
|
71
76
|
return this.hasher(keys.join('###'), 31);
|
72
77
|
} else {
|
@@ -88,7 +93,7 @@
|
|
88
93
|
*/
|
89
94
|
|
90
95
|
murmurhash3_32_gc: function(key, seed) {
|
91
|
-
var remainder, bytes, h1, h1b, c1,
|
96
|
+
var remainder, bytes, h1, h1b, c1, c2, k1, i;
|
92
97
|
|
93
98
|
remainder = key.length & 3; // key.length % 4
|
94
99
|
bytes = key.length - remainder;
|
@@ -146,6 +151,28 @@
|
|
146
151
|
} catch(e) {
|
147
152
|
return true; // SecurityError when referencing it means it exists
|
148
153
|
}
|
154
|
+
},
|
155
|
+
|
156
|
+
isCanvasSupported: function(){
|
157
|
+
var elem = document.createElement('canvas');
|
158
|
+
return !!(elem.getContext && elem.getContext('2d'));
|
159
|
+
},
|
160
|
+
|
161
|
+
getCanvasFingerprint: function(){
|
162
|
+
var canvas = document.createElement('canvas');
|
163
|
+
var ctx = canvas.getContext('2d');
|
164
|
+
// https://www.browserleaks.com/canvas#how-does-it-work
|
165
|
+
var txt = 'http://valve.github.io';
|
166
|
+
ctx.textBaseline = "top";
|
167
|
+
ctx.font = "14px 'Arial'";
|
168
|
+
ctx.textBaseline = "alphabetic";
|
169
|
+
ctx.fillStyle = "#f60";
|
170
|
+
ctx.fillRect(125,1,62,20);
|
171
|
+
ctx.fillStyle = "#069";
|
172
|
+
ctx.fillText(txt, 2, 15);
|
173
|
+
ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
|
174
|
+
ctx.fillText(txt, 4, 17);
|
175
|
+
return canvas.toDataURL();
|
149
176
|
}
|
150
177
|
};
|
151
178
|
|
@@ -1 +1,7 @@
|
|
1
|
-
|
1
|
+
/*
|
2
|
+
* fingerprintJS 0.4 - Fast browser fingerprint library
|
3
|
+
* https://github.com/Valve/fingerprintjs
|
4
|
+
* Copyright (c) 2013 Valentin Vasilyev (iamvalentin@gmail.com)
|
5
|
+
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
|
6
|
+
*/
|
7
|
+
!function(t){"use strict";var e=function(t){var e=Array.prototype.forEach,a=Array.prototype.map;this.each=function(t,a,n){if(null!==t)if(e&&t.forEach===e)t.forEach(a,n);else if(t.length===+t.length){for(var r=0,o=t.length;o>r;r++)if(a.call(n,t[r],r,t)==={})return}else for(var i in t)if(t.hasOwnProperty(i)&&a.call(n,t[i],i,t)==={})return},this.map=function(t,e,n){var r=[];return null==t?r:a&&t.map===a?t.map(e,n):(this.each(t,function(t,a,o){r[r.length]=e.call(n,t,a,o)}),r)},"object"==typeof t?(this.hasher=t.hasher,this.canvas=t.canvas):"function"==typeof t&&(this.hasher=t)};e.prototype={get:function(){var e=[];e.push(navigator.userAgent),e.push(navigator.language),e.push(screen.colorDepth),e.push((new Date).getTimezoneOffset()),e.push(!!t.sessionStorage),e.push(this.hasLocalStorage()),e.push(!!window.indexedDB),e.push(typeof document.body.addBehavior),e.push(typeof window.openDatabase),e.push(navigator.cpuClass),e.push(navigator.platform),e.push(navigator.doNotTrack);var a=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(";");return e.push(a),this.canvas&&this.isCanvasSupported()&&e.push(this.getCanvasFingerprint()),this.hasher?this.hasher(e.join("###"),31):this.murmurhash3_32_gc(e.join("###"),31)},murmurhash3_32_gc:function(t,e){var a,n,r,o,i,s,h,c;for(a=3&t.length,n=t.length-a,r=e,i=3432918353,s=461845907,c=0;n>c;)h=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<24,++c,h=4294967295&(65535&h)*i+((65535&(h>>>16)*i)<<16),h=h<<15|h>>>17,h=4294967295&(65535&h)*s+((65535&(h>>>16)*s)<<16),r^=h,r=r<<13|r>>>19,o=4294967295&5*(65535&r)+((65535&5*(r>>>16))<<16),r=(65535&o)+27492+((65535&(o>>>16)+58964)<<16);switch(h=0,a){case 3:h^=(255&t.charCodeAt(c+2))<<16;case 2:h^=(255&t.charCodeAt(c+1))<<8;case 1:h^=255&t.charCodeAt(c),h=4294967295&(65535&h)*i+((65535&(h>>>16)*i)<<16),h=h<<15|h>>>17,h=4294967295&(65535&h)*s+((65535&(h>>>16)*s)<<16),r^=h}return r^=t.length,r^=r>>>16,r=4294967295&2246822507*(65535&r)+((65535&2246822507*(r>>>16))<<16),r^=r>>>13,r=4294967295&3266489909*(65535&r)+((65535&3266489909*(r>>>16))<<16),r^=r>>>16,r>>>0},hasLocalStorage:function(){try{return!!t.localStorage}catch(e){return!0}},isCanvasSupported:function(){var t=document.createElement("canvas");return!(!t.getContext||!t.getContext("2d"))},getCanvasFingerprint:function(){var t=document.createElement("canvas"),e=t.getContext("2d"),a="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(a,2,15),e.fillStyle="rgba(102, 204, 0, 0.7)",e.fillText(a,4,17),t.toDataURL()}},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.4.1"
|
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.4.1
|
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-09-02 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: fingerprintjs for rails asset pipeline
|
15
15
|
email:
|