@stryke/crypto 0.5.34 → 0.5.36

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 (56) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/base-64.cjs +440 -1
  3. package/dist/base-64.mjs +437 -1
  4. package/dist/base-64.mjs.map +1 -1
  5. package/dist/convert/src/array-buffer-to-string.cjs +19 -1
  6. package/dist/convert/src/array-buffer-to-string.mjs +18 -1
  7. package/dist/convert/src/array-buffer-to-string.mjs.map +1 -1
  8. package/dist/convert/src/neutral.cjs +7 -1
  9. package/dist/convert/src/neutral.mjs +9 -1
  10. package/dist/convert/src/parse-type-definition.cjs +1 -1
  11. package/dist/convert/src/parse-type-definition.mjs +3 -1
  12. package/dist/convert/src/string-to-uint8-array.cjs +24 -1
  13. package/dist/convert/src/string-to-uint8-array.mjs +22 -1
  14. package/dist/convert/src/string-to-uint8-array.mjs.map +1 -1
  15. package/dist/convert/src/string-to-utf8-array.cjs +15 -1
  16. package/dist/convert/src/string-to-utf8-array.mjs +14 -1
  17. package/dist/convert/src/string-to-utf8-array.mjs.map +1 -1
  18. package/dist/convert/src/uint8-array-to-stream.cjs +22 -1
  19. package/dist/convert/src/uint8-array-to-stream.mjs +21 -1
  20. package/dist/convert/src/uint8-array-to-stream.mjs.map +1 -1
  21. package/dist/convert/src/uint8-array-to-string.cjs +15 -1
  22. package/dist/convert/src/uint8-array-to-string.mjs +15 -1
  23. package/dist/convert/src/uint8-array-to-string.mjs.map +1 -1
  24. package/dist/convert/src/utf8-array-to-string.cjs +15 -1
  25. package/dist/convert/src/utf8-array-to-string.mjs +14 -1
  26. package/dist/convert/src/utf8-array-to-string.mjs.map +1 -1
  27. package/dist/encryption.cjs +134 -1
  28. package/dist/encryption.mjs +128 -1
  29. package/dist/encryption.mjs.map +1 -1
  30. package/dist/encryption.node.cjs +63 -1
  31. package/dist/encryption.node.mjs +61 -1
  32. package/dist/encryption.node.mjs.map +1 -1
  33. package/dist/hex.cjs +62 -1
  34. package/dist/hex.mjs +60 -1
  35. package/dist/hex.mjs.map +1 -1
  36. package/dist/index.cjs +13 -1
  37. package/dist/index.mjs +5 -1
  38. package/dist/neutral.cjs +17 -1
  39. package/dist/neutral.mjs +5 -1
  40. package/dist/type-checks/src/index.cjs +5 -1
  41. package/dist/type-checks/src/index.mjs +7 -1
  42. package/dist/type-checks/src/is-buffer.cjs +12 -1
  43. package/dist/type-checks/src/is-buffer.mjs +11 -1
  44. package/dist/type-checks/src/is-buffer.mjs.map +1 -1
  45. package/dist/type-checks/src/is-collection.cjs +1 -1
  46. package/dist/type-checks/src/is-collection.mjs +3 -1
  47. package/dist/type-checks/src/is-string.cjs +12 -1
  48. package/dist/type-checks/src/is-string.mjs +11 -1
  49. package/dist/type-checks/src/is-string.mjs.map +1 -1
  50. package/dist/type-checks/src/is-undefined.cjs +8 -1
  51. package/dist/type-checks/src/is-undefined.mjs +7 -1
  52. package/dist/type-checks/src/is-undefined.mjs.map +1 -1
  53. package/dist/type-checks/src/type-detect.cjs +15 -1
  54. package/dist/type-checks/src/type-detect.mjs +16 -1
  55. package/dist/type-checks/src/type-detect.mjs.map +1 -1
  56. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"encryption.node.mjs","names":[],"sources":["../src/encryption.node.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\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"],"mappings":"8JA+BA,MAAM,EAAmB,oBAMnB,EAAoB,IA0B1B,SAAgB,EACd,EACA,EACW,CACX,OAAO,OAAO,GAAQ,SAClB,EAAgB,EAAK,EAAU,CAC/B,EAAgB,EAAI,CAY1B,SAAgB,EAAQ,EAAoB,EAA2B,CAErE,IAAM,EAAM,EACV,EACA,EAAY,GAAmB,CAC/B,EACA,GACA,SACD,CAEK,EAAK,EAAY,GAAiB,CAClC,EAAO,EAAY,GAAmB,CAEtC,EAAS,EACb,EACA,EACA,EAAY,GAAiB,CAC9B,CACK,EAAY,EAAO,OAAO,CAC9B,EAAO,OAAO,EAAW,OAAO,CAChC,EAAO,OAAO,CACf,CAAC,CAGI,EAAM,EAAO,YAAY,CAE/B,OAAO,EAAO,OAAO,CAEnB,EACA,EACA,EACA,EACD,CAAC,CAAC,SAAS,MAAM,CAYpB,SAAgB,EAAQ,EAAoB,EAA2B,CACrE,IAAM,EAAS,EAAO,KAAK,EAAW,MAAM,CAWtC,EAAW,EACf,EATU,EACV,EACA,EAAO,MAAM,EAAG,GAAmB,CACnC,EACA,GACA,SACD,CAKC,EAAO,MAAM,GAAoB,GAAsC,CACxE,CAQD,OAPA,EAAS,WACP,EAAO,MACL,GACA,GACD,CACF,CAIC,EAAS,OACP,EAAO,MAAM,GAA0D,CACxE,CAAG,EAAS,MAAM,OAAO"}
