@stryke/crypto 0.5.25 → 0.5.27

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 (104) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/base-64.cjs +1 -1
  3. package/dist/base-64.d.cts +40 -2
  4. package/dist/base-64.d.cts.map +1 -0
  5. package/dist/base-64.d.mts +40 -2
  6. package/dist/base-64.d.mts.map +1 -0
  7. package/dist/base-64.mjs +2 -1
  8. package/dist/base-64.mjs.map +1 -0
  9. package/dist/convert/src/array-buffer-to-string.cjs +1 -0
  10. package/dist/convert/src/array-buffer-to-string.mjs +2 -0
  11. package/dist/convert/src/array-buffer-to-string.mjs.map +1 -0
  12. package/dist/convert/src/neutral.cjs +1 -0
  13. package/dist/convert/src/neutral.mjs +1 -0
  14. package/dist/convert/src/parse-type-definition.cjs +1 -0
  15. package/dist/convert/src/parse-type-definition.mjs +1 -0
  16. package/dist/convert/src/string-to-uint8-array.cjs +1 -0
  17. package/dist/convert/src/string-to-uint8-array.mjs +2 -0
  18. package/dist/convert/src/string-to-uint8-array.mjs.map +1 -0
  19. package/dist/convert/src/string-to-utf8-array.cjs +1 -0
  20. package/dist/convert/src/string-to-utf8-array.mjs +2 -0
  21. package/dist/convert/src/string-to-utf8-array.mjs.map +1 -0
  22. package/dist/convert/src/uint8-array-to-stream.cjs +1 -0
  23. package/dist/convert/src/uint8-array-to-stream.mjs +2 -0
  24. package/dist/convert/src/uint8-array-to-stream.mjs.map +1 -0
  25. package/dist/convert/src/uint8-array-to-string.cjs +1 -0
  26. package/dist/convert/src/uint8-array-to-string.mjs +2 -0
  27. package/dist/convert/src/uint8-array-to-string.mjs.map +1 -0
  28. package/dist/convert/src/utf8-array-to-string.cjs +1 -0
  29. package/dist/convert/src/utf8-array-to-string.mjs +2 -0
  30. package/dist/convert/src/utf8-array-to-string.mjs.map +1 -0
  31. package/dist/encryption.cjs +1 -1
  32. package/dist/encryption.d.cts +82 -2
  33. package/dist/encryption.d.cts.map +1 -0
  34. package/dist/encryption.d.mts +82 -2
  35. package/dist/encryption.d.mts.map +1 -0
  36. package/dist/encryption.mjs +2 -1
  37. package/dist/encryption.mjs.map +1 -0
  38. package/dist/encryption.node.cjs +1 -1
  39. package/dist/encryption.node.d.cts +42 -2
  40. package/dist/encryption.node.d.cts.map +1 -0
  41. package/dist/encryption.node.d.mts +42 -2
  42. package/dist/encryption.node.d.mts.map +1 -0
  43. package/dist/encryption.node.mjs +2 -1
  44. package/dist/encryption.node.mjs.map +1 -0
  45. package/dist/hex.cjs +1 -1
  46. package/dist/hex.d.cts +18 -2
  47. package/dist/hex.d.cts.map +1 -0
  48. package/dist/hex.d.mts +18 -2
  49. package/dist/hex.d.mts.map +1 -0
  50. package/dist/hex.mjs +2 -1
  51. package/dist/hex.mjs.map +1 -0
  52. package/dist/index.cjs +1 -1
  53. package/dist/index.d.cts +3 -3
  54. package/dist/index.d.mts +3 -3
  55. package/dist/index.mjs +1 -1
  56. package/dist/neutral.cjs +1 -1
  57. package/dist/neutral.d.cts +3 -3
  58. package/dist/neutral.d.mts +3 -3
  59. package/dist/neutral.mjs +1 -1
  60. package/dist/type-checks/src/index.cjs +1 -0
  61. package/dist/type-checks/src/index.mjs +1 -0
  62. package/dist/type-checks/src/is-buffer.cjs +1 -0
  63. package/dist/type-checks/src/is-buffer.mjs +2 -0
  64. package/dist/type-checks/src/is-buffer.mjs.map +1 -0
  65. package/dist/type-checks/src/is-collection.cjs +1 -0
  66. package/dist/type-checks/src/is-collection.mjs +1 -0
  67. package/dist/type-checks/src/is-string.cjs +1 -0
  68. package/dist/type-checks/src/is-string.mjs +2 -0
  69. package/dist/type-checks/src/is-string.mjs.map +1 -0
  70. package/dist/type-checks/src/is-undefined.cjs +1 -0
  71. package/dist/type-checks/src/is-undefined.mjs +2 -0
  72. package/dist/type-checks/src/is-undefined.mjs.map +1 -0
  73. package/dist/type-checks/src/type-detect.cjs +1 -0
  74. package/dist/type-checks/src/type-detect.mjs +2 -0
  75. package/dist/type-checks/src/type-detect.mjs.map +1 -0
  76. package/package.json +5 -5
  77. package/dist/base-64-B1YDs-zl.d.cts +0 -40
  78. package/dist/base-64-B1YDs-zl.d.cts.map +0 -1
  79. package/dist/base-64-Bh0chPX9.cjs +0 -1
  80. package/dist/base-64-D3iUgxLe.d.mts +0 -40
  81. package/dist/base-64-D3iUgxLe.d.mts.map +0 -1
  82. package/dist/base-64-n6I9tGzK.mjs +0 -2
  83. package/dist/base-64-n6I9tGzK.mjs.map +0 -1
  84. package/dist/encryption-CchoDEon.mjs +0 -2
  85. package/dist/encryption-CchoDEon.mjs.map +0 -1
  86. package/dist/encryption-Dw19bezD.d.cts +0 -82
  87. package/dist/encryption-Dw19bezD.d.cts.map +0 -1
  88. package/dist/encryption-HwrvWUAF.cjs +0 -1
  89. package/dist/encryption-yC-pEQ14.d.mts +0 -82
  90. package/dist/encryption-yC-pEQ14.d.mts.map +0 -1
  91. package/dist/encryption.node-BLOlwsYV.mjs +0 -2
  92. package/dist/encryption.node-BLOlwsYV.mjs.map +0 -1
  93. package/dist/encryption.node-CyYXMEWi.d.cts +0 -42
  94. package/dist/encryption.node-CyYXMEWi.d.cts.map +0 -1
  95. package/dist/encryption.node-DCO-i6QP.cjs +0 -1
  96. package/dist/encryption.node-pNNijU1t.d.mts +0 -42
  97. package/dist/encryption.node-pNNijU1t.d.mts.map +0 -1
  98. package/dist/hex-BaOs3VLq.d.cts +0 -18
  99. package/dist/hex-BaOs3VLq.d.cts.map +0 -1
  100. package/dist/hex-C1p5VuEv.mjs +0 -2
  101. package/dist/hex-C1p5VuEv.mjs.map +0 -1
  102. package/dist/hex-CDXtL048.cjs +0 -1
  103. package/dist/hex-eot11JTh.d.mts +0 -18
  104. package/dist/hex-eot11JTh.d.mts.map +0 -1
