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.
@@ -1,128 +1,133 @@
1
1
  /*
2
- * fingerprintJS 0.1 - Fast browser fingerprint library
3
- * https://github.com/Valve/fingerprintJS
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
- function Fingerprint(hasher){
8
- var nativeForEach = Array.prototype.forEach;
9
- var nativeMap = Array.prototype.map;
10
- this.each = function(obj, iterator, context) {
11
- if (obj == null) return;
12
- if (nativeForEach && obj.forEach === nativeForEach) {
13
- obj.forEach(iterator, context);
14
- } else if (obj.length === +obj.length) {
15
- for (var i = 0, l = obj.length; i < l; i++) {
16
- if (iterator.call(context, obj[i], i, obj) === {}) return;
17
- }
18
- } else {
19
- for (var key in obj) {
20
- if (obj.hasOwnProperty(key)) {
21
- if (iterator.call(context, obj[key], key, obj) === {}) return;
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
- this.map = function(obj, iterator, context) {
27
- var results = [];
28
- if (obj == null) return results;
29
- if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
30
- this.each(obj, function(value, index, list) {
31
- results[results.length] = iterator.call(context, value, index, list);
32
- });
33
- return results;
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
- if(hasher){
37
- this.hasher = hasher;
40
+ if(hasher){
41
+ this.hasher = hasher;
42
+ }
38
43
  }
39
- }
40
44
 
41
- Fingerprint.prototype = {
45
+ Fingerprint.prototype = {
42
46
 
43
- get: function(){
44
- keys = [];
45
- keys.push(navigator.userAgent);
46
- keys.push([screen.height, screen.width, screen.colorDepth].join('x'));
47
- keys.push(new Date().getTimezoneOffset());
48
- keys.push(!!window.sessionStorage);
49
- keys.push(!!window.localStorage);
50
- var pluginsString = this.map(navigator.plugins, function(p){
51
- var mimeTypes = this.map(p, function(mt){
52
- return [mt.type, mt.suffixes].join('~');
53
- }).join(',');
54
- return [p.name, p.description, mimeTypes].join('::');
55
- }, this).join(';');
56
- keys.push(pluginsString);
57
- if(this.hasher){
58
- return this.hasher(keys.join('###'), 31);
59
- } else {
60
- return this.murmurhash3_32_gc(keys.join('###'), 31);
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
- * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
66
- *
67
- * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
68
- * @see http://github.com/garycourt/murmurhash-js
69
- * @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
70
- * @see http://sites.google.com/site/murmurhash/
71
- *
72
- * @param {string} key ASCII only
73
- * @param {number} seed Positive integer only
74
- * @return {number} 32-bit positive integer hash
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
- murmurhash3_32_gc: function(key, seed) {
78
- var remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i;
79
-
80
- remainder = key.length & 3; // key.length % 4
81
- bytes = key.length - remainder;
82
- h1 = seed;
83
- c1 = 0xcc9e2d51;
84
- c2 = 0x1b873593;
85
- i = 0;
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
- k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;
96
- k1 = (k1 << 15) | (k1 >>> 17);
97
- k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;
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
- h1 ^= k1;
100
- h1 = (h1 << 13) | (h1 >>> 19);
101
- h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;
102
- h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));
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 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;
113
- k1 = (k1 << 15) | (k1 >>> 17);
114
- k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;
115
- h1 ^= k1;
116
- }
117
-
118
- h1 ^= key.length;
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
- h1 ^= h1 >>> 16;
121
- h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;
122
- h1 ^= h1 >>> 13;
123
- h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
124
- h1 ^= h1 >>> 16;
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
- return h1 >>> 0;
130
+ return h1 >>> 0;
131
+ }
127
132
  }
128
- }
133
+ })();
@@ -1 +1,10 @@
1
- function Fingerprint(e){var r=Array.prototype.forEach,t=Array.prototype.map;this.each=function(e,t,n){if(null!=e)if(r&&e.forEach===r)e.forEach(t,n);else if(e.length===+e.length){for(var h=0,s=e.length;s>h;h++)if(t.call(n,e[h],h,e)==={})return}else for(var a in e)if(e.hasOwnProperty(a)&&t.call(n,e[a],a,e)==={})return},this.map=function(e,r,n){var h=[];return null==e?h:t&&e.map===t?e.map(r,n):(this.each(e,function(e,t,s){h[h.length]=r.call(n,e,t,s)}),h)},e&&(this.hasher=e)}Fingerprint.prototype={get:function(){keys=[],keys.push(navigator.userAgent),keys.push([screen.height,screen.width,screen.colorDepth].join("x")),keys.push((new Date).getTimezoneOffset()),keys.push(!!window.sessionStorage),keys.push(!!window.localStorage);var e=this.map(navigator.plugins,function(e){var r=this.map(e,function(e){return[e.type,e.suffixes].join("~")}).join(",");return[e.name,e.description,r].join("::")},this).join(";");return keys.push(e),this.hasher?this.hasher(keys.join("###"),31):this.murmurhash3_32_gc(keys.join("###"),31)},murmurhash3_32_gc:function(e,r){var t,n,h,s,a,i,o,c;for(t=3&e.length,n=e.length-t,h=r,a=3432918353,i=461845907,c=0;n>c;)o=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,o=4294967295&(65535&o)*a+((65535&(o>>>16)*a)<<16),o=o<<15|o>>>17,o=4294967295&(65535&o)*i+((65535&(o>>>16)*i)<<16),h^=o,h=h<<13|h>>>19,s=4294967295&5*(65535&h)+((65535&5*(h>>>16))<<16),h=(65535&s)+27492+((65535&(s>>>16)+58964)<<16);switch(o=0,t){case 3:o^=(255&e.charCodeAt(c+2))<<16;case 2:o^=(255&e.charCodeAt(c+1))<<8;case 1:o^=255&e.charCodeAt(c),o=4294967295&(65535&o)*a+((65535&(o>>>16)*a)<<16),o=o<<15|o>>>17,o=4294967295&(65535&o)*i+((65535&(o>>>16)*i)<<16),h^=o}return h^=e.length,h^=h>>>16,h=4294967295&2246822507*(65535&h)+((65535&2246822507*(h>>>16))<<16),h^=h>>>13,h=4294967295&3266489909*(65535&h)+((65535&3266489909*(h>>>16))<<16),h^=h>>>16,h>>>0}};
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}}})();
@@ -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.1.1"
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.1.1
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-01-09 00:00:00.000000000 Z
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.24
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