fingerprintjs-rails 0.3.2 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  /*
2
- * fingerprintJS 0.3.2 - Fast browser fingerprint library
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(hasher){
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
- if(hasher){
43
- this.hasher = hasher;
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, c1b, c2, c2b, k1, i;
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
- !function(t){"use strict";var r=function(t){var r=Array.prototype.forEach,a=Array.prototype.map;this.each=function(t,a,e){if(null!==t)if(r&&t.forEach===r)t.forEach(a,e);else if(t.length===+t.length){for(var n=0,o=t.length;o>n;n++)if(a.call(e,t[n],n,t)==={})return}else for(var h in t)if(t.hasOwnProperty(h)&&a.call(e,t[h],h,t)==={})return},this.map=function(t,r,e){var n=[];return null==t?n:a&&t.map===a?t.map(r,e):(this.each(t,function(t,a,o){n[n.length]=r.call(e,t,a,o)}),n)},t&&(this.hasher=t)};r.prototype={get:function(){var r=[];r.push(navigator.userAgent),r.push(navigator.language),r.push(screen.colorDepth),r.push((new Date).getTimezoneOffset()),r.push(!!t.sessionStorage),r.push(this.hasLocalStorage()),r.push(!!window.indexedDB),r.push(typeof document.body.addBehavior),r.push(typeof window.openDatabase),r.push(navigator.cpuClass),r.push(navigator.platform),r.push(navigator.doNotTrack);var a=this.map(navigator.plugins,function(t){var r=this.map(t,function(t){return[t.type,t.suffixes].join("~")}).join(",");return[t.name,t.description,r].join("::")},this).join(";");return r.push(a),this.hasher?this.hasher(r.join("###"),31):this.murmurhash3_32_gc(r.join("###"),31)},murmurhash3_32_gc:function(t,r){var a,e,n,o,h,i,s,u;for(a=3&t.length,e=t.length-a,n=r,h=3432918353,i=461845907,u=0;e>u;)s=255&t.charCodeAt(u)|(255&t.charCodeAt(++u))<<8|(255&t.charCodeAt(++u))<<16|(255&t.charCodeAt(++u))<<24,++u,s=4294967295&(65535&s)*h+((65535&(s>>>16)*h)<<16),s=s<<15|s>>>17,s=4294967295&(65535&s)*i+((65535&(s>>>16)*i)<<16),n^=s,n=n<<13|n>>>19,o=4294967295&5*(65535&n)+((65535&5*(n>>>16))<<16),n=(65535&o)+27492+((65535&(o>>>16)+58964)<<16);switch(s=0,a){case 3:s^=(255&t.charCodeAt(u+2))<<16;case 2:s^=(255&t.charCodeAt(u+1))<<8;case 1:s^=255&t.charCodeAt(u),s=4294967295&(65535&s)*h+((65535&(s>>>16)*h)<<16),s=s<<15|s>>>17,s=4294967295&(65535&s)*i+((65535&(s>>>16)*i)<<16),n^=s}return n^=t.length,n^=n>>>16,n=4294967295&2246822507*(65535&n)+((65535&2246822507*(n>>>16))<<16),n^=n>>>13,n=4294967295&3266489909*(65535&n)+((65535&3266489909*(n>>>16))<<16),n^=n>>>16,n>>>0},hasLocalStorage:function(){try{return!!t.localStorage}catch(r){return!0}}},t.Fingerprint=r}(window);
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);
@@ -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.3.2"
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.3.2
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-08-11 00:00:00.000000000 Z
12
+ date: 2013-09-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: fingerprintjs for rails asset pipeline
15
15
  email: