@stryke/crypto 0.5.44 → 0.6.1

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cloudflare.cjs +960 -0
  3. package/dist/cloudflare.d.cts +251 -0
  4. package/dist/cloudflare.d.cts.map +1 -0
  5. package/dist/cloudflare.d.mts +251 -0
  6. package/dist/cloudflare.d.mts.map +1 -0
  7. package/dist/cloudflare.mjs +942 -0
  8. package/dist/cloudflare.mjs.map +1 -0
  9. package/dist/index.cjs +16 -12
  10. package/dist/index.d.cts +2 -4
  11. package/dist/index.d.mts +2 -4
  12. package/dist/index.mjs +2 -4
  13. package/dist/neutral-BISXAuIW.cjs +868 -0
  14. package/dist/{encryption.d.mts → neutral-BJmyEdJq.d.mts} +77 -2
  15. package/dist/neutral-BJmyEdJq.d.mts.map +1 -0
  16. package/dist/neutral-BtZoJSl-.mjs +779 -0
  17. package/dist/neutral-BtZoJSl-.mjs.map +1 -0
  18. package/dist/{encryption.d.cts → neutral-CW6EXiYo.d.cts} +77 -2
  19. package/dist/neutral-CW6EXiYo.d.cts.map +1 -0
  20. package/dist/neutral.cjs +16 -16
  21. package/dist/neutral.d.cts +2 -4
  22. package/dist/neutral.d.mts +2 -4
  23. package/dist/neutral.mjs +2 -4
  24. package/dist/node.cjs +663 -0
  25. package/dist/node.d.cts +117 -0
  26. package/dist/node.d.cts.map +1 -0
  27. package/dist/node.d.mts +117 -0
  28. package/dist/node.d.mts.map +1 -0
  29. package/dist/node.mjs +654 -0
  30. package/dist/node.mjs.map +1 -0
  31. package/package.json +55 -20
  32. package/dist/base-64.cjs +0 -440
  33. package/dist/base-64.d.cts +0 -40
  34. package/dist/base-64.d.cts.map +0 -1
  35. package/dist/base-64.d.mts +0 -40
  36. package/dist/base-64.d.mts.map +0 -1
  37. package/dist/base-64.mjs +0 -438
  38. package/dist/base-64.mjs.map +0 -1
  39. package/dist/convert/src/array-buffer-to-string.cjs +0 -19
  40. package/dist/convert/src/array-buffer-to-string.mjs +0 -19
  41. package/dist/convert/src/array-buffer-to-string.mjs.map +0 -1
  42. package/dist/convert/src/neutral.cjs +0 -7
  43. package/dist/convert/src/neutral.mjs +0 -9
  44. package/dist/convert/src/parse-type-definition.cjs +0 -1
  45. package/dist/convert/src/parse-type-definition.mjs +0 -3
  46. package/dist/convert/src/string-to-uint8-array.cjs +0 -24
  47. package/dist/convert/src/string-to-uint8-array.mjs +0 -23
  48. package/dist/convert/src/string-to-uint8-array.mjs.map +0 -1
  49. package/dist/convert/src/string-to-utf8-array.cjs +0 -15
  50. package/dist/convert/src/string-to-utf8-array.mjs +0 -15
  51. package/dist/convert/src/string-to-utf8-array.mjs.map +0 -1
  52. package/dist/convert/src/uint8-array-to-stream.cjs +0 -22
  53. package/dist/convert/src/uint8-array-to-stream.mjs +0 -22
  54. package/dist/convert/src/uint8-array-to-stream.mjs.map +0 -1
  55. package/dist/convert/src/uint8-array-to-string.cjs +0 -15
  56. package/dist/convert/src/uint8-array-to-string.mjs +0 -16
  57. package/dist/convert/src/uint8-array-to-string.mjs.map +0 -1
  58. package/dist/convert/src/utf8-array-to-string.cjs +0 -15
  59. package/dist/convert/src/utf8-array-to-string.mjs +0 -15
  60. package/dist/convert/src/utf8-array-to-string.mjs.map +0 -1
  61. package/dist/encryption.cjs +0 -134
  62. package/dist/encryption.d.cts.map +0 -1
  63. package/dist/encryption.d.mts.map +0 -1
  64. package/dist/encryption.mjs +0 -129
  65. package/dist/encryption.mjs.map +0 -1
  66. package/dist/encryption.node.cjs +0 -63
  67. package/dist/encryption.node.d.cts +0 -42
  68. package/dist/encryption.node.d.cts.map +0 -1
  69. package/dist/encryption.node.d.mts +0 -42
  70. package/dist/encryption.node.d.mts.map +0 -1
  71. package/dist/encryption.node.mjs +0 -62
  72. package/dist/encryption.node.mjs.map +0 -1
  73. package/dist/hex.cjs +0 -62
  74. package/dist/hex.d.cts +0 -18
  75. package/dist/hex.d.cts.map +0 -1
  76. package/dist/hex.d.mts +0 -18
  77. package/dist/hex.d.mts.map +0 -1
  78. package/dist/hex.mjs +0 -61
  79. package/dist/hex.mjs.map +0 -1
  80. package/dist/type-checks/src/index.cjs +0 -5
  81. package/dist/type-checks/src/index.mjs +0 -7
  82. package/dist/type-checks/src/is-buffer.cjs +0 -12
  83. package/dist/type-checks/src/is-buffer.mjs +0 -12
  84. package/dist/type-checks/src/is-buffer.mjs.map +0 -1
  85. package/dist/type-checks/src/is-collection.cjs +0 -1
  86. package/dist/type-checks/src/is-collection.mjs +0 -3
  87. package/dist/type-checks/src/is-string.cjs +0 -12
  88. package/dist/type-checks/src/is-string.mjs +0 -12
  89. package/dist/type-checks/src/is-string.mjs.map +0 -1
  90. package/dist/type-checks/src/is-undefined.cjs +0 -8
  91. package/dist/type-checks/src/is-undefined.mjs +0 -8
  92. package/dist/type-checks/src/is-undefined.mjs.map +0 -1
  93. package/dist/type-checks/src/type-detect.cjs +0 -15
  94. package/dist/type-checks/src/type-detect.mjs +0 -17
  95. package/dist/type-checks/src/type-detect.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.mjs","names":["isBuffer: typeof Buffer.isBuffer","isBuffer","DECODE_MAP","i","Buffer","DECODE_MAP: Record<string, number>","result: string[]"],"sources":["../../type-checks/src/is-undefined.ts","../../type-checks/src/is-buffer.ts","../../type-checks/src/type-detect.ts","../../type-checks/src/is-string.ts","../../convert/src/string-to-uint8-array.ts","../../convert/src/string-to-utf8-array.ts","../../convert/src/utf8-array-to-string.ts","../src/base-64.ts","../src/encryption.node.ts","../src/hex.ts","../src/random.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isUndefined = (value: unknown): value is undefined => {\n return value === undefined;\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isBufferExists = typeof Buffer !== \"undefined\";\n\n/**\n * Check if the provided value's type is `Buffer`\n */\nexport const isBuffer: typeof Buffer.isBuffer = isBufferExists\n ? Buffer.isBuffer.bind(Buffer)\n : /**\n * Check if the provided value's type is `Buffer`\n\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Buffer`\n */\n function isBuffer(\n value: Parameters<typeof Buffer.isBuffer>[0]\n ): value is Buffer {\n return false;\n };\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isBuffer } from \"./is-buffer\";\n\nconst globalObject = (Obj => {\n if (typeof globalThis === \"object\") {\n return globalThis;\n }\n Object.defineProperty(Obj, \"typeDetectGlobalObject\", {\n get() {\n return this;\n },\n configurable: true\n });\n\n // // biome-ignore lint/correctness/noUndeclaredVariables: <explanation>\n // const global = typeDetectGlobalObject;\n\n // // biome-ignore lint/performance/noDelete: <explanation>\n // delete Obj.typeDetectGlobalObject;\n return globalThis;\n})(Object.prototype);\n\nexport function typeDetect(obj: unknown): string {\n // NOTE: isBuffer must execute before type-detect,\n // because type-detect returns 'Uint8Array'.\n if (isBuffer(obj)) {\n return \"Buffer\";\n }\n\n const typeofObj = typeof obj;\n if (typeofObj !== \"object\") {\n return typeofObj;\n }\n\n if (obj === null) {\n return \"null\";\n }\n\n if (obj === globalObject) {\n return \"global\";\n }\n\n if (\n Array.isArray(obj) &&\n (Symbol.toStringTag === undefined || !(Symbol.toStringTag in obj))\n ) {\n return \"Array\";\n }\n\n // https://html.spec.whatwg.org/multipage/browsers.html#location\n if (typeof globalThis === \"object\" && globalThis !== null) {\n if (\n typeof (globalThis as any).location === \"object\" &&\n obj === (globalThis as any).location\n ) {\n return \"Location\";\n }\n\n // https://html.spec.whatwg.org/#document\n if (\n typeof (globalThis as any).document === \"object\" &&\n obj === (globalThis as any).document\n ) {\n return \"Document\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray\n if (typeof (globalThis as any).navigator === \"object\") {\n if (\n typeof (globalThis as any).navigator.mimeTypes === \"object\" &&\n obj === (globalThis as any).navigator.mimeTypes\n ) {\n return \"MimeTypeArray\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n typeof (globalThis as any).navigator.plugins === \"object\" &&\n obj === (globalThis as any).navigator.plugins\n ) {\n return \"PluginArray\";\n }\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n (typeof (globalThis as any).HTMLElement === \"function\" ||\n typeof (globalThis as any).HTMLElement === \"object\") &&\n obj instanceof (globalThis as any).HTMLElement\n ) {\n if ((obj as any).tagName === \"BLOCKQUOTE\") {\n return \"HTMLQuoteElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltabledatacellelement\n if ((obj as any).tagName === \"TD\") {\n return \"HTMLTableDataCellElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltableheadercellelement\n if ((obj as any).tagName === \"TH\") {\n return \"HTMLTableHeaderCellElement\";\n }\n }\n }\n\n const stringTag =\n Symbol.toStringTag !== undefined && (obj as any)[Symbol.toStringTag];\n if (typeof stringTag === \"string\") {\n return stringTag;\n }\n\n const objPrototype = Object.getPrototypeOf(obj);\n if (objPrototype === RegExp.prototype) {\n return \"RegExp\";\n }\n\n if (objPrototype === Date.prototype) {\n return \"Date\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag\n if (typeof Promise !== \"undefined\" && objPrototype === Promise.prototype) {\n return \"Promise\";\n }\n\n if (typeof Set !== \"undefined\" && objPrototype === Set.prototype) {\n return \"Set\";\n }\n\n if (typeof Map !== \"undefined\" && objPrototype === Map.prototype) {\n return \"Map\";\n }\n\n if (typeof WeakSet !== \"undefined\" && objPrototype === WeakSet.prototype) {\n return \"WeakSet\";\n }\n\n if (typeof WeakMap !== \"undefined\" && objPrototype === WeakMap.prototype) {\n return \"WeakMap\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag\n if (typeof DataView !== \"undefined\" && objPrototype === DataView.prototype) {\n return \"DataView\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag\n if (\n typeof Map !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Map().entries())\n ) {\n return \"Map Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag\n if (\n typeof Set !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Set().entries())\n ) {\n return \"Set Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag\n if (\n typeof Array.prototype[Symbol.iterator] === \"function\" &&\n objPrototype === Object.getPrototypeOf([][Symbol.iterator]())\n ) {\n return \"Array Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag\n if (\n Symbol.iterator !== undefined &&\n typeof String.prototype[Symbol.iterator] === \"function\" &&\n Object.getPrototypeOf(\"\"[Symbol.iterator]()) &&\n objPrototype === Object.getPrototypeOf(\"\"[Symbol.iterator]())\n ) {\n return \"String Iterator\";\n }\n\n if (objPrototype === null) {\n return \"Object\";\n }\n\n return Object.prototype.toString.call(obj).slice(8, -1);\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isString = (value: unknown): value is string => {\n try {\n return typeof value === \"string\";\n } catch {\n return false;\n }\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Convert a string to Uint8Array\n *\n * @param text - The text to convert\n * @returns The converted Uint8Array\n */\nexport function stringToUint8Array(text: string): Uint8Array {\n return Uint8Array.from(\n [...encodeURIComponent(text)].map(letter => letter.codePointAt(0)!)\n );\n}\n\n/**\n * Convert a binary string to Uint8Array\n *\n * @param binary - The binary string to convert\n * @returns The converted Uint8Array\n */\nexport function binaryStringToUint8Array(binary: string): Uint8Array {\n const len = binary.length;\n const arr = new Uint8Array(len);\n for (let i = 0; i < len; i++) {\n arr[i] = binary.charCodeAt(i);\n }\n return arr;\n}\n\n/**\n * Convert a base64 string to a Uint8Array\n *\n * @param data - The base64 string to convert\n * @returns The converted Uint8Array\n */\nexport function base64StringToUint8Array(data: string): Uint8Array {\n return stringToUint8Array(atob(data));\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nconst encoder = new TextEncoder();\n\n/**\n * Convert a string to a utf-8 array\n *\n * @param input - The string to convert\n * @returns The converted utf-8 array\n */\nexport function stringToUtf8Array(input: string): Uint8Array {\n return encoder.encode(input);\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nconst decoder = new TextDecoder();\n\n/**\n * Convert a utf-8 array to string\n *\n * @param input - Utf-8 Array\n * @returns The converted string\n */\nexport function utf8ArrayToString(\n input: NodeJS.ArrayBufferView | ArrayBuffer\n): string {\n return decoder.decode(input);\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { stringToUint8Array } from \"@stryke/convert/neutral\";\nimport { utf8ArrayToString } from \"@stryke/convert/utf8-array-to-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\n\n// map 6 bits [0, 64) into ascii byte (8 bits)\n// generated by\n// Array.from(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\", c => c.charCodeAt(0))\n// biome-ignore format:\nconst ENCODE_MAP = new Uint8Array([\n 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,\n 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,\n 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,\n 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47\n]);\n\n// \"=\".codePointAt(0)\nconst ENCODE_PAD = 61;\n\n// inverse of ENCODE_MAP\n// generated by\n// ENCODE_MAP.reduce((acc, v, i) => { acc[v] = i; return acc }, Array(255).fill(100))\n// biome-ignore format:\nconst DECODE_MAP = new Uint8Array([\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 62, 100, 100,\n 100, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 100, 100, 100, 100, 100, 100,\n 100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,\n 21, 22, 23, 24, 25, 100, 100, 100, 100, 100, 100, 26, 27, 28, 29, 30, 31, 32,\n 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100\n]);\n\n/**\n * Encodes a Uint8Array into a Base64 encoded Uint8Array.\n *\n * @credit https://github.com/hi-ogawa/js-utils\n *\n * @param input - The input Uint8Array or string to encode.\n * @returns The Base64 encoded Uint8Array.\n */\nexport function encodeBase64(input: Uint8Array | string): string {\n if (isString(input)) {\n input = stringToUint8Array(input);\n }\n\n const xLen = input.length;\n const result = new Uint8Array(Math.ceil(xLen / 3) * 4);\n const chunkLen = Math.floor(xLen / 3);\n\n // encode complete chunks\n for (let i = 0; i < chunkLen; i++) {\n const chunk =\n (input[3 * i + 0]! << 16) | (input[3 * i + 1]! << 8) | input[3 * i + 2]!;\n result[4 * i + 0] = ENCODE_MAP[(chunk >> 18) & 0b111111]!;\n result[4 * i + 1] = ENCODE_MAP[(chunk >> 12) & 0b111111]!;\n result[4 * i + 2] = ENCODE_MAP[(chunk >> 6) & 0b111111]!;\n result[4 * i + 3] = ENCODE_MAP[(chunk >> 0) & 0b111111]!;\n }\n\n // encode partial chunk with padding\n const i = chunkLen;\n switch (xLen % 3) {\n case 1: {\n const chunk = input[3 * i + 0]! << 16;\n result[4 * i + 0] = ENCODE_MAP[(chunk >> 18) & 0b111111]!;\n result[4 * i + 1] = ENCODE_MAP[(chunk >> 12) & 0b111111]!;\n result[4 * i + 2] = ENCODE_PAD;\n result[4 * i + 3] = ENCODE_PAD;\n break;\n }\n case 2: {\n const chunk = (input[3 * i + 0]! << 16) | (input[3 * i + 1]! << 8);\n result[4 * i + 0] = ENCODE_MAP[(chunk >> 18) & 0b111111]!;\n result[4 * i + 1] = ENCODE_MAP[(chunk >> 12) & 0b111111]!;\n result[4 * i + 2] = ENCODE_MAP[(chunk >> 6) & 0b111111]!;\n result[4 * i + 3] = ENCODE_PAD;\n break;\n }\n }\n\n return utf8ArrayToString(result);\n}\n\n/**\n * Decodes a Base64 encoded Uint8Array into a Uint8Array.\n *\n * @credit https://github.com/hi-ogawa/js-utils\n *\n * @param input - The Base64 encoded Uint8Array or string to decode.\n * @returns The decoded Uint8Array.\n */\nexport function decodeBase64(input: Uint8Array | string): Uint8Array {\n if (isString(input)) {\n input = stringToUint8Array(input);\n }\n\n const yLen = input.length;\n\n // validate length\n if (yLen % 4 !== 0) {\n throw new Error(\"invalid length\");\n }\n\n // get padding length\n let padLen = 0;\n while (\n padLen < 2 &&\n padLen < input.length &&\n input[input.length - 1 - padLen] === ENCODE_PAD\n ) {\n padLen++;\n }\n\n // validate encoding\n for (let i = 0; i < input.length - padLen; i++) {\n if (\n isUndefined(input[i]) ||\n isUndefined(DECODE_MAP[input[i]!]) ||\n DECODE_MAP[input[i]!]! >= 64\n ) {\n throw new Error(\"invalid data\");\n }\n }\n\n // validate encoding\n const chunkLen = Math.floor((yLen - padLen) / 4);\n const xLen = 3 * chunkLen + ((3 - padLen) % 3);\n const result = new Uint8Array(xLen);\n\n // decode complete chunks\n for (let i = 0; i < chunkLen; i++) {\n const chunk =\n (DECODE_MAP[input[4 * i + 0]!]! << 18) |\n (DECODE_MAP[input[4 * i + 1]!]! << 12) |\n (DECODE_MAP[input[4 * i + 2]!]! << 6) |\n (DECODE_MAP[input[4 * i + 3]!]! << 0);\n result[3 * i] = (chunk >> 16) & 0xff;\n result[3 * i + 1] = (chunk >> 8) & 0xff;\n result[3 * i + 2] = (chunk >> 0) & 0xff;\n }\n\n // decode partial chunk\n const i = chunkLen;\n switch (xLen % 3) {\n case 1: {\n const chunk =\n (DECODE_MAP[input[4 * i + 0]!]! << 18) |\n (DECODE_MAP[input[4 * i + 1]!]! << 12);\n result[3 * i] = (chunk >> 16) & 0xff;\n break;\n }\n case 2: {\n const chunk =\n (DECODE_MAP[input[4 * i + 0]!]! << 18) |\n (DECODE_MAP[input[4 * i + 1]!]! << 12) |\n (DECODE_MAP[input[4 * i + 2]!]! << 6);\n result[3 * i] = (chunk >> 16) & 0xff;\n result[3 * i + 1] = (chunk >> 8) & 0xff;\n break;\n }\n }\n\n return result;\n}\n\n/**\n * Converts a Base64 encoded string to a [Base64url](https://datatracker.ietf.org/doc/html/rfc7515#appendix-C) encoded string.\n *\n * @see https://datatracker.ietf.org/doc/html/rfc7515#appendix-C\n *\n * @param base64 - The Base64 encoded string to convert.\n * @returns The Base64url encoded string.\n */\nexport function base64UrlEncode(base64: Uint8Array): string {\n return btoa(String.fromCharCode(...base64))\n .replace(/\\+/g, \"-\")\n .replace(/\\//g, \"_\")\n .replace(/=/g, \"\");\n}\n\n/**\n * Converts a [Base64url](https://datatracker.ietf.org/doc/html/rfc7515#appendix-C) encoded string to a Base64 encoded string.\n *\n * @see https://datatracker.ietf.org/doc/html/rfc7515#appendix-C\n *\n * @param base64url - The Base64url encoded string to convert.\n * @returns The Base64 encoded string.\n */\nexport function base64UrlDecode(base64url: string): Uint8Array {\n const base64 = base64url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n\n return new Uint8Array(\n [...atob(base64 + \"=\".repeat((4 - (base64.length % 4)) % 4))].map(c =>\n c.charCodeAt(0)\n )\n );\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Buffer } from \"node:buffer\";\nimport type { BinaryLike, KeyObject } from \"node:crypto\";\nimport {\n createCipheriv,\n createDecipheriv,\n createSecretKey,\n pbkdf2Sync,\n randomBytes\n} from \"node:crypto\";\n\n// Background:\n// https://security.stackexchange.com/questions/184305/why-would-i-ever-use-aes-256-cbc-if-aes-256-gcm-is-more-secure\n\nconst CIPHER_ALGORITHM = \"chacha20-poly1305\";\nconst CIPHER_KEY_LENGTH = 32; // https://stackoverflow.com/a/28307668/4397028\nconst CIPHER_IV_LENGTH = 16; // https://stackoverflow.com/a/28307668/4397028\nconst CIPHER_TAG_LENGTH = 16;\nconst CIPHER_SALT_LENGTH = 64;\n\nconst PBKDF2_ITERATIONS = 100_000; // https://support.1password.com/pbkdf2/\n\n/**\n * Creates and returns a new key object containing a secret key for symmetric encryption or \\`Hmac\\`.\n *\n * @param key - The key to use when creating the \\`KeyObject\\`.\n * @returns The new \\`KeyObject\\`.\n */\nexport function createKey(key: NodeJS.ArrayBufferView): KeyObject;\n\n/**\n * Creates and returns a new key object containing a secret key for symmetric encryption or \\`Hmac\\`.\n *\n * @param key - The key to use. If \\`key\\` is a \\`Buffer\\`, \\`TypedArray\\`, or \\`DataView\\`, the \\`encoding\\` argument is ignored.\n * @param encoding - The \\`encoding\\` of the \\`key\\` string. Must be one of \\`'utf8'\\`, \\`'utf16le'\\`, \\`'latin1'\\`, or \\`'base64'\\`. Default is \\`'utf8'\\`.\n * @returns The new \\`KeyObject\\`.\n */\nexport function createKey(key: string, encoding: BufferEncoding): KeyObject;\n\n/**\n * Creates and returns a new key object containing a secret key for symmetric encryption or \\`Hmac\\`.\n *\n * @param key - The key to use. If \\`key\\` is a \\`Buffer\\`, \\`TypedArray\\`, or \\`DataView\\`, the \\`encoding\\` argument is ignored.\n * @param encoding - The \\`encoding\\` of the \\`key\\` string. Must be one of \\`'utf8'\\`, \\`'utf16le'\\`, \\`'latin1'\\`, or \\`'base64'\\`. Default is \\`'utf8'\\`.\n * @returns The new \\`KeyObject\\`.\n */\nexport function createKey(\n key: string | NodeJS.ArrayBufferView,\n encoding?: BufferEncoding\n): KeyObject {\n return typeof key === \"string\"\n ? createSecretKey(key, encoding!)\n : createSecretKey(key);\n}\n\n/**\n * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.\n *\n * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305\n *\n * @param secret - The secret key used for encryption.\n * @param plaintext - The data to encrypt.\n * @returns The encrypted data.\n */\nexport function encrypt(secret: BinaryLike, plaintext: string): string {\n // https://nodejs.org/api/crypto.html#crypto_crypto_pbkdf2sync_password_salt_iterations_keylen_digest\n const key = pbkdf2Sync(\n secret,\n randomBytes(CIPHER_SALT_LENGTH),\n PBKDF2_ITERATIONS,\n CIPHER_KEY_LENGTH,\n \"sha512\"\n );\n\n const iv = randomBytes(CIPHER_IV_LENGTH);\n const salt = randomBytes(CIPHER_SALT_LENGTH);\n\n const cipher = createCipheriv(\n CIPHER_ALGORITHM,\n key,\n randomBytes(CIPHER_IV_LENGTH)\n );\n const encrypted = Buffer.concat([\n cipher.update(plaintext, \"utf8\"),\n cipher.final()\n ]);\n\n // https://nodejs.org/api/crypto.html#crypto_cipher_getauthtag\n const tag = cipher.getAuthTag();\n\n return Buffer.concat([\n // Data as required by: https://nodejs.org/api/crypto.html#crypto_crypto_createcipheriv_algorithm_key_iv_options\n salt, // Salt for Key: https://nodejs.org/api/crypto.html#crypto_crypto_pbkdf2sync_password_salt_iterations_keylen_digest\n iv, // IV: https://nodejs.org/api/crypto.html#crypto_class_decipher\n tag, // Tag: https://nodejs.org/api/crypto.html#crypto_decipher_setauthtag_buffer\n encrypted\n ]).toString(\"hex\");\n}\n\n/**\n * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.\n *\n * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305\n *\n * @param secret - The secret key used for decryption.\n * @param encrypted - The encrypted data to decrypt.\n * @returns The decrypted data.\n */\nexport function decrypt(secret: BinaryLike, encrypted: string): string {\n const buffer = Buffer.from(encrypted, \"hex\");\n\n // https://nodejs.org/api/crypto.html#crypto_crypto_pbkdf2sync_password_salt_iterations_keylen_digest\n const key = pbkdf2Sync(\n secret,\n buffer.slice(0, CIPHER_SALT_LENGTH),\n PBKDF2_ITERATIONS,\n CIPHER_KEY_LENGTH,\n \"sha512\"\n );\n\n const decipher = createDecipheriv(\n CIPHER_ALGORITHM,\n key,\n buffer.slice(CIPHER_SALT_LENGTH, CIPHER_SALT_LENGTH + CIPHER_IV_LENGTH)\n );\n decipher.setAuthTag(\n buffer.slice(\n CIPHER_SALT_LENGTH + CIPHER_IV_LENGTH,\n CIPHER_SALT_LENGTH + CIPHER_IV_LENGTH + CIPHER_TAG_LENGTH\n )\n );\n\n return (\n // eslint-disable-next-line ts/restrict-plus-operands\n decipher.update(\n buffer.slice(CIPHER_SALT_LENGTH + CIPHER_IV_LENGTH + CIPHER_TAG_LENGTH)\n ) + decipher.final(\"utf8\")\n );\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nconst ALPHABET = \"0123456789ABCDEF\";\nconst DECODE_MAP: Record<string, number> = {\n \"0\": 0,\n \"1\": 1,\n \"2\": 2,\n \"3\": 3,\n \"4\": 4,\n \"5\": 5,\n \"6\": 6,\n \"7\": 7,\n \"8\": 8,\n \"9\": 9,\n a: 10,\n A: 10,\n b: 11,\n B: 11,\n c: 12,\n C: 12,\n d: 13,\n D: 13,\n e: 14,\n E: 14,\n f: 15,\n F: 15\n};\n\n/**\n * Encodes a Uint8Array into a hexadecimal string.\n *\n * @param input - The input Uint8Array.\n * @returns The hexadecimal string.\n */\nexport function encodeHex(input: Uint8Array): string {\n let result = \"\";\n for (let i = 0; i < input.length; i++) {\n result += ALPHABET[input[i]! >> 4];\n result += ALPHABET[input[i]! & 0x0f];\n }\n return result;\n}\n\n/**\n * Encodes a Uint8Array into an uppercase hexadecimal string.\n *\n * @param input - The input Uint8Array.\n * @returns The uppercase hexadecimal string.\n */\nexport function decodeHex(input: string): Uint8Array {\n if (input.length % 2 !== 0) {\n throw new Error(\"Invalid hex string\");\n }\n const result = new Uint8Array(input.length / 2);\n for (let i = 0; i < input.length; i += 2) {\n if (!(input[i]! in DECODE_MAP)) {\n throw new Error(\"Invalid character\");\n }\n if (!(input[i + 1]! in DECODE_MAP)) {\n throw new Error(\"Invalid character\");\n }\n result[i / 2]! |= DECODE_MAP[input[i]!]! << 4;\n result[i / 2]! |= DECODE_MAP[input[i + 1]!]!;\n }\n return result;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Generate a random byte array of the specified length using the Web Crypto API.\n *\n * @param length - The length of the random byte array to generate (default is 32 bytes)\n * @returns A Uint8Array containing random bytes of the specified length\n */\nexport function generateRandomBytes(length: number = 32): Uint8Array {\n return crypto.getRandomValues(new Uint8Array(length));\n}\n\n/**\n * Generate a random string of the specified length using characters A-Z, a-z, and 0-9 for CSRF tokens, etc.\n *\n * @remarks\n * This function uses the Web Crypto API's `crypto.getRandomValues` to generate secure random bytes,\n * and then maps those bytes to characters in the specified character set. It uses rejection sampling\n * to ensure a uniform distribution of characters without modulo bias.\n *\n * @param length - The length of the random string to generate (default is 32 characters)\n * @returns A random string of the specified length\n */\nexport function generateRandomString(length: number = 32): string {\n const chars =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n const charsLen = chars.length; // 62 characters\n // Use rejection sampling to avoid modulo bias\n // 256 % 62 = 8, so we reject values >= 248 to ensure uniform distribution\n const maxValid = 256 - (256 % charsLen); // 248\n const result: string[] = [];\n\n while (result.length < length) {\n const bytes = generateRandomBytes(length - result.length);\n for (const b of bytes) {\n if (b < maxValid && result.length < length && chars[b % charsLen]) {\n result.push(chars[b % charsLen]!);\n }\n }\n }\n\n return result.join(\"\");\n}\n"],"mappings":";;;;AAkBA,MAAa,eAAe,UAAuC;AACjE,QAAO,UAAU;;;;;ACDnB,MAAa,iBAAiB,OAAO,WAAW;;;;AAKhD,MAAaA,WAAmC,iBAC5C,OAAO,SAAS,KAAK,OAAO,GAO5B,SAASC,WACP,OACiB;AACjB,QAAO;;;;;ACdb,MAAM,iBAAgB,QAAO;AAC3B,KAAI,OAAO,eAAe,SACxB,QAAO;AAET,QAAO,eAAe,KAAK,0BAA0B;EACnD,MAAM;AACJ,UAAO;;EAET,cAAc;EACf,CAAC;AAOF,Q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WAAW,OAAO,CAAC;;;;;;;;;;;;;AAcvD,SAAgB,qBAAqB,SAAiB,IAAY;CAChE,MAAM,QACJ;CACF,MAAM,WAAW;CAGjB,MAAM,WAAW,MAAO,MAAM;CAC9B,MAAMC,SAAmB,EAAE;AAE3B,QAAO,OAAO,SAAS,QAAQ;EAC7B,MAAM,QAAQ,oBAAoB,SAAS,OAAO,OAAO;AACzD,OAAK,MAAM,KAAK,MACd,KAAI,IAAI,YAAY,OAAO,SAAS,UAAU,MAAM,IAAI,UACtD,QAAO,KAAK,MAAM,IAAI,UAAW;;AAKvC,QAAO,OAAO,KAAK,GAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/crypto",
