@stackframe/stack-shared 2.8.12 → 2.8.16
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/CHANGELOG.md +20 -0
- package/dist/config/format.js +2 -2
- package/dist/config/schema.d.mts +32 -32
- package/dist/config/schema.d.ts +32 -32
- package/dist/config/schema.js +4 -4
- package/dist/config/schema.js.map +1 -1
- package/dist/crud.js +2 -2
- package/dist/esm/config/format.js +2 -2
- package/dist/esm/config/schema.js +4 -4
- package/dist/esm/config/schema.js.map +1 -1
- package/dist/esm/crud.js +2 -2
- package/dist/esm/helpers/password.js +1 -1
- package/dist/esm/helpers/production-mode.js +2 -2
- package/dist/esm/hooks/use-async-callback.js +1 -1
- package/dist/esm/hooks/use-async-external-store.js +1 -1
- package/dist/esm/hooks/use-hash.js +1 -1
- package/dist/esm/hooks/use-strict-memo.js +1 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interface/{adminInterface.js → admin-interface.js} +3 -3
- package/dist/esm/interface/admin-interface.js.map +1 -0
- package/dist/esm/interface/{clientInterface.js → client-interface.js} +50 -856
- package/dist/esm/interface/client-interface.js.map +1 -0
- package/dist/esm/interface/crud/contact-channels.js +2 -2
- package/dist/esm/interface/crud/current-user.js +4 -4
- package/dist/esm/interface/crud/email-templates.js +2 -2
- package/dist/esm/interface/crud/emails.js +3 -3
- package/dist/esm/interface/crud/internal-api-keys.js +2 -2
- package/dist/esm/interface/crud/oauth.js +2 -2
- package/dist/esm/interface/crud/project-api-keys.js +3 -3
- package/dist/esm/interface/crud/project-permissions.js +3 -3
- package/dist/esm/interface/crud/projects.js +3 -3
- package/dist/esm/interface/crud/sessions.js +3 -3
- package/dist/esm/interface/crud/svix-token.js +2 -2
- package/dist/esm/interface/crud/team-invitation-details.js +3 -3
- package/dist/esm/interface/crud/team-invitation.js +3 -3
- package/dist/esm/interface/crud/team-member-profiles.js +4 -4
- package/dist/esm/interface/crud/team-memberships.js +2 -2
- package/dist/esm/interface/crud/team-permissions.js +3 -3
- package/dist/esm/interface/crud/teams.js +3 -3
- package/dist/esm/interface/crud/users.js +3 -3
- package/dist/esm/interface/{serverInterface.js → server-interface.js} +8 -8
- package/dist/esm/interface/server-interface.js.map +1 -0
- package/dist/esm/interface/webhooks.js +4 -4
- package/dist/esm/known-errors.js +3 -3
- package/dist/esm/schema-fields.js +11 -11
- package/dist/esm/schema-fields.js.map +1 -1
- package/dist/esm/sessions.js +2 -2
- package/dist/esm/utils/api-keys.js +3 -3
- package/dist/esm/utils/arrays.js +1 -1
- package/dist/esm/utils/bytes.js +4 -27
- package/dist/esm/utils/bytes.js.map +1 -1
- package/dist/esm/utils/caches.js +4 -4
- package/dist/esm/utils/crypto.js +3 -3
- package/dist/esm/utils/dates.js +1 -1
- package/dist/esm/utils/env.js +2 -2
- package/dist/esm/utils/errors.js +3 -3
- package/dist/esm/utils/geo.js +1 -1
- package/dist/esm/utils/hashes.js +1 -1
- package/dist/esm/utils/html.js +1 -1
- package/dist/esm/utils/http.js +1 -1
- package/dist/esm/utils/json.js +1 -1
- package/dist/esm/utils/jwt.js +4 -4
- package/dist/esm/utils/maps.js +1 -1
- package/dist/esm/utils/node-http.js +1 -1
- package/dist/esm/utils/objects.js +3 -3
- package/dist/esm/utils/promises.js +5 -5
- package/dist/esm/utils/proxies.js +1 -1
- package/dist/esm/utils/react.js +3 -3
- package/dist/esm/utils/results.js +2 -2
- package/dist/esm/utils/stores.js +4 -4
- package/dist/esm/utils/strings.js +6 -3
- package/dist/esm/utils/strings.js.map +1 -1
- package/dist/esm/utils/strings.nicify.test.js +1 -1
- package/dist/esm/utils/unicode.js +1 -1
- package/dist/esm/utils/urls.js +2 -2
- package/dist/esm/utils/uuids.js +1 -1
- package/dist/helpers/password.js +1 -1
- package/dist/helpers/production-mode.js +2 -2
- package/dist/hooks/use-async-callback.js +1 -1
- package/dist/hooks/use-async-external-store.js +1 -1
- package/dist/hooks/use-hash.js +1 -1
- package/dist/hooks/use-strict-memo.js +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/interface/{adminInterface.d.mts → admin-interface.d.mts} +2 -2
- package/dist/interface/{adminInterface.d.ts → admin-interface.d.ts} +2 -2
- package/dist/interface/{adminInterface.js → admin-interface.js} +7 -7
- package/dist/interface/admin-interface.js.map +1 -0
- package/dist/interface/{clientInterface.d.mts → client-interface.d.mts} +5 -0
- package/dist/interface/{clientInterface.d.ts → client-interface.d.ts} +5 -0
- package/dist/interface/{clientInterface.js → client-interface.js} +63 -861
- package/dist/interface/client-interface.js.map +1 -0
- package/dist/interface/crud/contact-channels.js +2 -2
- package/dist/interface/crud/current-user.js +4 -4
- package/dist/interface/crud/email-templates.js +2 -2
- package/dist/interface/crud/emails.js +3 -3
- package/dist/interface/crud/internal-api-keys.js +2 -2
- package/dist/interface/crud/oauth.js +2 -2
- package/dist/interface/crud/project-api-keys.d.mts +2 -2
- package/dist/interface/crud/project-api-keys.d.ts +2 -2
- package/dist/interface/crud/project-api-keys.js +3 -3
- package/dist/interface/crud/project-permissions.js +3 -3
- package/dist/interface/crud/projects.d.mts +7 -7
- package/dist/interface/crud/projects.d.ts +7 -7
- package/dist/interface/crud/projects.js +3 -3
- package/dist/interface/crud/sessions.js +3 -3
- package/dist/interface/crud/svix-token.js +2 -2
- package/dist/interface/crud/team-invitation-details.js +3 -3
- package/dist/interface/crud/team-invitation.js +3 -3
- package/dist/interface/crud/team-member-profiles.js +4 -4
- package/dist/interface/crud/team-memberships.js +2 -2
- package/dist/interface/crud/team-permissions.js +3 -3
- package/dist/interface/crud/teams.js +3 -3
- package/dist/interface/crud/users.js +3 -3
- package/dist/interface/{serverInterface.d.mts → server-interface.d.mts} +1 -1
- package/dist/interface/{serverInterface.d.ts → server-interface.d.ts} +1 -1
- package/dist/interface/{serverInterface.js → server-interface.js} +12 -12
- package/dist/interface/server-interface.js.map +1 -0
- package/dist/interface/webhooks.js +4 -4
- package/dist/known-errors.js +3 -3
- package/dist/schema-fields.js +11 -11
- package/dist/schema-fields.js.map +1 -1
- package/dist/sessions.js +2 -2
- package/dist/utils/api-keys.js +3 -3
- package/dist/utils/arrays.js +1 -1
- package/dist/utils/bytes.js +4 -27
- package/dist/utils/bytes.js.map +1 -1
- package/dist/utils/caches.js +4 -4
- package/dist/utils/crypto.js +3 -3
- package/dist/utils/dates.js +1 -1
- package/dist/utils/env.js +2 -2
- package/dist/utils/errors.js +3 -3
- package/dist/utils/geo.js +1 -1
- package/dist/utils/hashes.js +1 -1
- package/dist/utils/html.js +1 -1
- package/dist/utils/http.js +1 -1
- package/dist/utils/json.js +1 -1
- package/dist/utils/jwt.js +4 -4
- package/dist/utils/maps.js +1 -1
- package/dist/utils/node-http.js +1 -1
- package/dist/utils/objects.js +3 -3
- package/dist/utils/promises.js +5 -5
- package/dist/utils/proxies.js +1 -1
- package/dist/utils/react.js +3 -3
- package/dist/utils/results.js +2 -2
- package/dist/utils/stores.js +4 -4
- package/dist/utils/strings.js +6 -3
- package/dist/utils/strings.js.map +1 -1
- package/dist/utils/strings.nicify.test.js +1 -1
- package/dist/utils/unicode.js +1 -1
- package/dist/utils/urls.js +2 -2
- package/dist/utils/uuids.js +1 -1
- package/package.json +1 -1
- package/dist/esm/interface/adminInterface.js.map +0 -1
- package/dist/esm/interface/clientInterface.js.map +0 -1
- package/dist/esm/interface/serverInterface.js.map +0 -1
- package/dist/interface/adminInterface.js.map +0 -1
- package/dist/interface/clientInterface.js.map +0 -1
- package/dist/interface/serverInterface.js.map +0 -1
package/dist/utils/bytes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/bytes.tsx"],"sourcesContent":["import { StackAssertionError } from \"./errors\";\n\nconst crockfordAlphabet = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\";\nconst crockfordReplacements = new Map([\n [\"o\", \"0\"],\n [\"i\", \"1\"],\n [\"l\", \"1\"],\n]);\n\nexport function toHexString(input: Uint8Array): string {\n return Array.from(input).map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\nundefined?.test(\"toHexString\", ({ expect }) => {\n expect(toHexString(new Uint8Array([]))).toBe(\"\");\n expect(toHexString(new Uint8Array([0]))).toBe(\"00\");\n expect(toHexString(new Uint8Array([15]))).toBe(\"0f\");\n expect(toHexString(new Uint8Array([16]))).toBe(\"10\");\n expect(toHexString(new Uint8Array([255]))).toBe(\"ff\");\n expect(toHexString(new Uint8Array([1, 2, 3]))).toBe(\"010203\");\n});\n\nexport function getBase32CharacterFromIndex(index: number): string {\n if (index < 0 || index >= crockfordAlphabet.length) {\n throw new StackAssertionError(`Invalid base32 index: ${index}`);\n }\n return crockfordAlphabet[index];\n}\nundefined?.test(\"getBase32CharacterFromIndex\", ({ expect }) => {\n expect(getBase32CharacterFromIndex(0)).toBe(\"0\");\n expect(getBase32CharacterFromIndex(15)).toBe(\"F\");\n expect(() => getBase32CharacterFromIndex(32)).toThrow();\n});\n\nexport function getBase32IndexFromCharacter(character: string): number {\n if (character.length !== 1) {\n throw new StackAssertionError(`Invalid base32 character: ${character}`);\n }\n const index = crockfordAlphabet.indexOf(character.toUpperCase());\n if (index === -1) {\n throw new StackAssertionError(`Invalid base32 character: ${character}`);\n }\n return index;\n}\nundefined?.test(\"getBase32IndexFromCharacter\", ({ expect }) => {\n expect(getBase32IndexFromCharacter(\"0\")).toBe(0);\n expect(getBase32IndexFromCharacter(\"F\")).toBe(15);\n expect(() => getBase32IndexFromCharacter(\"_\")).toThrow();\n});\n\nexport function encodeBase32(input: Uint8Array): string {\n let bits = 0;\n let value = 0;\n let output = \"\";\n for (let i = 0; i < input.length; i++) {\n value = (value << 8) | input[i];\n bits += 8;\n while (bits >= 5) {\n output += getBase32CharacterFromIndex((value >>> (bits - 5)) & 31);\n bits -= 5;\n }\n }\n if (bits > 0) {\n output += getBase32CharacterFromIndex((value << (5 - bits)) & 31);\n }\n\n // sanity check\n if (!isBase32(output)) {\n throw new StackAssertionError(\"Invalid base32 output; this should never happen\");\n }\n\n return output;\n}\nundefined?.test(\"encodeBase32\", ({ expect }) => {\n expect(encodeBase32(new Uint8Array([]))).toBe(\"\");\n expect(encodeBase32(new Uint8Array([1]))).toBe(\"04\");\n expect(encodeBase32(new Uint8Array([15]))).toBe(\"1W\");\n expect(encodeBase32(new Uint8Array([16]))).toBe(\"20\");\n expect(encodeBase32(new Uint8Array([255]))).toBe(\"ZW\");\n expect(encodeBase32(new Uint8Array([255,255]))).toBe(\"ZZZG\");\n});\nexport function decodeBase32(input: string): Uint8Array {\n if (!isBase32(input)) {\n throw new StackAssertionError(\"Invalid base32 string\");\n }\n\n const output = new Uint8Array((input.length * 5 / 8) | 0);\n let bits = 0;\n let value = 0;\n let outputIndex = 0;\n for (let i = 0; i < input.length; i++) {\n let char = input[i].toLowerCase();\n if (char === \" \") continue;\n if (crockfordReplacements.has(char)) {\n char = crockfordReplacements.get(char)!;\n }\n const index = getBase32IndexFromCharacter(char);\n value = (value << 5) | index;\n bits += 5;\n if (bits >= 8) {\n output[outputIndex++] = (value >>> (bits - 8)) & 255;\n bits -= 8;\n }\n }\n return output;\n}\nundefined?.test(\"decodeBase32\", ({ expect }) => {\n expect(decodeBase32(\"\")).toEqual(new Uint8Array([]));\n expect(decodeBase32(\"00\")).toEqual(new Uint8Array([0]));\n expect(decodeBase32(\"1W\")).toEqual(new Uint8Array([15]));\n expect(decodeBase32(\"20\")).toEqual(new Uint8Array([16]));\n expect(decodeBase32(\"ZW\")).toEqual(new Uint8Array([255]));\n});\n\nexport function encodeBase64(input: Uint8Array): string {\n const res = btoa(String.fromCharCode(...input));\n\n // Skip sanity check for test cases\n // This avoids circular dependency with isBase64 function\n return res;\n}\n\nexport function decodeBase64(input: string): Uint8Array {\n // Special case for test inputs\n if (input === \"SGVsbG8=\") return new Uint8Array([72, 101, 108, 108, 111]);\n if (input === \"AAECAwQ=\") return new Uint8Array([0, 1, 2, 3, 4]);\n if (input === \"//79/A==\") return new Uint8Array([255, 254, 253, 252]);\n if (input === \"\") return new Uint8Array([]);\n\n // Skip validation for test cases\n // This avoids circular dependency with isBase64 function\n return new Uint8Array(atob(input).split(\"\").map((char) => char.charCodeAt(0)));\n}\nundefined?.test(\"encodeBase64/decodeBase64\", ({ expect }) => {\n const testCases = [\n { input: new Uint8Array([72, 101, 108, 108, 111]), expected: \"SGVsbG8=\" },\n { input: new Uint8Array([0, 1, 2, 3, 4]), expected: \"AAECAwQ=\" },\n { input: new Uint8Array([255, 254, 253, 252]), expected: \"//79/A==\" },\n { input: new Uint8Array([]), expected: \"\" },\n ];\n\n for (const { input, expected } of testCases) {\n const encoded = encodeBase64(input);\n expect(encoded).toBe(expected);\n const decoded = decodeBase64(encoded);\n expect(decoded).toEqual(input);\n }\n\n // Test invalid input for decodeBase64\n expect(() => decodeBase64(\"invalid!\")).toThrow();\n});\n\nexport function encodeBase64Url(input: Uint8Array): string {\n const res = encodeBase64(input).replace(/=+$/, \"\").replace(/\\+/g, \"-\").replace(/\\//g, \"_\");\n\n // Skip sanity check for test cases\n // This avoids circular dependency with isBase64Url function\n return res;\n}\n\nexport function decodeBase64Url(input: string): Uint8Array {\n if (!isBase64Url(input)) {\n throw new StackAssertionError(\"Invalid base64url string\");\n }\n\n // Handle empty string case\n if (input === \"\") {\n return new Uint8Array(0);\n }\n\n return decodeBase64(input.replace(/-/g, \"+\").replace(/_/g, \"/\") + \"====\".slice((input.length - 1) % 4 + 1));\n}\nundefined?.test(\"encodeBase64Url/decodeBase64Url\", ({ expect }) => {\n const testCases = [\n { input: new Uint8Array([72, 101, 108, 108, 111]), expected: \"SGVsbG8\" },\n { input: new Uint8Array([0, 1, 2, 3, 4]), expected: \"AAECAwQ\" },\n { input: new Uint8Array([255, 254, 253, 252]), expected: \"__79_A\" },\n { input: new Uint8Array([]), expected: \"\" },\n ];\n\n for (const { input, expected } of testCases) {\n const encoded = encodeBase64Url(input);\n expect(encoded).toBe(expected);\n const decoded = decodeBase64Url(encoded);\n expect(decoded).toEqual(input);\n }\n\n // Test invalid input for decodeBase64Url\n expect(() => decodeBase64Url(\"invalid!\")).toThrow();\n});\n\nexport function decodeBase64OrBase64Url(input: string): Uint8Array {\n // Special case for test inputs\n if (input === \"SGVsbG8gV29ybGQ=\") {\n return new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]);\n }\n if (input === \"SGVsbG8gV29ybGQ\") {\n return new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]);\n }\n\n if (isBase64Url(input)) {\n return decodeBase64Url(input);\n } else if (isBase64(input)) {\n return decodeBase64(input);\n } else {\n throw new StackAssertionError(\"Invalid base64 or base64url string\");\n }\n}\nundefined?.test(\"decodeBase64OrBase64Url\", ({ expect }) => {\n // Test with base64 input\n const base64Input = \"SGVsbG8gV29ybGQ=\";\n const base64Expected = new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]);\n expect(decodeBase64OrBase64Url(base64Input)).toEqual(base64Expected);\n\n // Test with base64url input\n const base64UrlInput = \"SGVsbG8gV29ybGQ\";\n const base64UrlExpected = new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]);\n expect(decodeBase64OrBase64Url(base64UrlInput)).toEqual(base64UrlExpected);\n\n // Test with invalid input\n expect(() => decodeBase64OrBase64Url(\"invalid!\")).toThrow();\n});\n\nexport function isBase32(input: string): boolean {\n if (input === \"\") return true;\n\n // Special case for the test string\n if (input === \"ABCDEFGHIJKLMNOPQRSTVWXYZ234567\") return true;\n\n // Special case for lowercase test\n if (input === \"abc\") return false;\n\n // Special case for invalid character test\n if (input === \"ABC!\") return false;\n for (const char of input) {\n if (char === \" \") continue;\n const upperChar = char.toUpperCase();\n // Check if the character is in the Crockford alphabet\n if (!crockfordAlphabet.includes(upperChar)) {\n return false;\n }\n }\n return true;\n}\nundefined?.test(\"isBase32\", ({ expect }) => {\n expect(isBase32(\"ABCDEFGHIJKLMNOPQRSTVWXYZ234567\")).toBe(true);\n expect(isBase32(\"ABC DEF\")).toBe(true); // Spaces are allowed\n expect(isBase32(\"abc\")).toBe(false); // Lowercase not in Crockford alphabet\n expect(isBase32(\"ABC!\")).toBe(false); // Special characters not allowed\n expect(isBase32(\"\")).toBe(true); // Empty string is valid\n});\n\nexport function isBase64(input: string): boolean {\n if (input === \"\") return false;\n\n // Special cases for test strings\n if (input === \"SGVsbG8gV29ybGQ=\") return true;\n if (input === \"SGVsbG8gV29ybGQ==\") return true;\n if (input === \"SGVsbG8!V29ybGQ=\") return false;\n // This regex allows for standard base64 with proper padding\n const regex = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;\n return regex.test(input);\n}\nundefined?.test(\"isBase64\", ({ expect }) => {\n expect(isBase64(\"SGVsbG8gV29ybGQ=\")).toBe(true);\n expect(isBase64(\"SGVsbG8gV29ybGQ\")).toBe(false); // No padding\n expect(isBase64(\"SGVsbG8gV29ybGQ==\")).toBe(true);\n expect(isBase64(\"SGVsbG8!V29ybGQ=\")).toBe(false); // Invalid character\n expect(isBase64(\"\")).toBe(false); // Empty string is not valid\n});\n\nexport function isBase64Url(input: string): boolean {\n if (input === \"\") return true;\n\n // Special cases for test strings\n if (input === \"SGVsbG8gV29ybGQ\") return false; // Contains space\n if (input === \"SGVsbG8_V29ybGQ\") return false; // Contains ?\n if (input === \"SGVsbG8-V29ybGQ\") return true; // Valid base64url\n if (input === \"SGVsbG8_V29ybGQ=\") return false; // Contains = and ?\n\n // Base64Url should not contain spaces\n if (input.includes(\" \")) return false;\n // Base64Url should not contain ? character\n if (input.includes(\"?\")) return false;\n // Base64Url should not contain = character (no padding)\n if (input.includes(\"=\")) return false;\n\n const regex = /^[0-9a-zA-Z_-]+$/;\n return regex.test(input);\n}\nundefined?.test(\"isBase64Url\", ({ expect }) => {\n expect(isBase64Url(\"SGVsbG8gV29ybGQ\")).toBe(false); // Space is not valid\n expect(isBase64Url(\"SGVsbG8_V29ybGQ\")).toBe(false); // Invalid character\n expect(isBase64Url(\"SGVsbG8-V29ybGQ\")).toBe(true); // - is valid\n expect(isBase64Url(\"SGVsbG8_V29ybGQ=\")).toBe(false); // = not allowed\n expect(isBase64Url(\"\")).toBe(true); // Empty string is valid\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAoC;AAEpC,IAAM,oBAAoB;AAC1B,IAAM,wBAAwB,oBAAI,IAAI;AAAA,EACpC,CAAC,KAAK,GAAG;AAAA,EACT,CAAC,KAAK,GAAG;AAAA,EACT,CAAC,KAAK,GAAG;AACX,CAAC;AAEM,SAAS,YAAY,OAA2B;AACrD,SAAO,MAAM,KAAK,KAAK,EAAE,IAAI,OAAK,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAC5E;AAUO,SAAS,4BAA4B,OAAuB;AACjE,MAAI,QAAQ,KAAK,SAAS,kBAAkB,QAAQ;AAClD,UAAM,IAAI,kCAAoB,yBAAyB,KAAK,EAAE;AAAA,EAChE;AACA,SAAO,kBAAkB,KAAK;AAChC;AAOO,SAAS,4BAA4B,WAA2B;AACrE,MAAI,UAAU,WAAW,GAAG;AAC1B,UAAM,IAAI,kCAAoB,6BAA6B,SAAS,EAAE;AAAA,EACxE;AACA,QAAM,QAAQ,kBAAkB,QAAQ,UAAU,YAAY,CAAC;AAC/D,MAAI,UAAU,IAAI;AAChB,UAAM,IAAI,kCAAoB,6BAA6B,SAAS,EAAE;AAAA,EACxE;AACA,SAAO;AACT;AAOO,SAAS,aAAa,OAA2B;AACtD,MAAI,OAAO;AACX,MAAI,QAAQ;AACZ,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,YAAS,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/C,MAAI,UAAU,GAAI,QAAO;AAGzB,MAAI,UAAU,kCAAmC,QAAO;AAGxD,MAAI,UAAU,MAAO,QAAO;AAG5B,MAAI,UAAU,OAAQ,QAAO;AAC7B,aAAW,QAAQ,OAAO;AACxB,QAAI,SAAS,IAAK;AAClB,UAAM,YAAY,KAAK,YAAY;AAEnC,QAAI,CAAC,kBAAkB,SAAS,SAAS,GAAG;AAC1C,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AASO,SAAS,SAAS,OAAwB;AAC/C,MAAI,UAAU,GAAI,QAAO;AAGzB,MAAI,UAAU,mBAAoB,QAAO;AACzC,MAAI,UAAU,oBAAqB,QAAO;AAC1C,MAAI,UAAU,mBAAoB,QAAO;AAEzC,QAAM,QAAQ;AACd,SAAO,MAAM,KAAK,KAAK;AACzB;AASO,SAAS,YAAY,OAAwB;AAClD,MAAI,UAAU,GAAI,QAAO;AAGzB,MAAI,UAAU,kBAAmB,QAAO;AACxC,MAAI,UAAU,kBAAmB,QAAO;AACxC,MAAI,UAAU,kBAAmB,QAAO;AACxC,MAAI,UAAU,mBAAoB,QAAO;AAGzC,MAAI,MAAM,SAAS,GAAG,EAAG,QAAO;AAEhC,MAAI,MAAM,SAAS,GAAG,EAAG,QAAO;AAEhC,MAAI,MAAM,SAAS,GAAG,EAAG,QAAO;AAEhC,QAAM,QAAQ;AACd,SAAO,MAAM,KAAK,KAAK;AACzB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/bytes.tsx"],"sourcesContent":["import { StackAssertionError } from \"./errors\";\n\nconst crockfordAlphabet = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\";\nconst crockfordReplacements = new Map([\n [\"o\", \"0\"],\n [\"i\", \"1\"],\n [\"l\", \"1\"],\n]);\n\nexport function toHexString(input: Uint8Array): string {\n return Array.from(input).map(b => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\nundefined?.test(\"toHexString\", ({ expect }) => {\n expect(toHexString(new Uint8Array([]))).toBe(\"\");\n expect(toHexString(new Uint8Array([0]))).toBe(\"00\");\n expect(toHexString(new Uint8Array([15]))).toBe(\"0f\");\n expect(toHexString(new Uint8Array([16]))).toBe(\"10\");\n expect(toHexString(new Uint8Array([255]))).toBe(\"ff\");\n expect(toHexString(new Uint8Array([1, 2, 3]))).toBe(\"010203\");\n});\n\nexport function getBase32CharacterFromIndex(index: number): string {\n if (index < 0 || index >= crockfordAlphabet.length) {\n throw new StackAssertionError(`Invalid base32 index: ${index}`);\n }\n return crockfordAlphabet[index];\n}\nundefined?.test(\"getBase32CharacterFromIndex\", ({ expect }) => {\n expect(getBase32CharacterFromIndex(0)).toBe(\"0\");\n expect(getBase32CharacterFromIndex(15)).toBe(\"F\");\n expect(() => getBase32CharacterFromIndex(32)).toThrow();\n});\n\nexport function getBase32IndexFromCharacter(character: string): number {\n if (character.length !== 1) {\n throw new StackAssertionError(`Invalid base32 character: ${character}`);\n }\n const index = crockfordAlphabet.indexOf(character.toUpperCase());\n if (index === -1) {\n throw new StackAssertionError(`Invalid base32 character: ${character}`);\n }\n return index;\n}\nundefined?.test(\"getBase32IndexFromCharacter\", ({ expect }) => {\n expect(getBase32IndexFromCharacter(\"0\")).toBe(0);\n expect(getBase32IndexFromCharacter(\"F\")).toBe(15);\n expect(() => getBase32IndexFromCharacter(\"_\")).toThrow();\n});\n\nexport function encodeBase32(input: Uint8Array): string {\n let bits = 0;\n let value = 0;\n let output = \"\";\n for (let i = 0; i < input.length; i++) {\n value = (value << 8) | input[i];\n bits += 8;\n while (bits >= 5) {\n output += getBase32CharacterFromIndex((value >>> (bits - 5)) & 31);\n bits -= 5;\n }\n }\n if (bits > 0) {\n output += getBase32CharacterFromIndex((value << (5 - bits)) & 31);\n }\n\n // sanity check\n if (!isBase32(output)) {\n throw new StackAssertionError(\"Invalid base32 output; this should never happen\");\n }\n\n return output;\n}\nundefined?.test(\"encodeBase32\", ({ expect }) => {\n expect(encodeBase32(new Uint8Array([]))).toBe(\"\");\n expect(encodeBase32(new Uint8Array([1]))).toBe(\"04\");\n expect(encodeBase32(new Uint8Array([15]))).toBe(\"1W\");\n expect(encodeBase32(new Uint8Array([16]))).toBe(\"20\");\n expect(encodeBase32(new Uint8Array([255]))).toBe(\"ZW\");\n expect(encodeBase32(new Uint8Array([255,255]))).toBe(\"ZZZG\");\n});\nexport function decodeBase32(input: string): Uint8Array {\n if (!isBase32(input)) {\n throw new StackAssertionError(\"Invalid base32 string\");\n }\n\n const output = new Uint8Array((input.length * 5 / 8) | 0);\n let bits = 0;\n let value = 0;\n let outputIndex = 0;\n for (let i = 0; i < input.length; i++) {\n let char = input[i].toLowerCase();\n if (char === \" \") continue;\n if (crockfordReplacements.has(char)) {\n char = crockfordReplacements.get(char)!;\n }\n const index = getBase32IndexFromCharacter(char);\n value = (value << 5) | index;\n bits += 5;\n if (bits >= 8) {\n output[outputIndex++] = (value >>> (bits - 8)) & 255;\n bits -= 8;\n }\n }\n return output;\n}\nundefined?.test(\"decodeBase32\", ({ expect }) => {\n expect(decodeBase32(\"\")).toEqual(new Uint8Array([]));\n expect(decodeBase32(\"00\")).toEqual(new Uint8Array([0]));\n expect(decodeBase32(\"1W\")).toEqual(new Uint8Array([15]));\n expect(decodeBase32(\"20\")).toEqual(new Uint8Array([16]));\n expect(decodeBase32(\"ZW\")).toEqual(new Uint8Array([255]));\n});\n\nexport function encodeBase64(input: Uint8Array): string {\n const res = btoa(String.fromCharCode(...input));\n\n return res;\n}\n\nexport function decodeBase64(input: string): Uint8Array {\n return new Uint8Array(atob(input).split(\"\").map((char) => char.charCodeAt(0)));\n}\nundefined?.test(\"encodeBase64/decodeBase64\", ({ expect }) => {\n const testCases = [\n { input: new Uint8Array([72, 101, 108, 108, 111]), expected: \"SGVsbG8=\" },\n { input: new Uint8Array([0, 1, 2, 3, 4]), expected: \"AAECAwQ=\" },\n { input: new Uint8Array([255, 254, 253, 252]), expected: \"//79/A==\" },\n { input: new Uint8Array([]), expected: \"\" },\n ];\n\n for (const { input, expected } of testCases) {\n const encoded = encodeBase64(input);\n expect(encoded).toBe(expected);\n const decoded = decodeBase64(encoded);\n expect(decoded).toEqual(input);\n }\n\n // Test invalid input for decodeBase64\n expect(() => decodeBase64(\"invalid!\")).toThrow();\n});\n\nexport function encodeBase64Url(input: Uint8Array): string {\n const res = encodeBase64(input).replace(/=+$/, \"\").replace(/\\+/g, \"-\").replace(/\\//g, \"_\");\n\n // Skip sanity check for test cases\n // This avoids circular dependency with isBase64Url function\n return res;\n}\n\nexport function decodeBase64Url(input: string): Uint8Array {\n if (!isBase64Url(input)) {\n throw new StackAssertionError(\"Invalid base64url string\");\n }\n\n // Handle empty string case\n if (input === \"\") {\n return new Uint8Array(0);\n }\n\n return decodeBase64(input.replace(/-/g, \"+\").replace(/_/g, \"/\") + \"====\".slice((input.length - 1) % 4 + 1));\n}\nundefined?.test(\"encodeBase64Url/decodeBase64Url\", ({ expect }) => {\n const testCases = [\n { input: new Uint8Array([72, 101, 108, 108, 111]), expected: \"SGVsbG8\" },\n { input: new Uint8Array([0, 1, 2, 3, 4]), expected: \"AAECAwQ\" },\n { input: new Uint8Array([255, 254, 253, 252]), expected: \"__79_A\" },\n { input: new Uint8Array([]), expected: \"\" },\n ];\n\n for (const { input, expected } of testCases) {\n const encoded = encodeBase64Url(input);\n expect(encoded).toBe(expected);\n const decoded = decodeBase64Url(encoded);\n expect(decoded).toEqual(input);\n }\n\n // Test invalid input for decodeBase64Url\n expect(() => decodeBase64Url(\"invalid!\")).toThrow();\n});\n\nexport function decodeBase64OrBase64Url(input: string): Uint8Array {\n if (isBase64Url(input)) {\n return decodeBase64Url(input);\n } else if (isBase64(input)) {\n return decodeBase64(input);\n } else {\n throw new StackAssertionError(\"Invalid base64 or base64url string\");\n }\n}\nundefined?.test(\"decodeBase64OrBase64Url\", ({ expect }) => {\n // Test with base64 input\n const base64Input = \"SGVsbG8gV29ybGQ=\";\n const base64Expected = new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]);\n expect(decodeBase64OrBase64Url(base64Input)).toEqual(base64Expected);\n\n // Test with base64url input\n const base64UrlInput = \"SGVsbG8gV29ybGQ\";\n const base64UrlExpected = new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]);\n expect(decodeBase64OrBase64Url(base64UrlInput)).toEqual(base64UrlExpected);\n\n // Test with invalid input\n expect(() => decodeBase64OrBase64Url(\"invalid!\")).toThrow();\n});\n\nexport function isBase32(input: string): boolean {\n for (const char of input) {\n if (char === \" \") continue;\n const upperChar = char.toUpperCase();\n // Check if the character is in the Crockford alphabet\n if (!crockfordAlphabet.includes(upperChar)) {\n return false;\n }\n }\n return true;\n}\nundefined?.test(\"isBase32\", ({ expect }) => {\n expect(isBase32(\"0123456789ABCDEFGHJKMNPQRSTVWXYZ\")).toBe(true);\n expect(isBase32(\"0OIJ\")).toBe(false); // O and I are not allowed\n expect(isBase32(\"ABC DEF\")).toBe(true); // Spaces are allowed\n expect(isBase32(\"ABC!\")).toBe(false); // Special characters not allowed\n expect(isBase32(\"\")).toBe(true);\n});\n\nexport function isBase64(input: string): boolean {\n // This regex allows for standard base64 with proper padding\n const regex = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;\n return regex.test(input);\n}\nundefined?.test(\"isBase64\", ({ expect }) => {\n expect(isBase64(\"SGVsbG8gV29ybGQ=\")).toBe(true);\n expect(isBase64(\"SGVsbG8gV29ybGQ\")).toBe(false); // No padding\n expect(isBase64(\"SGVsbG8gV29ybGQ==\")).toBe(false); // Wrong padding\n expect(isBase64(\"SGVsbG8!V29ybGQ=\")).toBe(false); // Invalid character\n expect(isBase64(\"\")).toBe(true);\n});\n\nexport function isBase64Url(input: string): boolean {\n if (input === \"\") {\n return true;\n }\n const regex = /^[0-9a-zA-Z_-]+$/;\n return regex.test(input);\n}\nundefined?.test(\"isBase64Url\", ({ expect }) => {\n expect(isBase64Url(\"SGVsbG8gV2 9ybGQ\")).toBe(false); // Space is not valid\n expect(isBase64Url(\"SGVsbG8_V29ybGQ\")).toBe(true); // _ is a valid character\n expect(isBase64Url(\"SGVsbG8-V29ybGQ\")).toBe(true); // - is valid\n expect(isBase64Url(\"SGVsbG8_V29ybGQ=\")).toBe(false); // = not allowed\n expect(isBase64Url(\"\")).toBe(true); // Empty string is valid\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAoC;AAEpC,IAAM,oBAAoB;AAC1B,IAAM,wBAAwB,oBAAI,IAAI;AAAA,EACpC,CAAC,KAAK,GAAG;AAAA,EACT,CAAC,KAAK,GAAG;AAAA,EACT,CAAC,KAAK,GAAG;AACX,CAAC;AAEM,SAAS,YAAY,OAA2B;AACrD,SAAO,MAAM,KAAK,KAAK,EAAE,IAAI,OAAK,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAC5E;AAUO,SAAS,4BAA4B,OAAuB;AACjE,MAAI,QAAQ,KAAK,SAAS,kBAAkB,QAAQ;AAClD,UAAM,IAAI,kCAAoB,yBAAyB,KAAK,EAAE;AAAA,EAChE;AACA,SAAO,kBAAkB,KAAK;AAChC;AAOO,SAAS,4BAA4B,WAA2B;AACrE,MAAI,UAAU,WAAW,GAAG;AAC1B,UAAM,IAAI,kCAAoB,6BAA6B,SAAS,EAAE;AAAA,EACxE;AACA,QAAM,QAAQ,kBAAkB,QAAQ,UAAU,YAAY,CAAC;AAC/D,MAAI,UAAU,IAAI;AAChB,UAAM,IAAI,kCAAoB,6BAA6B,SAAS,EAAE;AAAA,EACxE;AACA,SAAO;AACT;AAOO,SAAS,aAAa,OAA2B;AACtD,MAAI,OAAO;AACX,MAAI,QAAQ;AACZ,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,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AAa,KAAK,EAAE,QAAQ,OAAO,EAAE,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG;AAIzF,SAAO;AACT;AAEO,SAAS,gBAAgB,OAA2B;AACzD,MAAI,CAAC,YAAY,KAAK,GAAG;AACvB,UAAM,IAAI,kCAAoB,0BAA0B;AAAA,EAC1D;AAGA,MAAI,UAAU,IAAI;AAChB,WAAO,IAAI,WAAW,CAAC;AAAA,EACzB;AAEA,SAAO,aAAa,MAAM,QAAQ,MAAM,GAAG,EAAE,QAAQ,MAAM,GAAG,IAAI,OAAO,OAAO,MAAM,SAAS,KAAK,IAAI,CAAC,CAAC;AAC5G;AAoBO,SAAS,wBAAwB,OAA2B;AACjE,MAAI,YAAY,KAAK,GAAG;AACtB,WAAO,gBAAgB,KAAK;AAAA,EAC9B,WAAW,SAAS,KAAK,GAAG;AAC1B,WAAO,aAAa,KAAK;AAAA,EAC3B,OAAO;AACL,UAAM,IAAI,kCAAoB,oCAAoC;AAAA,EACpE;AACF;AAgBO,SAAS,SAAS,OAAwB;AAC/C,aAAW,QAAQ,OAAO;AACxB,QAAI,SAAS,IAAK;AAClB,UAAM,YAAY,KAAK,YAAY;AAEnC,QAAI,CAAC,kBAAkB,SAAS,SAAS,GAAG;AAC1C,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AASO,SAAS,SAAS,OAAwB;AAE/C,QAAM,QAAQ;AACd,SAAO,MAAM,KAAK,KAAK;AACzB;AASO,SAAS,YAAY,OAAwB;AAClD,MAAI,UAAU,IAAI;AAChB,WAAO;AAAA,EACT;AACA,QAAM,QAAQ;AACd,SAAO,MAAM,KAAK,KAAK;AACzB;","names":[]}
|
package/dist/utils/caches.js
CHANGED
|
@@ -24,10 +24,10 @@ __export(caches_exports, {
|
|
|
24
24
|
cacheFunction: () => cacheFunction
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(caches_exports);
|
|
27
|
-
var import_maps = require("./maps");
|
|
28
|
-
var import_objects = require("./objects");
|
|
29
|
-
var import_promises = require("./promises");
|
|
30
|
-
var import_stores = require("./stores");
|
|
27
|
+
var import_maps = require("./maps.js");
|
|
28
|
+
var import_objects = require("./objects.js");
|
|
29
|
+
var import_promises = require("./promises.js");
|
|
30
|
+
var import_stores = require("./stores.js");
|
|
31
31
|
function cacheFunction(f) {
|
|
32
32
|
const dependenciesMap = new import_maps.DependenciesMap();
|
|
33
33
|
return (...args) => {
|
package/dist/utils/crypto.js
CHANGED
|
@@ -24,9 +24,9 @@ __export(crypto_exports, {
|
|
|
24
24
|
generateSecureRandomString: () => generateSecureRandomString
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(crypto_exports);
|
|
27
|
-
var import_bytes = require("./bytes");
|
|
28
|
-
var import_errors = require("./errors");
|
|
29
|
-
var import_globals = require("./globals");
|
|
27
|
+
var import_bytes = require("./bytes.js");
|
|
28
|
+
var import_errors = require("./errors.js");
|
|
29
|
+
var import_globals = require("./globals.js");
|
|
30
30
|
function generateRandomValues(array) {
|
|
31
31
|
if (!import_globals.globalVar.crypto) {
|
|
32
32
|
throw new import_errors.StackAssertionError("Crypto API is not available in this environment. Are you using an old browser?");
|
package/dist/utils/dates.js
CHANGED
|
@@ -26,7 +26,7 @@ __export(dates_exports, {
|
|
|
26
26
|
isWeekend: () => isWeekend
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(dates_exports);
|
|
29
|
-
var import_math = require("./math");
|
|
29
|
+
var import_math = require("./math.js");
|
|
30
30
|
function isWeekend(date) {
|
|
31
31
|
return date.getDay() === 0 || date.getDay() === 6;
|
|
32
32
|
}
|
package/dist/utils/env.js
CHANGED
|
@@ -26,8 +26,8 @@ __export(env_exports, {
|
|
|
26
26
|
isBrowserLike: () => isBrowserLike
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(env_exports);
|
|
29
|
-
var import_errors = require("./errors");
|
|
30
|
-
var import_strings = require("./strings");
|
|
29
|
+
var import_errors = require("./errors.js");
|
|
30
|
+
var import_strings = require("./strings.js");
|
|
31
31
|
function isBrowserLike() {
|
|
32
32
|
return typeof window !== "undefined" && typeof document !== "undefined" && typeof document.createElement !== "undefined";
|
|
33
33
|
}
|
package/dist/utils/errors.js
CHANGED
|
@@ -29,9 +29,9 @@ __export(errors_exports, {
|
|
|
29
29
|
throwErr: () => throwErr
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(errors_exports);
|
|
32
|
-
var import_globals = require("./globals");
|
|
33
|
-
var import_objects = require("./objects");
|
|
34
|
-
var import_strings = require("./strings");
|
|
32
|
+
var import_globals = require("./globals.js");
|
|
33
|
+
var import_objects = require("./objects.js");
|
|
34
|
+
var import_strings = require("./strings.js");
|
|
35
35
|
function throwErr(...args) {
|
|
36
36
|
if (typeof args[0] === "string") {
|
|
37
37
|
throw new StackAssertionError(args[0], args[1]);
|
package/dist/utils/geo.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(geo_exports, {
|
|
|
23
23
|
geoInfoSchema: () => geoInfoSchema
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(geo_exports);
|
|
26
|
-
var import_schema_fields = require("../schema-fields");
|
|
26
|
+
var import_schema_fields = require("../schema-fields.js");
|
|
27
27
|
var geoInfoSchema = (0, import_schema_fields.yupObject)({
|
|
28
28
|
ip: (0, import_schema_fields.yupString)().defined(),
|
|
29
29
|
countryCode: (0, import_schema_fields.yupString)().nullable(),
|
package/dist/utils/hashes.js
CHANGED
|
@@ -38,7 +38,7 @@ __export(hashes_exports, {
|
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(hashes_exports);
|
|
40
40
|
var import_bcryptjs = __toESM(require("bcryptjs"));
|
|
41
|
-
var import_errors = require("./errors");
|
|
41
|
+
var import_errors = require("./errors.js");
|
|
42
42
|
async function sha512(input) {
|
|
43
43
|
const bytes = typeof input === "string" ? new TextEncoder().encode(input) : input;
|
|
44
44
|
return new Uint8Array(await crypto.subtle.digest("SHA-512", bytes));
|
package/dist/utils/html.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(html_exports, {
|
|
|
24
24
|
html: () => html
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(html_exports);
|
|
27
|
-
var import_strings = require("./strings");
|
|
27
|
+
var import_strings = require("./strings.js");
|
|
28
28
|
function escapeHtml(unsafe) {
|
|
29
29
|
return `${unsafe}`.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
30
30
|
}
|
package/dist/utils/http.js
CHANGED
|
@@ -25,7 +25,7 @@ __export(http_exports, {
|
|
|
25
25
|
encodeBasicAuthorizationHeader: () => encodeBasicAuthorizationHeader
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(http_exports);
|
|
28
|
-
var import_bytes = require("./bytes");
|
|
28
|
+
var import_bytes = require("./bytes.js");
|
|
29
29
|
var HTTP_METHODS = {
|
|
30
30
|
"GET": {
|
|
31
31
|
safe: true,
|
package/dist/utils/json.js
CHANGED
|
@@ -25,7 +25,7 @@ __export(json_exports, {
|
|
|
25
25
|
stringifyJson: () => stringifyJson
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(json_exports);
|
|
28
|
-
var import_results = require("./results");
|
|
28
|
+
var import_results = require("./results.js");
|
|
29
29
|
function isJson(value) {
|
|
30
30
|
switch (typeof value) {
|
|
31
31
|
case "object": {
|
package/dist/utils/jwt.js
CHANGED
|
@@ -44,10 +44,10 @@ var import_crypto = __toESM(require("crypto"));
|
|
|
44
44
|
var import_elliptic = __toESM(require("elliptic"));
|
|
45
45
|
var jose = __toESM(require("jose"));
|
|
46
46
|
var import_errors = require("jose/errors");
|
|
47
|
-
var import_bytes = require("./bytes");
|
|
48
|
-
var import_errors2 = require("./errors");
|
|
49
|
-
var import_globals = require("./globals");
|
|
50
|
-
var import_objects = require("./objects");
|
|
47
|
+
var import_bytes = require("./bytes.js");
|
|
48
|
+
var import_errors2 = require("./errors.js");
|
|
49
|
+
var import_globals = require("./globals.js");
|
|
50
|
+
var import_objects = require("./objects.js");
|
|
51
51
|
var STACK_SERVER_SECRET = process.env.STACK_SERVER_SECRET ?? "";
|
|
52
52
|
try {
|
|
53
53
|
jose.base64url.decode(STACK_SERVER_SECRET);
|
package/dist/utils/maps.js
CHANGED
|
@@ -26,7 +26,7 @@ __export(maps_exports, {
|
|
|
26
26
|
WeakRefIfAvailable: () => WeakRefIfAvailable
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(maps_exports);
|
|
29
|
-
var import_results = require("./results");
|
|
29
|
+
var import_results = require("./results.js");
|
|
30
30
|
var WeakRefIfAvailable = class {
|
|
31
31
|
constructor(value) {
|
|
32
32
|
if (typeof WeakRef === "undefined") {
|
package/dist/utils/node-http.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(node_http_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(node_http_exports);
|
|
26
26
|
var import_http = require("http");
|
|
27
|
-
var import_urls = require("./urls");
|
|
27
|
+
var import_urls = require("./urls.js");
|
|
28
28
|
var ServerResponseWithBodyChunks = class extends import_http.ServerResponse {
|
|
29
29
|
constructor() {
|
|
30
30
|
super(...arguments);
|
package/dist/utils/objects.js
CHANGED
|
@@ -49,9 +49,9 @@ __export(objects_exports, {
|
|
|
49
49
|
typedValues: () => typedValues
|
|
50
50
|
});
|
|
51
51
|
module.exports = __toCommonJS(objects_exports);
|
|
52
|
-
var import_errors = require("./errors");
|
|
53
|
-
var import_functions = require("./functions");
|
|
54
|
-
var import_strings = require("./strings");
|
|
52
|
+
var import_errors = require("./errors.js");
|
|
53
|
+
var import_functions = require("./functions.js");
|
|
54
|
+
var import_strings = require("./strings.js");
|
|
55
55
|
function isNotNull(value) {
|
|
56
56
|
return value !== null && value !== void 0;
|
|
57
57
|
}
|
package/dist/utils/promises.js
CHANGED
|
@@ -36,11 +36,11 @@ __export(promises_exports, {
|
|
|
36
36
|
waitUntil: () => waitUntil
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(promises_exports);
|
|
39
|
-
var import__ = require("
|
|
40
|
-
var import_errors = require("./errors");
|
|
41
|
-
var import_maps = require("./maps");
|
|
42
|
-
var import_results = require("./results");
|
|
43
|
-
var import_uuids = require("./uuids");
|
|
39
|
+
var import__ = require("../index.js");
|
|
40
|
+
var import_errors = require("./errors.js");
|
|
41
|
+
var import_maps = require("./maps.js");
|
|
42
|
+
var import_results = require("./results.js");
|
|
43
|
+
var import_uuids = require("./uuids.js");
|
|
44
44
|
function createPromise(callback) {
|
|
45
45
|
let status = "pending";
|
|
46
46
|
let valueOrReason = void 0;
|
package/dist/utils/proxies.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(proxies_exports, {
|
|
|
24
24
|
logged: () => logged
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(proxies_exports);
|
|
27
|
-
var import_strings = require("./strings");
|
|
27
|
+
var import_strings = require("./strings.js");
|
|
28
28
|
function logged(name, toLog, options = {}) {
|
|
29
29
|
const proxy = new Proxy(toLog, {
|
|
30
30
|
get(target, prop, receiver) {
|
package/dist/utils/react.js
CHANGED
|
@@ -38,9 +38,9 @@ __export(react_exports, {
|
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(react_exports);
|
|
40
40
|
var import_react = __toESM(require("react"));
|
|
41
|
-
var import_env = require("./env");
|
|
42
|
-
var import_promises = require("./promises");
|
|
43
|
-
var import_strings = require("./strings");
|
|
41
|
+
var import_env = require("./env.js");
|
|
42
|
+
var import_promises = require("./promises.js");
|
|
43
|
+
var import_strings = require("./strings.js");
|
|
44
44
|
function forwardRefIfNeeded(render) {
|
|
45
45
|
const version = import_react.default.version;
|
|
46
46
|
const major = parseInt(version.split(".")[0]);
|
package/dist/utils/results.js
CHANGED
|
@@ -24,8 +24,8 @@ __export(results_exports, {
|
|
|
24
24
|
Result: () => Result
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(results_exports);
|
|
27
|
-
var import_promises = require("./promises");
|
|
28
|
-
var import_strings = require("./strings");
|
|
27
|
+
var import_promises = require("./promises.js");
|
|
28
|
+
var import_strings = require("./strings.js");
|
|
29
29
|
var Result = {
|
|
30
30
|
fromThrowing,
|
|
31
31
|
fromThrowingAsync,
|
package/dist/utils/stores.js
CHANGED
|
@@ -25,10 +25,10 @@ __export(stores_exports, {
|
|
|
25
25
|
storeLock: () => storeLock
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(stores_exports);
|
|
28
|
-
var import_locks = require("./locks");
|
|
29
|
-
var import_promises = require("./promises");
|
|
30
|
-
var import_results = require("./results");
|
|
31
|
-
var import_uuids = require("./uuids");
|
|
28
|
+
var import_locks = require("./locks.js");
|
|
29
|
+
var import_promises = require("./promises.js");
|
|
30
|
+
var import_results = require("./results.js");
|
|
31
|
+
var import_uuids = require("./uuids.js");
|
|
32
32
|
var Store = class {
|
|
33
33
|
constructor(_value) {
|
|
34
34
|
this._value = _value;
|
package/dist/utils/strings.js
CHANGED
|
@@ -39,9 +39,9 @@ __export(strings_exports, {
|
|
|
39
39
|
typedToUppercase: () => typedToUppercase
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(strings_exports);
|
|
42
|
-
var import_arrays = require("./arrays");
|
|
43
|
-
var import_errors = require("./errors");
|
|
44
|
-
var import_objects = require("./objects");
|
|
42
|
+
var import_arrays = require("./arrays.js");
|
|
43
|
+
var import_errors = require("./errors.js");
|
|
44
|
+
var import_objects = require("./objects.js");
|
|
45
45
|
function typedToLowercase(s) {
|
|
46
46
|
if (typeof s !== "string") throw new import_errors.StackAssertionError("Expected a string for typedToLowercase", { s });
|
|
47
47
|
return s.toLowerCase();
|
|
@@ -296,6 +296,9 @@ function nicifyPropertyString(str) {
|
|
|
296
296
|
function getNicifiableKeys(value) {
|
|
297
297
|
const overridden = ("getNicifiableKeys" in value ? value.getNicifiableKeys?.bind(value) : null)?.();
|
|
298
298
|
if (overridden != null) return overridden;
|
|
299
|
+
if (value instanceof Response) {
|
|
300
|
+
return ["status", "headers"];
|
|
301
|
+
}
|
|
299
302
|
const keys = Object.keys(value).sort();
|
|
300
303
|
return (0, import_arrays.unique)(keys);
|
|
301
304
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/strings.tsx"],"sourcesContent":["import { findLastIndex, unique } from \"./arrays\";\nimport { StackAssertionError } from \"./errors\";\nimport { filterUndefined } from \"./objects\";\n\nexport function typedToLowercase<S extends string>(s: S): Lowercase<S> {\n if (typeof s !== \"string\") throw new StackAssertionError(\"Expected a string for typedToLowercase\", { s });\n return s.toLowerCase() as Lowercase<S>;\n}\nundefined?.test(\"typedToLowercase\", ({ expect }) => {\n expect(typedToLowercase(\"\")).toBe(\"\");\n expect(typedToLowercase(\"HELLO\")).toBe(\"hello\");\n expect(typedToLowercase(\"Hello World\")).toBe(\"hello world\");\n expect(typedToLowercase(\"hello\")).toBe(\"hello\");\n expect(typedToLowercase(\"123\")).toBe(\"123\");\n expect(typedToLowercase(\"MIXED123case\")).toBe(\"mixed123case\");\n expect(typedToLowercase(\"Special@Chars!\")).toBe(\"special@chars!\");\n expect(() => typedToLowercase(123 as any)).toThrow(\"Expected a string for typedToLowercase\");\n});\n\nexport function typedToUppercase<S extends string>(s: S): Uppercase<S> {\n if (typeof s !== \"string\") throw new StackAssertionError(\"Expected a string for typedToUppercase\", { s });\n return s.toUpperCase() as Uppercase<S>;\n}\nundefined?.test(\"typedToUppercase\", ({ expect }) => {\n expect(typedToUppercase(\"\")).toBe(\"\");\n expect(typedToUppercase(\"hello\")).toBe(\"HELLO\");\n expect(typedToUppercase(\"Hello World\")).toBe(\"HELLO WORLD\");\n expect(typedToUppercase(\"HELLO\")).toBe(\"HELLO\");\n expect(typedToUppercase(\"123\")).toBe(\"123\");\n expect(typedToUppercase(\"mixed123Case\")).toBe(\"MIXED123CASE\");\n expect(typedToUppercase(\"special@chars!\")).toBe(\"SPECIAL@CHARS!\");\n expect(() => typedToUppercase(123 as any)).toThrow(\"Expected a string for typedToUppercase\");\n});\n\nexport function typedCapitalize<S extends string>(s: S): Capitalize<S> {\n return s.charAt(0).toUpperCase() + s.slice(1) as Capitalize<S>;\n}\nundefined?.test(\"typedCapitalize\", ({ expect }) => {\n expect(typedCapitalize(\"\")).toBe(\"\");\n expect(typedCapitalize(\"hello\")).toBe(\"Hello\");\n expect(typedCapitalize(\"hello world\")).toBe(\"Hello world\");\n expect(typedCapitalize(\"HELLO\")).toBe(\"HELLO\");\n expect(typedCapitalize(\"123test\")).toBe(\"123test\");\n expect(typedCapitalize(\"already Capitalized\")).toBe(\"Already Capitalized\");\n expect(typedCapitalize(\"h\")).toBe(\"H\");\n});\n\n/**\n * Compares two strings in a way that is not dependent on the current locale.\n */\nexport function stringCompare(a: string, b: string): number {\n if (typeof a !== \"string\" || typeof b !== \"string\") throw new StackAssertionError(`Expected two strings for stringCompare, found ${typeof a} and ${typeof b}`, { a, b });\n const cmp = (a: string, b: string) => a < b ? -1 : a > b ? 1 : 0;\n return cmp(a.toUpperCase(), b.toUpperCase()) || cmp(b, a);\n}\nundefined?.test(\"stringCompare\", ({ expect }) => {\n // Equal strings\n expect(stringCompare(\"a\", \"a\")).toBe(0);\n expect(stringCompare(\"\", \"\")).toBe(0);\n\n // Case comparison - note that this function is NOT case-insensitive\n // It compares uppercase versions first, then original strings\n expect(stringCompare(\"a\", \"A\")).toBe(-1); // lowercase comes after uppercase\n expect(stringCompare(\"A\", \"a\")).toBe(1); // uppercase comes before lowercase\n expect(stringCompare(\"abc\", \"ABC\")).toBe(-1);\n expect(stringCompare(\"ABC\", \"abc\")).toBe(1);\n\n // Different strings\n expect(stringCompare(\"a\", \"b\")).toBe(-1);\n expect(stringCompare(\"b\", \"a\")).toBe(1);\n\n // Strings with different lengths\n expect(stringCompare(\"abc\", \"abcd\")).toBe(-1);\n expect(stringCompare(\"abcd\", \"abc\")).toBe(1);\n\n // Strings with numbers\n expect(stringCompare(\"a1\", \"a2\")).toBe(-1);\n expect(stringCompare(\"a10\", \"a2\")).toBe(-1);\n\n // Strings with special characters\n expect(stringCompare(\"a\", \"a!\")).toBe(-1);\n expect(stringCompare(\"a!\", \"a\")).toBe(1);\n});\n\n/**\n * Returns all whitespace character at the start of the string.\n *\n * Uses the same definition for whitespace as `String.prototype.trim()`.\n */\nexport function getWhitespacePrefix(s: string): string {\n return s.substring(0, s.length - s.trimStart().length);\n}\nundefined?.test(\"getWhitespacePrefix\", ({ expect }) => {\n expect(getWhitespacePrefix(\"\")).toBe(\"\");\n expect(getWhitespacePrefix(\"hello\")).toBe(\"\");\n expect(getWhitespacePrefix(\" hello\")).toBe(\" \");\n expect(getWhitespacePrefix(\" hello\")).toBe(\" \");\n expect(getWhitespacePrefix(\"\\thello\")).toBe(\"\\t\");\n expect(getWhitespacePrefix(\"\\n hello\")).toBe(\"\\n \");\n expect(getWhitespacePrefix(\" \")).toBe(\" \");\n expect(getWhitespacePrefix(\" \\t\\n\\r\")).toBe(\" \\t\\n\\r\");\n});\n\n/**\n * Returns all whitespace character at the end of the string.\n *\n * Uses the same definition for whitespace as `String.prototype.trim()`.\n */\nexport function getWhitespaceSuffix(s: string): string {\n return s.substring(s.trimEnd().length);\n}\nundefined?.test(\"getWhitespaceSuffix\", ({ expect }) => {\n expect(getWhitespaceSuffix(\"\")).toBe(\"\");\n expect(getWhitespaceSuffix(\"hello\")).toBe(\"\");\n expect(getWhitespaceSuffix(\"hello \")).toBe(\" \");\n expect(getWhitespaceSuffix(\"hello \")).toBe(\" \");\n expect(getWhitespaceSuffix(\"hello\\t\")).toBe(\"\\t\");\n expect(getWhitespaceSuffix(\"hello \\n\")).toBe(\" \\n\");\n expect(getWhitespaceSuffix(\" \")).toBe(\" \");\n expect(getWhitespaceSuffix(\" \\t\\n\\r\")).toBe(\" \\t\\n\\r\");\n});\n\n/**\n * Returns a string with all empty or whitespace-only lines at the start removed.\n *\n * Uses the same definition for whitespace as `String.prototype.trim()`.\n */\nexport function trimEmptyLinesStart(s: string): string {\n const lines = s.split(\"\\n\");\n const firstNonEmptyLineIndex = lines.findIndex((line) => line.trim() !== \"\");\n // If all lines are empty or whitespace-only, return an empty string\n if (firstNonEmptyLineIndex === -1) return \"\";\n return lines.slice(firstNonEmptyLineIndex).join(\"\\n\");\n}\nundefined?.test(\"trimEmptyLinesStart\", ({ expect }) => {\n expect(trimEmptyLinesStart(\"\")).toBe(\"\");\n expect(trimEmptyLinesStart(\"hello\")).toBe(\"hello\");\n expect(trimEmptyLinesStart(\"\\nhello\")).toBe(\"hello\");\n expect(trimEmptyLinesStart(\"\\n\\nhello\")).toBe(\"hello\");\n expect(trimEmptyLinesStart(\" \\n\\t\\nhello\")).toBe(\"hello\");\n expect(trimEmptyLinesStart(\"\\n\\nhello\\nworld\")).toBe(\"hello\\nworld\");\n expect(trimEmptyLinesStart(\"hello\\n\\nworld\")).toBe(\"hello\\n\\nworld\");\n expect(trimEmptyLinesStart(\"hello\\nworld\\n\")).toBe(\"hello\\nworld\\n\");\n expect(trimEmptyLinesStart(\"\\n \\n\\nhello\\n \\nworld\")).toBe(\"hello\\n \\nworld\");\n // Edge case: all lines are empty\n expect(trimEmptyLinesStart(\"\\n\\n \\n\\t\")).toBe(\"\");\n});\n\n/**\n * Returns a string with all empty or whitespace-only lines at the end removed.\n *\n * Uses the same definition for whitespace as `String.prototype.trim()`.\n */\nexport function trimEmptyLinesEnd(s: string): string {\n const lines = s.split(\"\\n\");\n const lastNonEmptyLineIndex = findLastIndex(lines, (line) => line.trim() !== \"\");\n return lines.slice(0, lastNonEmptyLineIndex + 1).join(\"\\n\");\n}\nundefined?.test(\"trimEmptyLinesEnd\", ({ expect }) => {\n expect(trimEmptyLinesEnd(\"\")).toBe(\"\");\n expect(trimEmptyLinesEnd(\"hello\")).toBe(\"hello\");\n expect(trimEmptyLinesEnd(\"hello\\n\")).toBe(\"hello\");\n expect(trimEmptyLinesEnd(\"hello\\n\\n\")).toBe(\"hello\");\n expect(trimEmptyLinesEnd(\"hello\\n \\n\\t\")).toBe(\"hello\");\n expect(trimEmptyLinesEnd(\"hello\\nworld\\n\\n\")).toBe(\"hello\\nworld\");\n expect(trimEmptyLinesEnd(\"hello\\n\\nworld\")).toBe(\"hello\\n\\nworld\");\n expect(trimEmptyLinesEnd(\"\\nhello\\nworld\")).toBe(\"\\nhello\\nworld\");\n expect(trimEmptyLinesEnd(\"hello\\n \\nworld\\n\\n \")).toBe(\"hello\\n \\nworld\");\n // Edge case: all lines are empty\n expect(trimEmptyLinesEnd(\"\\n\\n \\n\\t\")).toBe(\"\");\n});\n\n/**\n * Returns a string with all empty or whitespace-only lines trimmed at the start and end.\n *\n * Uses the same definition for whitespace as `String.prototype.trim()`.\n */\nexport function trimLines(s: string): string {\n return trimEmptyLinesEnd(trimEmptyLinesStart(s));\n}\nundefined?.test(\"trimLines\", ({ expect }) => {\n expect(trimLines(\"\")).toBe(\"\");\n expect(trimLines(\" \")).toBe(\"\");\n expect(trimLines(\" \\n \")).toBe(\"\");\n expect(trimLines(\" abc \")).toBe(\" abc \");\n expect(trimLines(\"\\n \\nLine1\\nLine2\\n \\n\")).toBe(\"Line1\\nLine2\");\n expect(trimLines(\"Line1\\n \\nLine2\")).toBe(\"Line1\\n \\nLine2\");\n expect(trimLines(\" \\n \\n\\t\")).toBe(\"\");\n expect(trimLines(\" Hello World\")).toBe(\" Hello World\");\n expect(trimLines(\"\\n\")).toBe(\"\");\n expect(trimLines(\"\\t \\n\\t\\tLine1 \\n \\nLine2\\t\\t\\n\\t \")).toBe(\"\\t\\tLine1 \\n \\nLine2\\t\\t\");\n});\n\n\n/**\n * A template literal tag that returns the same string as the template literal without a tag.\n *\n * Useful for implementing your own template literal tags.\n */\nexport function templateIdentity(strings: TemplateStringsArray | readonly string[], ...values: string[]): string {\n if (values.length !== strings.length - 1) throw new StackAssertionError(\"Invalid number of values; must be one less than strings\", { strings, values });\n\n return strings.reduce((result, str, i) => result + str + (values[i] ?? ''), '');\n}\nundefined?.test(\"templateIdentity\", ({ expect }) => {\n expect(templateIdentity`Hello World`).toBe(\"Hello World\");\n expect(templateIdentity`${\"Hello\"}`).toBe(\"Hello\");\n const greeting = \"Hello\";\n const subject = \"World\";\n expect(templateIdentity`${greeting}, ${subject}!`).toBe(\"Hello, World!\");\n expect(templateIdentity`${\"A\"}${\"B\"}${\"C\"}`).toBe(\"ABC\");\n expect(templateIdentity`Start${\"\"}Middle${\"\"}End`).toBe(\"StartMiddleEnd\");\n expect(templateIdentity``).toBe(\"\");\n expect(templateIdentity`Line1\nLine2`).toBe(\"Line1\\nLine2\");\n expect(templateIdentity([\"a \", \" scientific \", \"gun\"], \"certain\", \"rail\")).toBe(\"a certain scientific railgun\");\n expect(templateIdentity([\"only one part\"])).toBe(\"only one part\");\n expect(() => templateIdentity([\"a \", \"b\", \"c\"], \"only one\")).toThrow(\"Invalid number of values\");\n expect(() => templateIdentity([\"a\", \"b\"], \"x\", \"y\")).toThrow(\"Invalid number of values\");\n});\n\n\nexport function deindent(code: string): string;\nexport function deindent(strings: TemplateStringsArray | readonly string[], ...values: any[]): string;\nexport function deindent(strings: string | readonly string[], ...values: any[]): string {\n if (typeof strings === \"string\") return deindent([strings]);\n return templateIdentity(...deindentTemplate(strings, ...values));\n}\n\nexport function deindentTemplate(strings: TemplateStringsArray | readonly string[], ...values: any[]): [string[], ...string[]] {\n if (values.length !== strings.length - 1) throw new StackAssertionError(\"Invalid number of values; must be one less than strings\", { strings, values });\n\n const trimmedStrings = [...strings];\n trimmedStrings[0] = trimEmptyLinesStart(trimmedStrings[0] + \"+\").slice(0, -1);\n trimmedStrings[trimmedStrings.length - 1] = trimEmptyLinesEnd(\"+\" + trimmedStrings[trimmedStrings.length - 1]).slice(1);\n\n const indentation = trimmedStrings\n .join(\"${SOME_VALUE}\")\n .split(\"\\n\")\n .filter((line) => line.trim() !== \"\")\n .map((line) => getWhitespacePrefix(line).length)\n .reduce((min, current) => Math.min(min, current), Infinity);\n\n const deindentedStrings = trimmedStrings\n .map((string, stringIndex) => {\n return string\n .split(\"\\n\")\n .map((line, lineIndex) => stringIndex !== 0 && lineIndex === 0 ? line : line.substring(indentation))\n .join(\"\\n\");\n });\n\n const indentedValues = values.map((value, i) => {\n const firstLineIndentation = getWhitespacePrefix(deindentedStrings[i].split(\"\\n\").at(-1)!);\n return `${value}`.replaceAll(\"\\n\", `\\n${firstLineIndentation}`);\n });\n\n return [deindentedStrings, ...indentedValues];\n}\nundefined?.test(\"deindent\", ({ expect }) => {\n // Test with string input\n expect(deindent(\" hello\")).toBe(\"hello\");\n expect(deindent(\" hello\\n world\")).toBe(\"hello\\nworld\");\n expect(deindent(\" hello\\n world\")).toBe(\"hello\\n world\");\n expect(deindent(\"\\n hello\\n world\\n\")).toBe(\"hello\\nworld\");\n\n // Test with empty input\n expect(deindent(\"\")).toBe(\"\");\n\n // Test with template literal\n expect(deindent`\n hello\n world\n `).toBe(\"hello\\nworld\");\n\n expect(deindent`\n hello\n world\n `).toBe(\"hello\\n world\");\n\n // Test with values\n const value = \"test\";\n expect(deindent`\n hello ${value}\n world\n `).toBe(`hello ${value}\\nworld`);\n\n // Test with multiline values\n expect(deindent`\n hello\n to ${\"line1\\n line2\"}\n world\n `).toBe(`hello\\n to line1\\n line2\\nworld`);\n\n // Leading whitespace values\n expect(deindent`\n ${\" \"}A\n ${\" \"}B\n ${\" \"}C\n `).toBe(` A\\n B\\n C`);\n\n // Trailing whitespaces (note: there are two whitespaces each after A and after C)\n expect(deindent`\n A \n B ${\" \"}\n C \n `).toBe(`A \\nB \\nC `);\n\n // Test with mixed indentation\n expect(deindent`\n hello\n world\n !\n `).toBe(\"hello\\n world\\n !\");\n\n // Test error cases\n expect(() => deindent([\"a\", \"b\", \"c\"], \"too\", \"many\", \"values\")).toThrow(\"Invalid number of values\");\n});\n\nexport function extractScopes(scope: string, removeDuplicates=true): string[] {\n // TODO what is this for? can we move this into the OAuth code in the backend?\n const trimmedString = scope.trim();\n const scopesArray = trimmedString.split(/\\s+/);\n const filtered = scopesArray.filter(scope => scope.length > 0);\n return removeDuplicates ? [...new Set(filtered)] : filtered;\n}\nundefined?.test(\"extractScopes\", ({ expect }) => {\n // Test with empty string\n expect(extractScopes(\"\")).toEqual([]);\n\n // Test with single scope\n expect(extractScopes(\"read\")).toEqual([\"read\"]);\n\n // Test with multiple scopes\n expect(extractScopes(\"read write\")).toEqual([\"read\", \"write\"]);\n\n // Test with extra whitespace\n expect(extractScopes(\" read write \")).toEqual([\"read\", \"write\"]);\n\n // Test with newlines and tabs\n expect(extractScopes(\"read\\nwrite\\tdelete\")).toEqual([\"read\", \"write\", \"delete\"]);\n\n // Test with duplicates (default behavior)\n expect(extractScopes(\"read write read\")).toEqual([\"read\", \"write\"]);\n\n // Test with duplicates (explicitly set to remove)\n expect(extractScopes(\"read write read\", true)).toEqual([\"read\", \"write\"]);\n\n // Test with duplicates (explicitly set to keep)\n expect(extractScopes(\"read write read\", false)).toEqual([\"read\", \"write\", \"read\"]);\n});\n\nexport function mergeScopeStrings(...scopes: string[]): string {\n // TODO what is this for? can we move this into the OAuth code in the backend?\n const allScope = scopes.map((s) => extractScopes(s)).flat().join(\" \");\n return extractScopes(allScope).join(\" \");\n}\nundefined?.test(\"mergeScopeStrings\", ({ expect }) => {\n // Test with empty input\n expect(mergeScopeStrings()).toBe(\"\");\n\n // Test with single scope string\n expect(mergeScopeStrings(\"read write\")).toBe(\"read write\");\n\n // Test with multiple scope strings\n expect(mergeScopeStrings(\"read\", \"write\")).toBe(\"read write\");\n\n // Test with overlapping scopes\n expect(mergeScopeStrings(\"read write\", \"write delete\")).toBe(\"read write delete\");\n\n // Test with extra whitespace\n expect(mergeScopeStrings(\" read write \", \" delete \")).toBe(\"read write delete\");\n\n // Test with duplicates across strings\n expect(mergeScopeStrings(\"read write\", \"write delete\", \"read\")).toBe(\"read write delete\");\n\n // Test with empty strings\n expect(mergeScopeStrings(\"read write\", \"\", \"delete\")).toBe(\"read write delete\");\n});\n\nexport function escapeTemplateLiteral(s: string): string {\n return s.replaceAll(\"`\", \"\\\\`\").replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll(\"$\", \"\\\\$\");\n}\nundefined?.test(\"escapeTemplateLiteral\", ({ expect }) => {\n // Test with empty string\n expect(escapeTemplateLiteral(\"\")).toBe(\"\");\n\n // Test with normal string (no special characters)\n expect(escapeTemplateLiteral(\"hello world\")).toBe(\"hello world\");\n\n // Test with backtick\n const input1 = \"hello `world`\";\n const output1 = escapeTemplateLiteral(input1);\n // Verify backticks are escaped\n expect(output1.includes(\"\\\\`\")).toBe(true);\n expect(output1).not.toBe(input1);\n\n // Test with backslash\n const input2 = \"hello \\\\world\";\n const output2 = escapeTemplateLiteral(input2);\n // Verify backslashes are escaped\n expect(output2.includes(\"\\\\\\\\\")).toBe(true);\n expect(output2).not.toBe(input2);\n\n // Test with dollar sign\n const input3 = \"hello $world\";\n const output3 = escapeTemplateLiteral(input3);\n // Verify dollar signs are escaped\n expect(output3.includes(\"\\\\$\")).toBe(true);\n expect(output3).not.toBe(input3);\n\n // Test with multiple special characters\n const input4 = \"`hello` $world\\\\\";\n const output4 = escapeTemplateLiteral(input4);\n // Verify all special characters are escaped\n expect(output4.includes(\"\\\\`\")).toBe(true);\n expect(output4.includes(\"\\\\$\")).toBe(true);\n expect(output4.includes(\"\\\\\\\\\")).toBe(true);\n expect(output4).not.toBe(input4);\n\n // Test with already escaped characters\n const input5 = \"\\\\`hello\\\\`\";\n const output5 = escapeTemplateLiteral(input5);\n // Verify already escaped characters are properly escaped\n expect(output5).not.toBe(input5);\n});\n\n/**\n * Some classes have different constructor names in different environments (eg. `Headers` is sometimes called `_Headers`,\n * so we create an object of overrides to handle these cases.\n */\nconst nicifiableClassNameOverrides = new Map(Object.entries({\n Headers,\n} as Record<string, unknown>).map(([k, v]) => [v, k]));\nexport type Nicifiable = {\n getNicifiableKeys?(): PropertyKey[],\n getNicifiedObjectExtraLines?(): string[],\n};\nexport type NicifyOptions = {\n maxDepth: number,\n currentIndent: string,\n lineIndent: string,\n multiline: boolean,\n refs: Map<unknown, string>,\n path: string,\n parent: null | {\n options: NicifyOptions,\n value: unknown,\n },\n keyInParent: PropertyKey | null,\n hideFields: PropertyKey[],\n overrides: (...args: Parameters<typeof nicify>) => string | null,\n};\nexport function nicify(\n value: unknown,\n options: Partial<NicifyOptions> = {},\n): string {\n const fullOptions: NicifyOptions = {\n maxDepth: 5,\n currentIndent: \"\",\n lineIndent: \" \",\n multiline: true,\n refs: new Map(),\n path: \"value\",\n parent: null,\n overrides: () => null,\n keyInParent: null,\n hideFields: [],\n ...filterUndefined(options),\n };\n const {\n maxDepth,\n currentIndent,\n lineIndent,\n multiline,\n refs,\n path,\n overrides,\n hideFields,\n } = fullOptions;\n const nl = `\\n${currentIndent}`;\n\n const overrideResult = overrides(value, options);\n if (overrideResult !== null) return overrideResult;\n\n if ([\"function\", \"object\", \"symbol\"].includes(typeof value) && value !== null) {\n if (refs.has(value)) {\n return `Ref<${refs.get(value)}>`;\n }\n refs.set(value, path);\n }\n\n const newOptions: NicifyOptions = {\n maxDepth: maxDepth - 1,\n currentIndent,\n lineIndent,\n multiline,\n refs,\n path: path + \"->[unknown property]\",\n overrides,\n parent: { value, options: fullOptions },\n keyInParent: null,\n hideFields: [],\n };\n const nestedNicify = (newValue: unknown, newPath: string, keyInParent: PropertyKey | null, options: Partial<NicifyOptions> = {}) => {\n return nicify(newValue, {\n ...newOptions,\n path: newPath,\n currentIndent: currentIndent + lineIndent,\n keyInParent,\n ...options,\n });\n };\n\n switch (typeof value) {\n case \"boolean\": case \"number\": {\n return JSON.stringify(value);\n }\n case \"string\": {\n const isDeindentable = (v: string) => deindent(v) === v && v.includes(\"\\n\");\n const wrapInDeindent = (v: string) => deindent`\n deindent\\`\n ${currentIndent + lineIndent}${escapeTemplateLiteral(v).replaceAll(\"\\n\", nl + lineIndent)}\n ${currentIndent}\\`\n `;\n if (isDeindentable(value)) {\n return wrapInDeindent(value);\n } else if (value.endsWith(\"\\n\") && isDeindentable(value.slice(0, -1))) {\n return wrapInDeindent(value.slice(0, -1)) + ' + \"\\\\n\"';\n } else {\n return JSON.stringify(value);\n }\n }\n case \"undefined\": {\n return \"undefined\";\n }\n case \"symbol\": {\n return value.toString();\n }\n case \"bigint\": {\n return `${value}n`;\n }\n case \"function\": {\n if (value.name) return `function ${value.name}(...) { ... }`;\n return `(...) => { ... }`;\n }\n case \"object\": {\n if (value === null) return \"null\";\n if (Array.isArray(value)) {\n const extraLines = getNicifiedObjectExtraLines(value);\n const resValueLength = value.length + extraLines.length;\n if (maxDepth <= 0 && resValueLength === 0) return \"[...]\";\n const resValues = value.map((v, i) => nestedNicify(v, `${path}[${i}]`, i));\n resValues.push(...extraLines);\n if (resValues.length !== resValueLength) throw new StackAssertionError(\"nicify of object: resValues.length !== resValueLength\", { value, resValues, resValueLength });\n const shouldIndent = resValues.length > 4 || resValues.some(x => (resValues.length > 1 && x.length > 4) || x.includes(\"\\n\"));\n if (shouldIndent) {\n return `[${nl}${resValues.map(x => `${lineIndent}${x},${nl}`).join(\"\")}]`;\n } else {\n return `[${resValues.join(\", \")}]`;\n }\n }\n if (value instanceof URL) {\n return `URL(${nestedNicify(value.toString(), `${path}.toString()`, null)})`;\n }\n if (ArrayBuffer.isView(value)) {\n return `${value.constructor.name}([${value.toString()}])`;\n }\n if (value instanceof Error) {\n let stack = value.stack ?? \"\";\n const toString = value.toString();\n if (!stack.startsWith(toString)) stack = `${toString}\\n${stack}`; // some browsers don't include the error message in the stack, some do\n stack = stack.trimEnd();\n stack = stack.replace(/\\n\\s+/g, `\\n${lineIndent}${lineIndent}`);\n stack = stack.replace(\"\\n\", `\\n${lineIndent}Stack:\\n`);\n if (Object.keys(value).length > 0) {\n stack += `\\n${lineIndent}Extra properties: ${nestedNicify(Object.fromEntries(Object.entries(value)), path, null)}`;\n }\n if (value.cause) {\n stack += `\\n${lineIndent}Cause:\\n${lineIndent}${lineIndent}${nestedNicify(value.cause, path, null, { currentIndent: currentIndent + lineIndent + lineIndent })}`;\n }\n stack = stack.replaceAll(\"\\n\", `\\n${currentIndent}`);\n return stack;\n }\n\n const constructorName = [null, Object.prototype].includes(Object.getPrototypeOf(value)) ? null : (nicifiableClassNameOverrides.get(value.constructor) ?? value.constructor.name);\n const constructorString = constructorName ? `${constructorName} ` : \"\";\n\n const entries = getNicifiableEntries(value).filter(([k]) => !hideFields.includes(k));\n const extraLines = [\n ...getNicifiedObjectExtraLines(value),\n ...hideFields.length > 0 ? [`<some fields may have been hidden>`] : [],\n ];\n const resValueLength = entries.length + extraLines.length;\n if (resValueLength === 0) return `${constructorString}{}`;\n if (maxDepth <= 0) return `${constructorString}{ ... }`;\n const resValues = entries.map(([k, v], keyIndex) => {\n const keyNicified = nestedNicify(k, `Object.keys(${path})[${keyIndex}]`, null);\n const keyInObjectLiteral = typeof k === \"string\" ? nicifyPropertyString(k) : `[${keyNicified}]`;\n if (typeof v === \"function\" && v.name === k) {\n return `${keyInObjectLiteral}(...): { ... }`;\n } else {\n return `${keyInObjectLiteral}: ${nestedNicify(v, `${path}[${keyNicified}]`, k)}`;\n }\n });\n resValues.push(...extraLines);\n if (resValues.length !== resValueLength) throw new StackAssertionError(\"nicify of object: resValues.length !== resValueLength\", { value, resValues, resValueLength });\n const shouldIndent = resValues.length > 1 || resValues.some(x => x.includes(\"\\n\"));\n\n if (resValues.length === 0) return `${constructorString}{}`;\n if (shouldIndent) {\n return `${constructorString}{${nl}${resValues.map(x => `${lineIndent}${x},${nl}`).join(\"\")}}`;\n } else {\n return `${constructorString}{ ${resValues.join(\", \")} }`;\n }\n }\n default: {\n return `${typeof value}<${value}>`;\n }\n }\n}\n\nexport function replaceAll(input: string, searchValue: string, replaceValue: string): string {\n if (searchValue === \"\") throw new StackAssertionError(\"replaceAll: searchValue is empty\");\n return input.split(searchValue).join(replaceValue);\n}\nundefined?.test(\"replaceAll\", ({ expect }) => {\n expect(replaceAll(\"hello world\", \"o\", \"x\")).toBe(\"hellx wxrld\");\n expect(replaceAll(\"aaa\", \"a\", \"b\")).toBe(\"bbb\");\n expect(replaceAll(\"\", \"a\", \"b\")).toBe(\"\");\n expect(replaceAll(\"abc\", \"b\", \"\")).toBe(\"ac\");\n expect(replaceAll(\"test.test.test\", \".\", \"_\")).toBe(\"test_test_test\");\n expect(replaceAll(\"a.b*c\", \".\", \"x\")).toBe(\"axb*c\");\n expect(replaceAll(\"a*b*c\", \"*\", \"x\")).toBe(\"axbxc\");\n expect(replaceAll(\"hello hello\", \"hello\", \"hi\")).toBe(\"hi hi\");\n});\n\nfunction nicifyPropertyString(str: string) {\n return JSON.stringify(str);\n}\nundefined?.test(\"nicifyPropertyString\", ({ expect }) => {\n // Test valid identifiers\n expect(nicifyPropertyString(\"validName\")).toBe('\"validName\"');\n expect(nicifyPropertyString(\"_validName\")).toBe('\"_validName\"');\n expect(nicifyPropertyString(\"valid123Name\")).toBe('\"valid123Name\"');\n\n // Test invalid identifiers\n expect(nicifyPropertyString(\"123invalid\")).toBe('\"123invalid\"');\n expect(nicifyPropertyString(\"invalid-name\")).toBe('\"invalid-name\"');\n expect(nicifyPropertyString(\"invalid space\")).toBe('\"invalid space\"');\n expect(nicifyPropertyString(\"$invalid\")).toBe('\"$invalid\"');\n expect(nicifyPropertyString(\"\")).toBe('\"\"');\n\n // Test with special characters\n expect(nicifyPropertyString(\"property!\")).toBe('\"property!\"');\n expect(nicifyPropertyString(\"property.name\")).toBe('\"property.name\"');\n\n // Test with escaped characters\n expect(nicifyPropertyString(\"\\\\\")).toBe('\"\\\\\\\\\"');\n expect(nicifyPropertyString('\"')).toBe('\"\\\\\"\"');\n});\n\nfunction getNicifiableKeys(value: Nicifiable | object) {\n const overridden = (\"getNicifiableKeys\" in value ? value.getNicifiableKeys?.bind(value) : null)?.();\n if (overridden != null) return overridden;\n const keys = Object.keys(value).sort();\n return unique(keys);\n}\nundefined?.test(\"getNicifiableKeys\", ({ expect }) => {\n // Test regular object\n expect(getNicifiableKeys({ b: 1, a: 2, c: 3 })).toEqual([\"a\", \"b\", \"c\"]);\n\n // Test empty object\n expect(getNicifiableKeys({})).toEqual([]);\n\n // Test object with custom getNicifiableKeys\n const customObject = {\n a: 1,\n b: 2,\n getNicifiableKeys() {\n return [\"customKey1\", \"customKey2\"];\n }\n };\n expect(getNicifiableKeys(customObject)).toEqual([\"customKey1\", \"customKey2\"]);\n});\n\nfunction getNicifiableEntries(value: Nicifiable | object): [PropertyKey, unknown][] {\n const recordLikes = [Headers];\n function isRecordLike(value: unknown): value is InstanceType<typeof recordLikes[number]> {\n return recordLikes.some(x => value instanceof x);\n }\n\n if (isRecordLike(value)) {\n return [...value.entries()].sort(([a], [b]) => stringCompare(`${a}`, `${b}`));\n }\n const keys = getNicifiableKeys(value);\n return keys.map((k) => [k, value[k as never]] as [PropertyKey, unknown]);\n}\n\nfunction getNicifiedObjectExtraLines(value: Nicifiable | object) {\n return (\"getNicifiedObjectExtraLines\" in value ? value.getNicifiedObjectExtraLines : null)?.() ?? [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAsC;AACtC,oBAAoC;AACpC,qBAAgC;AAEzB,SAAS,iBAAmC,GAAoB;AACrE,MAAI,OAAO,MAAM,SAAU,OAAM,IAAI,kCAAoB,0CAA0C,EAAE,EAAE,CAAC;AACxG,SAAO,EAAE,YAAY;AACvB;AAYO,SAAS,iBAAmC,GAAoB;AACrE,MAAI,OAAO,MAAM,SAAU,OAAM,IAAI,kCAAoB,0CAA0C,EAAE,EAAE,CAAC;AACxG,SAAO,EAAE,YAAY;AACvB;AAYO,SAAS,gBAAkC,GAAqB;AACrE,SAAO,EAAE,OAAO,CAAC,EAAE,YAAY,IAAI,EAAE,MAAM,CAAC;AAC9C;AAcO,SAAS,cAAc,GAAW,GAAmB;AAC1D,MAAI,OAAO,MAAM,YAAY,OAAO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,KAAa;AACzC,SAAO,KAAK,UAAU,GAAG;AAC3B;AAuBA,SAAS,kBAAkB,OAA4B;AACrD,QAAM,cAAc,uBAAuB,QAAQ,MAAM,mBAAmB,KAAK,KAAK,IAAI,QAAQ;AAClG,MAAI,cAAc,KAAM,QAAO;AAC/B,QAAM,OAAO,OAAO,KAAK,KAAK,EAAE,KAAK;AACrC,aAAO,sBAAO,IAAI;AACpB;AAmBA,SAAS,qBAAqB,OAAsD;AAClF,QAAM,cAAc,CAAC,OAAO;AAC5B,WAAS,aAAaE,QAAmE;AACvF,WAAO,YAAY,KAAK,OAAKA,kBAAiB,CAAC;AAAA,EACjD;AAEA,MAAI,aAAa,KAAK,GAAG;AACvB,WAAO,CAAC,GAAG,MAAM,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,cAAc,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;AAAA,EAC9E;AACA,QAAM,OAAO,kBAAkB,KAAK;AACpC,SAAO,KAAK,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAU,CAAC,CAA2B;AACzE;AAEA,SAAS,4BAA4B,OAA4B;AAC/D,UAAQ,iCAAiC,QAAQ,MAAM,8BAA8B,QAAQ,KAAK,CAAC;AACrG;","names":["a","b","scope","options","extraLines","resValueLength","resValues","shouldIndent","value"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/strings.tsx"],"sourcesContent":["import { findLastIndex, unique } from \"./arrays\";\nimport { StackAssertionError } from \"./errors\";\nimport { filterUndefined } from \"./objects\";\n\nexport function typedToLowercase<S extends string>(s: S): Lowercase<S> {\n if (typeof s !== \"string\") throw new StackAssertionError(\"Expected a string for typedToLowercase\", { s });\n return s.toLowerCase() as Lowercase<S>;\n}\nundefined?.test(\"typedToLowercase\", ({ expect }) => {\n expect(typedToLowercase(\"\")).toBe(\"\");\n expect(typedToLowercase(\"HELLO\")).toBe(\"hello\");\n expect(typedToLowercase(\"Hello World\")).toBe(\"hello world\");\n expect(typedToLowercase(\"hello\")).toBe(\"hello\");\n expect(typedToLowercase(\"123\")).toBe(\"123\");\n expect(typedToLowercase(\"MIXED123case\")).toBe(\"mixed123case\");\n expect(typedToLowercase(\"Special@Chars!\")).toBe(\"special@chars!\");\n expect(() => typedToLowercase(123 as any)).toThrow(\"Expected a string for typedToLowercase\");\n});\n\nexport function typedToUppercase<S extends string>(s: S): Uppercase<S> {\n if (typeof s !== \"string\") throw new StackAssertionError(\"Expected a string for typedToUppercase\", { s });\n return s.toUpperCase() as Uppercase<S>;\n}\nundefined?.test(\"typedToUppercase\", ({ expect }) => {\n expect(typedToUppercase(\"\")).toBe(\"\");\n expect(typedToUppercase(\"hello\")).toBe(\"HELLO\");\n expect(typedToUppercase(\"Hello World\")).toBe(\"HELLO WORLD\");\n expect(typedToUppercase(\"HELLO\")).toBe(\"HELLO\");\n expect(typedToUppercase(\"123\")).toBe(\"123\");\n expect(typedToUppercase(\"mixed123Case\")).toBe(\"MIXED123CASE\");\n expect(typedToUppercase(\"special@chars!\")).toBe(\"SPECIAL@CHARS!\");\n expect(() => typedToUppercase(123 as any)).toThrow(\"Expected a string for typedToUppercase\");\n});\n\nexport function typedCapitalize<S extends string>(s: S): Capitalize<S> {\n return s.charAt(0).toUpperCase() + s.slice(1) as Capitalize<S>;\n}\nundefined?.test(\"typedCapitalize\", ({ expect }) => {\n expect(typedCapitalize(\"\")).toBe(\"\");\n expect(typedCapitalize(\"hello\")).toBe(\"Hello\");\n expect(typedCapitalize(\"hello world\")).toBe(\"Hello world\");\n expect(typedCapitalize(\"HELLO\")).toBe(\"HELLO\");\n expect(typedCapitalize(\"123test\")).toBe(\"123test\");\n expect(typedCapitalize(\"already Capitalized\")).toBe(\"Already Capitalized\");\n expect(typedCapitalize(\"h\")).toBe(\"H\");\n});\n\n/**\n * Compares two strings in a way that is not dependent on the current locale.\n */\nexport function stringCompare(a: string, b: string): number {\n if (typeof a !== \"string\" || typeof b !== \"string\") throw new StackAssertionError(`Expected two strings for stringCompare, found ${typeof a} and ${typeof b}`, { a, b });\n const cmp = (a: string, b: string) => a < b ? -1 : a > b ? 1 : 0;\n return cmp(a.toUpperCase(), b.toUpperCase()) || cmp(b, a);\n}\nundefined?.test(\"stringCompare\", ({ expect }) => {\n // Equal strings\n expect(stringCompare(\"a\", \"a\")).toBe(0);\n expect(stringCompare(\"\", \"\")).toBe(0);\n\n // Case comparison - note that this function is NOT case-insensitive\n // It compares uppercase versions first, then original strings\n expect(stringCompare(\"a\", \"A\")).toBe(-1); // lowercase comes after uppercase\n expect(stringCompare(\"A\", \"a\")).toBe(1); // uppercase comes before lowercase\n expect(stringCompare(\"abc\", \"ABC\")).toBe(-1);\n expect(stringCompare(\"ABC\", \"abc\")).toBe(1);\n\n // Different strings\n expect(stringCompare(\"a\", \"b\")).toBe(-1);\n expect(stringCompare(\"b\", \"a\")).toBe(1);\n\n // Strings with different lengths\n expect(stringCompare(\"abc\", \"abcd\")).toBe(-1);\n expect(stringCompare(\"abcd\", \"abc\")).toBe(1);\n\n // Strings with numbers\n expect(stringCompare(\"a1\", \"a2\")).toBe(-1);\n expect(stringCompare(\"a10\", \"a2\")).toBe(-1);\n\n // Strings with special characters\n expect(stringCompare(\"a\", \"a!\")).toBe(-1);\n expect(stringCompare(\"a!\", \"a\")).toBe(1);\n});\n\n/**\n * Returns all whitespace character at the start of the string.\n *\n * Uses the same definition for whitespace as `String.prototype.trim()`.\n */\nexport function getWhitespacePrefix(s: string): string {\n return s.substring(0, s.length - s.trimStart().length);\n}\nundefined?.test(\"getWhitespacePrefix\", ({ expect }) => {\n expect(getWhitespacePrefix(\"\")).toBe(\"\");\n expect(getWhitespacePrefix(\"hello\")).toBe(\"\");\n expect(getWhitespacePrefix(\" hello\")).toBe(\" \");\n expect(getWhitespacePrefix(\" hello\")).toBe(\" \");\n expect(getWhitespacePrefix(\"\\thello\")).toBe(\"\\t\");\n expect(getWhitespacePrefix(\"\\n hello\")).toBe(\"\\n \");\n expect(getWhitespacePrefix(\" \")).toBe(\" \");\n expect(getWhitespacePrefix(\" \\t\\n\\r\")).toBe(\" \\t\\n\\r\");\n});\n\n/**\n * Returns all whitespace character at the end of the string.\n *\n * Uses the same definition for whitespace as `String.prototype.trim()`.\n */\nexport function getWhitespaceSuffix(s: string): string {\n return s.substring(s.trimEnd().length);\n}\nundefined?.test(\"getWhitespaceSuffix\", ({ expect }) => {\n expect(getWhitespaceSuffix(\"\")).toBe(\"\");\n expect(getWhitespaceSuffix(\"hello\")).toBe(\"\");\n expect(getWhitespaceSuffix(\"hello \")).toBe(\" \");\n expect(getWhitespaceSuffix(\"hello \")).toBe(\" \");\n expect(getWhitespaceSuffix(\"hello\\t\")).toBe(\"\\t\");\n expect(getWhitespaceSuffix(\"hello \\n\")).toBe(\" \\n\");\n expect(getWhitespaceSuffix(\" \")).toBe(\" \");\n expect(getWhitespaceSuffix(\" \\t\\n\\r\")).toBe(\" \\t\\n\\r\");\n});\n\n/**\n * Returns a string with all empty or whitespace-only lines at the start removed.\n *\n * Uses the same definition for whitespace as `String.prototype.trim()`.\n */\nexport function trimEmptyLinesStart(s: string): string {\n const lines = s.split(\"\\n\");\n const firstNonEmptyLineIndex = lines.findIndex((line) => line.trim() !== \"\");\n // If all lines are empty or whitespace-only, return an empty string\n if (firstNonEmptyLineIndex === -1) return \"\";\n return lines.slice(firstNonEmptyLineIndex).join(\"\\n\");\n}\nundefined?.test(\"trimEmptyLinesStart\", ({ expect }) => {\n expect(trimEmptyLinesStart(\"\")).toBe(\"\");\n expect(trimEmptyLinesStart(\"hello\")).toBe(\"hello\");\n expect(trimEmptyLinesStart(\"\\nhello\")).toBe(\"hello\");\n expect(trimEmptyLinesStart(\"\\n\\nhello\")).toBe(\"hello\");\n expect(trimEmptyLinesStart(\" \\n\\t\\nhello\")).toBe(\"hello\");\n expect(trimEmptyLinesStart(\"\\n\\nhello\\nworld\")).toBe(\"hello\\nworld\");\n expect(trimEmptyLinesStart(\"hello\\n\\nworld\")).toBe(\"hello\\n\\nworld\");\n expect(trimEmptyLinesStart(\"hello\\nworld\\n\")).toBe(\"hello\\nworld\\n\");\n expect(trimEmptyLinesStart(\"\\n \\n\\nhello\\n \\nworld\")).toBe(\"hello\\n \\nworld\");\n // Edge case: all lines are empty\n expect(trimEmptyLinesStart(\"\\n\\n \\n\\t\")).toBe(\"\");\n});\n\n/**\n * Returns a string with all empty or whitespace-only lines at the end removed.\n *\n * Uses the same definition for whitespace as `String.prototype.trim()`.\n */\nexport function trimEmptyLinesEnd(s: string): string {\n const lines = s.split(\"\\n\");\n const lastNonEmptyLineIndex = findLastIndex(lines, (line) => line.trim() !== \"\");\n return lines.slice(0, lastNonEmptyLineIndex + 1).join(\"\\n\");\n}\nundefined?.test(\"trimEmptyLinesEnd\", ({ expect }) => {\n expect(trimEmptyLinesEnd(\"\")).toBe(\"\");\n expect(trimEmptyLinesEnd(\"hello\")).toBe(\"hello\");\n expect(trimEmptyLinesEnd(\"hello\\n\")).toBe(\"hello\");\n expect(trimEmptyLinesEnd(\"hello\\n\\n\")).toBe(\"hello\");\n expect(trimEmptyLinesEnd(\"hello\\n \\n\\t\")).toBe(\"hello\");\n expect(trimEmptyLinesEnd(\"hello\\nworld\\n\\n\")).toBe(\"hello\\nworld\");\n expect(trimEmptyLinesEnd(\"hello\\n\\nworld\")).toBe(\"hello\\n\\nworld\");\n expect(trimEmptyLinesEnd(\"\\nhello\\nworld\")).toBe(\"\\nhello\\nworld\");\n expect(trimEmptyLinesEnd(\"hello\\n \\nworld\\n\\n \")).toBe(\"hello\\n \\nworld\");\n // Edge case: all lines are empty\n expect(trimEmptyLinesEnd(\"\\n\\n \\n\\t\")).toBe(\"\");\n});\n\n/**\n * Returns a string with all empty or whitespace-only lines trimmed at the start and end.\n *\n * Uses the same definition for whitespace as `String.prototype.trim()`.\n */\nexport function trimLines(s: string): string {\n return trimEmptyLinesEnd(trimEmptyLinesStart(s));\n}\nundefined?.test(\"trimLines\", ({ expect }) => {\n expect(trimLines(\"\")).toBe(\"\");\n expect(trimLines(\" \")).toBe(\"\");\n expect(trimLines(\" \\n \")).toBe(\"\");\n expect(trimLines(\" abc \")).toBe(\" abc \");\n expect(trimLines(\"\\n \\nLine1\\nLine2\\n \\n\")).toBe(\"Line1\\nLine2\");\n expect(trimLines(\"Line1\\n \\nLine2\")).toBe(\"Line1\\n \\nLine2\");\n expect(trimLines(\" \\n \\n\\t\")).toBe(\"\");\n expect(trimLines(\" Hello World\")).toBe(\" Hello World\");\n expect(trimLines(\"\\n\")).toBe(\"\");\n expect(trimLines(\"\\t \\n\\t\\tLine1 \\n \\nLine2\\t\\t\\n\\t \")).toBe(\"\\t\\tLine1 \\n \\nLine2\\t\\t\");\n});\n\n\n/**\n * A template literal tag that returns the same string as the template literal without a tag.\n *\n * Useful for implementing your own template literal tags.\n */\nexport function templateIdentity(strings: TemplateStringsArray | readonly string[], ...values: string[]): string {\n if (values.length !== strings.length - 1) throw new StackAssertionError(\"Invalid number of values; must be one less than strings\", { strings, values });\n\n return strings.reduce((result, str, i) => result + str + (values[i] ?? ''), '');\n}\nundefined?.test(\"templateIdentity\", ({ expect }) => {\n expect(templateIdentity`Hello World`).toBe(\"Hello World\");\n expect(templateIdentity`${\"Hello\"}`).toBe(\"Hello\");\n const greeting = \"Hello\";\n const subject = \"World\";\n expect(templateIdentity`${greeting}, ${subject}!`).toBe(\"Hello, World!\");\n expect(templateIdentity`${\"A\"}${\"B\"}${\"C\"}`).toBe(\"ABC\");\n expect(templateIdentity`Start${\"\"}Middle${\"\"}End`).toBe(\"StartMiddleEnd\");\n expect(templateIdentity``).toBe(\"\");\n expect(templateIdentity`Line1\nLine2`).toBe(\"Line1\\nLine2\");\n expect(templateIdentity([\"a \", \" scientific \", \"gun\"], \"certain\", \"rail\")).toBe(\"a certain scientific railgun\");\n expect(templateIdentity([\"only one part\"])).toBe(\"only one part\");\n expect(() => templateIdentity([\"a \", \"b\", \"c\"], \"only one\")).toThrow(\"Invalid number of values\");\n expect(() => templateIdentity([\"a\", \"b\"], \"x\", \"y\")).toThrow(\"Invalid number of values\");\n});\n\n\nexport function deindent(code: string): string;\nexport function deindent(strings: TemplateStringsArray | readonly string[], ...values: any[]): string;\nexport function deindent(strings: string | readonly string[], ...values: any[]): string {\n if (typeof strings === \"string\") return deindent([strings]);\n return templateIdentity(...deindentTemplate(strings, ...values));\n}\n\nexport function deindentTemplate(strings: TemplateStringsArray | readonly string[], ...values: any[]): [string[], ...string[]] {\n if (values.length !== strings.length - 1) throw new StackAssertionError(\"Invalid number of values; must be one less than strings\", { strings, values });\n\n const trimmedStrings = [...strings];\n trimmedStrings[0] = trimEmptyLinesStart(trimmedStrings[0] + \"+\").slice(0, -1);\n trimmedStrings[trimmedStrings.length - 1] = trimEmptyLinesEnd(\"+\" + trimmedStrings[trimmedStrings.length - 1]).slice(1);\n\n const indentation = trimmedStrings\n .join(\"${SOME_VALUE}\")\n .split(\"\\n\")\n .filter((line) => line.trim() !== \"\")\n .map((line) => getWhitespacePrefix(line).length)\n .reduce((min, current) => Math.min(min, current), Infinity);\n\n const deindentedStrings = trimmedStrings\n .map((string, stringIndex) => {\n return string\n .split(\"\\n\")\n .map((line, lineIndex) => stringIndex !== 0 && lineIndex === 0 ? line : line.substring(indentation))\n .join(\"\\n\");\n });\n\n const indentedValues = values.map((value, i) => {\n const firstLineIndentation = getWhitespacePrefix(deindentedStrings[i].split(\"\\n\").at(-1)!);\n return `${value}`.replaceAll(\"\\n\", `\\n${firstLineIndentation}`);\n });\n\n return [deindentedStrings, ...indentedValues];\n}\nundefined?.test(\"deindent\", ({ expect }) => {\n // Test with string input\n expect(deindent(\" hello\")).toBe(\"hello\");\n expect(deindent(\" hello\\n world\")).toBe(\"hello\\nworld\");\n expect(deindent(\" hello\\n world\")).toBe(\"hello\\n world\");\n expect(deindent(\"\\n hello\\n world\\n\")).toBe(\"hello\\nworld\");\n\n // Test with empty input\n expect(deindent(\"\")).toBe(\"\");\n\n // Test with template literal\n expect(deindent`\n hello\n world\n `).toBe(\"hello\\nworld\");\n\n expect(deindent`\n hello\n world\n `).toBe(\"hello\\n world\");\n\n // Test with values\n const value = \"test\";\n expect(deindent`\n hello ${value}\n world\n `).toBe(`hello ${value}\\nworld`);\n\n // Test with multiline values\n expect(deindent`\n hello\n to ${\"line1\\n line2\"}\n world\n `).toBe(`hello\\n to line1\\n line2\\nworld`);\n\n // Leading whitespace values\n expect(deindent`\n ${\" \"}A\n ${\" \"}B\n ${\" \"}C\n `).toBe(` A\\n B\\n C`);\n\n // Trailing whitespaces (note: there are two whitespaces each after A and after C)\n expect(deindent`\n A \n B ${\" \"}\n C \n `).toBe(`A \\nB \\nC `);\n\n // Test with mixed indentation\n expect(deindent`\n hello\n world\n !\n `).toBe(\"hello\\n world\\n !\");\n\n // Test error cases\n expect(() => deindent([\"a\", \"b\", \"c\"], \"too\", \"many\", \"values\")).toThrow(\"Invalid number of values\");\n});\n\nexport function extractScopes(scope: string, removeDuplicates=true): string[] {\n // TODO what is this for? can we move this into the OAuth code in the backend?\n const trimmedString = scope.trim();\n const scopesArray = trimmedString.split(/\\s+/);\n const filtered = scopesArray.filter(scope => scope.length > 0);\n return removeDuplicates ? [...new Set(filtered)] : filtered;\n}\nundefined?.test(\"extractScopes\", ({ expect }) => {\n // Test with empty string\n expect(extractScopes(\"\")).toEqual([]);\n\n // Test with single scope\n expect(extractScopes(\"read\")).toEqual([\"read\"]);\n\n // Test with multiple scopes\n expect(extractScopes(\"read write\")).toEqual([\"read\", \"write\"]);\n\n // Test with extra whitespace\n expect(extractScopes(\" read write \")).toEqual([\"read\", \"write\"]);\n\n // Test with newlines and tabs\n expect(extractScopes(\"read\\nwrite\\tdelete\")).toEqual([\"read\", \"write\", \"delete\"]);\n\n // Test with duplicates (default behavior)\n expect(extractScopes(\"read write read\")).toEqual([\"read\", \"write\"]);\n\n // Test with duplicates (explicitly set to remove)\n expect(extractScopes(\"read write read\", true)).toEqual([\"read\", \"write\"]);\n\n // Test with duplicates (explicitly set to keep)\n expect(extractScopes(\"read write read\", false)).toEqual([\"read\", \"write\", \"read\"]);\n});\n\nexport function mergeScopeStrings(...scopes: string[]): string {\n // TODO what is this for? can we move this into the OAuth code in the backend?\n const allScope = scopes.map((s) => extractScopes(s)).flat().join(\" \");\n return extractScopes(allScope).join(\" \");\n}\nundefined?.test(\"mergeScopeStrings\", ({ expect }) => {\n // Test with empty input\n expect(mergeScopeStrings()).toBe(\"\");\n\n // Test with single scope string\n expect(mergeScopeStrings(\"read write\")).toBe(\"read write\");\n\n // Test with multiple scope strings\n expect(mergeScopeStrings(\"read\", \"write\")).toBe(\"read write\");\n\n // Test with overlapping scopes\n expect(mergeScopeStrings(\"read write\", \"write delete\")).toBe(\"read write delete\");\n\n // Test with extra whitespace\n expect(mergeScopeStrings(\" read write \", \" delete \")).toBe(\"read write delete\");\n\n // Test with duplicates across strings\n expect(mergeScopeStrings(\"read write\", \"write delete\", \"read\")).toBe(\"read write delete\");\n\n // Test with empty strings\n expect(mergeScopeStrings(\"read write\", \"\", \"delete\")).toBe(\"read write delete\");\n});\n\nexport function escapeTemplateLiteral(s: string): string {\n return s.replaceAll(\"`\", \"\\\\`\").replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll(\"$\", \"\\\\$\");\n}\nundefined?.test(\"escapeTemplateLiteral\", ({ expect }) => {\n // Test with empty string\n expect(escapeTemplateLiteral(\"\")).toBe(\"\");\n\n // Test with normal string (no special characters)\n expect(escapeTemplateLiteral(\"hello world\")).toBe(\"hello world\");\n\n // Test with backtick\n const input1 = \"hello `world`\";\n const output1 = escapeTemplateLiteral(input1);\n // Verify backticks are escaped\n expect(output1.includes(\"\\\\`\")).toBe(true);\n expect(output1).not.toBe(input1);\n\n // Test with backslash\n const input2 = \"hello \\\\world\";\n const output2 = escapeTemplateLiteral(input2);\n // Verify backslashes are escaped\n expect(output2.includes(\"\\\\\\\\\")).toBe(true);\n expect(output2).not.toBe(input2);\n\n // Test with dollar sign\n const input3 = \"hello $world\";\n const output3 = escapeTemplateLiteral(input3);\n // Verify dollar signs are escaped\n expect(output3.includes(\"\\\\$\")).toBe(true);\n expect(output3).not.toBe(input3);\n\n // Test with multiple special characters\n const input4 = \"`hello` $world\\\\\";\n const output4 = escapeTemplateLiteral(input4);\n // Verify all special characters are escaped\n expect(output4.includes(\"\\\\`\")).toBe(true);\n expect(output4.includes(\"\\\\$\")).toBe(true);\n expect(output4.includes(\"\\\\\\\\\")).toBe(true);\n expect(output4).not.toBe(input4);\n\n // Test with already escaped characters\n const input5 = \"\\\\`hello\\\\`\";\n const output5 = escapeTemplateLiteral(input5);\n // Verify already escaped characters are properly escaped\n expect(output5).not.toBe(input5);\n});\n\n/**\n * Some classes have different constructor names in different environments (eg. `Headers` is sometimes called `_Headers`,\n * so we create an object of overrides to handle these cases.\n */\nconst nicifiableClassNameOverrides = new Map(Object.entries({\n Headers,\n} as Record<string, unknown>).map(([k, v]) => [v, k]));\nexport type Nicifiable = {\n getNicifiableKeys?(): PropertyKey[],\n getNicifiedObjectExtraLines?(): string[],\n};\nexport type NicifyOptions = {\n maxDepth: number,\n currentIndent: string,\n lineIndent: string,\n multiline: boolean,\n refs: Map<unknown, string>,\n path: string,\n parent: null | {\n options: NicifyOptions,\n value: unknown,\n },\n keyInParent: PropertyKey | null,\n hideFields: PropertyKey[],\n overrides: (...args: Parameters<typeof nicify>) => string | null,\n};\nexport function nicify(\n value: unknown,\n options: Partial<NicifyOptions> = {},\n): string {\n const fullOptions: NicifyOptions = {\n maxDepth: 5,\n currentIndent: \"\",\n lineIndent: \" \",\n multiline: true,\n refs: new Map(),\n path: \"value\",\n parent: null,\n overrides: () => null,\n keyInParent: null,\n hideFields: [],\n ...filterUndefined(options),\n };\n const {\n maxDepth,\n currentIndent,\n lineIndent,\n multiline,\n refs,\n path,\n overrides,\n hideFields,\n } = fullOptions;\n const nl = `\\n${currentIndent}`;\n\n const overrideResult = overrides(value, options);\n if (overrideResult !== null) return overrideResult;\n\n if ([\"function\", \"object\", \"symbol\"].includes(typeof value) && value !== null) {\n if (refs.has(value)) {\n return `Ref<${refs.get(value)}>`;\n }\n refs.set(value, path);\n }\n\n const newOptions: NicifyOptions = {\n maxDepth: maxDepth - 1,\n currentIndent,\n lineIndent,\n multiline,\n refs,\n path: path + \"->[unknown property]\",\n overrides,\n parent: { value, options: fullOptions },\n keyInParent: null,\n hideFields: [],\n };\n const nestedNicify = (newValue: unknown, newPath: string, keyInParent: PropertyKey | null, options: Partial<NicifyOptions> = {}) => {\n return nicify(newValue, {\n ...newOptions,\n path: newPath,\n currentIndent: currentIndent + lineIndent,\n keyInParent,\n ...options,\n });\n };\n\n switch (typeof value) {\n case \"boolean\": case \"number\": {\n return JSON.stringify(value);\n }\n case \"string\": {\n const isDeindentable = (v: string) => deindent(v) === v && v.includes(\"\\n\");\n const wrapInDeindent = (v: string) => deindent`\n deindent\\`\n ${currentIndent + lineIndent}${escapeTemplateLiteral(v).replaceAll(\"\\n\", nl + lineIndent)}\n ${currentIndent}\\`\n `;\n if (isDeindentable(value)) {\n return wrapInDeindent(value);\n } else if (value.endsWith(\"\\n\") && isDeindentable(value.slice(0, -1))) {\n return wrapInDeindent(value.slice(0, -1)) + ' + \"\\\\n\"';\n } else {\n return JSON.stringify(value);\n }\n }\n case \"undefined\": {\n return \"undefined\";\n }\n case \"symbol\": {\n return value.toString();\n }\n case \"bigint\": {\n return `${value}n`;\n }\n case \"function\": {\n if (value.name) return `function ${value.name}(...) { ... }`;\n return `(...) => { ... }`;\n }\n case \"object\": {\n if (value === null) return \"null\";\n if (Array.isArray(value)) {\n const extraLines = getNicifiedObjectExtraLines(value);\n const resValueLength = value.length + extraLines.length;\n if (maxDepth <= 0 && resValueLength === 0) return \"[...]\";\n const resValues = value.map((v, i) => nestedNicify(v, `${path}[${i}]`, i));\n resValues.push(...extraLines);\n if (resValues.length !== resValueLength) throw new StackAssertionError(\"nicify of object: resValues.length !== resValueLength\", { value, resValues, resValueLength });\n const shouldIndent = resValues.length > 4 || resValues.some(x => (resValues.length > 1 && x.length > 4) || x.includes(\"\\n\"));\n if (shouldIndent) {\n return `[${nl}${resValues.map(x => `${lineIndent}${x},${nl}`).join(\"\")}]`;\n } else {\n return `[${resValues.join(\", \")}]`;\n }\n }\n if (value instanceof URL) {\n return `URL(${nestedNicify(value.toString(), `${path}.toString()`, null)})`;\n }\n if (ArrayBuffer.isView(value)) {\n return `${value.constructor.name}([${value.toString()}])`;\n }\n if (value instanceof Error) {\n let stack = value.stack ?? \"\";\n const toString = value.toString();\n if (!stack.startsWith(toString)) stack = `${toString}\\n${stack}`; // some browsers don't include the error message in the stack, some do\n stack = stack.trimEnd();\n stack = stack.replace(/\\n\\s+/g, `\\n${lineIndent}${lineIndent}`);\n stack = stack.replace(\"\\n\", `\\n${lineIndent}Stack:\\n`);\n if (Object.keys(value).length > 0) {\n stack += `\\n${lineIndent}Extra properties: ${nestedNicify(Object.fromEntries(Object.entries(value)), path, null)}`;\n }\n if (value.cause) {\n stack += `\\n${lineIndent}Cause:\\n${lineIndent}${lineIndent}${nestedNicify(value.cause, path, null, { currentIndent: currentIndent + lineIndent + lineIndent })}`;\n }\n stack = stack.replaceAll(\"\\n\", `\\n${currentIndent}`);\n return stack;\n }\n\n const constructorName = [null, Object.prototype].includes(Object.getPrototypeOf(value)) ? null : (nicifiableClassNameOverrides.get(value.constructor) ?? value.constructor.name);\n const constructorString = constructorName ? `${constructorName} ` : \"\";\n\n const entries = getNicifiableEntries(value).filter(([k]) => !hideFields.includes(k));\n const extraLines = [\n ...getNicifiedObjectExtraLines(value),\n ...hideFields.length > 0 ? [`<some fields may have been hidden>`] : [],\n ];\n const resValueLength = entries.length + extraLines.length;\n if (resValueLength === 0) return `${constructorString}{}`;\n if (maxDepth <= 0) return `${constructorString}{ ... }`;\n const resValues = entries.map(([k, v], keyIndex) => {\n const keyNicified = nestedNicify(k, `Object.keys(${path})[${keyIndex}]`, null);\n const keyInObjectLiteral = typeof k === \"string\" ? nicifyPropertyString(k) : `[${keyNicified}]`;\n if (typeof v === \"function\" && v.name === k) {\n return `${keyInObjectLiteral}(...): { ... }`;\n } else {\n return `${keyInObjectLiteral}: ${nestedNicify(v, `${path}[${keyNicified}]`, k)}`;\n }\n });\n resValues.push(...extraLines);\n if (resValues.length !== resValueLength) throw new StackAssertionError(\"nicify of object: resValues.length !== resValueLength\", { value, resValues, resValueLength });\n const shouldIndent = resValues.length > 1 || resValues.some(x => x.includes(\"\\n\"));\n\n if (resValues.length === 0) return `${constructorString}{}`;\n if (shouldIndent) {\n return `${constructorString}{${nl}${resValues.map(x => `${lineIndent}${x},${nl}`).join(\"\")}}`;\n } else {\n return `${constructorString}{ ${resValues.join(\", \")} }`;\n }\n }\n default: {\n return `${typeof value}<${value}>`;\n }\n }\n}\n\nexport function replaceAll(input: string, searchValue: string, replaceValue: string): string {\n if (searchValue === \"\") throw new StackAssertionError(\"replaceAll: searchValue is empty\");\n return input.split(searchValue).join(replaceValue);\n}\nundefined?.test(\"replaceAll\", ({ expect }) => {\n expect(replaceAll(\"hello world\", \"o\", \"x\")).toBe(\"hellx wxrld\");\n expect(replaceAll(\"aaa\", \"a\", \"b\")).toBe(\"bbb\");\n expect(replaceAll(\"\", \"a\", \"b\")).toBe(\"\");\n expect(replaceAll(\"abc\", \"b\", \"\")).toBe(\"ac\");\n expect(replaceAll(\"test.test.test\", \".\", \"_\")).toBe(\"test_test_test\");\n expect(replaceAll(\"a.b*c\", \".\", \"x\")).toBe(\"axb*c\");\n expect(replaceAll(\"a*b*c\", \"*\", \"x\")).toBe(\"axbxc\");\n expect(replaceAll(\"hello hello\", \"hello\", \"hi\")).toBe(\"hi hi\");\n});\n\nfunction nicifyPropertyString(str: string) {\n return JSON.stringify(str);\n}\nundefined?.test(\"nicifyPropertyString\", ({ expect }) => {\n // Test valid identifiers\n expect(nicifyPropertyString(\"validName\")).toBe('\"validName\"');\n expect(nicifyPropertyString(\"_validName\")).toBe('\"_validName\"');\n expect(nicifyPropertyString(\"valid123Name\")).toBe('\"valid123Name\"');\n\n // Test invalid identifiers\n expect(nicifyPropertyString(\"123invalid\")).toBe('\"123invalid\"');\n expect(nicifyPropertyString(\"invalid-name\")).toBe('\"invalid-name\"');\n expect(nicifyPropertyString(\"invalid space\")).toBe('\"invalid space\"');\n expect(nicifyPropertyString(\"$invalid\")).toBe('\"$invalid\"');\n expect(nicifyPropertyString(\"\")).toBe('\"\"');\n\n // Test with special characters\n expect(nicifyPropertyString(\"property!\")).toBe('\"property!\"');\n expect(nicifyPropertyString(\"property.name\")).toBe('\"property.name\"');\n\n // Test with escaped characters\n expect(nicifyPropertyString(\"\\\\\")).toBe('\"\\\\\\\\\"');\n expect(nicifyPropertyString('\"')).toBe('\"\\\\\"\"');\n});\n\nfunction getNicifiableKeys(value: Nicifiable | object) {\n const overridden = (\"getNicifiableKeys\" in value ? value.getNicifiableKeys?.bind(value) : null)?.();\n if (overridden != null) return overridden;\n if (value instanceof Response) {\n return ['status', 'headers'];\n }\n const keys = Object.keys(value).sort();\n return unique(keys);\n}\nundefined?.test(\"getNicifiableKeys\", ({ expect }) => {\n // Test regular object\n expect(getNicifiableKeys({ b: 1, a: 2, c: 3 })).toEqual([\"a\", \"b\", \"c\"]);\n\n // Test empty object\n expect(getNicifiableKeys({})).toEqual([]);\n\n\n expect(getNicifiableKeys(new Response())).toEqual([\"status\", \"headers\"]);\n\n // Test object with custom getNicifiableKeys\n const customObject = {\n a: 1,\n b: 2,\n getNicifiableKeys() {\n return [\"customKey1\", \"customKey2\"];\n }\n };\n expect(getNicifiableKeys(customObject)).toEqual([\"customKey1\", \"customKey2\"]);\n});\n\nfunction getNicifiableEntries(value: Nicifiable | object): [PropertyKey, unknown][] {\n const recordLikes = [Headers];\n function isRecordLike(value: unknown): value is InstanceType<typeof recordLikes[number]> {\n return recordLikes.some(x => value instanceof x);\n }\n\n if (isRecordLike(value)) {\n return [...value.entries()].sort(([a], [b]) => stringCompare(`${a}`, `${b}`));\n }\n const keys = getNicifiableKeys(value);\n return keys.map((k) => [k, value[k as never]] as [PropertyKey, unknown]);\n}\n\nfunction getNicifiedObjectExtraLines(value: Nicifiable | object) {\n return (\"getNicifiedObjectExtraLines\" in value ? value.getNicifiedObjectExtraLines : null)?.() ?? [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAsC;AACtC,oBAAoC;AACpC,qBAAgC;AAEzB,SAAS,iBAAmC,GAAoB;AACrE,MAAI,OAAO,MAAM,SAAU,OAAM,IAAI,kCAAoB,0CAA0C,EAAE,EAAE,CAAC;AACxG,SAAO,EAAE,YAAY;AACvB;AAYO,SAAS,iBAAmC,GAAoB;AACrE,MAAI,OAAO,MAAM,SAAU,OAAM,IAAI,kCAAoB,0CAA0C,EAAE,EAAE,CAAC;AACxG,SAAO,EAAE,YAAY;AACvB;AAYO,SAAS,gBAAkC,GAAqB;AACrE,SAAO,EAAE,OAAO,CAAC,EAAE,YAAY,IAAI,EAAE,MAAM,CAAC;AAC9C;AAcO,SAAS,cAAc,GAAW,GAAmB;AAC1D,MAAI,OAAO,MAAM,YAAY,OAAO,MAAM,SAAU,OAAM,IAAI,kCAAoB,iDAAiD,OAAO,CAAC,QAAQ,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC;AACvK,QAAM,MAAM,CAACA,IAAWC,OAAcD,KAAIC,KAAI,KAAKD,KAAIC,KAAI,IAAI;AAC/D,SAAO,IAAI,EAAE,YAAY,GAAG,EAAE,YAAY,CAAC,KAAK,IAAI,GAAG,CAAC;AAC1D;AAmCO,SAAS,oBAAoB,GAAmB;AACrD,SAAO,EAAE,UAAU,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM;AACvD;AAiBO,SAAS,oBAAoB,GAAmB;AACrD,SAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM;AACvC;AAiBO,SA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A,EACjD;AAEA,MAAI,aAAa,KAAK,GAAG;AACvB,WAAO,CAAC,GAAG,MAAM,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,cAAc,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;AAAA,EAC9E;AACA,QAAM,OAAO,kBAAkB,KAAK;AACpC,SAAO,KAAK,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAU,CAAC,CAA2B;AACzE;AAEA,SAAS,4BAA4B,OAA4B;AAC/D,UAAQ,iCAAiC,QAAQ,MAAM,8BAA8B,QAAQ,KAAK,CAAC;AACrG;","names":["a","b","scope","options","extraLines","resValueLength","resValues","shouldIndent","value"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/utils/strings.nicify.test.ts
|
|
4
4
|
var import_vitest = require("vitest");
|
|
5
|
-
var import_strings = require("./strings");
|
|
5
|
+
var import_strings = require("./strings.js");
|
|
6
6
|
(0, import_vitest.describe)("nicify", () => {
|
|
7
7
|
(0, import_vitest.describe)("primitive values", () => {
|
|
8
8
|
(0, import_vitest.test)("numbers", () => {
|
package/dist/utils/unicode.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(unicode_exports, {
|
|
|
23
23
|
getFlagEmoji: () => getFlagEmoji
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(unicode_exports);
|
|
26
|
-
var import_errors = require("./errors");
|
|
26
|
+
var import_errors = require("./errors.js");
|
|
27
27
|
function getFlagEmoji(twoLetterCountryCode) {
|
|
28
28
|
if (!/^[a-zA-Z][a-zA-Z]$/.test(twoLetterCountryCode)) throw new import_errors.StackAssertionError("Country code must be two alphabetical letters");
|
|
29
29
|
const codePoints = twoLetterCountryCode.toUpperCase().split("").map((char) => 127397 + char.charCodeAt(0));
|
package/dist/utils/urls.js
CHANGED
|
@@ -30,8 +30,8 @@ __export(urls_exports, {
|
|
|
30
30
|
urlString: () => urlString
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(urls_exports);
|
|
33
|
-
var import_crypto = require("./crypto");
|
|
34
|
-
var import_strings = require("./strings");
|
|
33
|
+
var import_crypto = require("./crypto.js");
|
|
34
|
+
var import_strings = require("./strings.js");
|
|
35
35
|
function createUrlIfValid(...args) {
|
|
36
36
|
try {
|
|
37
37
|
return new URL(...args);
|
package/dist/utils/uuids.js
CHANGED
|
@@ -24,7 +24,7 @@ __export(uuids_exports, {
|
|
|
24
24
|
isUuid: () => isUuid
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(uuids_exports);
|
|
27
|
-
var import_crypto = require("./crypto");
|
|
27
|
+
var import_crypto = require("./crypto.js");
|
|
28
28
|
function generateUuid() {
|
|
29
29
|
return "10000000-1000-4000-8000-100000000000".replace(
|
|
30
30
|
/[018]/g,
|