@salespark/toolkit 2.1.14 → 2.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -692,6 +692,25 @@ declare const isNilTextOrEmpty: (value: unknown) => boolean;
692
692
  * 25-09-2025: Created
693
693
  ****************************************************/
694
694
  declare const formatCurrency: (value: number | string | null | undefined, withoutCurrencySymbol?: boolean, currency?: string, locale?: string) => string;
695
+ /******************************************************
696
+ * ##: Modern Currency Formatter (Options)
697
+ * Formats currency values using modern Intl.NumberFormat API with a single options object.
698
+ *
699
+ * Same behavior as `formatCurrency`, with optional redact masking.
700
+ * @param {number|string|null|undefined} value Currency value to format
701
+ * @param {FormatCurrencyProOptions} [options] Formatting options
702
+ * @returns {string} Formatted currency string (e.g., "1.234,56 €" or "1.234,56")
703
+ * History:
704
+ * 28-01-2026: Created
705
+ ****************************************************/
706
+ type FormatCurrencyProOptions = {
707
+ withoutCurrencySymbol?: boolean;
708
+ currency?: string;
709
+ locale?: string;
710
+ redact?: boolean;
711
+ redactChar?: string;
712
+ };
713
+ declare const formatCurrencyPro: (value: number | string | null | undefined, options?: FormatCurrencyProOptions) => string;
695
714
  /******************************************************
696
715
  * ##: Parse Name into First and Last Components
697
716
  * Extracts first and last name from a full name string.
@@ -830,6 +849,68 @@ declare const assessSecurityRisks: (risks: SecurityRisk[]) => {
830
849
  recommendations: string[];
831
850
  };
832
851
 
852
+ /******************************************************************
853
+ * ##: Scramble helpers (obfuscation, not crypto)
854
+ * Lightweight XOR scrambling for strings and JSON-serializable objects.
855
+ * Notes: This is reversible obfuscation and NOT cryptographic security.
856
+ ******************************************************************/
857
+ /******************************************************************
858
+ * ##: Scramble a string by XOR-ing each character with a repeating secret key
859
+ * Applies an XOR operation between each character code and a repeating key character code.
860
+ * The XOR result is then Base64-encoded for transport as a printable string.
861
+ *
862
+ * TL;DR: Obfuscate a string by XOR-ing it with a repeating secret and Base64-encoding the result.
863
+ * Use only for reversible scrambling, not cryptographic protection.
864
+ * @param {string} value - Plain string to scramble (typically a Base64-encoded JSON payload).
865
+ * @param {string} secret - Secret key used as the repeating XOR mask.
866
+ * @returns {string} - Base64-encoded scrambled output.
867
+ * History:
868
+ * 28-01-2026: Created
869
+ ******************************************************************/
870
+ declare const scrambleString: (value: string, secret: string) => string;
871
+ /******************************************************************
872
+ * ##: Descramble a Base64 string by reversing XOR with a repeating secret key
873
+ * Base64-decodes the scrambled input to a binary string, then XORs each character with the key.
874
+ * This reverses the scramble operation as long as the same secret key is used.
875
+ *
876
+ * TL;DR: Reverse the XOR-based scrambling using the same secret key.
877
+ * It Base64-decodes, then XORs again to recover the original string.
878
+ * @param {string} value - Base64-encoded scrambled input produced by the scrambler.
879
+ * @param {string} secret - Secret key used as the repeating XOR mask (must match the encoding key).
880
+ * @returns {string} - The original unscrambled string (typically a Base64 JSON payload).
881
+ * History:
882
+ * 28-01-2026: Created
883
+ ******************************************************************/
884
+ declare const descrambleString: (value: string, secret: string) => string;
885
+ /******************************************************************
886
+ * ##: Encode object into scrambled Base64 string using a secret key
887
+ * Serializes an input object to JSON, Base64-encodes it, and scrambles the result using a secret key.
888
+ * This is intended for lightweight obfuscation of JSON payloads, not for cryptographic security.
889
+ *
890
+ * TL;DR: Turn an object into a scrambled string so it can be stored/transmitted less visibly.
891
+ * It JSON-stringifies, Base64-encodes, then scrambles the payload with a secret key.
892
+ * @param {object} input - Any JSON-serializable object to encode (arrays are also accepted as objects).
893
+ * @param {string} secret - Secret key used to scramble the Base64 payload (must be a non-empty string).
894
+ * @returns {string} - Scrambled Base64 string representing the encoded object.
895
+ * History:
896
+ * 28-01-2026: Created
897
+ ******************************************************************/
898
+ declare const encodeObject: (input: object, secret: string) => string;
899
+ /******************************************************************
900
+ * ##: Decode scrambled string back into an object using a secret key
901
+ * Descrambles an encoded string with the provided secret, Base64-decodes it, and parses it as JSON.
902
+ * This reverses the encode flow and returns the original JSON-compatible value if inputs are valid.
903
+ *
904
+ * TL;DR: Convert a scrambled string back into the original object using the same secret key.
905
+ * It descrambles, Base64-decodes, then JSON-parses the payload.
906
+ * @param {string} encoded - Scrambled Base64 string produced by the encoder/scrambler.
907
+ * @param {string} secret - Secret key used to descramble the payload (must match the encoding key).
908
+ * @returns {object} - Decoded value parsed from JSON (shape depends on the original input and may vary).
909
+ * History:
910
+ * 28-01-2026: Created
911
+ ******************************************************************/
912
+ declare const decodeObject: (encoded: string, secret: string) => object;
913
+
833
914
  type DeferFn = () => void | Promise<void>;
