diff --git a/0.8/BatoTo/index.js b/0.8/BatoTo/index.js index 3c61759..a532681 100644 --- a/0.8/BatoTo/index.js +++ b/0.8/BatoTo/index.js @@ -10817,7 +10817,9 @@ module.exports = crt }).call(this)}).call(this,require("buffer").Buffer) },{"bn.js":78,"buffer":124,"randombytes":226}],102:[function(require,module,exports){ -module.exports = require('./browser/algorithms.json') +'use strict'; + +module.exports = require('./browser/algorithms.json'); },{"./browser/algorithms.json":103}],103:[function(require,module,exports){ module.exports={ @@ -10984,90 +10986,90 @@ module.exports={ } },{}],105:[function(require,module,exports){ -var Buffer = require('safe-buffer').Buffer -var createHash = require('create-hash') -var stream = require('readable-stream') -var inherits = require('inherits') -var sign = require('./sign') -var verify = require('./verify') +'use strict'; + +var Buffer = require('safe-buffer').Buffer; +var createHash = require('create-hash'); +var stream = require('readable-stream'); +var inherits = require('inherits'); +var sign = require('./sign'); +var verify = require('./verify'); -var algorithms = require('./algorithms.json') +var algorithms = require('./algorithms.json'); Object.keys(algorithms).forEach(function (key) { - algorithms[key].id = Buffer.from(algorithms[key].id, 'hex') - algorithms[key.toLowerCase()] = algorithms[key] -}) + algorithms[key].id = Buffer.from(algorithms[key].id, 'hex'); + algorithms[key.toLowerCase()] = algorithms[key]; +}); -function Sign (algorithm) { - stream.Writable.call(this) +function Sign(algorithm) { + stream.Writable.call(this); - var data = algorithms[algorithm] - if (!data) throw new Error('Unknown message digest') + var data = algorithms[algorithm]; + if (!data) { throw new Error('Unknown message digest'); } - this._hashType = data.hash - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign + this._hashType = data.hash; + this._hash = createHash(data.hash); + this._tag = data.id; + this._signType = data.sign; } -inherits(Sign, stream.Writable) +inherits(Sign, stream.Writable); -Sign.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() -} +Sign.prototype._write = function _write(data, _, done) { + this._hash.update(data); + done(); +}; -Sign.prototype.update = function update (data, enc) { - if (typeof data === 'string') data = Buffer.from(data, enc) +Sign.prototype.update = function update(data, enc) { + this._hash.update(typeof data === 'string' ? Buffer.from(data, enc) : data); - this._hash.update(data) - return this -} + return this; +}; -Sign.prototype.sign = function signMethod (key, enc) { - this.end() - var hash = this._hash.digest() - var sig = sign(hash, key, this._hashType, this._signType, this._tag) +Sign.prototype.sign = function signMethod(key, enc) { + this.end(); + var hash = this._hash.digest(); + var sig = sign(hash, key, this._hashType, this._signType, this._tag); - return enc ? sig.toString(enc) : sig -} + return enc ? sig.toString(enc) : sig; +}; -function Verify (algorithm) { - stream.Writable.call(this) +function Verify(algorithm) { + stream.Writable.call(this); - var data = algorithms[algorithm] - if (!data) throw new Error('Unknown message digest') + var data = algorithms[algorithm]; + if (!data) { throw new Error('Unknown message digest'); } - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign + this._hash = createHash(data.hash); + this._tag = data.id; + this._signType = data.sign; } -inherits(Verify, stream.Writable) +inherits(Verify, stream.Writable); -Verify.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() -} +Verify.prototype._write = function _write(data, _, done) { + this._hash.update(data); + done(); +}; -Verify.prototype.update = function update (data, enc) { - if (typeof data === 'string') data = Buffer.from(data, enc) +Verify.prototype.update = function update(data, enc) { + this._hash.update(typeof data === 'string' ? Buffer.from(data, enc) : data); - this._hash.update(data) - return this -} + return this; +}; -Verify.prototype.verify = function verifyMethod (key, sig, enc) { - if (typeof sig === 'string') sig = Buffer.from(sig, enc) +Verify.prototype.verify = function verifyMethod(key, sig, enc) { + var sigBuffer = typeof sig === 'string' ? Buffer.from(sig, enc) : sig; - this.end() - var hash = this._hash.digest() - return verify(sig, hash, key, this._signType, this._tag) -} + this.end(); + var hash = this._hash.digest(); + return verify(sigBuffer, hash, key, this._signType, this._tag); +}; -function createSign (algorithm) { - return new Sign(algorithm) +function createSign(algorithm) { + return new Sign(algorithm); } -function createVerify (algorithm) { - return new Verify(algorithm) +function createVerify(algorithm) { + return new Verify(algorithm); } module.exports = { @@ -11075,238 +11077,247 @@ module.exports = { Verify: createVerify, createSign: createSign, createVerify: createVerify -} +}; },{"./algorithms.json":103,"./sign":106,"./verify":107,"create-hash":128,"inherits":201,"readable-stream":122,"safe-buffer":229}],106:[function(require,module,exports){ +'use strict'; + // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js -var Buffer = require('safe-buffer').Buffer -var createHmac = require('create-hmac') -var crt = require('browserify-rsa') -var EC = require('elliptic').ec -var BN = require('bn.js') -var parseKeys = require('parse-asn1') -var curves = require('./curves.json') +var Buffer = require('safe-buffer').Buffer; +var createHmac = require('create-hmac'); +var crt = require('browserify-rsa'); +var EC = require('elliptic').ec; +var BN = require('bn.js'); +var parseKeys = require('parse-asn1'); +var curves = require('./curves.json'); + +var RSA_PKCS1_PADDING = 1; -function sign (hash, key, hashType, signType, tag) { - var priv = parseKeys(key) +function sign(hash, key, hashType, signType, tag) { + var priv = parseKeys(key); if (priv.curve) { // rsa keys can be interpreted as ecdsa ones in openssl - if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') - return ecSign(hash, priv) + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') { throw new Error('wrong private key type'); } + return ecSign(hash, priv); } else if (priv.type === 'dsa') { - if (signType !== 'dsa') throw new Error('wrong private key type') - return dsaSign(hash, priv, hashType) - } else { - if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + if (signType !== 'dsa') { throw new Error('wrong private key type'); } + return dsaSign(hash, priv, hashType); } - hash = Buffer.concat([tag, hash]) - var len = priv.modulus.byteLength() - var pad = [0, 1] - while (hash.length + pad.length + 1 < len) pad.push(0xff) - pad.push(0x00) - var i = -1 - while (++i < hash.length) pad.push(hash[i]) + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') { throw new Error('wrong private key type'); } + if (key.padding !== undefined && key.padding !== RSA_PKCS1_PADDING) { throw new Error('illegal or unsupported padding mode'); } - var out = crt(pad, priv) - return out + hash = Buffer.concat([tag, hash]); + var len = priv.modulus.byteLength(); + var pad = [0, 1]; + while (hash.length + pad.length + 1 < len) { pad.push(0xff); } + pad.push(0x00); + var i = -1; + while (++i < hash.length) { pad.push(hash[i]); } + + var out = crt(pad, priv); + return out; } -function ecSign (hash, priv) { - var curveId = curves[priv.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) +function ecSign(hash, priv) { + var curveId = curves[priv.curve.join('.')]; + if (!curveId) { throw new Error('unknown curve ' + priv.curve.join('.')); } - var curve = new EC(curveId) - var key = curve.keyFromPrivate(priv.privateKey) - var out = key.sign(hash) + var curve = new EC(curveId); + var key = curve.keyFromPrivate(priv.privateKey); + var out = key.sign(hash); - return Buffer.from(out.toDER()) + return Buffer.from(out.toDER()); } -function dsaSign (hash, priv, algo) { - var x = priv.params.priv_key - var p = priv.params.p - var q = priv.params.q - var g = priv.params.g - var r = new BN(0) - var k - var H = bits2int(hash, q).mod(q) - var s = false - var kv = getKey(x, q, hash, algo) +function dsaSign(hash, priv, algo) { + var x = priv.params.priv_key; + var p = priv.params.p; + var q = priv.params.q; + var g = priv.params.g; + var r = new BN(0); + var k; + var H = bits2int(hash, q).mod(q); + var s = false; + var kv = getKey(x, q, hash, algo); while (s === false) { - k = makeKey(q, kv, algo) - r = makeR(g, k, p, q) - s = k.invm(q).imul(H.add(x.mul(r))).mod(q) + k = makeKey(q, kv, algo); + r = makeR(g, k, p, q); + s = k.invm(q).imul(H.add(x.mul(r))).mod(q); if (s.cmpn(0) === 0) { - s = false - r = new BN(0) + s = false; + r = new BN(0); } } - return toDER(r, s) + return toDER(r, s); } -function toDER (r, s) { - r = r.toArray() - s = s.toArray() +function toDER(r, s) { + r = r.toArray(); + s = s.toArray(); // Pad values - if (r[0] & 0x80) r = [0].concat(r) - if (s[0] & 0x80) s = [0].concat(s) + if (r[0] & 0x80) { r = [0].concat(r); } + if (s[0] & 0x80) { s = [0].concat(s); } - var total = r.length + s.length + 4 - var res = [0x30, total, 0x02, r.length] - res = res.concat(r, [0x02, s.length], s) - return Buffer.from(res) + var total = r.length + s.length + 4; + var res = [ + 0x30, total, 0x02, r.length + ]; + res = res.concat(r, [0x02, s.length], s); + return Buffer.from(res); } -function getKey (x, q, hash, algo) { - x = Buffer.from(x.toArray()) +function getKey(x, q, hash, algo) { + x = Buffer.from(x.toArray()); if (x.length < q.byteLength()) { - var zeros = Buffer.alloc(q.byteLength() - x.length) - x = Buffer.concat([zeros, x]) - } - var hlen = hash.length - var hbits = bits2octets(hash, q) - var v = Buffer.alloc(hlen) - v.fill(1) - var k = Buffer.alloc(hlen) - k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest() - v = createHmac(algo, k).update(v).digest() - k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest() - v = createHmac(algo, k).update(v).digest() - return { k: k, v: v } -} - -function bits2int (obits, q) { - var bits = new BN(obits) - var shift = (obits.length << 3) - q.bitLength() - if (shift > 0) bits.ishrn(shift) - return bits -} - -function bits2octets (bits, q) { - bits = bits2int(bits, q) - bits = bits.mod(q) - var out = Buffer.from(bits.toArray()) + var zeros = Buffer.alloc(q.byteLength() - x.length); + x = Buffer.concat([zeros, x]); + } + var hlen = hash.length; + var hbits = bits2octets(hash, q); + var v = Buffer.alloc(hlen); + v.fill(1); + var k = Buffer.alloc(hlen); + k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest(); + v = createHmac(algo, k).update(v).digest(); + k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest(); + v = createHmac(algo, k).update(v).digest(); + return { k: k, v: v }; +} + +function bits2int(obits, q) { + var bits = new BN(obits); + var shift = (obits.length << 3) - q.bitLength(); + if (shift > 0) { bits.ishrn(shift); } + return bits; +} + +function bits2octets(bits, q) { + bits = bits2int(bits, q); + bits = bits.mod(q); + var out = Buffer.from(bits.toArray()); if (out.length < q.byteLength()) { - var zeros = Buffer.alloc(q.byteLength() - out.length) - out = Buffer.concat([zeros, out]) + var zeros = Buffer.alloc(q.byteLength() - out.length); + out = Buffer.concat([zeros, out]); } - return out + return out; } -function makeKey (q, kv, algo) { - var t - var k +function makeKey(q, kv, algo) { + var t; + var k; do { - t = Buffer.alloc(0) + t = Buffer.alloc(0); while (t.length * 8 < q.bitLength()) { - kv.v = createHmac(algo, kv.k).update(kv.v).digest() - t = Buffer.concat([t, kv.v]) + kv.v = createHmac(algo, kv.k).update(kv.v).digest(); + t = Buffer.concat([t, kv.v]); } - k = bits2int(t, q) - kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest() - kv.v = createHmac(algo, kv.k).update(kv.v).digest() - } while (k.cmp(q) !== -1) + k = bits2int(t, q); + kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest(); + kv.v = createHmac(algo, kv.k).update(kv.v).digest(); + } while (k.cmp(q) !== -1); - return k + return k; } -function makeR (g, k, p, q) { - return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) +function makeR(g, k, p, q) { + return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q); } -module.exports = sign -module.exports.getKey = getKey -module.exports.makeKey = makeKey +module.exports = sign; +module.exports.getKey = getKey; +module.exports.makeKey = makeKey; },{"./curves.json":104,"bn.js":78,"browserify-rsa":101,"create-hmac":130,"elliptic":144,"parse-asn1":211,"safe-buffer":229}],107:[function(require,module,exports){ +'use strict'; + // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js -var Buffer = require('safe-buffer').Buffer -var BN = require('bn.js') -var EC = require('elliptic').ec -var parseKeys = require('parse-asn1') -var curves = require('./curves.json') +var Buffer = require('safe-buffer').Buffer; +var BN = require('bn.js'); +var EC = require('elliptic').ec; +var parseKeys = require('parse-asn1'); +var curves = require('./curves.json'); -function verify (sig, hash, key, signType, tag) { - var pub = parseKeys(key) +function verify(sig, hash, key, signType, tag) { + var pub = parseKeys(key); if (pub.type === 'ec') { // rsa keys can be interpreted as ecdsa ones in openssl - if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') - return ecVerify(sig, hash, pub) + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') { throw new Error('wrong public key type'); } + return ecVerify(sig, hash, pub); } else if (pub.type === 'dsa') { - if (signType !== 'dsa') throw new Error('wrong public key type') - return dsaVerify(sig, hash, pub) - } else { - if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') + if (signType !== 'dsa') { throw new Error('wrong public key type'); } + return dsaVerify(sig, hash, pub); } - hash = Buffer.concat([tag, hash]) - var len = pub.modulus.byteLength() - var pad = [1] - var padNum = 0 + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') { throw new Error('wrong public key type'); } + + hash = Buffer.concat([tag, hash]); + var len = pub.modulus.byteLength(); + var pad = [1]; + var padNum = 0; while (hash.length + pad.length + 2 < len) { - pad.push(0xff) - padNum++ + pad.push(0xff); + padNum += 1; } - pad.push(0x00) - var i = -1 + pad.push(0x00); + var i = -1; while (++i < hash.length) { - pad.push(hash[i]) + pad.push(hash[i]); } - pad = Buffer.from(pad) - var red = BN.mont(pub.modulus) - sig = new BN(sig).toRed(red) + pad = Buffer.from(pad); + var red = BN.mont(pub.modulus); + sig = new BN(sig).toRed(red); - sig = sig.redPow(new BN(pub.publicExponent)) - sig = Buffer.from(sig.fromRed().toArray()) - var out = padNum < 8 ? 1 : 0 - len = Math.min(sig.length, pad.length) - if (sig.length !== pad.length) out = 1 + sig = sig.redPow(new BN(pub.publicExponent)); + sig = Buffer.from(sig.fromRed().toArray()); + var out = padNum < 8 ? 1 : 0; + len = Math.min(sig.length, pad.length); + if (sig.length !== pad.length) { out = 1; } - i = -1 - while (++i < len) out |= sig[i] ^ pad[i] - return out === 0 + i = -1; + while (++i < len) { out |= sig[i] ^ pad[i]; } + return out === 0; } -function ecVerify (sig, hash, pub) { - var curveId = curves[pub.data.algorithm.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) +function ecVerify(sig, hash, pub) { + var curveId = curves[pub.data.algorithm.curve.join('.')]; + if (!curveId) { throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')); } - var curve = new EC(curveId) - var pubkey = pub.data.subjectPrivateKey.data + var curve = new EC(curveId); + var pubkey = pub.data.subjectPrivateKey.data; - return curve.verify(hash, sig, pubkey) + return curve.verify(hash, sig, pubkey); } -function dsaVerify (sig, hash, pub) { - var p = pub.data.p - var q = pub.data.q - var g = pub.data.g - var y = pub.data.pub_key - var unpacked = parseKeys.signature.decode(sig, 'der') - var s = unpacked.s - var r = unpacked.r - checkValue(s, q) - checkValue(r, q) - var montp = BN.mont(p) - var w = s.invm(q) +function dsaVerify(sig, hash, pub) { + var p = pub.data.p; + var q = pub.data.q; + var g = pub.data.g; + var y = pub.data.pub_key; + var unpacked = parseKeys.signature.decode(sig, 'der'); + var s = unpacked.s; + var r = unpacked.r; + checkValue(s, q); + checkValue(r, q); + var montp = BN.mont(p); + var w = s.invm(q); var v = g.toRed(montp) .redPow(new BN(hash).mul(w).mod(q)) .fromRed() .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()) .mod(p) - .mod(q) - return v.cmp(r) === 0 + .mod(q); + return v.cmp(r) === 0; } -function checkValue (b, q) { - if (b.cmpn(0) <= 0) throw new Error('invalid sig') - if (b.cmp(q) >= q) throw new Error('invalid sig') +function checkValue(b, q) { + if (b.cmpn(0) <= 0) { throw new Error('invalid sig'); } + if (b.cmp(q) >= 0) { throw new Error('invalid sig'); } } -module.exports = verify +module.exports = verify; },{"./curves.json":104,"bn.js":78,"elliptic":144,"parse-asn1":211,"safe-buffer":229}],108:[function(require,module,exports){ 'use strict'; @@ -21371,7 +21382,7 @@ utils.intFromLE = intFromLE; arguments[4][76][0].apply(exports,arguments) },{"buffer":80,"dup":76}],160:[function(require,module,exports){ module.exports={ - "_from": "elliptic@^6.5.3", + "_from": "elliptic@^6.5.4", "_id": "elliptic@6.5.4", "_inBundle": false, "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", @@ -21380,12 +21391,12 @@ module.exports={ "_requested": { "type": "range", "registry": true, - "raw": "elliptic@^6.5.3", + "raw": "elliptic@^6.5.4", "name": "elliptic", "escapedName": "elliptic", - "rawSpec": "^6.5.3", + "rawSpec": "^6.5.4", "saveSpec": null, - "fetchSpec": "^6.5.3" + "fetchSpec": "^6.5.4" }, "_requiredBy": [ "/browserify-sign", @@ -21393,7 +21404,7 @@ module.exports={ ], "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", "_shasum": "da37cebd31e79a1367e941b592ed1fbebd58abbb", - "_spec": "elliptic@^6.5.3", + "_spec": "elliptic@^6.5.4", "_where": "/home/runner/work/community-extensions/community-extensions/node_modules/browserify-sign", "author": { "name": "Fedor Indutny", @@ -27829,7 +27840,7 @@ const types_1 = require("@paperback/types"); const BatoToParser_1 = require("./BatoToParser"); const BATO_DOMAIN = 'https://bato.to'; exports.BatoToInfo = { - version: '3.0.2', + version: '3.0.3', name: 'BatoTo', icon: 'icon.png', author: 'Nicholas', @@ -28810,7 +28821,7 @@ const parseChapterDetails = ($, mangaId, chapterId) => { const script = scriptObj?.children[0]?.data ?? ''; const batoPass = eval(script.match(/const\s+batoPass\s*=\s*(.*?);/)?.[1] ?? '').toString(); const batoWord = (script.match(/const\s+batoWord\s*=\s*"(.*)";/)?.[1] ?? ''); - const imgList = JSON.parse(script.match(/const\s+imgHttpLis\s*=\s*(.*?);/)?.[1] ?? ''); + const imgList = JSON.parse(script.match(/const\s+imgHttps\s*=\s*(.*?);/)?.[1] ?? ''); const tknList = JSON.parse(CryptoJS.AES.decrypt(batoWord, batoPass).toString(CryptoJS.enc.Utf8)); for (let i = 0; i < Math.min(imgList.length, tknList.length); i++) { pages.push(`${imgList[i]}?${tknList[i]}`); diff --git a/0.8/BatoTo/source.js b/0.8/BatoTo/source.js index 3c61759..a532681 100644 --- a/0.8/BatoTo/source.js +++ b/0.8/BatoTo/source.js @@ -10817,7 +10817,9 @@ module.exports = crt }).call(this)}).call(this,require("buffer").Buffer) },{"bn.js":78,"buffer":124,"randombytes":226}],102:[function(require,module,exports){ -module.exports = require('./browser/algorithms.json') +'use strict'; + +module.exports = require('./browser/algorithms.json'); },{"./browser/algorithms.json":103}],103:[function(require,module,exports){ module.exports={ @@ -10984,90 +10986,90 @@ module.exports={ } },{}],105:[function(require,module,exports){ -var Buffer = require('safe-buffer').Buffer -var createHash = require('create-hash') -var stream = require('readable-stream') -var inherits = require('inherits') -var sign = require('./sign') -var verify = require('./verify') +'use strict'; + +var Buffer = require('safe-buffer').Buffer; +var createHash = require('create-hash'); +var stream = require('readable-stream'); +var inherits = require('inherits'); +var sign = require('./sign'); +var verify = require('./verify'); -var algorithms = require('./algorithms.json') +var algorithms = require('./algorithms.json'); Object.keys(algorithms).forEach(function (key) { - algorithms[key].id = Buffer.from(algorithms[key].id, 'hex') - algorithms[key.toLowerCase()] = algorithms[key] -}) + algorithms[key].id = Buffer.from(algorithms[key].id, 'hex'); + algorithms[key.toLowerCase()] = algorithms[key]; +}); -function Sign (algorithm) { - stream.Writable.call(this) +function Sign(algorithm) { + stream.Writable.call(this); - var data = algorithms[algorithm] - if (!data) throw new Error('Unknown message digest') + var data = algorithms[algorithm]; + if (!data) { throw new Error('Unknown message digest'); } - this._hashType = data.hash - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign + this._hashType = data.hash; + this._hash = createHash(data.hash); + this._tag = data.id; + this._signType = data.sign; } -inherits(Sign, stream.Writable) +inherits(Sign, stream.Writable); -Sign.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() -} +Sign.prototype._write = function _write(data, _, done) { + this._hash.update(data); + done(); +}; -Sign.prototype.update = function update (data, enc) { - if (typeof data === 'string') data = Buffer.from(data, enc) +Sign.prototype.update = function update(data, enc) { + this._hash.update(typeof data === 'string' ? Buffer.from(data, enc) : data); - this._hash.update(data) - return this -} + return this; +}; -Sign.prototype.sign = function signMethod (key, enc) { - this.end() - var hash = this._hash.digest() - var sig = sign(hash, key, this._hashType, this._signType, this._tag) +Sign.prototype.sign = function signMethod(key, enc) { + this.end(); + var hash = this._hash.digest(); + var sig = sign(hash, key, this._hashType, this._signType, this._tag); - return enc ? sig.toString(enc) : sig -} + return enc ? sig.toString(enc) : sig; +}; -function Verify (algorithm) { - stream.Writable.call(this) +function Verify(algorithm) { + stream.Writable.call(this); - var data = algorithms[algorithm] - if (!data) throw new Error('Unknown message digest') + var data = algorithms[algorithm]; + if (!data) { throw new Error('Unknown message digest'); } - this._hash = createHash(data.hash) - this._tag = data.id - this._signType = data.sign + this._hash = createHash(data.hash); + this._tag = data.id; + this._signType = data.sign; } -inherits(Verify, stream.Writable) +inherits(Verify, stream.Writable); -Verify.prototype._write = function _write (data, _, done) { - this._hash.update(data) - done() -} +Verify.prototype._write = function _write(data, _, done) { + this._hash.update(data); + done(); +}; -Verify.prototype.update = function update (data, enc) { - if (typeof data === 'string') data = Buffer.from(data, enc) +Verify.prototype.update = function update(data, enc) { + this._hash.update(typeof data === 'string' ? Buffer.from(data, enc) : data); - this._hash.update(data) - return this -} + return this; +}; -Verify.prototype.verify = function verifyMethod (key, sig, enc) { - if (typeof sig === 'string') sig = Buffer.from(sig, enc) +Verify.prototype.verify = function verifyMethod(key, sig, enc) { + var sigBuffer = typeof sig === 'string' ? Buffer.from(sig, enc) : sig; - this.end() - var hash = this._hash.digest() - return verify(sig, hash, key, this._signType, this._tag) -} + this.end(); + var hash = this._hash.digest(); + return verify(sigBuffer, hash, key, this._signType, this._tag); +}; -function createSign (algorithm) { - return new Sign(algorithm) +function createSign(algorithm) { + return new Sign(algorithm); } -function createVerify (algorithm) { - return new Verify(algorithm) +function createVerify(algorithm) { + return new Verify(algorithm); } module.exports = { @@ -11075,238 +11077,247 @@ module.exports = { Verify: createVerify, createSign: createSign, createVerify: createVerify -} +}; },{"./algorithms.json":103,"./sign":106,"./verify":107,"create-hash":128,"inherits":201,"readable-stream":122,"safe-buffer":229}],106:[function(require,module,exports){ +'use strict'; + // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js -var Buffer = require('safe-buffer').Buffer -var createHmac = require('create-hmac') -var crt = require('browserify-rsa') -var EC = require('elliptic').ec -var BN = require('bn.js') -var parseKeys = require('parse-asn1') -var curves = require('./curves.json') +var Buffer = require('safe-buffer').Buffer; +var createHmac = require('create-hmac'); +var crt = require('browserify-rsa'); +var EC = require('elliptic').ec; +var BN = require('bn.js'); +var parseKeys = require('parse-asn1'); +var curves = require('./curves.json'); + +var RSA_PKCS1_PADDING = 1; -function sign (hash, key, hashType, signType, tag) { - var priv = parseKeys(key) +function sign(hash, key, hashType, signType, tag) { + var priv = parseKeys(key); if (priv.curve) { // rsa keys can be interpreted as ecdsa ones in openssl - if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') - return ecSign(hash, priv) + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') { throw new Error('wrong private key type'); } + return ecSign(hash, priv); } else if (priv.type === 'dsa') { - if (signType !== 'dsa') throw new Error('wrong private key type') - return dsaSign(hash, priv, hashType) - } else { - if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong private key type') + if (signType !== 'dsa') { throw new Error('wrong private key type'); } + return dsaSign(hash, priv, hashType); } - hash = Buffer.concat([tag, hash]) - var len = priv.modulus.byteLength() - var pad = [0, 1] - while (hash.length + pad.length + 1 < len) pad.push(0xff) - pad.push(0x00) - var i = -1 - while (++i < hash.length) pad.push(hash[i]) + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') { throw new Error('wrong private key type'); } + if (key.padding !== undefined && key.padding !== RSA_PKCS1_PADDING) { throw new Error('illegal or unsupported padding mode'); } - var out = crt(pad, priv) - return out + hash = Buffer.concat([tag, hash]); + var len = priv.modulus.byteLength(); + var pad = [0, 1]; + while (hash.length + pad.length + 1 < len) { pad.push(0xff); } + pad.push(0x00); + var i = -1; + while (++i < hash.length) { pad.push(hash[i]); } + + var out = crt(pad, priv); + return out; } -function ecSign (hash, priv) { - var curveId = curves[priv.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + priv.curve.join('.')) +function ecSign(hash, priv) { + var curveId = curves[priv.curve.join('.')]; + if (!curveId) { throw new Error('unknown curve ' + priv.curve.join('.')); } - var curve = new EC(curveId) - var key = curve.keyFromPrivate(priv.privateKey) - var out = key.sign(hash) + var curve = new EC(curveId); + var key = curve.keyFromPrivate(priv.privateKey); + var out = key.sign(hash); - return Buffer.from(out.toDER()) + return Buffer.from(out.toDER()); } -function dsaSign (hash, priv, algo) { - var x = priv.params.priv_key - var p = priv.params.p - var q = priv.params.q - var g = priv.params.g - var r = new BN(0) - var k - var H = bits2int(hash, q).mod(q) - var s = false - var kv = getKey(x, q, hash, algo) +function dsaSign(hash, priv, algo) { + var x = priv.params.priv_key; + var p = priv.params.p; + var q = priv.params.q; + var g = priv.params.g; + var r = new BN(0); + var k; + var H = bits2int(hash, q).mod(q); + var s = false; + var kv = getKey(x, q, hash, algo); while (s === false) { - k = makeKey(q, kv, algo) - r = makeR(g, k, p, q) - s = k.invm(q).imul(H.add(x.mul(r))).mod(q) + k = makeKey(q, kv, algo); + r = makeR(g, k, p, q); + s = k.invm(q).imul(H.add(x.mul(r))).mod(q); if (s.cmpn(0) === 0) { - s = false - r = new BN(0) + s = false; + r = new BN(0); } } - return toDER(r, s) + return toDER(r, s); } -function toDER (r, s) { - r = r.toArray() - s = s.toArray() +function toDER(r, s) { + r = r.toArray(); + s = s.toArray(); // Pad values - if (r[0] & 0x80) r = [0].concat(r) - if (s[0] & 0x80) s = [0].concat(s) + if (r[0] & 0x80) { r = [0].concat(r); } + if (s[0] & 0x80) { s = [0].concat(s); } - var total = r.length + s.length + 4 - var res = [0x30, total, 0x02, r.length] - res = res.concat(r, [0x02, s.length], s) - return Buffer.from(res) + var total = r.length + s.length + 4; + var res = [ + 0x30, total, 0x02, r.length + ]; + res = res.concat(r, [0x02, s.length], s); + return Buffer.from(res); } -function getKey (x, q, hash, algo) { - x = Buffer.from(x.toArray()) +function getKey(x, q, hash, algo) { + x = Buffer.from(x.toArray()); if (x.length < q.byteLength()) { - var zeros = Buffer.alloc(q.byteLength() - x.length) - x = Buffer.concat([zeros, x]) - } - var hlen = hash.length - var hbits = bits2octets(hash, q) - var v = Buffer.alloc(hlen) - v.fill(1) - var k = Buffer.alloc(hlen) - k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest() - v = createHmac(algo, k).update(v).digest() - k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest() - v = createHmac(algo, k).update(v).digest() - return { k: k, v: v } -} - -function bits2int (obits, q) { - var bits = new BN(obits) - var shift = (obits.length << 3) - q.bitLength() - if (shift > 0) bits.ishrn(shift) - return bits -} - -function bits2octets (bits, q) { - bits = bits2int(bits, q) - bits = bits.mod(q) - var out = Buffer.from(bits.toArray()) + var zeros = Buffer.alloc(q.byteLength() - x.length); + x = Buffer.concat([zeros, x]); + } + var hlen = hash.length; + var hbits = bits2octets(hash, q); + var v = Buffer.alloc(hlen); + v.fill(1); + var k = Buffer.alloc(hlen); + k = createHmac(algo, k).update(v).update(Buffer.from([0])).update(x).update(hbits).digest(); + v = createHmac(algo, k).update(v).digest(); + k = createHmac(algo, k).update(v).update(Buffer.from([1])).update(x).update(hbits).digest(); + v = createHmac(algo, k).update(v).digest(); + return { k: k, v: v }; +} + +function bits2int(obits, q) { + var bits = new BN(obits); + var shift = (obits.length << 3) - q.bitLength(); + if (shift > 0) { bits.ishrn(shift); } + return bits; +} + +function bits2octets(bits, q) { + bits = bits2int(bits, q); + bits = bits.mod(q); + var out = Buffer.from(bits.toArray()); if (out.length < q.byteLength()) { - var zeros = Buffer.alloc(q.byteLength() - out.length) - out = Buffer.concat([zeros, out]) + var zeros = Buffer.alloc(q.byteLength() - out.length); + out = Buffer.concat([zeros, out]); } - return out + return out; } -function makeKey (q, kv, algo) { - var t - var k +function makeKey(q, kv, algo) { + var t; + var k; do { - t = Buffer.alloc(0) + t = Buffer.alloc(0); while (t.length * 8 < q.bitLength()) { - kv.v = createHmac(algo, kv.k).update(kv.v).digest() - t = Buffer.concat([t, kv.v]) + kv.v = createHmac(algo, kv.k).update(kv.v).digest(); + t = Buffer.concat([t, kv.v]); } - k = bits2int(t, q) - kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest() - kv.v = createHmac(algo, kv.k).update(kv.v).digest() - } while (k.cmp(q) !== -1) + k = bits2int(t, q); + kv.k = createHmac(algo, kv.k).update(kv.v).update(Buffer.from([0])).digest(); + kv.v = createHmac(algo, kv.k).update(kv.v).digest(); + } while (k.cmp(q) !== -1); - return k + return k; } -function makeR (g, k, p, q) { - return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q) +function makeR(g, k, p, q) { + return g.toRed(BN.mont(p)).redPow(k).fromRed().mod(q); } -module.exports = sign -module.exports.getKey = getKey -module.exports.makeKey = makeKey +module.exports = sign; +module.exports.getKey = getKey; +module.exports.makeKey = makeKey; },{"./curves.json":104,"bn.js":78,"browserify-rsa":101,"create-hmac":130,"elliptic":144,"parse-asn1":211,"safe-buffer":229}],107:[function(require,module,exports){ +'use strict'; + // much of this based on https://github.com/indutny/self-signed/blob/gh-pages/lib/rsa.js -var Buffer = require('safe-buffer').Buffer -var BN = require('bn.js') -var EC = require('elliptic').ec -var parseKeys = require('parse-asn1') -var curves = require('./curves.json') +var Buffer = require('safe-buffer').Buffer; +var BN = require('bn.js'); +var EC = require('elliptic').ec; +var parseKeys = require('parse-asn1'); +var curves = require('./curves.json'); -function verify (sig, hash, key, signType, tag) { - var pub = parseKeys(key) +function verify(sig, hash, key, signType, tag) { + var pub = parseKeys(key); if (pub.type === 'ec') { // rsa keys can be interpreted as ecdsa ones in openssl - if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') - return ecVerify(sig, hash, pub) + if (signType !== 'ecdsa' && signType !== 'ecdsa/rsa') { throw new Error('wrong public key type'); } + return ecVerify(sig, hash, pub); } else if (pub.type === 'dsa') { - if (signType !== 'dsa') throw new Error('wrong public key type') - return dsaVerify(sig, hash, pub) - } else { - if (signType !== 'rsa' && signType !== 'ecdsa/rsa') throw new Error('wrong public key type') + if (signType !== 'dsa') { throw new Error('wrong public key type'); } + return dsaVerify(sig, hash, pub); } - hash = Buffer.concat([tag, hash]) - var len = pub.modulus.byteLength() - var pad = [1] - var padNum = 0 + if (signType !== 'rsa' && signType !== 'ecdsa/rsa') { throw new Error('wrong public key type'); } + + hash = Buffer.concat([tag, hash]); + var len = pub.modulus.byteLength(); + var pad = [1]; + var padNum = 0; while (hash.length + pad.length + 2 < len) { - pad.push(0xff) - padNum++ + pad.push(0xff); + padNum += 1; } - pad.push(0x00) - var i = -1 + pad.push(0x00); + var i = -1; while (++i < hash.length) { - pad.push(hash[i]) + pad.push(hash[i]); } - pad = Buffer.from(pad) - var red = BN.mont(pub.modulus) - sig = new BN(sig).toRed(red) + pad = Buffer.from(pad); + var red = BN.mont(pub.modulus); + sig = new BN(sig).toRed(red); - sig = sig.redPow(new BN(pub.publicExponent)) - sig = Buffer.from(sig.fromRed().toArray()) - var out = padNum < 8 ? 1 : 0 - len = Math.min(sig.length, pad.length) - if (sig.length !== pad.length) out = 1 + sig = sig.redPow(new BN(pub.publicExponent)); + sig = Buffer.from(sig.fromRed().toArray()); + var out = padNum < 8 ? 1 : 0; + len = Math.min(sig.length, pad.length); + if (sig.length !== pad.length) { out = 1; } - i = -1 - while (++i < len) out |= sig[i] ^ pad[i] - return out === 0 + i = -1; + while (++i < len) { out |= sig[i] ^ pad[i]; } + return out === 0; } -function ecVerify (sig, hash, pub) { - var curveId = curves[pub.data.algorithm.curve.join('.')] - if (!curveId) throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')) +function ecVerify(sig, hash, pub) { + var curveId = curves[pub.data.algorithm.curve.join('.')]; + if (!curveId) { throw new Error('unknown curve ' + pub.data.algorithm.curve.join('.')); } - var curve = new EC(curveId) - var pubkey = pub.data.subjectPrivateKey.data + var curve = new EC(curveId); + var pubkey = pub.data.subjectPrivateKey.data; - return curve.verify(hash, sig, pubkey) + return curve.verify(hash, sig, pubkey); } -function dsaVerify (sig, hash, pub) { - var p = pub.data.p - var q = pub.data.q - var g = pub.data.g - var y = pub.data.pub_key - var unpacked = parseKeys.signature.decode(sig, 'der') - var s = unpacked.s - var r = unpacked.r - checkValue(s, q) - checkValue(r, q) - var montp = BN.mont(p) - var w = s.invm(q) +function dsaVerify(sig, hash, pub) { + var p = pub.data.p; + var q = pub.data.q; + var g = pub.data.g; + var y = pub.data.pub_key; + var unpacked = parseKeys.signature.decode(sig, 'der'); + var s = unpacked.s; + var r = unpacked.r; + checkValue(s, q); + checkValue(r, q); + var montp = BN.mont(p); + var w = s.invm(q); var v = g.toRed(montp) .redPow(new BN(hash).mul(w).mod(q)) .fromRed() .mul(y.toRed(montp).redPow(r.mul(w).mod(q)).fromRed()) .mod(p) - .mod(q) - return v.cmp(r) === 0 + .mod(q); + return v.cmp(r) === 0; } -function checkValue (b, q) { - if (b.cmpn(0) <= 0) throw new Error('invalid sig') - if (b.cmp(q) >= q) throw new Error('invalid sig') +function checkValue(b, q) { + if (b.cmpn(0) <= 0) { throw new Error('invalid sig'); } + if (b.cmp(q) >= 0) { throw new Error('invalid sig'); } } -module.exports = verify +module.exports = verify; },{"./curves.json":104,"bn.js":78,"elliptic":144,"parse-asn1":211,"safe-buffer":229}],108:[function(require,module,exports){ 'use strict'; @@ -21371,7 +21382,7 @@ utils.intFromLE = intFromLE; arguments[4][76][0].apply(exports,arguments) },{"buffer":80,"dup":76}],160:[function(require,module,exports){ module.exports={ - "_from": "elliptic@^6.5.3", + "_from": "elliptic@^6.5.4", "_id": "elliptic@6.5.4", "_inBundle": false, "_integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", @@ -21380,12 +21391,12 @@ module.exports={ "_requested": { "type": "range", "registry": true, - "raw": "elliptic@^6.5.3", + "raw": "elliptic@^6.5.4", "name": "elliptic", "escapedName": "elliptic", - "rawSpec": "^6.5.3", + "rawSpec": "^6.5.4", "saveSpec": null, - "fetchSpec": "^6.5.3" + "fetchSpec": "^6.5.4" }, "_requiredBy": [ "/browserify-sign", @@ -21393,7 +21404,7 @@ module.exports={ ], "_resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", "_shasum": "da37cebd31e79a1367e941b592ed1fbebd58abbb", - "_spec": "elliptic@^6.5.3", + "_spec": "elliptic@^6.5.4", "_where": "/home/runner/work/community-extensions/community-extensions/node_modules/browserify-sign", "author": { "name": "Fedor Indutny", @@ -27829,7 +27840,7 @@ const types_1 = require("@paperback/types"); const BatoToParser_1 = require("./BatoToParser"); const BATO_DOMAIN = 'https://bato.to'; exports.BatoToInfo = { - version: '3.0.2', + version: '3.0.3', name: 'BatoTo', icon: 'icon.png', author: 'Nicholas', @@ -28810,7 +28821,7 @@ const parseChapterDetails = ($, mangaId, chapterId) => { const script = scriptObj?.children[0]?.data ?? ''; const batoPass = eval(script.match(/const\s+batoPass\s*=\s*(.*?);/)?.[1] ?? '').toString(); const batoWord = (script.match(/const\s+batoWord\s*=\s*"(.*)";/)?.[1] ?? ''); - const imgList = JSON.parse(script.match(/const\s+imgHttpLis\s*=\s*(.*?);/)?.[1] ?? ''); + const imgList = JSON.parse(script.match(/const\s+imgHttps\s*=\s*(.*?);/)?.[1] ?? ''); const tknList = JSON.parse(CryptoJS.AES.decrypt(batoWord, batoPass).toString(CryptoJS.enc.Utf8)); for (let i = 0; i < Math.min(imgList.length, tknList.length); i++) { pages.push(`${imgList[i]}?${tknList[i]}`); diff --git a/0.8/versioning.json b/0.8/versioning.json index f3f8d4b..362c437 100644 --- a/0.8/versioning.json +++ b/0.8/versioning.json @@ -1 +1 @@ -{"buildTime":"2023-10-12T18:42:52.884Z","sources":[{"id":"BatoTo","name":"BatoTo","author":"Nicholas","desc":"Extension that pulls manga from bato.to","website":"https://github.com/niclimcy","contentRating":"MATURE","version":"3.0.2","icon":"icon.png","tags":[],"websiteBaseURL":"https://bato.to","intents":21},{"id":"Hentai2Read","name":"Hentai2Read","author":"EmZedH","desc":"Extension that pulls manga from hentai2read.com","website":"https://github.com/EmZedH","contentRating":"ADULT","version":"1.0.0","icon":"icon.png","tags":[{"text":"18+","type":"warning"}],"websiteBaseURL":"https://hentai2read.com","intents":5},{"id":"MangaDex","name":"MangaDex","author":"Nar1n & Netsky","desc":"Extension that pulls manga from MangaDex","website":"https://github.com/nar1n","contentRating":"EVERYONE","version":"3.0.2","icon":"icon.png","tags":[],"websiteBaseURL":"https://mangadex.org","intents":37},{"id":"MangaPlus","name":"MangaPlus","author":"Rinto-kun","desc":"Extension that pulls manga from Manga+ by Shueisha","website":"https://github.com/Rinto-kun","contentRating":"EVERYONE","version":"2.0.1","icon":"icon.png","tags":[],"websiteBaseURL":"https://mangaplus.shueisha.co.jp","intents":53},{"id":"NHentai","name":"nhentai","author":"NotMarek & Netsky","desc":"Extension which pulls content from nHentai.","website":"https://github.com/TheNetsky","contentRating":"ADULT","version":"4.0.6","icon":"icon.png","tags":[{"text":"18+","type":"warning"}],"websiteBaseURL":"https://nhentai.net","intents":53}],"builtWith":{"toolchain":"0.8.0-alpha.47","types":"0.8.0-alpha.47"}} \ No newline at end of file +{"buildTime":"2024-01-07T16:57:18.840Z","sources":[{"id":"BatoTo","name":"BatoTo","author":"Nicholas","desc":"Extension that pulls manga from bato.to","website":"https://github.com/niclimcy","contentRating":"MATURE","version":"3.0.3","icon":"icon.png","tags":[],"websiteBaseURL":"https://bato.to","intents":21},{"id":"Hentai2Read","name":"Hentai2Read","author":"EmZedH","desc":"Extension that pulls manga from hentai2read.com","website":"https://github.com/EmZedH","contentRating":"ADULT","version":"1.0.0","icon":"icon.png","tags":[{"text":"18+","type":"warning"}],"websiteBaseURL":"https://hentai2read.com","intents":5},{"id":"MangaDex","name":"MangaDex","author":"Nar1n & Netsky","desc":"Extension that pulls manga from MangaDex","website":"https://github.com/nar1n","contentRating":"EVERYONE","version":"3.0.2","icon":"icon.png","tags":[],"websiteBaseURL":"https://mangadex.org","intents":37},{"id":"MangaPlus","name":"MangaPlus","author":"Rinto-kun","desc":"Extension that pulls manga from Manga+ by Shueisha","website":"https://github.com/Rinto-kun","contentRating":"EVERYONE","version":"2.0.1","icon":"icon.png","tags":[],"websiteBaseURL":"https://mangaplus.shueisha.co.jp","intents":53},{"id":"NHentai","name":"nhentai","author":"NotMarek & Netsky","desc":"Extension which pulls content from nHentai.","website":"https://github.com/TheNetsky","contentRating":"ADULT","version":"4.0.6","icon":"icon.png","tags":[{"text":"18+","type":"warning"}],"websiteBaseURL":"https://nhentai.net","intents":53}],"builtWith":{"toolchain":"0.8.0-alpha.47","types":"0.8.0-alpha.47"}} \ No newline at end of file