1
+ {"version":3,"file":"encryption.node.mjs","names":[],"sources":["../src/encryption.node.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\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"],"mappings":";;;;AA+BA,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAE3B,MAAM,oBAAoB;;;;;;;;AA0B1B,SAAgB,UACd,KACA,UACW;AACX,QAAO,OAAO,QAAQ,WAClB,gBAAgB,KAAK,SAAU,GAC/B,gBAAgB,IAAI;;;;;;;;;;;AAY1B,SAAgB,QAAQ,QAAoB,WAA2B;CAErE,MAAM,MAAM,WACV,QACA,YAAY,mBAAmB,EAC/B,mBACA,mBACA,SACD;CAED,MAAM,KAAK,YAAY,iBAAiB;CACxC,MAAM,OAAO,YAAY,mBAAmB;CAE5C,MAAM,SAAS,eACb,kBACA,KACA,YAAY,iBAAiB,CAC9B;CACD,MAAM,YAAY,OAAO,OAAO,CAC9B,OAAO,OAAO,WAAW,OAAO,EAChC,OAAO,OAAO,CACf,CAAC;CAGF,MAAM,MAAM,OAAO,YAAY;AAE/B,QAAO,OAAO,OAAO;EAEnB;EACA;EACA;EACA;EACD,CAAC,CAAC,SAAS,MAAM;;;;;;;;;;;AAYpB,SAAgB,QAAQ,QAAoB,WAA2B;CACrE,MAAM,SAAS,OAAO,KAAK,WAAW,MAAM;CAW5C,MAAM,WAAW,iBACf,kBATU,WACV,QACA,OAAO,MAAM,GAAG,mBAAmB,EACnC,mBACA,mBACA,SACD,EAKC,OAAO,MAAM,oBAAoB,qBAAqB,iBAAiB,CACxE;AACD,UAAS,WACP,OAAO,MACL,qBAAqB,kBACrB,qBAAqB,mBAAmB,kBACzC,CACF;AAED,QAEE,SAAS,OACP,OAAO,MAAM,qBAAqB,mBAAmB,kBAAkB,CACxE,GAAG,SAAS,MAAM,OAAO"}
package/dist/hex.cjs CHANGED
@@ -1 +1,62 @@
1
- const e=`0123456789ABCDEF`,t={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};function n(t){let n=``;for(let r=0;r<t.length;r++)n+=e[t[r]>>4],n+=e[t[r]&15];return n}function r(e){if(e.length%2!=0)throw Error(`Invalid hex string`);let n=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2){if(!(e[r]in t)||!(e[r+1]in t))throw Error(`Invalid character`);n[r/2]|=t[e[r]]<<4,n[r/2]|=t[e[r+1]]}return n}exports.decodeHex=r,exports.encodeHex=n;
1
+
2
+ //#region src/hex.ts
3
+ const ALPHABET = "0123456789ABCDEF";
4
+ const DECODE_MAP = {
5
+ "0": 0,
6
+ "1": 1,
7
+ "2": 2,
8
+ "3": 3,
9
+ "4": 4,
10
+ "5": 5,
11
+ "6": 6,
12
+ "7": 7,
13
+ "8": 8,
14
+ "9": 9,
15
+ a: 10,
16
+ A: 10,
17
+ b: 11,
18
+ B: 11,
19
+ c: 12,
20
+ C: 12,
21
+ d: 13,
22
+ D: 13,
23
+ e: 14,
24
+ E: 14,
25
+ f: 15,
26
+ F: 15
27
+ };
28
+ /**
29
+ * Encodes a Uint8Array into a hexadecimal string.
30
+ *
31
+ * @param input - The input Uint8Array.
32
+ * @returns The hexadecimal string.
33
+ */
34
+ function encodeHex(input) {
35
+ let result = "";
36
+ for (let i = 0; i < input.length; i++) {
37
+ result += ALPHABET[input[i] >> 4];
38
+ result += ALPHABET[input[i] & 15];
39
+ }
40
+ return result;
41
+ }
42
+ /**
43
+ * Encodes a Uint8Array into an uppercase hexadecimal string.
44
+ *
45
+ * @param input - The input Uint8Array.
46
+ * @returns The uppercase hexadecimal string.
47
+ */
48
+ function decodeHex(input) {
49
+ if (input.length % 2 !== 0) throw new Error("Invalid hex string");
50
+ const result = new Uint8Array(input.length / 2);
51
+ for (let i = 0; i < input.length; i += 2) {
52
+ if (!(input[i] in DECODE_MAP)) throw new Error("Invalid character");
53
+ if (!(input[i + 1] in DECODE_MAP)) throw new Error("Invalid character");
54
+ result[i / 2] |= DECODE_MAP[input[i]] << 4;
55
+ result[i / 2] |= DECODE_MAP[input[i + 1]];
56
+ }
57
+ return result;
58
+ }
59
+
60
+ //#endregion
61
+ exports.decodeHex = decodeHex;
62
+ exports.encodeHex = encodeHex;
package/dist/hex.mjs CHANGED
@@ -1,2 +1,61 @@
1
- const e=`0123456789ABCDEF`,t={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};function n(t){let n=``;for(let r=0;r<t.length;r++)n+=e[t[r]>>4],n+=e[t[r]&15];return n}function r(e){if(e.length%2!=0)throw Error(`Invalid hex string`);let n=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2){if(!(e[r]in t)||!(e[r+1]in t))throw Error(`Invalid character`);n[r/2]|=t[e[r]]<<4,n[r/2]|=t[e[r+1]]}return n}export{r as decodeHex,n as encodeHex};
1
+ //#region src/hex.ts
2
+ const ALPHABET = "0123456789ABCDEF";
3
+ const DECODE_MAP = {
4
+ "0": 0,
5
+ "1": 1,
6
+ "2": 2,
7
+ "3": 3,
8
+ "4": 4,
9
+ "5": 5,
10
+ "6": 6,
11
+ "7": 7,
12
+ "8": 8,
13
+ "9": 9,
14
+ a: 10,
15
+ A: 10,
16
+ b: 11,
17
+ B: 11,
18
+ c: 12,
19
+ C: 12,
20
+ d: 13,
21
+ D: 13,
22
+ e: 14,
23
+ E: 14,
24
+ f: 15,
25
+ F: 15
26
+ };
27
+ /**
28
+ * Encodes a Uint8Array into a hexadecimal string.
29
+ *
30
+ * @param input - The input Uint8Array.
31
+ * @returns The hexadecimal string.
32
+ */
33
+ function encodeHex(input) {
34
+ let result = "";
35
+ for (let i = 0; i < input.length; i++) {
36
+ result += ALPHABET[input[i] >> 4];
37
+ result += ALPHABET[input[i] & 15];
38
+ }
39
+ return result;
40
+ }
41
+ /**
42
+ * Encodes a Uint8Array into an uppercase hexadecimal string.
43
+ *
44
+ * @param input - The input Uint8Array.
45
+ * @returns The uppercase hexadecimal string.
46
+ */
47
+ function decodeHex(input) {
48
+ if (input.length % 2 !== 0) throw new Error("Invalid hex string");
49
+ const result = new Uint8Array(input.length / 2);
50
+ for (let i = 0; i < input.length; i += 2) {
51
+ if (!(input[i] in DECODE_MAP)) throw new Error("Invalid character");
52
+ if (!(input[i + 1] in DECODE_MAP)) throw new Error("Invalid character");
53
+ result[i / 2] |= DECODE_MAP[input[i]] << 4;
54
+ result[i / 2] |= DECODE_MAP[input[i + 1]];
55
+ }
56
+ return result;
57
+ }
58
+
59
+ //#endregion
60
+ export { decodeHex, encodeHex };
2
61
  //# sourceMappingURL=hex.mjs.map