3
- "version": "0.5.44",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "description": "A package containing cryptographic utilities used by Storm Software.",
6
6
  "repository": {
@@ -12,32 +12,67 @@
12
12
  "main": "./dist/index.cjs",
13
13
  "module": "./dist/index.mjs",
14
14
  "exports": {
15
- ".": { "require": "./dist/index.cjs", "import": "./dist/index.mjs" },
16
- "./base-64": {
17
- "require": "./dist/base-64.cjs",
18
- "import": "./dist/base-64.mjs"
15
+ ".": {
16
+ "require": {
17
+ "type": "./dist/index.d.cts",
18
+ "default": "./dist/index.cjs"
19
+ },
20
+ "import": { "type": "./dist/index.d.mts", "default": "./dist/index.mjs" },
21
+ "default": { "type": "./dist/index.d.mts", "default": "./dist/index.mjs" }
19
22
  },
20
- "./encryption": {
21
- "require": "./dist/encryption.cjs",
22
- "import": "./dist/encryption.mjs"
23
+ "./index": {
24
+ "require": {
25
+ "type": "./dist/index.d.cts",
26
+ "default": "./dist/index.cjs"
27
+ },
28
+ "import": { "type": "./dist/index.d.mts", "default": "./dist/index.mjs" },
29
+ "default": { "type": "./dist/index.d.mts", "default": "./dist/index.mjs" }
23
30
  },
24
- "./encryption.node": {
25
- "require": "./dist/encryption.node.cjs",
26
- "import": "./dist/encryption.node.mjs"
27
- },
28
- "./hex": { "require": "./dist/hex.cjs", "import": "./dist/hex.mjs" },
29
31
  "./neutral": {
30
- "require": "./dist/neutral.cjs",
31
- "import": "./dist/neutral.mjs"
32
+ "require": {
33
+ "type": "./dist/neutral.d.cts",
34
+ "default": "./dist/neutral.cjs"
35
+ },
36
+ "import": {
37
+ "type": "./dist/neutral.d.mts",
38
+ "default": "./dist/neutral.mjs"
39
+ },
40
+ "default": {
41
+ "type": "./dist/neutral.d.mts",
42
+ "default": "./dist/neutral.mjs"
43
+ }
44
+ },
45
+ "./node": {
46
+ "require": { "type": "./dist/node.d.cts", "default": "./dist/node.cjs" },
47
+ "import": { "type": "./dist/node.d.mts", "default": "./dist/node.mjs" },
48
+ "default": { "type": "./dist/node.d.mts", "default": "./dist/node.mjs" }
32
49
  },
33
- "./*": "./*"
50
+ "./cloudflare": {
51
+ "require": {
52
+ "type": "./dist/cloudflare.d.cts",
53
+ "default": "./dist/cloudflare.cjs"
54
+ },
55
+ "import": {
56
+ "type": "./dist/cloudflare.d.mts",
57
+ "default": "./dist/cloudflare.mjs"
58
+ },
59
+ "default": {
60
+ "type": "./dist/cloudflare.d.mts",
61
+ "default": "./dist/cloudflare.mjs"
62
+ }
63
+ }
34
64
  },
35
65
  "types": "./dist/index.d.cts",
36
66
  "dependencies": {
37
- "@stryke/convert": "^0.6.43",
38
- "@stryke/type-checks": "^0.5.28"
67
+ "@stryke/convert": "^0.6.45",
68
+ "@stryke/json": "^0.13.0",
69
+ "@stryke/type-checks": "^0.5.30"
70
+ },
71
+ "devDependencies": {
72
+ "@cloudflare/workers-types": "^4.20260305.0",
73
+ "@types/node": "^24.11.0",
74
+ "tsdown": "^0.17.2"
39
75
  },
40
- "devDependencies": { "@types/node": "^24.11.0", "tsdown": "^0.17.2" },
41
76
  "publishConfig": { "access": "public" },
42
- "gitHead": "c19d9de45cecf6e0cc805e04358c9dc9d9e4eb6a"
77
+ "gitHead": "793c21dcc2c0734890ffe5e40bd69683455dc301"
43
78
  }
package/dist/base-64.cjs DELETED
@@ -1,440 +0,0 @@
1
- const require_is_undefined = require('./type-checks/src/is-undefined.cjs');
2
- const require_is_string = require('./type-checks/src/is-string.cjs');
3
- const require_string_to_uint8_array = require('./convert/src/string-to-uint8-array.cjs');
4
- const require_utf8_array_to_string = require('./convert/src/utf8-array-to-string.cjs');
5
- require('./convert/src/neutral.cjs');
6
-
7
- //#region src/base-64.ts
8
- const ENCODE_MAP = new Uint8Array([
9
- 65,
10
- 66,
11
- 67,
12
- 68,
13
- 69,
14
- 70,
15
- 71,
16
- 72,
17
- 73,
18
- 74,
19
- 75,
20
- 76,
21
- 77,
22
- 78,
23
- 79,
24
- 80,
25
- 81,
26
- 82,
27
- 83,
28
- 84,
29
- 85,
30
- 86,
31
- 87,
32
- 88,
33
- 89,
34
- 90,
35
- 97,
36
- 98,
37
- 99,
38
- 100,
39
- 101,
40
- 102,
41
- 103,
42
- 104,
43
- 105,
44
- 106,
45
- 107,
46
- 108,
47
- 109,
48
- 110,
49
- 111,
50
- 112,
51
- 113,
52
- 114,
53
- 115,
54
- 116,
55
- 117,
56
- 118,
57
- 119,
58
- 120,
59
- 121,
60
- 122,
61
- 48,
62
- 49,
63
- 50,
64
- 51,
65
- 52,
66
- 53,
67
- 54,
68
- 55,
69
- 56,
70
- 57,
71
- 43,
72
- 47
73
- ]);
74
- const ENCODE_PAD = 61;
75
- const DECODE_MAP = new Uint8Array([
76
- 100,
77
- 100,
78
- 100,
79
- 100,
80
- 100,
81
- 100,
82
- 100,
83
- 100,
84
- 100,
85
- 100,
86
- 100,
87
- 100,
88
- 100,
89
- 100,
90
- 100,
91
- 100,
92
- 100,
93
- 100,
94
- 100,
95
- 100,
96
- 100,
97
- 100,
98
- 100,
99
- 100,
100
- 100,
101
- 100,
102
- 100,
103
- 100,
104
- 100,
105
- 100,
106
- 100,
107
- 100,
108
- 100,
109
- 100,
110
- 100,
111
- 100,
112
- 100,
113
- 100,
114
- 100,
115
- 100,
116
- 100,
117
- 100,
118
- 100,
119
- 62,
120
- 100,
121
- 100,
122
- 100,
123
- 63,
124
- 52,
125
- 53,
126
- 54,
127
- 55,
128
- 56,
129
- 57,
130
- 58,
131
- 59,
132
- 60,
133
- 61,
134
- 100,
135
- 100,
136
- 100,
137
- 100,
138
- 100,
139
- 100,
140
- 100,
141
- 0,
142
- 1,
143
- 2,
144
- 3,
145
- 4,
146
- 5,
147
- 6,
148
- 7,
149
- 8,
150
- 9,
151
- 10,
152
- 11,
153
- 12,
154
- 13,
155
- 14,
156
- 15,
157
- 16,
158
- 17,
159
- 18,
160
- 19,
161
- 20,
162
- 21,
163
- 22,
164
- 23,
165
- 24,
166
- 25,
167
- 100,
168
- 100,
169
- 100,
170
- 100,
171
- 100,
172
- 100,
173
- 26,
174
- 27,
175
- 28,
176
- 29,
177
- 30,
178
- 31,
179
- 32,
180
- 33,
181
- 34,
182
- 35,
183
- 36,
184
- 37,
185
- 38,
186
- 39,
187
- 40,
188
- 41,
189
- 42,
190
- 43,
191
- 44,
192
- 45,
193
- 46,
194
- 47,
195
- 48,
196
- 49,
197
- 50,
198
- 51,
199
- 100,
200
- 100,
201
- 100,
202
- 100,
203
- 100,
204
- 100,
205
- 100,
206
- 100,
207
- 100,
208
- 100,
209
- 100,
210
- 100,
211
- 100,
212
- 100,
213
- 100,
214
- 100,
215
- 100,
216
- 100,
217
- 100,
218
- 100,
219
- 100,
220
- 100,
221
- 100,
222
- 100,
223
- 100,
224
- 100,
225
- 100,
226
- 100,
227
- 100,
228
- 100,
229
- 100,
230
- 100,
231
- 100,
232
- 100,
233
- 100,
234
- 100,
235
- 100,
236
- 100,
237
- 100,
238
- 100,
239
- 100,
240
- 100,
241
- 100,
242
- 100,
243
- 100,
244
- 100,
245
- 100,
246
- 100,
247
- 100,
248
- 100,
249
- 100,
250
- 100,
251
- 100,
252
- 100,
253
- 100,
254
- 100,
255
- 100,
256
- 100,
257
- 100,
258
- 100,
259
- 100,
260
- 100,
261
- 100,
262
- 100,
263
- 100,
264
- 100,
265
- 100,
266
- 100,
267
- 100,
268
- 100,
269
- 100,
270
- 100,
271
- 100,
272
- 100,
273
- 100,
274
- 100,
275
- 100,
276
- 100,
277
- 100,
278
- 100,
279
- 100,
280
- 100,
281
- 100,
282
- 100,
283
- 100,
284
- 100,
285
- 100,
286
- 100,
287
- 100,
288
- 100,
289
- 100,
290
- 100,
291
- 100,
292
- 100,
293
- 100,
294
- 100,
295
- 100,
296
- 100,
297
- 100,
298
- 100,
299
- 100,
300
- 100,
301
- 100,
302
- 100,
303
- 100,
304
- 100,
305
- 100,
306
- 100,
307
- 100,
308
- 100,
309
- 100,
310
- 100,
311
- 100,
312
- 100,
313
- 100,
314
- 100,
315
- 100,
316
- 100,
317
- 100,
318
- 100,
319
- 100,
320
- 100,
321
- 100,
322
- 100,
323
- 100,
324
- 100,
325
- 100,
326
- 100,
327
- 100,
328
- 100,
329
- 100,
330
- 100
331
- ]);
332
- /**
333
- * Encodes a Uint8Array into a Base64 encoded Uint8Array.
334
- *
335
- * @credit https://github.com/hi-ogawa/js-utils
336
- *
337
- * @param input - The input Uint8Array or string to encode.
338
- * @returns The Base64 encoded Uint8Array.
339
- */
340
- function encodeBase64(input) {
341
- if (require_is_string.isString(input)) input = require_string_to_uint8_array.stringToUint8Array(input);
342
- const xLen = input.length;
343
- const result = new Uint8Array(Math.ceil(xLen / 3) * 4);
344
- const chunkLen = Math.floor(xLen / 3);
345
- for (let i$1 = 0; i$1 < chunkLen; i$1++) {
346
- const chunk = input[3 * i$1 + 0] << 16 | input[3 * i$1 + 1] << 8 | input[3 * i$1 + 2];
347
- result[4 * i$1 + 0] = ENCODE_MAP[chunk >> 18 & 63];
348
- result[4 * i$1 + 1] = ENCODE_MAP[chunk >> 12 & 63];
349
- result[4 * i$1 + 2] = ENCODE_MAP[chunk >> 6 & 63];
350
- result[4 * i$1 + 3] = ENCODE_MAP[chunk >> 0 & 63];
351
- }
352
- const i = chunkLen;
353
- switch (xLen % 3) {
354
- case 1: {
355
- const chunk = input[3 * i + 0] << 16;
356
- result[4 * i + 0] = ENCODE_MAP[chunk >> 18 & 63];
357
- result[4 * i + 1] = ENCODE_MAP[chunk >> 12 & 63];
358
- result[4 * i + 2] = ENCODE_PAD;
359
- result[4 * i + 3] = ENCODE_PAD;
360
- break;
361
- }
362
- case 2: {
363
- const chunk = input[3 * i + 0] << 16 | input[3 * i + 1] << 8;
364
- result[4 * i + 0] = ENCODE_MAP[chunk >> 18 & 63];
365
- result[4 * i + 1] = ENCODE_MAP[chunk >> 12 & 63];
366
- result[4 * i + 2] = ENCODE_MAP[chunk >> 6 & 63];
367
- result[4 * i + 3] = ENCODE_PAD;
368
- break;
369
- }
370
- }
371
- return require_utf8_array_to_string.utf8ArrayToString(result);
372
- }
373
- /**
374
- * Decodes a Base64 encoded Uint8Array into a Uint8Array.
375
- *
376
- * @credit https://github.com/hi-ogawa/js-utils
377
- *
378
- * @param input - The Base64 encoded Uint8Array or string to decode.
379
- * @returns The decoded Uint8Array.
380
- */
381
- function decodeBase64(input) {
382
- if (require_is_string.isString(input)) input = require_string_to_uint8_array.stringToUint8Array(input);
383
- const yLen = input.length;
384
- if (yLen % 4 !== 0) throw new Error("invalid length");
385
- let padLen = 0;
386
- while (padLen < 2 && padLen < input.length && input[input.length - 1 - padLen] === ENCODE_PAD) padLen++;
387
- for (let i$1 = 0; i$1 < input.length - padLen; i$1++) if (require_is_undefined.isUndefined(input[i$1]) || require_is_undefined.isUndefined(DECODE_MAP[input[i$1]]) || DECODE_MAP[input[i$1]] >= 64) throw new Error("invalid data");
388
- const chunkLen = Math.floor((yLen - padLen) / 4);
389
- const xLen = 3 * chunkLen + (3 - padLen) % 3;
390
- const result = new Uint8Array(xLen);
391
- for (let i$1 = 0; i$1 < chunkLen; i$1++) {
392
- const chunk = DECODE_MAP[input[4 * i$1 + 0]] << 18 | DECODE_MAP[input[4 * i$1 + 1]] << 12 | DECODE_MAP[input[4 * i$1 + 2]] << 6 | DECODE_MAP[input[4 * i$1 + 3]] << 0;
393
- result[3 * i$1] = chunk >> 16 & 255;
394
- result[3 * i$1 + 1] = chunk >> 8 & 255;
395
- result[3 * i$1 + 2] = chunk >> 0 & 255;
396
- }
397
- const i = chunkLen;
398
- switch (xLen % 3) {
399
- case 1: {
400
- const chunk = DECODE_MAP[input[4 * i + 0]] << 18 | DECODE_MAP[input[4 * i + 1]] << 12;
401
- result[3 * i] = chunk >> 16 & 255;
402
- break;
403
- }
404
- case 2: {
405
- const chunk = DECODE_MAP[input[4 * i + 0]] << 18 | DECODE_MAP[input[4 * i + 1]] << 12 | DECODE_MAP[input[4 * i + 2]] << 6;
406
- result[3 * i] = chunk >> 16 & 255;
407
- result[3 * i + 1] = chunk >> 8 & 255;
408
- break;
409
- }
410
- }
411
- return result;
412
- }
413
- /**
414
- * Converts a Base64 encoded string to a [Base64url](https://datatracker.ietf.org/doc/html/rfc7515#appendix-C) encoded string.
415
- *
416
- * @see https://datatracker.ietf.org/doc/html/rfc7515#appendix-C
417
- *
418
- * @param base64 - The Base64 encoded string to convert.
419
- * @returns The Base64url encoded string.
420
- */
421
- function base64ToBase64url(base64) {
422
- return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
423
- }
424
- /**
425
- * Converts a [Base64url](https://datatracker.ietf.org/doc/html/rfc7515#appendix-C) encoded string to a Base64 encoded string.
426
- *
427
- * @see https://datatracker.ietf.org/doc/html/rfc7515#appendix-C
428
- *
429
- * @param base64url - The Base64url encoded string to convert.
430
- * @returns The Base64 encoded string.
431
- */
432
- function base64FromBase64url(base64url) {
433
- return base64url.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - base64url.length % 4) % 4);
434
- }
435
-
436
- //#endregion
437
- exports.base64FromBase64url = base64FromBase64url;
438
- exports.base64ToBase64url = base64ToBase64url;
439
- exports.decodeBase64 = decodeBase64;
440
- exports.encodeBase64 = encodeBase64;
@@ -1,40 +0,0 @@
1
- //#region src/base-64.d.ts
2
- /**
3
- * Encodes a Uint8Array into a Base64 encoded Uint8Array.
4
- *
5
- * @credit https://github.com/hi-ogawa/js-utils
6
- *
7
- * @param input - The input Uint8Array or string to encode.
8
- * @returns The Base64 encoded Uint8Array.
9
- */
10
- declare function encodeBase64(input: Uint8Array | string): string;
11
- /**
12
- * Decodes a Base64 encoded Uint8Array into a Uint8Array.
13
- *
14
- * @credit https://github.com/hi-ogawa/js-utils
15
- *
16
- * @param input - The Base64 encoded Uint8Array or string to decode.
17
- * @returns The decoded Uint8Array.
18
- */
19
- declare function decodeBase64(input: Uint8Array | string): Uint8Array;
20
- /**
21
- * Converts a Base64 encoded string to a [Base64url](https://datatracker.ietf.org/doc/html/rfc7515#appendix-C) encoded string.
22
- *
23
- * @see https://datatracker.ietf.org/doc/html/rfc7515#appendix-C
24
- *
25
- * @param base64 - The Base64 encoded string to convert.
26
- * @returns The Base64url encoded string.
27
- */
28
- declare function base64ToBase64url(base64: string): string;
29
- /**
30
- * Converts a [Base64url](https://datatracker.ietf.org/doc/html/rfc7515#appendix-C) encoded string to a Base64 encoded string.
31
- *
32
- * @see https://datatracker.ietf.org/doc/html/rfc7515#appendix-C
33
- *
34
- * @param base64url - The Base64url encoded string to convert.
35
- * @returns The Base64 encoded string.
36
- */
37
- declare function base64FromBase64url(base64url: string): string;
38
- //#endregion
39
- export { base64FromBase64url, base64ToBase64url, decodeBase64, encodeBase64 };
40
- //# sourceMappingURL=base-64.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-64.d.cts","names":[],"sources":["../src/base-64.ts"],"sourcesContent":[],"mappings":";;AAoEA;AAmDA;AAkFA;AAYA;;;;iBAjJgB,YAAA,QAAoB;;;;;;;;;iBAmDpB,YAAA,QAAoB,sBAAsB;;;;;;;;;iBAkF1C,iBAAA;;;;;;;;;iBAYA,mBAAA"}