fingerprintjs-rails 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/fingerprint.js +115 -110
- data/app/assets/javascripts/fingerprint.min.js +10 -1
- data/fingerprintjs-rails.gemspec +1 -1
- metadata +3 -3
@@ -1,128 +1,133 @@
|
|
1
1
|
/*
|
2
|
-
* fingerprintJS 0.
|
3
|
-
* https://github.com/Valve/
|
2
|
+
* fingerprintJS 0.2 - Fast browser fingerprint library
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
7
|
+
/*jslint browser: true, indent: 2 */
|
8
|
+
(function() {
|
9
|
+
'use strict';
|
10
|
+
|
11
|
+
window.Fingerprint = function(hasher){
|
12
|
+
var nativeForEach = Array.prototype.forEach;
|
13
|
+
var nativeMap = Array.prototype.map;
|
14
|
+
this.each = function(obj, iterator, context) {
|
15
|
+
if(obj === null) return;
|
16
|
+
if(nativeForEach && obj.forEach === nativeForEach) {
|
17
|
+
obj.forEach(iterator, context);
|
18
|
+
} else if (obj.length === +obj.length) {
|
19
|
+
for (var i = 0, l = obj.length; i < l; i++) {
|
20
|
+
if (iterator.call(context, obj[i], i, obj) === {}) return;
|
21
|
+
}
|
22
|
+
} else {
|
23
|
+
for (var key in obj) {
|
24
|
+
if (obj.hasOwnProperty(key)) {
|
25
|
+
if (iterator.call(context, obj[key], key, obj) === {}) return;
|
26
|
+
}
|
22
27
|
}
|
23
28
|
}
|
24
|
-
}
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
};
|
29
|
+
};
|
30
|
+
this.map = function(obj, iterator, context) {
|
31
|
+
var results = [];
|
32
|
+
if (obj == null) return results;
|
33
|
+
if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
|
34
|
+
this.each(obj, function(value, index, list) {
|
35
|
+
results[results.length] = iterator.call(context, value, index, list);
|
36
|
+
});
|
37
|
+
return results;
|
38
|
+
};
|
35
39
|
|
36
|
-
|
37
|
-
|
40
|
+
if(hasher){
|
41
|
+
this.hasher = hasher;
|
42
|
+
}
|
38
43
|
}
|
39
|
-
}
|
40
44
|
|
41
|
-
Fingerprint.prototype = {
|
45
|
+
Fingerprint.prototype = {
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
47
|
+
get: function(){
|
48
|
+
var keys = [];
|
49
|
+
keys.push(navigator.userAgent);
|
50
|
+
keys.push([screen.height, screen.width, screen.colorDepth].join('x'));
|
51
|
+
keys.push(new Date().getTimezoneOffset());
|
52
|
+
keys.push(!!window.sessionStorage);
|
53
|
+
keys.push(!!window.localStorage);
|
54
|
+
var pluginsString = this.map(navigator.plugins, function(p){
|
55
|
+
var mimeTypes = this.map(p, function(mt){
|
56
|
+
return [mt.type, mt.suffixes].join('~');
|
57
|
+
}).join(',');
|
58
|
+
return [p.name, p.description, mimeTypes].join('::');
|
59
|
+
}, this).join(';');
|
60
|
+
keys.push(pluginsString);
|
61
|
+
if(this.hasher){
|
62
|
+
return this.hasher(keys.join('###'), 31);
|
63
|
+
} else {
|
64
|
+
return this.murmurhash3_32_gc(keys.join('###'), 31);
|
65
|
+
}
|
66
|
+
},
|
63
67
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
68
|
+
/**
|
69
|
+
* JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
|
70
|
+
*
|
71
|
+
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
|
72
|
+
* @see http://github.com/garycourt/murmurhash-js
|
73
|
+
* @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
|
74
|
+
* @see http://sites.google.com/site/murmurhash/
|
75
|
+
*
|
76
|
+
* @param {string} key ASCII only
|
77
|
+
* @param {number} seed Positive integer only
|
78
|
+
* @return {number} 32-bit positive integer hash
|
79
|
+
*/
|
76
80
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
while (i < bytes) {
|
88
|
-
k1 =
|
89
|
-
((key.charCodeAt(i) & 0xff)) |
|
90
|
-
((key.charCodeAt(++i) & 0xff) << 8) |
|
91
|
-
((key.charCodeAt(++i) & 0xff) << 16) |
|
92
|
-
((key.charCodeAt(++i) & 0xff) << 24);
|
93
|
-
++i;
|
81
|
+
murmurhash3_32_gc: function(key, seed) {
|
82
|
+
var remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i;
|
83
|
+
|
84
|
+
remainder = key.length & 3; // key.length % 4
|
85
|
+
bytes = key.length - remainder;
|
86
|
+
h1 = seed;
|
87
|
+
c1 = 0xcc9e2d51;
|
88
|
+
c2 = 0x1b873593;
|
89
|
+
i = 0;
|
94
90
|
|
95
|
-
|
96
|
-
|
97
|
-
|
91
|
+
while (i < bytes) {
|
92
|
+
k1 =
|
93
|
+
((key.charCodeAt(i) & 0xff)) |
|
94
|
+
((key.charCodeAt(++i) & 0xff) << 8) |
|
95
|
+
((key.charCodeAt(++i) & 0xff) << 16) |
|
96
|
+
((key.charCodeAt(++i) & 0xff) << 24);
|
97
|
+
++i;
|
98
|
+
|
99
|
+
k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;
|
100
|
+
k1 = (k1 << 15) | (k1 >>> 17);
|
101
|
+
k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;
|
98
102
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
k1 = 0;
|
106
|
-
|
107
|
-
switch (remainder) {
|
108
|
-
case 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16;
|
109
|
-
case 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8;
|
110
|
-
case 1: k1 ^= (key.charCodeAt(i) & 0xff);
|
103
|
+
h1 ^= k1;
|
104
|
+
h1 = (h1 << 13) | (h1 >>> 19);
|
105
|
+
h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;
|
106
|
+
h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));
|
107
|
+
}
|
111
108
|
|
112
|
-
k1 =
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
109
|
+
k1 = 0;
|
110
|
+
|
111
|
+
switch (remainder) {
|
112
|
+
case 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16;
|
113
|
+
case 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8;
|
114
|
+
case 1: k1 ^= (key.charCodeAt(i) & 0xff);
|
115
|
+
|
116
|
+
k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;
|
117
|
+
k1 = (k1 << 15) | (k1 >>> 17);
|
118
|
+
k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;
|
119
|
+
h1 ^= k1;
|
120
|
+
}
|
121
|
+
|
122
|
+
h1 ^= key.length;
|
119
123
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
124
|
+
h1 ^= h1 >>> 16;
|
125
|
+
h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;
|
126
|
+
h1 ^= h1 >>> 13;
|
127
|
+
h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
|
128
|
+
h1 ^= h1 >>> 16;
|
125
129
|
|
126
|
-
|
130
|
+
return h1 >>> 0;
|
131
|
+
}
|
127
132
|
}
|
128
|
-
}
|
133
|
+
})();
|
@@ -1 +1,10 @@
|
|
1
|
-
|
1
|
+
/*
|
2
|
+
* fingerprintJS 0.2 - 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(){'use strict';window.Fingerprint=function(a){var e=Array.prototype.forEach,f=Array.prototype.map;this.each=function(a,b,c){if(null!==a)if(e&&a.forEach===e)a.forEach(b,c);else if(a.length===+a.length)for(var d=0,f=a.length;d<f&&b.call(c,a[d],d,a)!=={};d++);else for(d in a)if(a.hasOwnProperty(d)&&b.call(c,a[d],d,a)==={})break};this.map=function(a,b,c){var d=[];if(null==a)return d;if(f&&a.map===f)return a.map(b,c);this.each(a,function(a,f,e){d[d.length]=b.call(c,a,f,e)});return d};a&&(this.hasher=a)};
|
8
|
+
Fingerprint.prototype={get:function(){var a=[];a.push(navigator.userAgent);a.push([screen.height,screen.width,screen.colorDepth].join("x"));a.push((new Date).getTimezoneOffset());a.push(!!window.sessionStorage);a.push(!!window.localStorage);var e=this.map(navigator.plugins,function(a){var e=this.map(a,function(a){return[a.type,a.suffixes].join("~")}).join(",");return[a.name,a.description,e].join("::")},this).join(";");a.push(e);return this.hasher?this.hasher(a.join("###"),31):this.murmurhash3_32_gc(a.join("###"),
|
9
|
+
31)},murmurhash3_32_gc:function(a,e){var f,g,b,c,d;f=a.length&3;g=a.length-f;b=e;for(d=0;d<g;)c=a.charCodeAt(d)&255|(a.charCodeAt(++d)&255)<<8|(a.charCodeAt(++d)&255)<<16|(a.charCodeAt(++d)&255)<<24,++d,c=3432918353*(c&65535)+((3432918353*(c>>>16)&65535)<<16)&4294967295,c=c<<15|c>>>17,c=461845907*(c&65535)+((461845907*(c>>>16)&65535)<<16)&4294967295,b^=c,b=b<<13|b>>>19,b=5*(b&65535)+((5*(b>>>16)&65535)<<16)&4294967295,b=(b&65535)+27492+(((b>>>16)+58964&65535)<<16);c=0;switch(f){case 3:c^=(a.charCodeAt(d+
|
10
|
+
2)&255)<<16;case 2:c^=(a.charCodeAt(d+1)&255)<<8;case 1:c^=a.charCodeAt(d)&255,c=3432918353*(c&65535)+((3432918353*(c>>>16)&65535)<<16)&4294967295,c=c<<15|c>>>17,b^=461845907*(c&65535)+((461845907*(c>>>16)&65535)<<16)&4294967295}b^=a.length;b^=b>>>16;b=2246822507*(b&65535)+((2246822507*(b>>>16)&65535)<<16)&4294967295;b^=b>>>13;b=3266489909*(b&65535)+((3266489909*(b>>>16)&65535)<<16)&4294967295;return(b^b>>>16)>>>0}}})();
|
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.2.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.2.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-05-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: fingerprintjs for rails asset pipeline
|
15
15
|
email:
|
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
47
|
version: '0'
|
48
48
|
requirements: []
|
49
49
|
rubyforge_project:
|
50
|
-
rubygems_version: 1.8.
|
50
|
+
rubygems_version: 1.8.23
|
51
51
|
signing_key:
|
52
52
|
specification_version: 3
|
53
53
|
summary: FingerprintJS JavaScript library, packaged for Ruby-on-Rails asset pipeline
|