package/dist/hex.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hex.mjs","names":["DECODE_MAP: Record<string, number>"],"sources":["../src/hex.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\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"],"mappings":"AAkBA,MAAM,EAAW,mBACXA,EAAqC,CACzC,EAAK,EACL,EAAK,EACL,EAAK,EACL,EAAK,EACL,EAAK,EACL,EAAK,EACL,EAAK,EACL,EAAK,EACL,EAAK,EACL,EAAK,EACL,EAAG,GACH,EAAG,GACH,EAAG,GACH,EAAG,GACH,EAAG,GACH,EAAG,GACH,EAAG,GACH,EAAG,GACH,EAAG,GACH,EAAG,GACH,EAAG,GACH,EAAG,GACJ,CAQD,SAAgB,EAAU,EAA2B,CACnD,IAAI,EAAS,GACb,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAChC,GAAU,EAAS,EAAM,IAAO,GAChC,GAAU,EAAS,EAAM,GAAM,IAEjC,OAAO,EAST,SAAgB,EAAU,EAA2B,CACnD,GAAI,EAAM,OAAS,GAAM,EACvB,MAAU,MAAM,qBAAqB,CAEvC,IAAM,EAAS,IAAI,WAAW,EAAM,OAAS,EAAE,CAC/C,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,GAAK,EAAG,CAIxC,GAHI,EAAE,EAAM,KAAO,IAGf,EAAE,EAAM,EAAI,KAAO,GACrB,MAAU,MAAM,oBAAoB,CAEtC,EAAO,EAAI,IAAO,EAAW,EAAM,KAAS,EAC5C,EAAO,EAAI,IAAO,EAAW,EAAM,EAAI,IAEzC,OAAO"}
1
+ {"version":3,"file":"hex.mjs","names":["DECODE_MAP: Record<string, number>"],"sources":["../src/hex.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\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"],"mappings":";AAkBA,MAAM,WAAW;AACjB,MAAMA,aAAqC;CACzC,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACJ;;;;;;;AAQD,SAAgB,UAAU,OAA2B;CACnD,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,YAAU,SAAS,MAAM,MAAO;AAChC,YAAU,SAAS,MAAM,KAAM;;AAEjC,QAAO;;;;;;;;AAST,SAAgB,UAAU,OAA2B;AACnD,KAAI,MAAM,SAAS,MAAM,EACvB,OAAM,IAAI,MAAM,qBAAqB;CAEvC,MAAM,SAAS,IAAI,WAAW,MAAM,SAAS,EAAE;AAC/C,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;AACxC,MAAI,EAAE,MAAM,MAAO,YACjB,OAAM,IAAI,MAAM,oBAAoB;AAEtC,MAAI,EAAE,MAAM,IAAI,MAAO,YACrB,OAAM,IAAI,MAAM,oBAAoB;AAEtC,SAAO,IAAI,MAAO,WAAW,MAAM,OAAS;AAC5C,SAAO,IAAI,MAAO,WAAW,MAAM,IAAI;;AAEzC,QAAO"}
package/dist/index.cjs CHANGED
@@ -1 +1,13 @@
1
- const e=require(`./base-64.cjs`),t=require(`./encryption.node.cjs`),n=require(`./hex.cjs`);exports.base64FromBase64url=e.base64FromBase64url,exports.base64ToBase64url=e.base64ToBase64url,exports.createKey=t.createKey,exports.decodeBase64=e.decodeBase64,exports.decodeHex=n.decodeHex,exports.decrypt=t.decrypt,exports.encodeBase64=e.encodeBase64,exports.encodeHex=n.encodeHex,exports.encrypt=t.encrypt;
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');
4
+
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;
package/dist/index.mjs CHANGED
@@ -1 +1,5 @@
1
- import{base64FromBase64url as e,base64ToBase64url as t,decodeBase64 as n,encodeBase64 as r}from"./base-64.mjs";import{createKey as i,decrypt as a,encrypt as o}from"./encryption.node.mjs";import{decodeHex as s,encodeHex as c}from"./hex.mjs";export{e as base64FromBase64url,t as base64ToBase64url,i as createKey,n as decodeBase64,s as decodeHex,a as decrypt,r as encodeBase64,c as encodeHex,o as encrypt};
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
+
5
+ export { base64FromBase64url, base64ToBase64url, createKey, decodeBase64, decodeHex, decrypt, encodeBase64, encodeHex, encrypt };
package/dist/neutral.cjs CHANGED
@@ -1 +1,17 @@
1
- const e=require(`./base-64.cjs`),t=require(`./hex.cjs`),n=require(`./encryption.cjs`);exports.base64FromBase64url=e.base64FromBase64url,exports.base64ToBase64url=e.base64ToBase64url,exports.createKey=n.createKey,exports.decodeBase64=e.decodeBase64,exports.decodeHex=t.decodeHex,exports.decodeKey=n.decodeKey,exports.decrypt=n.decrypt,exports.decryptBuffer=n.decryptBuffer,exports.encodeBase64=e.encodeBase64,exports.encodeHex=t.encodeHex,exports.encodeKey=n.encodeKey,exports.encrypt=n.encrypt,exports.encryptBuffer=n.encryptBuffer;
1
+ const require_base_64 = require('./base-64.cjs');
2
+ const require_hex = require('./hex.cjs');
3
+ const require_encryption = require('./encryption.cjs');
4
+
5
+ exports.base64FromBase64url = require_base_64.base64FromBase64url;
6
+ exports.base64ToBase64url = require_base_64.base64ToBase64url;
7
+ exports.createKey = require_encryption.createKey;
8
+ exports.decodeBase64 = require_base_64.decodeBase64;
9
+ exports.decodeHex = require_hex.decodeHex;
10
+ exports.decodeKey = require_encryption.decodeKey;
11
+ exports.decrypt = require_encryption.decrypt;
12
+ exports.decryptBuffer = require_encryption.decryptBuffer;
13
+ exports.encodeBase64 = require_base_64.encodeBase64;
14
+ exports.encodeHex = require_hex.encodeHex;
15
+ exports.encodeKey = require_encryption.encodeKey;
16
+ exports.encrypt = require_encryption.encrypt;
17
+ exports.encryptBuffer = require_encryption.encryptBuffer;
package/dist/neutral.mjs CHANGED
@@ -1 +1,5 @@
1
- import{base64FromBase64url as e,base64ToBase64url as t,decodeBase64 as n,encodeBase64 as r}from"./base-64.mjs";import{decodeHex as i,encodeHex as a}from"./hex.mjs";import{createKey as o,decodeKey as s,decrypt as c,decryptBuffer as l,encodeKey as u,encrypt as d,encryptBuffer as f}from"./encryption.mjs";export{e as base64FromBase64url,t as base64ToBase64url,o as createKey,n as decodeBase64,i as decodeHex,s as decodeKey,c as decrypt,l as decryptBuffer,r as encodeBase64,a as encodeHex,u as encodeKey,d as encrypt,f as encryptBuffer};
1
+ import { base64FromBase64url, base64ToBase64url, decodeBase64, encodeBase64 } from "./base-64.mjs";
2
+ import { decodeHex, encodeHex } from "./hex.mjs";
3
+ import { createKey, decodeKey, decrypt, decryptBuffer, encodeKey, encrypt, encryptBuffer } from "./encryption.mjs";
4
+
5
+ export { base64FromBase64url, base64ToBase64url, createKey, decodeBase64, decodeHex, decodeKey, decrypt, decryptBuffer, encodeBase64, encodeHex, encodeKey, encrypt, encryptBuffer };
@@ -1 +1,5 @@
1
- const e=require(`./is-undefined.cjs`),t=require(`./is-buffer.cjs`);require(`./type-detect.cjs`),require(`./is-collection.cjs`);const n=require(`./is-string.cjs`);
1
+ const require_is_undefined = require('./is-undefined.cjs');
2
+ const require_is_buffer = require('./is-buffer.cjs');
3
+ require('./type-detect.cjs');
4
+ require('./is-collection.cjs');
5
+ const require_is_string = require('./is-string.cjs');
@@ -1 +1,7 @@
1
- import{isUndefined as e}from"./is-undefined.mjs";import{isBufferExists as t}from"./is-buffer.mjs";import"./type-detect.mjs";import"./is-collection.mjs";import{isString as n}from"./is-string.mjs";export{};
1
+ import { isUndefined } from "./is-undefined.mjs";
2
+ import { isBufferExists } from "./is-buffer.mjs";
3
+ import "./type-detect.mjs";
4
+ import "./is-collection.mjs";
5
+ import { isString } from "./is-string.mjs";
6
+
7
+ export { };
@@ -1 +1,12 @@
1
- const e=typeof Buffer<`u`,t=e?Buffer.isBuffer.bind(Buffer):function(e){return!1};exports.isBufferExists=e;
1
+
2
+ //#region ../type-checks/src/is-buffer.ts
3
+ const isBufferExists = typeof Buffer !== "undefined";
4
+ /**
5
+ * Check if the provided value's type is `Buffer`
6
+ */
7
+ const isBuffer = isBufferExists ? Buffer.isBuffer.bind(Buffer) : function isBuffer$1(value) {
8
+ return false;
9
+ };
10
+
11
+ //#endregion
12
+ exports.isBufferExists = isBufferExists;
@@ -1,2 +1,12 @@
1
- const e=typeof Buffer<`u`;e&&Buffer.isBuffer.bind(Buffer);export{e as isBufferExists};
1
+ //#region ../type-checks/src/is-buffer.ts
2
+ const isBufferExists = typeof Buffer !== "undefined";
3
+ /**
4
+ * Check if the provided value's type is `Buffer`
5
+ */
6
+ const isBuffer = isBufferExists ? Buffer.isBuffer.bind(Buffer) : function isBuffer$1(value) {
7
+ return false;
8
+ };
9
+
10
+ //#endregion
11
+ export { isBufferExists };
2
12
  //# sourceMappingURL=is-buffer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-buffer.mjs","names":["isBuffer: typeof Buffer.isBuffer","isBuffer"],"sources":["../../../../type-checks/src/is-buffer.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 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"],"mappings":"AAkBA,MAAa,EAAiB,OAAO,OAAW,IAKA,GAC5C,OAAO,SAAS,KAAK,OAAO"}