834
915
  /******************************************************************
835
916
  * ##: Defer work to run right after return using a microtask
@@ -895,4 +976,4 @@ declare const deferAfterResponseNonCritical: (res: HttpResponseLike, fn: DeferFn
895
976
  declare const isBrowser: boolean;
896
977
  declare const isNode: boolean;
897
978
 
898
- export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatDecimalNumber, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
979
+ export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type FormatCurrencyProOptions, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, decodeObject, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, descrambleString, difference, encodeObject, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, scrambleString, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
package/dist/index.d.ts CHANGED
@@ -692,6 +692,25 @@ declare const isNilTextOrEmpty: (value: unknown) => boolean;
692
692
  * 25-09-2025: Created
693
693
  ****************************************************/
694
694
  declare const formatCurrency: (value: number | string | null | undefined, withoutCurrencySymbol?: boolean, currency?: string, locale?: string) => string;
695
+ /******************************************************
696
+ * ##: Modern Currency Formatter (Options)
697
+ * Formats currency values using modern Intl.NumberFormat API with a single options object.
698
+ *
699
+ * Same behavior as `formatCurrency`, with optional redact masking.
700
+ * @param {number|string|null|undefined} value Currency value to format
701
+ * @param {FormatCurrencyProOptions} [options] Formatting options
702
+ * @returns {string} Formatted currency string (e.g., "1.234,56 €" or "1.234,56")
703
+ * History:
704
+ * 28-01-2026: Created
705
+ ****************************************************/
706
+ type FormatCurrencyProOptions = {
707
+ withoutCurrencySymbol?: boolean;
708
+ currency?: string;
709
+ locale?: string;
710
+ redact?: boolean;
711
+ redactChar?: string;
712
+ };
713
+ declare const formatCurrencyPro: (value: number | string | null | undefined, options?: FormatCurrencyProOptions) => string;
695
714
  /******************************************************
696
715
  * ##: Parse Name into First and Last Components
697
716
  * Extracts first and last name from a full name string.
@@ -830,6 +849,68 @@ declare const assessSecurityRisks: (risks: SecurityRisk[]) => {
830
849
  recommendations: string[];
831
850
  };
832
851
 
852
+ /******************************************************************
853
+ * ##: Scramble helpers (obfuscation, not crypto)
854
+ * Lightweight XOR scrambling for strings and JSON-serializable objects.
855
+ * Notes: This is reversible obfuscation and NOT cryptographic security.
856
+ ******************************************************************/
857
+ /******************************************************************
858
+ * ##: Scramble a string by XOR-ing each character with a repeating secret key
859
+ * Applies an XOR operation between each character code and a repeating key character code.
860
+ * The XOR result is then Base64-encoded for transport as a printable string.
861
+ *
862
+ * TL;DR: Obfuscate a string by XOR-ing it with a repeating secret and Base64-encoding the result.
863
+ * Use only for reversible scrambling, not cryptographic protection.
864
+ * @param {string} value - Plain string to scramble (typically a Base64-encoded JSON payload).
865
+ * @param {string} secret - Secret key used as the repeating XOR mask.
866
+ * @returns {string} - Base64-encoded scrambled output.
867
+ * History:
868
+ * 28-01-2026: Created
869
+ ******************************************************************/
870
+ declare const scrambleString: (value: string, secret: string) => string;
871
+ /******************************************************************
872
+ * ##: Descramble a Base64 string by reversing XOR with a repeating secret key
873
+ * Base64-decodes the scrambled input to a binary string, then XORs each character with the key.
874
+ * This reverses the scramble operation as long as the same secret key is used.
875
+ *
876
+ * TL;DR: Reverse the XOR-based scrambling using the same secret key.
877
+ * It Base64-decodes, then XORs again to recover the original string.
878
+ * @param {string} value - Base64-encoded scrambled input produced by the scrambler.
879
+ * @param {string} secret - Secret key used as the repeating XOR mask (must match the encoding key).
880
+ * @returns {string} - The original unscrambled string (typically a Base64 JSON payload).
881
+ * History:
882
+ * 28-01-2026: Created
883
+ ******************************************************************/
884
+ declare const descrambleString: (value: string, secret: string) => string;
885
+ /******************************************************************
886
+ * ##: Encode object into scrambled Base64 string using a secret key
887
+ * Serializes an input object to JSON, Base64-encodes it, and scrambles the result using a secret key.
888
+ * This is intended for lightweight obfuscation of JSON payloads, not for cryptographic security.
889
+ *
890
+ * TL;DR: Turn an object into a scrambled string so it can be stored/transmitted less visibly.
891
+ * It JSON-stringifies, Base64-encodes, then scrambles the payload with a secret key.
892
+ * @param {object} input - Any JSON-serializable object to encode (arrays are also accepted as objects).
893
+ * @param {string} secret - Secret key used to scramble the Base64 payload (must be a non-empty string).
894
+ * @returns {string} - Scrambled Base64 string representing the encoded object.
895
+ * History:
896
+ * 28-01-2026: Created
897
+ ******************************************************************/
898
+ declare const encodeObject: (input: object, secret: string) => string;
899
+ /******************************************************************
900
+ * ##: Decode scrambled string back into an object using a secret key
901
+ * Descrambles an encoded string with the provided secret, Base64-decodes it, and parses it as JSON.
902
+ * This reverses the encode flow and returns the original JSON-compatible value if inputs are valid.
903
+ *
904
+ * TL;DR: Convert a scrambled string back into the original object using the same secret key.
905
+ * It descrambles, Base64-decodes, then JSON-parses the payload.
906
+ * @param {string} encoded - Scrambled Base64 string produced by the encoder/scrambler.
907
+ * @param {string} secret - Secret key used to descramble the payload (must match the encoding key).
908
+ * @returns {object} - Decoded value parsed from JSON (shape depends on the original input and may vary).
909
+ * History:
910
+ * 28-01-2026: Created
911
+ ******************************************************************/
912
+ declare const decodeObject: (encoded: string, secret: string) => object;
913
+
833
914
  type DeferFn = () => void | Promise<void>;
