631 lines
21 KiB
JavaScript
631 lines
21 KiB
JavaScript
import {
|
|
__commonJS,
|
|
__require
|
|
} from "./chunk-GFT2G5UO.js";
|
|
|
|
// browser-external:crypto
|
|
var require_crypto = __commonJS({
|
|
"browser-external:crypto"(exports, module) {
|
|
module.exports = Object.create(new Proxy({}, {
|
|
get(_, key) {
|
|
if (key !== "__esModule" && key !== "__proto__" && key !== "constructor" && key !== "splice") {
|
|
console.warn(`Module "crypto" has been externalized for browser compatibility. Cannot access "crypto.${key}" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.`);
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
});
|
|
|
|
// node_modules/crypto-js/core.js
|
|
var require_core = __commonJS({
|
|
"node_modules/crypto-js/core.js"(exports, module) {
|
|
(function(root, factory) {
|
|
if (typeof exports === "object") {
|
|
module.exports = exports = factory();
|
|
} else if (typeof define === "function" && define.amd) {
|
|
define([], factory);
|
|
} else {
|
|
root.CryptoJS = factory();
|
|
}
|
|
})(exports, function() {
|
|
var CryptoJS = CryptoJS || function(Math2, undefined) {
|
|
var crypto;
|
|
if (typeof window !== "undefined" && window.crypto) {
|
|
crypto = window.crypto;
|
|
}
|
|
if (typeof self !== "undefined" && self.crypto) {
|
|
crypto = self.crypto;
|
|
}
|
|
if (typeof globalThis !== "undefined" && globalThis.crypto) {
|
|
crypto = globalThis.crypto;
|
|
}
|
|
if (!crypto && typeof window !== "undefined" && window.msCrypto) {
|
|
crypto = window.msCrypto;
|
|
}
|
|
if (!crypto && typeof global !== "undefined" && global.crypto) {
|
|
crypto = global.crypto;
|
|
}
|
|
if (!crypto && typeof __require === "function") {
|
|
try {
|
|
crypto = require_crypto();
|
|
} catch (err) {
|
|
}
|
|
}
|
|
var cryptoSecureRandomInt = function() {
|
|
if (crypto) {
|
|
if (typeof crypto.getRandomValues === "function") {
|
|
try {
|
|
return crypto.getRandomValues(new Uint32Array(1))[0];
|
|
} catch (err) {
|
|
}
|
|
}
|
|
if (typeof crypto.randomBytes === "function") {
|
|
try {
|
|
return crypto.randomBytes(4).readInt32LE();
|
|
} catch (err) {
|
|
}
|
|
}
|
|
}
|
|
throw new Error("Native crypto module could not be used to get secure random number.");
|
|
};
|
|
var create = Object.create || /* @__PURE__ */ function() {
|
|
function F() {
|
|
}
|
|
return function(obj) {
|
|
var subtype;
|
|
F.prototype = obj;
|
|
subtype = new F();
|
|
F.prototype = null;
|
|
return subtype;
|
|
};
|
|
}();
|
|
var C = {};
|
|
var C_lib = C.lib = {};
|
|
var Base = C_lib.Base = /* @__PURE__ */ function() {
|
|
return {
|
|
/**
|
|
* Creates a new object that inherits from this object.
|
|
*
|
|
* @param {Object} overrides Properties to copy into the new object.
|
|
*
|
|
* @return {Object} The new object.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var MyType = CryptoJS.lib.Base.extend({
|
|
* field: 'value',
|
|
*
|
|
* method: function () {
|
|
* }
|
|
* });
|
|
*/
|
|
extend: function(overrides) {
|
|
var subtype = create(this);
|
|
if (overrides) {
|
|
subtype.mixIn(overrides);
|
|
}
|
|
if (!subtype.hasOwnProperty("init") || this.init === subtype.init) {
|
|
subtype.init = function() {
|
|
subtype.$super.init.apply(this, arguments);
|
|
};
|
|
}
|
|
subtype.init.prototype = subtype;
|
|
subtype.$super = this;
|
|
return subtype;
|
|
},
|
|
/**
|
|
* Extends this object and runs the init method.
|
|
* Arguments to create() will be passed to init().
|
|
*
|
|
* @return {Object} The new object.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var instance = MyType.create();
|
|
*/
|
|
create: function() {
|
|
var instance = this.extend();
|
|
instance.init.apply(instance, arguments);
|
|
return instance;
|
|
},
|
|
/**
|
|
* Initializes a newly created object.
|
|
* Override this method to add some logic when your objects are created.
|
|
*
|
|
* @example
|
|
*
|
|
* var MyType = CryptoJS.lib.Base.extend({
|
|
* init: function () {
|
|
* // ...
|
|
* }
|
|
* });
|
|
*/
|
|
init: function() {
|
|
},
|
|
/**
|
|
* Copies properties into this object.
|
|
*
|
|
* @param {Object} properties The properties to mix in.
|
|
*
|
|
* @example
|
|
*
|
|
* MyType.mixIn({
|
|
* field: 'value'
|
|
* });
|
|
*/
|
|
mixIn: function(properties) {
|
|
for (var propertyName in properties) {
|
|
if (properties.hasOwnProperty(propertyName)) {
|
|
this[propertyName] = properties[propertyName];
|
|
}
|
|
}
|
|
if (properties.hasOwnProperty("toString")) {
|
|
this.toString = properties.toString;
|
|
}
|
|
},
|
|
/**
|
|
* Creates a copy of this object.
|
|
*
|
|
* @return {Object} The clone.
|
|
*
|
|
* @example
|
|
*
|
|
* var clone = instance.clone();
|
|
*/
|
|
clone: function() {
|
|
return this.init.prototype.extend(this);
|
|
}
|
|
};
|
|
}();
|
|
var WordArray = C_lib.WordArray = Base.extend({
|
|
/**
|
|
* Initializes a newly created word array.
|
|
*
|
|
* @param {Array} words (Optional) An array of 32-bit words.
|
|
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
|
*
|
|
* @example
|
|
*
|
|
* var wordArray = CryptoJS.lib.WordArray.create();
|
|
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
|
|
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
|
|
*/
|
|
init: function(words, sigBytes) {
|
|
words = this.words = words || [];
|
|
if (sigBytes != undefined) {
|
|
this.sigBytes = sigBytes;
|
|
} else {
|
|
this.sigBytes = words.length * 4;
|
|
}
|
|
},
|
|
/**
|
|
* Converts this word array to a string.
|
|
*
|
|
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
|
|
*
|
|
* @return {string} The stringified word array.
|
|
*
|
|
* @example
|
|
*
|
|
* var string = wordArray + '';
|
|
* var string = wordArray.toString();
|
|
* var string = wordArray.toString(CryptoJS.enc.Utf8);
|
|
*/
|
|
toString: function(encoder) {
|
|
return (encoder || Hex).stringify(this);
|
|
},
|
|
/**
|
|
* Concatenates a word array to this word array.
|
|
*
|
|
* @param {WordArray} wordArray The word array to append.
|
|
*
|
|
* @return {WordArray} This word array.
|
|
*
|
|
* @example
|
|
*
|
|
* wordArray1.concat(wordArray2);
|
|
*/
|
|
concat: function(wordArray) {
|
|
var thisWords = this.words;
|
|
var thatWords = wordArray.words;
|
|
var thisSigBytes = this.sigBytes;
|
|
var thatSigBytes = wordArray.sigBytes;
|
|
this.clamp();
|
|
if (thisSigBytes % 4) {
|
|
for (var i = 0; i < thatSigBytes; i++) {
|
|
var thatByte = thatWords[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
thisWords[thisSigBytes + i >>> 2] |= thatByte << 24 - (thisSigBytes + i) % 4 * 8;
|
|
}
|
|
} else {
|
|
for (var j = 0; j < thatSigBytes; j += 4) {
|
|
thisWords[thisSigBytes + j >>> 2] = thatWords[j >>> 2];
|
|
}
|
|
}
|
|
this.sigBytes += thatSigBytes;
|
|
return this;
|
|
},
|
|
/**
|
|
* Removes insignificant bits.
|
|
*
|
|
* @example
|
|
*
|
|
* wordArray.clamp();
|
|
*/
|
|
clamp: function() {
|
|
var words = this.words;
|
|
var sigBytes = this.sigBytes;
|
|
words[sigBytes >>> 2] &= 4294967295 << 32 - sigBytes % 4 * 8;
|
|
words.length = Math2.ceil(sigBytes / 4);
|
|
},
|
|
/**
|
|
* Creates a copy of this word array.
|
|
*
|
|
* @return {WordArray} The clone.
|
|
*
|
|
* @example
|
|
*
|
|
* var clone = wordArray.clone();
|
|
*/
|
|
clone: function() {
|
|
var clone = Base.clone.call(this);
|
|
clone.words = this.words.slice(0);
|
|
return clone;
|
|
},
|
|
/**
|
|
* Creates a word array filled with random bytes.
|
|
*
|
|
* @param {number} nBytes The number of random bytes to generate.
|
|
*
|
|
* @return {WordArray} The random word array.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var wordArray = CryptoJS.lib.WordArray.random(16);
|
|
*/
|
|
random: function(nBytes) {
|
|
var words = [];
|
|
for (var i = 0; i < nBytes; i += 4) {
|
|
words.push(cryptoSecureRandomInt());
|
|
}
|
|
return new WordArray.init(words, nBytes);
|
|
}
|
|
});
|
|
var C_enc = C.enc = {};
|
|
var Hex = C_enc.Hex = {
|
|
/**
|
|
* Converts a word array to a hex string.
|
|
*
|
|
* @param {WordArray} wordArray The word array.
|
|
*
|
|
* @return {string} The hex string.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
|
|
*/
|
|
stringify: function(wordArray) {
|
|
var words = wordArray.words;
|
|
var sigBytes = wordArray.sigBytes;
|
|
var hexChars = [];
|
|
for (var i = 0; i < sigBytes; i++) {
|
|
var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
hexChars.push((bite >>> 4).toString(16));
|
|
hexChars.push((bite & 15).toString(16));
|
|
}
|
|
return hexChars.join("");
|
|
},
|
|
/**
|
|
* Converts a hex string to a word array.
|
|
*
|
|
* @param {string} hexStr The hex string.
|
|
*
|
|
* @return {WordArray} The word array.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
|
|
*/
|
|
parse: function(hexStr) {
|
|
var hexStrLength = hexStr.length;
|
|
var words = [];
|
|
for (var i = 0; i < hexStrLength; i += 2) {
|
|
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << 24 - i % 8 * 4;
|
|
}
|
|
return new WordArray.init(words, hexStrLength / 2);
|
|
}
|
|
};
|
|
var Latin1 = C_enc.Latin1 = {
|
|
/**
|
|
* Converts a word array to a Latin1 string.
|
|
*
|
|
* @param {WordArray} wordArray The word array.
|
|
*
|
|
* @return {string} The Latin1 string.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
|
|
*/
|
|
stringify: function(wordArray) {
|
|
var words = wordArray.words;
|
|
var sigBytes = wordArray.sigBytes;
|
|
var latin1Chars = [];
|
|
for (var i = 0; i < sigBytes; i++) {
|
|
var bite = words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
latin1Chars.push(String.fromCharCode(bite));
|
|
}
|
|
return latin1Chars.join("");
|
|
},
|
|
/**
|
|
* Converts a Latin1 string to a word array.
|
|
*
|
|
* @param {string} latin1Str The Latin1 string.
|
|
*
|
|
* @return {WordArray} The word array.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
|
|
*/
|
|
parse: function(latin1Str) {
|
|
var latin1StrLength = latin1Str.length;
|
|
var words = [];
|
|
for (var i = 0; i < latin1StrLength; i++) {
|
|
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
|
|
}
|
|
return new WordArray.init(words, latin1StrLength);
|
|
}
|
|
};
|
|
var Utf8 = C_enc.Utf8 = {
|
|
/**
|
|
* Converts a word array to a UTF-8 string.
|
|
*
|
|
* @param {WordArray} wordArray The word array.
|
|
*
|
|
* @return {string} The UTF-8 string.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
|
|
*/
|
|
stringify: function(wordArray) {
|
|
try {
|
|
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
|
} catch (e) {
|
|
throw new Error("Malformed UTF-8 data");
|
|
}
|
|
},
|
|
/**
|
|
* Converts a UTF-8 string to a word array.
|
|
*
|
|
* @param {string} utf8Str The UTF-8 string.
|
|
*
|
|
* @return {WordArray} The word array.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
|
|
*/
|
|
parse: function(utf8Str) {
|
|
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
|
}
|
|
};
|
|
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
|
/**
|
|
* Resets this block algorithm's data buffer to its initial state.
|
|
*
|
|
* @example
|
|
*
|
|
* bufferedBlockAlgorithm.reset();
|
|
*/
|
|
reset: function() {
|
|
this._data = new WordArray.init();
|
|
this._nDataBytes = 0;
|
|
},
|
|
/**
|
|
* Adds new data to this block algorithm's buffer.
|
|
*
|
|
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
|
|
*
|
|
* @example
|
|
*
|
|
* bufferedBlockAlgorithm._append('data');
|
|
* bufferedBlockAlgorithm._append(wordArray);
|
|
*/
|
|
_append: function(data) {
|
|
if (typeof data == "string") {
|
|
data = Utf8.parse(data);
|
|
}
|
|
this._data.concat(data);
|
|
this._nDataBytes += data.sigBytes;
|
|
},
|
|
/**
|
|
* Processes available data blocks.
|
|
*
|
|
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
|
|
*
|
|
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
|
|
*
|
|
* @return {WordArray} The processed data.
|
|
*
|
|
* @example
|
|
*
|
|
* var processedData = bufferedBlockAlgorithm._process();
|
|
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
|
|
*/
|
|
_process: function(doFlush) {
|
|
var processedWords;
|
|
var data = this._data;
|
|
var dataWords = data.words;
|
|
var dataSigBytes = data.sigBytes;
|
|
var blockSize = this.blockSize;
|
|
var blockSizeBytes = blockSize * 4;
|
|
var nBlocksReady = dataSigBytes / blockSizeBytes;
|
|
if (doFlush) {
|
|
nBlocksReady = Math2.ceil(nBlocksReady);
|
|
} else {
|
|
nBlocksReady = Math2.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
|
}
|
|
var nWordsReady = nBlocksReady * blockSize;
|
|
var nBytesReady = Math2.min(nWordsReady * 4, dataSigBytes);
|
|
if (nWordsReady) {
|
|
for (var offset = 0; offset < nWordsReady; offset += blockSize) {
|
|
this._doProcessBlock(dataWords, offset);
|
|
}
|
|
processedWords = dataWords.splice(0, nWordsReady);
|
|
data.sigBytes -= nBytesReady;
|
|
}
|
|
return new WordArray.init(processedWords, nBytesReady);
|
|
},
|
|
/**
|
|
* Creates a copy of this object.
|
|
*
|
|
* @return {Object} The clone.
|
|
*
|
|
* @example
|
|
*
|
|
* var clone = bufferedBlockAlgorithm.clone();
|
|
*/
|
|
clone: function() {
|
|
var clone = Base.clone.call(this);
|
|
clone._data = this._data.clone();
|
|
return clone;
|
|
},
|
|
_minBufferSize: 0
|
|
});
|
|
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
|
/**
|
|
* Configuration options.
|
|
*/
|
|
cfg: Base.extend(),
|
|
/**
|
|
* Initializes a newly created hasher.
|
|
*
|
|
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
|
|
*
|
|
* @example
|
|
*
|
|
* var hasher = CryptoJS.algo.SHA256.create();
|
|
*/
|
|
init: function(cfg) {
|
|
this.cfg = this.cfg.extend(cfg);
|
|
this.reset();
|
|
},
|
|
/**
|
|
* Resets this hasher to its initial state.
|
|
*
|
|
* @example
|
|
*
|
|
* hasher.reset();
|
|
*/
|
|
reset: function() {
|
|
BufferedBlockAlgorithm.reset.call(this);
|
|
this._doReset();
|
|
},
|
|
/**
|
|
* Updates this hasher with a message.
|
|
*
|
|
* @param {WordArray|string} messageUpdate The message to append.
|
|
*
|
|
* @return {Hasher} This hasher.
|
|
*
|
|
* @example
|
|
*
|
|
* hasher.update('message');
|
|
* hasher.update(wordArray);
|
|
*/
|
|
update: function(messageUpdate) {
|
|
this._append(messageUpdate);
|
|
this._process();
|
|
return this;
|
|
},
|
|
/**
|
|
* Finalizes the hash computation.
|
|
* Note that the finalize operation is effectively a destructive, read-once operation.
|
|
*
|
|
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
|
*
|
|
* @return {WordArray} The hash.
|
|
*
|
|
* @example
|
|
*
|
|
* var hash = hasher.finalize();
|
|
* var hash = hasher.finalize('message');
|
|
* var hash = hasher.finalize(wordArray);
|
|
*/
|
|
finalize: function(messageUpdate) {
|
|
if (messageUpdate) {
|
|
this._append(messageUpdate);
|
|
}
|
|
var hash = this._doFinalize();
|
|
return hash;
|
|
},
|
|
blockSize: 512 / 32,
|
|
/**
|
|
* Creates a shortcut function to a hasher's object interface.
|
|
*
|
|
* @param {Hasher} hasher The hasher to create a helper for.
|
|
*
|
|
* @return {Function} The shortcut function.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
|
|
*/
|
|
_createHelper: function(hasher) {
|
|
return function(message, cfg) {
|
|
return new hasher.init(cfg).finalize(message);
|
|
};
|
|
},
|
|
/**
|
|
* Creates a shortcut function to the HMAC's object interface.
|
|
*
|
|
* @param {Hasher} hasher The hasher to use in this HMAC helper.
|
|
*
|
|
* @return {Function} The shortcut function.
|
|
*
|
|
* @static
|
|
*
|
|
* @example
|
|
*
|
|
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
|
|
*/
|
|
_createHmacHelper: function(hasher) {
|
|
return function(message, key) {
|
|
return new C_algo.HMAC.init(hasher, key).finalize(message);
|
|
};
|
|
}
|
|
});
|
|
var C_algo = C.algo = {};
|
|
return C;
|
|
}(Math);
|
|
return CryptoJS;
|
|
});
|
|
}
|
|
});
|
|
|
|
export {
|
|
require_core
|
|
};
|
|
//# sourceMappingURL=chunk-CV3XWTUU.js.map
|