1
+ {"version":3,"file":"is-buffer.mjs","names":["isBuffer: typeof Buffer.isBuffer","isBuffer"],"sources":["../../../../type-checks/src/is-buffer.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 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"],"mappings":";AAkBA,MAAa,iBAAiB,OAAO,WAAW;;;;AAKhD,MAAaA,WAAmC,iBAC5C,OAAO,SAAS,KAAK,OAAO,GAO5B,SAASC,WACP,OACiB;AACjB,QAAO"}
@@ -1 +1 @@
1
- require(`./type-detect.cjs`);
1
+ require('./type-detect.cjs');
@@ -1 +1,3 @@
1
- import"./type-detect.mjs";export{};
1
+ import "./type-detect.mjs";
2
+
3
+ export { };
@@ -1 +1,12 @@
1
- const e=e=>{try{return typeof e==`string`}catch{return!1}};exports.isString=e;
1
+
2
+ //#region ../type-checks/src/is-string.ts
3
+ const isString = (value) => {
4
+ try {
5
+ return typeof value === "string";
6
+ } catch {
7
+ return false;
8
+ }
9
+ };
10
+
11
+ //#endregion
12
+ exports.isString = isString;
@@ -1,2 +1,12 @@
1
- const e=e=>{try{return typeof e==`string`}catch{return!1}};export{e as isString};
1
+ //#region ../type-checks/src/is-string.ts
2
+ const isString = (value) => {
3
+ try {
4
+ return typeof value === "string";
5
+ } catch {
6
+ return false;
7
+ }
8
+ };
9
+
10
+ //#endregion
11
+ export { isString };
2
12
  //# sourceMappingURL=is-string.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-string.mjs","names":[],"sources":["../../../../type-checks/src/is-string.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 isString = (value: unknown): value is string => {\n try {\n return typeof value === \"string\";\n } catch {\n return false;\n }\n};\n"],"mappings":"AAkBA,MAAa,EAAY,GAAoC,CAC3D,GAAI,CACF,OAAO,OAAO,GAAU,cAClB,CACN,MAAO"}
