diff --git a/README.md b/README.md index 2bb6388..82185e6 100644 --- a/README.md +++ b/README.md @@ -18,23 +18,17 @@ pnpm add @unraid/shared-callbacks ## Usage ```typescript -import { createCallbackStore, CallbackActionsStore } from '@unraid/shared-callbacks'; - -// Define your callback actions store -const useCallbackActions = (): CallbackActionsStore => ({ - saveCallbackData: (decryptedData) => { - // Handle the decrypted callback data - console.log(decryptedData); - }, +import { createCallback } from '@unraid/shared-callbacks'; + +const callback = createCallback({ encryptionKey: 'your-encryption-key', - sendType: 'forUpc' + // Optional: when true (default), encrypted data is stored in the hash + // instead of the `data` query parameter. + useHash: true, }); -// Create the callback store -const callbackStore = createCallbackStore(useCallbackActions); - -// Use the store to send callbacks -callbackStore.send('https://example.com/callback', [ +// Send encrypted callbacks (client-only) +callback.send('https://example.com/callback', [ { type: 'signIn', apiKey: 'your-api-key', @@ -44,8 +38,8 @@ callbackStore.send('https://example.com/callback', [ } ]); -// Watch for incoming callbacks -callbackStore.watcher(); +// Watch for incoming callbacks (client-only) +const decrypted = callback.watcher(); ``` ## API @@ -82,7 +76,7 @@ interface CallbackActionsStore { By default, encrypted callback data is now placed in the URL hash (fragment) rather than a query parameter to help prevent sensitive data from being sent in referrers. -You can control this behavior via the `CallbackConfig` passed to `useCallback`: +You can control this behavior via the `CallbackConfig` passed to `createCallback`: ```ts interface CallbackConfig { @@ -96,3 +90,25 @@ interface CallbackConfig { ``` Parsing helpers (`parse`, `watcher`) support both formats and will read encrypted data from either the hash or the `data` query parameter. + +### Server / client entrypoints + +To make SSR / Workers usage explicit and safe, the package also exposes split entrypoints: + +- `@unraid/shared-callbacks/client` – exports `createCallback` (send, watcher, parse, generateUrl) and all types. This is intended for browser/client-only code. +- `@unraid/shared-callbacks/server` – exports `createServerCallback`, which exposes only `parse` and `generateUrl` and never touches browser globals. + +Example server usage: + +```ts +import { + createServerCallback, + type CallbackConfig, +} from '@unraid/shared-callbacks/server'; + +const config: CallbackConfig = { + encryptionKey: 'your-encryption-key', +}; + +const { parse, generateUrl } = createServerCallback(config); +``` diff --git a/dist/client.d.ts b/dist/client.d.ts new file mode 100644 index 0000000..677a547 --- /dev/null +++ b/dist/client.d.ts @@ -0,0 +1,22 @@ +import type { CallbackConfig, QueryPayloads, SendPayloads, WatcherOptions, SignIn, SignOut, OemSignOut, Troubleshoot, Recover, Replace, TrialExtend, TrialStart, Purchase, Redeem, Renew, Upgrade, UpdateOs, DowngradeOs, Manage, MyKeys, LinkKey, Activate, AccountActionTypes, AccountKeyActionTypes, PurchaseActionTypes, ServerActionTypes, ServerState, ServerData, UserInfo, ExternalSignIn, ExternalSignOut, ExternalKeyActions, ExternalUpdateOsAction, ServerPayload, ServerTroubleshoot, ExternalActions, UpcActions, ExternalPayload, UpcPayload } from "./types.js"; +export declare const createCallback: (config: CallbackConfig) => { + send: (url: string, payload: SendPayloads, redirectType?: "newTab" | "replace" | null, sendType?: string, sender?: string) => void; + parse: (data: string, options?: { + isDataURIEncoded?: boolean; + }) => QueryPayloads; + watcher: (options?: WatcherOptions) => QueryPayloads | undefined; + generateUrl: (url: string, payload: SendPayloads, sendType?: string, sender?: string) => string; +}; +/** + * Backwards-compatible alias for older consumers. + * This no longer returns a shared singleton; it is a plain factory. + */ +export declare const useCallback: (config: CallbackConfig) => { + send: (url: string, payload: SendPayloads, redirectType?: "newTab" | "replace" | null, sendType?: string, sender?: string) => void; + parse: (data: string, options?: { + isDataURIEncoded?: boolean; + }) => QueryPayloads; + watcher: (options?: WatcherOptions) => QueryPayloads | undefined; + generateUrl: (url: string, payload: SendPayloads, sendType?: string, sender?: string) => string; +}; +export type { CallbackConfig, QueryPayloads, SendPayloads, WatcherOptions, SignIn, SignOut, OemSignOut, Troubleshoot, Recover, Replace, TrialExtend, TrialStart, Purchase, Redeem, Renew, Upgrade, UpdateOs, DowngradeOs, Manage, MyKeys, LinkKey, Activate, AccountActionTypes, AccountKeyActionTypes, PurchaseActionTypes, ServerActionTypes, ServerState, ServerData, UserInfo, ExternalSignIn, ExternalSignOut, ExternalKeyActions, ExternalUpdateOsAction, ServerPayload, ServerTroubleshoot, ExternalActions, UpcActions, ExternalPayload, UpcPayload, }; diff --git a/dist/client.js b/dist/client.js new file mode 100644 index 0000000..a84a995 --- /dev/null +++ b/dist/client.js @@ -0,0 +1,2165 @@ +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { + get: (a, b) => (typeof require !== "undefined" ? require : a)[b] +}) : x)(function(x) { + if (typeof require !== "undefined") return require.apply(this, arguments); + throw Error('Dynamic require of "' + x + '" is not supported'); +}); +var __commonJS = (cb, mod) => function __require2() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + __defProp(target, "default", { value: mod, enumerable: true }) , + mod +)); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.js +var require_core = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(); + } else if (typeof define === "function" && define.amd) { + define([], factory); + } else { + root.CryptoJS = factory(); + } + })(exports$1, function() { + var CryptoJS = CryptoJS || (function(Math2, undefined2) { + 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 != undefined2) { + 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 Utf82 = 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 = Utf82.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 + }); + 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; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.js +var require_enc_base64 = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_enc = C.enc; + C_enc.Base64 = { + /** + * Converts a word array to a Base64 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Base64 string. + * + * @static + * + * @example + * + * var base64String = CryptoJS.enc.Base64.stringify(wordArray); + */ + stringify: function(wordArray) { + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + var map = this._map; + wordArray.clamp(); + var base64Chars = []; + for (var i = 0; i < sigBytes; i += 3) { + var byte1 = words[i >>> 2] >>> 24 - i % 4 * 8 & 255; + var byte2 = words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255; + var byte3 = words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255; + var triplet = byte1 << 16 | byte2 << 8 | byte3; + for (var j = 0; j < 4 && i + j * 0.75 < sigBytes; j++) { + base64Chars.push(map.charAt(triplet >>> 6 * (3 - j) & 63)); + } + } + var paddingChar = map.charAt(64); + if (paddingChar) { + while (base64Chars.length % 4) { + base64Chars.push(paddingChar); + } + } + return base64Chars.join(""); + }, + /** + * Converts a Base64 string to a word array. + * + * @param {string} base64Str The Base64 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Base64.parse(base64String); + */ + parse: function(base64Str) { + var base64StrLength = base64Str.length; + var map = this._map; + var reverseMap = this._reverseMap; + if (!reverseMap) { + reverseMap = this._reverseMap = []; + for (var j = 0; j < map.length; j++) { + reverseMap[map.charCodeAt(j)] = j; + } + } + var paddingChar = map.charAt(64); + if (paddingChar) { + var paddingIndex = base64Str.indexOf(paddingChar); + if (paddingIndex !== -1) { + base64StrLength = paddingIndex; + } + } + return parseLoop(base64Str, base64StrLength, reverseMap); + }, + _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" + }; + function parseLoop(base64Str, base64StrLength, reverseMap) { + var words = []; + var nBytes = 0; + for (var i = 0; i < base64StrLength; i++) { + if (i % 4) { + var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << i % 4 * 2; + var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> 6 - i % 4 * 2; + var bitsCombined = bits1 | bits2; + words[nBytes >>> 2] |= bitsCombined << 24 - nBytes % 4 * 8; + nBytes++; + } + } + return WordArray.create(words, nBytes); + } + })(); + return CryptoJS.enc.Base64; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.js +var require_md5 = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function(Math2) { + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + var T = []; + (function() { + for (var i = 0; i < 64; i++) { + T[i] = Math2.abs(Math2.sin(i + 1)) * 4294967296 | 0; + } + })(); + var MD5 = C_algo.MD5 = Hasher.extend({ + _doReset: function() { + this._hash = new WordArray.init([ + 1732584193, + 4023233417, + 2562383102, + 271733878 + ]); + }, + _doProcessBlock: function(M, offset) { + for (var i = 0; i < 16; i++) { + var offset_i = offset + i; + var M_offset_i = M[offset_i]; + M[offset_i] = (M_offset_i << 8 | M_offset_i >>> 24) & 16711935 | (M_offset_i << 24 | M_offset_i >>> 8) & 4278255360; + } + var H = this._hash.words; + var M_offset_0 = M[offset + 0]; + var M_offset_1 = M[offset + 1]; + var M_offset_2 = M[offset + 2]; + var M_offset_3 = M[offset + 3]; + var M_offset_4 = M[offset + 4]; + var M_offset_5 = M[offset + 5]; + var M_offset_6 = M[offset + 6]; + var M_offset_7 = M[offset + 7]; + var M_offset_8 = M[offset + 8]; + var M_offset_9 = M[offset + 9]; + var M_offset_10 = M[offset + 10]; + var M_offset_11 = M[offset + 11]; + var M_offset_12 = M[offset + 12]; + var M_offset_13 = M[offset + 13]; + var M_offset_14 = M[offset + 14]; + var M_offset_15 = M[offset + 15]; + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + a = FF(a, b, c, d, M_offset_0, 7, T[0]); + d = FF(d, a, b, c, M_offset_1, 12, T[1]); + c = FF(c, d, a, b, M_offset_2, 17, T[2]); + b = FF(b, c, d, a, M_offset_3, 22, T[3]); + a = FF(a, b, c, d, M_offset_4, 7, T[4]); + d = FF(d, a, b, c, M_offset_5, 12, T[5]); + c = FF(c, d, a, b, M_offset_6, 17, T[6]); + b = FF(b, c, d, a, M_offset_7, 22, T[7]); + a = FF(a, b, c, d, M_offset_8, 7, T[8]); + d = FF(d, a, b, c, M_offset_9, 12, T[9]); + c = FF(c, d, a, b, M_offset_10, 17, T[10]); + b = FF(b, c, d, a, M_offset_11, 22, T[11]); + a = FF(a, b, c, d, M_offset_12, 7, T[12]); + d = FF(d, a, b, c, M_offset_13, 12, T[13]); + c = FF(c, d, a, b, M_offset_14, 17, T[14]); + b = FF(b, c, d, a, M_offset_15, 22, T[15]); + a = GG(a, b, c, d, M_offset_1, 5, T[16]); + d = GG(d, a, b, c, M_offset_6, 9, T[17]); + c = GG(c, d, a, b, M_offset_11, 14, T[18]); + b = GG(b, c, d, a, M_offset_0, 20, T[19]); + a = GG(a, b, c, d, M_offset_5, 5, T[20]); + d = GG(d, a, b, c, M_offset_10, 9, T[21]); + c = GG(c, d, a, b, M_offset_15, 14, T[22]); + b = GG(b, c, d, a, M_offset_4, 20, T[23]); + a = GG(a, b, c, d, M_offset_9, 5, T[24]); + d = GG(d, a, b, c, M_offset_14, 9, T[25]); + c = GG(c, d, a, b, M_offset_3, 14, T[26]); + b = GG(b, c, d, a, M_offset_8, 20, T[27]); + a = GG(a, b, c, d, M_offset_13, 5, T[28]); + d = GG(d, a, b, c, M_offset_2, 9, T[29]); + c = GG(c, d, a, b, M_offset_7, 14, T[30]); + b = GG(b, c, d, a, M_offset_12, 20, T[31]); + a = HH(a, b, c, d, M_offset_5, 4, T[32]); + d = HH(d, a, b, c, M_offset_8, 11, T[33]); + c = HH(c, d, a, b, M_offset_11, 16, T[34]); + b = HH(b, c, d, a, M_offset_14, 23, T[35]); + a = HH(a, b, c, d, M_offset_1, 4, T[36]); + d = HH(d, a, b, c, M_offset_4, 11, T[37]); + c = HH(c, d, a, b, M_offset_7, 16, T[38]); + b = HH(b, c, d, a, M_offset_10, 23, T[39]); + a = HH(a, b, c, d, M_offset_13, 4, T[40]); + d = HH(d, a, b, c, M_offset_0, 11, T[41]); + c = HH(c, d, a, b, M_offset_3, 16, T[42]); + b = HH(b, c, d, a, M_offset_6, 23, T[43]); + a = HH(a, b, c, d, M_offset_9, 4, T[44]); + d = HH(d, a, b, c, M_offset_12, 11, T[45]); + c = HH(c, d, a, b, M_offset_15, 16, T[46]); + b = HH(b, c, d, a, M_offset_2, 23, T[47]); + a = II(a, b, c, d, M_offset_0, 6, T[48]); + d = II(d, a, b, c, M_offset_7, 10, T[49]); + c = II(c, d, a, b, M_offset_14, 15, T[50]); + b = II(b, c, d, a, M_offset_5, 21, T[51]); + a = II(a, b, c, d, M_offset_12, 6, T[52]); + d = II(d, a, b, c, M_offset_3, 10, T[53]); + c = II(c, d, a, b, M_offset_10, 15, T[54]); + b = II(b, c, d, a, M_offset_1, 21, T[55]); + a = II(a, b, c, d, M_offset_8, 6, T[56]); + d = II(d, a, b, c, M_offset_15, 10, T[57]); + c = II(c, d, a, b, M_offset_6, 15, T[58]); + b = II(b, c, d, a, M_offset_13, 21, T[59]); + a = II(a, b, c, d, M_offset_4, 6, T[60]); + d = II(d, a, b, c, M_offset_11, 10, T[61]); + c = II(c, d, a, b, M_offset_2, 15, T[62]); + b = II(b, c, d, a, M_offset_9, 21, T[63]); + H[0] = H[0] + a | 0; + H[1] = H[1] + b | 0; + H[2] = H[2] + c | 0; + H[3] = H[3] + d | 0; + }, + _doFinalize: function() { + var data = this._data; + var dataWords = data.words; + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32; + var nBitsTotalH = Math2.floor(nBitsTotal / 4294967296); + var nBitsTotalL = nBitsTotal; + dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = (nBitsTotalH << 8 | nBitsTotalH >>> 24) & 16711935 | (nBitsTotalH << 24 | nBitsTotalH >>> 8) & 4278255360; + dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = (nBitsTotalL << 8 | nBitsTotalL >>> 24) & 16711935 | (nBitsTotalL << 24 | nBitsTotalL >>> 8) & 4278255360; + data.sigBytes = (dataWords.length + 1) * 4; + this._process(); + var hash = this._hash; + var H = hash.words; + for (var i = 0; i < 4; i++) { + var H_i = H[i]; + H[i] = (H_i << 8 | H_i >>> 24) & 16711935 | (H_i << 24 | H_i >>> 8) & 4278255360; + } + return hash; + }, + clone: function() { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + return clone; + } + }); + function FF(a, b, c, d, x, s, t) { + var n = a + (b & c | ~b & d) + x + t; + return (n << s | n >>> 32 - s) + b; + } + function GG(a, b, c, d, x, s, t) { + var n = a + (b & d | c & ~d) + x + t; + return (n << s | n >>> 32 - s) + b; + } + function HH(a, b, c, d, x, s, t) { + var n = a + (b ^ c ^ d) + x + t; + return (n << s | n >>> 32 - s) + b; + } + function II(a, b, c, d, x, s, t) { + var n = a + (c ^ (b | ~d)) + x + t; + return (n << s | n >>> 32 - s) + b; + } + C.MD5 = Hasher._createHelper(MD5); + C.HmacMD5 = Hasher._createHmacHelper(MD5); + })(Math); + return CryptoJS.MD5; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.js +var require_sha1 = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + var W = []; + var SHA1 = C_algo.SHA1 = Hasher.extend({ + _doReset: function() { + this._hash = new WordArray.init([ + 1732584193, + 4023233417, + 2562383102, + 271733878, + 3285377520 + ]); + }, + _doProcessBlock: function(M, offset) { + var H = this._hash.words; + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + var e = H[4]; + for (var i = 0; i < 80; i++) { + if (i < 16) { + W[i] = M[offset + i] | 0; + } else { + var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; + W[i] = n << 1 | n >>> 31; + } + var t = (a << 5 | a >>> 27) + e + W[i]; + if (i < 20) { + t += (b & c | ~b & d) + 1518500249; + } else if (i < 40) { + t += (b ^ c ^ d) + 1859775393; + } else if (i < 60) { + t += (b & c | b & d | c & d) - 1894007588; + } else { + t += (b ^ c ^ d) - 899497514; + } + e = d; + d = c; + c = b << 30 | b >>> 2; + b = a; + a = t; + } + H[0] = H[0] + a | 0; + H[1] = H[1] + b | 0; + H[2] = H[2] + c | 0; + H[3] = H[3] + d | 0; + H[4] = H[4] + e | 0; + }, + _doFinalize: function() { + var data = this._data; + var dataWords = data.words; + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32; + dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math.floor(nBitsTotal / 4294967296); + dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal; + data.sigBytes = dataWords.length * 4; + this._process(); + return this._hash; + }, + clone: function() { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + return clone; + } + }); + C.SHA1 = Hasher._createHelper(SHA1); + C.HmacSHA1 = Hasher._createHmacHelper(SHA1); + })(); + return CryptoJS.SHA1; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.js +var require_hmac = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var C_enc = C.enc; + var Utf82 = C_enc.Utf8; + var C_algo = C.algo; + C_algo.HMAC = Base.extend({ + /** + * Initializes a newly created HMAC. + * + * @param {Hasher} hasher The hash algorithm to use. + * @param {WordArray|string} key The secret key. + * + * @example + * + * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); + */ + init: function(hasher, key) { + hasher = this._hasher = new hasher.init(); + if (typeof key == "string") { + key = Utf82.parse(key); + } + var hasherBlockSize = hasher.blockSize; + var hasherBlockSizeBytes = hasherBlockSize * 4; + if (key.sigBytes > hasherBlockSizeBytes) { + key = hasher.finalize(key); + } + key.clamp(); + var oKey = this._oKey = key.clone(); + var iKey = this._iKey = key.clone(); + var oKeyWords = oKey.words; + var iKeyWords = iKey.words; + for (var i = 0; i < hasherBlockSize; i++) { + oKeyWords[i] ^= 1549556828; + iKeyWords[i] ^= 909522486; + } + oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes; + this.reset(); + }, + /** + * Resets this HMAC to its initial state. + * + * @example + * + * hmacHasher.reset(); + */ + reset: function() { + var hasher = this._hasher; + hasher.reset(); + hasher.update(this._iKey); + }, + /** + * Updates this HMAC with a message. + * + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {HMAC} This HMAC instance. + * + * @example + * + * hmacHasher.update('message'); + * hmacHasher.update(wordArray); + */ + update: function(messageUpdate) { + this._hasher.update(messageUpdate); + return this; + }, + /** + * Finalizes the HMAC 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 HMAC. + * + * @example + * + * var hmac = hmacHasher.finalize(); + * var hmac = hmacHasher.finalize('message'); + * var hmac = hmacHasher.finalize(wordArray); + */ + finalize: function(messageUpdate) { + var hasher = this._hasher; + var innerHash = hasher.finalize(messageUpdate); + hasher.reset(); + var hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); + return hmac; + } + }); + })(); + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.js +var require_evpkdf = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.js"(exports$1, module) { + (function(root, factory, undef) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core(), require_sha1(), require_hmac()); + } else if (typeof define === "function" && define.amd) { + define(["./core", "./sha1", "./hmac"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var C_algo = C.algo; + var MD5 = C_algo.MD5; + var EvpKDF = C_algo.EvpKDF = Base.extend({ + /** + * Configuration options. + * + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) + * @property {Hasher} hasher The hash algorithm to use. Default: MD5 + * @property {number} iterations The number of iterations to perform. Default: 1 + */ + cfg: Base.extend({ + keySize: 128 / 32, + hasher: MD5, + iterations: 1 + }), + /** + * Initializes a newly created key derivation function. + * + * @param {Object} cfg (Optional) The configuration options to use for the derivation. + * + * @example + * + * var kdf = CryptoJS.algo.EvpKDF.create(); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); + */ + init: function(cfg) { + this.cfg = this.cfg.extend(cfg); + }, + /** + * Derives a key from a password. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * + * @return {WordArray} The derived key. + * + * @example + * + * var key = kdf.compute(password, salt); + */ + compute: function(password, salt) { + var block; + var cfg = this.cfg; + var hasher = cfg.hasher.create(); + var derivedKey = WordArray.create(); + var derivedKeyWords = derivedKey.words; + var keySize = cfg.keySize; + var iterations = cfg.iterations; + while (derivedKeyWords.length < keySize) { + if (block) { + hasher.update(block); + } + block = hasher.update(password).finalize(salt); + hasher.reset(); + for (var i = 1; i < iterations; i++) { + block = hasher.finalize(block); + hasher.reset(); + } + derivedKey.concat(block); + } + derivedKey.sigBytes = keySize * 4; + return derivedKey; + } + }); + C.EvpKDF = function(password, salt, cfg) { + return EvpKDF.create(cfg).compute(password, salt); + }; + })(); + return CryptoJS.EvpKDF; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.js +var require_cipher_core = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.js"(exports$1, module) { + (function(root, factory, undef) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core(), require_evpkdf()); + } else if (typeof define === "function" && define.amd) { + define(["./core", "./evpkdf"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + CryptoJS.lib.Cipher || (function(undefined2) { + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm; + var C_enc = C.enc; + C_enc.Utf8; + var Base64 = C_enc.Base64; + var C_algo = C.algo; + var EvpKDF = C_algo.EvpKDF; + var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({ + /** + * Configuration options. + * + * @property {WordArray} iv The IV to use for this operation. + */ + cfg: Base.extend(), + /** + * Creates this cipher in encryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); + */ + createEncryptor: function(key, cfg) { + return this.create(this._ENC_XFORM_MODE, key, cfg); + }, + /** + * Creates this cipher in decryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); + */ + createDecryptor: function(key, cfg) { + return this.create(this._DEC_XFORM_MODE, key, cfg); + }, + /** + * Initializes a newly created cipher. + * + * @param {number} xformMode Either the encryption or decryption transormation mode constant. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @example + * + * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); + */ + init: function(xformMode, key, cfg) { + this.cfg = this.cfg.extend(cfg); + this._xformMode = xformMode; + this._key = key; + this.reset(); + }, + /** + * Resets this cipher to its initial state. + * + * @example + * + * cipher.reset(); + */ + reset: function() { + BufferedBlockAlgorithm.reset.call(this); + this._doReset(); + }, + /** + * Adds data to be encrypted or decrypted. + * + * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. + * + * @return {WordArray} The data after processing. + * + * @example + * + * var encrypted = cipher.process('data'); + * var encrypted = cipher.process(wordArray); + */ + process: function(dataUpdate) { + this._append(dataUpdate); + return this._process(); + }, + /** + * Finalizes the encryption or decryption process. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. + * + * @return {WordArray} The data after final processing. + * + * @example + * + * var encrypted = cipher.finalize(); + * var encrypted = cipher.finalize('data'); + * var encrypted = cipher.finalize(wordArray); + */ + finalize: function(dataUpdate) { + if (dataUpdate) { + this._append(dataUpdate); + } + var finalProcessedData = this._doFinalize(); + return finalProcessedData; + }, + keySize: 128 / 32, + ivSize: 128 / 32, + _ENC_XFORM_MODE: 1, + _DEC_XFORM_MODE: 2, + /** + * Creates shortcut functions to a cipher's object interface. + * + * @param {Cipher} cipher The cipher to create a helper for. + * + * @return {Object} An object with encrypt and decrypt shortcut functions. + * + * @static + * + * @example + * + * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); + */ + _createHelper: /* @__PURE__ */ (function() { + function selectCipherStrategy(key) { + if (typeof key == "string") { + return PasswordBasedCipher; + } else { + return SerializableCipher; + } + } + return function(cipher) { + return { + encrypt: function(message, key, cfg) { + return selectCipherStrategy(key).encrypt(cipher, message, key, cfg); + }, + decrypt: function(ciphertext, key, cfg) { + return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); + } + }; + }; + })() + }); + C_lib.StreamCipher = Cipher.extend({ + _doFinalize: function() { + var finalProcessedBlocks = this._process(true); + return finalProcessedBlocks; + }, + blockSize: 1 + }); + var C_mode = C.mode = {}; + var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({ + /** + * Creates this mode for encryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); + */ + createEncryptor: function(cipher, iv) { + return this.Encryptor.create(cipher, iv); + }, + /** + * Creates this mode for decryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); + */ + createDecryptor: function(cipher, iv) { + return this.Decryptor.create(cipher, iv); + }, + /** + * Initializes a newly created mode. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @example + * + * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); + */ + init: function(cipher, iv) { + this._cipher = cipher; + this._iv = iv; + } + }); + var CBC = C_mode.CBC = (function() { + var CBC2 = BlockCipherMode.extend(); + CBC2.Encryptor = CBC2.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function(words, offset) { + var cipher = this._cipher; + var blockSize = cipher.blockSize; + xorBlock.call(this, words, offset, blockSize); + cipher.encryptBlock(words, offset); + this._prevBlock = words.slice(offset, offset + blockSize); + } + }); + CBC2.Decryptor = CBC2.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function(words, offset) { + var cipher = this._cipher; + var blockSize = cipher.blockSize; + var thisBlock = words.slice(offset, offset + blockSize); + cipher.decryptBlock(words, offset); + xorBlock.call(this, words, offset, blockSize); + this._prevBlock = thisBlock; + } + }); + function xorBlock(words, offset, blockSize) { + var block; + var iv = this._iv; + if (iv) { + block = iv; + this._iv = undefined2; + } else { + block = this._prevBlock; + } + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= block[i]; + } + } + return CBC2; + })(); + var C_pad = C.pad = {}; + var Pkcs7 = C_pad.Pkcs7 = { + /** + * Pads data using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to pad. + * @param {number} blockSize The multiple that the data should be padded to. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.pad(wordArray, 4); + */ + pad: function(data, blockSize) { + var blockSizeBytes = blockSize * 4; + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; + var paddingWord = nPaddingBytes << 24 | nPaddingBytes << 16 | nPaddingBytes << 8 | nPaddingBytes; + var paddingWords = []; + for (var i = 0; i < nPaddingBytes; i += 4) { + paddingWords.push(paddingWord); + } + var padding = WordArray.create(paddingWords, nPaddingBytes); + data.concat(padding); + }, + /** + * Unpads data that had been padded using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to unpad. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.unpad(wordArray); + */ + unpad: function(data) { + var nPaddingBytes = data.words[data.sigBytes - 1 >>> 2] & 255; + data.sigBytes -= nPaddingBytes; + } + }; + C_lib.BlockCipher = Cipher.extend({ + /** + * Configuration options. + * + * @property {Mode} mode The block mode to use. Default: CBC + * @property {Padding} padding The padding strategy to use. Default: Pkcs7 + */ + cfg: Cipher.cfg.extend({ + mode: CBC, + padding: Pkcs7 + }), + reset: function() { + var modeCreator; + Cipher.reset.call(this); + var cfg = this.cfg; + var iv = cfg.iv; + var mode = cfg.mode; + if (this._xformMode == this._ENC_XFORM_MODE) { + modeCreator = mode.createEncryptor; + } else { + modeCreator = mode.createDecryptor; + this._minBufferSize = 1; + } + if (this._mode && this._mode.__creator == modeCreator) { + this._mode.init(this, iv && iv.words); + } else { + this._mode = modeCreator.call(mode, this, iv && iv.words); + this._mode.__creator = modeCreator; + } + }, + _doProcessBlock: function(words, offset) { + this._mode.processBlock(words, offset); + }, + _doFinalize: function() { + var finalProcessedBlocks; + var padding = this.cfg.padding; + if (this._xformMode == this._ENC_XFORM_MODE) { + padding.pad(this._data, this.blockSize); + finalProcessedBlocks = this._process(true); + } else { + finalProcessedBlocks = this._process(true); + padding.unpad(finalProcessedBlocks); + } + return finalProcessedBlocks; + }, + blockSize: 128 / 32 + }); + var CipherParams = C_lib.CipherParams = Base.extend({ + /** + * Initializes a newly created cipher params object. + * + * @param {Object} cipherParams An object with any of the possible cipher parameters. + * + * @example + * + * var cipherParams = CryptoJS.lib.CipherParams.create({ + * ciphertext: ciphertextWordArray, + * key: keyWordArray, + * iv: ivWordArray, + * salt: saltWordArray, + * algorithm: CryptoJS.algo.AES, + * mode: CryptoJS.mode.CBC, + * padding: CryptoJS.pad.PKCS7, + * blockSize: 4, + * formatter: CryptoJS.format.OpenSSL + * }); + */ + init: function(cipherParams) { + this.mixIn(cipherParams); + }, + /** + * Converts this cipher params object to a string. + * + * @param {Format} formatter (Optional) The formatting strategy to use. + * + * @return {string} The stringified cipher params. + * + * @throws Error If neither the formatter nor the default formatter is set. + * + * @example + * + * var string = cipherParams + ''; + * var string = cipherParams.toString(); + * var string = cipherParams.toString(CryptoJS.format.OpenSSL); + */ + toString: function(formatter) { + return (formatter || this.formatter).stringify(this); + } + }); + var C_format = C.format = {}; + var OpenSSLFormatter = C_format.OpenSSL = { + /** + * Converts a cipher params object to an OpenSSL-compatible string. + * + * @param {CipherParams} cipherParams The cipher params object. + * + * @return {string} The OpenSSL-compatible string. + * + * @static + * + * @example + * + * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); + */ + stringify: function(cipherParams) { + var wordArray; + var ciphertext = cipherParams.ciphertext; + var salt = cipherParams.salt; + if (salt) { + wordArray = WordArray.create([1398893684, 1701076831]).concat(salt).concat(ciphertext); + } else { + wordArray = ciphertext; + } + return wordArray.toString(Base64); + }, + /** + * Converts an OpenSSL-compatible string to a cipher params object. + * + * @param {string} openSSLStr The OpenSSL-compatible string. + * + * @return {CipherParams} The cipher params object. + * + * @static + * + * @example + * + * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); + */ + parse: function(openSSLStr) { + var salt; + var ciphertext = Base64.parse(openSSLStr); + var ciphertextWords = ciphertext.words; + if (ciphertextWords[0] == 1398893684 && ciphertextWords[1] == 1701076831) { + salt = WordArray.create(ciphertextWords.slice(2, 4)); + ciphertextWords.splice(0, 4); + ciphertext.sigBytes -= 16; + } + return CipherParams.create({ ciphertext, salt }); + } + }; + var SerializableCipher = C_lib.SerializableCipher = Base.extend({ + /** + * Configuration options. + * + * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL + */ + cfg: Base.extend({ + format: OpenSSLFormatter + }), + /** + * Encrypts a message. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + encrypt: function(cipher, message, key, cfg) { + cfg = this.cfg.extend(cfg); + var encryptor = cipher.createEncryptor(key, cfg); + var ciphertext = encryptor.finalize(message); + var cipherCfg = encryptor.cfg; + return CipherParams.create({ + ciphertext, + key, + iv: cipherCfg.iv, + algorithm: cipher, + mode: cipherCfg.mode, + padding: cipherCfg.padding, + blockSize: cipher.blockSize, + formatter: cfg.format + }); + }, + /** + * Decrypts serialized ciphertext. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + decrypt: function(cipher, ciphertext, key, cfg) { + cfg = this.cfg.extend(cfg); + ciphertext = this._parse(ciphertext, cfg.format); + var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext); + return plaintext; + }, + /** + * Converts serialized ciphertext to CipherParams, + * else assumed CipherParams already and returns ciphertext unchanged. + * + * @param {CipherParams|string} ciphertext The ciphertext. + * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. + * + * @return {CipherParams} The unserialized ciphertext. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format); + */ + _parse: function(ciphertext, format) { + if (typeof ciphertext == "string") { + return format.parse(ciphertext, this); + } else { + return ciphertext; + } + } + }); + var C_kdf = C.kdf = {}; + var OpenSSLKdf = C_kdf.OpenSSL = { + /** + * Derives a key and IV from a password. + * + * @param {string} password The password to derive from. + * @param {number} keySize The size in words of the key to generate. + * @param {number} ivSize The size in words of the IV to generate. + * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. + * + * @return {CipherParams} A cipher params object with the key, IV, and salt. + * + * @static + * + * @example + * + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); + */ + execute: function(password, keySize, ivSize, salt, hasher) { + if (!salt) { + salt = WordArray.random(64 / 8); + } + if (!hasher) { + var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt); + } else { + var key = EvpKDF.create({ keySize: keySize + ivSize, hasher }).compute(password, salt); + } + var iv = WordArray.create(key.words.slice(keySize), ivSize * 4); + key.sigBytes = keySize * 4; + return CipherParams.create({ key, iv, salt }); + } + }; + var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({ + /** + * Configuration options. + * + * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL + */ + cfg: SerializableCipher.cfg.extend({ + kdf: OpenSSLKdf + }), + /** + * Encrypts a message using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password'); + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); + */ + encrypt: function(cipher, message, password, cfg) { + cfg = this.cfg.extend(cfg); + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, cfg.salt, cfg.hasher); + cfg.iv = derivedParams.iv; + var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg); + ciphertext.mixIn(derivedParams); + return ciphertext; + }, + /** + * Decrypts serialized ciphertext using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL }); + */ + decrypt: function(cipher, ciphertext, password, cfg) { + cfg = this.cfg.extend(cfg); + ciphertext = this._parse(ciphertext, cfg.format); + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt, cfg.hasher); + cfg.iv = derivedParams.iv; + var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg); + return plaintext; + } + }); + })(); + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js +var require_aes = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js"(exports$1, module) { + (function(root, factory, undef) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core(), require_enc_base64(), require_md5(), require_evpkdf(), require_cipher_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var BlockCipher = C_lib.BlockCipher; + var C_algo = C.algo; + var SBOX = []; + var INV_SBOX = []; + var SUB_MIX_0 = []; + var SUB_MIX_1 = []; + var SUB_MIX_2 = []; + var SUB_MIX_3 = []; + var INV_SUB_MIX_0 = []; + var INV_SUB_MIX_1 = []; + var INV_SUB_MIX_2 = []; + var INV_SUB_MIX_3 = []; + (function() { + var d = []; + for (var i = 0; i < 256; i++) { + if (i < 128) { + d[i] = i << 1; + } else { + d[i] = i << 1 ^ 283; + } + } + var x = 0; + var xi = 0; + for (var i = 0; i < 256; i++) { + var sx = xi ^ xi << 1 ^ xi << 2 ^ xi << 3 ^ xi << 4; + sx = sx >>> 8 ^ sx & 255 ^ 99; + SBOX[x] = sx; + INV_SBOX[sx] = x; + var x2 = d[x]; + var x4 = d[x2]; + var x8 = d[x4]; + var t = d[sx] * 257 ^ sx * 16843008; + SUB_MIX_0[x] = t << 24 | t >>> 8; + SUB_MIX_1[x] = t << 16 | t >>> 16; + SUB_MIX_2[x] = t << 8 | t >>> 24; + SUB_MIX_3[x] = t; + var t = x8 * 16843009 ^ x4 * 65537 ^ x2 * 257 ^ x * 16843008; + INV_SUB_MIX_0[sx] = t << 24 | t >>> 8; + INV_SUB_MIX_1[sx] = t << 16 | t >>> 16; + INV_SUB_MIX_2[sx] = t << 8 | t >>> 24; + INV_SUB_MIX_3[sx] = t; + if (!x) { + x = xi = 1; + } else { + x = x2 ^ d[d[d[x8 ^ x2]]]; + xi ^= d[d[xi]]; + } + } + })(); + var RCON = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54]; + var AES2 = C_algo.AES = BlockCipher.extend({ + _doReset: function() { + var t; + if (this._nRounds && this._keyPriorReset === this._key) { + return; + } + var key = this._keyPriorReset = this._key; + var keyWords = key.words; + var keySize = key.sigBytes / 4; + var nRounds = this._nRounds = keySize + 6; + var ksRows = (nRounds + 1) * 4; + var keySchedule = this._keySchedule = []; + for (var ksRow = 0; ksRow < ksRows; ksRow++) { + if (ksRow < keySize) { + keySchedule[ksRow] = keyWords[ksRow]; + } else { + t = keySchedule[ksRow - 1]; + if (!(ksRow % keySize)) { + t = t << 8 | t >>> 24; + t = SBOX[t >>> 24] << 24 | SBOX[t >>> 16 & 255] << 16 | SBOX[t >>> 8 & 255] << 8 | SBOX[t & 255]; + t ^= RCON[ksRow / keySize | 0] << 24; + } else if (keySize > 6 && ksRow % keySize == 4) { + t = SBOX[t >>> 24] << 24 | SBOX[t >>> 16 & 255] << 16 | SBOX[t >>> 8 & 255] << 8 | SBOX[t & 255]; + } + keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; + } + } + var invKeySchedule = this._invKeySchedule = []; + for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { + var ksRow = ksRows - invKsRow; + if (invKsRow % 4) { + var t = keySchedule[ksRow]; + } else { + var t = keySchedule[ksRow - 4]; + } + if (invKsRow < 4 || ksRow <= 4) { + invKeySchedule[invKsRow] = t; + } else { + invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[t >>> 16 & 255]] ^ INV_SUB_MIX_2[SBOX[t >>> 8 & 255]] ^ INV_SUB_MIX_3[SBOX[t & 255]]; + } + } + }, + encryptBlock: function(M, offset) { + this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); + }, + decryptBlock: function(M, offset) { + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + }, + _doCryptBlock: function(M, offset, keySchedule, SUB_MIX_02, SUB_MIX_12, SUB_MIX_22, SUB_MIX_32, SBOX2) { + var nRounds = this._nRounds; + var s0 = M[offset] ^ keySchedule[0]; + var s1 = M[offset + 1] ^ keySchedule[1]; + var s2 = M[offset + 2] ^ keySchedule[2]; + var s3 = M[offset + 3] ^ keySchedule[3]; + var ksRow = 4; + for (var round = 1; round < nRounds; round++) { + var t0 = SUB_MIX_02[s0 >>> 24] ^ SUB_MIX_12[s1 >>> 16 & 255] ^ SUB_MIX_22[s2 >>> 8 & 255] ^ SUB_MIX_32[s3 & 255] ^ keySchedule[ksRow++]; + var t1 = SUB_MIX_02[s1 >>> 24] ^ SUB_MIX_12[s2 >>> 16 & 255] ^ SUB_MIX_22[s3 >>> 8 & 255] ^ SUB_MIX_32[s0 & 255] ^ keySchedule[ksRow++]; + var t2 = SUB_MIX_02[s2 >>> 24] ^ SUB_MIX_12[s3 >>> 16 & 255] ^ SUB_MIX_22[s0 >>> 8 & 255] ^ SUB_MIX_32[s1 & 255] ^ keySchedule[ksRow++]; + var t3 = SUB_MIX_02[s3 >>> 24] ^ SUB_MIX_12[s0 >>> 16 & 255] ^ SUB_MIX_22[s1 >>> 8 & 255] ^ SUB_MIX_32[s2 & 255] ^ keySchedule[ksRow++]; + s0 = t0; + s1 = t1; + s2 = t2; + s3 = t3; + } + var t0 = (SBOX2[s0 >>> 24] << 24 | SBOX2[s1 >>> 16 & 255] << 16 | SBOX2[s2 >>> 8 & 255] << 8 | SBOX2[s3 & 255]) ^ keySchedule[ksRow++]; + var t1 = (SBOX2[s1 >>> 24] << 24 | SBOX2[s2 >>> 16 & 255] << 16 | SBOX2[s3 >>> 8 & 255] << 8 | SBOX2[s0 & 255]) ^ keySchedule[ksRow++]; + var t2 = (SBOX2[s2 >>> 24] << 24 | SBOX2[s3 >>> 16 & 255] << 16 | SBOX2[s0 >>> 8 & 255] << 8 | SBOX2[s1 & 255]) ^ keySchedule[ksRow++]; + var t3 = (SBOX2[s3 >>> 24] << 24 | SBOX2[s0 >>> 16 & 255] << 16 | SBOX2[s1 >>> 8 & 255] << 8 | SBOX2[s2 & 255]) ^ keySchedule[ksRow++]; + M[offset] = t0; + M[offset + 1] = t1; + M[offset + 2] = t2; + M[offset + 3] = t3; + }, + keySize: 256 / 32 + }); + C.AES = BlockCipher._createHelper(AES2); + })(); + return CryptoJS.AES; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js +var require_enc_utf8 = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + return CryptoJS.enc.Utf8; + }); + } +}); + +// src/core.ts +var import_aes = __toESM(require_aes()); +var import_enc_utf8 = __toESM(require_enc_utf8()); +var encryptData = (data, encryptionKey) => { + return import_aes.default.encrypt(data, encryptionKey).toString(); +}; +var decryptData = (encryptedData, encryptionKey) => { + const decryptedMessage = import_aes.default.decrypt(encryptedData, encryptionKey); + let decryptedString; + try { + decryptedString = decryptedMessage.toString(import_enc_utf8.default); + } catch { + throw new Error("Decryption failed. Invalid key or corrupt data."); + } + if (!decryptedString) { + throw new Error("Decryption failed. Invalid key or corrupt data."); + } + return decryptedString; +}; +var stringifyPayload = (payload, sender, sendType) => { + return JSON.stringify({ + actions: [...payload], + sender, + type: sendType + }); +}; +var createEncryptedPayload = (payload, sender, sendType, encryptionKey) => { + const stringifiedData = stringifyPayload(payload, sender, sendType); + return encryptData(stringifiedData, encryptionKey); +}; +var parseEncryptedPayload = (encryptedData, encryptionKey, options) => { + const dataToParse = options?.isDataURIEncoded ? decodeURI(encryptedData) : encryptedData; + const decryptedString = decryptData(dataToParse, encryptionKey); + try { + const decryptedData = JSON.parse(decryptedString); + return decryptedData; + } catch { + throw new Error("Failed to parse decrypted data."); + } +}; +var appendEncryptedDataToUrl = (url, encryptedData, useHash) => { + const destinationUrl = new URL(url); + if (useHash) { + destinationUrl.hash = `data=${encodeURI(encryptedData)}`; + } else { + destinationUrl.searchParams.set("data", encodeURI(encryptedData)); + } + return destinationUrl.toString(); +}; + +// src/client.ts +var createCallback = (config) => { + const shouldUseHash = config.useHash !== false; + const send = (url, payload, redirectType, sendType, sender) => { + if (typeof window === "undefined") { + throw new Error("send() can only be called on the client side"); + } + const defaultSender = sender ?? window.location.href.replace("/Tools/Update", "/Tools"); + const encryptedMessage = createEncryptedPayload( + payload, + defaultSender, + sendType, + config.encryptionKey + ); + const destinationUrl = appendEncryptedDataToUrl( + url.replace("/Tools/Update", "/Tools"), + encryptedMessage, + shouldUseHash + ); + if (redirectType === "newTab") { + window.open(destinationUrl, "_blank"); + return; + } + if (redirectType === "replace") { + window.location.replace(destinationUrl); + return; + } + window.location.href = destinationUrl; + }; + const parse = (data, options) => { + return parseEncryptedPayload(data, config.encryptionKey, options); + }; + const watcher = (options = {}) => { + let urlToParse = ""; + if (options?.baseUrl && !options.skipCurrentUrl) { + urlToParse = options.baseUrl; + } else if (typeof window !== "undefined" && window.location && !options.skipCurrentUrl) { + urlToParse = window.location.toString(); + } else if (!options?.dataToParse && !options?.baseUrl) { + return void 0; + } + const uriDecodedEncryptedData = options?.dataToParse ? decodeURI(options.dataToParse) : (() => { + try { + const currentUrl = new URL(urlToParse); + const searchParamData = currentUrl.searchParams.get("data") ?? ""; + let hashData = ""; + const rawHash = currentUrl.hash ?? ""; + if (rawHash) { + const hashWithoutHash = rawHash.startsWith("#") ? rawHash.slice(1) : rawHash; + if (hashWithoutHash.startsWith("data=")) { + hashData = hashWithoutHash.slice("data=".length); + } + } + const dataFromUrl = searchParamData || hashData; + return decodeURI(dataFromUrl); + } catch { + return ""; + } + })(); + if (!uriDecodedEncryptedData) { + return void 0; + } + return parse(uriDecodedEncryptedData); + }; + const generateUrl = (url, payload, sendType, sender) => { + const defaultSender = sender ?? (typeof window !== "undefined" ? window.location.href.replace("/Tools/Update", "/Tools") : ""); + const encryptedMessage = createEncryptedPayload( + payload, + defaultSender, + sendType, + config.encryptionKey + ); + return appendEncryptedDataToUrl(url, encryptedMessage, shouldUseHash); + }; + return { + send, + parse, + watcher, + generateUrl + }; +}; +var useCallback = createCallback; + +export { createCallback, useCallback }; diff --git a/dist/core.d.ts b/dist/core.d.ts new file mode 100644 index 0000000..22abb9e --- /dev/null +++ b/dist/core.d.ts @@ -0,0 +1,28 @@ +import type { QueryPayloads, SendPayloads } from "./types"; +/** + * Encrypts a string using AES encryption. + */ +export declare const encryptData: (data: string, encryptionKey: string) => string; +/** + * Decrypts an encrypted string using AES decryption. + * Throws when decryption fails or results in invalid / empty UTF-8. + */ +export declare const decryptData: (encryptedData: string, encryptionKey: string) => string; +/** + * Stringifies a payload into the standard callback data format. + */ +export declare const stringifyPayload: (payload: SendPayloads, sender: string, sendType?: string) => string; +/** + * Creates an encrypted data string from a payload. + */ +export declare const createEncryptedPayload: (payload: SendPayloads, sender: string, sendType: string | undefined, encryptionKey: string) => string; +/** + * Parses an encrypted callback payload string into its typed structure. + */ +export declare const parseEncryptedPayload: (encryptedData: string, encryptionKey: string, options?: { + isDataURIEncoded?: boolean; +}) => QueryPayloads; +/** + * Appends encrypted callback data to a URL, using either hash or query param. + */ +export declare const appendEncryptedDataToUrl: (url: string, encryptedData: string, useHash: boolean) => string; diff --git a/dist/index.d.ts b/dist/index.d.ts index 5ec5875..5ec7692 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,10 +1 @@ -import type { CallbackConfig, QueryPayloads, SendPayloads, WatcherOptions, SignIn, SignOut, OemSignOut, Troubleshoot, Recover, Replace, TrialExtend, TrialStart, Purchase, Redeem, Renew, Upgrade, UpdateOs, DowngradeOs, Manage, MyKeys, LinkKey, Activate, AccountActionTypes, AccountKeyActionTypes, PurchaseActionTypes, ServerActionTypes, ServerState, ServerData, UserInfo, ExternalSignIn, ExternalSignOut, ExternalKeyActions, ExternalUpdateOsAction, ServerPayload, ServerTroubleshoot, ExternalActions, UpcActions, ExternalPayload, UpcPayload } from "./types.js"; -export declare const useCallback: (config: CallbackConfig) => { - send: (url: string, payload: SendPayloads, redirectType?: "newTab" | "replace" | null, sendType?: string, sender?: string) => void; - parse: (data: string, options?: { - isDataURIEncoded?: boolean; - }) => QueryPayloads; - watcher: (options?: WatcherOptions) => QueryPayloads | undefined; - generateUrl: (url: string, payload: SendPayloads, sendType?: string, sender?: string) => string; -}; -export type { CallbackConfig, QueryPayloads, SendPayloads, WatcherOptions, SignIn, SignOut, OemSignOut, Troubleshoot, Recover, Replace, TrialExtend, TrialStart, Purchase, Redeem, Renew, Upgrade, UpdateOs, DowngradeOs, Manage, MyKeys, LinkKey, Activate, AccountActionTypes, AccountKeyActionTypes, PurchaseActionTypes, ServerActionTypes, ServerState, ServerData, UserInfo, ExternalSignIn, ExternalSignOut, ExternalKeyActions, ExternalUpdateOsAction, ServerPayload, ServerTroubleshoot, ExternalActions, UpcActions, ExternalPayload, UpcPayload, }; +export * from "./client"; diff --git a/dist/index.js b/dist/index.js index 99928d6..a84a995 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,106 +1,2165 @@ -import AES from "crypto-js/aes.js"; -import Utf8 from "crypto-js/enc-utf8.js"; -import { createSharedComposable } from "@vueuse/core"; -const _useCallback = (config) => { - const send = (url, payload, redirectType, sendType, sender) => { - // send() requires browser APIs and is client-only - if (typeof window === "undefined") { - throw new Error("send() can only be called on the client side"); +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { + get: (a, b) => (typeof require !== "undefined" ? require : a)[b] +}) : x)(function(x) { + if (typeof require !== "undefined") return require.apply(this, arguments); + throw Error('Dynamic require of "' + x + '" is not supported'); +}); +var __commonJS = (cb, mod) => function __require2() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + __defProp(target, "default", { value: mod, enumerable: true }) , + mod +)); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.js +var require_core = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(); + } else if (typeof define === "function" && define.amd) { + define([], factory); + } else { + root.CryptoJS = factory(); + } + })(exports$1, function() { + var CryptoJS = CryptoJS || (function(Math2, undefined2) { + var crypto; + if (typeof window !== "undefined" && window.crypto) { + crypto = window.crypto; } - const stringifiedData = JSON.stringify({ - actions: [...payload], - sender: sender ?? window.location.href.replace("/Tools/Update", "/Tools"), - type: sendType, - }); - const encryptedMessage = AES.encrypt(stringifiedData, config.encryptionKey).toString(); - const destinationUrl = new URL(url.replace("/Tools/Update", "/Tools")); - destinationUrl.searchParams.set("data", encodeURI(encryptedMessage)); - if (redirectType === "newTab") { - window.open(destinationUrl.toString(), "_blank"); - return; + if (typeof self !== "undefined" && self.crypto) { + crypto = self.crypto; } - if (redirectType === "replace") { - window.location.replace(destinationUrl.toString()); - return; + if (typeof globalThis !== "undefined" && globalThis.crypto) { + crypto = globalThis.crypto; } - window.location.href = destinationUrl.toString(); - }; - const parse = (data, options) => { - const dataToParse = options?.isDataURIEncoded - ? decodeURI(data) - : data; - const decryptedMessage = AES.decrypt(dataToParse, config.encryptionKey); - let decryptedString; - try { - decryptedString = decryptedMessage.toString(Utf8); + if (!crypto && typeof window !== "undefined" && window.msCrypto) { + crypto = window.msCrypto; } - catch (e) { - // Catch errors during UTF-8 conversion (likely due to bad decryption) - throw new Error('Decryption failed. Invalid key or corrupt data.'); + if (!crypto && typeof global !== "undefined" && global.crypto) { + crypto = global.crypto; } - // Check if decryption resulted in an empty string (another failure case) - if (!decryptedString) { - throw new Error('Decryption failed. Invalid key or corrupt data.'); + if (!crypto && typeof __require === "function") { + try { + crypto = __require("crypto"); + } catch (err) { + } } - try { - const decryptedData = JSON.parse(decryptedString); - return decryptedData; + 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 != undefined2) { + 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 Utf82 = 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 = Utf82.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 + }); + 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; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.js +var require_enc_base64 = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_enc = C.enc; + C_enc.Base64 = { + /** + * Converts a word array to a Base64 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Base64 string. + * + * @static + * + * @example + * + * var base64String = CryptoJS.enc.Base64.stringify(wordArray); + */ + stringify: function(wordArray) { + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + var map = this._map; + wordArray.clamp(); + var base64Chars = []; + for (var i = 0; i < sigBytes; i += 3) { + var byte1 = words[i >>> 2] >>> 24 - i % 4 * 8 & 255; + var byte2 = words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255; + var byte3 = words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255; + var triplet = byte1 << 16 | byte2 << 8 | byte3; + for (var j = 0; j < 4 && i + j * 0.75 < sigBytes; j++) { + base64Chars.push(map.charAt(triplet >>> 6 * (3 - j) & 63)); + } + } + var paddingChar = map.charAt(64); + if (paddingChar) { + while (base64Chars.length % 4) { + base64Chars.push(paddingChar); + } + } + return base64Chars.join(""); + }, + /** + * Converts a Base64 string to a word array. + * + * @param {string} base64Str The Base64 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Base64.parse(base64String); + */ + parse: function(base64Str) { + var base64StrLength = base64Str.length; + var map = this._map; + var reverseMap = this._reverseMap; + if (!reverseMap) { + reverseMap = this._reverseMap = []; + for (var j = 0; j < map.length; j++) { + reverseMap[map.charCodeAt(j)] = j; + } + } + var paddingChar = map.charAt(64); + if (paddingChar) { + var paddingIndex = base64Str.indexOf(paddingChar); + if (paddingIndex !== -1) { + base64StrLength = paddingIndex; + } + } + return parseLoop(base64Str, base64StrLength, reverseMap); + }, + _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" + }; + function parseLoop(base64Str, base64StrLength, reverseMap) { + var words = []; + var nBytes = 0; + for (var i = 0; i < base64StrLength; i++) { + if (i % 4) { + var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << i % 4 * 2; + var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> 6 - i % 4 * 2; + var bitsCombined = bits1 | bits2; + words[nBytes >>> 2] |= bitsCombined << 24 - nBytes % 4 * 8; + nBytes++; + } + } + return WordArray.create(words, nBytes); } - catch (e) { - // Catch potential JSON parse errors even if decryption seemed successful - throw new Error('Failed to parse decrypted data.'); + })(); + return CryptoJS.enc.Base64; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.js +var require_md5 = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function(Math2) { + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + var T = []; + (function() { + for (var i = 0; i < 64; i++) { + T[i] = Math2.abs(Math2.sin(i + 1)) * 4294967296 | 0; + } + })(); + var MD5 = C_algo.MD5 = Hasher.extend({ + _doReset: function() { + this._hash = new WordArray.init([ + 1732584193, + 4023233417, + 2562383102, + 271733878 + ]); + }, + _doProcessBlock: function(M, offset) { + for (var i = 0; i < 16; i++) { + var offset_i = offset + i; + var M_offset_i = M[offset_i]; + M[offset_i] = (M_offset_i << 8 | M_offset_i >>> 24) & 16711935 | (M_offset_i << 24 | M_offset_i >>> 8) & 4278255360; + } + var H = this._hash.words; + var M_offset_0 = M[offset + 0]; + var M_offset_1 = M[offset + 1]; + var M_offset_2 = M[offset + 2]; + var M_offset_3 = M[offset + 3]; + var M_offset_4 = M[offset + 4]; + var M_offset_5 = M[offset + 5]; + var M_offset_6 = M[offset + 6]; + var M_offset_7 = M[offset + 7]; + var M_offset_8 = M[offset + 8]; + var M_offset_9 = M[offset + 9]; + var M_offset_10 = M[offset + 10]; + var M_offset_11 = M[offset + 11]; + var M_offset_12 = M[offset + 12]; + var M_offset_13 = M[offset + 13]; + var M_offset_14 = M[offset + 14]; + var M_offset_15 = M[offset + 15]; + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + a = FF(a, b, c, d, M_offset_0, 7, T[0]); + d = FF(d, a, b, c, M_offset_1, 12, T[1]); + c = FF(c, d, a, b, M_offset_2, 17, T[2]); + b = FF(b, c, d, a, M_offset_3, 22, T[3]); + a = FF(a, b, c, d, M_offset_4, 7, T[4]); + d = FF(d, a, b, c, M_offset_5, 12, T[5]); + c = FF(c, d, a, b, M_offset_6, 17, T[6]); + b = FF(b, c, d, a, M_offset_7, 22, T[7]); + a = FF(a, b, c, d, M_offset_8, 7, T[8]); + d = FF(d, a, b, c, M_offset_9, 12, T[9]); + c = FF(c, d, a, b, M_offset_10, 17, T[10]); + b = FF(b, c, d, a, M_offset_11, 22, T[11]); + a = FF(a, b, c, d, M_offset_12, 7, T[12]); + d = FF(d, a, b, c, M_offset_13, 12, T[13]); + c = FF(c, d, a, b, M_offset_14, 17, T[14]); + b = FF(b, c, d, a, M_offset_15, 22, T[15]); + a = GG(a, b, c, d, M_offset_1, 5, T[16]); + d = GG(d, a, b, c, M_offset_6, 9, T[17]); + c = GG(c, d, a, b, M_offset_11, 14, T[18]); + b = GG(b, c, d, a, M_offset_0, 20, T[19]); + a = GG(a, b, c, d, M_offset_5, 5, T[20]); + d = GG(d, a, b, c, M_offset_10, 9, T[21]); + c = GG(c, d, a, b, M_offset_15, 14, T[22]); + b = GG(b, c, d, a, M_offset_4, 20, T[23]); + a = GG(a, b, c, d, M_offset_9, 5, T[24]); + d = GG(d, a, b, c, M_offset_14, 9, T[25]); + c = GG(c, d, a, b, M_offset_3, 14, T[26]); + b = GG(b, c, d, a, M_offset_8, 20, T[27]); + a = GG(a, b, c, d, M_offset_13, 5, T[28]); + d = GG(d, a, b, c, M_offset_2, 9, T[29]); + c = GG(c, d, a, b, M_offset_7, 14, T[30]); + b = GG(b, c, d, a, M_offset_12, 20, T[31]); + a = HH(a, b, c, d, M_offset_5, 4, T[32]); + d = HH(d, a, b, c, M_offset_8, 11, T[33]); + c = HH(c, d, a, b, M_offset_11, 16, T[34]); + b = HH(b, c, d, a, M_offset_14, 23, T[35]); + a = HH(a, b, c, d, M_offset_1, 4, T[36]); + d = HH(d, a, b, c, M_offset_4, 11, T[37]); + c = HH(c, d, a, b, M_offset_7, 16, T[38]); + b = HH(b, c, d, a, M_offset_10, 23, T[39]); + a = HH(a, b, c, d, M_offset_13, 4, T[40]); + d = HH(d, a, b, c, M_offset_0, 11, T[41]); + c = HH(c, d, a, b, M_offset_3, 16, T[42]); + b = HH(b, c, d, a, M_offset_6, 23, T[43]); + a = HH(a, b, c, d, M_offset_9, 4, T[44]); + d = HH(d, a, b, c, M_offset_12, 11, T[45]); + c = HH(c, d, a, b, M_offset_15, 16, T[46]); + b = HH(b, c, d, a, M_offset_2, 23, T[47]); + a = II(a, b, c, d, M_offset_0, 6, T[48]); + d = II(d, a, b, c, M_offset_7, 10, T[49]); + c = II(c, d, a, b, M_offset_14, 15, T[50]); + b = II(b, c, d, a, M_offset_5, 21, T[51]); + a = II(a, b, c, d, M_offset_12, 6, T[52]); + d = II(d, a, b, c, M_offset_3, 10, T[53]); + c = II(c, d, a, b, M_offset_10, 15, T[54]); + b = II(b, c, d, a, M_offset_1, 21, T[55]); + a = II(a, b, c, d, M_offset_8, 6, T[56]); + d = II(d, a, b, c, M_offset_15, 10, T[57]); + c = II(c, d, a, b, M_offset_6, 15, T[58]); + b = II(b, c, d, a, M_offset_13, 21, T[59]); + a = II(a, b, c, d, M_offset_4, 6, T[60]); + d = II(d, a, b, c, M_offset_11, 10, T[61]); + c = II(c, d, a, b, M_offset_2, 15, T[62]); + b = II(b, c, d, a, M_offset_9, 21, T[63]); + H[0] = H[0] + a | 0; + H[1] = H[1] + b | 0; + H[2] = H[2] + c | 0; + H[3] = H[3] + d | 0; + }, + _doFinalize: function() { + var data = this._data; + var dataWords = data.words; + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32; + var nBitsTotalH = Math2.floor(nBitsTotal / 4294967296); + var nBitsTotalL = nBitsTotal; + dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = (nBitsTotalH << 8 | nBitsTotalH >>> 24) & 16711935 | (nBitsTotalH << 24 | nBitsTotalH >>> 8) & 4278255360; + dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = (nBitsTotalL << 8 | nBitsTotalL >>> 24) & 16711935 | (nBitsTotalL << 24 | nBitsTotalL >>> 8) & 4278255360; + data.sigBytes = (dataWords.length + 1) * 4; + this._process(); + var hash = this._hash; + var H = hash.words; + for (var i = 0; i < 4; i++) { + var H_i = H[i]; + H[i] = (H_i << 8 | H_i >>> 24) & 16711935 | (H_i << 24 | H_i >>> 8) & 4278255360; + } + return hash; + }, + clone: function() { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + return clone; + } + }); + function FF(a, b, c, d, x, s, t) { + var n = a + (b & c | ~b & d) + x + t; + return (n << s | n >>> 32 - s) + b; } - }; - const watcher = (options = {}) => { - let urlToParse = ""; - if (options?.baseUrl && !options.skipCurrentUrl) { - urlToParse = options.baseUrl; + function GG(a, b, c, d, x, s, t) { + var n = a + (b & d | c & ~d) + x + t; + return (n << s | n >>> 32 - s) + b; } - else if (typeof window !== "undefined" && window.location && !options.skipCurrentUrl) { - urlToParse = window.location.toString(); + function HH(a, b, c, d, x, s, t) { + var n = a + (b ^ c ^ d) + x + t; + return (n << s | n >>> 32 - s) + b; } - else if (!options?.dataToParse && !options?.baseUrl) { - // If no window and no explicit data/baseUrl provided, return undefined - return undefined; + function II(a, b, c, d, x, s, t) { + var n = a + (c ^ (b | ~d)) + x + t; + return (n << s | n >>> 32 - s) + b; } - // If we have dataToParse, use it directly; otherwise parse from URL - const uriDecodedEncryptedData = options?.dataToParse - ? decodeURI(options.dataToParse) - : (() => { - try { - const currentUrl = new URL(urlToParse); - return decodeURI(currentUrl.searchParams.get("data") ?? ""); + C.MD5 = Hasher._createHelper(MD5); + C.HmacMD5 = Hasher._createHmacHelper(MD5); + })(Math); + return CryptoJS.MD5; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.js +var require_sha1 = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + var W = []; + var SHA1 = C_algo.SHA1 = Hasher.extend({ + _doReset: function() { + this._hash = new WordArray.init([ + 1732584193, + 4023233417, + 2562383102, + 271733878, + 3285377520 + ]); + }, + _doProcessBlock: function(M, offset) { + var H = this._hash.words; + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + var e = H[4]; + for (var i = 0; i < 80; i++) { + if (i < 16) { + W[i] = M[offset + i] | 0; + } else { + var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; + W[i] = n << 1 | n >>> 31; + } + var t = (a << 5 | a >>> 27) + e + W[i]; + if (i < 20) { + t += (b & c | ~b & d) + 1518500249; + } else if (i < 40) { + t += (b ^ c ^ d) + 1859775393; + } else if (i < 60) { + t += (b & c | b & d | c & d) - 1894007588; + } else { + t += (b ^ c ^ d) - 899497514; + } + e = d; + d = c; + c = b << 30 | b >>> 2; + b = a; + a = t; + } + H[0] = H[0] + a | 0; + H[1] = H[1] + b | 0; + H[2] = H[2] + c | 0; + H[3] = H[3] + d | 0; + H[4] = H[4] + e | 0; + }, + _doFinalize: function() { + var data = this._data; + var dataWords = data.words; + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32; + dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math.floor(nBitsTotal / 4294967296); + dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal; + data.sigBytes = dataWords.length * 4; + this._process(); + return this._hash; + }, + clone: function() { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + return clone; + } + }); + C.SHA1 = Hasher._createHelper(SHA1); + C.HmacSHA1 = Hasher._createHmacHelper(SHA1); + })(); + return CryptoJS.SHA1; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.js +var require_hmac = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var C_enc = C.enc; + var Utf82 = C_enc.Utf8; + var C_algo = C.algo; + C_algo.HMAC = Base.extend({ + /** + * Initializes a newly created HMAC. + * + * @param {Hasher} hasher The hash algorithm to use. + * @param {WordArray|string} key The secret key. + * + * @example + * + * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); + */ + init: function(hasher, key) { + hasher = this._hasher = new hasher.init(); + if (typeof key == "string") { + key = Utf82.parse(key); + } + var hasherBlockSize = hasher.blockSize; + var hasherBlockSizeBytes = hasherBlockSize * 4; + if (key.sigBytes > hasherBlockSizeBytes) { + key = hasher.finalize(key); + } + key.clamp(); + var oKey = this._oKey = key.clone(); + var iKey = this._iKey = key.clone(); + var oKeyWords = oKey.words; + var iKeyWords = iKey.words; + for (var i = 0; i < hasherBlockSize; i++) { + oKeyWords[i] ^= 1549556828; + iKeyWords[i] ^= 909522486; + } + oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes; + this.reset(); + }, + /** + * Resets this HMAC to its initial state. + * + * @example + * + * hmacHasher.reset(); + */ + reset: function() { + var hasher = this._hasher; + hasher.reset(); + hasher.update(this._iKey); + }, + /** + * Updates this HMAC with a message. + * + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {HMAC} This HMAC instance. + * + * @example + * + * hmacHasher.update('message'); + * hmacHasher.update(wordArray); + */ + update: function(messageUpdate) { + this._hasher.update(messageUpdate); + return this; + }, + /** + * Finalizes the HMAC 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 HMAC. + * + * @example + * + * var hmac = hmacHasher.finalize(); + * var hmac = hmacHasher.finalize('message'); + * var hmac = hmacHasher.finalize(wordArray); + */ + finalize: function(messageUpdate) { + var hasher = this._hasher; + var innerHash = hasher.finalize(messageUpdate); + hasher.reset(); + var hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); + return hmac; + } + }); + })(); + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.js +var require_evpkdf = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.js"(exports$1, module) { + (function(root, factory, undef) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core(), require_sha1(), require_hmac()); + } else if (typeof define === "function" && define.amd) { + define(["./core", "./sha1", "./hmac"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var C_algo = C.algo; + var MD5 = C_algo.MD5; + var EvpKDF = C_algo.EvpKDF = Base.extend({ + /** + * Configuration options. + * + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) + * @property {Hasher} hasher The hash algorithm to use. Default: MD5 + * @property {number} iterations The number of iterations to perform. Default: 1 + */ + cfg: Base.extend({ + keySize: 128 / 32, + hasher: MD5, + iterations: 1 + }), + /** + * Initializes a newly created key derivation function. + * + * @param {Object} cfg (Optional) The configuration options to use for the derivation. + * + * @example + * + * var kdf = CryptoJS.algo.EvpKDF.create(); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); + */ + init: function(cfg) { + this.cfg = this.cfg.extend(cfg); + }, + /** + * Derives a key from a password. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * + * @return {WordArray} The derived key. + * + * @example + * + * var key = kdf.compute(password, salt); + */ + compute: function(password, salt) { + var block; + var cfg = this.cfg; + var hasher = cfg.hasher.create(); + var derivedKey = WordArray.create(); + var derivedKeyWords = derivedKey.words; + var keySize = cfg.keySize; + var iterations = cfg.iterations; + while (derivedKeyWords.length < keySize) { + if (block) { + hasher.update(block); + } + block = hasher.update(password).finalize(salt); + hasher.reset(); + for (var i = 1; i < iterations; i++) { + block = hasher.finalize(block); + hasher.reset(); + } + derivedKey.concat(block); + } + derivedKey.sigBytes = keySize * 4; + return derivedKey; + } + }); + C.EvpKDF = function(password, salt, cfg) { + return EvpKDF.create(cfg).compute(password, salt); + }; + })(); + return CryptoJS.EvpKDF; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.js +var require_cipher_core = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.js"(exports$1, module) { + (function(root, factory, undef) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core(), require_evpkdf()); + } else if (typeof define === "function" && define.amd) { + define(["./core", "./evpkdf"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + CryptoJS.lib.Cipher || (function(undefined2) { + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm; + var C_enc = C.enc; + C_enc.Utf8; + var Base64 = C_enc.Base64; + var C_algo = C.algo; + var EvpKDF = C_algo.EvpKDF; + var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({ + /** + * Configuration options. + * + * @property {WordArray} iv The IV to use for this operation. + */ + cfg: Base.extend(), + /** + * Creates this cipher in encryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); + */ + createEncryptor: function(key, cfg) { + return this.create(this._ENC_XFORM_MODE, key, cfg); + }, + /** + * Creates this cipher in decryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); + */ + createDecryptor: function(key, cfg) { + return this.create(this._DEC_XFORM_MODE, key, cfg); + }, + /** + * Initializes a newly created cipher. + * + * @param {number} xformMode Either the encryption or decryption transormation mode constant. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @example + * + * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); + */ + init: function(xformMode, key, cfg) { + this.cfg = this.cfg.extend(cfg); + this._xformMode = xformMode; + this._key = key; + this.reset(); + }, + /** + * Resets this cipher to its initial state. + * + * @example + * + * cipher.reset(); + */ + reset: function() { + BufferedBlockAlgorithm.reset.call(this); + this._doReset(); + }, + /** + * Adds data to be encrypted or decrypted. + * + * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. + * + * @return {WordArray} The data after processing. + * + * @example + * + * var encrypted = cipher.process('data'); + * var encrypted = cipher.process(wordArray); + */ + process: function(dataUpdate) { + this._append(dataUpdate); + return this._process(); + }, + /** + * Finalizes the encryption or decryption process. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. + * + * @return {WordArray} The data after final processing. + * + * @example + * + * var encrypted = cipher.finalize(); + * var encrypted = cipher.finalize('data'); + * var encrypted = cipher.finalize(wordArray); + */ + finalize: function(dataUpdate) { + if (dataUpdate) { + this._append(dataUpdate); + } + var finalProcessedData = this._doFinalize(); + return finalProcessedData; + }, + keySize: 128 / 32, + ivSize: 128 / 32, + _ENC_XFORM_MODE: 1, + _DEC_XFORM_MODE: 2, + /** + * Creates shortcut functions to a cipher's object interface. + * + * @param {Cipher} cipher The cipher to create a helper for. + * + * @return {Object} An object with encrypt and decrypt shortcut functions. + * + * @static + * + * @example + * + * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); + */ + _createHelper: /* @__PURE__ */ (function() { + function selectCipherStrategy(key) { + if (typeof key == "string") { + return PasswordBasedCipher; + } else { + return SerializableCipher; + } + } + return function(cipher) { + return { + encrypt: function(message, key, cfg) { + return selectCipherStrategy(key).encrypt(cipher, message, key, cfg); + }, + decrypt: function(ciphertext, key, cfg) { + return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); } - catch { - return ""; + }; + }; + })() + }); + C_lib.StreamCipher = Cipher.extend({ + _doFinalize: function() { + var finalProcessedBlocks = this._process(true); + return finalProcessedBlocks; + }, + blockSize: 1 + }); + var C_mode = C.mode = {}; + var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({ + /** + * Creates this mode for encryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); + */ + createEncryptor: function(cipher, iv) { + return this.Encryptor.create(cipher, iv); + }, + /** + * Creates this mode for decryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); + */ + createDecryptor: function(cipher, iv) { + return this.Decryptor.create(cipher, iv); + }, + /** + * Initializes a newly created mode. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @example + * + * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); + */ + init: function(cipher, iv) { + this._cipher = cipher; + this._iv = iv; + } + }); + var CBC = C_mode.CBC = (function() { + var CBC2 = BlockCipherMode.extend(); + CBC2.Encryptor = CBC2.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function(words, offset) { + var cipher = this._cipher; + var blockSize = cipher.blockSize; + xorBlock.call(this, words, offset, blockSize); + cipher.encryptBlock(words, offset); + this._prevBlock = words.slice(offset, offset + blockSize); + } + }); + CBC2.Decryptor = CBC2.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function(words, offset) { + var cipher = this._cipher; + var blockSize = cipher.blockSize; + var thisBlock = words.slice(offset, offset + blockSize); + cipher.decryptBlock(words, offset); + xorBlock.call(this, words, offset, blockSize); + this._prevBlock = thisBlock; + } + }); + function xorBlock(words, offset, blockSize) { + var block; + var iv = this._iv; + if (iv) { + block = iv; + this._iv = undefined2; + } else { + block = this._prevBlock; + } + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= block[i]; + } + } + return CBC2; + })(); + var C_pad = C.pad = {}; + var Pkcs7 = C_pad.Pkcs7 = { + /** + * Pads data using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to pad. + * @param {number} blockSize The multiple that the data should be padded to. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.pad(wordArray, 4); + */ + pad: function(data, blockSize) { + var blockSizeBytes = blockSize * 4; + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; + var paddingWord = nPaddingBytes << 24 | nPaddingBytes << 16 | nPaddingBytes << 8 | nPaddingBytes; + var paddingWords = []; + for (var i = 0; i < nPaddingBytes; i += 4) { + paddingWords.push(paddingWord); + } + var padding = WordArray.create(paddingWords, nPaddingBytes); + data.concat(padding); + }, + /** + * Unpads data that had been padded using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to unpad. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.unpad(wordArray); + */ + unpad: function(data) { + var nPaddingBytes = data.words[data.sigBytes - 1 >>> 2] & 255; + data.sigBytes -= nPaddingBytes; + } + }; + C_lib.BlockCipher = Cipher.extend({ + /** + * Configuration options. + * + * @property {Mode} mode The block mode to use. Default: CBC + * @property {Padding} padding The padding strategy to use. Default: Pkcs7 + */ + cfg: Cipher.cfg.extend({ + mode: CBC, + padding: Pkcs7 + }), + reset: function() { + var modeCreator; + Cipher.reset.call(this); + var cfg = this.cfg; + var iv = cfg.iv; + var mode = cfg.mode; + if (this._xformMode == this._ENC_XFORM_MODE) { + modeCreator = mode.createEncryptor; + } else { + modeCreator = mode.createDecryptor; + this._minBufferSize = 1; + } + if (this._mode && this._mode.__creator == modeCreator) { + this._mode.init(this, iv && iv.words); + } else { + this._mode = modeCreator.call(mode, this, iv && iv.words); + this._mode.__creator = modeCreator; + } + }, + _doProcessBlock: function(words, offset) { + this._mode.processBlock(words, offset); + }, + _doFinalize: function() { + var finalProcessedBlocks; + var padding = this.cfg.padding; + if (this._xformMode == this._ENC_XFORM_MODE) { + padding.pad(this._data, this.blockSize); + finalProcessedBlocks = this._process(true); + } else { + finalProcessedBlocks = this._process(true); + padding.unpad(finalProcessedBlocks); + } + return finalProcessedBlocks; + }, + blockSize: 128 / 32 + }); + var CipherParams = C_lib.CipherParams = Base.extend({ + /** + * Initializes a newly created cipher params object. + * + * @param {Object} cipherParams An object with any of the possible cipher parameters. + * + * @example + * + * var cipherParams = CryptoJS.lib.CipherParams.create({ + * ciphertext: ciphertextWordArray, + * key: keyWordArray, + * iv: ivWordArray, + * salt: saltWordArray, + * algorithm: CryptoJS.algo.AES, + * mode: CryptoJS.mode.CBC, + * padding: CryptoJS.pad.PKCS7, + * blockSize: 4, + * formatter: CryptoJS.format.OpenSSL + * }); + */ + init: function(cipherParams) { + this.mixIn(cipherParams); + }, + /** + * Converts this cipher params object to a string. + * + * @param {Format} formatter (Optional) The formatting strategy to use. + * + * @return {string} The stringified cipher params. + * + * @throws Error If neither the formatter nor the default formatter is set. + * + * @example + * + * var string = cipherParams + ''; + * var string = cipherParams.toString(); + * var string = cipherParams.toString(CryptoJS.format.OpenSSL); + */ + toString: function(formatter) { + return (formatter || this.formatter).stringify(this); + } + }); + var C_format = C.format = {}; + var OpenSSLFormatter = C_format.OpenSSL = { + /** + * Converts a cipher params object to an OpenSSL-compatible string. + * + * @param {CipherParams} cipherParams The cipher params object. + * + * @return {string} The OpenSSL-compatible string. + * + * @static + * + * @example + * + * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); + */ + stringify: function(cipherParams) { + var wordArray; + var ciphertext = cipherParams.ciphertext; + var salt = cipherParams.salt; + if (salt) { + wordArray = WordArray.create([1398893684, 1701076831]).concat(salt).concat(ciphertext); + } else { + wordArray = ciphertext; + } + return wordArray.toString(Base64); + }, + /** + * Converts an OpenSSL-compatible string to a cipher params object. + * + * @param {string} openSSLStr The OpenSSL-compatible string. + * + * @return {CipherParams} The cipher params object. + * + * @static + * + * @example + * + * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); + */ + parse: function(openSSLStr) { + var salt; + var ciphertext = Base64.parse(openSSLStr); + var ciphertextWords = ciphertext.words; + if (ciphertextWords[0] == 1398893684 && ciphertextWords[1] == 1701076831) { + salt = WordArray.create(ciphertextWords.slice(2, 4)); + ciphertextWords.splice(0, 4); + ciphertext.sigBytes -= 16; + } + return CipherParams.create({ ciphertext, salt }); + } + }; + var SerializableCipher = C_lib.SerializableCipher = Base.extend({ + /** + * Configuration options. + * + * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL + */ + cfg: Base.extend({ + format: OpenSSLFormatter + }), + /** + * Encrypts a message. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + encrypt: function(cipher, message, key, cfg) { + cfg = this.cfg.extend(cfg); + var encryptor = cipher.createEncryptor(key, cfg); + var ciphertext = encryptor.finalize(message); + var cipherCfg = encryptor.cfg; + return CipherParams.create({ + ciphertext, + key, + iv: cipherCfg.iv, + algorithm: cipher, + mode: cipherCfg.mode, + padding: cipherCfg.padding, + blockSize: cipher.blockSize, + formatter: cfg.format + }); + }, + /** + * Decrypts serialized ciphertext. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + decrypt: function(cipher, ciphertext, key, cfg) { + cfg = this.cfg.extend(cfg); + ciphertext = this._parse(ciphertext, cfg.format); + var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext); + return plaintext; + }, + /** + * Converts serialized ciphertext to CipherParams, + * else assumed CipherParams already and returns ciphertext unchanged. + * + * @param {CipherParams|string} ciphertext The ciphertext. + * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. + * + * @return {CipherParams} The unserialized ciphertext. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format); + */ + _parse: function(ciphertext, format) { + if (typeof ciphertext == "string") { + return format.parse(ciphertext, this); + } else { + return ciphertext; + } + } + }); + var C_kdf = C.kdf = {}; + var OpenSSLKdf = C_kdf.OpenSSL = { + /** + * Derives a key and IV from a password. + * + * @param {string} password The password to derive from. + * @param {number} keySize The size in words of the key to generate. + * @param {number} ivSize The size in words of the IV to generate. + * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. + * + * @return {CipherParams} A cipher params object with the key, IV, and salt. + * + * @static + * + * @example + * + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); + */ + execute: function(password, keySize, ivSize, salt, hasher) { + if (!salt) { + salt = WordArray.random(64 / 8); + } + if (!hasher) { + var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt); + } else { + var key = EvpKDF.create({ keySize: keySize + ivSize, hasher }).compute(password, salt); + } + var iv = WordArray.create(key.words.slice(keySize), ivSize * 4); + key.sigBytes = keySize * 4; + return CipherParams.create({ key, iv, salt }); + } + }; + var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({ + /** + * Configuration options. + * + * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL + */ + cfg: SerializableCipher.cfg.extend({ + kdf: OpenSSLKdf + }), + /** + * Encrypts a message using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password'); + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); + */ + encrypt: function(cipher, message, password, cfg) { + cfg = this.cfg.extend(cfg); + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, cfg.salt, cfg.hasher); + cfg.iv = derivedParams.iv; + var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg); + ciphertext.mixIn(derivedParams); + return ciphertext; + }, + /** + * Decrypts serialized ciphertext using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL }); + */ + decrypt: function(cipher, ciphertext, password, cfg) { + cfg = this.cfg.extend(cfg); + ciphertext = this._parse(ciphertext, cfg.format); + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt, cfg.hasher); + cfg.iv = derivedParams.iv; + var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg); + return plaintext; + } + }); + })(); + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js +var require_aes = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js"(exports$1, module) { + (function(root, factory, undef) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core(), require_enc_base64(), require_md5(), require_evpkdf(), require_cipher_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var BlockCipher = C_lib.BlockCipher; + var C_algo = C.algo; + var SBOX = []; + var INV_SBOX = []; + var SUB_MIX_0 = []; + var SUB_MIX_1 = []; + var SUB_MIX_2 = []; + var SUB_MIX_3 = []; + var INV_SUB_MIX_0 = []; + var INV_SUB_MIX_1 = []; + var INV_SUB_MIX_2 = []; + var INV_SUB_MIX_3 = []; + (function() { + var d = []; + for (var i = 0; i < 256; i++) { + if (i < 128) { + d[i] = i << 1; + } else { + d[i] = i << 1 ^ 283; + } + } + var x = 0; + var xi = 0; + for (var i = 0; i < 256; i++) { + var sx = xi ^ xi << 1 ^ xi << 2 ^ xi << 3 ^ xi << 4; + sx = sx >>> 8 ^ sx & 255 ^ 99; + SBOX[x] = sx; + INV_SBOX[sx] = x; + var x2 = d[x]; + var x4 = d[x2]; + var x8 = d[x4]; + var t = d[sx] * 257 ^ sx * 16843008; + SUB_MIX_0[x] = t << 24 | t >>> 8; + SUB_MIX_1[x] = t << 16 | t >>> 16; + SUB_MIX_2[x] = t << 8 | t >>> 24; + SUB_MIX_3[x] = t; + var t = x8 * 16843009 ^ x4 * 65537 ^ x2 * 257 ^ x * 16843008; + INV_SUB_MIX_0[sx] = t << 24 | t >>> 8; + INV_SUB_MIX_1[sx] = t << 16 | t >>> 16; + INV_SUB_MIX_2[sx] = t << 8 | t >>> 24; + INV_SUB_MIX_3[sx] = t; + if (!x) { + x = xi = 1; + } else { + x = x2 ^ d[d[d[x8 ^ x2]]]; + xi ^= d[d[xi]]; + } + } + })(); + var RCON = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54]; + var AES2 = C_algo.AES = BlockCipher.extend({ + _doReset: function() { + var t; + if (this._nRounds && this._keyPriorReset === this._key) { + return; + } + var key = this._keyPriorReset = this._key; + var keyWords = key.words; + var keySize = key.sigBytes / 4; + var nRounds = this._nRounds = keySize + 6; + var ksRows = (nRounds + 1) * 4; + var keySchedule = this._keySchedule = []; + for (var ksRow = 0; ksRow < ksRows; ksRow++) { + if (ksRow < keySize) { + keySchedule[ksRow] = keyWords[ksRow]; + } else { + t = keySchedule[ksRow - 1]; + if (!(ksRow % keySize)) { + t = t << 8 | t >>> 24; + t = SBOX[t >>> 24] << 24 | SBOX[t >>> 16 & 255] << 16 | SBOX[t >>> 8 & 255] << 8 | SBOX[t & 255]; + t ^= RCON[ksRow / keySize | 0] << 24; + } else if (keySize > 6 && ksRow % keySize == 4) { + t = SBOX[t >>> 24] << 24 | SBOX[t >>> 16 & 255] << 16 | SBOX[t >>> 8 & 255] << 8 | SBOX[t & 255]; } - })(); - if (!uriDecodedEncryptedData) { - return undefined; - } - return parse(uriDecodedEncryptedData); - }; - const generateUrl = (url, payload, sendType, sender) => { - // generateUrl() works on both server and client - // If no sender provided and we're on client, use window.location; otherwise use empty string - const defaultSender = sender ?? (typeof window !== "undefined" - ? window.location.href.replace("/Tools/Update", "/Tools") - : ""); - const stringifiedData = JSON.stringify({ - actions: [...payload], - sender: defaultSender, - type: sendType, + keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; + } + } + var invKeySchedule = this._invKeySchedule = []; + for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { + var ksRow = ksRows - invKsRow; + if (invKsRow % 4) { + var t = keySchedule[ksRow]; + } else { + var t = keySchedule[ksRow - 4]; + } + if (invKsRow < 4 || ksRow <= 4) { + invKeySchedule[invKsRow] = t; + } else { + invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[t >>> 16 & 255]] ^ INV_SUB_MIX_2[SBOX[t >>> 8 & 255]] ^ INV_SUB_MIX_3[SBOX[t & 255]]; + } + } + }, + encryptBlock: function(M, offset) { + this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); + }, + decryptBlock: function(M, offset) { + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + }, + _doCryptBlock: function(M, offset, keySchedule, SUB_MIX_02, SUB_MIX_12, SUB_MIX_22, SUB_MIX_32, SBOX2) { + var nRounds = this._nRounds; + var s0 = M[offset] ^ keySchedule[0]; + var s1 = M[offset + 1] ^ keySchedule[1]; + var s2 = M[offset + 2] ^ keySchedule[2]; + var s3 = M[offset + 3] ^ keySchedule[3]; + var ksRow = 4; + for (var round = 1; round < nRounds; round++) { + var t0 = SUB_MIX_02[s0 >>> 24] ^ SUB_MIX_12[s1 >>> 16 & 255] ^ SUB_MIX_22[s2 >>> 8 & 255] ^ SUB_MIX_32[s3 & 255] ^ keySchedule[ksRow++]; + var t1 = SUB_MIX_02[s1 >>> 24] ^ SUB_MIX_12[s2 >>> 16 & 255] ^ SUB_MIX_22[s3 >>> 8 & 255] ^ SUB_MIX_32[s0 & 255] ^ keySchedule[ksRow++]; + var t2 = SUB_MIX_02[s2 >>> 24] ^ SUB_MIX_12[s3 >>> 16 & 255] ^ SUB_MIX_22[s0 >>> 8 & 255] ^ SUB_MIX_32[s1 & 255] ^ keySchedule[ksRow++]; + var t3 = SUB_MIX_02[s3 >>> 24] ^ SUB_MIX_12[s0 >>> 16 & 255] ^ SUB_MIX_22[s1 >>> 8 & 255] ^ SUB_MIX_32[s2 & 255] ^ keySchedule[ksRow++]; + s0 = t0; + s1 = t1; + s2 = t2; + s3 = t3; + } + var t0 = (SBOX2[s0 >>> 24] << 24 | SBOX2[s1 >>> 16 & 255] << 16 | SBOX2[s2 >>> 8 & 255] << 8 | SBOX2[s3 & 255]) ^ keySchedule[ksRow++]; + var t1 = (SBOX2[s1 >>> 24] << 24 | SBOX2[s2 >>> 16 & 255] << 16 | SBOX2[s3 >>> 8 & 255] << 8 | SBOX2[s0 & 255]) ^ keySchedule[ksRow++]; + var t2 = (SBOX2[s2 >>> 24] << 24 | SBOX2[s3 >>> 16 & 255] << 16 | SBOX2[s0 >>> 8 & 255] << 8 | SBOX2[s1 & 255]) ^ keySchedule[ksRow++]; + var t3 = (SBOX2[s3 >>> 24] << 24 | SBOX2[s0 >>> 16 & 255] << 16 | SBOX2[s1 >>> 8 & 255] << 8 | SBOX2[s2 & 255]) ^ keySchedule[ksRow++]; + M[offset] = t0; + M[offset + 1] = t1; + M[offset + 2] = t2; + M[offset + 3] = t3; + }, + keySize: 256 / 32 }); - const encryptedMessage = AES.encrypt(stringifiedData, config.encryptionKey).toString(); - const destinationUrl = new URL(url); - destinationUrl.searchParams.set("data", encodeURI(encryptedMessage)); - return destinationUrl.toString(); - }; - return { - send, - parse, - watcher, - generateUrl, - }; + C.AES = BlockCipher._createHelper(AES2); + })(); + return CryptoJS.AES; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js +var require_enc_utf8 = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + return CryptoJS.enc.Utf8; + }); + } +}); + +// src/core.ts +var import_aes = __toESM(require_aes()); +var import_enc_utf8 = __toESM(require_enc_utf8()); +var encryptData = (data, encryptionKey) => { + return import_aes.default.encrypt(data, encryptionKey).toString(); +}; +var decryptData = (encryptedData, encryptionKey) => { + const decryptedMessage = import_aes.default.decrypt(encryptedData, encryptionKey); + let decryptedString; + try { + decryptedString = decryptedMessage.toString(import_enc_utf8.default); + } catch { + throw new Error("Decryption failed. Invalid key or corrupt data."); + } + if (!decryptedString) { + throw new Error("Decryption failed. Invalid key or corrupt data."); + } + return decryptedString; +}; +var stringifyPayload = (payload, sender, sendType) => { + return JSON.stringify({ + actions: [...payload], + sender, + type: sendType + }); +}; +var createEncryptedPayload = (payload, sender, sendType, encryptionKey) => { + const stringifiedData = stringifyPayload(payload, sender, sendType); + return encryptData(stringifiedData, encryptionKey); +}; +var parseEncryptedPayload = (encryptedData, encryptionKey, options) => { + const dataToParse = options?.isDataURIEncoded ? decodeURI(encryptedData) : encryptedData; + const decryptedString = decryptData(dataToParse, encryptionKey); + try { + const decryptedData = JSON.parse(decryptedString); + return decryptedData; + } catch { + throw new Error("Failed to parse decrypted data."); + } +}; +var appendEncryptedDataToUrl = (url, encryptedData, useHash) => { + const destinationUrl = new URL(url); + if (useHash) { + destinationUrl.hash = `data=${encodeURI(encryptedData)}`; + } else { + destinationUrl.searchParams.set("data", encodeURI(encryptedData)); + } + return destinationUrl.toString(); +}; + +// src/client.ts +var createCallback = (config) => { + const shouldUseHash = config.useHash !== false; + const send = (url, payload, redirectType, sendType, sender) => { + if (typeof window === "undefined") { + throw new Error("send() can only be called on the client side"); + } + const defaultSender = sender ?? window.location.href.replace("/Tools/Update", "/Tools"); + const encryptedMessage = createEncryptedPayload( + payload, + defaultSender, + sendType, + config.encryptionKey + ); + const destinationUrl = appendEncryptedDataToUrl( + url.replace("/Tools/Update", "/Tools"), + encryptedMessage, + shouldUseHash + ); + if (redirectType === "newTab") { + window.open(destinationUrl, "_blank"); + return; + } + if (redirectType === "replace") { + window.location.replace(destinationUrl); + return; + } + window.location.href = destinationUrl; + }; + const parse = (data, options) => { + return parseEncryptedPayload(data, config.encryptionKey, options); + }; + const watcher = (options = {}) => { + let urlToParse = ""; + if (options?.baseUrl && !options.skipCurrentUrl) { + urlToParse = options.baseUrl; + } else if (typeof window !== "undefined" && window.location && !options.skipCurrentUrl) { + urlToParse = window.location.toString(); + } else if (!options?.dataToParse && !options?.baseUrl) { + return void 0; + } + const uriDecodedEncryptedData = options?.dataToParse ? decodeURI(options.dataToParse) : (() => { + try { + const currentUrl = new URL(urlToParse); + const searchParamData = currentUrl.searchParams.get("data") ?? ""; + let hashData = ""; + const rawHash = currentUrl.hash ?? ""; + if (rawHash) { + const hashWithoutHash = rawHash.startsWith("#") ? rawHash.slice(1) : rawHash; + if (hashWithoutHash.startsWith("data=")) { + hashData = hashWithoutHash.slice("data=".length); + } + } + const dataFromUrl = searchParamData || hashData; + return decodeURI(dataFromUrl); + } catch { + return ""; + } + })(); + if (!uriDecodedEncryptedData) { + return void 0; + } + return parse(uriDecodedEncryptedData); + }; + const generateUrl = (url, payload, sendType, sender) => { + const defaultSender = sender ?? (typeof window !== "undefined" ? window.location.href.replace("/Tools/Update", "/Tools") : ""); + const encryptedMessage = createEncryptedPayload( + payload, + defaultSender, + sendType, + config.encryptionKey + ); + return appendEncryptedDataToUrl(url, encryptedMessage, shouldUseHash); + }; + return { + send, + parse, + watcher, + generateUrl + }; }; -export const useCallback = createSharedComposable(_useCallback); +var useCallback = createCallback; + +export { createCallback, useCallback }; diff --git a/dist/server.d.ts b/dist/server.d.ts new file mode 100644 index 0000000..35e9a93 --- /dev/null +++ b/dist/server.d.ts @@ -0,0 +1,14 @@ +import type { CallbackConfig, QueryPayloads, SendPayloads, SignIn, SignOut, OemSignOut, Troubleshoot, Recover, Replace, TrialExtend, TrialStart, Purchase, Redeem, Renew, Upgrade, UpdateOs, DowngradeOs, Manage, MyKeys, LinkKey, Activate, AccountActionTypes, AccountKeyActionTypes, PurchaseActionTypes, ServerActionTypes, ServerState, ServerData, UserInfo, ExternalSignIn, ExternalSignOut, ExternalKeyActions, ExternalUpdateOsAction, ServerPayload, ServerTroubleshoot, ExternalActions, UpcActions, ExternalPayload, UpcPayload } from "./types.js"; +/** + * Server-safe factory that exposes only parse and generateUrl. + * + * Uses only AES/UTF-8 helpers and never touches browser globals, making this + * entrypoint safe to import in server/worker (e.g. Cloudflare Workers) code. + */ +export declare const createServerCallback: (config: CallbackConfig) => { + parse: (data: string, options?: { + isDataURIEncoded?: boolean; + }) => QueryPayloads; + generateUrl: (url: string, payload: SendPayloads, sendType?: string, sender?: string) => string; +}; +export type { CallbackConfig, QueryPayloads, SendPayloads, SignIn, SignOut, OemSignOut, Troubleshoot, Recover, Replace, TrialExtend, TrialStart, Purchase, Redeem, Renew, Upgrade, UpdateOs, DowngradeOs, Manage, MyKeys, LinkKey, Activate, AccountActionTypes, AccountKeyActionTypes, PurchaseActionTypes, ServerActionTypes, ServerState, ServerData, UserInfo, ExternalSignIn, ExternalSignOut, ExternalKeyActions, ExternalUpdateOsAction, ServerPayload, ServerTroubleshoot, ExternalActions, UpcActions, ExternalPayload, UpcPayload, }; diff --git a/dist/server.js b/dist/server.js new file mode 100644 index 0000000..1c39717 --- /dev/null +++ b/dist/server.js @@ -0,0 +1,2104 @@ +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { + get: (a, b) => (typeof require !== "undefined" ? require : a)[b] +}) : x)(function(x) { + if (typeof require !== "undefined") return require.apply(this, arguments); + throw Error('Dynamic require of "' + x + '" is not supported'); +}); +var __commonJS = (cb, mod) => function __require2() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + __defProp(target, "default", { value: mod, enumerable: true }) , + mod +)); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.js +var require_core = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/core.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(); + } else if (typeof define === "function" && define.amd) { + define([], factory); + } else { + root.CryptoJS = factory(); + } + })(exports$1, function() { + var CryptoJS = CryptoJS || (function(Math2, undefined$1) { + 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$1) { + 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 Utf82 = 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 = Utf82.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 + }); + 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; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.js +var require_enc_base64 = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-base64.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_enc = C.enc; + C_enc.Base64 = { + /** + * Converts a word array to a Base64 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Base64 string. + * + * @static + * + * @example + * + * var base64String = CryptoJS.enc.Base64.stringify(wordArray); + */ + stringify: function(wordArray) { + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + var map = this._map; + wordArray.clamp(); + var base64Chars = []; + for (var i = 0; i < sigBytes; i += 3) { + var byte1 = words[i >>> 2] >>> 24 - i % 4 * 8 & 255; + var byte2 = words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255; + var byte3 = words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255; + var triplet = byte1 << 16 | byte2 << 8 | byte3; + for (var j = 0; j < 4 && i + j * 0.75 < sigBytes; j++) { + base64Chars.push(map.charAt(triplet >>> 6 * (3 - j) & 63)); + } + } + var paddingChar = map.charAt(64); + if (paddingChar) { + while (base64Chars.length % 4) { + base64Chars.push(paddingChar); + } + } + return base64Chars.join(""); + }, + /** + * Converts a Base64 string to a word array. + * + * @param {string} base64Str The Base64 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Base64.parse(base64String); + */ + parse: function(base64Str) { + var base64StrLength = base64Str.length; + var map = this._map; + var reverseMap = this._reverseMap; + if (!reverseMap) { + reverseMap = this._reverseMap = []; + for (var j = 0; j < map.length; j++) { + reverseMap[map.charCodeAt(j)] = j; + } + } + var paddingChar = map.charAt(64); + if (paddingChar) { + var paddingIndex = base64Str.indexOf(paddingChar); + if (paddingIndex !== -1) { + base64StrLength = paddingIndex; + } + } + return parseLoop(base64Str, base64StrLength, reverseMap); + }, + _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" + }; + function parseLoop(base64Str, base64StrLength, reverseMap) { + var words = []; + var nBytes = 0; + for (var i = 0; i < base64StrLength; i++) { + if (i % 4) { + var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << i % 4 * 2; + var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> 6 - i % 4 * 2; + var bitsCombined = bits1 | bits2; + words[nBytes >>> 2] |= bitsCombined << 24 - nBytes % 4 * 8; + nBytes++; + } + } + return WordArray.create(words, nBytes); + } + })(); + return CryptoJS.enc.Base64; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.js +var require_md5 = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/md5.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function(Math2) { + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + var T = []; + (function() { + for (var i = 0; i < 64; i++) { + T[i] = Math2.abs(Math2.sin(i + 1)) * 4294967296 | 0; + } + })(); + var MD5 = C_algo.MD5 = Hasher.extend({ + _doReset: function() { + this._hash = new WordArray.init([ + 1732584193, + 4023233417, + 2562383102, + 271733878 + ]); + }, + _doProcessBlock: function(M, offset) { + for (var i = 0; i < 16; i++) { + var offset_i = offset + i; + var M_offset_i = M[offset_i]; + M[offset_i] = (M_offset_i << 8 | M_offset_i >>> 24) & 16711935 | (M_offset_i << 24 | M_offset_i >>> 8) & 4278255360; + } + var H = this._hash.words; + var M_offset_0 = M[offset + 0]; + var M_offset_1 = M[offset + 1]; + var M_offset_2 = M[offset + 2]; + var M_offset_3 = M[offset + 3]; + var M_offset_4 = M[offset + 4]; + var M_offset_5 = M[offset + 5]; + var M_offset_6 = M[offset + 6]; + var M_offset_7 = M[offset + 7]; + var M_offset_8 = M[offset + 8]; + var M_offset_9 = M[offset + 9]; + var M_offset_10 = M[offset + 10]; + var M_offset_11 = M[offset + 11]; + var M_offset_12 = M[offset + 12]; + var M_offset_13 = M[offset + 13]; + var M_offset_14 = M[offset + 14]; + var M_offset_15 = M[offset + 15]; + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + a = FF(a, b, c, d, M_offset_0, 7, T[0]); + d = FF(d, a, b, c, M_offset_1, 12, T[1]); + c = FF(c, d, a, b, M_offset_2, 17, T[2]); + b = FF(b, c, d, a, M_offset_3, 22, T[3]); + a = FF(a, b, c, d, M_offset_4, 7, T[4]); + d = FF(d, a, b, c, M_offset_5, 12, T[5]); + c = FF(c, d, a, b, M_offset_6, 17, T[6]); + b = FF(b, c, d, a, M_offset_7, 22, T[7]); + a = FF(a, b, c, d, M_offset_8, 7, T[8]); + d = FF(d, a, b, c, M_offset_9, 12, T[9]); + c = FF(c, d, a, b, M_offset_10, 17, T[10]); + b = FF(b, c, d, a, M_offset_11, 22, T[11]); + a = FF(a, b, c, d, M_offset_12, 7, T[12]); + d = FF(d, a, b, c, M_offset_13, 12, T[13]); + c = FF(c, d, a, b, M_offset_14, 17, T[14]); + b = FF(b, c, d, a, M_offset_15, 22, T[15]); + a = GG(a, b, c, d, M_offset_1, 5, T[16]); + d = GG(d, a, b, c, M_offset_6, 9, T[17]); + c = GG(c, d, a, b, M_offset_11, 14, T[18]); + b = GG(b, c, d, a, M_offset_0, 20, T[19]); + a = GG(a, b, c, d, M_offset_5, 5, T[20]); + d = GG(d, a, b, c, M_offset_10, 9, T[21]); + c = GG(c, d, a, b, M_offset_15, 14, T[22]); + b = GG(b, c, d, a, M_offset_4, 20, T[23]); + a = GG(a, b, c, d, M_offset_9, 5, T[24]); + d = GG(d, a, b, c, M_offset_14, 9, T[25]); + c = GG(c, d, a, b, M_offset_3, 14, T[26]); + b = GG(b, c, d, a, M_offset_8, 20, T[27]); + a = GG(a, b, c, d, M_offset_13, 5, T[28]); + d = GG(d, a, b, c, M_offset_2, 9, T[29]); + c = GG(c, d, a, b, M_offset_7, 14, T[30]); + b = GG(b, c, d, a, M_offset_12, 20, T[31]); + a = HH(a, b, c, d, M_offset_5, 4, T[32]); + d = HH(d, a, b, c, M_offset_8, 11, T[33]); + c = HH(c, d, a, b, M_offset_11, 16, T[34]); + b = HH(b, c, d, a, M_offset_14, 23, T[35]); + a = HH(a, b, c, d, M_offset_1, 4, T[36]); + d = HH(d, a, b, c, M_offset_4, 11, T[37]); + c = HH(c, d, a, b, M_offset_7, 16, T[38]); + b = HH(b, c, d, a, M_offset_10, 23, T[39]); + a = HH(a, b, c, d, M_offset_13, 4, T[40]); + d = HH(d, a, b, c, M_offset_0, 11, T[41]); + c = HH(c, d, a, b, M_offset_3, 16, T[42]); + b = HH(b, c, d, a, M_offset_6, 23, T[43]); + a = HH(a, b, c, d, M_offset_9, 4, T[44]); + d = HH(d, a, b, c, M_offset_12, 11, T[45]); + c = HH(c, d, a, b, M_offset_15, 16, T[46]); + b = HH(b, c, d, a, M_offset_2, 23, T[47]); + a = II(a, b, c, d, M_offset_0, 6, T[48]); + d = II(d, a, b, c, M_offset_7, 10, T[49]); + c = II(c, d, a, b, M_offset_14, 15, T[50]); + b = II(b, c, d, a, M_offset_5, 21, T[51]); + a = II(a, b, c, d, M_offset_12, 6, T[52]); + d = II(d, a, b, c, M_offset_3, 10, T[53]); + c = II(c, d, a, b, M_offset_10, 15, T[54]); + b = II(b, c, d, a, M_offset_1, 21, T[55]); + a = II(a, b, c, d, M_offset_8, 6, T[56]); + d = II(d, a, b, c, M_offset_15, 10, T[57]); + c = II(c, d, a, b, M_offset_6, 15, T[58]); + b = II(b, c, d, a, M_offset_13, 21, T[59]); + a = II(a, b, c, d, M_offset_4, 6, T[60]); + d = II(d, a, b, c, M_offset_11, 10, T[61]); + c = II(c, d, a, b, M_offset_2, 15, T[62]); + b = II(b, c, d, a, M_offset_9, 21, T[63]); + H[0] = H[0] + a | 0; + H[1] = H[1] + b | 0; + H[2] = H[2] + c | 0; + H[3] = H[3] + d | 0; + }, + _doFinalize: function() { + var data = this._data; + var dataWords = data.words; + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32; + var nBitsTotalH = Math2.floor(nBitsTotal / 4294967296); + var nBitsTotalL = nBitsTotal; + dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = (nBitsTotalH << 8 | nBitsTotalH >>> 24) & 16711935 | (nBitsTotalH << 24 | nBitsTotalH >>> 8) & 4278255360; + dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = (nBitsTotalL << 8 | nBitsTotalL >>> 24) & 16711935 | (nBitsTotalL << 24 | nBitsTotalL >>> 8) & 4278255360; + data.sigBytes = (dataWords.length + 1) * 4; + this._process(); + var hash = this._hash; + var H = hash.words; + for (var i = 0; i < 4; i++) { + var H_i = H[i]; + H[i] = (H_i << 8 | H_i >>> 24) & 16711935 | (H_i << 24 | H_i >>> 8) & 4278255360; + } + return hash; + }, + clone: function() { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + return clone; + } + }); + function FF(a, b, c, d, x, s, t) { + var n = a + (b & c | ~b & d) + x + t; + return (n << s | n >>> 32 - s) + b; + } + function GG(a, b, c, d, x, s, t) { + var n = a + (b & d | c & ~d) + x + t; + return (n << s | n >>> 32 - s) + b; + } + function HH(a, b, c, d, x, s, t) { + var n = a + (b ^ c ^ d) + x + t; + return (n << s | n >>> 32 - s) + b; + } + function II(a, b, c, d, x, s, t) { + var n = a + (c ^ (b | ~d)) + x + t; + return (n << s | n >>> 32 - s) + b; + } + C.MD5 = Hasher._createHelper(MD5); + C.HmacMD5 = Hasher._createHmacHelper(MD5); + })(Math); + return CryptoJS.MD5; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.js +var require_sha1 = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/sha1.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + var W = []; + var SHA1 = C_algo.SHA1 = Hasher.extend({ + _doReset: function() { + this._hash = new WordArray.init([ + 1732584193, + 4023233417, + 2562383102, + 271733878, + 3285377520 + ]); + }, + _doProcessBlock: function(M, offset) { + var H = this._hash.words; + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + var e = H[4]; + for (var i = 0; i < 80; i++) { + if (i < 16) { + W[i] = M[offset + i] | 0; + } else { + var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; + W[i] = n << 1 | n >>> 31; + } + var t = (a << 5 | a >>> 27) + e + W[i]; + if (i < 20) { + t += (b & c | ~b & d) + 1518500249; + } else if (i < 40) { + t += (b ^ c ^ d) + 1859775393; + } else if (i < 60) { + t += (b & c | b & d | c & d) - 1894007588; + } else { + t += (b ^ c ^ d) - 899497514; + } + e = d; + d = c; + c = b << 30 | b >>> 2; + b = a; + a = t; + } + H[0] = H[0] + a | 0; + H[1] = H[1] + b | 0; + H[2] = H[2] + c | 0; + H[3] = H[3] + d | 0; + H[4] = H[4] + e | 0; + }, + _doFinalize: function() { + var data = this._data; + var dataWords = data.words; + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32; + dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math.floor(nBitsTotal / 4294967296); + dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal; + data.sigBytes = dataWords.length * 4; + this._process(); + return this._hash; + }, + clone: function() { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + return clone; + } + }); + C.SHA1 = Hasher._createHelper(SHA1); + C.HmacSHA1 = Hasher._createHmacHelper(SHA1); + })(); + return CryptoJS.SHA1; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.js +var require_hmac = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/hmac.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var C_enc = C.enc; + var Utf82 = C_enc.Utf8; + var C_algo = C.algo; + C_algo.HMAC = Base.extend({ + /** + * Initializes a newly created HMAC. + * + * @param {Hasher} hasher The hash algorithm to use. + * @param {WordArray|string} key The secret key. + * + * @example + * + * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); + */ + init: function(hasher, key) { + hasher = this._hasher = new hasher.init(); + if (typeof key == "string") { + key = Utf82.parse(key); + } + var hasherBlockSize = hasher.blockSize; + var hasherBlockSizeBytes = hasherBlockSize * 4; + if (key.sigBytes > hasherBlockSizeBytes) { + key = hasher.finalize(key); + } + key.clamp(); + var oKey = this._oKey = key.clone(); + var iKey = this._iKey = key.clone(); + var oKeyWords = oKey.words; + var iKeyWords = iKey.words; + for (var i = 0; i < hasherBlockSize; i++) { + oKeyWords[i] ^= 1549556828; + iKeyWords[i] ^= 909522486; + } + oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes; + this.reset(); + }, + /** + * Resets this HMAC to its initial state. + * + * @example + * + * hmacHasher.reset(); + */ + reset: function() { + var hasher = this._hasher; + hasher.reset(); + hasher.update(this._iKey); + }, + /** + * Updates this HMAC with a message. + * + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {HMAC} This HMAC instance. + * + * @example + * + * hmacHasher.update('message'); + * hmacHasher.update(wordArray); + */ + update: function(messageUpdate) { + this._hasher.update(messageUpdate); + return this; + }, + /** + * Finalizes the HMAC 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 HMAC. + * + * @example + * + * var hmac = hmacHasher.finalize(); + * var hmac = hmacHasher.finalize('message'); + * var hmac = hmacHasher.finalize(wordArray); + */ + finalize: function(messageUpdate) { + var hasher = this._hasher; + var innerHash = hasher.finalize(messageUpdate); + hasher.reset(); + var hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); + return hmac; + } + }); + })(); + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.js +var require_evpkdf = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/evpkdf.js"(exports$1, module) { + (function(root, factory, undef) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core(), require_sha1(), require_hmac()); + } else if (typeof define === "function" && define.amd) { + define(["./core", "./sha1", "./hmac"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var C_algo = C.algo; + var MD5 = C_algo.MD5; + var EvpKDF = C_algo.EvpKDF = Base.extend({ + /** + * Configuration options. + * + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) + * @property {Hasher} hasher The hash algorithm to use. Default: MD5 + * @property {number} iterations The number of iterations to perform. Default: 1 + */ + cfg: Base.extend({ + keySize: 128 / 32, + hasher: MD5, + iterations: 1 + }), + /** + * Initializes a newly created key derivation function. + * + * @param {Object} cfg (Optional) The configuration options to use for the derivation. + * + * @example + * + * var kdf = CryptoJS.algo.EvpKDF.create(); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); + */ + init: function(cfg) { + this.cfg = this.cfg.extend(cfg); + }, + /** + * Derives a key from a password. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * + * @return {WordArray} The derived key. + * + * @example + * + * var key = kdf.compute(password, salt); + */ + compute: function(password, salt) { + var block; + var cfg = this.cfg; + var hasher = cfg.hasher.create(); + var derivedKey = WordArray.create(); + var derivedKeyWords = derivedKey.words; + var keySize = cfg.keySize; + var iterations = cfg.iterations; + while (derivedKeyWords.length < keySize) { + if (block) { + hasher.update(block); + } + block = hasher.update(password).finalize(salt); + hasher.reset(); + for (var i = 1; i < iterations; i++) { + block = hasher.finalize(block); + hasher.reset(); + } + derivedKey.concat(block); + } + derivedKey.sigBytes = keySize * 4; + return derivedKey; + } + }); + C.EvpKDF = function(password, salt, cfg) { + return EvpKDF.create(cfg).compute(password, salt); + }; + })(); + return CryptoJS.EvpKDF; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.js +var require_cipher_core = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/cipher-core.js"(exports$1, module) { + (function(root, factory, undef) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core(), require_evpkdf()); + } else if (typeof define === "function" && define.amd) { + define(["./core", "./evpkdf"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + CryptoJS.lib.Cipher || (function(undefined$1) { + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm; + var C_enc = C.enc; + C_enc.Utf8; + var Base64 = C_enc.Base64; + var C_algo = C.algo; + var EvpKDF = C_algo.EvpKDF; + var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({ + /** + * Configuration options. + * + * @property {WordArray} iv The IV to use for this operation. + */ + cfg: Base.extend(), + /** + * Creates this cipher in encryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); + */ + createEncryptor: function(key, cfg) { + return this.create(this._ENC_XFORM_MODE, key, cfg); + }, + /** + * Creates this cipher in decryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); + */ + createDecryptor: function(key, cfg) { + return this.create(this._DEC_XFORM_MODE, key, cfg); + }, + /** + * Initializes a newly created cipher. + * + * @param {number} xformMode Either the encryption or decryption transormation mode constant. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @example + * + * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); + */ + init: function(xformMode, key, cfg) { + this.cfg = this.cfg.extend(cfg); + this._xformMode = xformMode; + this._key = key; + this.reset(); + }, + /** + * Resets this cipher to its initial state. + * + * @example + * + * cipher.reset(); + */ + reset: function() { + BufferedBlockAlgorithm.reset.call(this); + this._doReset(); + }, + /** + * Adds data to be encrypted or decrypted. + * + * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. + * + * @return {WordArray} The data after processing. + * + * @example + * + * var encrypted = cipher.process('data'); + * var encrypted = cipher.process(wordArray); + */ + process: function(dataUpdate) { + this._append(dataUpdate); + return this._process(); + }, + /** + * Finalizes the encryption or decryption process. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. + * + * @return {WordArray} The data after final processing. + * + * @example + * + * var encrypted = cipher.finalize(); + * var encrypted = cipher.finalize('data'); + * var encrypted = cipher.finalize(wordArray); + */ + finalize: function(dataUpdate) { + if (dataUpdate) { + this._append(dataUpdate); + } + var finalProcessedData = this._doFinalize(); + return finalProcessedData; + }, + keySize: 128 / 32, + ivSize: 128 / 32, + _ENC_XFORM_MODE: 1, + _DEC_XFORM_MODE: 2, + /** + * Creates shortcut functions to a cipher's object interface. + * + * @param {Cipher} cipher The cipher to create a helper for. + * + * @return {Object} An object with encrypt and decrypt shortcut functions. + * + * @static + * + * @example + * + * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); + */ + _createHelper: /* @__PURE__ */ (function() { + function selectCipherStrategy(key) { + if (typeof key == "string") { + return PasswordBasedCipher; + } else { + return SerializableCipher; + } + } + return function(cipher) { + return { + encrypt: function(message, key, cfg) { + return selectCipherStrategy(key).encrypt(cipher, message, key, cfg); + }, + decrypt: function(ciphertext, key, cfg) { + return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); + } + }; + }; + })() + }); + C_lib.StreamCipher = Cipher.extend({ + _doFinalize: function() { + var finalProcessedBlocks = this._process(true); + return finalProcessedBlocks; + }, + blockSize: 1 + }); + var C_mode = C.mode = {}; + var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({ + /** + * Creates this mode for encryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); + */ + createEncryptor: function(cipher, iv) { + return this.Encryptor.create(cipher, iv); + }, + /** + * Creates this mode for decryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); + */ + createDecryptor: function(cipher, iv) { + return this.Decryptor.create(cipher, iv); + }, + /** + * Initializes a newly created mode. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @example + * + * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); + */ + init: function(cipher, iv) { + this._cipher = cipher; + this._iv = iv; + } + }); + var CBC = C_mode.CBC = (function() { + var CBC2 = BlockCipherMode.extend(); + CBC2.Encryptor = CBC2.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function(words, offset) { + var cipher = this._cipher; + var blockSize = cipher.blockSize; + xorBlock.call(this, words, offset, blockSize); + cipher.encryptBlock(words, offset); + this._prevBlock = words.slice(offset, offset + blockSize); + } + }); + CBC2.Decryptor = CBC2.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function(words, offset) { + var cipher = this._cipher; + var blockSize = cipher.blockSize; + var thisBlock = words.slice(offset, offset + blockSize); + cipher.decryptBlock(words, offset); + xorBlock.call(this, words, offset, blockSize); + this._prevBlock = thisBlock; + } + }); + function xorBlock(words, offset, blockSize) { + var block; + var iv = this._iv; + if (iv) { + block = iv; + this._iv = undefined$1; + } else { + block = this._prevBlock; + } + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= block[i]; + } + } + return CBC2; + })(); + var C_pad = C.pad = {}; + var Pkcs7 = C_pad.Pkcs7 = { + /** + * Pads data using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to pad. + * @param {number} blockSize The multiple that the data should be padded to. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.pad(wordArray, 4); + */ + pad: function(data, blockSize) { + var blockSizeBytes = blockSize * 4; + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; + var paddingWord = nPaddingBytes << 24 | nPaddingBytes << 16 | nPaddingBytes << 8 | nPaddingBytes; + var paddingWords = []; + for (var i = 0; i < nPaddingBytes; i += 4) { + paddingWords.push(paddingWord); + } + var padding = WordArray.create(paddingWords, nPaddingBytes); + data.concat(padding); + }, + /** + * Unpads data that had been padded using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to unpad. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.unpad(wordArray); + */ + unpad: function(data) { + var nPaddingBytes = data.words[data.sigBytes - 1 >>> 2] & 255; + data.sigBytes -= nPaddingBytes; + } + }; + C_lib.BlockCipher = Cipher.extend({ + /** + * Configuration options. + * + * @property {Mode} mode The block mode to use. Default: CBC + * @property {Padding} padding The padding strategy to use. Default: Pkcs7 + */ + cfg: Cipher.cfg.extend({ + mode: CBC, + padding: Pkcs7 + }), + reset: function() { + var modeCreator; + Cipher.reset.call(this); + var cfg = this.cfg; + var iv = cfg.iv; + var mode = cfg.mode; + if (this._xformMode == this._ENC_XFORM_MODE) { + modeCreator = mode.createEncryptor; + } else { + modeCreator = mode.createDecryptor; + this._minBufferSize = 1; + } + if (this._mode && this._mode.__creator == modeCreator) { + this._mode.init(this, iv && iv.words); + } else { + this._mode = modeCreator.call(mode, this, iv && iv.words); + this._mode.__creator = modeCreator; + } + }, + _doProcessBlock: function(words, offset) { + this._mode.processBlock(words, offset); + }, + _doFinalize: function() { + var finalProcessedBlocks; + var padding = this.cfg.padding; + if (this._xformMode == this._ENC_XFORM_MODE) { + padding.pad(this._data, this.blockSize); + finalProcessedBlocks = this._process(true); + } else { + finalProcessedBlocks = this._process(true); + padding.unpad(finalProcessedBlocks); + } + return finalProcessedBlocks; + }, + blockSize: 128 / 32 + }); + var CipherParams = C_lib.CipherParams = Base.extend({ + /** + * Initializes a newly created cipher params object. + * + * @param {Object} cipherParams An object with any of the possible cipher parameters. + * + * @example + * + * var cipherParams = CryptoJS.lib.CipherParams.create({ + * ciphertext: ciphertextWordArray, + * key: keyWordArray, + * iv: ivWordArray, + * salt: saltWordArray, + * algorithm: CryptoJS.algo.AES, + * mode: CryptoJS.mode.CBC, + * padding: CryptoJS.pad.PKCS7, + * blockSize: 4, + * formatter: CryptoJS.format.OpenSSL + * }); + */ + init: function(cipherParams) { + this.mixIn(cipherParams); + }, + /** + * Converts this cipher params object to a string. + * + * @param {Format} formatter (Optional) The formatting strategy to use. + * + * @return {string} The stringified cipher params. + * + * @throws Error If neither the formatter nor the default formatter is set. + * + * @example + * + * var string = cipherParams + ''; + * var string = cipherParams.toString(); + * var string = cipherParams.toString(CryptoJS.format.OpenSSL); + */ + toString: function(formatter) { + return (formatter || this.formatter).stringify(this); + } + }); + var C_format = C.format = {}; + var OpenSSLFormatter = C_format.OpenSSL = { + /** + * Converts a cipher params object to an OpenSSL-compatible string. + * + * @param {CipherParams} cipherParams The cipher params object. + * + * @return {string} The OpenSSL-compatible string. + * + * @static + * + * @example + * + * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); + */ + stringify: function(cipherParams) { + var wordArray; + var ciphertext = cipherParams.ciphertext; + var salt = cipherParams.salt; + if (salt) { + wordArray = WordArray.create([1398893684, 1701076831]).concat(salt).concat(ciphertext); + } else { + wordArray = ciphertext; + } + return wordArray.toString(Base64); + }, + /** + * Converts an OpenSSL-compatible string to a cipher params object. + * + * @param {string} openSSLStr The OpenSSL-compatible string. + * + * @return {CipherParams} The cipher params object. + * + * @static + * + * @example + * + * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); + */ + parse: function(openSSLStr) { + var salt; + var ciphertext = Base64.parse(openSSLStr); + var ciphertextWords = ciphertext.words; + if (ciphertextWords[0] == 1398893684 && ciphertextWords[1] == 1701076831) { + salt = WordArray.create(ciphertextWords.slice(2, 4)); + ciphertextWords.splice(0, 4); + ciphertext.sigBytes -= 16; + } + return CipherParams.create({ ciphertext, salt }); + } + }; + var SerializableCipher = C_lib.SerializableCipher = Base.extend({ + /** + * Configuration options. + * + * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL + */ + cfg: Base.extend({ + format: OpenSSLFormatter + }), + /** + * Encrypts a message. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + encrypt: function(cipher, message, key, cfg) { + cfg = this.cfg.extend(cfg); + var encryptor = cipher.createEncryptor(key, cfg); + var ciphertext = encryptor.finalize(message); + var cipherCfg = encryptor.cfg; + return CipherParams.create({ + ciphertext, + key, + iv: cipherCfg.iv, + algorithm: cipher, + mode: cipherCfg.mode, + padding: cipherCfg.padding, + blockSize: cipher.blockSize, + formatter: cfg.format + }); + }, + /** + * Decrypts serialized ciphertext. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + decrypt: function(cipher, ciphertext, key, cfg) { + cfg = this.cfg.extend(cfg); + ciphertext = this._parse(ciphertext, cfg.format); + var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext); + return plaintext; + }, + /** + * Converts serialized ciphertext to CipherParams, + * else assumed CipherParams already and returns ciphertext unchanged. + * + * @param {CipherParams|string} ciphertext The ciphertext. + * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. + * + * @return {CipherParams} The unserialized ciphertext. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format); + */ + _parse: function(ciphertext, format) { + if (typeof ciphertext == "string") { + return format.parse(ciphertext, this); + } else { + return ciphertext; + } + } + }); + var C_kdf = C.kdf = {}; + var OpenSSLKdf = C_kdf.OpenSSL = { + /** + * Derives a key and IV from a password. + * + * @param {string} password The password to derive from. + * @param {number} keySize The size in words of the key to generate. + * @param {number} ivSize The size in words of the IV to generate. + * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. + * + * @return {CipherParams} A cipher params object with the key, IV, and salt. + * + * @static + * + * @example + * + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); + */ + execute: function(password, keySize, ivSize, salt, hasher) { + if (!salt) { + salt = WordArray.random(64 / 8); + } + if (!hasher) { + var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt); + } else { + var key = EvpKDF.create({ keySize: keySize + ivSize, hasher }).compute(password, salt); + } + var iv = WordArray.create(key.words.slice(keySize), ivSize * 4); + key.sigBytes = keySize * 4; + return CipherParams.create({ key, iv, salt }); + } + }; + var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({ + /** + * Configuration options. + * + * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL + */ + cfg: SerializableCipher.cfg.extend({ + kdf: OpenSSLKdf + }), + /** + * Encrypts a message using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password'); + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); + */ + encrypt: function(cipher, message, password, cfg) { + cfg = this.cfg.extend(cfg); + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, cfg.salt, cfg.hasher); + cfg.iv = derivedParams.iv; + var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg); + ciphertext.mixIn(derivedParams); + return ciphertext; + }, + /** + * Decrypts serialized ciphertext using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL }); + */ + decrypt: function(cipher, ciphertext, password, cfg) { + cfg = this.cfg.extend(cfg); + ciphertext = this._parse(ciphertext, cfg.format); + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt, cfg.hasher); + cfg.iv = derivedParams.iv; + var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg); + return plaintext; + } + }); + })(); + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js +var require_aes = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js"(exports$1, module) { + (function(root, factory, undef) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core(), require_enc_base64(), require_md5(), require_evpkdf(), require_cipher_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + (function() { + var C = CryptoJS; + var C_lib = C.lib; + var BlockCipher = C_lib.BlockCipher; + var C_algo = C.algo; + var SBOX = []; + var INV_SBOX = []; + var SUB_MIX_0 = []; + var SUB_MIX_1 = []; + var SUB_MIX_2 = []; + var SUB_MIX_3 = []; + var INV_SUB_MIX_0 = []; + var INV_SUB_MIX_1 = []; + var INV_SUB_MIX_2 = []; + var INV_SUB_MIX_3 = []; + (function() { + var d = []; + for (var i = 0; i < 256; i++) { + if (i < 128) { + d[i] = i << 1; + } else { + d[i] = i << 1 ^ 283; + } + } + var x = 0; + var xi = 0; + for (var i = 0; i < 256; i++) { + var sx = xi ^ xi << 1 ^ xi << 2 ^ xi << 3 ^ xi << 4; + sx = sx >>> 8 ^ sx & 255 ^ 99; + SBOX[x] = sx; + INV_SBOX[sx] = x; + var x2 = d[x]; + var x4 = d[x2]; + var x8 = d[x4]; + var t = d[sx] * 257 ^ sx * 16843008; + SUB_MIX_0[x] = t << 24 | t >>> 8; + SUB_MIX_1[x] = t << 16 | t >>> 16; + SUB_MIX_2[x] = t << 8 | t >>> 24; + SUB_MIX_3[x] = t; + var t = x8 * 16843009 ^ x4 * 65537 ^ x2 * 257 ^ x * 16843008; + INV_SUB_MIX_0[sx] = t << 24 | t >>> 8; + INV_SUB_MIX_1[sx] = t << 16 | t >>> 16; + INV_SUB_MIX_2[sx] = t << 8 | t >>> 24; + INV_SUB_MIX_3[sx] = t; + if (!x) { + x = xi = 1; + } else { + x = x2 ^ d[d[d[x8 ^ x2]]]; + xi ^= d[d[xi]]; + } + } + })(); + var RCON = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54]; + var AES2 = C_algo.AES = BlockCipher.extend({ + _doReset: function() { + var t; + if (this._nRounds && this._keyPriorReset === this._key) { + return; + } + var key = this._keyPriorReset = this._key; + var keyWords = key.words; + var keySize = key.sigBytes / 4; + var nRounds = this._nRounds = keySize + 6; + var ksRows = (nRounds + 1) * 4; + var keySchedule = this._keySchedule = []; + for (var ksRow = 0; ksRow < ksRows; ksRow++) { + if (ksRow < keySize) { + keySchedule[ksRow] = keyWords[ksRow]; + } else { + t = keySchedule[ksRow - 1]; + if (!(ksRow % keySize)) { + t = t << 8 | t >>> 24; + t = SBOX[t >>> 24] << 24 | SBOX[t >>> 16 & 255] << 16 | SBOX[t >>> 8 & 255] << 8 | SBOX[t & 255]; + t ^= RCON[ksRow / keySize | 0] << 24; + } else if (keySize > 6 && ksRow % keySize == 4) { + t = SBOX[t >>> 24] << 24 | SBOX[t >>> 16 & 255] << 16 | SBOX[t >>> 8 & 255] << 8 | SBOX[t & 255]; + } + keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; + } + } + var invKeySchedule = this._invKeySchedule = []; + for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { + var ksRow = ksRows - invKsRow; + if (invKsRow % 4) { + var t = keySchedule[ksRow]; + } else { + var t = keySchedule[ksRow - 4]; + } + if (invKsRow < 4 || ksRow <= 4) { + invKeySchedule[invKsRow] = t; + } else { + invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[t >>> 16 & 255]] ^ INV_SUB_MIX_2[SBOX[t >>> 8 & 255]] ^ INV_SUB_MIX_3[SBOX[t & 255]]; + } + } + }, + encryptBlock: function(M, offset) { + this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); + }, + decryptBlock: function(M, offset) { + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + }, + _doCryptBlock: function(M, offset, keySchedule, SUB_MIX_02, SUB_MIX_12, SUB_MIX_22, SUB_MIX_32, SBOX2) { + var nRounds = this._nRounds; + var s0 = M[offset] ^ keySchedule[0]; + var s1 = M[offset + 1] ^ keySchedule[1]; + var s2 = M[offset + 2] ^ keySchedule[2]; + var s3 = M[offset + 3] ^ keySchedule[3]; + var ksRow = 4; + for (var round = 1; round < nRounds; round++) { + var t0 = SUB_MIX_02[s0 >>> 24] ^ SUB_MIX_12[s1 >>> 16 & 255] ^ SUB_MIX_22[s2 >>> 8 & 255] ^ SUB_MIX_32[s3 & 255] ^ keySchedule[ksRow++]; + var t1 = SUB_MIX_02[s1 >>> 24] ^ SUB_MIX_12[s2 >>> 16 & 255] ^ SUB_MIX_22[s3 >>> 8 & 255] ^ SUB_MIX_32[s0 & 255] ^ keySchedule[ksRow++]; + var t2 = SUB_MIX_02[s2 >>> 24] ^ SUB_MIX_12[s3 >>> 16 & 255] ^ SUB_MIX_22[s0 >>> 8 & 255] ^ SUB_MIX_32[s1 & 255] ^ keySchedule[ksRow++]; + var t3 = SUB_MIX_02[s3 >>> 24] ^ SUB_MIX_12[s0 >>> 16 & 255] ^ SUB_MIX_22[s1 >>> 8 & 255] ^ SUB_MIX_32[s2 & 255] ^ keySchedule[ksRow++]; + s0 = t0; + s1 = t1; + s2 = t2; + s3 = t3; + } + var t0 = (SBOX2[s0 >>> 24] << 24 | SBOX2[s1 >>> 16 & 255] << 16 | SBOX2[s2 >>> 8 & 255] << 8 | SBOX2[s3 & 255]) ^ keySchedule[ksRow++]; + var t1 = (SBOX2[s1 >>> 24] << 24 | SBOX2[s2 >>> 16 & 255] << 16 | SBOX2[s3 >>> 8 & 255] << 8 | SBOX2[s0 & 255]) ^ keySchedule[ksRow++]; + var t2 = (SBOX2[s2 >>> 24] << 24 | SBOX2[s3 >>> 16 & 255] << 16 | SBOX2[s0 >>> 8 & 255] << 8 | SBOX2[s1 & 255]) ^ keySchedule[ksRow++]; + var t3 = (SBOX2[s3 >>> 24] << 24 | SBOX2[s0 >>> 16 & 255] << 16 | SBOX2[s1 >>> 8 & 255] << 8 | SBOX2[s2 & 255]) ^ keySchedule[ksRow++]; + M[offset] = t0; + M[offset + 1] = t1; + M[offset + 2] = t2; + M[offset + 3] = t3; + }, + keySize: 256 / 32 + }); + C.AES = BlockCipher._createHelper(AES2); + })(); + return CryptoJS.AES; + }); + } +}); + +// node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js +var require_enc_utf8 = __commonJS({ + "node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js"(exports$1, module) { + (function(root, factory) { + if (typeof exports$1 === "object") { + module.exports = exports$1 = factory(require_core()); + } else if (typeof define === "function" && define.amd) { + define(["./core"], factory); + } else { + factory(root.CryptoJS); + } + })(exports$1, function(CryptoJS) { + return CryptoJS.enc.Utf8; + }); + } +}); + +// src/core.ts +var import_aes = __toESM(require_aes()); +var import_enc_utf8 = __toESM(require_enc_utf8()); +var encryptData = (data, encryptionKey) => { + return import_aes.default.encrypt(data, encryptionKey).toString(); +}; +var decryptData = (encryptedData, encryptionKey) => { + const decryptedMessage = import_aes.default.decrypt(encryptedData, encryptionKey); + let decryptedString; + try { + decryptedString = decryptedMessage.toString(import_enc_utf8.default); + } catch { + throw new Error("Decryption failed. Invalid key or corrupt data."); + } + if (!decryptedString) { + throw new Error("Decryption failed. Invalid key or corrupt data."); + } + return decryptedString; +}; +var stringifyPayload = (payload, sender, sendType) => { + return JSON.stringify({ + actions: [...payload], + sender, + type: sendType + }); +}; +var createEncryptedPayload = (payload, sender, sendType, encryptionKey) => { + const stringifiedData = stringifyPayload(payload, sender, sendType); + return encryptData(stringifiedData, encryptionKey); +}; +var parseEncryptedPayload = (encryptedData, encryptionKey, options) => { + const dataToParse = options?.isDataURIEncoded ? decodeURI(encryptedData) : encryptedData; + const decryptedString = decryptData(dataToParse, encryptionKey); + try { + const decryptedData = JSON.parse(decryptedString); + return decryptedData; + } catch { + throw new Error("Failed to parse decrypted data."); + } +}; +var appendEncryptedDataToUrl = (url, encryptedData, useHash) => { + const destinationUrl = new URL(url); + if (useHash) { + destinationUrl.hash = `data=${encodeURI(encryptedData)}`; + } else { + destinationUrl.searchParams.set("data", encodeURI(encryptedData)); + } + return destinationUrl.toString(); +}; + +// src/server.ts +var createServerCallback = (config) => { + const parse = (data, options) => { + return parseEncryptedPayload(data, config.encryptionKey, options); + }; + const generateUrl = (url, payload, sendType, sender) => { + const effectiveSender = sender ?? ""; + const encryptedMessage = createEncryptedPayload( + payload, + effectiveSender, + sendType, + config.encryptionKey + ); + const shouldUseHash = config.useHash !== false; + return appendEncryptedDataToUrl(url, encryptedMessage, shouldUseHash); + }; + return { + parse, + generateUrl + }; +}; + +export { createServerCallback }; diff --git a/dist/types.d.ts b/dist/types.d.ts index 678400b..8d608b4 100644 --- a/dist/types.d.ts +++ b/dist/types.d.ts @@ -112,4 +112,10 @@ export interface WatcherOptions { } export interface CallbackConfig { encryptionKey: string; + /** + * When true (default), encrypted callback data will be placed in the URL hash + * instead of a query parameter to avoid leaking data via referrers. + * Set to false to use a query parameter instead. + */ + useHash?: boolean; } diff --git a/dist/types.js b/dist/types.js deleted file mode 100644 index cb0ff5c..0000000 --- a/dist/types.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/package.json b/package.json index 69faf8c..5cc98bb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,10 @@ { "name": "@unraid/shared-callbacks", "version": "2.0.3", - "repository": "github:unraid/shared-callbacks", + "repository": { + "type": "git", + "url": "git+https://github.com/unraid/shared-callbacks" + }, "publishConfig": { "access": "public" }, @@ -9,11 +12,27 @@ "main": "dist/index.js", "module": "dist/index.js", "types": "dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + }, + "./client": { + "types": "./dist/client.d.ts", + "import": "./dist/client.js" + }, + "./server": { + "types": "./dist/server.d.ts", + "import": "./dist/server.js" + } + }, "files": [ "dist" ], "scripts": { - "build": "tsc", + "build": "pnpm build:types && pnpm build:js", + "build:types": "tsc --emitDeclarationOnly", + "build:js": "tsup", "dev": "tsc --watch", "clean": "rimraf dist", "prebuild": "pnpm clean", @@ -24,15 +43,12 @@ "dependencies": { "crypto-js": "^4.2.0" }, - "peerDependencies": { - "@vueuse/core": "^10.9.0 || ^13.0.0" - }, "devDependencies": { "@types/crypto-js": "^4.2.1", "@vitest/coverage-v8": "^4.0.0", "@vue/test-utils": "^2.4.6", - "@vueuse/core": "^13.0.0", "rimraf": "^6.0.0", + "tsup": "^8.5.0", "typescript": "^5.3.3", "vitest": "^4.0.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3068439..0440438 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,12 +21,12 @@ importers: '@vue/test-utils': specifier: ^2.4.6 version: 2.4.6 - '@vueuse/core': - specifier: ^13.0.0 - version: 13.9.0(vue@3.5.13(typescript@5.9.3)) rimraf: specifier: ^6.0.0 version: 6.1.2 + tsup: + specifier: ^8.5.0 + version: 8.5.1(postcss@8.5.6)(typescript@5.9.3) typescript: specifier: ^5.3.3 version: 5.9.3 @@ -94,156 +94,312 @@ packages: cpu: [ppc64] os: [aix] + '@esbuild/aix-ppc64@0.27.1': + resolution: {integrity: sha512-HHB50pdsBX6k47S4u5g/CaLjqS3qwaOVE5ILsq64jyzgMhLuCuZ8rGzM9yhsAjfjkbgUPMzZEPa7DAp7yz6vuA==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + '@esbuild/android-arm64@0.25.12': resolution: {integrity: sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==} engines: {node: '>=18'} cpu: [arm64] os: [android] + '@esbuild/android-arm64@0.27.1': + resolution: {integrity: sha512-45fuKmAJpxnQWixOGCrS+ro4Uvb4Re9+UTieUY2f8AEc+t7d4AaZ6eUJ3Hva7dtrxAAWHtlEFsXFMAgNnGU9uQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + '@esbuild/android-arm@0.25.12': resolution: {integrity: sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==} engines: {node: '>=18'} cpu: [arm] os: [android] + '@esbuild/android-arm@0.27.1': + resolution: {integrity: sha512-kFqa6/UcaTbGm/NncN9kzVOODjhZW8e+FRdSeypWe6j33gzclHtwlANs26JrupOntlcWmB0u8+8HZo8s7thHvg==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + '@esbuild/android-x64@0.25.12': resolution: {integrity: sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==} engines: {node: '>=18'} cpu: [x64] os: [android] + '@esbuild/android-x64@0.27.1': + resolution: {integrity: sha512-LBEpOz0BsgMEeHgenf5aqmn/lLNTFXVfoWMUox8CtWWYK9X4jmQzWjoGoNb8lmAYml/tQ/Ysvm8q7szu7BoxRQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + '@esbuild/darwin-arm64@0.25.12': resolution: {integrity: sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==} engines: {node: '>=18'} cpu: [arm64] os: [darwin] + '@esbuild/darwin-arm64@0.27.1': + resolution: {integrity: sha512-veg7fL8eMSCVKL7IW4pxb54QERtedFDfY/ASrumK/SbFsXnRazxY4YykN/THYqFnFwJ0aVjiUrVG2PwcdAEqQQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + '@esbuild/darwin-x64@0.25.12': resolution: {integrity: sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==} engines: {node: '>=18'} cpu: [x64] os: [darwin] + '@esbuild/darwin-x64@0.27.1': + resolution: {integrity: sha512-+3ELd+nTzhfWb07Vol7EZ+5PTbJ/u74nC6iv4/lwIU99Ip5uuY6QoIf0Hn4m2HoV0qcnRivN3KSqc+FyCHjoVQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + '@esbuild/freebsd-arm64@0.25.12': resolution: {integrity: sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==} engines: {node: '>=18'} cpu: [arm64] os: [freebsd] + '@esbuild/freebsd-arm64@0.27.1': + resolution: {integrity: sha512-/8Rfgns4XD9XOSXlzUDepG8PX+AVWHliYlUkFI3K3GB6tqbdjYqdhcb4BKRd7C0BhZSoaCxhv8kTcBrcZWP+xg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + '@esbuild/freebsd-x64@0.25.12': resolution: {integrity: sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==} engines: {node: '>=18'} cpu: [x64] os: [freebsd] + '@esbuild/freebsd-x64@0.27.1': + resolution: {integrity: sha512-GITpD8dK9C+r+5yRT/UKVT36h/DQLOHdwGVwwoHidlnA168oD3uxA878XloXebK4Ul3gDBBIvEdL7go9gCUFzQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + '@esbuild/linux-arm64@0.25.12': resolution: {integrity: sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==} engines: {node: '>=18'} cpu: [arm64] os: [linux] + '@esbuild/linux-arm64@0.27.1': + resolution: {integrity: sha512-W9//kCrh/6in9rWIBdKaMtuTTzNj6jSeG/haWBADqLLa9P8O5YSRDzgD5y9QBok4AYlzS6ARHifAb75V6G670Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + '@esbuild/linux-arm@0.25.12': resolution: {integrity: sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==} engines: {node: '>=18'} cpu: [arm] os: [linux] + '@esbuild/linux-arm@0.27.1': + resolution: {integrity: sha512-ieMID0JRZY/ZeCrsFQ3Y3NlHNCqIhTprJfDgSB3/lv5jJZ8FX3hqPyXWhe+gvS5ARMBJ242PM+VNz/ctNj//eA==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + '@esbuild/linux-ia32@0.25.12': resolution: {integrity: sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==} engines: {node: '>=18'} cpu: [ia32] os: [linux] + '@esbuild/linux-ia32@0.27.1': + resolution: {integrity: sha512-VIUV4z8GD8rtSVMfAj1aXFahsi/+tcoXXNYmXgzISL+KB381vbSTNdeZHHHIYqFyXcoEhu9n5cT+05tRv13rlw==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + '@esbuild/linux-loong64@0.25.12': resolution: {integrity: sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==} engines: {node: '>=18'} cpu: [loong64] os: [linux] + '@esbuild/linux-loong64@0.27.1': + resolution: {integrity: sha512-l4rfiiJRN7sTNI//ff65zJ9z8U+k6zcCg0LALU5iEWzY+a1mVZ8iWC1k5EsNKThZ7XCQ6YWtsZ8EWYm7r1UEsg==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + '@esbuild/linux-mips64el@0.25.12': resolution: {integrity: sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==} engines: {node: '>=18'} cpu: [mips64el] os: [linux] + '@esbuild/linux-mips64el@0.27.1': + resolution: {integrity: sha512-U0bEuAOLvO/DWFdygTHWY8C067FXz+UbzKgxYhXC0fDieFa0kDIra1FAhsAARRJbvEyso8aAqvPdNxzWuStBnA==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + '@esbuild/linux-ppc64@0.25.12': resolution: {integrity: sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==} engines: {node: '>=18'} cpu: [ppc64] os: [linux] + '@esbuild/linux-ppc64@0.27.1': + resolution: {integrity: sha512-NzdQ/Xwu6vPSf/GkdmRNsOfIeSGnh7muundsWItmBsVpMoNPVpM61qNzAVY3pZ1glzzAxLR40UyYM23eaDDbYQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + '@esbuild/linux-riscv64@0.25.12': resolution: {integrity: sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==} engines: {node: '>=18'} cpu: [riscv64] os: [linux] + '@esbuild/linux-riscv64@0.27.1': + resolution: {integrity: sha512-7zlw8p3IApcsN7mFw0O1Z1PyEk6PlKMu18roImfl3iQHTnr/yAfYv6s4hXPidbDoI2Q0pW+5xeoM4eTCC0UdrQ==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + '@esbuild/linux-s390x@0.25.12': resolution: {integrity: sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==} engines: {node: '>=18'} cpu: [s390x] os: [linux] + '@esbuild/linux-s390x@0.27.1': + resolution: {integrity: sha512-cGj5wli+G+nkVQdZo3+7FDKC25Uh4ZVwOAK6A06Hsvgr8WqBBuOy/1s+PUEd/6Je+vjfm6stX0kmib5b/O2Ykw==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + '@esbuild/linux-x64@0.25.12': resolution: {integrity: sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==} engines: {node: '>=18'} cpu: [x64] os: [linux] + '@esbuild/linux-x64@0.27.1': + resolution: {integrity: sha512-z3H/HYI9MM0HTv3hQZ81f+AKb+yEoCRlUby1F80vbQ5XdzEMyY/9iNlAmhqiBKw4MJXwfgsh7ERGEOhrM1niMA==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + '@esbuild/netbsd-arm64@0.25.12': resolution: {integrity: sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==} engines: {node: '>=18'} cpu: [arm64] os: [netbsd] + '@esbuild/netbsd-arm64@0.27.1': + resolution: {integrity: sha512-wzC24DxAvk8Em01YmVXyjl96Mr+ecTPyOuADAvjGg+fyBpGmxmcr2E5ttf7Im8D0sXZihpxzO1isus8MdjMCXQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + '@esbuild/netbsd-x64@0.25.12': resolution: {integrity: sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==} engines: {node: '>=18'} cpu: [x64] os: [netbsd] + '@esbuild/netbsd-x64@0.27.1': + resolution: {integrity: sha512-1YQ8ybGi2yIXswu6eNzJsrYIGFpnlzEWRl6iR5gMgmsrR0FcNoV1m9k9sc3PuP5rUBLshOZylc9nqSgymI+TYg==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + '@esbuild/openbsd-arm64@0.25.12': resolution: {integrity: sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==} engines: {node: '>=18'} cpu: [arm64] os: [openbsd] + '@esbuild/openbsd-arm64@0.27.1': + resolution: {integrity: sha512-5Z+DzLCrq5wmU7RDaMDe2DVXMRm2tTDvX2KU14JJVBN2CT/qov7XVix85QoJqHltpvAOZUAc3ndU56HSMWrv8g==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + '@esbuild/openbsd-x64@0.25.12': resolution: {integrity: sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==} engines: {node: '>=18'} cpu: [x64] os: [openbsd] + '@esbuild/openbsd-x64@0.27.1': + resolution: {integrity: sha512-Q73ENzIdPF5jap4wqLtsfh8YbYSZ8Q0wnxplOlZUOyZy7B4ZKW8DXGWgTCZmF8VWD7Tciwv5F4NsRf6vYlZtqg==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + '@esbuild/openharmony-arm64@0.25.12': resolution: {integrity: sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==} engines: {node: '>=18'} cpu: [arm64] os: [openharmony] + '@esbuild/openharmony-arm64@0.27.1': + resolution: {integrity: sha512-ajbHrGM/XiK+sXM0JzEbJAen+0E+JMQZ2l4RR4VFwvV9JEERx+oxtgkpoKv1SevhjavK2z2ReHk32pjzktWbGg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + '@esbuild/sunos-x64@0.25.12': resolution: {integrity: sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==} engines: {node: '>=18'} cpu: [x64] os: [sunos] + '@esbuild/sunos-x64@0.27.1': + resolution: {integrity: sha512-IPUW+y4VIjuDVn+OMzHc5FV4GubIwPnsz6ubkvN8cuhEqH81NovB53IUlrlBkPMEPxvNnf79MGBoz8rZ2iW8HA==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + '@esbuild/win32-arm64@0.25.12': resolution: {integrity: sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==} engines: {node: '>=18'} cpu: [arm64] os: [win32] + '@esbuild/win32-arm64@0.27.1': + resolution: {integrity: sha512-RIVRWiljWA6CdVu8zkWcRmGP7iRRIIwvhDKem8UMBjPql2TXM5PkDVvvrzMtj1V+WFPB4K7zkIGM7VzRtFkjdg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + '@esbuild/win32-ia32@0.25.12': resolution: {integrity: sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==} engines: {node: '>=18'} cpu: [ia32] os: [win32] + '@esbuild/win32-ia32@0.27.1': + resolution: {integrity: sha512-2BR5M8CPbptC1AK5JbJT1fWrHLvejwZidKx3UMSF0ecHMa+smhi16drIrCEggkgviBwLYd5nwrFLSl5Kho96RQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + '@esbuild/win32-x64@0.25.12': resolution: {integrity: sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==} engines: {node: '>=18'} cpu: [x64] os: [win32] + '@esbuild/win32-x64@0.27.1': + resolution: {integrity: sha512-d5X6RMYv6taIymSk8JBP+nxv8DQAMY6A51GPgusqLdK9wBz5wWIXy1KjTck6HnjE9hqJzJRdk+1p/t5soSbCtw==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + '@isaacs/balanced-match@4.0.1': resolution: {integrity: sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==} engines: {node: 20 || >=22} @@ -256,6 +412,9 @@ packages: resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} + '@jridgewell/gen-mapping@0.3.13': + resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} + '@jridgewell/resolve-uri@3.1.2': resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} @@ -398,9 +557,6 @@ packages: '@types/estree@1.0.8': resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} - '@types/web-bluetooth@0.0.21': - resolution: {integrity: sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==} - '@vitest/coverage-v8@4.0.15': resolution: {integrity: sha512-FUJ+1RkpTFW7rQITdgTi93qOCWJobWhBirEPCeXh2SW2wsTlFxy51apDz5gzG+ZEYt/THvWeNmhdAoS9DTwpCw==} peerDependencies: @@ -439,55 +595,18 @@ packages: '@vitest/utils@4.0.15': resolution: {integrity: sha512-HXjPW2w5dxhTD0dLwtYHDnelK3j8sR8cWIaLxr22evTyY6q8pRCjZSmhRWVjBaOVXChQd6AwMzi9pucorXCPZA==} - '@vue/compiler-core@3.5.13': - resolution: {integrity: sha512-oOdAkwqUfW1WqpwSYJce06wvt6HljgY3fGeM9NcVA1HaYOij3mZG9Rkysn0OHuyUAGMbEbARIpsG+LPVlBJ5/Q==} - - '@vue/compiler-dom@3.5.13': - resolution: {integrity: sha512-ZOJ46sMOKUjO3e94wPdCzQ6P1Lx/vhp2RSvfaab88Ajexs0AHeV0uasYhi99WPaogmBlRHNRuly8xV75cNTMDA==} - - '@vue/compiler-sfc@3.5.13': - resolution: {integrity: sha512-6VdaljMpD82w6c2749Zhf5T9u5uLBWKnVue6XWxprDobftnletJ8+oel7sexFfM3qIxNmVE7LSFGTpv6obNyaQ==} - - '@vue/compiler-ssr@3.5.13': - resolution: {integrity: sha512-wMH6vrYHxQl/IybKJagqbquvxpWCuVYpoUJfCqFZwa/JY1GdATAQ+TgVtgrwwMZ0D07QhA99rs/EAAWfvG6KpA==} - - '@vue/reactivity@3.5.13': - resolution: {integrity: sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==} - - '@vue/runtime-core@3.5.13': - resolution: {integrity: sha512-Fj4YRQ3Az0WTZw1sFe+QDb0aXCerigEpw418pw1HBUKFtnQHWzwojaukAs2X/c9DQz4MQ4bsXTGlcpGxU/RCIw==} - - '@vue/runtime-dom@3.5.13': - resolution: {integrity: sha512-dLaj94s93NYLqjLiyFzVs9X6dWhTdAlEAciC3Moq7gzAc13VJUdCnjjRurNM6uTLFATRHexHCTu/Xp3eW6yoog==} - - '@vue/server-renderer@3.5.13': - resolution: {integrity: sha512-wAi4IRJV/2SAW3htkTlB+dHeRmpTiVIK1OGLWV1yeStVSebSQQOwGwIq0D3ZIoBj2C2qpgz5+vX9iEBkTdk5YA==} - peerDependencies: - vue: 3.5.13 - - '@vue/shared@3.5.13': - resolution: {integrity: sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==} - '@vue/test-utils@2.4.6': resolution: {integrity: sha512-FMxEjOpYNYiFe0GkaHsnJPXFHxQ6m4t8vI/ElPGpMWxZKpmRvQ33OIrvRXemy6yha03RxhOlQuy+gZMC3CQSow==} - '@vueuse/core@13.9.0': - resolution: {integrity: sha512-ts3regBQyURfCE2BcytLqzm8+MmLlo5Ln/KLoxDVcsZ2gzIwVNnQpQOL/UKV8alUqjSZOlpFZcRNsLRqj+OzyA==} - peerDependencies: - vue: ^3.5.0 - - '@vueuse/metadata@13.9.0': - resolution: {integrity: sha512-1AFRvuiGphfF7yWixZa0KwjYH8ulyjDCC0aFgrGRz8+P4kvDFSdXLVfTk5xAN9wEuD1J6z4/myMoYbnHoX07zg==} - - '@vueuse/shared@13.9.0': - resolution: {integrity: sha512-e89uuTLMh0U5cZ9iDpEI2senqPGfbPRTHM/0AaQkcxnpqjkZqDYP8rpfm7edOz8s+pOCOROEy1PIveSW8+fL5g==} - peerDependencies: - vue: ^3.5.0 - abbrev@2.0.0: resolution: {integrity: sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + acorn@8.15.0: + resolution: {integrity: sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==} + engines: {node: '>=0.4.0'} + hasBin: true + agent-base@7.1.4: resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==} engines: {node: '>= 14'} @@ -508,6 +627,9 @@ packages: resolution: {integrity: sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==} engines: {node: '>=12'} + any-promise@1.3.0: + resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==} + assertion-error@2.0.1: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} @@ -524,6 +646,16 @@ packages: brace-expansion@2.0.2: resolution: {integrity: sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==} + bundle-require@5.1.0: + resolution: {integrity: sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + peerDependencies: + esbuild: '>=0.18' + + cac@6.7.14: + resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} + engines: {node: '>=8'} + call-bind-apply-helpers@1.0.2: resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} engines: {node: '>= 0.4'} @@ -532,6 +664,10 @@ packages: resolution: {integrity: sha512-p4Z49OGG5W/WBCPSS/dH3jQ73kD6tiMmUM+bckNK6Jr5JHMG3k9bg/BvKR8lKmtVBKmOiuVaV2ws8s9oSbwysg==} engines: {node: '>=18'} + chokidar@4.0.3: + resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==} + engines: {node: '>= 14.16.0'} + color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} @@ -547,9 +683,20 @@ packages: resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} engines: {node: '>=14'} + commander@4.1.1: + resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} + engines: {node: '>= 6'} + + confbox@0.1.8: + resolution: {integrity: sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==} + config-chain@1.1.13: resolution: {integrity: sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ==} + consola@3.4.2: + resolution: {integrity: sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==} + engines: {node: ^14.18.0 || >=16.10.0} + cross-spawn@7.0.6: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} @@ -561,9 +708,6 @@ packages: resolution: {integrity: sha512-2z+rWdzbbSZv6/rhtvzvqeZQHrBaqgogqt85sqFNbabZOuFbCVFb8kPeEtZjiKkbrm395irpNKiYeFeLiQnFPg==} engines: {node: '>=18'} - csstype@3.2.3: - resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==} - data-urls@5.0.0: resolution: {integrity: sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==} engines: {node: '>=18'} @@ -602,10 +746,6 @@ packages: emoji-regex@9.2.2: resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} - entities@4.5.0: - resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} - engines: {node: '>=0.12'} - entities@6.0.1: resolution: {integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==} engines: {node: '>=0.12'} @@ -634,8 +774,10 @@ packages: engines: {node: '>=18'} hasBin: true - estree-walker@2.0.2: - resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} + esbuild@0.27.1: + resolution: {integrity: sha512-yY35KZckJJuVVPXpvjgxiCuVEJT67F6zDeVTv4rizyPrfGBUpZQsvmxnN+C371c2esD/hNMjj4tpBhuueLN7aA==} + engines: {node: '>=18'} + hasBin: true estree-walker@3.0.3: resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} @@ -653,6 +795,9 @@ packages: picomatch: optional: true + fix-dts-default-cjs-exports@1.0.1: + resolution: {integrity: sha512-pVIECanWFC61Hzl2+oOCtoJ3F17kglZC/6N94eRWycFgBH35hHx0Li604ZIzhseh97mf2p0cv7vVrOZGoqhlEg==} + foreground-child@3.3.1: resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==} engines: {node: '>=14'} @@ -756,6 +901,10 @@ packages: jackspeak@3.4.3: resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} + joycon@3.1.1: + resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} + engines: {node: '>=10'} + js-beautify@1.15.4: resolution: {integrity: sha512-9/KXeZUKKJwqCXUdBxFJ3vPh467OCckSBmYDwSK/EtV090K+iMJ7zx2S3HLVDIWFQdqMIsZWbnaGiba18aWhaA==} engines: {node: '>=14'} @@ -777,6 +926,17 @@ packages: canvas: optional: true + lilconfig@3.1.3: + resolution: {integrity: sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==} + engines: {node: '>=14'} + + lines-and-columns@1.2.4: + resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} + + load-tsconfig@0.2.5: + resolution: {integrity: sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + lru-cache@10.4.3: resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} @@ -822,9 +982,15 @@ packages: resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==} engines: {node: '>=16 || 14 >=14.17'} + mlly@1.8.0: + resolution: {integrity: sha512-l8D9ODSRWLe2KHJSifWGwBqpTZXIXTeo8mlKjY+E2HAakaTeNpqAyBZ8GSqLzHgw4XmHmC8whvpjJNMbFZN7/g==} + ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + mz@2.7.0: + resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} + nanoid@3.3.11: resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -838,6 +1004,10 @@ packages: nwsapi@2.2.23: resolution: {integrity: sha512-7wfH4sLbt4M0gCDzGE6vzQBo0bfTKjU7Sfpqy/7gs1qBfYz2vEJH6vXcBKpO3+6Yu1telwd0t9HpyOoLEQQbIQ==} + object-assign@4.1.1: + resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} + engines: {node: '>=0.10.0'} + obug@2.1.1: resolution: {integrity: sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==} @@ -869,6 +1039,31 @@ packages: resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==} engines: {node: '>=12'} + pirates@4.0.7: + resolution: {integrity: sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==} + engines: {node: '>= 6'} + + pkg-types@1.3.1: + resolution: {integrity: sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==} + + postcss-load-config@6.0.1: + resolution: {integrity: sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g==} + engines: {node: '>= 18'} + peerDependencies: + jiti: '>=1.21.0' + postcss: '>=8.0.9' + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + jiti: + optional: true + postcss: + optional: true + tsx: + optional: true + yaml: + optional: true + postcss@8.5.6: resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==} engines: {node: ^10 || ^12 || >=14} @@ -880,6 +1075,14 @@ packages: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} + readdirp@4.1.2: + resolution: {integrity: sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==} + engines: {node: '>= 14.18.0'} + + resolve-from@5.0.0: + resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} + engines: {node: '>=8'} + rimraf@6.1.2: resolution: {integrity: sha512-cFCkPslJv7BAXJsYlK1dZsbP8/ZNLkCAQ0bi1hf5EKX2QHegmDFEFA6QhuYJlk7UDdc+02JjO80YSOrWPpw06g==} engines: {node: 20 || >=22} @@ -929,6 +1132,10 @@ packages: resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==} engines: {node: '>=0.10.0'} + source-map@0.7.6: + resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==} + engines: {node: '>= 12'} + stackback@0.0.2: resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} @@ -951,6 +1158,11 @@ packages: resolution: {integrity: sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==} engines: {node: '>=12'} + sucrase@3.35.1: + resolution: {integrity: sha512-DhuTmvZWux4H1UOnWMB3sk0sbaCVOoQZjv8u1rDoTV0HTdGem9hkAZtl4JZy8P2z4Bg0nT+YMeOFyVr4zcG5Tw==} + engines: {node: '>=16 || 14 >=14.17'} + hasBin: true + supports-color@7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} engines: {node: '>=8'} @@ -958,9 +1170,19 @@ packages: symbol-tree@3.2.4: resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==} + thenify-all@1.6.0: + resolution: {integrity: sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==} + engines: {node: '>=0.8'} + + thenify@3.3.1: + resolution: {integrity: sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==} + tinybench@2.9.0: resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} + tinyexec@0.3.2: + resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==} + tinyexec@1.0.2: resolution: {integrity: sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==} engines: {node: '>=18'} @@ -988,11 +1210,40 @@ packages: resolution: {integrity: sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==} engines: {node: '>=18'} + tree-kill@1.2.2: + resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==} + hasBin: true + + ts-interface-checker@0.1.13: + resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} + + tsup@8.5.1: + resolution: {integrity: sha512-xtgkqwdhpKWr3tKPmCkvYmS9xnQK3m3XgxZHwSUjvfTjp7YfXe5tT3GgWi0F2N+ZSMsOeWeZFh7ZZFg5iPhing==} + engines: {node: '>=18'} + hasBin: true + peerDependencies: + '@microsoft/api-extractor': ^7.36.0 + '@swc/core': ^1 + postcss: ^8.4.12 + typescript: '>=4.5.0' + peerDependenciesMeta: + '@microsoft/api-extractor': + optional: true + '@swc/core': + optional: true + postcss: + optional: true + typescript: + optional: true + typescript@5.9.3: resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} engines: {node: '>=14.17'} hasBin: true + ufo@1.6.1: + resolution: {integrity: sha512-9a4/uxlTWJ4+a5i0ooc1rU7C7YOw3wT+UGqdeNNHWnOF9qcMBgLRS+4IYUqbczewFx4mLEig6gawh7X6mFlEkA==} + vite@7.2.2: resolution: {integrity: sha512-BxAKBWmIbrDgrokdGZH1IgkIk/5mMHDreLDmCJ0qpyJaAteP8NvMhkwr/ZCQNqNH97bw/dANTE9PDzqwJghfMQ==} engines: {node: ^20.19.0 || >=22.12.0} @@ -1070,14 +1321,6 @@ packages: vue-component-type-helpers@2.2.8: resolution: {integrity: sha512-4bjIsC284coDO9om4HPA62M7wfsTvcmZyzdfR0aUlFXqq4tXxM1APyXpNVxPC8QazKw9OhmZNHBVDA6ODaZsrA==} - vue@3.5.13: - resolution: {integrity: sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==} - peerDependencies: - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - w3c-xmlserializer@5.0.0: resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==} engines: {node: '>=18'} @@ -1189,81 +1432,159 @@ snapshots: '@esbuild/aix-ppc64@0.25.12': optional: true + '@esbuild/aix-ppc64@0.27.1': + optional: true + '@esbuild/android-arm64@0.25.12': optional: true + '@esbuild/android-arm64@0.27.1': + optional: true + '@esbuild/android-arm@0.25.12': optional: true + '@esbuild/android-arm@0.27.1': + optional: true + '@esbuild/android-x64@0.25.12': optional: true + '@esbuild/android-x64@0.27.1': + optional: true + '@esbuild/darwin-arm64@0.25.12': optional: true + '@esbuild/darwin-arm64@0.27.1': + optional: true + '@esbuild/darwin-x64@0.25.12': optional: true + '@esbuild/darwin-x64@0.27.1': + optional: true + '@esbuild/freebsd-arm64@0.25.12': optional: true + '@esbuild/freebsd-arm64@0.27.1': + optional: true + '@esbuild/freebsd-x64@0.25.12': optional: true + '@esbuild/freebsd-x64@0.27.1': + optional: true + '@esbuild/linux-arm64@0.25.12': optional: true + '@esbuild/linux-arm64@0.27.1': + optional: true + '@esbuild/linux-arm@0.25.12': optional: true + '@esbuild/linux-arm@0.27.1': + optional: true + '@esbuild/linux-ia32@0.25.12': optional: true + '@esbuild/linux-ia32@0.27.1': + optional: true + '@esbuild/linux-loong64@0.25.12': optional: true + '@esbuild/linux-loong64@0.27.1': + optional: true + '@esbuild/linux-mips64el@0.25.12': optional: true + '@esbuild/linux-mips64el@0.27.1': + optional: true + '@esbuild/linux-ppc64@0.25.12': optional: true + '@esbuild/linux-ppc64@0.27.1': + optional: true + '@esbuild/linux-riscv64@0.25.12': optional: true + '@esbuild/linux-riscv64@0.27.1': + optional: true + '@esbuild/linux-s390x@0.25.12': optional: true + '@esbuild/linux-s390x@0.27.1': + optional: true + '@esbuild/linux-x64@0.25.12': optional: true + '@esbuild/linux-x64@0.27.1': + optional: true + '@esbuild/netbsd-arm64@0.25.12': optional: true + '@esbuild/netbsd-arm64@0.27.1': + optional: true + '@esbuild/netbsd-x64@0.25.12': optional: true + '@esbuild/netbsd-x64@0.27.1': + optional: true + '@esbuild/openbsd-arm64@0.25.12': optional: true + '@esbuild/openbsd-arm64@0.27.1': + optional: true + '@esbuild/openbsd-x64@0.25.12': optional: true + '@esbuild/openbsd-x64@0.27.1': + optional: true + '@esbuild/openharmony-arm64@0.25.12': optional: true + '@esbuild/openharmony-arm64@0.27.1': + optional: true + '@esbuild/sunos-x64@0.25.12': optional: true + '@esbuild/sunos-x64@0.27.1': + optional: true + '@esbuild/win32-arm64@0.25.12': optional: true + '@esbuild/win32-arm64@0.27.1': + optional: true + '@esbuild/win32-ia32@0.25.12': optional: true + '@esbuild/win32-ia32@0.27.1': + optional: true + '@esbuild/win32-x64@0.25.12': optional: true + '@esbuild/win32-x64@0.27.1': + optional: true + '@isaacs/balanced-match@4.0.1': {} '@isaacs/brace-expansion@5.0.0': @@ -1279,6 +1600,11 @@ snapshots: wrap-ansi: 8.1.0 wrap-ansi-cjs: wrap-ansi@7.0.0 + '@jridgewell/gen-mapping@0.3.13': + dependencies: + '@jridgewell/sourcemap-codec': 1.5.5 + '@jridgewell/trace-mapping': 0.3.31 + '@jridgewell/resolve-uri@3.1.2': {} '@jridgewell/sourcemap-codec@1.5.5': {} @@ -1372,8 +1698,6 @@ snapshots: '@types/estree@1.0.8': {} - '@types/web-bluetooth@0.0.21': {} - '@vitest/coverage-v8@4.0.15(vitest@4.0.15(jsdom@26.0.0))': dependencies: '@bcoe/v8-coverage': 1.0.2 @@ -1430,80 +1754,15 @@ snapshots: '@vitest/pretty-format': 4.0.15 tinyrainbow: 3.0.3 - '@vue/compiler-core@3.5.13': - dependencies: - '@babel/parser': 7.28.5 - '@vue/shared': 3.5.13 - entities: 4.5.0 - estree-walker: 2.0.2 - source-map-js: 1.2.1 - - '@vue/compiler-dom@3.5.13': - dependencies: - '@vue/compiler-core': 3.5.13 - '@vue/shared': 3.5.13 - - '@vue/compiler-sfc@3.5.13': - dependencies: - '@babel/parser': 7.28.5 - '@vue/compiler-core': 3.5.13 - '@vue/compiler-dom': 3.5.13 - '@vue/compiler-ssr': 3.5.13 - '@vue/shared': 3.5.13 - estree-walker: 2.0.2 - magic-string: 0.30.21 - postcss: 8.5.6 - source-map-js: 1.2.1 - - '@vue/compiler-ssr@3.5.13': - dependencies: - '@vue/compiler-dom': 3.5.13 - '@vue/shared': 3.5.13 - - '@vue/reactivity@3.5.13': - dependencies: - '@vue/shared': 3.5.13 - - '@vue/runtime-core@3.5.13': - dependencies: - '@vue/reactivity': 3.5.13 - '@vue/shared': 3.5.13 - - '@vue/runtime-dom@3.5.13': - dependencies: - '@vue/reactivity': 3.5.13 - '@vue/runtime-core': 3.5.13 - '@vue/shared': 3.5.13 - csstype: 3.2.3 - - '@vue/server-renderer@3.5.13(vue@3.5.13(typescript@5.9.3))': - dependencies: - '@vue/compiler-ssr': 3.5.13 - '@vue/shared': 3.5.13 - vue: 3.5.13(typescript@5.9.3) - - '@vue/shared@3.5.13': {} - '@vue/test-utils@2.4.6': dependencies: js-beautify: 1.15.4 vue-component-type-helpers: 2.2.8 - '@vueuse/core@13.9.0(vue@3.5.13(typescript@5.9.3))': - dependencies: - '@types/web-bluetooth': 0.0.21 - '@vueuse/metadata': 13.9.0 - '@vueuse/shared': 13.9.0(vue@3.5.13(typescript@5.9.3)) - vue: 3.5.13(typescript@5.9.3) - - '@vueuse/metadata@13.9.0': {} - - '@vueuse/shared@13.9.0(vue@3.5.13(typescript@5.9.3))': - dependencies: - vue: 3.5.13(typescript@5.9.3) - abbrev@2.0.0: {} + acorn@8.15.0: {} + agent-base@7.1.4: optional: true @@ -1517,6 +1776,8 @@ snapshots: ansi-styles@6.2.3: {} + any-promise@1.3.0: {} + assertion-error@2.0.1: {} ast-v8-to-istanbul@0.3.8: @@ -1534,6 +1795,13 @@ snapshots: dependencies: balanced-match: 1.0.2 + bundle-require@5.1.0(esbuild@0.27.1): + dependencies: + esbuild: 0.27.1 + load-tsconfig: 0.2.5 + + cac@6.7.14: {} + call-bind-apply-helpers@1.0.2: dependencies: es-errors: 1.3.0 @@ -1542,6 +1810,10 @@ snapshots: chai@6.2.1: {} + chokidar@4.0.3: + dependencies: + readdirp: 4.1.2 + color-convert@2.0.1: dependencies: color-name: 1.1.4 @@ -1555,11 +1827,17 @@ snapshots: commander@10.0.1: {} + commander@4.1.1: {} + + confbox@0.1.8: {} + config-chain@1.1.13: dependencies: ini: 1.3.8 proto-list: 1.2.4 + consola@3.4.2: {} + cross-spawn@7.0.6: dependencies: path-key: 3.1.1 @@ -1574,8 +1852,6 @@ snapshots: rrweb-cssom: 0.8.0 optional: true - csstype@3.2.3: {} - data-urls@5.0.0: dependencies: whatwg-mimetype: 4.0.0 @@ -1612,8 +1888,6 @@ snapshots: emoji-regex@9.2.2: {} - entities@4.5.0: {} - entities@6.0.1: optional: true @@ -1667,7 +1941,34 @@ snapshots: '@esbuild/win32-ia32': 0.25.12 '@esbuild/win32-x64': 0.25.12 - estree-walker@2.0.2: {} + esbuild@0.27.1: + optionalDependencies: + '@esbuild/aix-ppc64': 0.27.1 + '@esbuild/android-arm': 0.27.1 + '@esbuild/android-arm64': 0.27.1 + '@esbuild/android-x64': 0.27.1 + '@esbuild/darwin-arm64': 0.27.1 + '@esbuild/darwin-x64': 0.27.1 + '@esbuild/freebsd-arm64': 0.27.1 + '@esbuild/freebsd-x64': 0.27.1 + '@esbuild/linux-arm': 0.27.1 + '@esbuild/linux-arm64': 0.27.1 + '@esbuild/linux-ia32': 0.27.1 + '@esbuild/linux-loong64': 0.27.1 + '@esbuild/linux-mips64el': 0.27.1 + '@esbuild/linux-ppc64': 0.27.1 + '@esbuild/linux-riscv64': 0.27.1 + '@esbuild/linux-s390x': 0.27.1 + '@esbuild/linux-x64': 0.27.1 + '@esbuild/netbsd-arm64': 0.27.1 + '@esbuild/netbsd-x64': 0.27.1 + '@esbuild/openbsd-arm64': 0.27.1 + '@esbuild/openbsd-x64': 0.27.1 + '@esbuild/openharmony-arm64': 0.27.1 + '@esbuild/sunos-x64': 0.27.1 + '@esbuild/win32-arm64': 0.27.1 + '@esbuild/win32-ia32': 0.27.1 + '@esbuild/win32-x64': 0.27.1 estree-walker@3.0.3: dependencies: @@ -1679,6 +1980,12 @@ snapshots: optionalDependencies: picomatch: 4.0.3 + fix-dts-default-cjs-exports@1.0.1: + dependencies: + magic-string: 0.30.21 + mlly: 1.8.0 + rollup: 4.53.2 + foreground-child@3.3.1: dependencies: cross-spawn: 7.0.6 @@ -1816,6 +2123,8 @@ snapshots: optionalDependencies: '@pkgjs/parseargs': 0.11.0 + joycon@3.1.1: {} + js-beautify@1.15.4: dependencies: config-chain: 1.1.13 @@ -1857,6 +2166,12 @@ snapshots: - utf-8-validate optional: true + lilconfig@3.1.3: {} + + lines-and-columns@1.2.4: {} + + load-tsconfig@0.2.5: {} + lru-cache@10.4.3: {} lru-cache@11.2.4: {} @@ -1900,8 +2215,21 @@ snapshots: minipass@7.1.2: {} + mlly@1.8.0: + dependencies: + acorn: 8.15.0 + pathe: 2.0.3 + pkg-types: 1.3.1 + ufo: 1.6.1 + ms@2.1.3: {} + mz@2.7.0: + dependencies: + any-promise: 1.3.0 + object-assign: 4.1.1 + thenify-all: 1.6.0 + nanoid@3.3.11: {} nopt@7.2.1: @@ -1911,6 +2239,8 @@ snapshots: nwsapi@2.2.23: optional: true + object-assign@4.1.1: {} + obug@2.1.1: {} package-json-from-dist@1.0.1: {} @@ -1938,6 +2268,20 @@ snapshots: picomatch@4.0.3: {} + pirates@4.0.7: {} + + pkg-types@1.3.1: + dependencies: + confbox: 0.1.8 + mlly: 1.8.0 + pathe: 2.0.3 + + postcss-load-config@6.0.1(postcss@8.5.6): + dependencies: + lilconfig: 3.1.3 + optionalDependencies: + postcss: 8.5.6 + postcss@8.5.6: dependencies: nanoid: 3.3.11 @@ -1949,6 +2293,10 @@ snapshots: punycode@2.3.1: optional: true + readdirp@4.1.2: {} + + resolve-from@5.0.0: {} + rimraf@6.1.2: dependencies: glob: 13.0.0 @@ -2009,6 +2357,8 @@ snapshots: source-map-js@1.2.1: {} + source-map@0.7.6: {} + stackback@0.0.2: {} std-env@3.10.0: {} @@ -2033,6 +2383,16 @@ snapshots: dependencies: ansi-regex: 6.2.2 + sucrase@3.35.1: + dependencies: + '@jridgewell/gen-mapping': 0.3.13 + commander: 4.1.1 + lines-and-columns: 1.2.4 + mz: 2.7.0 + pirates: 4.0.7 + tinyglobby: 0.2.15 + ts-interface-checker: 0.1.13 + supports-color@7.2.0: dependencies: has-flag: 4.0.0 @@ -2040,8 +2400,18 @@ snapshots: symbol-tree@3.2.4: optional: true + thenify-all@1.6.0: + dependencies: + thenify: 3.3.1 + + thenify@3.3.1: + dependencies: + any-promise: 1.3.0 + tinybench@2.9.0: {} + tinyexec@0.3.2: {} + tinyexec@1.0.2: {} tinyglobby@0.2.15: @@ -2069,8 +2439,42 @@ snapshots: punycode: 2.3.1 optional: true + tree-kill@1.2.2: {} + + ts-interface-checker@0.1.13: {} + + tsup@8.5.1(postcss@8.5.6)(typescript@5.9.3): + dependencies: + bundle-require: 5.1.0(esbuild@0.27.1) + cac: 6.7.14 + chokidar: 4.0.3 + consola: 3.4.2 + debug: 4.4.3 + esbuild: 0.27.1 + fix-dts-default-cjs-exports: 1.0.1 + joycon: 3.1.1 + picocolors: 1.1.1 + postcss-load-config: 6.0.1(postcss@8.5.6) + resolve-from: 5.0.0 + rollup: 4.53.2 + source-map: 0.7.6 + sucrase: 3.35.1 + tinyexec: 0.3.2 + tinyglobby: 0.2.15 + tree-kill: 1.2.2 + optionalDependencies: + postcss: 8.5.6 + typescript: 5.9.3 + transitivePeerDependencies: + - jiti + - supports-color + - tsx + - yaml + typescript@5.9.3: {} + ufo@1.6.1: {} + vite@7.2.2: dependencies: esbuild: 0.25.12 @@ -2121,16 +2525,6 @@ snapshots: vue-component-type-helpers@2.2.8: {} - vue@3.5.13(typescript@5.9.3): - dependencies: - '@vue/compiler-dom': 3.5.13 - '@vue/compiler-sfc': 3.5.13 - '@vue/runtime-dom': 3.5.13 - '@vue/server-renderer': 3.5.13(vue@3.5.13(typescript@5.9.3)) - '@vue/shared': 3.5.13 - optionalDependencies: - typescript: 5.9.3 - w3c-xmlserializer@5.0.0: dependencies: xml-name-validator: 5.0.0 diff --git a/src/__tests__/server.test.ts b/src/__tests__/server.test.ts new file mode 100644 index 0000000..c3be895 --- /dev/null +++ b/src/__tests__/server.test.ts @@ -0,0 +1,33 @@ +import { describe, it, expect } from 'vitest' +import { createServerCallback } from '../server' +import type { ExternalSignOut } from '../types' + +describe('createServerCallback (server entry)', () => { + const config = { + encryptionKey: 'test-key', + } + + it('should round-trip data via generateUrl and parse without using window', () => { + const { parse, generateUrl } = createServerCallback(config) + const testActions: ExternalSignOut[] = [{ type: 'signOut' }] + const targetUrl = 'http://test.com/c' + const sendType = 'forUpc' + const sender = 'http://sender.com' + + const generatedUrl = generateUrl(targetUrl, testActions, sendType, sender) + const url = new URL(generatedUrl) + + const encryptedData = url.hash.startsWith('#data=') + ? url.hash.slice('#data='.length) + : url.searchParams.get('data') || '' + + const decrypted = parse(encryptedData) + + expect(decrypted).toEqual({ + actions: testActions, + sender, + type: sendType, + }) + }) +}) + diff --git a/src/__tests__/useSharedCallback.test.ts b/src/__tests__/useSharedCallback.test.ts index 095fe14..1c49a8e 100644 --- a/src/__tests__/useSharedCallback.test.ts +++ b/src/__tests__/useSharedCallback.test.ts @@ -1,5 +1,4 @@ import { describe, it, expect, beforeEach, vi } from 'vitest' -import { createSharedComposable } from '@vueuse/core' import AES from 'crypto-js/aes.js' import Utf8 from 'crypto-js/enc-utf8.js' import type { ExternalSignOut } from '../types' @@ -27,7 +26,7 @@ describe('useCallback', () => { } // Re-import useCallback fresh for each test so configuration - // (including useHash) can vary per test despite createSharedComposable. + // (including useHash) can vary per test. vi.resetModules() const mod = await import('../index') useCallback = mod.useCallback @@ -49,7 +48,7 @@ describe('useCallback', () => { }) }) - it('should create a shared callback instance', () => { + it('should create a callback instance', () => { const callback = useCallback(mockConfig) expect(callback).toBeDefined() expect(typeof callback.send).toBe('function') @@ -57,27 +56,10 @@ describe('useCallback', () => { expect(typeof callback.watcher).toBe('function') }) - it('should maintain the same instance for the same config', () => { + it('should create a new instance per call', () => { const callback1 = useCallback(mockConfig) const callback2 = useCallback(mockConfig) - expect(callback1).toBe(callback2) - }) - - it('should maintain the same instance even with different configs due to createSharedComposable', () => { - const callback1 = useCallback({ encryptionKey: 'key1' }) - const callback2 = useCallback({ encryptionKey: 'key2' }) - expect(callback1).toBe(callback2) - }) - - it('should work with createSharedComposable', () => { - const useTestComposable = createSharedComposable(() => { - return useCallback(mockConfig) - }) - - const callback1 = useTestComposable() - const callback2 = useTestComposable() - - expect(callback1).toBe(callback2) + expect(callback1).not.toBe(callback2) }) describe('send function', () => { @@ -205,6 +187,30 @@ describe('useCallback', () => { const decryptedData = callback.parse(encryptedData) expect(decryptedData).toEqual(testData) }) + + it('should use window.location.href as default sender when sender is not provided', () => { + const callback = useCallback(mockConfig) + const testActions: ExternalSignOut[] = [{ type: 'signOut' }] + const testData = { + actions: testActions, + sender: 'http://test.com/Tools', // Should use window.location.href normalized + type: 'test' + } + + // Call send without providing sender parameter (undefined) + callback.send('http://test.com/Tools', testActions, 'newTab', 'test') + + // Get the URL from the spy call + const [[urlString]] = (window.open as any).mock.calls + const url = new URL(urlString) + + // Verify the decrypted data uses default sender + const encryptedData = url.hash.startsWith('#data=') + ? url.hash.slice('#data='.length) + : '' + const decryptedData = callback.parse(encryptedData) + expect(decryptedData).toEqual(testData) + }) }) describe('parse function', () => { @@ -330,6 +336,84 @@ describe('useCallback', () => { expect(result).toEqual(testData) }) + it('should handle hash without # prefix', () => { + const callback = useCallback(mockConfig) + const testActions: ExternalSignOut[] = [{ type: 'signOut' }] + const testData = { + actions: testActions, + sender: 'http://test.com/Tools', + type: 'test' + } + + const stringifiedData = JSON.stringify(testData) + const encryptedData = AES.encrypt(stringifiedData, mockConfig.encryptionKey).toString() + const uriEncodedData = encodeURI(encryptedData) + + // Mock URL constructor to return an object with hash that doesn't start with "#" + // This tests the branch where rawHash doesn't start with "#" + const OriginalURL = global.URL + global.URL = class MockURL { + searchParams: URLSearchParams + private _hash: string + constructor(url: string) { + this.searchParams = new URLSearchParams() + // Extract hash from URL string, but store it without "#" prefix + const hashMatch = url.match(/#(.+)$/) + this._hash = hashMatch ? hashMatch[1] : '' + } + get hash() { + // Return hash without "#" prefix to test the uncovered branch + return this._hash + } + toString() { + return `http://test.com/Tools${this._hash ? '#' + this._hash : ''}` + } + } as any + + try { + const baseUrlWithHash = `http://test.com/Tools#data=${uriEncodedData}` + const result = callback.watcher({ baseUrl: baseUrlWithHash }) + expect(result).toEqual(testData) + } finally { + global.URL = OriginalURL + } + }) + + it('should handle hash without # prefix and without data= prefix', () => { + const callback = useCallback(mockConfig) + + // Mock URL constructor to return an object with hash that doesn't start with "#" + // and doesn't start with "data=" to test the uncovered branch at line 133 + const OriginalURL = global.URL + global.URL = class MockURL { + searchParams: URLSearchParams + private _hash: string + constructor(url: string) { + this.searchParams = new URLSearchParams() + // Extract hash from URL string, but store it without "#" prefix + const hashMatch = url.match(/#(.+)$/) + this._hash = hashMatch ? hashMatch[1] : '' + } + get hash() { + // Return hash without "#" prefix and without "data=" prefix + return this._hash + } + toString() { + return `http://test.com/Tools${this._hash ? '#' + this._hash : ''}` + } + } as any + + try { + // URL with hash that doesn't start with "#" and doesn't start with "data=" + const baseUrlWithHash = `http://test.com/Tools#someOtherHash=value` + const result = callback.watcher({ baseUrl: baseUrlWithHash }) + // Should return undefined since there's no valid data + expect(result).toBeUndefined() + } finally { + global.URL = OriginalURL + } + }) + it('should use dataToParse when provided', () => { const callback = useCallback(mockConfig) const testActions: ExternalSignOut[] = [{ type: 'signOut' }] @@ -422,6 +506,55 @@ describe('useCallback', () => { const result = callback.watcher({ baseUrl: 'not-a-valid-url' }) expect(result).toBeUndefined() }) + + it('should handle URL with no hash (null/undefined hash)', () => { + const callback = useCallback(mockConfig) + const testActions: ExternalSignOut[] = [{ type: 'signOut' }] + const testData = { + actions: testActions, + sender: 'http://test.com/Tools', + type: 'test' + } + + // Create URL with data in search params but no hash + const stringifiedData = JSON.stringify(testData) + const encryptedData = AES.encrypt(stringifiedData, mockConfig.encryptionKey).toString() + + // Mock URL constructor to return an object with hash as null/undefined + const OriginalURL = global.URL + global.URL = class MockURL { + searchParams: URLSearchParams + constructor(url: string) { + this.searchParams = new URLSearchParams() + // Parse search params from URL string manually + const searchMatch = url.match(/\?([^#]*)/) + if (searchMatch) { + searchMatch[1].split('&').forEach(param => { + const [key, value] = param.split('=') + if (key) { + this.searchParams.set(key, decodeURIComponent(value || '')) + } + }) + } + } + get hash() { + // Return null to test the nullish coalescing on line 127 + return null as any + } + toString() { + const search = this.searchParams.toString() + return `http://test.com/Tools${search ? '?' + search : ''}` + } + } as any + + try { + const baseUrl = `http://test.com/Tools?data=${encodeURI(encryptedData)}` + const result = callback.watcher({ baseUrl }) + expect(result).toEqual(testData) + } finally { + global.URL = OriginalURL + } + }) }) describe('generateUrl function', () => { diff --git a/src/client.ts b/src/client.ts new file mode 100644 index 0000000..9ae4ef7 --- /dev/null +++ b/src/client.ts @@ -0,0 +1,225 @@ +import type { + CallbackConfig, + QueryPayloads, + SendPayloads, + WatcherOptions, + SignIn, + SignOut, + OemSignOut, + Troubleshoot, + Recover, + Replace, + TrialExtend, + TrialStart, + Purchase, + Redeem, + Renew, + Upgrade, + UpdateOs, + DowngradeOs, + Manage, + MyKeys, + LinkKey, + Activate, + AccountActionTypes, + AccountKeyActionTypes, + PurchaseActionTypes, + ServerActionTypes, + ServerState, + ServerData, + UserInfo, + ExternalSignIn, + ExternalSignOut, + ExternalKeyActions, + ExternalUpdateOsAction, + ServerPayload, + ServerTroubleshoot, + ExternalActions, + UpcActions, + ExternalPayload, + UpcPayload, +} from "./types.js"; +import { + appendEncryptedDataToUrl, + createEncryptedPayload, + parseEncryptedPayload, +} from "./core"; + +export const createCallback = (config: CallbackConfig) => { + const shouldUseHash = config.useHash !== false; + + const send = ( + url: string, + payload: SendPayloads, + redirectType?: "newTab" | "replace" | null, + sendType?: string, + sender?: string + ) => { + if (typeof window === "undefined") { + throw new Error("send() can only be called on the client side"); + } + + const defaultSender = + sender ?? window.location.href.replace("/Tools/Update", "/Tools"); + + const encryptedMessage = createEncryptedPayload( + payload, + defaultSender, + sendType, + config.encryptionKey + ); + + const destinationUrl = appendEncryptedDataToUrl( + url.replace("/Tools/Update", "/Tools"), + encryptedMessage, + shouldUseHash + ); + + if (redirectType === "newTab") { + window.open(destinationUrl, "_blank"); + return; + } + if (redirectType === "replace") { + window.location.replace(destinationUrl); + return; + } + window.location.href = destinationUrl; + }; + + const parse = ( + data: string, + options?: { isDataURIEncoded?: boolean } + ): QueryPayloads => { + return parseEncryptedPayload(data, config.encryptionKey, options); + }; + + const watcher = ( + options: WatcherOptions = {} + ): QueryPayloads | undefined => { + let urlToParse = ""; + + if (options?.baseUrl && !options.skipCurrentUrl) { + urlToParse = options.baseUrl; + } else if ( + typeof window !== "undefined" && + window.location && + !options.skipCurrentUrl + ) { + urlToParse = window.location.toString(); + } else if (!options?.dataToParse && !options?.baseUrl) { + return undefined; + } + + const uriDecodedEncryptedData = options?.dataToParse + ? decodeURI(options.dataToParse) + : (() => { + try { + const currentUrl = new URL(urlToParse); + + const searchParamData = + currentUrl.searchParams.get("data") ?? ""; + + let hashData = ""; + const rawHash = currentUrl.hash ?? ""; + if (rawHash) { + const hashWithoutHash = rawHash.startsWith("#") + ? rawHash.slice(1) + : rawHash; + + if (hashWithoutHash.startsWith("data=")) { + hashData = hashWithoutHash.slice("data=".length); + } + } + + const dataFromUrl = searchParamData || hashData; + return decodeURI(dataFromUrl); + } catch { + return ""; + } + })(); + + if (!uriDecodedEncryptedData) { + return undefined; + } + + return parse(uriDecodedEncryptedData); + }; + + const generateUrl = ( + url: string, + payload: SendPayloads, + sendType?: string, + sender?: string + ): string => { + const defaultSender = + sender ?? + (typeof window !== "undefined" + ? window.location.href.replace("/Tools/Update", "/Tools") + : ""); + + const encryptedMessage = createEncryptedPayload( + payload, + defaultSender, + sendType, + config.encryptionKey + ); + + return appendEncryptedDataToUrl(url, encryptedMessage, shouldUseHash); + }; + + return { + send, + parse, + watcher, + generateUrl, + }; +}; + +/** + * Backwards-compatible alias for older consumers. + * This no longer returns a shared singleton; it is a plain factory. + */ +export const useCallback = createCallback; + +// Re-export all types for convenience from the client entry. +export type { + CallbackConfig, + QueryPayloads, + SendPayloads, + WatcherOptions, + SignIn, + SignOut, + OemSignOut, + Troubleshoot, + Recover, + Replace, + TrialExtend, + TrialStart, + Purchase, + Redeem, + Renew, + Upgrade, + UpdateOs, + DowngradeOs, + Manage, + MyKeys, + LinkKey, + Activate, + AccountActionTypes, + AccountKeyActionTypes, + PurchaseActionTypes, + ServerActionTypes, + ServerState, + ServerData, + UserInfo, + ExternalSignIn, + ExternalSignOut, + ExternalKeyActions, + ExternalUpdateOsAction, + ServerPayload, + ServerTroubleshoot, + ExternalActions, + UpcActions, + ExternalPayload, + UpcPayload, +}; diff --git a/src/core.ts b/src/core.ts new file mode 100644 index 0000000..0c10fc3 --- /dev/null +++ b/src/core.ts @@ -0,0 +1,103 @@ +import AES from "crypto-js/aes.js"; +import Utf8 from "crypto-js/enc-utf8.js"; +import type { QueryPayloads, SendPayloads } from "./types"; + +/** + * Encrypts a string using AES encryption. + */ +export const encryptData = (data: string, encryptionKey: string): string => { + return AES.encrypt(data, encryptionKey).toString(); +}; + +/** + * Decrypts an encrypted string using AES decryption. + * Throws when decryption fails or results in invalid / empty UTF-8. + */ +export const decryptData = ( + encryptedData: string, + encryptionKey: string +): string => { + const decryptedMessage = AES.decrypt(encryptedData, encryptionKey); + + let decryptedString: string; + try { + decryptedString = decryptedMessage.toString(Utf8); + } catch { + throw new Error("Decryption failed. Invalid key or corrupt data."); + } + + if (!decryptedString) { + throw new Error("Decryption failed. Invalid key or corrupt data."); + } + + return decryptedString; +}; + +/** + * Stringifies a payload into the standard callback data format. + */ +export const stringifyPayload = ( + payload: SendPayloads, + sender: string, + sendType?: string +): string => { + return JSON.stringify({ + actions: [...payload], + sender, + type: sendType, + }); +}; + +/** + * Creates an encrypted data string from a payload. + */ +export const createEncryptedPayload = ( + payload: SendPayloads, + sender: string, + sendType: string | undefined, + encryptionKey: string +): string => { + const stringifiedData = stringifyPayload(payload, sender, sendType); + return encryptData(stringifiedData, encryptionKey); +}; + +/** + * Parses an encrypted callback payload string into its typed structure. + */ +export const parseEncryptedPayload = ( + encryptedData: string, + encryptionKey: string, + options?: { isDataURIEncoded?: boolean } +): QueryPayloads => { + const dataToParse: string = options?.isDataURIEncoded + ? decodeURI(encryptedData) + : encryptedData; + + const decryptedString = decryptData(dataToParse, encryptionKey); + + try { + const decryptedData: QueryPayloads = JSON.parse(decryptedString); + return decryptedData; + } catch { + throw new Error("Failed to parse decrypted data."); + } +}; + +/** + * Appends encrypted callback data to a URL, using either hash or query param. + */ +export const appendEncryptedDataToUrl = ( + url: string, + encryptedData: string, + useHash: boolean +): string => { + const destinationUrl = new URL(url); + + if (useHash) { + destinationUrl.hash = `data=${encodeURI(encryptedData)}`; + } else { + destinationUrl.searchParams.set("data", encodeURI(encryptedData)); + } + + return destinationUrl.toString(); +}; diff --git a/src/index.ts b/src/index.ts index 86eb808..5ec7692 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,291 +1 @@ -import AES from "crypto-js/aes.js"; -import Utf8 from "crypto-js/enc-utf8.js"; -import { createSharedComposable } from "@vueuse/core"; -import type { - CallbackConfig, - QueryPayloads, - SendPayloads, - WatcherOptions, - SignIn, - SignOut, - OemSignOut, - Troubleshoot, - Recover, - Replace, - TrialExtend, - TrialStart, - Purchase, - Redeem, - Renew, - Upgrade, - UpdateOs, - DowngradeOs, - Manage, - MyKeys, - LinkKey, - Activate, - AccountActionTypes, - AccountKeyActionTypes, - PurchaseActionTypes, - ServerActionTypes, - ServerState, - ServerData, - UserInfo, - ExternalSignIn, - ExternalSignOut, - ExternalKeyActions, - ExternalUpdateOsAction, - ServerPayload, - ServerTroubleshoot, - ExternalActions, - UpcActions, - ExternalPayload, - UpcPayload, -} from "./types.js"; - -/** - * Encrypts a string using AES encryption - */ -const encryptData = (data: string, encryptionKey: string): string => { - return AES.encrypt(data, encryptionKey).toString(); -}; - -/** - * Decrypts an encrypted string using AES decryption - */ -const decryptData = (encryptedData: string, encryptionKey: string): string => { - const decryptedMessage = AES.decrypt(encryptedData, encryptionKey); - - let decryptedString: string; - try { - decryptedString = decryptedMessage.toString(Utf8); - } catch (e) { - // Catch errors during UTF-8 conversion (likely due to bad decryption) - throw new Error('Decryption failed. Invalid key or corrupt data.'); - } - - // Check if decryption resulted in an empty string (another failure case) - if (!decryptedString) { - throw new Error('Decryption failed. Invalid key or corrupt data.'); - } - - return decryptedString; -}; - -/** - * Stringifies a payload into the standard callback data format - */ -const stringifyPayload = ( - payload: SendPayloads, - sender: string, - sendType?: string -): string => { - return JSON.stringify({ - actions: [...payload], - sender, - type: sendType, - }); -}; - -/** - * Creates an encrypted data string from a payload - */ -const createEncryptedPayload = ( - payload: SendPayloads, - sender: string, - sendType: string | undefined, - encryptionKey: string -): string => { - const stringifiedData = stringifyPayload(payload, sender, sendType); - return encryptData(stringifiedData, encryptionKey); -}; - -const _useCallback = (config: CallbackConfig) => { - const shouldUseHash = config.useHash !== false; - - const send = ( - url: string, - payload: SendPayloads, - redirectType?: "newTab" | "replace" | null, - sendType?: string, - sender?: string - ) => { - // send() requires browser APIs and is client-only - if (typeof window === "undefined") { - throw new Error("send() can only be called on the client side"); - } - - const defaultSender = sender ?? window.location.href.replace("/Tools/Update", "/Tools"); - const encryptedMessage = createEncryptedPayload( - payload, - defaultSender, - sendType, - config.encryptionKey - ); - - const destinationUrl = new URL(url.replace("/Tools/Update", "/Tools")); - if (shouldUseHash) { - destinationUrl.hash = `data=${encodeURI(encryptedMessage)}`; - } else { - destinationUrl.searchParams.set("data", encodeURI(encryptedMessage)); - } - - if (redirectType === "newTab") { - window.open(destinationUrl.toString(), "_blank"); - return; - } - if (redirectType === "replace") { - window.location.replace(destinationUrl.toString()); - return; - } - window.location.href = destinationUrl.toString(); - }; - - const parse = (data: string, options?: { isDataURIEncoded?: boolean }) => { - const dataToParse: string = options?.isDataURIEncoded - ? decodeURI(data) - : data; - - const decryptedString = decryptData(dataToParse, config.encryptionKey); - - try { - const decryptedData: QueryPayloads = JSON.parse(decryptedString); - return decryptedData; - } catch (e) { - // Catch potential JSON parse errors even if decryption seemed successful - throw new Error('Failed to parse decrypted data.'); - } - }; - - const watcher = (options: WatcherOptions = {}): QueryPayloads | undefined => { - let urlToParse: string = ""; - if (options?.baseUrl && !options.skipCurrentUrl) { - urlToParse = options.baseUrl; - } else if (typeof window !== "undefined" && window.location && !options.skipCurrentUrl) { - urlToParse = window.location.toString(); - } else if (!options?.dataToParse && !options?.baseUrl) { - // If no window and no explicit data/baseUrl provided, return undefined - return undefined; - } - - // If we have dataToParse, use it directly; otherwise parse from URL - const uriDecodedEncryptedData = options?.dataToParse - ? decodeURI(options.dataToParse) - : (() => { - try { - const currentUrl = new URL(urlToParse); - - // Prefer query param if present to maintain backward compatibility, - // but also support hash-based data for enhanced privacy. - const searchParamData = currentUrl.searchParams.get("data") ?? ""; - - let hashData = ""; - const rawHash = currentUrl.hash ?? ""; - if (rawHash) { - const hashWithoutHash = rawHash.startsWith("#") - ? rawHash.slice(1) - : rawHash; - - // Expect hash in the form `data=` for privacy mode. - if (hashWithoutHash.startsWith("data=")) { - hashData = hashWithoutHash.slice("data=".length); - } - } - - const dataFromUrl = searchParamData || hashData; - return decodeURI(dataFromUrl); - } catch { - return ""; - } - })(); - - if (!uriDecodedEncryptedData) { - return undefined; - } - - return parse(uriDecodedEncryptedData); - }; - - const generateUrl = ( - url: string, - payload: SendPayloads, - sendType?: string, - sender?: string - ): string => { - // generateUrl() works on both server and client - // If no sender provided and we're on client, use window.location; otherwise use empty string - const defaultSender = sender ?? ( - typeof window !== "undefined" - ? window.location.href.replace("/Tools/Update", "/Tools") - : "" - ); - - const encryptedMessage = createEncryptedPayload( - payload, - defaultSender, - sendType, - config.encryptionKey - ); - - const destinationUrl = new URL(url); - if (shouldUseHash) { - destinationUrl.hash = `data=${encodeURI(encryptedMessage)}`; - } else { - destinationUrl.searchParams.set("data", encodeURI(encryptedMessage)); - } - - return destinationUrl.toString(); - }; - - return { - send, - parse, - watcher, - generateUrl, - }; -}; - -export const useCallback = createSharedComposable(_useCallback); - -// Re-export all types -export type { - CallbackConfig, - QueryPayloads, - SendPayloads, - WatcherOptions, - SignIn, - SignOut, - OemSignOut, - Troubleshoot, - Recover, - Replace, - TrialExtend, - TrialStart, - Purchase, - Redeem, - Renew, - Upgrade, - UpdateOs, - DowngradeOs, - Manage, - MyKeys, - LinkKey, - Activate, - AccountActionTypes, - AccountKeyActionTypes, - PurchaseActionTypes, - ServerActionTypes, - ServerState, - ServerData, - UserInfo, - ExternalSignIn, - ExternalSignOut, - ExternalKeyActions, - ExternalUpdateOsAction, - ServerPayload, - ServerTroubleshoot, - ExternalActions, - UpcActions, - ExternalPayload, - UpcPayload, -}; +export * from "./client"; diff --git a/src/server.ts b/src/server.ts new file mode 100644 index 0000000..f0d2e5a --- /dev/null +++ b/src/server.ts @@ -0,0 +1,125 @@ +import type { + CallbackConfig, + QueryPayloads, + SendPayloads, + SignIn, + SignOut, + OemSignOut, + Troubleshoot, + Recover, + Replace, + TrialExtend, + TrialStart, + Purchase, + Redeem, + Renew, + Upgrade, + UpdateOs, + DowngradeOs, + Manage, + MyKeys, + LinkKey, + Activate, + AccountActionTypes, + AccountKeyActionTypes, + PurchaseActionTypes, + ServerActionTypes, + ServerState, + ServerData, + UserInfo, + ExternalSignIn, + ExternalSignOut, + ExternalKeyActions, + ExternalUpdateOsAction, + ServerPayload, + ServerTroubleshoot, + ExternalActions, + UpcActions, + ExternalPayload, + UpcPayload, +} from "./types.js"; +import { + appendEncryptedDataToUrl, + createEncryptedPayload, + parseEncryptedPayload, +} from "./core.js"; + +/** + * Server-safe factory that exposes only parse and generateUrl. + * + * Uses only AES/UTF-8 helpers and never touches browser globals, making this + * entrypoint safe to import in server/worker (e.g. Cloudflare Workers) code. + */ +export const createServerCallback = (config: CallbackConfig) => { + const parse = ( + data: string, + options?: { isDataURIEncoded?: boolean } + ): QueryPayloads => { + return parseEncryptedPayload(data, config.encryptionKey, options); + }; + + const generateUrl = ( + url: string, + payload: SendPayloads, + sendType?: string, + sender?: string + ): string => { + const effectiveSender = sender ?? ""; + const encryptedMessage = createEncryptedPayload( + payload, + effectiveSender, + sendType, + config.encryptionKey + ); + + const shouldUseHash = config.useHash !== false; + return appendEncryptedDataToUrl(url, encryptedMessage, shouldUseHash); + }; + + return { + parse, + generateUrl, + }; +}; + +// Re-export all types for convenience from the server entry. +export type { + CallbackConfig, + QueryPayloads, + SendPayloads, + SignIn, + SignOut, + OemSignOut, + Troubleshoot, + Recover, + Replace, + TrialExtend, + TrialStart, + Purchase, + Redeem, + Renew, + Upgrade, + UpdateOs, + DowngradeOs, + Manage, + MyKeys, + LinkKey, + Activate, + AccountActionTypes, + AccountKeyActionTypes, + PurchaseActionTypes, + ServerActionTypes, + ServerState, + ServerData, + UserInfo, + ExternalSignIn, + ExternalSignOut, + ExternalKeyActions, + ExternalUpdateOsAction, + ServerPayload, + ServerTroubleshoot, + ExternalActions, + UpcActions, + ExternalPayload, + UpcPayload, +}; diff --git a/tsup.config.ts b/tsup.config.ts new file mode 100644 index 0000000..0a367d1 --- /dev/null +++ b/tsup.config.ts @@ -0,0 +1,18 @@ +import { defineConfig } from "tsup"; + +export default defineConfig({ + entry: { + index: "src/index.ts", + client: "src/client.ts", + server: "src/server.ts", + }, + format: ["esm"], + target: "es2020", + platform: "neutral", + splitting: false, + sourcemap: false, + clean: false, + dts: false, + treeshake: true, + noExternal: ["crypto-js"], +});