@tern-secure/shared 1.3.0-canary.v20250916132854 → 1.3.0-canary.v20250919131424

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.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Convert words to a sentence.
3
+ *
4
+ * @param items - An array of words to be joined.
5
+ * @returns A string with the items joined by a comma and the last item joined by ", or".
6
+ */
7
+ declare const toSentence: (items: string[]) => string;
8
+ /**
9
+ * Checks if a string is a valid IPv4 address.
10
+ *
11
+ * @returns True if the string is a valid IPv4 address, false otherwise.
12
+ */
13
+ declare function isIPV4Address(str: string | undefined | null): boolean;
14
+ /**
15
+ * Converts the first character of a string to uppercase.
16
+ *
17
+ * @param str - The string to be converted.
18
+ * @returns The modified string with the rest of the string unchanged.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * titleize('hello world') // 'Hello world'
23
+ * ```
24
+ */
25
+ declare function titleize(str: string | undefined | null): string;
26
+ /**
27
+ * Converts a string from snake_case to camelCase.
28
+ */
29
+ declare function snakeToCamel(str: string | undefined): string;
30
+ /**
31
+ * Converts a string from camelCase to snake_case.
32
+ */
33
+ declare function camelToSnake(str: string | undefined): string;
34
+ /**
35
+ * Transforms camelCased objects/ arrays to snake_cased.
36
+ * This function recursively traverses all objects and arrays of the passed value
37
+ * camelCased keys are removed.
38
+ *
39
+ * @function
40
+ */
41
+ declare const deepCamelToSnake: (obj: any) => any;
42
+ /**
43
+ * Transforms snake_cased objects/ arrays to camelCased.
44
+ * This function recursively traverses all objects and arrays of the passed value
45
+ * camelCased keys are removed.
46
+ *
47
+ * @function
48
+ */
49
+ declare const deepSnakeToCamel: (obj: any) => any;
50
+ /**
51
+ * A function to determine if a value is truthy.
52
+ *
53
+ * @returns True for `true`, true, positive numbers. False for `false`, false, 0, negative integers and anything else.
54
+ */
55
+ declare function isTruthy(value: unknown): boolean;
56
+ /**
57
+ * Get all non-undefined values from an object.
58
+ */
59
+ declare function getNonUndefinedValues<T extends object>(obj: T): Partial<T>;
60
+ declare function jitteredDelay(delay: number): number;
61
+
62
+ export { camelToSnake, deepCamelToSnake, deepSnakeToCamel, getNonUndefinedValues, isIPV4Address, isTruthy, jitteredDelay, snakeToCamel, titleize, toSentence };
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Convert words to a sentence.
3
+ *
4
+ * @param items - An array of words to be joined.
5
+ * @returns A string with the items joined by a comma and the last item joined by ", or".
6
+ */
7
+ declare const toSentence: (items: string[]) => string;
8
+ /**
9
+ * Checks if a string is a valid IPv4 address.
10
+ *
11
+ * @returns True if the string is a valid IPv4 address, false otherwise.
12
+ */
13
+ declare function isIPV4Address(str: string | undefined | null): boolean;
14
+ /**
15
+ * Converts the first character of a string to uppercase.
16
+ *
17
+ * @param str - The string to be converted.
18
+ * @returns The modified string with the rest of the string unchanged.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * titleize('hello world') // 'Hello world'
23
+ * ```
24
+ */
25
+ declare function titleize(str: string | undefined | null): string;
26
+ /**
27
+ * Converts a string from snake_case to camelCase.
28
+ */
29
+ declare function snakeToCamel(str: string | undefined): string;
30
+ /**
31
+ * Converts a string from camelCase to snake_case.
32
+ */
33
+ declare function camelToSnake(str: string | undefined): string;
34
+ /**
35
+ * Transforms camelCased objects/ arrays to snake_cased.
36
+ * This function recursively traverses all objects and arrays of the passed value
37
+ * camelCased keys are removed.
38
+ *
39
+ * @function
40
+ */
41
+ declare const deepCamelToSnake: (obj: any) => any;
42
+ /**
43
+ * Transforms snake_cased objects/ arrays to camelCased.
44
+ * This function recursively traverses all objects and arrays of the passed value
45
+ * camelCased keys are removed.
46
+ *
47
+ * @function
48
+ */
49
+ declare const deepSnakeToCamel: (obj: any) => any;
50
+ /**
51
+ * A function to determine if a value is truthy.
52
+ *
53
+ * @returns True for `true`, true, positive numbers. False for `false`, false, 0, negative integers and anything else.
54
+ */
55
+ declare function isTruthy(value: unknown): boolean;
56
+ /**
57
+ * Get all non-undefined values from an object.
58
+ */
59
+ declare function getNonUndefinedValues<T extends object>(obj: T): Partial<T>;
60
+ declare function jitteredDelay(delay: number): number;
61
+
62
+ export { camelToSnake, deepCamelToSnake, deepSnakeToCamel, getNonUndefinedValues, isIPV4Address, isTruthy, jitteredDelay, snakeToCamel, titleize, toSentence };
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/caseUtils.ts
21
+ var caseUtils_exports = {};
22
+ __export(caseUtils_exports, {
23
+ camelToSnake: () => camelToSnake,
24
+ deepCamelToSnake: () => deepCamelToSnake,
25
+ deepSnakeToCamel: () => deepSnakeToCamel,
26
+ getNonUndefinedValues: () => getNonUndefinedValues,
27
+ isIPV4Address: () => isIPV4Address,
28
+ isTruthy: () => isTruthy,
29
+ jitteredDelay: () => jitteredDelay,
30
+ snakeToCamel: () => snakeToCamel,
31
+ titleize: () => titleize,
32
+ toSentence: () => toSentence
33
+ });
34
+ module.exports = __toCommonJS(caseUtils_exports);
35
+ var toSentence = (items) => {
36
+ if (items.length == 0) {
37
+ return "";
38
+ }
39
+ if (items.length == 1) {
40
+ return items[0];
41
+ }
42
+ let sentence = items.slice(0, -1).join(", ");
43
+ sentence += `, or ${items.slice(-1)}`;
44
+ return sentence;
45
+ };
46
+ var IP_V4_ADDRESS_REGEX = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
47
+ function isIPV4Address(str) {
48
+ return IP_V4_ADDRESS_REGEX.test(str || "");
49
+ }
50
+ function titleize(str) {
51
+ const s = str || "";
52
+ return s.charAt(0).toUpperCase() + s.slice(1);
53
+ }
54
+ function snakeToCamel(str) {
55
+ return str ? str.replace(/([-_][a-z])/g, (match) => match.toUpperCase().replace(/-|_/, "")) : "";
56
+ }
57
+ function camelToSnake(str) {
58
+ return str ? str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`) : "";
59
+ }
60
+ var createDeepObjectTransformer = (transform) => {
61
+ const deepTransform = (obj) => {
62
+ if (!obj) {
63
+ return obj;
64
+ }
65
+ if (Array.isArray(obj)) {
66
+ return obj.map((el) => {
67
+ if (typeof el === "object" || Array.isArray(el)) {
68
+ return deepTransform(el);
69
+ }
70
+ return el;
71
+ });
72
+ }
73
+ const copy = { ...obj };
74
+ const keys = Object.keys(copy);
75
+ for (const oldName of keys) {
76
+ const newName = transform(oldName.toString());
77
+ if (newName !== oldName) {
78
+ copy[newName] = copy[oldName];
79
+ delete copy[oldName];
80
+ }
81
+ if (typeof copy[newName] === "object") {
82
+ copy[newName] = deepTransform(copy[newName]);
83
+ }
84
+ }
85
+ return copy;
86
+ };
87
+ return deepTransform;
88
+ };
89
+ var deepCamelToSnake = createDeepObjectTransformer(camelToSnake);
90
+ var deepSnakeToCamel = createDeepObjectTransformer(snakeToCamel);
91
+ function isTruthy(value) {
92
+ if (typeof value === `boolean`) {
93
+ return value;
94
+ }
95
+ if (value === void 0 || value === null) {
96
+ return false;
97
+ }
98
+ if (typeof value === `string`) {
99
+ if (value.toLowerCase() === `true`) {
100
+ return true;
101
+ }
102
+ if (value.toLowerCase() === `false`) {
103
+ return false;
104
+ }
105
+ }
106
+ const number = parseInt(value, 10);
107
+ if (isNaN(number)) {
108
+ return false;
109
+ }
110
+ if (number > 0) {
111
+ return true;
112
+ }
113
+ return false;
114
+ }
115
+ function getNonUndefinedValues(obj) {
116
+ return Object.entries(obj).reduce((acc, [key, value]) => {
117
+ if (value !== void 0) {
118
+ acc[key] = value;
119
+ }
120
+ return acc;
121
+ }, {});
122
+ }
123
+ function jitteredDelay(delay) {
124
+ return delay * Math.random();
125
+ }
126
+ // Annotate the CommonJS export names for ESM import in node:
127
+ 0 && (module.exports = {
128
+ camelToSnake,
129
+ deepCamelToSnake,
130
+ deepSnakeToCamel,
131
+ getNonUndefinedValues,
132
+ isIPV4Address,
133
+ isTruthy,
134
+ jitteredDelay,
135
+ snakeToCamel,
136
+ titleize,
137
+ toSentence
138
+ });
139
+ //# sourceMappingURL=caseUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/caseUtils.ts"],"sourcesContent":["/**\n * Convert words to a sentence.\n *\n * @param items - An array of words to be joined.\n * @returns A string with the items joined by a comma and the last item joined by \", or\".\n */\nexport const toSentence = (items: string[]): string => {\n // TODO: Once Safari supports it, use Intl.ListFormat\n if (items.length == 0) {\n return '';\n }\n if (items.length == 1) {\n return items[0];\n }\n let sentence = items.slice(0, -1).join(', ');\n sentence += `, or ${items.slice(-1)}`;\n return sentence;\n};\n\nconst IP_V4_ADDRESS_REGEX =\n /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;\n\n/**\n * Checks if a string is a valid IPv4 address.\n *\n * @returns True if the string is a valid IPv4 address, false otherwise.\n */\nexport function isIPV4Address(str: string | undefined | null): boolean {\n return IP_V4_ADDRESS_REGEX.test(str || '');\n}\n\n/**\n * Converts the first character of a string to uppercase.\n *\n * @param str - The string to be converted.\n * @returns The modified string with the rest of the string unchanged.\n *\n * @example\n * ```ts\n * titleize('hello world') // 'Hello world'\n * ```\n */\nexport function titleize(str: string | undefined | null): string {\n const s = str || '';\n return s.charAt(0).toUpperCase() + s.slice(1);\n}\n\n/**\n * Converts a string from snake_case to camelCase.\n */\nexport function snakeToCamel(str: string | undefined): string {\n return str ? str.replace(/([-_][a-z])/g, match => match.toUpperCase().replace(/-|_/, '')) : '';\n}\n\n/**\n * Converts a string from camelCase to snake_case.\n */\nexport function camelToSnake(str: string | undefined): string {\n return str ? str.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`) : '';\n}\n\nconst createDeepObjectTransformer = (transform: any) => {\n const deepTransform = (obj: any): any => {\n if (!obj) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(el => {\n if (typeof el === 'object' || Array.isArray(el)) {\n return deepTransform(el);\n }\n return el;\n });\n }\n\n const copy = { ...obj };\n const keys = Object.keys(copy);\n for (const oldName of keys) {\n const newName = transform(oldName.toString());\n if (newName !== oldName) {\n copy[newName] = copy[oldName];\n delete copy[oldName];\n }\n if (typeof copy[newName] === 'object') {\n copy[newName] = deepTransform(copy[newName]);\n }\n }\n return copy;\n };\n\n return deepTransform;\n};\n\n/**\n * Transforms camelCased objects/ arrays to snake_cased.\n * This function recursively traverses all objects and arrays of the passed value\n * camelCased keys are removed.\n *\n * @function\n */\nexport const deepCamelToSnake = createDeepObjectTransformer(camelToSnake);\n\n/**\n * Transforms snake_cased objects/ arrays to camelCased.\n * This function recursively traverses all objects and arrays of the passed value\n * camelCased keys are removed.\n *\n * @function\n */\nexport const deepSnakeToCamel = createDeepObjectTransformer(snakeToCamel);\n\n/**\n * A function to determine if a value is truthy.\n *\n * @returns True for `true`, true, positive numbers. False for `false`, false, 0, negative integers and anything else.\n */\nexport function isTruthy(value: unknown): boolean {\n // Return if Boolean\n if (typeof value === `boolean`) {\n return value;\n }\n\n // Return false if null or undefined\n if (value === undefined || value === null) {\n return false;\n }\n\n // If the String is true or false\n if (typeof value === `string`) {\n if (value.toLowerCase() === `true`) {\n return true;\n }\n\n if (value.toLowerCase() === `false`) {\n return false;\n }\n }\n\n // Now check if it's a number\n const number = parseInt(value as string, 10);\n if (isNaN(number)) {\n return false;\n }\n\n if (number > 0) {\n return true;\n }\n\n // Default to false\n return false;\n}\n\n/**\n * Get all non-undefined values from an object.\n */\nexport function getNonUndefinedValues<T extends object>(obj: T): Partial<T> {\n return Object.entries(obj).reduce((acc, [key, value]) => {\n if (value !== undefined) {\n acc[key as keyof T] = value;\n }\n return acc;\n }, {} as Partial<T>);\n}\n\n\nexport function jitteredDelay(delay: number): number {\n return delay * Math.random();\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,IAAM,aAAa,CAAC,UAA4B;AAErD,MAAI,MAAM,UAAU,GAAG;AACrB,WAAO;AAAA,EACT;AACA,MAAI,MAAM,UAAU,GAAG;AACrB,WAAO,MAAM,CAAC;AAAA,EAChB;AACA,MAAI,WAAW,MAAM,MAAM,GAAG,EAAE,EAAE,KAAK,IAAI;AAC3C,cAAY,QAAQ,MAAM,MAAM,EAAE,CAAC;AACnC,SAAO;AACT;AAEA,IAAM,sBACJ;AAOK,SAAS,cAAc,KAAyC;AACrE,SAAO,oBAAoB,KAAK,OAAO,EAAE;AAC3C;AAaO,SAAS,SAAS,KAAwC;AAC/D,QAAM,IAAI,OAAO;AACjB,SAAO,EAAE,OAAO,CAAC,EAAE,YAAY,IAAI,EAAE,MAAM,CAAC;AAC9C;AAKO,SAAS,aAAa,KAAiC;AAC5D,SAAO,MAAM,IAAI,QAAQ,gBAAgB,WAAS,MAAM,YAAY,EAAE,QAAQ,OAAO,EAAE,CAAC,IAAI;AAC9F;AAKO,SAAS,aAAa,KAAi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G;AACjB,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,GAAG;AACd,WAAO;AAAA,EACT;AAGA,SAAO;AACT;AAKO,SAAS,sBAAwC,KAAoB;AAC1E,SAAO,OAAO,QAAQ,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;AACvD,QAAI,UAAU,QAAW;AACvB,UAAI,GAAc,IAAI;AAAA,IACxB;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAe;AACrB;AAGO,SAAS,cAAc,OAAuB;AACnD,SAAO,QAAQ,KAAK,OAAO;AAC7B;","names":[]}
@@ -0,0 +1,105 @@
1
+ // src/caseUtils.ts
2
+ var toSentence = (items) => {
3
+ if (items.length == 0) {
4
+ return "";
5
+ }
6
+ if (items.length == 1) {
7
+ return items[0];
8
+ }
9
+ let sentence = items.slice(0, -1).join(", ");
10
+ sentence += `, or ${items.slice(-1)}`;
11
+ return sentence;
12
+ };
13
+ var IP_V4_ADDRESS_REGEX = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
14
+ function isIPV4Address(str) {
15
+ return IP_V4_ADDRESS_REGEX.test(str || "");
16
+ }
17
+ function titleize(str) {
18
+ const s = str || "";
19
+ return s.charAt(0).toUpperCase() + s.slice(1);
20
+ }
21
+ function snakeToCamel(str) {
22
+ return str ? str.replace(/([-_][a-z])/g, (match) => match.toUpperCase().replace(/-|_/, "")) : "";
23
+ }
24
+ function camelToSnake(str) {
25
+ return str ? str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`) : "";
26
+ }
27
+ var createDeepObjectTransformer = (transform) => {
28
+ const deepTransform = (obj) => {
29
+ if (!obj) {
30
+ return obj;
31
+ }
32
+ if (Array.isArray(obj)) {
33
+ return obj.map((el) => {
34
+ if (typeof el === "object" || Array.isArray(el)) {
35
+ return deepTransform(el);
36
+ }
37
+ return el;
38
+ });
39
+ }
40
+ const copy = { ...obj };
41
+ const keys = Object.keys(copy);
42
+ for (const oldName of keys) {
43
+ const newName = transform(oldName.toString());
44
+ if (newName !== oldName) {
45
+ copy[newName] = copy[oldName];
46
+ delete copy[oldName];
47
+ }
48
+ if (typeof copy[newName] === "object") {
49
+ copy[newName] = deepTransform(copy[newName]);
50
+ }
51
+ }
52
+ return copy;
53
+ };
54
+ return deepTransform;
55
+ };
56
+ var deepCamelToSnake = createDeepObjectTransformer(camelToSnake);
57
+ var deepSnakeToCamel = createDeepObjectTransformer(snakeToCamel);
58
+ function isTruthy(value) {
59
+ if (typeof value === `boolean`) {
60
+ return value;
61
+ }
62
+ if (value === void 0 || value === null) {
63
+ return false;
64
+ }
65
+ if (typeof value === `string`) {
66
+ if (value.toLowerCase() === `true`) {
67
+ return true;
68
+ }
69
+ if (value.toLowerCase() === `false`) {
70
+ return false;
71
+ }
72
+ }
73
+ const number = parseInt(value, 10);
74
+ if (isNaN(number)) {
75
+ return false;
76
+ }
77
+ if (number > 0) {
78
+ return true;
79
+ }
80
+ return false;
81
+ }
82
+ function getNonUndefinedValues(obj) {
83
+ return Object.entries(obj).reduce((acc, [key, value]) => {
84
+ if (value !== void 0) {
85
+ acc[key] = value;
86
+ }
87
+ return acc;
88
+ }, {});
89
+ }
90
+ function jitteredDelay(delay) {
91
+ return delay * Math.random();
92
+ }
93
+ export {
94
+ camelToSnake,
95
+ deepCamelToSnake,
96
+ deepSnakeToCamel,
97
+ getNonUndefinedValues,
98
+ isIPV4Address,
99
+ isTruthy,
100
+ jitteredDelay,
101
+ snakeToCamel,
102
+ titleize,
103
+ toSentence
104
+ };
105
+ //# sourceMappingURL=caseUtils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/caseUtils.ts"],"sourcesContent":["/**\n * Convert words to a sentence.\n *\n * @param items - An array of words to be joined.\n * @returns A string with the items joined by a comma and the last item joined by \", or\".\n */\nexport const toSentence = (items: string[]): string => {\n // TODO: Once Safari supports it, use Intl.ListFormat\n if (items.length == 0) {\n return '';\n }\n if (items.length == 1) {\n return items[0];\n }\n let sentence = items.slice(0, -1).join(', ');\n sentence += `, or ${items.slice(-1)}`;\n return sentence;\n};\n\nconst IP_V4_ADDRESS_REGEX =\n /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;\n\n/**\n * Checks if a string is a valid IPv4 address.\n *\n * @returns True if the string is a valid IPv4 address, false otherwise.\n */\nexport function isIPV4Address(str: string | undefined | null): boolean {\n return IP_V4_ADDRESS_REGEX.test(str || '');\n}\n\n/**\n * Converts the first character of a string to uppercase.\n *\n * @param str - The string to be converted.\n * @returns The modified string with the rest of the string unchanged.\n *\n * @example\n * ```ts\n * titleize('hello world') // 'Hello world'\n * ```\n */\nexport function titleize(str: string | undefined | null): string {\n const s = str || '';\n return s.charAt(0).toUpperCase() + s.slice(1);\n}\n\n/**\n * Converts a string from snake_case to camelCase.\n */\nexport function snakeToCamel(str: string | undefined): string {\n return str ? str.replace(/([-_][a-z])/g, match => match.toUpperCase().replace(/-|_/, '')) : '';\n}\n\n/**\n * Converts a string from camelCase to snake_case.\n */\nexport function camelToSnake(str: string | undefined): string {\n return str ? str.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`) : '';\n}\n\nconst createDeepObjectTransformer = (transform: any) => {\n const deepTransform = (obj: any): any => {\n if (!obj) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map(el => {\n if (typeof el === 'object' || Array.isArray(el)) {\n return deepTransform(el);\n }\n return el;\n });\n }\n\n const copy = { ...obj };\n const keys = Object.keys(copy);\n for (const oldName of keys) {\n const newName = transform(oldName.toString());\n if (newName !== oldName) {\n copy[newName] = copy[oldName];\n delete copy[oldName];\n }\n if (typeof copy[newName] === 'object') {\n copy[newName] = deepTransform(copy[newName]);\n }\n }\n return copy;\n };\n\n return deepTransform;\n};\n\n/**\n * Transforms camelCased objects/ arrays to snake_cased.\n * This function recursively traverses all objects and arrays of the passed value\n * camelCased keys are removed.\n *\n * @function\n */\nexport const deepCamelToSnake = createDeepObjectTransformer(camelToSnake);\n\n/**\n * Transforms snake_cased objects/ arrays to camelCased.\n * This function recursively traverses all objects and arrays of the passed value\n * camelCased keys are removed.\n *\n * @function\n */\nexport const deepSnakeToCamel = createDeepObjectTransformer(snakeToCamel);\n\n/**\n * A function to determine if a value is truthy.\n *\n * @returns True for `true`, true, positive numbers. False for `false`, false, 0, negative integers and anything else.\n */\nexport function isTruthy(value: unknown): boolean {\n // Return if Boolean\n if (typeof value === `boolean`) {\n return value;\n }\n\n // Return false if null or undefined\n if (value === undefined || value === null) {\n return false;\n }\n\n // If the String is true or false\n if (typeof value === `string`) {\n if (value.toLowerCase() === `true`) {\n return true;\n }\n\n if (value.toLowerCase() === `false`) {\n return false;\n }\n }\n\n // Now check if it's a number\n const number = parseInt(value as string, 10);\n if (isNaN(number)) {\n return false;\n }\n\n if (number > 0) {\n return true;\n }\n\n // Default to false\n return false;\n}\n\n/**\n * Get all non-undefined values from an object.\n */\nexport function getNonUndefinedValues<T extends object>(obj: T): Partial<T> {\n return Object.entries(obj).reduce((acc, [key, value]) => {\n if (value !== undefined) {\n acc[key as keyof T] = value;\n }\n return acc;\n }, {} as Partial<T>);\n}\n\n\nexport function jitteredDelay(delay: number): number {\n return delay * Math.random();\n}"],"mappings":";AAMO,IAAM,aAAa,CAAC,UAA4B;AAErD,MAAI,MAAM,UAAU,GAAG;AACrB,WAAO;AAAA,EACT;AACA,MAAI,MAAM,UAAU,GAAG;AACrB,WAAO,MAAM,CAAC;AAAA,EAChB;AACA,MAAI,WAAW,MAAM,MAAM,GAAG,EAAE,EAAE,KAAK,IAAI;AA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BAAmB,4BAA4B,YAAY;AASjE,IAAM,mBAAmB,4BAA4B,YAAY;AAOjE,SAAS,SAAS,OAAyB;AAEhD,MAAI,OAAO,UAAU,WAAW;AAC9B,WAAO;AAAA,EACT;AAGA,MAAI,UAAU,UAAa,UAAU,MAAM;AACzC,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI,MAAM,YAAY,MAAM,QAAQ;AAClC,aAAO;AAAA,IACT;AAEA,QAAI,MAAM,YAAY,MAAM,SAAS;AACnC,aAAO;AAAA,IACT;AAAA,EACF;AAGA,QAAM,SAAS,SAAS,OAAiB,EAAE;AAC3C,MAAI,MAAM,MAAM,GAAG;AACjB,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,GAAG;AACd,WAAO;AAAA,EACT;AAGA,SAAO;AACT;AAKO,SAAS,sBAAwC,KAAoB;AAC1E,SAAO,OAAO,QAAQ,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;AACvD,QAAI,UAAU,QAAW;AACvB,UAAI,GAAc,IAAI;AAAA,IACxB;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAe;AACrB;AAGO,SAAS,cAAc,OAAuB;AACnD,SAAO,QAAQ,KAAK,OAAO;AAC7B;","names":[]}
@@ -1,9 +1,9 @@
1
- import {
2
- resolveVersion
3
- } from "./chunk-PHCVLVZY.mjs";
4
1
  import {
5
2
  loadScript
6
3
  } from "./chunk-33U3M4YY.mjs";
4
+ import {
5
+ resolveVersion
6
+ } from "./chunk-PHCVLVZY.mjs";
7
7
 
8
8
  // src/loadTernUIScript.ts
9
9
  var loadTernUIScript = async (options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tern-secure/shared",
3
- "version": "1.3.0-canary.v20250916132854",
3
+ "version": "1.3.0-canary.v20250919131424",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/TernSecure/auth.git",
@@ -81,7 +81,7 @@
81
81
  "dependencies": {
82
82
  "js-cookie": "^3.0.5",
83
83
  "tslib": "2.4.1",
84
- "@tern-secure/types": "1.1.0-canary.v20250916132854"
84
+ "@tern-secure/types": "1.1.0-canary.v20250919131424"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "react": "^19",