1
+ {"version":3,"file":"is-string.mjs","names":[],"sources":["../../../../type-checks/src/is-string.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 isString = (value: unknown): value is string => {\n try {\n return typeof value === \"string\";\n } catch {\n return false;\n }\n};\n"],"mappings":";AAkBA,MAAa,YAAY,UAAoC;AAC3D,KAAI;AACF,SAAO,OAAO,UAAU;SAClB;AACN,SAAO"}
@@ -1 +1,8 @@
1
- const e=e=>e===void 0;exports.isUndefined=e;
1
+
2
+ //#region ../type-checks/src/is-undefined.ts
3
+ const isUndefined = (value) => {
4
+ return value === void 0;
5
+ };
6
+
7
+ //#endregion
8
+ exports.isUndefined = isUndefined;
@@ -1,2 +1,8 @@
1
- const e=e=>e===void 0;export{e as isUndefined};
1
+ //#region ../type-checks/src/is-undefined.ts
2
+ const isUndefined = (value) => {
3
+ return value === void 0;
4
+ };
5
+
6
+ //#endregion
7
+ export { isUndefined };
2
8
  //# sourceMappingURL=is-undefined.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-undefined.mjs","names":[],"sources":["../../../../type-checks/src/is-undefined.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"],"mappings":"AAkBA,MAAa,EAAe,GACnB,IAAU,IAAA"}
