@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":"cloudflare.mjs","names":["isBuffer: typeof Buffer.isBuffer","isBuffer","DECODE_MAP","i","jwk: JsonWebKey","DECODE_MAP: Record<string, number>","result: string[]"],"sources":["../../json/src/canonical.ts","../../convert/src/array-buffer-to-string.ts","../../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/uint8-array-to-stream.ts","../../convert/src/uint8-array-to-string.ts","../../convert/src/utf8-array-to-string.ts","../src/base-64.ts","../src/ed25519.ts","../src/hex.ts","../src/encryption.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\n/**\n * Converts a JavaScript value to a canonical JSON string representation. This function is used for signing JSON objects in a consistent way, ensuring that the same input will always produce the same output string. The canonicalization process includes:\n * - Sorting object keys in lexicographical order.\n * - Removing whitespace and line breaks.\n * - Representing primitive values (null, boolean, number, string) in their standard JSON format.\n * - Recursively applying these rules to nested objects and arrays.\n *\n * This function is designed to produce a deterministic string representation of a JSON value, which is essential for cryptographic signing and verification processes where the exact byte representation of the data must be consistent across different environments and implementations.\n *\n * @param obj - The JavaScript value to convert to a canonical JSON string.\n * @returns A canonical JSON string representation of the input value.\n */\nexport function canonicalJson(obj: unknown): string {\n if (obj === null || obj === undefined) {\n return \"null\";\n }\n\n if (typeof obj === \"boolean\" || typeof obj === \"number\") {\n return JSON.stringify(obj);\n }\n\n if (typeof obj === \"string\") {\n return JSON.stringify(obj);\n }\n\n if (Array.isArray(obj)) {\n const items = obj.map(item => canonicalJson(item));\n\n return `[${items.join(\",\")}]`;\n }\n\n if (typeof obj === \"object\") {\n const keys = Object.keys(obj).sort();\n const pairs = keys.map(key => {\n const value = canonicalJson((obj as Record<string, unknown>)[key]);\n\n return `${JSON.stringify(key)}:${value}`;\n });\n\n return `{${pairs.join(\",\")}}`;\n }\n\n return \"null\";\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 an ArrayBuffer or Uint8Array to a string\n *\n * @param buffer - The ArrayBuffer or Uint8Array to convert\n * @returns The converted string\n */\nexport function arrayBufferToString(\n buffer: ArrayBuffer | ArrayBufferLike | Uint8Array\n): string {\n const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);\n const len = bytes.byteLength;\n if (len < 65535) {\n return String.fromCharCode.apply(null, bytes as unknown as number[]);\n }\n let binary = \"\";\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]!);\n }\n return binary;\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 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\n/**\n * Convert a Uint8Array to a ReadableStream\n *\n * @param data - The Uint8Array to convert\n * @returns The converted ReadableStream\n */\nexport function uint8ArrayToStream(\n data: Uint8Array\n): ReadableStream<Uint8Array> {\n return new ReadableStream({\n start(controller) {\n controller.enqueue(data);\n controller.close();\n }\n });\n}\n\n/**\n * Concatenate an array of Uint8Array chunks into a single Uint8Array\n *\n * @param chunks - Array of Uint8Array chunks to concatenate\n * @returns The concatenated Uint8Array\n */\nexport function concatUint8Array(chunks: Uint8Array[]): Uint8Array {\n let total = 0;\n for (const chunk of chunks) {\n total += chunk.length;\n }\n const result = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n result.set(chunk, offset);\n offset += chunk.length;\n }\n return result;\n}\n\n/**\n * Concatenate a ReadableStream of Uint8Array chunks into a single Uint8Array\n *\n * @param stream - The ReadableStream of Uint8Array chunks to concatenate\n * @returns A promise that resolves to the concatenated Uint8Array\n */\nexport async function concatUint8ArrayStream(\n stream: ReadableStream<Uint8Array>\n): Promise<Uint8Array> {\n const chunks: Uint8Array[] = [];\n await stream.pipeTo(\n new WritableStream({\n write(chunk) {\n chunks.push(chunk);\n }\n })\n );\n\n return concatUint8Array(chunks);\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 { arrayBufferToString } from \"./array-buffer-to-string\";\n\n/**\n * Convert a Uint8Array to a base64 string\n *\n * @param buffer - The Uint8Array to convert\n * @returns The converted base64 string\n */\nexport function uint8ArrayToString(buffer: Uint8Array): string {\n return btoa(arrayBufferToString(buffer));\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 { canonicalJson } from \"@stryke/json/canonical\";\nimport { base64UrlDecode, base64UrlEncode } from \"./base-64\";\n\n/**\n * Parameters for Ed25519 key generation and signing in Cloudflare Workers. This interface defines the algorithm name and named curve used for Ed25519 operations in the Cloudflare Workers environment. The `name` and `namedCurve` properties are set to \"NODE-ED25519\" to indicate that these parameters are specific to Cloudflare Workers' implementation of Ed25519, which is not compatible with standard Web Crypto API Ed25519 implementations in other environments.\n */\nexport interface Ed25519Params {\n name: \"NODE-ED25519\";\n namedCurve: \"NODE-ED25519\";\n}\n\n/**\n * Represents an Ed25519 key pair with a public key and a private key, both of which are CryptoKey objects. This interface is used to define the structure of the key pair generated by the `generateSigningKeyPair` function, where the `publicKey` is used for signature verification and the `privateKey` is used for signing operations. The keys are generated using Cloudflare Workers' `NODE-ED25519` algorithm parameters, which are specific to Cloudflare Workers' implementation of Ed25519 and are not compatible with standard Web Crypto API Ed25519 implementations in other environments.\n */\nexport interface Ed25519KeyPair {\n publicKey: CryptoKey;\n privateKey: CryptoKey;\n}\n\n/**\n * Generates an Ed25519 key pair using Cloudflare Workers' `NODE-ED25519` algorithm and returns the public key as a base64 string, the private key as a JWK object, and a key ID derived from the public key. The private key is returned as a JWK for compatibility with Web Crypto API operations.\n *\n * @remarks\n * This function uses Cloudflare Workers' `NODE-ED25519` algorithm parameters, which are specific to Cloudflare Workers' implementation of Ed25519. The returned key pair is structured as follows:\n * - The `publicKey` is returned as a base64url-encoded string of the raw public key bytes (the 'x' parameter from the JWK).\n * - The `privateKeyJwk` is returned as a JWK object containing the private key parameters, which can be used for signing operations with the Web Crypto API.\n * - The `keyId` is generated by hashing the raw public key bytes and taking the first 4 bytes of the hash, encoded as a hex string prefixed with \"ed25519:\". This provides a unique identifier for the key pair based on its public key.\n *\n * This function is not compatible with standard Web Crypto API Ed25519 implementations in other environments. The legacy function `generateSigningKeyPairLegacy` is also available for backwards compatibility, which returns the private key as a JSON stringified JWK. However, it is recommended to use this structured version for new code.\n *\n * @returns An object containing the `publicKey` as a base64 string, the `privateKeyJwk` as a JWK object, and a `keyId` derived from the public key.\n * @throws {@link DOMException} If key generation or export fails in the Web Crypto API.\n */\nexport async function generateSigningKeyPair(): Promise<{\n publicKey: string;\n privateKeyJwk: JsonWebKey;\n keyId: string;\n}> {\n // Generate Ed25519 key pair using Cloudflare Workers' native support\n const keyPair = (await crypto.subtle.generateKey(\n { name: \"NODE-ED25519\", namedCurve: \"NODE-ED25519\" } as Ed25519Params,\n true, // extractable\n [\"sign\", \"verify\"]\n )) as Ed25519KeyPair;\n\n // Export the public key as JWK to get the raw key bytes\n const publicKeyJwk = await crypto.subtle.exportKey(\"jwk\", keyPair.publicKey);\n const privateKeyJwk = await crypto.subtle.exportKey(\n \"jwk\",\n keyPair.privateKey\n );\n\n // Get raw public key bytes from the JWK 'x' parameter\n const publicKeyBytes = base64UrlDecode(publicKeyJwk.x!);\n\n // Generate key ID from first 4 bytes of public key hash (for uniqueness)\n const keyIdHash = new Uint8Array(\n await crypto.subtle.digest(\"SHA-256\", publicKeyBytes as BufferSource)\n ).slice(0, 4);\n const keyId = `ed25519:${Array.from(keyIdHash)\n .map(b => b.toString(16).padStart(2, \"0\"))\n .join(\"\")}`;\n\n return {\n publicKey: base64UrlEncode(publicKeyBytes),\n privateKeyJwk,\n keyId\n };\n}\n\n/**\n * Generates an Ed25519 key pair and returns the public key as a base64 string, the private key as a JSON stringified JWK, and a key ID derived from the public key. The private key is returned in a legacy format for compatibility with existing code that expects a JSON string.\n *\n * @remarks\n * Legacy function for backwards compatibility during migration. Returns the old format but with a proper key.\n *\n * @deprecated Use `generateSigningKeyPair` instead, which returns a structured key object and separate key ID. This legacy function is retained for backwards compatibility but may be removed in future releases.\n *\n * @returns An object containing the `publicKey` as a base64 string, the `privateKey` as a JSON stringified JWK, and a `keyId` derived from the public key.\n * @throws {@link SyntaxError} If the generated private key cannot be stringified to JSON (should not occur under normal circumstances).\n */\nexport async function generateSigningKeyPairLegacy(): Promise<{\n publicKey: string;\n privateKey: string;\n keyId: string;\n}> {\n const { publicKey, privateKeyJwk, keyId } = await generateSigningKeyPair();\n\n return {\n publicKey,\n privateKey: JSON.stringify(privateKeyJwk),\n keyId\n };\n}\n\n/**\n * Creates and attaches an [Ed25519 signature](https://matrix.org/docs/spec/client_server/latest#signing-json-objects) for a JSON object using [Matrix-style](https://matrix.org/docs/spec/client_server/latest#signing-json-objects) signing rules.\n *\n * @see https://matrix.org/docs/spec/client_server/latest#signing-json-objects\n *\n * @remarks\n * - Signature output is encoded as un-padded base64url.\n * - The original `obj` is not mutated.\n * - Uses `NODE-ED25519` algorithm parameters for key import/sign operations.\n *\n * The function canonicalizes a copy of the input object after removing the `signatures`\n * and `unsigned` properties, signs that canonical JSON payload with the provided private key,\n * and returns a new object with the generated signature merged into `obj.signatures`.\n *\n * Existing signatures are preserved, including other keys under the same `serverName`.\n *\n * @param obj - The JSON object to sign.\n * @param serverName - The signing entity name used as the top-level key in `signatures`.\n * @param keyId - The key identifier used under `signatures[serverName]`.\n * @param privateKeyJwk - The Ed25519 private key as a JWK object, or a JSON stringified JWK (legacy compatibility).\n * @returns A new object containing all original fields plus an updated `signatures` map with the new signature.\n * @throws {@link SyntaxError} If `privateKeyJwk` is a string that is not valid JSON.\n * @throws {@link DOMException} If key import or signing fails in the Web Crypto API.\n */\nexport async function signJson(\n obj: Record<string, unknown>,\n serverName: string,\n keyId: string,\n privateKeyJwk: JsonWebKey | string\n): Promise<Record<string, unknown>> {\n // Parse JWK if passed as string (for backwards compatibility)\n const jwk: JsonWebKey =\n typeof privateKeyJwk === \"string\"\n ? JSON.parse(privateKeyJwk)\n : privateKeyJwk;\n\n // Remove signatures and unsigned before signing (per Matrix spec)\n const toSign = { ...obj };\n delete toSign.signatures;\n delete toSign.unsigned;\n\n // Import the private key\n const privateKey = await crypto.subtle.importKey(\n \"jwk\",\n jwk,\n { name: \"NODE-ED25519\", namedCurve: \"NODE-ED25519\" } as Ed25519Params,\n false,\n [\"sign\"]\n );\n\n // Get canonical JSON representation\n const canonical = canonicalJson(toSign);\n\n // Sign the canonical JSON\n const signatureBytes = await crypto.subtle.sign(\n { name: \"NODE-ED25519\" },\n privateKey,\n new TextEncoder().encode(canonical)\n );\n\n // Encode signature as un-padded base64\n const signatureB64 = base64UrlEncode(new Uint8Array(signatureBytes));\n\n // Merge with existing signatures if present\n const existingSignatures =\n (obj.signatures as Record<string, Record<string, string>>) ?? {};\n\n return {\n ...obj,\n signatures: {\n ...existingSignatures,\n [serverName]: {\n ...(existingSignatures[serverName] ?? {}),\n [keyId]: signatureB64\n }\n }\n };\n}\n\n/**\n * Verifies an Ed25519 signature on a JSON object using [Matrix-style signing rules](https://matrix.org/docs/spec/client_server/latest#signing-json-objects). The function extracts the relevant signature from the `signatures` property of the input object, removes the `signatures` and `unsigned` properties to create a canonical JSON payload, and then verifies the signature against the provided public key. The public key is expected to be a base64url-encoded string of the raw public key bytes (the 'x' parameter from the JWK). The function returns `true` if the signature is valid and `false` otherwise. Any errors during the verification process are caught and logged, with a return value of `false` in case of failure.\n *\n * @see https://matrix.org/docs/spec/client_server/latest#signing-json-objects\n *\n * @remarks\n * - Signature input is expected to be un-padded base64url.\n * - The original `obj` is not mutated.\n * - Uses `NODE-ED25519` algorithm parameters for key import/verify operations.\n * - The function does not throw on verification failure; it returns `false` instead. Errors during key import or verification are logged to the console for debugging purposes.\n *\n * @param obj - The JSON object containing the signature to verify.\n * @param serverName - The signing entity name used as the top-level key in `signatures`.\n * @param keyId - The key identifier used under `signatures[serverName]` to locate the specific signature to verify.\n * @param publicKeyB64 - The Ed25519 public key as a base64url-encoded string of the raw public key bytes (the 'x' parameter from the JWK).\n * @returns A boolean indicating whether the signature is valid (`true`) or not (`false`). Returns `false` if the signature is missing, invalid, or if any errors occur during the verification process.\n */\nexport async function verifySignature(\n obj: Record<string, unknown>,\n serverName: string,\n keyId: string,\n publicKeyB64: string\n): Promise<boolean> {\n try {\n // Get the signature\n const signatures = obj.signatures as\n | Record<string, Record<string, string>>\n | undefined;\n const signature = signatures?.[serverName]?.[keyId];\n if (!signature) {\n return false;\n }\n\n // Remove signatures and unsigned before verifying\n const toVerify = { ...obj };\n delete toVerify.signatures;\n delete toVerify.unsigned;\n\n // Decode the public key\n const publicKeyBytes = base64UrlDecode(publicKeyB64);\n\n // Import the public key\n const publicKey = await crypto.subtle.importKey(\n \"raw\",\n publicKeyBytes as BufferSource,\n { name: \"NODE-ED25519\", namedCurve: \"NODE-ED25519\" } as Ed25519Params,\n false,\n [\"verify\"]\n );\n\n // Decode the signature\n const signatureBytes = base64UrlDecode(signature);\n\n // Get canonical JSON\n const canonical = canonicalJson(toVerify);\n\n // Verify the signature\n return await crypto.subtle.verify(\n { name: \"NODE-ED25519\" },\n publicKey,\n signatureBytes as BufferSource,\n new TextEncoder().encode(canonical)\n );\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(\"Signature verification failed:\", error);\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\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\nimport {\n base64StringToUint8Array,\n concatUint8Array,\n stringToUtf8Array,\n uint8ArrayToString,\n utf8ArrayToString\n} from \"@stryke/convert/neutral\";\nimport { decodeBase64, encodeBase64 } from \"./base-64\";\nimport { decodeHex, encodeHex } from \"./hex\";\n\n/**\n * Creates a CryptoKey object that can be used to encrypt any string.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey\n *\n * @returns A promise that resolves to a CryptoKey object that can be used to encrypt and decrypt strings.\n */\nexport async function createKey(): Promise<CryptoKey> {\n return crypto.subtle.generateKey(\n {\n name: \"AES-GCM\",\n length: 256\n },\n true,\n [\"encrypt\", \"decrypt\"]\n );\n}\n\n/**\n * Encodes a CryptoKey to base64 string, so that it can be embedded in JSON / JavaScript\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/exportKey\n *\n * @param key - The CryptoKey to encode\n * @returns A promise that resolves to a base64 string representing the key\n */\nexport async function encodeKey(key: CryptoKey): Promise<string> {\n const exported = await crypto.subtle.exportKey(\"raw\", key);\n\n return encodeBase64(new Uint8Array(exported)).toString();\n}\n\n/**\n * Decodes a base64 string into bytes and then imports the key.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey\n *\n * @param encoded - The base64 encoded key\n * @returns A promise that resolves to a CryptoKey object that can be used to encrypt and decrypt strings\n */\nexport async function decodeKey(encoded: string): Promise<CryptoKey> {\n const bytes = decodeBase64(encoded);\n\n return crypto.subtle.importKey(\n \"raw\",\n bytes.buffer as ArrayBuffer,\n \"AES-GCM\",\n true,\n [\"encrypt\", \"decrypt\"]\n );\n}\n\n// The length of the initialization vector\n// See https://developer.mozilla.org/en-US/docs/Web/API/AesGcmParams\nconst IV_LENGTH = 24;\n\n/**\n * Using a CryptoKey, use AES-GCM to encrypt a string into a base64 string.\n *\n * @remarks\n * The initialization vector is randomly generated and prepended to the encrypted string. The IV is required for decryption, so it must be stored alongside the encrypted data.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt\n *\n * @param key - The CryptoKey to use for encryption\n * @param plaintext - The plaintext string to encrypt\n * @returns A promise that resolves to a base64 string representing the encrypted data\n */\nexport async function encrypt(\n key: CryptoKey,\n plaintext: string\n): Promise<string> {\n const iv = crypto.getRandomValues(new Uint8Array(IV_LENGTH / 2));\n const encrypted = await crypto.subtle.encrypt(\n {\n name: \"AES-GCM\",\n iv\n },\n key,\n stringToUtf8Array(plaintext) as BufferSource\n );\n\n // iv is 12, hex brings it to 24\n return encodeHex(iv) + encodeBase64(new Uint8Array(encrypted));\n}\n\n/**\n * Takes a base64 encoded string, decodes it and returns the AES-GCM decrypted text.\n *\n * @remarks\n * The initialization vector is expected to be prepended to the encrypted string. The IV is required for decryption, so it must be extracted from the start of the string.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/decrypt\n *\n * @param key - The CryptoKey to use for decryption\n * @param encrypted - The encrypted base64 encoded string to decrypt\n * @returns A promise that resolves to the decrypted string\n */\nexport async function decrypt(\n key: CryptoKey,\n encrypted: string\n): Promise<string> {\n const decrypted = await crypto.subtle.decrypt(\n {\n name: \"AES-GCM\",\n iv: decodeHex(encrypted.slice(0, IV_LENGTH)) as Uint8Array<ArrayBuffer>\n },\n key,\n decodeBase64(encrypted.slice(IV_LENGTH)) as BufferSource\n );\n\n return utf8ArrayToString(decrypted);\n}\n\n/**\n * Encrypts a buffer using AES-GCM with a given CryptoKey.\n *\n * @remarks\n * The initialization vector (IV) is randomly generated and prepended to the encrypted data. The resulting data is then encoded as a base64 string for easy storage/transmission.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt\n *\n * @param key - The CryptoKey to use for encryption\n * @param buffer - The buffer to encrypt\n * @returns A promise that resolves to a base64 string representing the encrypted data\n */\nexport async function encryptBuffer(\n key: CryptoKey,\n buffer: BufferSource\n): Promise<string> {\n const iv = crypto.getRandomValues(new Uint8Array(16));\n const encrypted = await crypto.subtle.encrypt(\n {\n name: \"AES-GCM\",\n iv\n },\n key,\n buffer\n );\n\n return uint8ArrayToString(concatUint8Array([iv, new Uint8Array(encrypted)]));\n}\n\n/**\n * Decrypts a buffer using AES-GCM with a given CryptoKey.\n *\n * @remarks\n * The initialization vector (IV) is expected to be prepended to the encrypted data. The IV is required for decryption, so it must be extracted from the start of the buffer.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/decrypt\n *\n * @param key - The CryptoKey to use for decryption\n * @param encrypted - The encrypted base64 encoded string to decrypt\n * @returns A promise that resolves to the decrypted string\n */\nexport async function decryptBuffer(\n key: CryptoKey,\n encrypted: string\n): Promise<ArrayBuffer> {\n const concatenated = base64StringToUint8Array(encrypted);\n\n return crypto.subtle.decrypt(\n {\n name: \"AES-GCM\",\n iv: concatenated.slice(0, 16)\n },\n key,\n concatenated.slice(16)\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 * 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)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N;EACD,EACD,KACA,OACD;AAED,QAAO,mBAAmB,iBAAiB,CAAC,IAAI,IAAI,WAAW,UAAU,CAAC,CAAC,CAAC;;;;;;;;;;;;;;AAe9E,eAAsB,cACpB,KACA,WACsB;CACtB,MAAM,eAAe,yBAAyB,UAAU;AAExD,QAAO,OAAO,OAAO,QACnB;EACE,MAAM;EACN,IAAI,aAAa,MAAM,GAAG,GAAG;EAC9B,EACD,KACA,aAAa,MAAM,GAAG,CACvB;;;;;;;;;;;AC5KH,SAAgB,oBAAoB,SAAiB,IAAgB;AACnE,QAAO,OAAO,gBAAgB,IAAI,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/dist/index.cjs CHANGED
@@ -1,13 +1,17 @@
1
- const require_base_64 = require('./base-64.cjs');
2
- const require_encryption_node = require('./encryption.node.cjs');
3
- const require_hex = require('./hex.cjs');
1
+ const require_neutral = require('./neutral-BISXAuIW.cjs');
4
2
 
5
- exports.base64FromBase64url = require_base_64.base64FromBase64url;
6
- exports.base64ToBase64url = require_base_64.base64ToBase64url;
7
- exports.createKey = require_encryption_node.createKey;
8
- exports.decodeBase64 = require_base_64.decodeBase64;
9
- exports.decodeHex = require_hex.decodeHex;
10
- exports.decrypt = require_encryption_node.decrypt;
11
- exports.encodeBase64 = require_base_64.encodeBase64;
12
- exports.encodeHex = require_hex.encodeHex;
13
- exports.encrypt = require_encryption_node.encrypt;
3
+ exports.base64UrlDecode = require_neutral.base64UrlDecode;
4
+ exports.base64UrlEncode = require_neutral.base64UrlEncode;
5
+ exports.createKey = require_neutral.createKey;
6
+ exports.decodeBase64 = require_neutral.decodeBase64;
7
+ exports.decodeHex = require_neutral.decodeHex;
8
+ exports.decodeKey = require_neutral.decodeKey;
9
+ exports.decrypt = require_neutral.decrypt;
10
+ exports.decryptBuffer = require_neutral.decryptBuffer;
11
+ exports.encodeBase64 = require_neutral.encodeBase64;
12
+ exports.encodeHex = require_neutral.encodeHex;
13
+ exports.encodeKey = require_neutral.encodeKey;
14
+ exports.encrypt = require_neutral.encrypt;
15
+ exports.encryptBuffer = require_neutral.encryptBuffer;
16
+ exports.generateRandomBytes = require_neutral.generateRandomBytes;
17
+ exports.generateRandomString = require_neutral.generateRandomString;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,2 @@
1
- import { base64FromBase64url, base64ToBase64url, decodeBase64, encodeBase64 } from "./base-64.cjs";
2
- import { createKey, decrypt, encrypt } from "./encryption.node.cjs";
3
- import { decodeHex, encodeHex } from "./hex.cjs";
4
- export { base64FromBase64url, base64ToBase64url, createKey, decodeBase64, decodeHex, decrypt, encodeBase64, encodeHex, encrypt };
1
+ import { a as createKey, c as decryptBuffer, d as encryptBuffer, f as base64UrlDecode, h as encodeBase64, i as encodeHex, l as encodeKey, m as decodeBase64, n as generateRandomString, o as decodeKey, p as base64UrlEncode, r as decodeHex, s as decrypt, t as generateRandomBytes, u as encrypt } from "./neutral-CW6EXiYo.cjs";
2
+ export { base64UrlDecode, base64UrlEncode, createKey, decodeBase64, decodeHex, decodeKey, decrypt, decryptBuffer, encodeBase64, encodeHex, encodeKey, encrypt, encryptBuffer, generateRandomBytes, generateRandomString };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,2 @@
1
- import { base64FromBase64url, base64ToBase64url, decodeBase64, encodeBase64 } from "./base-64.mjs";
2
- import { createKey, decrypt, encrypt } from "./encryption.node.mjs";
3
- import { decodeHex, encodeHex } from "./hex.mjs";
4
- export { base64FromBase64url, base64ToBase64url, createKey, decodeBase64, decodeHex, decrypt, encodeBase64, encodeHex, encrypt };
1
+ import { a as createKey, c as decryptBuffer, d as encryptBuffer, f as base64UrlDecode, h as encodeBase64, i as encodeHex, l as encodeKey, m as decodeBase64, n as generateRandomString, o as decodeKey, p as base64UrlEncode, r as decodeHex, s as decrypt, t as generateRandomBytes, u as encrypt } from "./neutral-BJmyEdJq.mjs";
2
+ export { base64UrlDecode, base64UrlEncode, createKey, decodeBase64, decodeHex, decodeKey, decrypt, decryptBuffer, encodeBase64, encodeHex, encodeKey, encrypt, encryptBuffer, generateRandomBytes, generateRandomString };
package/dist/index.mjs CHANGED
@@ -1,5 +1,3 @@
1
- import { base64FromBase64url, base64ToBase64url, decodeBase64, encodeBase64 } from "./base-64.mjs";
2
- import { createKey, decrypt, encrypt } from "./encryption.node.mjs";
3
- import { decodeHex, encodeHex } from "./hex.mjs";
1
+ import { a as decrypt, c as encrypt, d as encodeHex, f as base64UrlDecode, h as encodeBase64, i as decodeKey, l as encryptBuffer, m as decodeBase64, n as generateRandomString, o as decryptBuffer, p as base64UrlEncode, r as createKey, s as encodeKey, t as generateRandomBytes, u as decodeHex } from "./neutral-BtZoJSl-.mjs";
4
2
 
5
- export { base64FromBase64url, base64ToBase64url, createKey, decodeBase64, decodeHex, decrypt, encodeBase64, encodeHex, encrypt };
3
+ export { base64UrlDecode, base64UrlEncode, createKey, decodeBase64, decodeHex, decodeKey, decrypt, decryptBuffer, encodeBase64, encodeHex, encodeKey, encrypt, encryptBuffer, generateRandomBytes, generateRandomString };