@thumbmarkjs/thumbmarkjs
Advanced tools
Comparing version 0.12.1 to 0.12.2
@@ -6,2 +6,3 @@ "use strict"; | ||
var commonPixels_1 = require("../../utils/commonPixels"); | ||
var browser_1 = require("../system/browser"); | ||
/** | ||
@@ -26,3 +27,4 @@ * A simple canvas finger printing function | ||
resolve({ | ||
'commonImageDataHash': (0, hash_1.hash)(commonImageData.data.toString()).toString() | ||
'commonImageDataHash': (0, hash_1.hash)(commonImageData.data.toString()).toString(), | ||
'dataURL': imageDataToDataURL(commonImageData), | ||
}); | ||
@@ -32,2 +34,13 @@ }); | ||
exports.default = generateCanvasFingerprint; | ||
function imageDataToDataURL(imageData) { | ||
var canvas = document.createElement('canvas'); | ||
var context = canvas.getContext('2d'); | ||
if (!context) { | ||
throw new Error('Canvas context not supported'); | ||
} | ||
canvas.width = imageData.width; | ||
canvas.height = imageData.height; | ||
context.putImageData(imageData, 0, 0); | ||
return canvas.toDataURL(); | ||
} | ||
function generateCanvasImageData() { | ||
@@ -73,3 +86,4 @@ var canvas = document.createElement('canvas'); | ||
} | ||
(0, factory_1.includeComponent)('canvas', generateCanvasFingerprint); | ||
if ((0, browser_1.getBrowser)().name != 'Firefox') | ||
(0, factory_1.includeComponent)('canvas', generateCanvasFingerprint); | ||
//# sourceMappingURL=canvas.js.map |
{ | ||
"name": "@thumbmarkjs/thumbmarkjs", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -56,2 +56,4 @@ # ThumbmarkJS | ||
:warning: note, thumbmarkjs was published up to version 0.12.1 to NPM package `thumbmarkjs` and from v0.12.1 onwards will be published under `@thumbmarkjs/thumbmarkjs`. I'll occasionally update the old location, but please update your imports. | ||
But bear in mind that the library is meant to be running in the browser. Let me know if the library fails on a server side import. However, `getFingerprint()` is not meant to be called server side. | ||
@@ -58,0 +60,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
98
0
100765
66
1438