1
+ {"version":3,"file":"is-undefined.mjs","names":[],"sources":["../../../../type-checks/src/is-undefined.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"],"mappings":";AAkBA,MAAa,eAAe,UAAuC;AACjE,QAAO,UAAU"}
@@ -1 +1,15 @@
1
- require(`./is-buffer.cjs`);const e=(e=>(typeof globalThis==`object`||Object.defineProperty(e,`typeDetectGlobalObject`,{get(){return this},configurable:!0}),globalThis))(Object.prototype);
1
+ require('./is-buffer.cjs');
2
+
3
+ //#region ../type-checks/src/type-detect.ts
4
+ const globalObject = ((Obj) => {
5
+ if (typeof globalThis === "object") return globalThis;
6
+ Object.defineProperty(Obj, "typeDetectGlobalObject", {
7
+ get() {
8
+ return this;
9
+ },
10
+ configurable: true
11
+ });
12
+ return globalThis;
13
+ })(Object.prototype);
14
+
15
+ //#endregion
@@ -1,2 +1,17 @@
1
- import"./is-buffer.mjs";(e=>(typeof globalThis==`object`||Object.defineProperty(e,`typeDetectGlobalObject`,{get(){return this},configurable:!0}),globalThis))(Object.prototype);export{};
1
+ import "./is-buffer.mjs";
2
+
3
+ //#region ../type-checks/src/type-detect.ts
4
+ const globalObject = ((Obj) => {
5
+ if (typeof globalThis === "object") return globalThis;
6
+ Object.defineProperty(Obj, "typeDetectGlobalObject", {
7
+ get() {
8
+ return this;
9
+ },
10
+ configurable: true
11
+ });
12
+ return globalThis;
13
+ })(Object.prototype);
14
+
15
+ //#endregion
16
+ export { };
2
17
  //# sourceMappingURL=type-detect.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-detect.mjs","names":[],"sources":["../../../../type-checks/src/type-detect.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\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"],"mappings":"yBAoBsB,IAChB,OAAO,YAAe,UAG1B,OAAO,eAAe,EAAK,yBAA0B,CACnD,KAAM,CACJ,OAAO,MAET,aAAc,GACf,CAAC,CAPO,aAeR,OAAO,UAAU"}
