@jspm/core
Version:
This package contains the core libraries used in jspm 2.
1,418 lines (1,377 loc) • 3.66 MB
JavaScript
import { d as dew$3H, e as exports$3J } from './chunk-CcCWfKp1.js';
import { p as process } from './chunk-DEMDiNwt.js';
import { d as dew$3I } from './chunk-CkFCi-G1.js';
import { e as exports$3I } from './chunk-B6-G-Ftj.js';
import { d as dew$3J } from './chunk-DtuTasat.js';
import { e as e$1$2, a as e$1$1$1, u as u$q, b as buffer, d as dew$f$4 } from './chunk-B738Er4n.js';
import { p as process$1 } from './chunk-b0rmRow7.js';
import { d as dew$3K } from './chunk-C4rKjYLo.js';
import { y as y$o } from './chunk-tHuMsdT0.js';
import { p as promisify, X as X$5, t as t$2$2, T as T$9 } from './chunk-D3uu3VYh.js';
import './chunk-DtDiafJB.js';
import './chunk-CbQqNoLO.js';
import { d as dew$3L } from './chunk-BsRZ0PEC.js';
import exports$3K from './vm.js';
var exports$3H = {},
_dewExec$3G = false;
var _global$1e = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
function dew$3G() {
if (_dewExec$3G) return exports$3H;
_dewExec$3G = true;
var process$1 = process;
// limit of Crypto.getRandomValues()
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
var MAX_BYTES = 65536;
// Node supports requesting up to this number of bytes
// https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
var MAX_UINT32 = 4294967295;
function oldBrowser() {
throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11");
}
var Buffer = dew$3H().Buffer;
var crypto = _global$1e.crypto || _global$1e.msCrypto;
if (crypto && crypto.getRandomValues) {
exports$3H = randomBytes;
} else {
exports$3H = oldBrowser;
}
function randomBytes(size, cb) {
// phantomjs needs to throw
if (size > MAX_UINT32) throw new RangeError("requested too many random bytes");
var bytes = Buffer.allocUnsafe(size);
if (size > 0) {
// getRandomValues fails on IE if size == 0
if (size > MAX_BYTES) {
// this is the max bytes crypto.getRandomValues
// can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
for (var generated = 0; generated < size; generated += MAX_BYTES) {
// buffer.slice automatically checks if the end is past the end of
// the buffer so we don't have to here
crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
}
} else {
crypto.getRandomValues(bytes);
}
}
if (typeof cb === "function") {
return process$1.nextTick(function () {
cb(null, bytes);
});
}
return bytes;
}
return exports$3H;
}
var exports$3G = {},
_dewExec$3F = false;
function dew$3F() {
if (_dewExec$3F) return exports$3G;
_dewExec$3F = true;
var Buffer = dew$3H().Buffer;
var Transform = exports$3I.Transform;
var inherits = dew$3I();
function throwIfNotStringOrBuffer(val, prefix) {
if (!Buffer.isBuffer(val) && typeof val !== "string") {
throw new TypeError(prefix + " must be a string or a buffer");
}
}
function HashBase(blockSize) {
Transform.call(this);
this._block = Buffer.allocUnsafe(blockSize);
this._blockSize = blockSize;
this._blockOffset = 0;
this._length = [0, 0, 0, 0];
this._finalized = false;
}
inherits(HashBase, Transform);
HashBase.prototype._transform = function (chunk, encoding, callback) {
var error = null;
try {
this.update(chunk, encoding);
} catch (err) {
error = err;
}
callback(error);
};
HashBase.prototype._flush = function (callback) {
var error = null;
try {
this.push(this.digest());
} catch (err) {
error = err;
}
callback(error);
};
HashBase.prototype.update = function (data, encoding) {
throwIfNotStringOrBuffer(data, "Data");
if (this._finalized) throw new Error("Digest already called");
if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding);
// consume data
var block = this._block;
var offset = 0;
while (this._blockOffset + data.length - offset >= this._blockSize) {
for (var i = this._blockOffset; i < this._blockSize;) block[i++] = data[offset++];
this._update();
this._blockOffset = 0;
}
while (offset < data.length) block[this._blockOffset++] = data[offset++];
// update length
for (var j = 0, carry = data.length * 8; carry > 0; ++j) {
this._length[j] += carry;
carry = this._length[j] / 4294967296 | 0;
if (carry > 0) this._length[j] -= 4294967296 * carry;
}
return this;
};
HashBase.prototype._update = function () {
throw new Error("_update is not implemented");
};
HashBase.prototype.digest = function (encoding) {
if (this._finalized) throw new Error("Digest already called");
this._finalized = true;
var digest = this._digest();
if (encoding !== undefined) digest = digest.toString(encoding);
// reset state
this._block.fill(0);
this._blockOffset = 0;
for (var i = 0; i < 4; ++i) this._length[i] = 0;
return digest;
};
HashBase.prototype._digest = function () {
throw new Error("_digest is not implemented");
};
exports$3G = HashBase;
return exports$3G;
}
var exports$3F = {},
_dewExec$3E = false;
function dew$3E() {
if (_dewExec$3E) return exports$3F;
_dewExec$3E = true;
var inherits = dew$3I();
var HashBase = dew$3F();
var Buffer = dew$3H().Buffer;
var ARRAY16 = new Array(16);
function MD5() {
HashBase.call(this, 64);
// state
this._a = 1732584193;
this._b = 4023233417;
this._c = 2562383102;
this._d = 271733878;
}
inherits(MD5, HashBase);
MD5.prototype._update = function () {
var M = ARRAY16;
for (var i = 0; i < 16; ++i) M[i] = this._block.readInt32LE(i * 4);
var a = this._a;
var b = this._b;
var c = this._c;
var d = this._d;
a = fnF(a, b, c, d, M[0], 3614090360, 7);
d = fnF(d, a, b, c, M[1], 3905402710, 12);
c = fnF(c, d, a, b, M[2], 606105819, 17);
b = fnF(b, c, d, a, M[3], 3250441966, 22);
a = fnF(a, b, c, d, M[4], 4118548399, 7);
d = fnF(d, a, b, c, M[5], 1200080426, 12);
c = fnF(c, d, a, b, M[6], 2821735955, 17);
b = fnF(b, c, d, a, M[7], 4249261313, 22);
a = fnF(a, b, c, d, M[8], 1770035416, 7);
d = fnF(d, a, b, c, M[9], 2336552879, 12);
c = fnF(c, d, a, b, M[10], 4294925233, 17);
b = fnF(b, c, d, a, M[11], 2304563134, 22);
a = fnF(a, b, c, d, M[12], 1804603682, 7);
d = fnF(d, a, b, c, M[13], 4254626195, 12);
c = fnF(c, d, a, b, M[14], 2792965006, 17);
b = fnF(b, c, d, a, M[15], 1236535329, 22);
a = fnG(a, b, c, d, M[1], 4129170786, 5);
d = fnG(d, a, b, c, M[6], 3225465664, 9);
c = fnG(c, d, a, b, M[11], 643717713, 14);
b = fnG(b, c, d, a, M[0], 3921069994, 20);
a = fnG(a, b, c, d, M[5], 3593408605, 5);
d = fnG(d, a, b, c, M[10], 38016083, 9);
c = fnG(c, d, a, b, M[15], 3634488961, 14);
b = fnG(b, c, d, a, M[4], 3889429448, 20);
a = fnG(a, b, c, d, M[9], 568446438, 5);
d = fnG(d, a, b, c, M[14], 3275163606, 9);
c = fnG(c, d, a, b, M[3], 4107603335, 14);
b = fnG(b, c, d, a, M[8], 1163531501, 20);
a = fnG(a, b, c, d, M[13], 2850285829, 5);
d = fnG(d, a, b, c, M[2], 4243563512, 9);
c = fnG(c, d, a, b, M[7], 1735328473, 14);
b = fnG(b, c, d, a, M[12], 2368359562, 20);
a = fnH(a, b, c, d, M[5], 4294588738, 4);
d = fnH(d, a, b, c, M[8], 2272392833, 11);
c = fnH(c, d, a, b, M[11], 1839030562, 16);
b = fnH(b, c, d, a, M[14], 4259657740, 23);
a = fnH(a, b, c, d, M[1], 2763975236, 4);
d = fnH(d, a, b, c, M[4], 1272893353, 11);
c = fnH(c, d, a, b, M[7], 4139469664, 16);
b = fnH(b, c, d, a, M[10], 3200236656, 23);
a = fnH(a, b, c, d, M[13], 681279174, 4);
d = fnH(d, a, b, c, M[0], 3936430074, 11);
c = fnH(c, d, a, b, M[3], 3572445317, 16);
b = fnH(b, c, d, a, M[6], 76029189, 23);
a = fnH(a, b, c, d, M[9], 3654602809, 4);
d = fnH(d, a, b, c, M[12], 3873151461, 11);
c = fnH(c, d, a, b, M[15], 530742520, 16);
b = fnH(b, c, d, a, M[2], 3299628645, 23);
a = fnI(a, b, c, d, M[0], 4096336452, 6);
d = fnI(d, a, b, c, M[7], 1126891415, 10);
c = fnI(c, d, a, b, M[14], 2878612391, 15);
b = fnI(b, c, d, a, M[5], 4237533241, 21);
a = fnI(a, b, c, d, M[12], 1700485571, 6);
d = fnI(d, a, b, c, M[3], 2399980690, 10);
c = fnI(c, d, a, b, M[10], 4293915773, 15);
b = fnI(b, c, d, a, M[1], 2240044497, 21);
a = fnI(a, b, c, d, M[8], 1873313359, 6);
d = fnI(d, a, b, c, M[15], 4264355552, 10);
c = fnI(c, d, a, b, M[6], 2734768916, 15);
b = fnI(b, c, d, a, M[13], 1309151649, 21);
a = fnI(a, b, c, d, M[4], 4149444226, 6);
d = fnI(d, a, b, c, M[11], 3174756917, 10);
c = fnI(c, d, a, b, M[2], 718787259, 15);
b = fnI(b, c, d, a, M[9], 3951481745, 21);
this._a = this._a + a | 0;
this._b = this._b + b | 0;
this._c = this._c + c | 0;
this._d = this._d + d | 0;
};
MD5.prototype._digest = function () {
// create padding and handle blocks
this._block[this._blockOffset++] = 128;
if (this._blockOffset > 56) {
this._block.fill(0, this._blockOffset, 64);
this._update();
this._blockOffset = 0;
}
this._block.fill(0, this._blockOffset, 56);
this._block.writeUInt32LE(this._length[0], 56);
this._block.writeUInt32LE(this._length[1], 60);
this._update();
// produce result
var buffer = Buffer.allocUnsafe(16);
buffer.writeInt32LE(this._a, 0);
buffer.writeInt32LE(this._b, 4);
buffer.writeInt32LE(this._c, 8);
buffer.writeInt32LE(this._d, 12);
return buffer;
};
function rotl(x, n) {
return x << n | x >>> 32 - n;
}
function fnF(a, b, c, d, m, k, s) {
return rotl(a + (b & c | ~b & d) + m + k | 0, s) + b | 0;
}
function fnG(a, b, c, d, m, k, s) {
return rotl(a + (b & d | c & ~d) + m + k | 0, s) + b | 0;
}
function fnH(a, b, c, d, m, k, s) {
return rotl(a + (b ^ c ^ d) + m + k | 0, s) + b | 0;
}
function fnI(a, b, c, d, m, k, s) {
return rotl(a + (c ^ (b | ~d)) + m + k | 0, s) + b | 0;
}
exports$3F = MD5;
return exports$3F;
}
var exports$3E = {},
_dewExec$3D = false;
function dew$3D() {
if (_dewExec$3D) return exports$3E;
_dewExec$3D = true;
var Buffer = dew$3J().Buffer;
var inherits = dew$3I();
var HashBase = dew$3F();
var ARRAY16 = new Array(16);
var zl = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13];
var zr = [5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11];
var sl = [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6];
var sr = [8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11];
var hl = [0, 1518500249, 1859775393, 2400959708, 2840853838];
var hr = [1352829926, 1548603684, 1836072691, 2053994217, 0];
function RIPEMD160() {
HashBase.call(this, 64);
// state
this._a = 1732584193;
this._b = 4023233417;
this._c = 2562383102;
this._d = 271733878;
this._e = 3285377520;
}
inherits(RIPEMD160, HashBase);
RIPEMD160.prototype._update = function () {
var words = ARRAY16;
for (var j = 0; j < 16; ++j) words[j] = this._block.readInt32LE(j * 4);
var al = this._a | 0;
var bl = this._b | 0;
var cl = this._c | 0;
var dl = this._d | 0;
var el = this._e | 0;
var ar = this._a | 0;
var br = this._b | 0;
var cr = this._c | 0;
var dr = this._d | 0;
var er = this._e | 0;
// computation
for (var i = 0; i < 80; i += 1) {
var tl;
var tr;
if (i < 16) {
tl = fn1(al, bl, cl, dl, el, words[zl[i]], hl[0], sl[i]);
tr = fn5(ar, br, cr, dr, er, words[zr[i]], hr[0], sr[i]);
} else if (i < 32) {
tl = fn2(al, bl, cl, dl, el, words[zl[i]], hl[1], sl[i]);
tr = fn4(ar, br, cr, dr, er, words[zr[i]], hr[1], sr[i]);
} else if (i < 48) {
tl = fn3(al, bl, cl, dl, el, words[zl[i]], hl[2], sl[i]);
tr = fn3(ar, br, cr, dr, er, words[zr[i]], hr[2], sr[i]);
} else if (i < 64) {
tl = fn4(al, bl, cl, dl, el, words[zl[i]], hl[3], sl[i]);
tr = fn2(ar, br, cr, dr, er, words[zr[i]], hr[3], sr[i]);
} else {
// if (i<80) {
tl = fn5(al, bl, cl, dl, el, words[zl[i]], hl[4], sl[i]);
tr = fn1(ar, br, cr, dr, er, words[zr[i]], hr[4], sr[i]);
}
al = el;
el = dl;
dl = rotl(cl, 10);
cl = bl;
bl = tl;
ar = er;
er = dr;
dr = rotl(cr, 10);
cr = br;
br = tr;
}
// update state
var t = this._b + cl + dr | 0;
this._b = this._c + dl + er | 0;
this._c = this._d + el + ar | 0;
this._d = this._e + al + br | 0;
this._e = this._a + bl + cr | 0;
this._a = t;
};
RIPEMD160.prototype._digest = function () {
// create padding and handle blocks
this._block[this._blockOffset++] = 128;
if (this._blockOffset > 56) {
this._block.fill(0, this._blockOffset, 64);
this._update();
this._blockOffset = 0;
}
this._block.fill(0, this._blockOffset, 56);
this._block.writeUInt32LE(this._length[0], 56);
this._block.writeUInt32LE(this._length[1], 60);
this._update();
// produce result
var buffer = Buffer.alloc ? Buffer.alloc(20) : new Buffer(20);
buffer.writeInt32LE(this._a, 0);
buffer.writeInt32LE(this._b, 4);
buffer.writeInt32LE(this._c, 8);
buffer.writeInt32LE(this._d, 12);
buffer.writeInt32LE(this._e, 16);
return buffer;
};
function rotl(x, n) {
return x << n | x >>> 32 - n;
}
function fn1(a, b, c, d, e, m, k, s) {
return rotl(a + (b ^ c ^ d) + m + k | 0, s) + e | 0;
}
function fn2(a, b, c, d, e, m, k, s) {
return rotl(a + (b & c | ~b & d) + m + k | 0, s) + e | 0;
}
function fn3(a, b, c, d, e, m, k, s) {
return rotl(a + ((b | ~c) ^ d) + m + k | 0, s) + e | 0;
}
function fn4(a, b, c, d, e, m, k, s) {
return rotl(a + (b & d | c & ~d) + m + k | 0, s) + e | 0;
}
function fn5(a, b, c, d, e, m, k, s) {
return rotl(a + (b ^ (c | ~d)) + m + k | 0, s) + e | 0;
}
exports$3E = RIPEMD160;
return exports$3E;
}
var exports$3D = {},
_dewExec$3C = false;
var _global$1d = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
function dew$3C() {
if (_dewExec$3C) return exports$3D;
_dewExec$3C = true;
var Buffer = dew$3H().Buffer;
// prototype class for hash functions
function Hash(blockSize, finalSize) {
(this || _global$1d)._block = Buffer.alloc(blockSize);
(this || _global$1d)._finalSize = finalSize;
(this || _global$1d)._blockSize = blockSize;
(this || _global$1d)._len = 0;
}
Hash.prototype.update = function (data, enc) {
if (typeof data === "string") {
enc = enc || "utf8";
data = Buffer.from(data, enc);
}
var block = (this || _global$1d)._block;
var blockSize = (this || _global$1d)._blockSize;
var length = data.length;
var accum = (this || _global$1d)._len;
for (var offset = 0; offset < length;) {
var assigned = accum % blockSize;
var remainder = Math.min(length - offset, blockSize - assigned);
for (var i = 0; i < remainder; i++) {
block[assigned + i] = data[offset + i];
}
accum += remainder;
offset += remainder;
if (accum % blockSize === 0) {
this._update(block);
}
}
(this || _global$1d)._len += length;
return this || _global$1d;
};
Hash.prototype.digest = function (enc) {
var rem = (this || _global$1d)._len % (this || _global$1d)._blockSize;
(this || _global$1d)._block[rem] = 128;
// zero (rem + 1) trailing bits, where (rem + 1) is the smallest
// non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
(this || _global$1d)._block.fill(0, rem + 1);
if (rem >= (this || _global$1d)._finalSize) {
this._update((this || _global$1d)._block);
(this || _global$1d)._block.fill(0);
}
var bits = (this || _global$1d)._len * 8;
// uint32
if (bits <= 4294967295) {
(this || _global$1d)._block.writeUInt32BE(bits, (this || _global$1d)._blockSize - 4);
// uint64
} else {
var lowBits = (bits & 4294967295) >>> 0;
var highBits = (bits - lowBits) / 4294967296;
(this || _global$1d)._block.writeUInt32BE(highBits, (this || _global$1d)._blockSize - 8);
(this || _global$1d)._block.writeUInt32BE(lowBits, (this || _global$1d)._blockSize - 4);
}
this._update((this || _global$1d)._block);
var hash = this._hash();
return enc ? hash.toString(enc) : hash;
};
Hash.prototype._update = function () {
throw new Error("_update must be implemented by subclass");
};
exports$3D = Hash;
return exports$3D;
}
var exports$3C = {},
_dewExec$3B = false;
var _global$1c = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
function dew$3B() {
if (_dewExec$3B) return exports$3C;
_dewExec$3B = true;
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined
* in FIPS PUB 180-1
* This source code is derived from sha1.js of the same repository.
* The difference between SHA-0 and SHA-1 is just a bitwise rotate left
* operation was added.
*/
var inherits = dew$3I();
var Hash = dew$3C();
var Buffer = dew$3H().Buffer;
var K = [1518500249, 1859775393, 2400959708 | 0, 3395469782 | 0];
var W = new Array(80);
function Sha() {
this.init();
(this || _global$1c)._w = W;
Hash.call(this || _global$1c, 64, 56);
}
inherits(Sha, Hash);
Sha.prototype.init = function () {
(this || _global$1c)._a = 1732584193;
(this || _global$1c)._b = 4023233417;
(this || _global$1c)._c = 2562383102;
(this || _global$1c)._d = 271733878;
(this || _global$1c)._e = 3285377520;
return this || _global$1c;
};
function rotl5(num) {
return num << 5 | num >>> 27;
}
function rotl30(num) {
return num << 30 | num >>> 2;
}
function ft(s, b, c, d) {
if (s === 0) return b & c | ~b & d;
if (s === 2) return b & c | b & d | c & d;
return b ^ c ^ d;
}
Sha.prototype._update = function (M) {
var W = (this || _global$1c)._w;
var a = (this || _global$1c)._a | 0;
var b = (this || _global$1c)._b | 0;
var c = (this || _global$1c)._c | 0;
var d = (this || _global$1c)._d | 0;
var e = (this || _global$1c)._e | 0;
for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4);
for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
for (var j = 0; j < 80; ++j) {
var s = ~~(j / 20);
var t = rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s] | 0;
e = d;
d = c;
c = rotl30(b);
b = a;
a = t;
}
(this || _global$1c)._a = a + (this || _global$1c)._a | 0;
(this || _global$1c)._b = b + (this || _global$1c)._b | 0;
(this || _global$1c)._c = c + (this || _global$1c)._c | 0;
(this || _global$1c)._d = d + (this || _global$1c)._d | 0;
(this || _global$1c)._e = e + (this || _global$1c)._e | 0;
};
Sha.prototype._hash = function () {
var H = Buffer.allocUnsafe(20);
H.writeInt32BE((this || _global$1c)._a | 0, 0);
H.writeInt32BE((this || _global$1c)._b | 0, 4);
H.writeInt32BE((this || _global$1c)._c | 0, 8);
H.writeInt32BE((this || _global$1c)._d | 0, 12);
H.writeInt32BE((this || _global$1c)._e | 0, 16);
return H;
};
exports$3C = Sha;
return exports$3C;
}
var exports$3B = {},
_dewExec$3A = false;
var _global$1b = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
function dew$3A() {
if (_dewExec$3A) return exports$3B;
_dewExec$3A = true;
/*
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
* in FIPS PUB 180-1
* Version 2.1a Copyright Paul Johnston 2000 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for details.
*/
var inherits = dew$3I();
var Hash = dew$3C();
var Buffer = dew$3H().Buffer;
var K = [1518500249, 1859775393, 2400959708 | 0, 3395469782 | 0];
var W = new Array(80);
function Sha1() {
this.init();
(this || _global$1b)._w = W;
Hash.call(this || _global$1b, 64, 56);
}
inherits(Sha1, Hash);
Sha1.prototype.init = function () {
(this || _global$1b)._a = 1732584193;
(this || _global$1b)._b = 4023233417;
(this || _global$1b)._c = 2562383102;
(this || _global$1b)._d = 271733878;
(this || _global$1b)._e = 3285377520;
return this || _global$1b;
};
function rotl1(num) {
return num << 1 | num >>> 31;
}
function rotl5(num) {
return num << 5 | num >>> 27;
}
function rotl30(num) {
return num << 30 | num >>> 2;
}
function ft(s, b, c, d) {
if (s === 0) return b & c | ~b & d;
if (s === 2) return b & c | b & d | c & d;
return b ^ c ^ d;
}
Sha1.prototype._update = function (M) {
var W = (this || _global$1b)._w;
var a = (this || _global$1b)._a | 0;
var b = (this || _global$1b)._b | 0;
var c = (this || _global$1b)._c | 0;
var d = (this || _global$1b)._d | 0;
var e = (this || _global$1b)._e | 0;
for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4);
for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]);
for (var j = 0; j < 80; ++j) {
var s = ~~(j / 20);
var t = rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s] | 0;
e = d;
d = c;
c = rotl30(b);
b = a;
a = t;
}
(this || _global$1b)._a = a + (this || _global$1b)._a | 0;
(this || _global$1b)._b = b + (this || _global$1b)._b | 0;
(this || _global$1b)._c = c + (this || _global$1b)._c | 0;
(this || _global$1b)._d = d + (this || _global$1b)._d | 0;
(this || _global$1b)._e = e + (this || _global$1b)._e | 0;
};
Sha1.prototype._hash = function () {
var H = Buffer.allocUnsafe(20);
H.writeInt32BE((this || _global$1b)._a | 0, 0);
H.writeInt32BE((this || _global$1b)._b | 0, 4);
H.writeInt32BE((this || _global$1b)._c | 0, 8);
H.writeInt32BE((this || _global$1b)._d | 0, 12);
H.writeInt32BE((this || _global$1b)._e | 0, 16);
return H;
};
exports$3B = Sha1;
return exports$3B;
}
var exports$3A = {},
_dewExec$3z = false;
var _global$1a = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
function dew$3z() {
if (_dewExec$3z) return exports$3A;
_dewExec$3z = true;
/**
* A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
* in FIPS 180-2
* Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
*
*/
var inherits = dew$3I();
var Hash = dew$3C();
var Buffer = dew$3H().Buffer;
var K = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298];
var W = new Array(64);
function Sha256() {
this.init();
(this || _global$1a)._w = W; // new Array(64)
Hash.call(this || _global$1a, 64, 56);
}
inherits(Sha256, Hash);
Sha256.prototype.init = function () {
(this || _global$1a)._a = 1779033703;
(this || _global$1a)._b = 3144134277;
(this || _global$1a)._c = 1013904242;
(this || _global$1a)._d = 2773480762;
(this || _global$1a)._e = 1359893119;
(this || _global$1a)._f = 2600822924;
(this || _global$1a)._g = 528734635;
(this || _global$1a)._h = 1541459225;
return this || _global$1a;
};
function ch(x, y, z) {
return z ^ x & (y ^ z);
}
function maj(x, y, z) {
return x & y | z & (x | y);
}
function sigma0(x) {
return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10);
}
function sigma1(x) {
return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7);
}
function gamma0(x) {
return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ x >>> 3;
}
function gamma1(x) {
return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ x >>> 10;
}
Sha256.prototype._update = function (M) {
var W = (this || _global$1a)._w;
var a = (this || _global$1a)._a | 0;
var b = (this || _global$1a)._b | 0;
var c = (this || _global$1a)._c | 0;
var d = (this || _global$1a)._d | 0;
var e = (this || _global$1a)._e | 0;
var f = (this || _global$1a)._f | 0;
var g = (this || _global$1a)._g | 0;
var h = (this || _global$1a)._h | 0;
for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4);
for (; i < 64; ++i) W[i] = gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16] | 0;
for (var j = 0; j < 64; ++j) {
var T1 = h + sigma1(e) + ch(e, f, g) + K[j] + W[j] | 0;
var T2 = sigma0(a) + maj(a, b, c) | 0;
h = g;
g = f;
f = e;
e = d + T1 | 0;
d = c;
c = b;
b = a;
a = T1 + T2 | 0;
}
(this || _global$1a)._a = a + (this || _global$1a)._a | 0;
(this || _global$1a)._b = b + (this || _global$1a)._b | 0;
(this || _global$1a)._c = c + (this || _global$1a)._c | 0;
(this || _global$1a)._d = d + (this || _global$1a)._d | 0;
(this || _global$1a)._e = e + (this || _global$1a)._e | 0;
(this || _global$1a)._f = f + (this || _global$1a)._f | 0;
(this || _global$1a)._g = g + (this || _global$1a)._g | 0;
(this || _global$1a)._h = h + (this || _global$1a)._h | 0;
};
Sha256.prototype._hash = function () {
var H = Buffer.allocUnsafe(32);
H.writeInt32BE((this || _global$1a)._a, 0);
H.writeInt32BE((this || _global$1a)._b, 4);
H.writeInt32BE((this || _global$1a)._c, 8);
H.writeInt32BE((this || _global$1a)._d, 12);
H.writeInt32BE((this || _global$1a)._e, 16);
H.writeInt32BE((this || _global$1a)._f, 20);
H.writeInt32BE((this || _global$1a)._g, 24);
H.writeInt32BE((this || _global$1a)._h, 28);
return H;
};
exports$3A = Sha256;
return exports$3A;
}
var exports$3z = {},
_dewExec$3y = false;
var _global$19 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
function dew$3y() {
if (_dewExec$3y) return exports$3z;
_dewExec$3y = true;
/**
* A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
* in FIPS 180-2
* Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
*
*/
var inherits = dew$3I();
var Sha256 = dew$3z();
var Hash = dew$3C();
var Buffer = dew$3H().Buffer;
var W = new Array(64);
function Sha224() {
this.init();
(this || _global$19)._w = W; // new Array(64)
Hash.call(this || _global$19, 64, 56);
}
inherits(Sha224, Sha256);
Sha224.prototype.init = function () {
(this || _global$19)._a = 3238371032;
(this || _global$19)._b = 914150663;
(this || _global$19)._c = 812702999;
(this || _global$19)._d = 4144912697;
(this || _global$19)._e = 4290775857;
(this || _global$19)._f = 1750603025;
(this || _global$19)._g = 1694076839;
(this || _global$19)._h = 3204075428;
return this || _global$19;
};
Sha224.prototype._hash = function () {
var H = Buffer.allocUnsafe(28);
H.writeInt32BE((this || _global$19)._a, 0);
H.writeInt32BE((this || _global$19)._b, 4);
H.writeInt32BE((this || _global$19)._c, 8);
H.writeInt32BE((this || _global$19)._d, 12);
H.writeInt32BE((this || _global$19)._e, 16);
H.writeInt32BE((this || _global$19)._f, 20);
H.writeInt32BE((this || _global$19)._g, 24);
return H;
};
exports$3z = Sha224;
return exports$3z;
}
var exports$3y = {},
_dewExec$3x = false;
var _global$18 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
function dew$3x() {
if (_dewExec$3x) return exports$3y;
_dewExec$3x = true;
var inherits = dew$3I();
var Hash = dew$3C();
var Buffer = dew$3H().Buffer;
var K = [1116352408, 3609767458, 1899447441, 602891725, 3049323471, 3964484399, 3921009573, 2173295548, 961987163, 4081628472, 1508970993, 3053834265, 2453635748, 2937671579, 2870763221, 3664609560, 3624381080, 2734883394, 310598401, 1164996542, 607225278, 1323610764, 1426881987, 3590304994, 1925078388, 4068182383, 2162078206, 991336113, 2614888103, 633803317, 3248222580, 3479774868, 3835390401, 2666613458, 4022224774, 944711139, 264347078, 2341262773, 604807628, 2007800933, 770255983, 1495990901, 1249150122, 1856431235, 1555081692, 3175218132, 1996064986, 2198950837, 2554220882, 3999719339, 2821834349, 766784016, 2952996808, 2566594879, 3210313671, 3203337956, 3336571891, 1034457026, 3584528711, 2466948901, 113926993, 3758326383, 338241895, 168717936, 666307205, 1188179964, 773529912, 1546045734, 1294757372, 1522805485, 1396182291, 2643833823, 1695183700, 2343527390, 1986661051, 1014477480, 2177026350, 1206759142, 2456956037, 344077627, 2730485921, 1290863460, 2820302411, 3158454273, 3259730800, 3505952657, 3345764771, 106217008, 3516065817, 3606008344, 3600352804, 1432725776, 4094571909, 1467031594, 275423344, 851169720, 430227734, 3100823752, 506948616, 1363258195, 659060556, 3750685593, 883997877, 3785050280, 958139571, 3318307427, 1322822218, 3812723403, 1537002063, 2003034995, 1747873779, 3602036899, 1955562222, 1575990012, 2024104815, 1125592928, 2227730452, 2716904306, 2361852424, 442776044, 2428436474, 593698344, 2756734187, 3733110249, 3204031479, 2999351573, 3329325298, 3815920427, 3391569614, 3928383900, 3515267271, 566280711, 3940187606, 3454069534, 4118630271, 4000239992, 116418474, 1914138554, 174292421, 2731055270, 289380356, 3203993006, 460393269, 320620315, 685471733, 587496836, 852142971, 1086792851, 1017036298, 365543100, 1126000580, 2618297676, 1288033470, 3409855158, 1501505948, 4234509866, 1607167915, 987167468, 1816402316, 1246189591];
var W = new Array(160);
function Sha512() {
this.init();
(this || _global$18)._w = W;
Hash.call(this || _global$18, 128, 112);
}
inherits(Sha512, Hash);
Sha512.prototype.init = function () {
(this || _global$18)._ah = 1779033703;
(this || _global$18)._bh = 3144134277;
(this || _global$18)._ch = 1013904242;
(this || _global$18)._dh = 2773480762;
(this || _global$18)._eh = 1359893119;
(this || _global$18)._fh = 2600822924;
(this || _global$18)._gh = 528734635;
(this || _global$18)._hh = 1541459225;
(this || _global$18)._al = 4089235720;
(this || _global$18)._bl = 2227873595;
(this || _global$18)._cl = 4271175723;
(this || _global$18)._dl = 1595750129;
(this || _global$18)._el = 2917565137;
(this || _global$18)._fl = 725511199;
(this || _global$18)._gl = 4215389547;
(this || _global$18)._hl = 327033209;
return this || _global$18;
};
function Ch(x, y, z) {
return z ^ x & (y ^ z);
}
function maj(x, y, z) {
return x & y | z & (x | y);
}
function sigma0(x, xl) {
return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25);
}
function sigma1(x, xl) {
return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23);
}
function Gamma0(x, xl) {
return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ x >>> 7;
}
function Gamma0l(x, xl) {
return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25);
}
function Gamma1(x, xl) {
return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ x >>> 6;
}
function Gamma1l(x, xl) {
return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26);
}
function getCarry(a, b) {
return a >>> 0 < b >>> 0 ? 1 : 0;
}
Sha512.prototype._update = function (M) {
var W = (this || _global$18)._w;
var ah = (this || _global$18)._ah | 0;
var bh = (this || _global$18)._bh | 0;
var ch = (this || _global$18)._ch | 0;
var dh = (this || _global$18)._dh | 0;
var eh = (this || _global$18)._eh | 0;
var fh = (this || _global$18)._fh | 0;
var gh = (this || _global$18)._gh | 0;
var hh = (this || _global$18)._hh | 0;
var al = (this || _global$18)._al | 0;
var bl = (this || _global$18)._bl | 0;
var cl = (this || _global$18)._cl | 0;
var dl = (this || _global$18)._dl | 0;
var el = (this || _global$18)._el | 0;
var fl = (this || _global$18)._fl | 0;
var gl = (this || _global$18)._gl | 0;
var hl = (this || _global$18)._hl | 0;
for (var i = 0; i < 32; i += 2) {
W[i] = M.readInt32BE(i * 4);
W[i + 1] = M.readInt32BE(i * 4 + 4);
}
for (; i < 160; i += 2) {
var xh = W[i - 15 * 2];
var xl = W[i - 15 * 2 + 1];
var gamma0 = Gamma0(xh, xl);
var gamma0l = Gamma0l(xl, xh);
xh = W[i - 2 * 2];
xl = W[i - 2 * 2 + 1];
var gamma1 = Gamma1(xh, xl);
var gamma1l = Gamma1l(xl, xh);
// W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
var Wi7h = W[i - 7 * 2];
var Wi7l = W[i - 7 * 2 + 1];
var Wi16h = W[i - 16 * 2];
var Wi16l = W[i - 16 * 2 + 1];
var Wil = gamma0l + Wi7l | 0;
var Wih = gamma0 + Wi7h + getCarry(Wil, gamma0l) | 0;
Wil = Wil + gamma1l | 0;
Wih = Wih + gamma1 + getCarry(Wil, gamma1l) | 0;
Wil = Wil + Wi16l | 0;
Wih = Wih + Wi16h + getCarry(Wil, Wi16l) | 0;
W[i] = Wih;
W[i + 1] = Wil;
}
for (var j = 0; j < 160; j += 2) {
Wih = W[j];
Wil = W[j + 1];
var majh = maj(ah, bh, ch);
var majl = maj(al, bl, cl);
var sigma0h = sigma0(ah, al);
var sigma0l = sigma0(al, ah);
var sigma1h = sigma1(eh, el);
var sigma1l = sigma1(el, eh);
// t1 = h + sigma1 + ch + K[j] + W[j]
var Kih = K[j];
var Kil = K[j + 1];
var chh = Ch(eh, fh, gh);
var chl = Ch(el, fl, gl);
var t1l = hl + sigma1l | 0;
var t1h = hh + sigma1h + getCarry(t1l, hl) | 0;
t1l = t1l + chl | 0;
t1h = t1h + chh + getCarry(t1l, chl) | 0;
t1l = t1l + Kil | 0;
t1h = t1h + Kih + getCarry(t1l, Kil) | 0;
t1l = t1l + Wil | 0;
t1h = t1h + Wih + getCarry(t1l, Wil) | 0;
// t2 = sigma0 + maj
var t2l = sigma0l + majl | 0;
var t2h = sigma0h + majh + getCarry(t2l, sigma0l) | 0;
hh = gh;
hl = gl;
gh = fh;
gl = fl;
fh = eh;
fl = el;
el = dl + t1l | 0;
eh = dh + t1h + getCarry(el, dl) | 0;
dh = ch;
dl = cl;
ch = bh;
cl = bl;
bh = ah;
bl = al;
al = t1l + t2l | 0;
ah = t1h + t2h + getCarry(al, t1l) | 0;
}
(this || _global$18)._al = (this || _global$18)._al + al | 0;
(this || _global$18)._bl = (this || _global$18)._bl + bl | 0;
(this || _global$18)._cl = (this || _global$18)._cl + cl | 0;
(this || _global$18)._dl = (this || _global$18)._dl + dl | 0;
(this || _global$18)._el = (this || _global$18)._el + el | 0;
(this || _global$18)._fl = (this || _global$18)._fl + fl | 0;
(this || _global$18)._gl = (this || _global$18)._gl + gl | 0;
(this || _global$18)._hl = (this || _global$18)._hl + hl | 0;
(this || _global$18)._ah = (this || _global$18)._ah + ah + getCarry((this || _global$18)._al, al) | 0;
(this || _global$18)._bh = (this || _global$18)._bh + bh + getCarry((this || _global$18)._bl, bl) | 0;
(this || _global$18)._ch = (this || _global$18)._ch + ch + getCarry((this || _global$18)._cl, cl) | 0;
(this || _global$18)._dh = (this || _global$18)._dh + dh + getCarry((this || _global$18)._dl, dl) | 0;
(this || _global$18)._eh = (this || _global$18)._eh + eh + getCarry((this || _global$18)._el, el) | 0;
(this || _global$18)._fh = (this || _global$18)._fh + fh + getCarry((this || _global$18)._fl, fl) | 0;
(this || _global$18)._gh = (this || _global$18)._gh + gh + getCarry((this || _global$18)._gl, gl) | 0;
(this || _global$18)._hh = (this || _global$18)._hh + hh + getCarry((this || _global$18)._hl, hl) | 0;
};
Sha512.prototype._hash = function () {
var H = Buffer.allocUnsafe(64);
function writeInt64BE(h, l, offset) {
H.writeInt32BE(h, offset);
H.writeInt32BE(l, offset + 4);
}
writeInt64BE((this || _global$18)._ah, (this || _global$18)._al, 0);
writeInt64BE((this || _global$18)._bh, (this || _global$18)._bl, 8);
writeInt64BE((this || _global$18)._ch, (this || _global$18)._cl, 16);
writeInt64BE((this || _global$18)._dh, (this || _global$18)._dl, 24);
writeInt64BE((this || _global$18)._eh, (this || _global$18)._el, 32);
writeInt64BE((this || _global$18)._fh, (this || _global$18)._fl, 40);
writeInt64BE((this || _global$18)._gh, (this || _global$18)._gl, 48);
writeInt64BE((this || _global$18)._hh, (this || _global$18)._hl, 56);
return H;
};
exports$3y = Sha512;
return exports$3y;
}
var exports$3x = {},
_dewExec$3w = false;
var _global$17 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
function dew$3w() {
if (_dewExec$3w) return exports$3x;
_dewExec$3w = true;
var inherits = dew$3I();
var SHA512 = dew$3x();
var Hash = dew$3C();
var Buffer = dew$3H().Buffer;
var W = new Array(160);
function Sha384() {
this.init();
(this || _global$17)._w = W;
Hash.call(this || _global$17, 128, 112);
}
inherits(Sha384, SHA512);
Sha384.prototype.init = function () {
(this || _global$17)._ah = 3418070365;
(this || _global$17)._bh = 1654270250;
(this || _global$17)._ch = 2438529370;
(this || _global$17)._dh = 355462360;
(this || _global$17)._eh = 1731405415;
(this || _global$17)._fh = 2394180231;
(this || _global$17)._gh = 3675008525;
(this || _global$17)._hh = 1203062813;
(this || _global$17)._al = 3238371032;
(this || _global$17)._bl = 914150663;
(this || _global$17)._cl = 812702999;
(this || _global$17)._dl = 4144912697;
(this || _global$17)._el = 4290775857;
(this || _global$17)._fl = 1750603025;
(this || _global$17)._gl = 1694076839;
(this || _global$17)._hl = 3204075428;
return this || _global$17;
};
Sha384.prototype._hash = function () {
var H = Buffer.allocUnsafe(48);
function writeInt64BE(h, l, offset) {
H.writeInt32BE(h, offset);
H.writeInt32BE(l, offset + 4);
}
writeInt64BE((this || _global$17)._ah, (this || _global$17)._al, 0);
writeInt64BE((this || _global$17)._bh, (this || _global$17)._bl, 8);
writeInt64BE((this || _global$17)._ch, (this || _global$17)._cl, 16);
writeInt64BE((this || _global$17)._dh, (this || _global$17)._dl, 24);
writeInt64BE((this || _global$17)._eh, (this || _global$17)._el, 32);
writeInt64BE((this || _global$17)._fh, (this || _global$17)._fl, 40);
return H;
};
exports$3x = Sha384;
return exports$3x;
}
var exports$3w = {},
_dewExec$3v = false;
var module$f = {
exports: exports$3w
};
function dew$3v() {
if (_dewExec$3v) return module$f.exports;
_dewExec$3v = true;
var exports = module$f.exports = function SHA(algorithm) {
algorithm = algorithm.toLowerCase();
var Algorithm = exports[algorithm];
if (!Algorithm) throw new Error(algorithm + " is not supported (we accept pull requests)");
return new Algorithm();
};
exports.sha = dew$3B();
exports.sha1 = dew$3A();
exports.sha224 = dew$3y();
exports.sha256 = dew$3z();
exports.sha384 = dew$3w();
exports.sha512 = dew$3x();
return module$f.exports;
}
var exports$3v = {},
_dewExec$3u = false;
var _global$16 = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : global;
function dew$3u() {
if (_dewExec$3u) return exports$3v;
_dewExec$3u = true;
var Buffer = dew$3H().Buffer;
var Transform = exports$3I.Transform;
var StringDecoder = e$1$2.StringDecoder;
var inherits = dew$3I();
function CipherBase(hashMode) {
Transform.call(this || _global$16);
(this || _global$16).hashMode = typeof hashMode === "string";
if ((this || _global$16).hashMode) {
(this || _global$16)[hashMode] = (this || _global$16)._finalOrDigest;
} else {
(this || _global$16).final = (this || _global$16)._finalOrDigest;
}
if ((this || _global$16)._final) {
(this || _global$16).__final = (this || _global$16)._final;
(this || _global$16)._final = null;
}
(this || _global$16)._decoder = null;
(this || _global$16)._encoding = null;
}
inherits(CipherBase, Transform);
CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
if (typeof data === "string") {
data = Buffer.from(data, inputEnc);
}
var outData = this._update(data);
if ((this || _global$16).hashMode) return this || _global$16;
if (outputEnc) {
outData = this._toString(outData, outputEnc);
}
return outData;
};
CipherBase.prototype.setAutoPadding = function () {};
CipherBase.prototype.getAuthTag = function () {
throw new Error("trying to get auth tag in unsupported state");
};
CipherBase.prototype.setAuthTag = function () {
throw new Error("trying to set auth tag in unsupported state");
};
CipherBase.prototype.setAAD = function () {
throw new Error("trying to set aad in unsupported state");
};
CipherBase.prototype._transform = function (data, _, next) {
var err;
try {
if ((this || _global$16).hashMode) {
this._update(data);
} else {
this.push(this._update(data));
}
} catch (e) {
err = e;
} finally {
next(err);
}
};
CipherBase.prototype._flush = function (done) {
var err;
try {
this.push(this.__final());
} catch (e) {
err = e;
}
done(err);
};
CipherBase.prototype._finalOrDigest = function (outputEnc) {
var outData = this.__final() || Buffer.alloc(0);
if (outputEnc) {
outData = this._toString(outData, outputEnc, true);
}
return outData;
};
CipherBase.prototype._toString = function (value, enc, fin) {
if (!(this || _global$16)._decoder) {
(this || _global$16)._decoder = new StringDecoder(enc);
(this || _global$16)._encoding = enc;
}
if ((this || _global$16)._encoding !== enc) throw new Error("can't switch encodings");
var out = (this || _global$16)._decoder.write(value);
if (fin) {
out += (this || _global$16)._decoder.end();
}
return out;
};
exports$3v = CipherBase;
return exports$3v;
}
var exports$3u = {},
_dewExec$3t = false;
function dew$3t() {
if (_dewExec$3t) return exports$3u;
_dewExec$3t = true;
var inherits = dew$3I();
var MD5 = dew$3E();
var RIPEMD160 = dew$3D();
var sha = dew$3v();
var Base = dew$3u();
function Hash(hash) {
Base.call(this, "digest");
this._hash = hash;
}
inherits(Hash, Base);
Hash.prototype._update = function (data) {
this._hash.update(data);
};
Hash.prototype._final = function () {
return this._hash.digest();
};
exports$3u = function createHash(alg) {
alg = alg.toLowerCase();
if (alg === "md5") return new MD5();
if (alg === "rmd160" || alg === "ripemd160") return new RIPEMD160();
return new Hash(sha(alg));
};
return exports$3u;
}
var exports$3t = {},
_dewExec$3s = false;
function dew$3s() {
if (_dewExec$3s) return exports$3t;
_dewExec$3s = true;
var inherits = dew$3I();
var Buffer = dew$3H().Buffer;
var Base = dew$3u();
var ZEROS = Buffer.alloc(128);
var blocksize = 64;
function Hmac(alg, key) {
Base.call(this, "digest");
if (typeof key === "string") {
key = Buffer.from(key);
}
this._alg = alg;
this._key = key;
if (key.length > blocksize) {
key = alg(key);
} else if (key.length < blocksize) {
key = Buffer.concat([key, ZEROS], blocksize);
}
var ipad = this._ipad = Buffer.allocUnsafe(blocksize);
var opad = this._opad = Buffer.allocUnsafe(blocksize);
for (var i = 0; i < blocksize; i++) {
ipad[i] = key[i] ^ 54;
opad[i] = key[i] ^ 92;
}
this._hash = [ipad];
}
inherits(Hmac, Base);
Hmac.prototype._update = function (data) {
this._hash.push(data);
};
Hmac.prototype._final = function () {
var h = this._alg(Buffer.concat(this._hash));
return this._alg(Buffer.concat([this._opad, h]));
};
exports$3t = Hmac;
return exports$3t;
}
var exports$3s = {},
_dewExec$3r = false;
function dew$3r() {
if (_dewExec$3r) return exports$3s;
_dewExec$3r = true;
var MD5 = dew$3E();
exports$3s = function (buffer) {
return new MD5().update(buffer).digest();
};
return exports$3s;
}
var exports$3r = {},
_dewExec$3q = false;
function dew$3q() {
if (_dewExec$3q) return exports$3r;
_dewExec$3q = true;
var inherits = dew$3I();
var Legacy = dew$3s();
var Base = dew$3u();
var Buffer = dew$3H().Buffer;
var md5 = dew$3r();
var RIPEMD160 = dew$3D();
var sha = dew$3v();
var ZEROS = Buffer.alloc(128);
function Hmac(alg, key) {
Base.call(this, "digest");
if (typeof key === "string") {
key = Buffer.from(key);
}
var blocksize = alg === "sha512" || alg === "sha384" ? 128 : 64;
this._alg = alg;
this._key = key;
if (key.length > blocksize) {
var hash = alg === "rmd160" ? new RIPEMD160() : sha(alg);
key = hash.update(key).digest();
} else if (key.length < blocksize) {
key = Buffer.concat([key, ZEROS], blocksize);
}
var ipad = this._ipad = Buffer.allocUnsafe(blocksize);
var opad = this._opad = Buffer.allocUnsafe(blocksize);
for (var i = 0; i < blocksize; i++) {
ipad[i] = key[i] ^ 54;
opad[i] = key[i] ^ 92;
}
this._hash = alg === "rmd160" ? new RIPEMD160() : sha(alg);
this._hash.update(ipad);
}
inherits(Hmac, Base);
Hmac.prototype._update = function (data) {
this._hash.update(data);
};
Hmac.prototype._final = function () {
var h = this._hash.digest();
var hash = this._alg === "rmd160" ? new RIPEMD160() : sha(this._alg);
return hash.update(this._opad).update(h).digest();
};
exports$3r = function createHmac(alg, key) {
alg = alg.toLowerCase();
if (alg === "rmd160" || alg === "ripemd160") {
return new Hmac("rmd160", key);
}
if (alg === "md5") {
return new Legacy(md5, key);
}
return new Hmac(alg, key);
};
return exports$3r;
}
var _algorithms$2 = {
"sha224WithRSAEncryption": {
"sign": "rsa",
"hash": "sha224",
"id": "302d300d06096086480165030402040500041c"
},
"RSA-SHA224": {
"sign": "ecdsa/rsa",
"hash": "sha224",
"id": "302d300d06096086480165030402040500041c"
},
"sha256WithRSAEncryption": {
"sign": "rsa",
"hash": "sha256",
"id": "3031300d060960864801650304020105000420"
},
"RSA-SHA256": {
"sign": "ecdsa/rsa",
"hash": "sha256",
"id": "3031300d060960864801650304020105000420"
},
"sha384WithRSAEncryption": {
"sign": "rsa",
"hash": "sha384",
"id": "3041300d060960864801650304020205000430"
},
"RSA-SHA384": {
"sign": "ecdsa/rsa",
"hash": "sha384",
"id": "3041300d060960864801650304020205000430"
},
"sha512WithRSAEncryption": {
"sign": "rsa",
"hash": "sha512",
"id": "3051300d060960864801650304020305000440"
},
"RSA-SHA512": {
"sign": "ecdsa/rsa",
"hash": "sha512",
"id": "3051300d060960864801650304020305000440"
},
"RSA-SHA1": {
"sign": "rsa",
"hash": "sha1",
"id": "3021300906052b0e03021a05000414"
},
"ecdsa-with-SHA1": {
"sign": "ecdsa",
"hash": "sha1",
"id": ""
},
"sha256": {
"sign": "ecdsa",
"hash": "sha256",
"id": ""
},
"sha224": {
"sign": "ecdsa",
"hash": "sha224",
"id": ""
},
"sha384": {
"sign": "ecdsa",
"hash": "sha384",
"id": ""
},
"sha512": {
"sign": "ecdsa",
"hash": "sha512",
"id": ""
},
"DSA-SHA": {
"sign": "dsa",
"hash": "sha1",
"id": ""
},
"DSA-SHA1": {
"sign": "dsa",
"hash": "sha1",
"id": ""
},
"DSA": {
"sign": "dsa",
"hash": "sha1",
"id": ""
},
"DSA-WITH-SHA224": {
"sign": "dsa",
"hash": "sha224",
"id": ""
},
"DSA-SHA224": {
"sign": "dsa",
"hash": "sha224",
"id": ""
},
"DSA-WITH-SHA256": {
"sign": "dsa",
"hash": "sha256",
"id": ""
},
"DSA-SHA256": {
"sign": "dsa",
"hash": "sha256",
"id": ""
},
"DSA-WITH-SHA384": {
"sign":