@@ -1,82 +0,0 @@
1
- //#region src/encryption.d.ts
2
- /**
3
- * Creates a CryptoKey object that can be used to encrypt any string.
4
- *
5
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/generateKey
6
- *
7
- * @returns A promise that resolves to a CryptoKey object that can be used to encrypt and decrypt strings.
8
- */
9
- declare function createKey(): Promise<CryptoKey>;
10
- /**
11
- * Encodes a CryptoKey to base64 string, so that it can be embedded in JSON / JavaScript
12
- *
13
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/exportKey
14
- *
15
- * @param key - The CryptoKey to encode
16
- * @returns A promise that resolves to a base64 string representing the key
17
- */
18
- declare function encodeKey(key: CryptoKey): Promise<string>;
19
- /**
20
- * Decodes a base64 string into bytes and then imports the key.
21
- *
22
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey
23
- *
24
- * @param encoded - The base64 encoded key
25
- * @returns A promise that resolves to a CryptoKey object that can be used to encrypt and decrypt strings
26
- */
27
- declare function decodeKey(encoded: string): Promise<CryptoKey>;
28
- /**
29
- * Using a CryptoKey, use AES-GCM to encrypt a string into a base64 string.
30
- *
31
- * @remarks
32
- * 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.
33
- *
34
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt
35
- *
36
- * @param key - The CryptoKey to use for encryption
37
- * @param plaintext - The plaintext string to encrypt
38
- * @returns A promise that resolves to a base64 string representing the encrypted data
39
- */
40
- declare function encrypt(key: CryptoKey, plaintext: string): Promise<string>;
41
- /**
42
- * Takes a base64 encoded string, decodes it and returns the AES-GCM decrypted text.
43
- *
44
- * @remarks
45
- * 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.
46
- *
47
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/decrypt
48
- *
49
- * @param key - The CryptoKey to use for decryption
50
- * @param encrypted - The encrypted base64 encoded string to decrypt
51
- * @returns A promise that resolves to the decrypted string
52
- */
53
- declare function decrypt(key: CryptoKey, encrypted: string): Promise<string>;
54
- /**
55
- * Encrypts a buffer using AES-GCM with a given CryptoKey.
56
- *
57
- * @remarks
58
- * 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.
59
- *
60
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt
61
- *
62
- * @param key - The CryptoKey to use for encryption
63
- * @param buffer - The buffer to encrypt
64
- * @returns A promise that resolves to a base64 string representing the encrypted data
65
- */
66
- declare function encryptBuffer(key: CryptoKey, buffer: BufferSource): Promise<string>;
67
- /**
68
- * Decrypts a buffer using AES-GCM with a given CryptoKey.
69
- *
70
- * @remarks
71
- * 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.
72
- *
73
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/decrypt
74
- *
75
- * @param key - The CryptoKey to use for decryption
76
- * @param encrypted - The encrypted base64 encoded string to decrypt
77
- * @returns A promise that resolves to the decrypted string
78
- */
79
- declare function decryptBuffer(key: CryptoKey, encrypted: string): Promise<ArrayBuffer>;
80
- //#endregion
81
- export { encodeKey as a, decryptBuffer as i, decodeKey as n, encrypt as o, decrypt as r, encryptBuffer as s, createKey as t };
82
- //# sourceMappingURL=encryption-yC-pEQ14.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encryption-yC-pEQ14.d.mts","names":[],"sources":["../src/encryption.ts"],"sourcesContent":[],"mappings":";;AAmCA;AAmBA;AAcA;AA4BA;AA8BA;AA4BA;AACO,iBAxHe,SAAA,CAAA,CAwHf,EAxH4B,OAwH5B,CAxHoC,SAwHpC,CAAA;;;;AA4BP;;;;;iBAjIsB,SAAA,MAAe,YAAY;;;;;;;;;iBAc3B,SAAA,mBAA4B,QAAQ;;;;;;;;;;;;;iBA4BpC,OAAA,MACf,+BAEJ;;;;;;;;;;;;;iBA2BmB,OAAA,MACf,+BAEJ;;;;;;;;;;;;;iBAyBmB,aAAA,MACf,mBACG,eACP;;;;;;;;;;;;;iBA0BmB,aAAA,MACf,+BAEJ,QAAQ"}
@@ -1,2 +0,0 @@
1
- import{Buffer as e}from"node:buffer";import{createCipheriv as t,createDecipheriv as n,createSecretKey as r,pbkdf2Sync as i,randomBytes as a}from"node:crypto";const o=`chacha20-poly1305`,s=1e5;function c(e,t){return typeof e==`string`?r(e,t):r(e)}function l(n,r){let c=i(n,a(64),s,32,`sha512`),l=a(16),u=a(64),d=t(o,c,a(16)),f=e.concat([d.update(r,`utf8`),d.final()]),p=d.getAuthTag();return e.concat([u,l,p,f]).toString(`hex`)}function u(t,r){let a=e.from(r,`hex`),c=n(o,i(t,a.slice(0,64),s,32,`sha512`),a.slice(64,80));return c.setAuthTag(a.slice(80,96)),c.update(a.slice(96))+c.final(`utf8`)}export{u as n,l as r,c as t};
2
- //# sourceMappingURL=encryption.node-BLOlwsYV.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encryption.node-BLOlwsYV.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,42 +0,0 @@
1
- import { BinaryLike, KeyObject } from "node:crypto";
2
-
3
- //#region src/encryption.node.d.ts
4
-
5
- /**
6
- * Creates and returns a new key object containing a secret key for symmetric encryption or \`Hmac\`.
7
- *
8
- * @param key - The key to use when creating the \`KeyObject\`.
9
- * @returns The new \`KeyObject\`.
10
- */
11
- declare function createKey(key: NodeJS.ArrayBufferView): KeyObject;
12
- /**
13
- * Creates and returns a new key object containing a secret key for symmetric encryption or \`Hmac\`.
14
- *
15
- * @param key - The key to use. If \`key\` is a \`Buffer\`, \`TypedArray\`, or \`DataView\`, the \`encoding\` argument is ignored.
16
- * @param encoding - The \`encoding\` of the \`key\` string. Must be one of \`'utf8'\`, \`'utf16le'\`, \`'latin1'\`, or \`'base64'\`. Default is \`'utf8'\`.
17
- * @returns The new \`KeyObject\`.
18
- */
19
- declare function createKey(key: string, encoding: BufferEncoding): KeyObject;
20
- /**
21
- * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
22
- *
23
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
24
- *
25
- * @param secret - The secret key used for encryption.
26
- * @param plaintext - The data to encrypt.
27
- * @returns The encrypted data.
28
- */
29
- declare function encrypt(secret: BinaryLike, plaintext: string): string;
30
- /**
31
- * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
32
- *
33
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
34
- *
35
- * @param secret - The secret key used for decryption.
36
- * @param encrypted - The encrypted data to decrypt.
37
- * @returns The decrypted data.
38
- */
39
- declare function decrypt(secret: BinaryLike, encrypted: string): string;
40
- //#endregion
41
- export { decrypt as n, encrypt as r, createKey as t };
42
- //# sourceMappingURL=encryption.node-CyYXMEWi.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encryption.node-CyYXMEWi.d.cts","names":[],"sources":["../src/encryption.node.ts"],"sourcesContent":[],"mappings":";;;;;;AA6CA;AASA;AA2BA;AA4CA;iBAhFgB,SAAA,MAAe,MAAA,CAAO,kBAAkB;;;;;;;;iBASxC,SAAA,wBAAiC,iBAAiB;;;;;;;;;;iBA2BlD,OAAA,SAAgB;;;;;;;;;;iBA4ChB,OAAA,SAAgB"}
@@ -1 +0,0 @@
1
- let e=require(`node:buffer`),t=require(`node:crypto`);const n=`chacha20-poly1305`,r=32,i=16,a=16,o=64,s=1e5;function c(e,n){return typeof e==`string`?(0,t.createSecretKey)(e,n):(0,t.createSecretKey)(e)}function l(r,i){let a=(0,t.pbkdf2Sync)(r,(0,t.randomBytes)(64),s,32,`sha512`),o=(0,t.randomBytes)(16),c=(0,t.randomBytes)(64),l=(0,t.createCipheriv)(n,a,(0,t.randomBytes)(16)),u=e.Buffer.concat([l.update(i,`utf8`),l.final()]),d=l.getAuthTag();return e.Buffer.concat([c,o,d,u]).toString(`hex`)}function u(r,i){let a=e.Buffer.from(i,`hex`),o=(0,t.createDecipheriv)(n,(0,t.pbkdf2Sync)(r,a.slice(0,64),s,32,`sha512`),a.slice(64,80));return o.setAuthTag(a.slice(80,96)),o.update(a.slice(96))+o.final(`utf8`)}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
@@ -1,42 +0,0 @@
1
- import { BinaryLike, KeyObject } from "node:crypto";
2
-
3
- //#region src/encryption.node.d.ts
4
-
5
- /**
6
- * Creates and returns a new key object containing a secret key for symmetric encryption or \`Hmac\`.
7
- *
8
- * @param key - The key to use when creating the \`KeyObject\`.
9
- * @returns The new \`KeyObject\`.
10
- */
11
- declare function createKey(key: NodeJS.ArrayBufferView): KeyObject;
12
- /**
13
- * Creates and returns a new key object containing a secret key for symmetric encryption or \`Hmac\`.
14
- *
15
- * @param key - The key to use. If \`key\` is a \`Buffer\`, \`TypedArray\`, or \`DataView\`, the \`encoding\` argument is ignored.
16
- * @param encoding - The \`encoding\` of the \`key\` string. Must be one of \`'utf8'\`, \`'utf16le'\`, \`'latin1'\`, or \`'base64'\`. Default is \`'utf8'\`.
17
- * @returns The new \`KeyObject\`.
18
- */
19
- declare function createKey(key: string, encoding: BufferEncoding): KeyObject;
20
- /**
21
- * Symmetrically encrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
22
- *
23
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
24
- *
25
- * @param secret - The secret key used for encryption.
26
- * @param plaintext - The data to encrypt.
27
- * @returns The encrypted data.
28
- */
29
- declare function encrypt(secret: BinaryLike, plaintext: string): string;
30
- /**
31
- * Symmetrically decrypts data using the [ChaCha20-Poly1305](https://en.wikipedia.org/wiki/ChaCha20-Poly1305) cipher.
32
- *
33
- * @see https://en.wikipedia.org/wiki/ChaCha20-Poly1305
34
- *
35
- * @param secret - The secret key used for decryption.
36
- * @param encrypted - The encrypted data to decrypt.
37
- * @returns The decrypted data.
38
- */
39
- declare function decrypt(secret: BinaryLike, encrypted: string): string;
40
- //#endregion
41
- export { decrypt as n, encrypt as r, createKey as t };
42
- //# sourceMappingURL=encryption.node-pNNijU1t.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encryption.node-pNNijU1t.d.mts","names":[],"sources":["../src/encryption.node.ts"],"sourcesContent":[],"mappings":";;;;;;AA6CA;AASA;AA2BA;AA4CA;iBAhFgB,SAAA,MAAe,MAAA,CAAO,kBAAkB;;;;;;;;iBASxC,SAAA,wBAAiC,iBAAiB;;;;;;;;;;iBA2BlD,OAAA,SAAgB;;;;;;;;;;iBA4ChB,OAAA,SAAgB"}
@@ -1,18 +0,0 @@
1
- //#region src/hex.d.ts
2
- /**
3
- * Encodes a Uint8Array into a hexadecimal string.
4
- *
5
- * @param input - The input Uint8Array.
6
- * @returns The hexadecimal string.
7
- */
8
- declare function encodeHex(input: Uint8Array): string;
9
- /**
10
- * Encodes a Uint8Array into an uppercase hexadecimal string.
11
- *
12
- * @param input - The input Uint8Array.
13
- * @returns The uppercase hexadecimal string.
14
- */
15
- declare function decodeHex(input: string): Uint8Array;
16
- //#endregion
17
- export { encodeHex as n, decodeHex as t };
18
- //# sourceMappingURL=hex-BaOs3VLq.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hex-BaOs3VLq.d.cts","names":[],"sources":["../src/hex.ts"],"sourcesContent":[],"mappings":";;AAkDA;AAeA;;;;iBAfgB,SAAA,QAAiB;;;;;;;iBAejB,SAAA,iBAA0B"}
@@ -1,2 +0,0 @@
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{n,r as t};
2
- //# sourceMappingURL=hex-C1p5VuEv.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hex-C1p5VuEv.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 +0,0 @@
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}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
@@ -1,18 +0,0 @@
1
- //#region src/hex.d.ts
2
- /**
3
- * Encodes a Uint8Array into a hexadecimal string.
4
- *
5
- * @param input - The input Uint8Array.
6
- * @returns The hexadecimal string.
7
- */
8
- declare function encodeHex(input: Uint8Array): string;
9
- /**
10
- * Encodes a Uint8Array into an uppercase hexadecimal string.
11
- *
12
- * @param input - The input Uint8Array.
13
- * @returns The uppercase hexadecimal string.
14
- */
15
- declare function decodeHex(input: string): Uint8Array;
16
- //#endregion
17
- export { encodeHex as n, decodeHex as t };
18
- //# sourceMappingURL=hex-eot11JTh.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hex-eot11JTh.d.mts","names":[],"sources":["../src/hex.ts"],"sourcesContent":[],"mappings":";;AAkDA;AAeA;;;;iBAfgB,SAAA,QAAiB;;;;;;;iBAejB,SAAA,iBAA0B"}