1
+ {"version":3,"file":"type-detect.mjs","names":[],"sources":["../../../../type-checks/src/type-detect.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\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"],"mappings":";;;AAoBA,MAAM,iBAAgB,QAAO;AAC3B,KAAI,OAAO,eAAe,SACxB,QAAO;AAET,QAAO,eAAe,KAAK,0BAA0B;EACnD,MAAM;AACJ,UAAO;;EAET,cAAc;EACf,CAAC;AAOF,QAAO;GACN,OAAO,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/crypto",
3
- "version": "0.5.34",
3
+ "version": "0.5.36",
4
4
  "type": "module",
5
5
  "description": "A package containing cryptographic utilities used by Storm Software.",
6
6
  "repository": {
@@ -34,10 +34,10 @@
34
34
  },
35
35
  "types": "./dist/index.d.cts",
36
36
  "dependencies": {
37
- "@stryke/convert": "^0.6.33",
38
- "@stryke/type-checks": "^0.5.18"
37
+ "@stryke/convert": "^0.6.35",
38
+ "@stryke/type-checks": "^0.5.20"
39
39
  },
40
40
  "devDependencies": { "@types/node": "^24.10.9", "tsdown": "^0.17.2" },
41
41
  "publishConfig": { "access": "public" },
42
- "gitHead": "8b7fc067d9cb2000a264ca3829f8c94c1b5e4424"
42
+ "gitHead": "e56e13fe0b09b8e53917efa1aab3877bc96383f7"
43
43
  }