diff --git a/README.md b/README.md
index 8b28b04..6162248 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ Either host `dist/web-crypto.js` yourself or use jsDelivr like this:
```html
```
-*You can use `window.WebCrypto` to access the API after installing.*
+*You can use `globalThis.WebCrypto` to access the API after installing.*
# Usage
@@ -42,7 +42,7 @@ that accepts `P-256`, `P-384`, and `P-521` (defaults to `P-256`).
```js
// Assuming you have loaded the easy-web-crypto library in your HTML file
-const WebCrypto = window.WebCrypto
+const WebCrypto = globalThis.WebCrypto
// generate an ECDA P-256 key pair
const keyPair = await WebCrypto.genKeyPair()
diff --git a/dist/cjs/web-crypto.js b/dist/cjs/web-crypto.js
index e79ba19..32c7366 100644
--- a/dist/cjs/web-crypto.js
+++ b/dist/cjs/web-crypto.js
@@ -1,403 +1,3 @@
-"use strict";
-/**
- * Originally from https://github.com/QwantResearch/masq-common/
- * with improvements by Andrei Sambra
- */
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports._genRandomBufferAsStr = exports._genRandomBuffer = exports.updatePassphraseKey = exports.decryptMasterKey = exports.genEncryptedMasterKey = exports.decryptBuffer = exports.encryptBuffer = exports.decrypt = exports.encrypt = exports.exportKey = exports.importKey = exports.genAESKey = exports.verify = exports.sign = exports.exportPrivateKey = exports.exportPublicKey = exports.importPrivateKey = exports.importPublicKey = exports.genKeyPair = exports.hash = exports.genId = void 0;
-const buffer_1 = require("buffer");
-const checkCryptokey = (key) => {
- if (!key.type || key.type !== 'secret') {
- throw new Error('Invalid key type');
- }
-};
-const genRandomBuffer = (len = 16) => {
- const values = window.crypto.getRandomValues(new Uint8Array(len));
- return buffer_1.Buffer.from(values);
-};
-const genRandomBufferAsStr = (len = 16, encodingFormat = 'hex') => {
- if (encodingFormat) {
- checkEncodingFormat(encodingFormat);
- }
- const buf = genRandomBuffer(len);
- return buf.toString(encodingFormat);
-};
-const checkPassphrase = (str) => {
- if (typeof str !== 'string' || str === '') {
- throw new Error(`Not a valid value`);
- }
-};
-const checkEncodingFormat = (format) => {
- if (format !== 'hex' && format !== 'base64')
- throw new Error('Invalid encoding');
-};
-/**
- * Generate a random hexadecimal ID of a given length
- *
- * @param {integer} [len] The string length of the new ID
- * @returns {string} The new ID
- */
-const genId = (len = 32) => {
- // 2 bytes for each char
- return genRandomBufferAsStr(Math.floor(len / 2));
-};
-exports.genId = genId;
-/**
- * Generate the hash of a string or ArrayBuffer
- *
- * @param {string | arrayBuffer} data The message
- * @param {string} [format] The encoding format ('hex' by default, can also be 'base64')
- * @param {string} [name] The hashing algorithm (SHA-256 by default)
- * @returns {Promise} A promise that contains the hash as a String encoded with encodingFormat
- */
-const hash = (data, format = 'hex', name = 'SHA-256') => __awaiter(void 0, void 0, void 0, function* () {
- const digest = yield window.crypto.subtle.digest({
- name
- }, (typeof data === 'string') ? buffer_1.Buffer.from(data) : data);
- return buffer_1.Buffer.from(digest).toString(format);
-});
-exports.hash = hash;
-/**
- * Generate an ECDA key pair based on the provided curve name
- *
- * @param {boolean} extractable - Specify if the generated key is extractable
- * @param {namedCurve} namedCurve - The curve name to use
- * @returns {Promise} - A promise containing the key pair
- */
-const genKeyPair = (extractable = true, namedCurve = 'P-256') => {
- return window.crypto.subtle.generateKey({
- name: 'ECDSA',
- namedCurve // can be "P-256", "P-384", or "P-521"
- }, extractable, ['sign', 'verify']);
-};
-exports.genKeyPair = genKeyPair;
-function importPublicKey(key, namedCurve = 'P-256', format = 'base64') {
- return window.crypto.subtle.importKey('spki', typeof key === 'string' ? buffer_1.Buffer.from(key, format) : key, {
- name: 'ECDSA',
- namedCurve // can be "P-256", "P-384", or "P-521"
- }, true, ['verify']);
-}
-exports.importPublicKey = importPublicKey;
-function importPrivateKey(key, namedCurve = 'P-256', format = 'base64') {
- return window.crypto.subtle.importKey('pkcs8', typeof key === 'string' ? buffer_1.Buffer.from(key, format) : key, {
- name: 'ECDSA',
- namedCurve // can be "P-256", "P-384", or "P-521"
- }, true, ['sign']);
-}
-exports.importPrivateKey = importPrivateKey;
-function exportPublicKey(key, format = 'base64') {
- return __awaiter(this, void 0, void 0, function* () {
- const exported = yield window.crypto.subtle.exportKey('spki', key);
- return (format === 'raw') ? new Uint8Array(exported) : buffer_1.Buffer.from(exported).toString(format);
- });
-}
-exports.exportPublicKey = exportPublicKey;
-function exportPrivateKey(key, format = 'base64') {
- return __awaiter(this, void 0, void 0, function* () {
- const exported = yield window.crypto.subtle.exportKey('pkcs8', key);
- return (format === 'raw') ? new Uint8Array(exported) : buffer_1.Buffer.from(exported).toString(format);
- });
-}
-exports.exportPrivateKey = exportPrivateKey;
-/**
- * Sign data using the private key
- *
- * @param {CryptoKey} key - The private key
- * @param {*} data - Data to sign
- * @param {*} hash - The hashing algorithm
- * @returns {Promise} - The raw signature
- */
-const sign = (key, data, format = 'base64', hash = 'SHA-256') => __awaiter(void 0, void 0, void 0, function* () {
- const signature = yield window.crypto.subtle.sign({
- name: 'ECDSA',
- hash: { name: hash } // can be "SHA-1", "SHA-256", "SHA-384", or "SHA-512"
- }, key, buffer_1.Buffer.from(typeof data === "string" ? data : JSON.stringify(data)));
- return (format === 'raw') ? new Uint8Array(signature) : buffer_1.Buffer.from(signature).toString(format);
-});
-exports.sign = sign;
-/**
- * Verify data using the public key
- *
- * @param {CryptoKey} key - The public key
- * @param {*} data - Data to verify
- * @param {*} hash - The hashing algorithm
- * @returns {Promise} - The verification outcome
- */
-const verify = (key, data, signature, format = 'base64', hash = 'SHA-256') => __awaiter(void 0, void 0, void 0, function* () {
- return window.crypto.subtle.verify({
- name: 'ECDSA',
- hash: { name: hash } // can be "SHA-1", "SHA-256", "SHA-384", or "SHA-512"
- }, key, buffer_1.Buffer.from(signature, format), buffer_1.Buffer.from(typeof data === "string" ? data : JSON.stringify(data)));
-});
-exports.verify = verify;
-/**
- * Generate an AES key based on the cipher mode and keysize
- *
- * @param {boolean} [extractable] - Specify if the generated key is extractable
- * @param {string} [mode] - The aes mode of the generated key
- * @param {Number} [keySize] - Specify if the generated key is extractable
- * @returns {Promise} - The generated AES key.
- */
-const genAESKey = (extractable = true, mode = 'AES-GCM', keySize = 128) => {
- return window.crypto.subtle.generateKey({
- name: mode,
- length: keySize
- }, extractable, ['decrypt', 'encrypt']);
-};
-exports.genAESKey = genAESKey;
-/**
- * Import a raw|jwk as a CryptoKey
- *
- * @param {arrayBuffer|Object} key - The key
- * @param {string} [type] - The type of the key to import ('raw', 'jwk')
- * @param {string} [mode] - The mode of the key to import (default 'AES-GCM')
- * @returns {Promise} - The cryptoKey
- */
-const importKey = (key, type = 'raw', mode = 'AES-GCM') => {
- const parsedKey = (type === 'raw') ? buffer_1.Buffer.from(key, 'base64') : key;
- return window.crypto.subtle.importKey(type, parsedKey, { name: mode }, true, ['encrypt', 'decrypt']);
-};
-exports.importKey = importKey;
-/**
- * Export a CryptoKey into a raw|jwk key
- *
- * @param {CryptoKey} key - The CryptoKey
- * @param {string} [type] - The type of the exported key: raw|jwk
- * @returns {Promise} - The raw key or the key as a jwk format
- */
-const exportKey = (key, type = 'raw') => __awaiter(void 0, void 0, void 0, function* () {
- const exportedKey = yield window.crypto.subtle.exportKey(type, key);
- return (type === 'raw') ? new Uint8Array(exportedKey) : exportedKey;
-});
-exports.exportKey = exportKey;
-/**
- * Encrypt buffer
- *
- * @param {ArrayBuffer} key - The AES CryptoKey
- * @param {ArrayBuffer} data - Data to encrypt
- * @param {Object} cipherContext - The AES cipher parameters
- * @returns {ArrayBuffer} - The encrypted buffer
- */
-const encryptBuffer = (key, data, cipherContext) => __awaiter(void 0, void 0, void 0, function* () {
- const encrypted = yield window.crypto.subtle.encrypt(cipherContext, key, data);
- return new Uint8Array(encrypted);
-});
-exports.encryptBuffer = encryptBuffer;
-/**
- * Decrypt buffer
- * @param {ArrayBuffer} key - The AES CryptoKey
- * @param {ArrayBuffer} data - Data to decrypt
- * @param {Object} cipherContext - The AES cipher parameters
- * @returns {Promise} - The decrypted buffer
- */
-const decryptBuffer = (key, data, cipherContext) => __awaiter(void 0, void 0, void 0, function* () {
- // TODO: test input params
- try {
- const decrypted = yield window.crypto.subtle.decrypt(cipherContext, key, data);
- return new Uint8Array(decrypted);
- }
- catch (e) {
- if (e instanceof Error && e.message === 'Unsupported state or unable to authenticate data') {
- throw new Error('Unable to decrypt data');
- }
- else if (typeof e === 'string') {
- throw new Error(e);
- }
- }
-});
-exports.decryptBuffer = decryptBuffer;
-/**
- * Encrypt data
- *
- * @param {CryptoKey} key - The AES CryptoKey
- * @param {string | Object} - The data to encrypt
- * @param {string} [format] - The ciphertext and iv encoding format
- * @returns {Object} - The stringified ciphertext object (ciphertext and iv)
- */
-const encrypt = (key, data, format = 'hex') => __awaiter(void 0, void 0, void 0, function* () {
- checkCryptokey(key);
- const context = {
- iv: genRandomBuffer(key.algorithm.name === 'AES-GCM' ? 12 : 16),
- plaintext: buffer_1.Buffer.from(JSON.stringify(data))
- };
- // Prepare cipher context, depends on cipher mode
- const cipherContext = {
- name: key.algorithm.name,
- iv: context.iv
- };
- const encrypted = yield encryptBuffer(key, context.plaintext, cipherContext);
- return {
- ciphertext: buffer_1.Buffer.from(encrypted).toString(format),
- iv: buffer_1.Buffer.from(context.iv).toString(format)
- };
-});
-exports.encrypt = encrypt;
-/**
- * Decrypt data
- *
- * @param {CryptoKey} key - The AES CryptoKey
- * @param {string | Object} - The data to decrypt
- * @param {string} [format] - The ciphertext and iv encoding format
- */
-const decrypt = (key, ciphertext, format = 'hex') => __awaiter(void 0, void 0, void 0, function* () {
- checkCryptokey(key);
- const context = {
- ciphertext: buffer_1.Buffer.from(Object.prototype.hasOwnProperty.call(ciphertext, 'ciphertext') ? ciphertext.ciphertext : '', (format)),
- // IV is 128 bits long === 16 bytes
- iv: Object.prototype.hasOwnProperty.call(ciphertext, 'iv') ? buffer_1.Buffer.from(ciphertext.iv, (format)) : ''
- };
- // Prepare cipher context, depends on cipher mode
- const cipherContext = {
- name: key.algorithm.name,
- iv: context.iv
- };
- try {
- const decrypted = yield decryptBuffer(key, context.ciphertext, cipherContext);
- if (decrypted === undefined) {
- throw new Error();
- }
- return JSON.parse(buffer_1.Buffer.from(decrypted).toString());
- }
- catch (error) {
- throw new Error('Unable to decrypt data');
- }
-});
-exports.decrypt = decrypt;
-/**
- * Generate a PBKDF2 derived key (bits) based on user given passPhrase
- *
- * @param {string | arrayBuffer} passPhrase The passphrase that is used to derive the key
- * @param {arrayBuffer} [salt] The salt
- * @param {Number} [iterations] The iterations number
- * @param {string} [hashAlgo] The hash function used for derivation
- * @returns {Promise} A promise that contains the derived key
- */
-const deriveBits = (passPhrase, salt, iterations, hashAlgo) => __awaiter(void 0, void 0, void 0, function* () {
- // Always specify a strong salt
- if (iterations < 10000) {
- console.warn('Less than 10000 :(');
- }
- const baseKey = yield window.crypto.subtle.importKey('raw', (typeof passPhrase === 'string') ? buffer_1.Buffer.from(passPhrase) : passPhrase, 'PBKDF2', false, ['deriveBits', 'deriveKey']);
- const derivedKey = yield window.crypto.subtle.deriveBits({
- name: 'PBKDF2',
- salt: salt || new Uint8Array([]),
- iterations: iterations || 100000,
- hash: hashAlgo || 'SHA-256'
- }, baseKey, 128);
- return new Uint8Array(derivedKey);
-});
-/**
- * Derive a key based on a given passphrase
- *
- * @param {string} passPhrase The passphrase that is used to derive the key
- * @param {arrayBuffer} [salt] The salt
- * @param {Number} [iterations] The iterations number
- * @param {string} [hashAlgo] The hash function used for derivation and final hash computing
- * @returns {Promise} A promise that contains the derived key and derivation
- * parameters
- */
-const deriveKeyFromPassphrase = (passPhrase, salt = genRandomBuffer(16), iterations = 100000, hashAlgo = 'SHA-256') => __awaiter(void 0, void 0, void 0, function* () {
- checkPassphrase(passPhrase);
- const derivedKey = yield deriveBits(passPhrase, salt, iterations, hashAlgo);
- const key = yield importKey(derivedKey);
- return {
- derivationParams: {
- salt: buffer_1.Buffer.from(salt).toString('hex'),
- iterations,
- hashAlgo
- },
- key
- };
-});
-/**
- * Derive the passphrase with PBKDF2 to obtain a KEK
- * Generate a AES key (masterKey)
- * Encrypt the masterKey with the KEK
- *
- * @param {string} passPhrase The passphrase that is used to derive the key
- * @param {arrayBuffer} [salt] The salt
- * @param {Number} [iterations] The iterations number
- * @param {string} [hashAlgo] The hash function used for derivation and final hash computing
- * @returns {Promise} A promise that contains the encrypted derived key
- */
-const genEncryptedMasterKey = (passPhrase, salt, iterations, hashAlgo) => __awaiter(void 0, void 0, void 0, function* () {
- // derive key encryption key from passphrase
- const keyEncryptionKey = yield deriveKeyFromPassphrase(passPhrase, salt, iterations, hashAlgo);
- // Generate the masterKey
- const masterKey = genRandomBufferAsStr(32, 'hex');
- const encryptedMasterKey = yield encrypt(keyEncryptionKey.key, masterKey);
- return {
- derivationParams: keyEncryptionKey.derivationParams,
- encryptedMasterKey
- };
-});
-exports.genEncryptedMasterKey = genEncryptedMasterKey;
-/**
- * Update the derived encryption key (KEK) based on the new passphrase from user, while retaining
- * the symmetric key that encrypts data at rest
- *
- * @param {string} currentPassPhrase The current (old) passphrase that is used to derive the key
- * @param {string} newPassPhrase The new passphrase that will be used to derive the key
- * @param {oldMasterKey} oldMasterKey - The old object returned by genEncryptedMasterKey for the old passphrase
- * @param {arrayBuffer} [salt] The salt
- * @param {Number} [iterations] The iterations number
- * @param {string} [hashAlgo] The hash function used for derivation and final hash computing
- * @returns {Promise}
- */
-const updatePassphraseKey = (currentPassPhrase, newPassPhrase, oldMasterKey, salt, iterations, hashAlgo) => __awaiter(void 0, void 0, void 0, function* () {
- const masterKey = yield decryptMasterKey(currentPassPhrase, oldMasterKey);
- // derive a new key encryption key from newPassPhrase
- const keyEncryptionKey = yield deriveKeyFromPassphrase(newPassPhrase, salt, iterations, hashAlgo);
- // enconde existing masterKey as a hex string since it's a buffer
- const toBeEncryptedMasterKey = buffer_1.Buffer.from(yield exportKey(masterKey)).toString('hex');
- const encryptedMasterKey = yield encrypt(keyEncryptionKey.key, toBeEncryptedMasterKey);
- return {
- derivationParams: keyEncryptionKey.derivationParams,
- encryptedMasterKey
- };
-});
-exports.updatePassphraseKey = updatePassphraseKey;
-/**
- * Decrypt a master key by deriving the encryption key from the
- * provided passphrase and encrypted master key.
- *
- * @param {string | arrayBuffer} passPhrase The passphrase that is used to derive the key
- * @param {protectedMasterKey} protectedMasterKey - The same object returned
- * by genEncryptedMasterKey
- * @returns {Promise} A promise that contains the masterKey
- */
-const decryptMasterKey = (passPhrase, protectedMasterKey) => __awaiter(void 0, void 0, void 0, function* () {
- if (!protectedMasterKey.encryptedMasterKey ||
- !protectedMasterKey.derivationParams) {
- throw new Error('Missing properties from master key');
- }
- const { derivationParams, encryptedMasterKey } = protectedMasterKey;
- const { salt, iterations, hashAlgo } = derivationParams;
- const _salt = typeof (salt) === 'string' ? buffer_1.Buffer.from(salt, ('hex')) : salt;
- const derivedKey = yield deriveBits(passPhrase, _salt, iterations, hashAlgo);
- const keyEncryptionKey = yield importKey(derivedKey);
- try {
- const decryptedMasterKeyHex = yield decrypt(keyEncryptionKey, encryptedMasterKey);
- // return decryptedMasterKeyHex
- const parsedKey = buffer_1.Buffer.from(decryptedMasterKeyHex, 'hex');
- return window.crypto.subtle.importKey('raw', parsedKey, { name: 'AES-GCM' }, true, ['encrypt', 'decrypt']);
- }
- catch (error) {
- throw new Error('Wrong passphrase');
- }
-});
-exports.decryptMasterKey = decryptMasterKey;
-const _genRandomBuffer = genRandomBuffer;
-exports._genRandomBuffer = _genRandomBuffer;
-const _genRandomBufferAsStr = genRandomBufferAsStr;
-exports._genRandomBufferAsStr = _genRandomBufferAsStr;
+/*! For license information please see web-crypto.js.LICENSE.txt */
+!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("WebCrypto",[],e):"object"==typeof exports?exports.WebCrypto=e():t.WebCrypto=e()}(self,(()=>(()=>{var t={742:(t,e)=>{"use strict";e.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,i=s(t),f=i[0],u=i[1],h=new o(function(t,e,r){return 3*(e+r)/4-r}(0,f,u)),a=0,c=u>0?f-4:f;for(r=0;r>16&255,h[a++]=e>>8&255,h[a++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,h[a++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,h[a++]=e>>8&255,h[a++]=255&e),h},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,i=[],f=16383,s=0,h=n-o;sh?h:s+f));return 1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0;f<64;++f)r[f]=i[f],n[i.charCodeAt(f)]=f;function s(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var o,i,f=[],s=e;s>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return f.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},764:(t,e,r)=>{"use strict";const n=r(742),o=r(645),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.lW=u,e.h2=50;const f=2147483647;function s(t){if(t>f)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return h(t,e,r)}function h(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|g(t,e);let n=s(r);const o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(V(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(V(t,ArrayBuffer)||t&&V(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(V(t,SharedArrayBuffer)||t&&V(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const o=function(t){if(u.isBuffer(t)){const e=0|y(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||q(t.length)?s(0):l(t):"Buffer"===t.type&&Array.isArray(t.data)?l(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return a(t),s(t<0?0:0|y(t))}function l(t){const e=t.length<0?0:0|y(t.length),r=s(e);for(let n=0;n=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return 0|t}function g(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||V(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(t).length;default:if(o)return n?-1:Y(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return O(this,e,r);case"latin1":case"binary":return R(this,e,r);case"base64":return I(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function w(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),q(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,o){let i,f=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;f=2,s/=2,u/=2,r/=2}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(o){let n=-1;for(i=r;is&&(r=s-u),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=e.length;let f;for(n>i/2&&(n=i/2),f=0;f>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function I(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o239?4:e>223?3:e>191?2:1;if(o+f<=r){let r,n,s,u;switch(f){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(i=u));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:r=t[o+1],n=t[o+2],s=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,f=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=f}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e.buffer,e.byteOffset,e.byteLength)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},u.byteLength=g,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(V(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0);const s=Math.min(i,f),h=this.slice(n,o),a=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return B(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function O(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;on)&&(r=n);let o="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,r,n,o,i){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function M(t,e,r,n,o){F(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function _(t,e,r,n,o){F(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function W(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function $(t,e,r,n,i){return e=+e,r>>>=0,i||W(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,i){return e=+e,r>>>=0,i||W(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||P(t,e,this.length);let n=this[t],o=1,i=0;for(;++i>>=0,e>>>=0,r||P(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Q((function(t){D(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||P(t,e,this.length);let n=this[t],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},u.prototype.readInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||P(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||P(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Q((function(t){D(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||P(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||P(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||P(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||P(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||C(this,t,e,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n||C(this,t,e,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Q((function(t,e=0){return M(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Q((function(t,e=0){return _(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n)}let o=0,i=1,f=0;for(this[e]=255&t;++o>0)-f&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n)}let o=r-1,i=1,f=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===f&&0!==this[e+o+1]&&(f=1),this[e+o]=(t/i>>0)-f&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Q((function(t,e=0){return M(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Q((function(t,e=0){return _(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return $(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return $(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function F(t,e,r,n,o,i){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new K.ERR_OUT_OF_RANGE("value",o,t)}!function(t,e,r){D(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||G(e,t.length-(r+1))}(n,o,i)}function D(t,e){if("number"!=typeof t)throw new K.ERR_INVALID_ARG_TYPE(e,"number",t)}function G(t,e,r){if(Math.floor(t)!==t)throw D(t,r),new K.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new K.ERR_BUFFER_OUT_OF_BOUNDS;throw new K.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}k("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),k("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),k("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=j(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=j(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const z=/[^+/0-9A-Za-z-_]/g;function Y(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let f=0;f55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(z,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,e,r,n){let o;for(o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function V(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function q(t){return t!=t}const Z=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function Q(t){return"undefined"==typeof BigInt?X:t}function X(){throw new Error("BigInt not supported")}},645:(t,e)=>{e.read=function(t,e,r,n,o){var i,f,s=8*o-n-1,u=(1<>1,a=-7,c=r?o-1:0,l=r?-1:1,p=t[e+c];for(c+=l,i=p&(1<<-a)-1,p>>=-a,a+=s;a>0;i=256*i+t[e+c],c+=l,a-=8);for(f=i&(1<<-a)-1,i>>=-a,a+=n;a>0;f=256*f+t[e+c],c+=l,a-=8);if(0===i)i=1-h;else{if(i===u)return f?NaN:1/0*(p?-1:1);f+=Math.pow(2,n),i-=h}return(p?-1:1)*f*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var f,s,u,h=8*i-o-1,a=(1<>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,f=a):(f=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-f))<1&&(f--,u*=2),(e+=f+c>=1?l/u:l*Math.pow(2,1-c))*u>=2&&(f++,u/=2),f+c>=a?(s=0,f=a):f+c>=1?(s=(e*u-1)*Math.pow(2,o),f+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,o),f=0));o>=8;t[r+p]=255&s,p+=y,s/=256,o-=8);for(f=f<0;t[r+p]=255&f,p+=y,f/=256,h-=8);t[r+p-y]|=128*g}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{_genRandomBuffer:()=>R,_genRandomBufferAsStr:()=>x,decrypt:()=>A,decryptBuffer:()=>E,decryptMasterKey:()=>O,encrypt:()=>B,encryptBuffer:()=>v,exportKey:()=>m,exportPrivateKey:()=>y,exportPublicKey:()=>p,genAESKey:()=>w,genEncryptedMasterKey:()=>S,genId:()=>u,genKeyPair:()=>a,hash:()=>h,importKey:()=>b,importPrivateKey:()=>l,importPublicKey:()=>c,sign:()=>g,updatePassphraseKey:()=>T,verify:()=>d});var t=r(764),e=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function f(t){try{u(n.next(t))}catch(t){i(t)}}function s(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(f,s)}u((n=n.apply(t,e||[])).next())}))};const o=t=>{if(!t.type||"secret"!==t.type)throw new Error("Invalid key type")},i=(e=16)=>{const r=globalThis.crypto.getRandomValues(new Uint8Array(e));return t.lW.from(r)},f=(t=16,e="hex")=>(e&&s(e),i(t).toString(e)),s=t=>{if("hex"!==t&&"base64"!==t)throw new Error("Invalid encoding")},u=(t=32)=>f(Math.floor(t/2)),h=(r,n="hex",o="SHA-256")=>e(void 0,void 0,void 0,(function*(){const e=yield globalThis.crypto.subtle.digest({name:o},"string"==typeof r?t.lW.from(r):r);return t.lW.from(e).toString(n)})),a=(t=!0,e="P-256")=>globalThis.crypto.subtle.generateKey({name:"ECDSA",namedCurve:e},t,["sign","verify"]);function c(e,r="P-256",n="base64"){return globalThis.crypto.subtle.importKey("spki","string"==typeof e?t.lW.from(e,n):e,{name:"ECDSA",namedCurve:r},!0,["verify"])}function l(e,r="P-256",n="base64"){return globalThis.crypto.subtle.importKey("pkcs8","string"==typeof e?t.lW.from(e,n):e,{name:"ECDSA",namedCurve:r},!0,["sign"])}function p(r,n="base64"){return e(this,void 0,void 0,(function*(){const e=yield globalThis.crypto.subtle.exportKey("spki",r);return"raw"===n?new Uint8Array(e):t.lW.from(e).toString(n)}))}function y(r,n="base64"){return e(this,void 0,void 0,(function*(){const e=yield globalThis.crypto.subtle.exportKey("pkcs8",r);return"raw"===n?new Uint8Array(e):t.lW.from(e).toString(n)}))}const g=(r,n,o="base64",i="SHA-256")=>e(void 0,void 0,void 0,(function*(){const e=yield globalThis.crypto.subtle.sign({name:"ECDSA",hash:{name:i}},r,t.lW.from("string"==typeof n?n:JSON.stringify(n)));return"raw"===o?new Uint8Array(e):t.lW.from(e).toString(o)})),d=(r,n,o,i="base64",f="SHA-256")=>e(void 0,void 0,void 0,(function*(){return globalThis.crypto.subtle.verify({name:"ECDSA",hash:{name:f}},r,t.lW.from(o,i),t.lW.from("string"==typeof n?n:JSON.stringify(n)))})),w=(t=!0,e="AES-GCM",r=128)=>globalThis.crypto.subtle.generateKey({name:e,length:r},t,["decrypt","encrypt"]),b=(e,r="raw",n="AES-GCM")=>{const o="raw"===r?t.lW.from(e,"base64"):e;return globalThis.crypto.subtle.importKey(r,o,{name:n},!0,["encrypt","decrypt"])},m=(t,r="raw")=>e(void 0,void 0,void 0,(function*(){const e=yield globalThis.crypto.subtle.exportKey(r,t);return"raw"===r?new Uint8Array(e):e})),v=(t,r,n)=>e(void 0,void 0,void 0,(function*(){const e=yield globalThis.crypto.subtle.encrypt(n,t,r);return new Uint8Array(e)})),E=(t,r,n)=>e(void 0,void 0,void 0,(function*(){try{const e=yield globalThis.crypto.subtle.decrypt(n,t,r);return new Uint8Array(e)}catch(t){if(t instanceof Error&&"Unsupported state or unable to authenticate data"===t.message)throw new Error("Unable to decrypt data");if("string"==typeof t)throw new Error(t)}})),B=(r,n,f="hex")=>e(void 0,void 0,void 0,(function*(){o(r);const e={iv:i("AES-GCM"===r.algorithm.name?12:16),plaintext:t.lW.from(JSON.stringify(n))},s={name:r.algorithm.name,iv:e.iv},u=yield v(r,e.plaintext,s);return{ciphertext:t.lW.from(u).toString(f),iv:t.lW.from(e.iv).toString(f)}})),A=(r,n,i="hex")=>e(void 0,void 0,void 0,(function*(){o(r);const e={ciphertext:t.lW.from(Object.prototype.hasOwnProperty.call(n,"ciphertext")?n.ciphertext:"",i),iv:Object.prototype.hasOwnProperty.call(n,"iv")?t.lW.from(n.iv,i):""},f={name:r.algorithm.name,iv:e.iv};try{const n=yield E(r,e.ciphertext,f);if(void 0===n)throw new Error;return JSON.parse(t.lW.from(n).toString())}catch(t){throw new Error("Unable to decrypt data")}})),U=(r,n,o,i)=>e(void 0,void 0,void 0,(function*(){o<1e4&&console.warn("Less than 10000 :(");const e=yield globalThis.crypto.subtle.importKey("raw","string"==typeof r?t.lW.from(r):r,"PBKDF2",!1,["deriveBits","deriveKey"]),f=yield globalThis.crypto.subtle.deriveBits({name:"PBKDF2",salt:n||new Uint8Array([]),iterations:o||1e5,hash:i||"SHA-256"},e,128);return new Uint8Array(f)})),I=(r,n=i(16),o=1e5,f="SHA-256")=>e(void 0,void 0,void 0,(function*(){(t=>{if("string"!=typeof t||""===t)throw new Error("Not a valid value")})(r);const e=yield U(r,n,o,f),i=yield b(e);return{derivationParams:{salt:t.lW.from(n).toString("hex"),iterations:o,hashAlgo:f},key:i}})),S=(t,r,n,o)=>e(void 0,void 0,void 0,(function*(){const e=yield I(t,r,n,o),i=f(32,"hex"),s=yield B(e.key,i);return{derivationParams:e.derivationParams,encryptedMasterKey:s}})),T=(r,n,o,i,f,s)=>e(void 0,void 0,void 0,(function*(){const e=yield O(r,o),u=yield I(n,i,f,s),h=t.lW.from(yield m(e)).toString("hex"),a=yield B(u.key,h);return{derivationParams:u.derivationParams,encryptedMasterKey:a}})),O=(r,n)=>e(void 0,void 0,void 0,(function*(){if(!n.encryptedMasterKey||!n.derivationParams)throw new Error("Missing properties from master key");const{derivationParams:e,encryptedMasterKey:o}=n,{salt:i,iterations:f,hashAlgo:s}=e,u="string"==typeof i?t.lW.from(i,"hex"):i,h=yield U(r,u,f,s),a=yield b(h);try{const e=yield A(a,o),r=t.lW.from(e,"hex");return globalThis.crypto.subtle.importKey("raw",r,{name:"AES-GCM"},!0,["encrypt","decrypt"])}catch(t){throw new Error("Wrong passphrase")}})),R=i,x=f})(),n})()));
//# sourceMappingURL=web-crypto.js.map
\ No newline at end of file
diff --git a/dist/cjs/web-crypto.js.map b/dist/cjs/web-crypto.js.map
index d50836c..a540a8b 100644
--- a/dist/cjs/web-crypto.js.map
+++ b/dist/cjs/web-crypto.js.map
@@ -1 +1 @@
-{"version":3,"file":"web-crypto.js","sourceRoot":"","sources":["../../src/web-crypto.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,mCAAgC;AAkBhC,MAAM,cAAc,GAAG,CAAC,GAAc,E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B,CAAOlB,EAAoBoB,IAA2C,OAAD,6BAC5F,IAAKA,EAAmBP,qBACrBO,EAAmBX,iBACpB,MAAM,IAAIrX,MAAM,sCAElB,MAAM,iBAAEqX,EAAgB,mBAAEI,GAAuBO,GAC3C,KAAEnB,EAAI,WAAEC,EAAU,SAAEC,GAAaM,EACjCY,EAA0B,iBAAX,EAAsB,KAAO3W,KAAKuV,EAAM,OAAWA,EAClEK,QAAmBP,EAAWC,EAAYqB,EAAOnB,EAAYC,GAC7DQ,QAAyBzC,EAAUoC,GACzC,IACE,MAAMgB,QAA8B9B,EAAQmB,EAAkBE,GAExD7B,EAAY,KAAOtU,KAAK4W,EAAuB,OACrD,OAAOpE,WAAWC,OAAOS,OAAOM,UAAU,MAAOc,EAAW,CAAEtF,KAAM,YAChE,EAAM,CAAC,UAAW,YACtB,MAAOlI,GACP,MAAM,IAAIpI,MAAM,oBAEpB,IAEMmY,EAAmBvE,EACnBwE,EAAwBnE","sources":["webpack://WebCrypto/webpack/universalModuleDefinition","webpack://WebCrypto/./node_modules/base64-js/index.js","webpack://WebCrypto/./node_modules/buffer/index.js","webpack://WebCrypto/./node_modules/ieee754/index.js","webpack://WebCrypto/webpack/bootstrap","webpack://WebCrypto/webpack/runtime/define property getters","webpack://WebCrypto/webpack/runtime/hasOwnProperty shorthand","webpack://WebCrypto/webpack/runtime/make namespace object","webpack://WebCrypto/./src/web-crypto.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WebCrypto\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WebCrypto\"] = factory();\n\telse\n\t\troot[\"WebCrypto\"] = factory();\n})(self, () => {\nreturn ","'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nconst base64 = require('base64-js')\nconst ieee754 = require('ieee754')\nconst customInspectSymbol =\n (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation\n ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation\n : null\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nconst K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Print warning and recommend using `buffer` v4.x which has an Object\n * implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&\n typeof console.error === 'function') {\n console.error(\n 'This browser lacks typed array (Uint8Array) support which is required by ' +\n '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'\n )\n}\n\nfunction typedArraySupport () {\n // Can typed array instances can be augmented?\n try {\n const arr = new Uint8Array(1)\n const proto = { foo: function () { return 42 } }\n Object.setPrototypeOf(proto, Uint8Array.prototype)\n Object.setPrototypeOf(arr, proto)\n return arr.foo() === 42\n } catch (e) {\n return false\n }\n}\n\nObject.defineProperty(Buffer.prototype, 'parent', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.buffer\n }\n})\n\nObject.defineProperty(Buffer.prototype, 'offset', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.byteOffset\n }\n})\n\nfunction createBuffer (length) {\n if (length > K_MAX_LENGTH) {\n throw new RangeError('The value \"' + length + '\" is invalid for option \"size\"')\n }\n // Return an augmented `Uint8Array` instance\n const buf = new Uint8Array(length)\n Object.setPrototypeOf(buf, Buffer.prototype)\n return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new TypeError(\n 'The \"string\" argument must be of type string. Received type number'\n )\n }\n return allocUnsafe(arg)\n }\n return from(arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n if (typeof value === 'string') {\n return fromString(value, encodingOrOffset)\n }\n\n if (ArrayBuffer.isView(value)) {\n return fromArrayView(value)\n }\n\n if (value == null) {\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n }\n\n if (isInstance(value, ArrayBuffer) ||\n (value && isInstance(value.buffer, ArrayBuffer))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof SharedArrayBuffer !== 'undefined' &&\n (isInstance(value, SharedArrayBuffer) ||\n (value && isInstance(value.buffer, SharedArrayBuffer)))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof value === 'number') {\n throw new TypeError(\n 'The \"value\" argument must not be of type number. Received type number'\n )\n }\n\n const valueOf = value.valueOf && value.valueOf()\n if (valueOf != null && valueOf !== value) {\n return Buffer.from(valueOf, encodingOrOffset, length)\n }\n\n const b = fromObject(value)\n if (b) return b\n\n if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&\n typeof value[Symbol.toPrimitive] === 'function') {\n return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)\n }\n\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nObject.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)\nObject.setPrototypeOf(Buffer, Uint8Array)\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be of type number')\n } else if (size < 0) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n}\n\nfunction alloc (size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpreted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(size).fill(fill, encoding)\n : createBuffer(size).fill(fill)\n }\n return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n assertSize(size)\n return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n\n const length = byteLength(string, encoding) | 0\n let buf = createBuffer(length)\n\n const actual = buf.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n buf = buf.slice(0, actual)\n }\n\n return buf\n}\n\nfunction fromArrayLike (array) {\n const length = array.length < 0 ? 0 : checked(array.length) | 0\n const buf = createBuffer(length)\n for (let i = 0; i < length; i += 1) {\n buf[i] = array[i] & 255\n }\n return buf\n}\n\nfunction fromArrayView (arrayView) {\n if (isInstance(arrayView, Uint8Array)) {\n const copy = new Uint8Array(arrayView)\n return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)\n }\n return fromArrayLike(arrayView)\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\"offset\" is outside of buffer bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\"length\" is outside of buffer bounds')\n }\n\n let buf\n if (byteOffset === undefined && length === undefined) {\n buf = new Uint8Array(array)\n } else if (length === undefined) {\n buf = new Uint8Array(array, byteOffset)\n } else {\n buf = new Uint8Array(array, byteOffset, length)\n }\n\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(buf, Buffer.prototype)\n\n return buf\n}\n\nfunction fromObject (obj) {\n if (Buffer.isBuffer(obj)) {\n const len = checked(obj.length) | 0\n const buf = createBuffer(len)\n\n if (buf.length === 0) {\n return buf\n }\n\n obj.copy(buf, 0, 0, len)\n return buf\n }\n\n if (obj.length !== undefined) {\n if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {\n return createBuffer(0)\n }\n return fromArrayLike(obj)\n }\n\n if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n return fromArrayLike(obj.data)\n }\n}\n\nfunction checked (length) {\n // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= K_MAX_LENGTH) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return b != null && b._isBuffer === true &&\n b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false\n}\n\nBuffer.compare = function compare (a, b) {\n if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)\n if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError(\n 'The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array'\n )\n }\n\n if (a === b) return 0\n\n let x = a.length\n let y = b.length\n\n for (let i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!Array.isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n let i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n const buffer = Buffer.allocUnsafe(length)\n let pos = 0\n for (i = 0; i < list.length; ++i) {\n let buf = list[i]\n if (isInstance(buf, Uint8Array)) {\n if (pos + buf.length > buffer.length) {\n if (!Buffer.isBuffer(buf)) {\n buf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)\n }\n buf.copy(buffer, pos)\n } else {\n Uint8Array.prototype.set.call(\n buffer,\n buf,\n pos\n )\n }\n } else if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n } else {\n buf.copy(buffer, pos)\n }\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n throw new TypeError(\n 'The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. ' +\n 'Received type ' + typeof string\n )\n }\n\n const len = string.length\n const mustMatch = (arguments.length > 2 && arguments[2] === true)\n if (!mustMatch && len === 0) return 0\n\n // Use a for loop to avoid recursion\n let loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) {\n return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8\n }\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n let loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coercion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)\n// to detect a Buffer instance. It's not possible to use `instanceof Buffer`\n// reliably in a browserify context because there could be multiple different\n// copies of the 'buffer' package in use. This method works even for Buffer\n// instances that were created from another copy of the `buffer` package.\n// See: https://github.com/feross/buffer/issues/154\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n const i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n const len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (let i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n const len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (let i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n const len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (let i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n const length = this.length\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.toLocaleString = Buffer.prototype.toString\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n let str = ''\n const max = exports.INSPECT_MAX_BYTES\n str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()\n if (this.length > max) str += ' ... '\n return ''\n}\nif (customInspectSymbol) {\n Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (isInstance(target, Uint8Array)) {\n target = Buffer.from(target, target.offset, target.byteLength)\n }\n if (!Buffer.isBuffer(target)) {\n throw new TypeError(\n 'The \"target\" argument must be one of type Buffer or Uint8Array. ' +\n 'Received type ' + (typeof target)\n )\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n let x = thisEnd - thisStart\n let y = end - start\n const len = Math.min(x, y)\n\n const thisCopy = this.slice(thisStart, thisEnd)\n const targetCopy = target.slice(start, end)\n\n for (let i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (numberIsNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n let indexSize = 1\n let arrLength = arr.length\n let valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n let i\n if (dir) {\n let foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n let found = true\n for (let j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n const remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n const strLen = string.length\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n let i\n for (i = 0; i < length; ++i) {\n const parsed = parseInt(string.substr(i * 2, 2), 16)\n if (numberIsNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset >>> 0\n if (isFinite(length)) {\n length = length >>> 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n const remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n let loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n case 'latin1':\n case 'binary':\n return asciiWrite(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n const res = []\n\n let i = start\n while (i < end) {\n const firstByte = buf[i]\n let codePoint = null\n let bytesPerSequence = (firstByte > 0xEF)\n ? 4\n : (firstByte > 0xDF)\n ? 3\n : (firstByte > 0xBF)\n ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n let secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nconst MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n const len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n let res = ''\n let i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n let ret = ''\n end = Math.min(buf.length, end)\n\n for (let i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n let ret = ''\n end = Math.min(buf.length, end)\n\n for (let i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n const len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n let out = ''\n for (let i = start; i < end; ++i) {\n out += hexSliceLookupTable[buf[i]]\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n const bytes = buf.slice(start, end)\n let res = ''\n // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)\n for (let i = 0; i < bytes.length - 1; i += 2) {\n res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n const len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n const newBuf = this.subarray(start, end)\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(newBuf, Buffer.prototype)\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUintLE =\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let val = this[offset]\n let mul = 1\n let i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUintBE =\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n let val = this[offset + --byteLength]\n let mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUint8 =\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUint16LE =\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUint16BE =\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUint32LE =\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUint32BE =\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const lo = first +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 24\n\n const hi = this[++offset] +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n last * 2 ** 24\n\n return BigInt(lo) + (BigInt(hi) << BigInt(32))\n})\n\nBuffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const hi = first * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n this[++offset]\n\n const lo = this[++offset] * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n last\n\n return (BigInt(hi) << BigInt(32)) + BigInt(lo)\n})\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let val = this[offset]\n let mul = 1\n let i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let i = byteLength\n let mul = 1\n let val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n const val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n const val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const val = this[offset + 4] +\n this[offset + 5] * 2 ** 8 +\n this[offset + 6] * 2 ** 16 +\n (last << 24) // Overflow\n\n return (BigInt(val) << BigInt(32)) +\n BigInt(first +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 24)\n})\n\nBuffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const val = (first << 24) + // Overflow\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n this[++offset]\n\n return (BigInt(val) << BigInt(32)) +\n BigInt(this[++offset] * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n last)\n})\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUintLE =\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n let mul = 1\n let i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUintBE =\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n let i = byteLength - 1\n let mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUint8 =\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeUint16LE =\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeUint16BE =\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeUint32LE =\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeUint32BE =\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nfunction wrtBigUInt64LE (buf, value, offset, min, max) {\n checkIntBI(value, min, max, buf, offset, 7)\n\n let lo = Number(value & BigInt(0xffffffff))\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n return offset\n}\n\nfunction wrtBigUInt64BE (buf, value, offset, min, max) {\n checkIntBI(value, min, max, buf, offset, 7)\n\n let lo = Number(value & BigInt(0xffffffff))\n buf[offset + 7] = lo\n lo = lo >> 8\n buf[offset + 6] = lo\n lo = lo >> 8\n buf[offset + 5] = lo\n lo = lo >> 8\n buf[offset + 4] = lo\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))\n buf[offset + 3] = hi\n hi = hi >> 8\n buf[offset + 2] = hi\n hi = hi >> 8\n buf[offset + 1] = hi\n hi = hi >> 8\n buf[offset] = hi\n return offset + 8\n}\n\nBuffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {\n return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))\n})\n\nBuffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {\n return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))\n})\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n const limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n let i = 0\n let mul = 1\n let sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n const limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n let i = byteLength - 1\n let mul = 1\n let sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {\n return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))\n})\n\nBuffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {\n return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))\n})\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('Index out of range')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n const len = end - start\n\n if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {\n // Use built-in when available, missing from IE11\n this.copyWithin(targetStart, start, end)\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, end),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n if (val.length === 1) {\n const code = val.charCodeAt(0)\n if ((encoding === 'utf8' && code < 128) ||\n encoding === 'latin1') {\n // Fast path: If `val` fits into a single byte, use that numeric value.\n val = code\n }\n }\n } else if (typeof val === 'number') {\n val = val & 255\n } else if (typeof val === 'boolean') {\n val = Number(val)\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n let i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n const bytes = Buffer.isBuffer(val)\n ? val\n : Buffer.from(val, encoding)\n const len = bytes.length\n if (len === 0) {\n throw new TypeError('The value \"' + val +\n '\" is invalid for argument \"value\"')\n }\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// CUSTOM ERRORS\n// =============\n\n// Simplified versions from Node, changed for Buffer-only usage\nconst errors = {}\nfunction E (sym, getMessage, Base) {\n errors[sym] = class NodeError extends Base {\n constructor () {\n super()\n\n Object.defineProperty(this, 'message', {\n value: getMessage.apply(this, arguments),\n writable: true,\n configurable: true\n })\n\n // Add the error code to the name to include it in the stack trace.\n this.name = `${this.name} [${sym}]`\n // Access the stack to generate the error message including the error code\n // from the name.\n this.stack // eslint-disable-line no-unused-expressions\n // Reset the name to the actual name.\n delete this.name\n }\n\n get code () {\n return sym\n }\n\n set code (value) {\n Object.defineProperty(this, 'code', {\n configurable: true,\n enumerable: true,\n value,\n writable: true\n })\n }\n\n toString () {\n return `${this.name} [${sym}]: ${this.message}`\n }\n }\n}\n\nE('ERR_BUFFER_OUT_OF_BOUNDS',\n function (name) {\n if (name) {\n return `${name} is outside of buffer bounds`\n }\n\n return 'Attempt to access memory outside buffer bounds'\n }, RangeError)\nE('ERR_INVALID_ARG_TYPE',\n function (name, actual) {\n return `The \"${name}\" argument must be of type number. Received type ${typeof actual}`\n }, TypeError)\nE('ERR_OUT_OF_RANGE',\n function (str, range, input) {\n let msg = `The value of \"${str}\" is out of range.`\n let received = input\n if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {\n received = addNumericalSeparator(String(input))\n } else if (typeof input === 'bigint') {\n received = String(input)\n if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {\n received = addNumericalSeparator(received)\n }\n received += 'n'\n }\n msg += ` It must be ${range}. Received ${received}`\n return msg\n }, RangeError)\n\nfunction addNumericalSeparator (val) {\n let res = ''\n let i = val.length\n const start = val[0] === '-' ? 1 : 0\n for (; i >= start + 4; i -= 3) {\n res = `_${val.slice(i - 3, i)}${res}`\n }\n return `${val.slice(0, i)}${res}`\n}\n\n// CHECK FUNCTIONS\n// ===============\n\nfunction checkBounds (buf, offset, byteLength) {\n validateNumber(offset, 'offset')\n if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {\n boundsError(offset, buf.length - (byteLength + 1))\n }\n}\n\nfunction checkIntBI (value, min, max, buf, offset, byteLength) {\n if (value > max || value < min) {\n const n = typeof min === 'bigint' ? 'n' : ''\n let range\n if (byteLength > 3) {\n if (min === 0 || min === BigInt(0)) {\n range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`\n } else {\n range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +\n `${(byteLength + 1) * 8 - 1}${n}`\n }\n } else {\n range = `>= ${min}${n} and <= ${max}${n}`\n }\n throw new errors.ERR_OUT_OF_RANGE('value', range, value)\n }\n checkBounds(buf, offset, byteLength)\n}\n\nfunction validateNumber (value, name) {\n if (typeof value !== 'number') {\n throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)\n }\n}\n\nfunction boundsError (value, length, type) {\n if (Math.floor(value) !== value) {\n validateNumber(value, type)\n throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)\n }\n\n if (length < 0) {\n throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()\n }\n\n throw new errors.ERR_OUT_OF_RANGE(type || 'offset',\n `>= ${type ? 1 : 0} and <= ${length}`,\n value)\n}\n\n// HELPER FUNCTIONS\n// ================\n\nconst INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node takes equal signs as end of the Base64 encoding\n str = str.split('=')[0]\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = str.trim().replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n let codePoint\n const length = string.length\n let leadSurrogate = null\n const bytes = []\n\n for (let i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n const byteArray = []\n for (let i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n let c, hi, lo\n const byteArray = []\n for (let i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n let i\n for (i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\n// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass\n// the `instanceof` check but they should be treated as of that type.\n// See: https://github.com/feross/buffer/issues/166\nfunction isInstance (obj, type) {\n return obj instanceof type ||\n (obj != null && obj.constructor != null && obj.constructor.name != null &&\n obj.constructor.name === type.name)\n}\nfunction numberIsNaN (obj) {\n // For IE11 support\n return obj !== obj // eslint-disable-line no-self-compare\n}\n\n// Create lookup table for `toString('hex')`\n// See: https://github.com/feross/buffer/issues/219\nconst hexSliceLookupTable = (function () {\n const alphabet = '0123456789abcdef'\n const table = new Array(256)\n for (let i = 0; i < 16; ++i) {\n const i16 = i * 16\n for (let j = 0; j < 16; ++j) {\n table[i16 + j] = alphabet[i] + alphabet[j]\n }\n }\n return table\n})()\n\n// Return not function with Error if BigInt not supported\nfunction defineBigIntMethod (fn) {\n return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn\n}\n\nfunction BufferBigIntNotDefined () {\n throw new Error('BigInt not supported')\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * Originally from https://github.com/QwantResearch/masq-common/ \n * with improvements by Andrei Sambra\n */\n\nimport { Buffer } from 'buffer';\n\ninterface CipherData {\n ciphertext: string;\n iv: string;\n}\n\ninterface DerivationParams {\n salt: string;\n iterations: number;\n hashAlgo: string;\n}\n\ninterface ProtectedMasterKey {\n derivationParams: DerivationParams;\n encryptedMasterKey: CipherData;\n}\n\nconst checkCryptokey = (key: CryptoKey) => {\n if (!key.type || key.type !== 'secret') {\n throw new Error('Invalid key type')\n }\n}\n\nconst genRandomBuffer = (len = 16) => {\n const values = globalThis.crypto.getRandomValues(new Uint8Array(len))\n return Buffer.from(values)\n}\n\nconst genRandomBufferAsStr = (len = 16, encodingFormat: BufferEncoding = 'hex') => {\n if (encodingFormat) {\n checkEncodingFormat(encodingFormat)\n }\n const buf = genRandomBuffer(len)\n return buf.toString(encodingFormat)\n}\n\nconst checkPassphrase = (str: string) => {\n if (typeof str !== 'string' || str === '') {\n throw new Error(`Not a valid value`)\n }\n}\n\nconst checkEncodingFormat = (format: BufferEncoding) => {\n if (format !== 'hex' && format !== 'base64') throw new Error('Invalid encoding')\n}\n\n/**\n * Generate a random hexadecimal ID of a given length\n *\n * @param {integer} [len] The string length of the new ID\n * @returns {string} The new ID\n */\nconst genId = (len = 32) => {\n // 2 bytes for each char\n return genRandomBufferAsStr(Math.floor(len / 2))\n}\n\n/**\n * Generate the hash of a string or ArrayBuffer\n *\n * @param {string | arrayBuffer} data The message\n * @param {string} [format] The encoding format ('hex' by default, can also be 'base64')\n * @param {string} [name] The hashing algorithm (SHA-256 by default)\n * @returns {Promise} A promise that contains the hash as a String encoded with encodingFormat\n */\nconst hash = async (data: string | ArrayBuffer, format: BufferEncoding = 'hex', name = 'SHA-256') => {\n const digest = await globalThis.crypto.subtle.digest(\n {\n name\n },\n (typeof data === 'string') ? Buffer.from(data) : data\n )\n return Buffer.from(digest).toString(format)\n}\n\n/**\n * Generate an ECDA key pair based on the provided curve name\n *\n * @param {boolean} extractable - Specify if the generated key is extractable\n * @param {namedCurve} namedCurve - The curve name to use\n * @returns {Promise} - A promise containing the key pair\n */\nconst genKeyPair = (extractable = true, namedCurve = 'P-256') => {\n return globalThis.crypto.subtle.generateKey(\n {\n name: 'ECDSA',\n namedCurve // can be \"P-256\", \"P-384\", or \"P-521\"\n },\n extractable,\n ['sign', 'verify']\n )\n}\n\n// Helper to correctly select return type based on format argument.\ntype KeyBufferEncoding = BufferEncoding | 'raw';\ntype SelectKeyType = TFormat extends 'raw' ? Uint8Array : string;\n\n/**\n * Import a public key\n *\n * @param {CryptoKey} key - The public CryptoKey\n * @param {string} namedCurve - The curve name to use\n * @returns {Promise} - The raw key\n */\nfunction importPublicKey(key: string): Promise;\nfunction importPublicKey(key: string, namedCurve: string): Promise;\nfunction importPublicKey(key: SelectKeyType, namedCurve: string, format: TFormat): Promise;\n\nfunction importPublicKey(key: string | Uint8Array, namedCurve = 'P-256', format: KeyBufferEncoding = 'base64') {\n return globalThis.crypto.subtle.importKey(\n 'spki',\n typeof key === 'string' ? Buffer.from(key, format as BufferEncoding) : key,\n {\n name: 'ECDSA',\n namedCurve // can be \"P-256\", \"P-384\", or \"P-521\"\n },\n true,\n ['verify']\n )\n}\n\n/**\n * Import a private key\n *\n * @param {CryptoKey} key - The private CryptoKey\n * @param {string} namedCurve - The curve name to use\n * @returns {Promise} - The raw key\n */\nfunction importPrivateKey(key: string): Promise;\nfunction importPrivateKey(key: string, namedCurve: string): Promise;\nfunction importPrivateKey(key: SelectKeyType, namedCurve: string, format: TFormat): Promise;\n\nfunction importPrivateKey(key: string | Uint8Array, namedCurve = 'P-256', format: KeyBufferEncoding = 'base64') {\n return globalThis.crypto.subtle.importKey(\n 'pkcs8',\n typeof key === 'string' ? Buffer.from(key, format as BufferEncoding) : key,\n {\n name: 'ECDSA',\n namedCurve // can be \"P-256\", \"P-384\", or \"P-521\"\n },\n true,\n ['sign']\n )\n}\n\n/**\n * Export a public key\n *\n * @param {CryptoKey} key - The public CryptoKey\n * @returns {Promise} - The raw key\n */\n\nfunction exportPublicKey(key: CryptoKey): Promise;\nfunction exportPublicKey (key: CryptoKey, format: TFormat): Promise>;\n\nasync function exportPublicKey(key: CryptoKey, format: KeyBufferEncoding = 'base64') {\n const exported = await globalThis.crypto.subtle.exportKey('spki', key)\n return (format === 'raw') ? new Uint8Array(exported) : Buffer.from(exported).toString(format)\n}\n\n/**\n * Export a private key\n *\n * @param {CryptoKey} key - The private CryptoKey\n * @returns {Promise} - The raw key\n */\nfunction exportPrivateKey(key: CryptoKey): Promise;\nfunction exportPrivateKey (key: CryptoKey, format: TFormat): Promise>;\n \nasync function exportPrivateKey(key: CryptoKey, format: KeyBufferEncoding = 'base64') {\n const exported = await globalThis.crypto.subtle.exportKey('pkcs8', key)\n return (format === 'raw') ? new Uint8Array(exported) : Buffer.from(exported).toString(format)\n}\n\n/**\n * Sign data using the private key\n *\n * @param {CryptoKey} key - The private key\n * @param {*} data - Data to sign\n * @param {*} hash - The hashing algorithm\n * @returns {Promise} - The raw signature\n */\nconst sign = async (key: CryptoKey, data: any, format: KeyBufferEncoding = 'base64', hash = 'SHA-256') => {\n const signature = await globalThis.crypto.subtle.sign(\n {\n name: 'ECDSA',\n hash: { name: hash } // can be \"SHA-1\", \"SHA-256\", \"SHA-384\", or \"SHA-512\"\n },\n key,\n Buffer.from(typeof data === \"string\" ? data : JSON.stringify(data))\n )\n return (format === 'raw') ? new Uint8Array(signature) : Buffer.from(signature).toString(format)\n}\n\n/**\n * Verify data using the public key\n *\n * @param {CryptoKey} key - The public key\n * @param {*} data - Data to verify\n * @param {*} hash - The hashing algorithm\n * @returns {Promise} - The verification outcome\n */\nconst verify = async (key: CryptoKey, data: any, signature: string, format: BufferEncoding = 'base64', hash = 'SHA-256') => {\n return globalThis.crypto.subtle.verify(\n {\n name: 'ECDSA',\n hash: { name: hash } // can be \"SHA-1\", \"SHA-256\", \"SHA-384\", or \"SHA-512\"\n },\n key,\n Buffer.from(signature, format),\n Buffer.from(typeof data === \"string\" ? data : JSON.stringify(data))\n )\n}\n\n/**\n * Generate an AES key based on the cipher mode and keysize\n *\n * @param {boolean} [extractable] - Specify if the generated key is extractable\n * @param {string} [mode] - The aes mode of the generated key\n * @param {Number} [keySize] - Specify if the generated key is extractable\n * @returns {Promise} - The generated AES key.\n */\nconst genAESKey = (extractable = true, mode = 'AES-GCM', keySize = 128) => {\n return globalThis.crypto.subtle.generateKey({\n name: mode,\n length: keySize\n },\n extractable,\n ['decrypt', 'encrypt'])\n}\n\n/**\n * Import a raw|jwk as a CryptoKey\n *\n * @param {arrayBuffer|Object} key - The key\n * @param {string} [type] - The type of the key to import ('raw', 'jwk')\n * @param {string} [mode] - The mode of the key to import (default 'AES-GCM')\n * @returns {Promise} - The cryptoKey\n */\nconst importKey = (key: ArrayBuffer, type: 'pkcs8' | 'spki' | 'raw' = 'raw', mode = 'AES-GCM') => {\n const parsedKey = (type === 'raw') ? Buffer.from(key as unknown as string, 'base64') : key\n return globalThis.crypto.subtle.importKey(type, parsedKey, { name: mode }\n , true, ['encrypt', 'decrypt'])\n}\n\n/**\n * Export a CryptoKey into a raw|jwk key\n *\n * @param {CryptoKey} key - The CryptoKey\n * @param {string} [type] - The type of the exported key: raw|jwk\n * @returns {Promise} - The raw key or the key as a jwk format\n */\nconst exportKey = async (key: CryptoKey, type: 'pkcs8' | 'spki' | 'raw' = 'raw') => {\n const exportedKey = await globalThis.crypto.subtle.exportKey(type, key)\n return (type === 'raw') ? new Uint8Array(exportedKey as ArrayBuffer) : exportedKey as ArrayBuffer\n}\n\n/**\n * Encrypt buffer\n *\n * @param {ArrayBuffer} key - The AES CryptoKey\n * @param {ArrayBuffer} data - Data to encrypt\n * @param {Object} cipherContext - The AES cipher parameters\n * @returns {ArrayBuffer} - The encrypted buffer\n */\nconst encryptBuffer = async (key: CryptoKey, data: Buffer, cipherContext: TCipherContext) => {\n const encrypted = await globalThis.crypto.subtle.encrypt(cipherContext, key, data)\n return new Uint8Array(encrypted)\n}\n\n/**\n * Decrypt buffer\n * @param {ArrayBuffer} key - The AES CryptoKey\n * @param {ArrayBuffer} data - Data to decrypt\n * @param {Object} cipherContext - The AES cipher parameters\n * @returns {Promise} - The decrypted buffer\n */\nconst decryptBuffer = async (key: CryptoKey, data: ArrayBuffer, cipherContext: TCipherContext) => {\n // TODO: test input params\n try {\n const decrypted = await globalThis.crypto.subtle.decrypt(cipherContext, key, data)\n return new Uint8Array(decrypted)\n } catch (e) {\n if (e instanceof Error && e.message === 'Unsupported state or unable to authenticate data') {\n throw new Error('Unable to decrypt data')\n } else if (typeof e === 'string') {\n throw new Error(e);\n }\n }\n}\n\n/**\n * Encrypt data\n *\n * @param {CryptoKey} key - The AES CryptoKey\n * @param {string | Object} - The data to encrypt\n * @param {string} [format] - The ciphertext and iv encoding format\n * @returns {Object} - The stringified ciphertext object (ciphertext and iv)\n */\nconst encrypt = async (key: CryptoKey, data: string | object, format: BufferEncoding = 'hex'): Promise => {\n checkCryptokey(key)\n const context = {\n iv: genRandomBuffer(key.algorithm.name === 'AES-GCM' ? 12 : 16),\n plaintext: Buffer.from(JSON.stringify(data))\n }\n\n // Prepare cipher context, depends on cipher mode\n const cipherContext = {\n name: key.algorithm.name,\n iv: context.iv\n }\n\n const encrypted = await encryptBuffer(key, context.plaintext, cipherContext)\n return {\n ciphertext: Buffer.from(encrypted).toString(format),\n iv: Buffer.from(context.iv).toString(format)\n }\n}\n\n/**\n * Decrypt data\n *\n * @param {CryptoKey} key - The AES CryptoKey\n * @param {string | Object} - The data to decrypt\n * @param {string} [format] - The ciphertext and iv encoding format\n */\nconst decrypt = async (key: CryptoKey, ciphertext: CipherData, format: BufferEncoding = 'hex') => {\n checkCryptokey(key)\n\n const context = {\n ciphertext: Buffer.from(Object.prototype.hasOwnProperty.call(ciphertext, 'ciphertext') ? ciphertext.ciphertext : '', (format)),\n // IV is 128 bits long === 16 bytes\n iv: Object.prototype.hasOwnProperty.call(ciphertext, 'iv') ? Buffer.from(ciphertext.iv, (format)) : ''\n }\n\n // Prepare cipher context, depends on cipher mode\n const cipherContext = {\n name: key.algorithm.name,\n iv: context.iv\n }\n try {\n const decrypted = await decryptBuffer(key, context.ciphertext, cipherContext)\n if (decrypted === undefined) {\n throw new Error();\n }\n return JSON.parse(Buffer.from(decrypted).toString())\n } catch (error) {\n throw new Error('Unable to decrypt data')\n }\n}\n\n/**\n * Generate a PBKDF2 derived key (bits) based on user given passPhrase\n *\n * @param {string | arrayBuffer} passPhrase The passphrase that is used to derive the key\n * @param {arrayBuffer} [salt] The salt\n * @param {Number} [iterations] The iterations number\n * @param {string} [hashAlgo] The hash function used for derivation\n * @returns {Promise} A promise that contains the derived key\n */\nconst deriveBits = async (passPhrase: string | ArrayBuffer, salt: ArrayBuffer, iterations: number, hashAlgo: string) => {\n // Always specify a strong salt\n if (iterations < 10000) { console.warn('Less than 10000 :(') }\n\n const baseKey = await globalThis.crypto.subtle.importKey(\n 'raw',\n (typeof passPhrase === 'string') ? Buffer.from(passPhrase) : passPhrase,\n 'PBKDF2',\n false,\n ['deriveBits', 'deriveKey']\n )\n const derivedKey = await globalThis.crypto.subtle.deriveBits({\n name: 'PBKDF2',\n salt: salt || new Uint8Array([]),\n iterations: iterations || 100000,\n hash: hashAlgo || 'SHA-256'\n }, baseKey, 128)\n\n return new Uint8Array(derivedKey)\n}\n\n/**\n * Derive a key based on a given passphrase\n *\n * @param {string} passPhrase The passphrase that is used to derive the key\n * @param {arrayBuffer} [salt] The salt\n * @param {Number} [iterations] The iterations number\n * @param {string} [hashAlgo] The hash function used for derivation and final hash computing\n * @returns {Promise} A promise that contains the derived key and derivation\n * parameters\n */\nconst deriveKeyFromPassphrase = async (passPhrase: string, salt = genRandomBuffer(16), iterations = 100000, hashAlgo: string = 'SHA-256') => {\n checkPassphrase(passPhrase)\n\n const derivedKey = await deriveBits(passPhrase, salt, iterations, hashAlgo)\n const key = await importKey(derivedKey)\n return {\n derivationParams: {\n salt: Buffer.from(salt).toString('hex'),\n iterations,\n hashAlgo\n },\n key\n }\n}\n\n/**\n * Derive the passphrase with PBKDF2 to obtain a KEK\n * Generate a AES key (masterKey)\n * Encrypt the masterKey with the KEK\n *\n * @param {string} passPhrase The passphrase that is used to derive the key\n * @param {arrayBuffer} [salt] The salt\n * @param {Number} [iterations] The iterations number\n * @param {string} [hashAlgo] The hash function used for derivation and final hash computing\n * @returns {Promise} A promise that contains the encrypted derived key\n */\nconst genEncryptedMasterKey = async (passPhrase: string, salt?: Buffer, iterations?: number, hashAlgo?: string): Promise => {\n // derive key encryption key from passphrase\n const keyEncryptionKey = await deriveKeyFromPassphrase(passPhrase, salt, iterations, hashAlgo)\n\n // Generate the masterKey\n const masterKey = genRandomBufferAsStr(32, 'hex')\n\n const encryptedMasterKey = await encrypt(keyEncryptionKey.key, masterKey)\n\n return {\n derivationParams: keyEncryptionKey.derivationParams,\n encryptedMasterKey\n }\n}\n\n/**\n * Update the derived encryption key (KEK) based on the new passphrase from user, while retaining\n * the symmetric key that encrypts data at rest\n *\n * @param {string} currentPassPhrase The current (old) passphrase that is used to derive the key\n * @param {string} newPassPhrase The new passphrase that will be used to derive the key\n * @param {oldMasterKey} oldMasterKey - The old object returned by genEncryptedMasterKey for the old passphrase\n * @param {arrayBuffer} [salt] The salt\n * @param {Number} [iterations] The iterations number\n * @param {string} [hashAlgo] The hash function used for derivation and final hash computing\n * @returns {Promise}\n */\nconst updatePassphraseKey = async (currentPassPhrase: string, newPassPhrase: string, oldMasterKey: ProtectedMasterKey, salt?: Buffer, iterations?: number, hashAlgo?: string): Promise => {\n const masterKey = await decryptMasterKey(currentPassPhrase, oldMasterKey)\n // derive a new key encryption key from newPassPhrase\n const keyEncryptionKey = await deriveKeyFromPassphrase(newPassPhrase, salt, iterations, hashAlgo)\n\n // enconde existing masterKey as a hex string since it's a buffer\n const toBeEncryptedMasterKey = Buffer.from(await exportKey(masterKey)).toString('hex')\n\n const encryptedMasterKey = await encrypt(keyEncryptionKey.key, toBeEncryptedMasterKey)\n\n return {\n derivationParams: keyEncryptionKey.derivationParams,\n encryptedMasterKey\n }\n}\n\n/**\n * Decrypt a master key by deriving the encryption key from the\n * provided passphrase and encrypted master key.\n *\n * @param {string | arrayBuffer} passPhrase The passphrase that is used to derive the key\n * @param {protectedMasterKey} protectedMasterKey - The same object returned\n * by genEncryptedMasterKey\n * @returns {Promise} A promise that contains the masterKey\n */\nconst decryptMasterKey = async (passPhrase: string, protectedMasterKey: ProtectedMasterKey) => {\n if (!protectedMasterKey.encryptedMasterKey ||\n !protectedMasterKey.derivationParams) {\n throw new Error('Missing properties from master key')\n }\n const { derivationParams, encryptedMasterKey } = protectedMasterKey\n const { salt, iterations, hashAlgo } = derivationParams\n const _salt = typeof (salt) === 'string' ? Buffer.from(salt, ('hex')) : salt\n const derivedKey = await deriveBits(passPhrase, _salt, iterations, hashAlgo)\n const keyEncryptionKey = await importKey(derivedKey)\n try {\n const decryptedMasterKeyHex = await decrypt(keyEncryptionKey, encryptedMasterKey)\n // return decryptedMasterKeyHex\n const parsedKey = Buffer.from(decryptedMasterKeyHex, 'hex')\n return globalThis.crypto.subtle.importKey('raw', parsedKey, { name: 'AES-GCM' }\n , true, ['encrypt', 'decrypt'])\n } catch (error) {\n throw new Error('Wrong passphrase')\n }\n}\n\nconst _genRandomBuffer = genRandomBuffer;\nconst _genRandomBufferAsStr = genRandomBufferAsStr;\n\nexport {\n genId,\n hash,\n genKeyPair,\n importPublicKey,\n importPrivateKey,\n exportPublicKey,\n exportPrivateKey,\n sign,\n verify,\n genAESKey,\n importKey,\n exportKey,\n encrypt,\n decrypt,\n encryptBuffer,\n decryptBuffer,\n genEncryptedMasterKey,\n decryptMasterKey,\n updatePassphraseKey,\n _genRandomBuffer,\n _genRandomBufferAsStr,\n CipherData,\n DerivationParams,\n ProtectedMasterKey\n}\n"],"names":["root","factory","exports","module","define","amd","self","byteLength","b64","lens","getLens","validLen","placeHoldersLen","toByteArray","tmp","i","arr","Arr","_byteLength","curByte","len","revLookup","charCodeAt","fromByteArray","uint8","length","extraBytes","parts","maxChunkLength","len2","push","encodeChunk","lookup","join","Uint8Array","Array","code","Error","indexOf","start","end","num","output","base64","ieee754","customInspectSymbol","Symbol","Buffer","K_MAX_LENGTH","createBuffer","RangeError","buf","Object","setPrototypeOf","prototype","arg","encodingOrOffset","TypeError","allocUnsafe","from","value","string","encoding","isEncoding","actual","write","slice","fromString","ArrayBuffer","isView","arrayView","isInstance","copy","fromArrayBuffer","buffer","byteOffset","fromArrayLike","fromArrayView","SharedArrayBuffer","valueOf","b","obj","isBuffer","checked","undefined","numberIsNaN","type","isArray","data","fromObject","toPrimitive","assertSize","size","array","toString","mustMatch","arguments","loweredCase","utf8ToBytes","base64ToBytes","toLowerCase","slowToString","this","hexSlice","utf8Slice","asciiSlice","latin1Slice","base64Slice","utf16leSlice","swap","n","m","bidirectionalIndexOf","val","dir","arrayIndexOf","call","lastIndexOf","indexSize","arrLength","valLength","String","read","readUInt16BE","foundIndex","found","j","hexWrite","offset","Number","remaining","strLen","parsed","parseInt","substr","utf8Write","blitBuffer","asciiWrite","str","byteArray","asciiToBytes","base64Write","ucs2Write","units","c","hi","lo","utf16leToBytes","Math","min","res","firstByte","codePoint","bytesPerSequence","secondByte","thirdByte","fourthByte","tempCodePoint","codePoints","MAX_ARGUMENTS_LENGTH","fromCharCode","apply","decodeCodePointsArray","TYPED_ARRAY_SUPPORT","proto","foo","e","typedArraySupport","console","error","defineProperty","enumerable","get","poolSize","alloc","fill","allocUnsafeSlow","_isBuffer","compare","a","x","y","concat","list","pos","set","swap16","swap32","swap64","toLocaleString","equals","inspect","max","replace","trim","target","thisStart","thisEnd","thisCopy","targetCopy","includes","isFinite","toJSON","_arr","ret","out","hexSliceLookupTable","bytes","checkOffset","ext","checkInt","wrtBigUInt64LE","checkIntBI","BigInt","wrtBigUInt64BE","checkIEEE754","writeFloat","littleEndian","noAssert","writeDouble","newBuf","subarray","readUintLE","readUIntLE","mul","readUintBE","readUIntBE","readUint8","readUInt8","readUint16LE","readUInt16LE","readUint16BE","readUint32LE","readUInt32LE","readUint32BE","readUInt32BE","readBigUInt64LE","defineBigIntMethod","validateNumber","first","last","boundsError","readBigUInt64BE","readIntLE","pow","readIntBE","readInt8","readInt16LE","readInt16BE","readInt32LE","readInt32BE","readBigInt64LE","readBigInt64BE","readFloatLE","readFloatBE","readDoubleLE","readDoubleBE","writeUintLE","writeUIntLE","writeUintBE","writeUIntBE","writeUint8","writeUInt8","writeUint16LE","writeUInt16LE","writeUint16BE","writeUInt16BE","writeUint32LE","writeUInt32LE","writeUint32BE","writeUInt32BE","writeBigUInt64LE","writeBigUInt64BE","writeIntLE","limit","sub","writeIntBE","writeInt8","writeInt16LE","writeInt16BE","writeInt32LE","writeInt32BE","writeBigInt64LE","writeBigInt64BE","writeFloatLE","writeFloatBE","writeDoubleLE","writeDoubleBE","targetStart","copyWithin","errors","E","sym","getMessage","Base","constructor","super","writable","configurable","name","stack","message","addNumericalSeparator","range","ERR_OUT_OF_RANGE","checkBounds","ERR_INVALID_ARG_TYPE","floor","ERR_BUFFER_OUT_OF_BOUNDS","input","msg","received","isInteger","abs","INVALID_BASE64_RE","Infinity","leadSurrogate","split","base64clean","src","dst","alphabet","table","i16","fn","BufferBigIntNotDefined","isLE","mLen","nBytes","eLen","eMax","eBias","nBits","d","s","NaN","rt","isNaN","log","LN2","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","definition","key","o","prop","hasOwnProperty","r","toStringTag","checkCryptokey","genRandomBuffer","values","globalThis","crypto","getRandomValues","genRandomBufferAsStr","encodingFormat","checkEncodingFormat","format","genId","hash","digest","subtle","genKeyPair","extractable","namedCurve","generateKey","importPublicKey","importKey","importPrivateKey","exportPublicKey","exported","exportKey","exportPrivateKey","sign","signature","JSON","stringify","verify","genAESKey","mode","keySize","parsedKey","exportedKey","encryptBuffer","cipherContext","encrypted","encrypt","decryptBuffer","decrypted","decrypt","context","iv","algorithm","plaintext","ciphertext","parse","deriveBits","passPhrase","salt","iterations","hashAlgo","warn","baseKey","derivedKey","deriveKeyFromPassphrase","checkPassphrase","derivationParams","genEncryptedMasterKey","keyEncryptionKey","masterKey","encryptedMasterKey","updatePassphraseKey","currentPassPhrase","newPassPhrase","oldMasterKey","decryptMasterKey","toBeEncryptedMasterKey","protectedMasterKey","_salt","decryptedMasterKeyHex","_genRandomBuffer","_genRandomBufferAsStr"],"sourceRoot":""}
\ No newline at end of file
diff --git a/dist/esm/web-crypto.js b/dist/esm/web-crypto.js
index 2760767..040b004 100644
--- a/dist/esm/web-crypto.js
+++ b/dist/esm/web-crypto.js
@@ -18,7 +18,7 @@ const checkCryptokey = (key) => {
}
};
const genRandomBuffer = (len = 16) => {
- const values = window.crypto.getRandomValues(new Uint8Array(len));
+ const values = globalThis.crypto.getRandomValues(new Uint8Array(len));
return Buffer.from(values);
};
const genRandomBufferAsStr = (len = 16, encodingFormat = 'hex') => {
@@ -56,7 +56,7 @@ const genId = (len = 32) => {
* @returns {Promise} A promise that contains the hash as a String encoded with encodingFormat
*/
const hash = (data, format = 'hex', name = 'SHA-256') => __awaiter(void 0, void 0, void 0, function* () {
- const digest = yield window.crypto.subtle.digest({
+ const digest = yield globalThis.crypto.subtle.digest({
name
}, (typeof data === 'string') ? Buffer.from(data) : data);
return Buffer.from(digest).toString(format);
@@ -69,32 +69,32 @@ const hash = (data, format = 'hex', name = 'SHA-256') => __awaiter(void 0, void
* @returns {Promise} - A promise containing the key pair
*/
const genKeyPair = (extractable = true, namedCurve = 'P-256') => {
- return window.crypto.subtle.generateKey({
+ return globalThis.crypto.subtle.generateKey({
name: 'ECDSA',
namedCurve // can be "P-256", "P-384", or "P-521"
}, extractable, ['sign', 'verify']);
};
function importPublicKey(key, namedCurve = 'P-256', format = 'base64') {
- return window.crypto.subtle.importKey('spki', typeof key === 'string' ? Buffer.from(key, format) : key, {
+ return globalThis.crypto.subtle.importKey('spki', typeof key === 'string' ? Buffer.from(key, format) : key, {
name: 'ECDSA',
namedCurve // can be "P-256", "P-384", or "P-521"
}, true, ['verify']);
}
function importPrivateKey(key, namedCurve = 'P-256', format = 'base64') {
- return window.crypto.subtle.importKey('pkcs8', typeof key === 'string' ? Buffer.from(key, format) : key, {
+ return globalThis.crypto.subtle.importKey('pkcs8', typeof key === 'string' ? Buffer.from(key, format) : key, {
name: 'ECDSA',
namedCurve // can be "P-256", "P-384", or "P-521"
}, true, ['sign']);
}
function exportPublicKey(key, format = 'base64') {
return __awaiter(this, void 0, void 0, function* () {
- const exported = yield window.crypto.subtle.exportKey('spki', key);
+ const exported = yield globalThis.crypto.subtle.exportKey('spki', key);
return (format === 'raw') ? new Uint8Array(exported) : Buffer.from(exported).toString(format);
});
}
function exportPrivateKey(key, format = 'base64') {
return __awaiter(this, void 0, void 0, function* () {
- const exported = yield window.crypto.subtle.exportKey('pkcs8', key);
+ const exported = yield globalThis.crypto.subtle.exportKey('pkcs8', key);
return (format === 'raw') ? new Uint8Array(exported) : Buffer.from(exported).toString(format);
});
}
@@ -107,7 +107,7 @@ function exportPrivateKey(key, format = 'base64') {
* @returns {Promise} - The raw signature
*/
const sign = (key, data, format = 'base64', hash = 'SHA-256') => __awaiter(void 0, void 0, void 0, function* () {
- const signature = yield window.crypto.subtle.sign({
+ const signature = yield globalThis.crypto.subtle.sign({
name: 'ECDSA',
hash: { name: hash } // can be "SHA-1", "SHA-256", "SHA-384", or "SHA-512"
}, key, Buffer.from(typeof data === "string" ? data : JSON.stringify(data)));
@@ -122,7 +122,7 @@ const sign = (key, data, format = 'base64', hash = 'SHA-256') => __awaiter(void
* @returns {Promise} - The verification outcome
*/
const verify = (key, data, signature, format = 'base64', hash = 'SHA-256') => __awaiter(void 0, void 0, void 0, function* () {
- return window.crypto.subtle.verify({
+ return globalThis.crypto.subtle.verify({
name: 'ECDSA',
hash: { name: hash } // can be "SHA-1", "SHA-256", "SHA-384", or "SHA-512"
}, key, Buffer.from(signature, format), Buffer.from(typeof data === "string" ? data : JSON.stringify(data)));
@@ -136,7 +136,7 @@ const verify = (key, data, signature, format = 'base64', hash = 'SHA-256') => __
* @returns {Promise} - The generated AES key.
*/
const genAESKey = (extractable = true, mode = 'AES-GCM', keySize = 128) => {
- return window.crypto.subtle.generateKey({
+ return globalThis.crypto.subtle.generateKey({
name: mode,
length: keySize
}, extractable, ['decrypt', 'encrypt']);
@@ -151,7 +151,7 @@ const genAESKey = (extractable = true, mode = 'AES-GCM', keySize = 128) => {
*/
const importKey = (key, type = 'raw', mode = 'AES-GCM') => {
const parsedKey = (type === 'raw') ? Buffer.from(key, 'base64') : key;
- return window.crypto.subtle.importKey(type, parsedKey, { name: mode }, true, ['encrypt', 'decrypt']);
+ return globalThis.crypto.subtle.importKey(type, parsedKey, { name: mode }, true, ['encrypt', 'decrypt']);
};
/**
* Export a CryptoKey into a raw|jwk key
@@ -161,7 +161,7 @@ const importKey = (key, type = 'raw', mode = 'AES-GCM') => {
* @returns {Promise} - The raw key or the key as a jwk format
*/
const exportKey = (key, type = 'raw') => __awaiter(void 0, void 0, void 0, function* () {
- const exportedKey = yield window.crypto.subtle.exportKey(type, key);
+ const exportedKey = yield globalThis.crypto.subtle.exportKey(type, key);
return (type === 'raw') ? new Uint8Array(exportedKey) : exportedKey;
});
/**
@@ -173,7 +173,7 @@ const exportKey = (key, type = 'raw') => __awaiter(void 0, void 0, void 0, funct
* @returns {ArrayBuffer} - The encrypted buffer
*/
const encryptBuffer = (key, data, cipherContext) => __awaiter(void 0, void 0, void 0, function* () {
- const encrypted = yield window.crypto.subtle.encrypt(cipherContext, key, data);
+ const encrypted = yield globalThis.crypto.subtle.encrypt(cipherContext, key, data);
return new Uint8Array(encrypted);
});
/**
@@ -186,7 +186,7 @@ const encryptBuffer = (key, data, cipherContext) => __awaiter(void 0, void 0, vo
const decryptBuffer = (key, data, cipherContext) => __awaiter(void 0, void 0, void 0, function* () {
// TODO: test input params
try {
- const decrypted = yield window.crypto.subtle.decrypt(cipherContext, key, data);
+ const decrypted = yield globalThis.crypto.subtle.decrypt(cipherContext, key, data);
return new Uint8Array(decrypted);
}
catch (e) {
@@ -267,8 +267,8 @@ const deriveBits = (passPhrase, salt, iterations, hashAlgo) => __awaiter(void 0,
if (iterations < 10000) {
console.warn('Less than 10000 :(');
}
- const baseKey = yield window.crypto.subtle.importKey('raw', (typeof passPhrase === 'string') ? Buffer.from(passPhrase) : passPhrase, 'PBKDF2', false, ['deriveBits', 'deriveKey']);
- const derivedKey = yield window.crypto.subtle.deriveBits({
+ const baseKey = yield globalThis.crypto.subtle.importKey('raw', (typeof passPhrase === 'string') ? Buffer.from(passPhrase) : passPhrase, 'PBKDF2', false, ['deriveBits', 'deriveKey']);
+ const derivedKey = yield globalThis.crypto.subtle.deriveBits({
name: 'PBKDF2',
salt: salt || new Uint8Array([]),
iterations: iterations || 100000,
@@ -368,7 +368,7 @@ const decryptMasterKey = (passPhrase, protectedMasterKey) => __awaiter(void 0, v
const decryptedMasterKeyHex = yield decrypt(keyEncryptionKey, encryptedMasterKey);
// return decryptedMasterKeyHex
const parsedKey = Buffer.from(decryptedMasterKeyHex, 'hex');
- return window.crypto.subtle.importKey('raw', parsedKey, { name: 'AES-GCM' }, true, ['encrypt', 'decrypt']);
+ return globalThis.crypto.subtle.importKey('raw', parsedKey, { name: 'AES-GCM' }, true, ['encrypt', 'decrypt']);
}
catch (error) {
throw new Error('Wrong passphrase');
diff --git a/dist/esm/web-crypto.js.map b/dist/esm/web-crypto.js.map
index 0796cb4..8518818 100644
--- a/dist/esm/web-crypto.js.map
+++ b/dist/esm/web-crypto.js.map
@@ -1 +1 @@
-{"version":3,"file":"web-crypto.js","sourceRoot":"","sources":["../../src/web-crypto.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAkBhC,MAAM,cAAc,GAAG,CAAC,GAAc,EAAE,EAAE;IACxC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;QACtC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;KACpC;AACH,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,CAAC,GAAG,GAAG,EAAE,EAAE,EAAE;IACnC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,CAAA;IACjE,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,MAAM,oBAAoB,GAAG,CAAC,GAAG,GAAG,EAAE,EAAE,iBAAiC,KAAK,EAAE,EAAE;IAChF,IAAI,cAAc,EAAE;QAClB,mBAAmB,CAAC,cAAc,C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IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAC5E,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAA;IAC5E,MAAM,gBAAgB,GAAG,MAAM,SAAS,CAAC,UAAU,CAAC,CAAA;IACpD,IAAI;QACF,MAAM,qBAAqB,GAAG,MAAM,OAAO,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAA;QACjF,+BAA+B;QAC/B,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAA;QAC3D,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EACvE,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAA;KAClC;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;KACpC;AACH,CAAC,CAAA,CAAA;AAED,MAAM,gBAAgB,GAAG,eAAe,CAAC;AACzC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD,OAAO,EACL,KAAK,EACL,IAAI,EACJ,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,IAAI,EACJ,MAAM,EACN,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,EACP,OAAO,EACP,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EAItB,CAAA"}
\ No newline at end of file
+{"version":3,"file":"web-crypto.js","sourceRoot":"","sources":["../../src/web-crypto.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAkBh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B,CAAC,CAAA;KACpC;AACH,CAAC,CAAA,CAAA;AAED,MAAM,gBAAgB,GAAG,eAAe,CAAC;AACzC,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD,OAAO,EACL,KAAK,EACL,IAAI,EACJ,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,IAAI,EACJ,MAAM,EACN,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,EACP,OAAO,EACP,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EAItB,CAAA"}
\ No newline at end of file
diff --git a/src/web-crypto.ts b/src/web-crypto.ts
index 1afba03..f8610e8 100644
--- a/src/web-crypto.ts
+++ b/src/web-crypto.ts
@@ -28,7 +28,7 @@ const checkCryptokey = (key: CryptoKey) => {
}
const genRandomBuffer = (len = 16) => {
- const values = window.crypto.getRandomValues(new Uint8Array(len))
+ const values = globalThis.crypto.getRandomValues(new Uint8Array(len))
return Buffer.from(values)
}
@@ -70,7 +70,7 @@ const genId = (len = 32) => {
* @returns {Promise} A promise that contains the hash as a String encoded with encodingFormat
*/
const hash = async (data: string | ArrayBuffer, format: BufferEncoding = 'hex', name = 'SHA-256') => {
- const digest = await window.crypto.subtle.digest(
+ const digest = await globalThis.crypto.subtle.digest(
{
name
},
@@ -87,7 +87,7 @@ const hash = async (data: string | ArrayBuffer, format: BufferEncoding = 'hex',
* @returns {Promise} - A promise containing the key pair
*/
const genKeyPair = (extractable = true, namedCurve = 'P-256') => {
- return window.crypto.subtle.generateKey(
+ return globalThis.crypto.subtle.generateKey(
{
name: 'ECDSA',
namedCurve // can be "P-256", "P-384", or "P-521"
@@ -113,7 +113,7 @@ function importPublicKey(key: string, namedCurve: string): Promise;
function importPublicKey(key: SelectKeyType, namedCurve: string, format: TFormat): Promise;
function importPublicKey(key: string | Uint8Array, namedCurve = 'P-256', format: KeyBufferEncoding = 'base64') {
- return window.crypto.subtle.importKey(
+ return globalThis.crypto.subtle.importKey(
'spki',
typeof key === 'string' ? Buffer.from(key, format as BufferEncoding) : key,
{
@@ -137,7 +137,7 @@ function importPrivateKey(key: string, namedCurve: string): Promise;
function importPrivateKey(key: SelectKeyType, namedCurve: string, format: TFormat): Promise;
function importPrivateKey(key: string | Uint8Array, namedCurve = 'P-256', format: KeyBufferEncoding = 'base64') {
- return window.crypto.subtle.importKey(
+ return globalThis.crypto.subtle.importKey(
'pkcs8',
typeof key === 'string' ? Buffer.from(key, format as BufferEncoding) : key,
{
@@ -160,7 +160,7 @@ function exportPublicKey(key: CryptoKey): Promise;
function exportPublicKey (key: CryptoKey, format: TFormat): Promise>;
async function exportPublicKey(key: CryptoKey, format: KeyBufferEncoding = 'base64') {
- const exported = await window.crypto.subtle.exportKey('spki', key)
+ const exported = await globalThis.crypto.subtle.exportKey('spki', key)
return (format === 'raw') ? new Uint8Array(exported) : Buffer.from(exported).toString(format)
}
@@ -174,7 +174,7 @@ function exportPrivateKey(key: CryptoKey): Promise;
function exportPrivateKey (key: CryptoKey, format: TFormat): Promise>;
async function exportPrivateKey(key: CryptoKey, format: KeyBufferEncoding = 'base64') {
- const exported = await window.crypto.subtle.exportKey('pkcs8', key)
+ const exported = await globalThis.crypto.subtle.exportKey('pkcs8', key)
return (format === 'raw') ? new Uint8Array(exported) : Buffer.from(exported).toString(format)
}
@@ -187,7 +187,7 @@ async function exportPrivateKey(key: CryptoKey, format: KeyBufferEncoding = 'bas
* @returns {Promise} - The raw signature
*/
const sign = async (key: CryptoKey, data: any, format: KeyBufferEncoding = 'base64', hash = 'SHA-256') => {
- const signature = await window.crypto.subtle.sign(
+ const signature = await globalThis.crypto.subtle.sign(
{
name: 'ECDSA',
hash: { name: hash } // can be "SHA-1", "SHA-256", "SHA-384", or "SHA-512"
@@ -207,7 +207,7 @@ const sign = async (key: CryptoKey, data: any, format: KeyBufferEncoding = 'base
* @returns {Promise} - The verification outcome
*/
const verify = async (key: CryptoKey, data: any, signature: string, format: BufferEncoding = 'base64', hash = 'SHA-256') => {
- return window.crypto.subtle.verify(
+ return globalThis.crypto.subtle.verify(
{
name: 'ECDSA',
hash: { name: hash } // can be "SHA-1", "SHA-256", "SHA-384", or "SHA-512"
@@ -227,7 +227,7 @@ const verify = async (key: CryptoKey, data: any, signature: string, format: Buff
* @returns {Promise} - The generated AES key.
*/
const genAESKey = (extractable = true, mode = 'AES-GCM', keySize = 128) => {
- return window.crypto.subtle.generateKey({
+ return globalThis.crypto.subtle.generateKey({
name: mode,
length: keySize
},
@@ -245,7 +245,7 @@ const genAESKey = (extractable = true, mode = 'AES-GCM', keySize = 128) => {
*/
const importKey = (key: ArrayBuffer, type: 'pkcs8' | 'spki' | 'raw' = 'raw', mode = 'AES-GCM') => {
const parsedKey = (type === 'raw') ? Buffer.from(key as unknown as string, 'base64') : key
- return window.crypto.subtle.importKey(type, parsedKey, { name: mode }
+ return globalThis.crypto.subtle.importKey(type, parsedKey, { name: mode }
, true, ['encrypt', 'decrypt'])
}
@@ -257,7 +257,7 @@ const importKey = (key: ArrayBuffer, type: 'pkcs8' | 'spki' | 'raw' = 'raw', mod
* @returns {Promise} - The raw key or the key as a jwk format
*/
const exportKey = async (key: CryptoKey, type: 'pkcs8' | 'spki' | 'raw' = 'raw') => {
- const exportedKey = await window.crypto.subtle.exportKey(type, key)
+ const exportedKey = await globalThis.crypto.subtle.exportKey(type, key)
return (type === 'raw') ? new Uint8Array(exportedKey as ArrayBuffer) : exportedKey as ArrayBuffer
}
@@ -270,7 +270,7 @@ const exportKey = async (key: CryptoKey, type: 'pkcs8' | 'spki' | 'raw' = 'raw')
* @returns {ArrayBuffer} - The encrypted buffer
*/
const encryptBuffer = async (key: CryptoKey, data: Buffer, cipherContext: TCipherContext) => {
- const encrypted = await window.crypto.subtle.encrypt(cipherContext, key, data)
+ const encrypted = await globalThis.crypto.subtle.encrypt(cipherContext, key, data)
return new Uint8Array(encrypted)
}
@@ -284,7 +284,7 @@ const encryptBuffer = async (key: CryptoKey, d
const decryptBuffer = async (key: CryptoKey, data: ArrayBuffer, cipherContext: TCipherContext) => {
// TODO: test input params
try {
- const decrypted = await window.crypto.subtle.decrypt(cipherContext, key, data)
+ const decrypted = await globalThis.crypto.subtle.decrypt(cipherContext, key, data)
return new Uint8Array(decrypted)
} catch (e) {
if (e instanceof Error && e.message === 'Unsupported state or unable to authenticate data') {
@@ -368,14 +368,14 @@ const deriveBits = async (passPhrase: string | ArrayBuffer, salt: ArrayBuffer, i
// Always specify a strong salt
if (iterations < 10000) { console.warn('Less than 10000 :(') }
- const baseKey = await window.crypto.subtle.importKey(
+ const baseKey = await globalThis.crypto.subtle.importKey(
'raw',
(typeof passPhrase === 'string') ? Buffer.from(passPhrase) : passPhrase,
'PBKDF2',
false,
['deriveBits', 'deriveKey']
)
- const derivedKey = await window.crypto.subtle.deriveBits({
+ const derivedKey = await globalThis.crypto.subtle.deriveBits({
name: 'PBKDF2',
salt: salt || new Uint8Array([]),
iterations: iterations || 100000,
@@ -487,7 +487,7 @@ const decryptMasterKey = async (passPhrase: string, protectedMasterKey: Protecte
const decryptedMasterKeyHex = await decrypt(keyEncryptionKey, encryptedMasterKey)
// return decryptedMasterKeyHex
const parsedKey = Buffer.from(decryptedMasterKeyHex, 'hex')
- return window.crypto.subtle.importKey('raw', parsedKey, { name: 'AES-GCM' }
+ return globalThis.crypto.subtle.importKey('raw', parsedKey, { name: 'AES-GCM' }
, true, ['encrypt', 'decrypt'])
} catch (error) {
throw new Error('Wrong passphrase')
diff --git a/test/crypto.test.js b/test/crypto.test.js
index dca34f1..a162487 100644
--- a/test/crypto.test.js
+++ b/test/crypto.test.js
@@ -1,7 +1,7 @@
/* eslint-env mocha */
/* global chai */
-const WebCrypto = window.WebCrypto
+const WebCrypto = globalThis.WebCrypto
describe('Web crypto', function () {
context('Generating a random buffer (for iv)', () => {