834
915
  /******************************************************************
835
916
  * ##: Defer work to run right after return using a microtask
@@ -895,4 +976,4 @@ declare const deferAfterResponseNonCritical: (res: HttpResponseLike, fn: DeferFn
895
976
  declare const isBrowser: boolean;
896
977
  declare const isNode: boolean;
897
978
 
898
- export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatDecimalNumber, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
979
+ export { type CapitalizeFirstOptions, type CapitalizeWordsOptions, type DeferFn, type FormatCurrencyProOptions, type HttpResponseLike, type SecurityCheckResult, type SecurityRisk, type SentenceCaseOptions, addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, decodeObject, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, descrambleString, difference, encodeObject, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, scrambleString, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
package/dist/index.js CHANGED
@@ -564,7 +564,7 @@ var formatBytes = (bytes, si = false, dp = 1, noSpace = false) => {
564
564
  value /= thresh;
565
565
  ++u;
566
566
  } while (Math.round(Math.abs(value) * r) / r >= thresh && u < units.length - 1);
567
- return `${value.toFixed(dp)}${noSpace ? "" : " "}${units[u]}`;
567
+ return `${value.toFixed(dp)}${noSpace === true ? "" : " "}${units[u]}`;
568
568
  };
569
569
  var humanFileSize = formatBytes;
570
570
  var levenshtein = (a, b) => {
@@ -656,6 +656,35 @@ var formatCurrency = (value, withoutCurrencySymbol = false, currency = "EUR", lo
656
656
  return withoutCurrencySymbol ? formatted : `${formatted} \u20AC`;
657
657
  }
658
658
  };
659
+ var formatCurrencyPro = (value, options = {}) => {
660
+ const resolvedWithoutSymbol = options.withoutCurrencySymbol === true;
661
+ const resolvedCurrency = options.currency ?? "EUR";
662
+ const resolvedLocale = options.locale ?? "pt-PT";
663
+ const redact = options.redact === true;
664
+ const redactChar = options.redactChar ? options.redactChar : "*";
665
+ try {
666
+ const numValue = value === void 0 || value === null || value === "" ? 0 : Number(value);
667
+ if (isNaN(numValue) || !isFinite(numValue)) {
668
+ const fallback = resolvedWithoutSymbol ? "0,00" : "0,00 \u20AC";
669
+ return redact ? fallback.replace(/\d/g, redactChar) : fallback;
670
+ }
671
+ const intlOptions = {
672
+ style: resolvedWithoutSymbol ? "decimal" : "currency",
673
+ currency: resolvedCurrency,
674
+ minimumFractionDigits: 2,
675
+ maximumFractionDigits: 2
676
+ };
677
+ const formatted = new Intl.NumberFormat(resolvedLocale, intlOptions).format(
678
+ numValue
679
+ );
680
+ return redact ? formatted.replace(/\d/g, redactChar) : formatted;
681
+ } catch (error) {
682
+ const numValue = Number(value) || 0;
683
+ const formatted = numValue.toFixed(2).replace(".", ",");
684
+ const fallback = resolvedWithoutSymbol ? formatted : `${formatted} \u20AC`;
685
+ return redact ? fallback.replace(/\d/g, redactChar) : fallback;
686
+ }
687
+ };
659
688
  var parseName = (name) => {
660
689
  try {
661
690
  if (name === void 0 || name === null || name === "") {
@@ -1743,6 +1772,109 @@ var assessSecurityRisks = (risks) => {
1743
1772
  return { score, level, recommendations };
1744
1773
  };
1745
1774
 
1775
+ // src/utils/scramble.ts
1776
+ var hasBuffer = typeof Buffer !== "undefined" && typeof Buffer.from === "function";
1777
+ var base64EncodeBinary = (binary) => {
1778
+ if (hasBuffer) {
1779
+ return Buffer.from(binary, "binary").toString("base64");
1780
+ }
1781
+ if (typeof btoa === "function") {
1782
+ return btoa(binary);
1783
+ }
1784
+ throw new Error("Base64 encoder not available");
1785
+ };
1786
+ var base64DecodeToBinary = (base64) => {
1787
+ if (hasBuffer) {
1788
+ return Buffer.from(base64, "base64").toString("binary");
1789
+ }
1790
+ if (typeof atob === "function") {
1791
+ return atob(base64);
1792
+ }
1793
+ throw new Error("Base64 decoder not available");
1794
+ };
1795
+ var utf8ToBinary = (value) => {
1796
+ if (hasBuffer) {
1797
+ return Buffer.from(value, "utf8").toString("binary");
1798
+ }
1799
+ if (typeof TextEncoder !== "undefined") {
1800
+ const bytes = new TextEncoder().encode(value);
1801
+ let binary = "";
1802
+ for (const b of bytes) {
1803
+ binary += String.fromCharCode(b);
1804
+ }
1805
+ return binary;
1806
+ }
1807
+ return value;
1808
+ };
1809
+ var binaryToUtf8 = (binary) => {
1810
+ if (hasBuffer) {
1811
+ return Buffer.from(binary, "binary").toString("utf8");
1812
+ }
1813
+ if (typeof TextDecoder !== "undefined") {
1814
+ const bytes = new Uint8Array(binary.length);
1815
+ for (let i = 0; i < binary.length; i++) {
1816
+ bytes[i] = binary.charCodeAt(i) & 255;
1817
+ }
1818
+ return new TextDecoder().decode(bytes);
1819
+ }
1820
+ return binary;
1821
+ };
1822
+ var toBase64 = (value) => base64EncodeBinary(utf8ToBinary(value));
1823
+ var fromBase64 = (value) => binaryToUtf8(base64DecodeToBinary(value));
1824
+ var scrambleString = (value, secret) => {
1825
+ if (typeof value !== "string") {
1826
+ throw new TypeError("Value must be a string");
1827
+ }
1828
+ if (!secret || typeof secret !== "string") {
1829
+ throw new TypeError("Secret must be a non-empty string");
1830
+ }
1831
+ let result = "";
1832
+ for (let i = 0; i < value.length; i++) {
1833
+ const charCode = value.charCodeAt(i) & 255;
1834
+ const keyCode = secret.charCodeAt(i % secret.length) & 255;
1835
+ result += String.fromCharCode(charCode ^ keyCode);
1836
+ }
1837
+ return base64EncodeBinary(result);
1838
+ };
1839
+ var descrambleString = (value, secret) => {
1840
+ if (typeof value !== "string") {
1841
+ throw new TypeError("Value must be a string");
1842
+ }
1843
+ if (!secret || typeof secret !== "string") {
1844
+ throw new TypeError("Secret must be a non-empty string");
1845
+ }
1846
+ const decoded = base64DecodeToBinary(value);
1847
+ let result = "";
1848
+ for (let i = 0; i < decoded.length; i++) {
1849
+ const charCode = decoded.charCodeAt(i) & 255;
1850
+ const keyCode = secret.charCodeAt(i % secret.length) & 255;
1851
+ result += String.fromCharCode(charCode ^ keyCode);
1852
+ }
1853
+ return result;
1854
+ };
1855
+ var encodeObject = (input, secret) => {
1856
+ if (!input || typeof input !== "object") {
1857
+ throw new TypeError("Input must be an object");
1858
+ }
1859
+ if (!secret || typeof secret !== "string") {
1860
+ throw new TypeError("Secret must be a non-empty string");
1861
+ }
1862
+ const jsonString = JSON.stringify(input);
1863
+ const base64 = toBase64(jsonString);
1864
+ return scrambleString(base64, secret);
1865
+ };
1866
+ var decodeObject = (encoded, secret) => {
1867
+ if (typeof encoded !== "string") {
1868
+ throw new TypeError("Encoded value must be a string");
1869
+ }
1870
+ if (!secret || typeof secret !== "string") {
1871
+ throw new TypeError("Secret must be a non-empty string");
1872
+ }
1873
+ const descrambled = descrambleString(encoded, secret);
1874
+ const jsonString = fromBase64(descrambled);
1875
+ return JSON.parse(jsonString);
1876
+ };
1877
+
1746
1878
  // src/utils/defer.ts
1747
1879
  var swallow = (p) => p.catch(() => {
1748
1880
  });
@@ -1831,6 +1963,6 @@ var deferAfterResponseNonCritical = (res, fn) => {
1831
1963
  var isBrowser = typeof globalThis !== "undefined" && typeof globalThis.document !== "undefined";
1832
1964
  var isNode = typeof process !== "undefined" && !!process.versions?.node;
1833
1965
 
1834
- export { addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, difference, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatDecimalNumber, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
1966
+ export { addSpaceBetweenNumbers, addThousandsSpace, areArraysDeepEqualUnordered, areArraysEqual, assessSecurityRisks, basicSanitize, capitalizeFirst, capitalizeWords, checkMarkdownSecurity, chunk, clamp, cleanObject, compact, currencyToSymbol, debounce, deburr, decodeObject, deferAfterResponse, deferAfterResponseNonCritical, deferNonCritical, deferPostReturn, delay, descrambleString, difference, encodeObject, fill, flatten, flattenDepth, flattenDepthBase, flattenOnce, formatBytes, formatCurrency, formatCurrencyPro, formatDecimalNumber, getStringSimilarity, groupBy, hasNilOrEmpty, humanFileSize, intersection, isBrowser, isFlattenable, isNil, isNilEmptyOrZeroLen, isNilEmptyOrZeroLength, isNilOrEmpty, isNilOrNaN, isNilOrZeroLen, isNilOrZeroLength, isNilText, isNilTextOrEmpty, isNode, isNullOrUndefined, isNullOrUndefinedEmptyOrZero, isNullOrUndefinedInArray, isNullOrUndefinedOrNaN, isNullOrUndefinedTextInc, isNullUndefinedOrEmpty, isNullUndefinedOrEmptyEnforced, isNullUndefinedOrZero, isPTTaxId, isValidIBAN, isValidPTTaxId, numbersEqual, objectToString, omit, otp, parseName, parseToBool, parseToNumber, pick, pluck, pushAll, randomDigits, removeDiacritics, round, safeAdd, safeDivide, safeJSONParse, safeMultiply, safeParseFloat, safeParseInt, safeSubtract, sanitize, sanitizeMarkdown, scrambleString, sentenceCase, shuffle, slugify, sortBy, stringSimilarity, symbolToCurrency, throttle, toBool, toInteger, toNumber, uniq, uniqBy };
1835
1967
  //# sourceMappingURL=index.js.map
1836
1968
  //# sourceMappingURL=index.js.map