aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-06-10 14:53:31 +0200
committerWojtek Kosior <koszko@koszko.org>2022-06-10 14:53:31 +0200
commit051d2472407c1dc1e6c2b88a00be04fe77da8919 (patch)
treedaec6d822a65d9e9747a69a692fd608419cc8e0a /common
parentf8dedf60638bffde3f92116db3f418d2e6260e80 (diff)
parentd9441412a6052e5fb057d01b745208070f8bdfd4 (diff)
downloadbrowser-extension-051d2472407c1dc1e6c2b88a00be04fe77da8919.tar.gz
browser-extension-051d2472407c1dc1e6c2b88a00be04fe77da8919.zip
merge support for CORS bypassing and eval()
Diffstat (limited to 'common')
-rw-r--r--common/patterns.js2
-rw-r--r--common/sha256.js32
2 files changed, 2 insertions, 32 deletions
diff --git a/common/patterns.js b/common/patterns.js
index 9e9d387..7381cdd 100644
--- a/common/patterns.js
+++ b/common/patterns.js
@@ -192,7 +192,7 @@ const patterns_doc_url =
function reconstruct_url(deco)
{
- const domain = deco.domain.join(".");
+ const domain = (deco.domain || []).join(".");
const path = ["", ...deco.path].join("/");
const trail = deco.trailing_slash ? "/" : "";
return `${deco.proto}://${domain}${path}${trail}`;
diff --git a/common/sha256.js b/common/sha256.js
index 5149f97..13c8c7c 100644
--- a/common/sha256.js
+++ b/common/sha256.js
@@ -36,10 +36,7 @@ if (root.JS_SHA256_NO_WINDOW) {
WINDOW = false;
}
var WEB_WORKER = !WINDOW && typeof self === 'object';
-var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
-if (NODE_JS) {
- root = global;
-} else if (WEB_WORKER) {
+if (WEB_WORKER) {
root = self;
}
var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && typeof module === 'object' && module.exports;
@@ -82,9 +79,6 @@ var createOutputMethod = function (outputType, is224) {
var createMethod = function (is224) {
var method = createOutputMethod('hex', is224);
- if (NODE_JS) {
- method = nodeWrap(method, is224);
- }
method.create = function () {
return new Sha256(is224);
};
@@ -98,30 +92,6 @@ var createMethod = function (is224) {
return method;
};
-var nodeWrap = function (method, is224) {
- var crypto = eval("require('crypto')");
- var Buffer = eval("require('buffer').Buffer");
- var algorithm = is224 ? 'sha224' : 'sha256';
- var nodeMethod = function (message) {
- if (typeof message === 'string') {
- return crypto.createHash(algorithm).update(message, 'utf8').digest('hex');
- } else {
- if (message === null || message === undefined) {
- throw new Error(ERROR);
- } else if (message.constructor === ArrayBuffer) {
- message = new Uint8Array(message);
- }
- }
- if (Array.isArray(message) || ArrayBuffer.isView(message) ||
- message.constructor === Buffer) {
- return crypto.createHash(algorithm).update(new Buffer(message)).digest('hex');
- } else {
- return method(message);
- }
- };
- return nodeMethod;
-};
-
var createHmacOutputMethod = function (outputType, is224) {
return function (key, message) {
return new HmacSha256(key, is224, true).update(message)[outputType]();