@zudojs/crypto 0.0.1 → 1.0.0

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 (353) hide show
  1. package/README.md +43 -14
  2. package/dist/compare/compare.helper.d.ts +10 -2
  3. package/dist/compare/compare.helper.js +22 -6
  4. package/dist/cryptoCipher/cryptoCipher.core.d.ts +11 -1
  5. package/dist/cryptoCipher/cryptoCipher.core.js +19 -3
  6. package/dist/cryptoCipher/cryptoCipher.envelope.d.ts +7 -2
  7. package/dist/cryptoCipher/cryptoCipher.envelope.js +33 -14
  8. package/dist/cryptoCipher/cryptoCipher.string.d.ts +2 -1
  9. package/dist/cryptoCipher/cryptoCipher.string.js +2 -2
  10. package/dist/cryptoConstants/cryptoConstants.guard.d.ts +9 -0
  11. package/dist/cryptoConstants/cryptoConstants.guard.js +16 -1
  12. package/dist/cryptoConstants/cryptoConstants.security.d.ts +34 -1
  13. package/dist/cryptoConstants/cryptoConstants.security.js +34 -1
  14. package/dist/cryptoConstants/cryptoConstants.token.d.ts +2 -0
  15. package/dist/cryptoConstants/cryptoConstants.token.js +2 -0
  16. package/dist/cryptoConstants/cryptoConstants.type.d.ts +36 -14
  17. package/dist/cryptoConstants/cryptoConstants.type.js +36 -14
  18. package/dist/cryptoEncoding/cryptoEncoding.compare.d.ts +4 -1
  19. package/dist/cryptoEncoding/cryptoEncoding.compare.js +11 -4
  20. package/dist/cryptoEncoding/cryptoEncoding.core.d.ts +22 -0
  21. package/dist/cryptoEncoding/cryptoEncoding.core.js +41 -3
  22. package/dist/cryptoEncoding/encoding/cryptoEncoding.base64.d.ts +10 -2
  23. package/dist/cryptoEncoding/encoding/cryptoEncoding.base64.js +24 -16
  24. package/dist/cryptoEncoding/encoding/cryptoEncoding.base64url.d.ts +9 -1
  25. package/dist/cryptoEncoding/encoding/cryptoEncoding.base64url.js +23 -20
  26. package/dist/cryptoEncoding/encoding/cryptoEncoding.hex.d.ts +9 -2
  27. package/dist/cryptoEncoding/encoding/cryptoEncoding.hex.js +17 -11
  28. package/dist/cryptoErrors/cryptoErrors.helper.d.ts +30 -0
  29. package/dist/cryptoErrors/cryptoErrors.helper.js +72 -0
  30. package/dist/cryptoFactory/cryptoFactory.core.d.ts +37 -6
  31. package/dist/cryptoFactory/cryptoFactory.core.js +56 -30
  32. package/dist/cryptoFactory/cryptoFactory.password.d.ts +4 -3
  33. package/dist/cryptoFactory/cryptoFactory.password.js +4 -4
  34. package/dist/cryptoFactory/cryptoFactory.token.d.ts +9 -8
  35. package/dist/cryptoFactory/cryptoFactory.token.js +16 -15
  36. package/dist/cryptoHash/cryptoHash.codec.d.ts +2 -0
  37. package/dist/cryptoHash/cryptoHash.codec.js +12 -12
  38. package/dist/cryptoHash/cryptoHash.compare.d.ts +3 -1
  39. package/dist/cryptoHash/cryptoHash.compare.js +5 -9
  40. package/dist/cryptoHash/cryptoHash.core.d.ts +6 -2
  41. package/dist/cryptoHash/cryptoHash.core.js +9 -2
  42. package/dist/cryptoHash/cryptoHmac.core.d.ts +8 -5
  43. package/dist/cryptoHash/cryptoHmac.core.js +22 -9
  44. package/dist/cryptoKey/cryptoKey.factory.d.ts +29 -2
  45. package/dist/cryptoKey/cryptoKey.factory.js +82 -18
  46. package/dist/cryptoKey/cryptoKey.utils.d.ts +5 -3
  47. package/dist/cryptoKey/cryptoKey.utils.js +5 -3
  48. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.core.d.ts +7 -1
  49. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.core.js +40 -15
  50. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.salt.d.ts +2 -1
  51. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.salt.js +2 -3
  52. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.type.d.ts +5 -1
  53. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.validate.d.ts +2 -2
  54. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.validate.js +16 -6
  55. package/dist/cryptoPassword/cryptoPassword.codec.d.ts +15 -1
  56. package/dist/cryptoPassword/cryptoPassword.codec.js +127 -56
  57. package/dist/cryptoPassword/cryptoPassword.core.d.ts +17 -3
  58. package/dist/cryptoPassword/cryptoPassword.core.js +29 -21
  59. package/dist/cryptoPassword/cryptoPassword.helper.js +6 -5
  60. package/dist/cryptoPassword/cryptoPassword.type.d.ts +33 -5
  61. package/dist/cryptoPassword/cryptoPassword.validate.d.ts +14 -3
  62. package/dist/cryptoPassword/cryptoPassword.validate.js +51 -20
  63. package/dist/cryptoProvider/cryptoProvider.default.d.ts +18 -0
  64. package/dist/cryptoProvider/cryptoProvider.default.js +31 -0
  65. package/dist/cryptoProvider/cryptoProvider.interface.d.ts +9 -34
  66. package/dist/cryptoProvider/cryptoProvider.type.d.ts +32 -3
  67. package/dist/cryptoProvider/cryptoProvider.type.js +40 -1
  68. package/dist/cryptoProvider/index.d.ts +5 -2
  69. package/dist/cryptoProvider/index.js +2 -0
  70. package/dist/cryptoProvider/types/cryptoCipher.type.d.ts +11 -6
  71. package/dist/cryptoProvider/types/cryptoKeyDerivation.type.d.ts +39 -3
  72. package/dist/cryptoProvider/types/cryptoSignature.type.d.ts +5 -5
  73. package/dist/cryptoProvider/types/index.d.ts +1 -1
  74. package/dist/cryptoRandom/cryptoRandom.choice.d.ts +6 -3
  75. package/dist/cryptoRandom/cryptoRandom.choice.js +10 -6
  76. package/dist/cryptoRandom/cryptoRandom.core.d.ts +8 -5
  77. package/dist/cryptoRandom/cryptoRandom.core.js +8 -7
  78. package/dist/cryptoRandom/cryptoRandom.string.d.ts +11 -9
  79. package/dist/cryptoRandom/cryptoRandom.string.js +28 -29
  80. package/dist/cryptoService/cryptoService.core.d.ts +47 -9
  81. package/dist/cryptoService/cryptoService.core.js +65 -33
  82. package/dist/cryptoService/cryptoService.derivation.d.ts +3 -3
  83. package/dist/cryptoService/cryptoService.derivation.js +8 -6
  84. package/dist/cryptoService/cryptoService.encoding.js +6 -5
  85. package/dist/cryptoService/index.d.ts +1 -5
  86. package/dist/cryptoService/index.js +1 -5
  87. package/dist/cryptoService/operations/cryptoService.cipher.d.ts +3 -2
  88. package/dist/cryptoService/operations/cryptoService.cipher.js +13 -9
  89. package/dist/cryptoService/operations/cryptoService.hash.d.ts +3 -2
  90. package/dist/cryptoService/operations/cryptoService.hash.js +7 -8
  91. package/dist/cryptoService/operations/cryptoService.password.d.ts +7 -2
  92. package/dist/cryptoService/operations/cryptoService.password.js +20 -9
  93. package/dist/cryptoService/operations/cryptoService.token.d.ts +9 -4
  94. package/dist/cryptoService/operations/cryptoService.token.js +31 -17
  95. package/dist/cryptoSignature/cryptoSignature.core.d.ts +10 -2
  96. package/dist/cryptoSignature/cryptoSignature.core.js +7 -3
  97. package/dist/cryptoToken/cryptoToken.core.d.ts +15 -9
  98. package/dist/cryptoToken/cryptoToken.core.js +63 -38
  99. package/dist/cryptoToken/cryptoToken.hash.d.ts +9 -7
  100. package/dist/cryptoToken/cryptoToken.hash.js +19 -43
  101. package/dist/cryptoUtils/cryptoUtils.compare.d.ts +3 -1
  102. package/dist/cryptoUtils/cryptoUtils.compare.js +5 -14
  103. package/dist/cryptoUtils/cryptoUtils.number.d.ts +3 -0
  104. package/dist/cryptoUtils/cryptoUtils.number.js +12 -6
  105. package/dist/cryptoUtils/cryptoUtils.validation.d.ts +2 -2
  106. package/dist/cryptoUtils/cryptoUtils.validation.js +6 -8
  107. package/dist/cryptoUtils/encoding/cryptoUtils.base64.d.ts +4 -4
  108. package/dist/cryptoUtils/encoding/cryptoUtils.base64.js +5 -23
  109. package/dist/cryptoUtils/encoding/cryptoUtils.base64url.d.ts +4 -4
  110. package/dist/cryptoUtils/encoding/cryptoUtils.base64url.js +5 -32
  111. package/dist/cryptoUtils/encoding/cryptoUtils.hex.d.ts +4 -4
  112. package/dist/cryptoUtils/encoding/cryptoUtils.hex.js +5 -20
  113. package/dist/index.d.ts +1 -2
  114. package/dist/index.js +1 -2
  115. package/dist/node/nodeCryptoProvider/nodeCryptoProvider.core.d.ts +6 -29
  116. package/dist/node/nodeCryptoProvider/nodeCryptoProvider.core.js +0 -1
  117. package/dist/node/nodeCryptoProvider/nodeCryptoProvider.helper.d.ts +9 -4
  118. package/dist/node/nodeCryptoProvider/nodeCryptoProvider.helper.js +25 -43
  119. package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.derivation.d.ts +7 -0
  120. package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.derivation.js +89 -30
  121. package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.password.d.ts +17 -10
  122. package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.password.js +112 -72
  123. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.encryption.d.ts +3 -12
  124. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.encryption.js +74 -25
  125. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.hash.js +7 -2
  126. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.random.d.ts +6 -0
  127. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.random.js +18 -18
  128. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.signing.d.ts +10 -12
  129. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.signing.js +75 -20
  130. package/dist/node/signing/signing.conversion.d.ts +13 -3
  131. package/dist/node/signing/signing.conversion.js +35 -15
  132. package/dist/node/signing/signing.core.d.ts +2 -1
  133. package/dist/node/signing/signing.core.js +2 -3
  134. package/dist/node/signing/signing.utils.d.ts +10 -2
  135. package/dist/node/signing/signing.utils.js +26 -5
  136. package/package.json +18 -8
  137. package/dist/.tsbuildinfo +0 -1
  138. package/dist/compare/compare.helper.d.ts.map +0 -1
  139. package/dist/compare/compare.helper.js.map +0 -1
  140. package/dist/compare/index.d.ts.map +0 -1
  141. package/dist/compare/index.js.map +0 -1
  142. package/dist/cryptoAlgorithm/index.d.ts +0 -8
  143. package/dist/cryptoAlgorithm/index.d.ts.map +0 -1
  144. package/dist/cryptoAlgorithm/index.js +0 -8
  145. package/dist/cryptoAlgorithm/index.js.map +0 -1
  146. package/dist/cryptoCipher/cryptoCipher.core.d.ts.map +0 -1
  147. package/dist/cryptoCipher/cryptoCipher.core.js.map +0 -1
  148. package/dist/cryptoCipher/cryptoCipher.envelope.d.ts.map +0 -1
  149. package/dist/cryptoCipher/cryptoCipher.envelope.js.map +0 -1
  150. package/dist/cryptoCipher/cryptoCipher.string.d.ts.map +0 -1
  151. package/dist/cryptoCipher/cryptoCipher.string.js.map +0 -1
  152. package/dist/cryptoCipher/index.d.ts.map +0 -1
  153. package/dist/cryptoCipher/index.js.map +0 -1
  154. package/dist/cryptoConstants/cryptoConstants.config.d.ts.map +0 -1
  155. package/dist/cryptoConstants/cryptoConstants.config.js.map +0 -1
  156. package/dist/cryptoConstants/cryptoConstants.guard.d.ts.map +0 -1
  157. package/dist/cryptoConstants/cryptoConstants.guard.js.map +0 -1
  158. package/dist/cryptoConstants/cryptoConstants.security.d.ts.map +0 -1
  159. package/dist/cryptoConstants/cryptoConstants.security.js.map +0 -1
  160. package/dist/cryptoConstants/cryptoConstants.token.d.ts.map +0 -1
  161. package/dist/cryptoConstants/cryptoConstants.token.js.map +0 -1
  162. package/dist/cryptoConstants/cryptoConstants.type.d.ts.map +0 -1
  163. package/dist/cryptoConstants/cryptoConstants.type.js.map +0 -1
  164. package/dist/cryptoConstants/index.d.ts.map +0 -1
  165. package/dist/cryptoConstants/index.js.map +0 -1
  166. package/dist/cryptoEncoding/cryptoEncoding.arrayBuffer.d.ts.map +0 -1
  167. package/dist/cryptoEncoding/cryptoEncoding.arrayBuffer.js.map +0 -1
  168. package/dist/cryptoEncoding/cryptoEncoding.compare.d.ts.map +0 -1
  169. package/dist/cryptoEncoding/cryptoEncoding.compare.js.map +0 -1
  170. package/dist/cryptoEncoding/cryptoEncoding.core.d.ts.map +0 -1
  171. package/dist/cryptoEncoding/cryptoEncoding.core.js.map +0 -1
  172. package/dist/cryptoEncoding/encoding/cryptoEncoding.base64.d.ts.map +0 -1
  173. package/dist/cryptoEncoding/encoding/cryptoEncoding.base64.js.map +0 -1
  174. package/dist/cryptoEncoding/encoding/cryptoEncoding.base64url.d.ts.map +0 -1
  175. package/dist/cryptoEncoding/encoding/cryptoEncoding.base64url.js.map +0 -1
  176. package/dist/cryptoEncoding/encoding/cryptoEncoding.hex.d.ts.map +0 -1
  177. package/dist/cryptoEncoding/encoding/cryptoEncoding.hex.js.map +0 -1
  178. package/dist/cryptoEncoding/encoding/index.d.ts.map +0 -1
  179. package/dist/cryptoEncoding/encoding/index.js.map +0 -1
  180. package/dist/cryptoEncoding/index.d.ts.map +0 -1
  181. package/dist/cryptoEncoding/index.js.map +0 -1
  182. package/dist/cryptoErrors/index.d.ts.map +0 -1
  183. package/dist/cryptoErrors/index.js.map +0 -1
  184. package/dist/cryptoFactory/cryptoFactory.core.d.ts.map +0 -1
  185. package/dist/cryptoFactory/cryptoFactory.core.js.map +0 -1
  186. package/dist/cryptoFactory/cryptoFactory.encoding.d.ts.map +0 -1
  187. package/dist/cryptoFactory/cryptoFactory.encoding.js.map +0 -1
  188. package/dist/cryptoFactory/cryptoFactory.options.d.ts +0 -2
  189. package/dist/cryptoFactory/cryptoFactory.options.d.ts.map +0 -1
  190. package/dist/cryptoFactory/cryptoFactory.options.js +0 -6
  191. package/dist/cryptoFactory/cryptoFactory.options.js.map +0 -1
  192. package/dist/cryptoFactory/cryptoFactory.password.d.ts.map +0 -1
  193. package/dist/cryptoFactory/cryptoFactory.password.js.map +0 -1
  194. package/dist/cryptoFactory/cryptoFactory.token.d.ts.map +0 -1
  195. package/dist/cryptoFactory/cryptoFactory.token.js.map +0 -1
  196. package/dist/cryptoFactory/index.d.ts.map +0 -1
  197. package/dist/cryptoFactory/index.js.map +0 -1
  198. package/dist/cryptoHash/cryptoHash.codec.d.ts.map +0 -1
  199. package/dist/cryptoHash/cryptoHash.codec.js.map +0 -1
  200. package/dist/cryptoHash/cryptoHash.compare.d.ts.map +0 -1
  201. package/dist/cryptoHash/cryptoHash.compare.js.map +0 -1
  202. package/dist/cryptoHash/cryptoHash.convenience.d.ts.map +0 -1
  203. package/dist/cryptoHash/cryptoHash.convenience.js.map +0 -1
  204. package/dist/cryptoHash/cryptoHash.core.d.ts.map +0 -1
  205. package/dist/cryptoHash/cryptoHash.core.js.map +0 -1
  206. package/dist/cryptoHash/cryptoHmac.core.d.ts.map +0 -1
  207. package/dist/cryptoHash/cryptoHmac.core.js.map +0 -1
  208. package/dist/cryptoHash/index.d.ts.map +0 -1
  209. package/dist/cryptoHash/index.js.map +0 -1
  210. package/dist/cryptoKey/cryptoKey.factory.d.ts.map +0 -1
  211. package/dist/cryptoKey/cryptoKey.factory.js.map +0 -1
  212. package/dist/cryptoKey/cryptoKey.type.d.ts.map +0 -1
  213. package/dist/cryptoKey/cryptoKey.type.js.map +0 -1
  214. package/dist/cryptoKey/cryptoKey.utils.d.ts.map +0 -1
  215. package/dist/cryptoKey/cryptoKey.utils.js.map +0 -1
  216. package/dist/cryptoKey/index.d.ts.map +0 -1
  217. package/dist/cryptoKey/index.js.map +0 -1
  218. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.core.d.ts.map +0 -1
  219. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.core.js.map +0 -1
  220. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.salt.d.ts.map +0 -1
  221. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.salt.js.map +0 -1
  222. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.type.d.ts.map +0 -1
  223. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.type.js.map +0 -1
  224. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.validate.d.ts.map +0 -1
  225. package/dist/cryptoKeyDerivation/cryptoKeyDerivation.validate.js.map +0 -1
  226. package/dist/cryptoKeyDerivation/index.d.ts.map +0 -1
  227. package/dist/cryptoKeyDerivation/index.js.map +0 -1
  228. package/dist/cryptoPassword/cryptoPassword.codec.d.ts.map +0 -1
  229. package/dist/cryptoPassword/cryptoPassword.codec.js.map +0 -1
  230. package/dist/cryptoPassword/cryptoPassword.core.d.ts.map +0 -1
  231. package/dist/cryptoPassword/cryptoPassword.core.js.map +0 -1
  232. package/dist/cryptoPassword/cryptoPassword.helper.d.ts.map +0 -1
  233. package/dist/cryptoPassword/cryptoPassword.helper.js.map +0 -1
  234. package/dist/cryptoPassword/cryptoPassword.type.d.ts.map +0 -1
  235. package/dist/cryptoPassword/cryptoPassword.type.js.map +0 -1
  236. package/dist/cryptoPassword/cryptoPassword.validate.d.ts.map +0 -1
  237. package/dist/cryptoPassword/cryptoPassword.validate.js.map +0 -1
  238. package/dist/cryptoPassword/index.d.ts.map +0 -1
  239. package/dist/cryptoPassword/index.js.map +0 -1
  240. package/dist/cryptoProvider/cryptoProvider.core.d.ts.map +0 -1
  241. package/dist/cryptoProvider/cryptoProvider.core.js.map +0 -1
  242. package/dist/cryptoProvider/cryptoProvider.interface.d.ts.map +0 -1
  243. package/dist/cryptoProvider/cryptoProvider.interface.js.map +0 -1
  244. package/dist/cryptoProvider/cryptoProvider.type.d.ts.map +0 -1
  245. package/dist/cryptoProvider/cryptoProvider.type.js.map +0 -1
  246. package/dist/cryptoProvider/index.d.ts.map +0 -1
  247. package/dist/cryptoProvider/index.js.map +0 -1
  248. package/dist/cryptoProvider/types/cryptoCipher.type.d.ts.map +0 -1
  249. package/dist/cryptoProvider/types/cryptoCipher.type.js.map +0 -1
  250. package/dist/cryptoProvider/types/cryptoHash.type.d.ts.map +0 -1
  251. package/dist/cryptoProvider/types/cryptoHash.type.js.map +0 -1
  252. package/dist/cryptoProvider/types/cryptoKeyDerivation.type.d.ts.map +0 -1
  253. package/dist/cryptoProvider/types/cryptoKeyDerivation.type.js.map +0 -1
  254. package/dist/cryptoProvider/types/cryptoRandom.type.d.ts.map +0 -1
  255. package/dist/cryptoProvider/types/cryptoRandom.type.js.map +0 -1
  256. package/dist/cryptoProvider/types/cryptoSignature.type.d.ts.map +0 -1
  257. package/dist/cryptoProvider/types/cryptoSignature.type.js.map +0 -1
  258. package/dist/cryptoProvider/types/index.d.ts.map +0 -1
  259. package/dist/cryptoProvider/types/index.js.map +0 -1
  260. package/dist/cryptoRandom/cryptoRandom.choice.d.ts.map +0 -1
  261. package/dist/cryptoRandom/cryptoRandom.choice.js.map +0 -1
  262. package/dist/cryptoRandom/cryptoRandom.core.d.ts.map +0 -1
  263. package/dist/cryptoRandom/cryptoRandom.core.js.map +0 -1
  264. package/dist/cryptoRandom/cryptoRandom.string.d.ts.map +0 -1
  265. package/dist/cryptoRandom/cryptoRandom.string.js.map +0 -1
  266. package/dist/cryptoRandom/index.d.ts.map +0 -1
  267. package/dist/cryptoRandom/index.js.map +0 -1
  268. package/dist/cryptoService/cryptoService.core.d.ts.map +0 -1
  269. package/dist/cryptoService/cryptoService.core.js.map +0 -1
  270. package/dist/cryptoService/cryptoService.derivation.d.ts.map +0 -1
  271. package/dist/cryptoService/cryptoService.derivation.js.map +0 -1
  272. package/dist/cryptoService/cryptoService.encoding.d.ts.map +0 -1
  273. package/dist/cryptoService/cryptoService.encoding.js.map +0 -1
  274. package/dist/cryptoService/index.d.ts.map +0 -1
  275. package/dist/cryptoService/index.js.map +0 -1
  276. package/dist/cryptoService/operations/cryptoService.cipher.d.ts.map +0 -1
  277. package/dist/cryptoService/operations/cryptoService.cipher.js.map +0 -1
  278. package/dist/cryptoService/operations/cryptoService.hash.d.ts.map +0 -1
  279. package/dist/cryptoService/operations/cryptoService.hash.js.map +0 -1
  280. package/dist/cryptoService/operations/cryptoService.password.d.ts.map +0 -1
  281. package/dist/cryptoService/operations/cryptoService.password.js.map +0 -1
  282. package/dist/cryptoService/operations/cryptoService.token.d.ts.map +0 -1
  283. package/dist/cryptoService/operations/cryptoService.token.js.map +0 -1
  284. package/dist/cryptoService/operations/index.d.ts.map +0 -1
  285. package/dist/cryptoService/operations/index.js.map +0 -1
  286. package/dist/cryptoSignature/cryptoSignature.core.d.ts.map +0 -1
  287. package/dist/cryptoSignature/cryptoSignature.core.js.map +0 -1
  288. package/dist/cryptoSignature/index.d.ts.map +0 -1
  289. package/dist/cryptoSignature/index.js.map +0 -1
  290. package/dist/cryptoToken/cryptoToken.core.d.ts.map +0 -1
  291. package/dist/cryptoToken/cryptoToken.core.js.map +0 -1
  292. package/dist/cryptoToken/cryptoToken.hash.d.ts.map +0 -1
  293. package/dist/cryptoToken/cryptoToken.hash.js.map +0 -1
  294. package/dist/cryptoToken/cryptoToken.utils.d.ts.map +0 -1
  295. package/dist/cryptoToken/cryptoToken.utils.js.map +0 -1
  296. package/dist/cryptoToken/index.d.ts.map +0 -1
  297. package/dist/cryptoToken/index.js.map +0 -1
  298. package/dist/cryptoUtils/cryptoUtils.compare.d.ts.map +0 -1
  299. package/dist/cryptoUtils/cryptoUtils.compare.js.map +0 -1
  300. package/dist/cryptoUtils/cryptoUtils.conversion.d.ts.map +0 -1
  301. package/dist/cryptoUtils/cryptoUtils.conversion.js.map +0 -1
  302. package/dist/cryptoUtils/cryptoUtils.number.d.ts.map +0 -1
  303. package/dist/cryptoUtils/cryptoUtils.number.js.map +0 -1
  304. package/dist/cryptoUtils/cryptoUtils.text.d.ts.map +0 -1
  305. package/dist/cryptoUtils/cryptoUtils.text.js.map +0 -1
  306. package/dist/cryptoUtils/cryptoUtils.validation.d.ts.map +0 -1
  307. package/dist/cryptoUtils/cryptoUtils.validation.js.map +0 -1
  308. package/dist/cryptoUtils/encoding/cryptoUtils.base64.d.ts.map +0 -1
  309. package/dist/cryptoUtils/encoding/cryptoUtils.base64.js.map +0 -1
  310. package/dist/cryptoUtils/encoding/cryptoUtils.base64url.d.ts.map +0 -1
  311. package/dist/cryptoUtils/encoding/cryptoUtils.base64url.js.map +0 -1
  312. package/dist/cryptoUtils/encoding/cryptoUtils.hex.d.ts.map +0 -1
  313. package/dist/cryptoUtils/encoding/cryptoUtils.hex.js.map +0 -1
  314. package/dist/cryptoUtils/encoding/index.d.ts.map +0 -1
  315. package/dist/cryptoUtils/encoding/index.js.map +0 -1
  316. package/dist/cryptoUtils/index.d.ts.map +0 -1
  317. package/dist/cryptoUtils/index.js.map +0 -1
  318. package/dist/index.d.ts.map +0 -1
  319. package/dist/index.js.map +0 -1
  320. package/dist/node/index.d.ts.map +0 -1
  321. package/dist/node/index.js.map +0 -1
  322. package/dist/node/nodeCryptoProvider/index.d.ts.map +0 -1
  323. package/dist/node/nodeCryptoProvider/index.js.map +0 -1
  324. package/dist/node/nodeCryptoProvider/nodeCryptoProvider.core.d.ts.map +0 -1
  325. package/dist/node/nodeCryptoProvider/nodeCryptoProvider.core.js.map +0 -1
  326. package/dist/node/nodeCryptoProvider/nodeCryptoProvider.factory.d.ts.map +0 -1
  327. package/dist/node/nodeCryptoProvider/nodeCryptoProvider.factory.js.map +0 -1
  328. package/dist/node/nodeCryptoProvider/nodeCryptoProvider.helper.d.ts.map +0 -1
  329. package/dist/node/nodeCryptoProvider/nodeCryptoProvider.helper.js.map +0 -1
  330. package/dist/node/nodeCryptoProvider/operations/index.d.ts.map +0 -1
  331. package/dist/node/nodeCryptoProvider/operations/index.js.map +0 -1
  332. package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.derivation.d.ts.map +0 -1
  333. package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.derivation.js.map +0 -1
  334. package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.password.d.ts.map +0 -1
  335. package/dist/node/nodeCryptoProvider/operations/nodeCryptoProvider.password.js.map +0 -1
  336. package/dist/node/nodeCryptoProvider/primitives/index.d.ts.map +0 -1
  337. package/dist/node/nodeCryptoProvider/primitives/index.js.map +0 -1
  338. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.encryption.d.ts.map +0 -1
  339. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.encryption.js.map +0 -1
  340. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.hash.d.ts.map +0 -1
  341. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.hash.js.map +0 -1
  342. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.random.d.ts.map +0 -1
  343. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.random.js.map +0 -1
  344. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.signing.d.ts.map +0 -1
  345. package/dist/node/nodeCryptoProvider/primitives/nodeCryptoProvider.signing.js.map +0 -1
  346. package/dist/node/signing/index.d.ts.map +0 -1
  347. package/dist/node/signing/index.js.map +0 -1
  348. package/dist/node/signing/signing.conversion.d.ts.map +0 -1
  349. package/dist/node/signing/signing.conversion.js.map +0 -1
  350. package/dist/node/signing/signing.core.d.ts.map +0 -1
  351. package/dist/node/signing/signing.core.js.map +0 -1
  352. package/dist/node/signing/signing.utils.d.ts.map +0 -1
  353. package/dist/node/signing/signing.utils.js.map +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @zudojs/crypto
2
2
 
3
- Cryptographic primitives for hashing, encryption, tokens, and secure random generation.
3
+ Cryptographic primitives for hashing, authenticated encryption, password hashing, digital signatures, key derivation, opaque tokens, and secure random generation. Everything is backed by `node:crypto` through a swappable provider.
4
4
 
5
5
  ## Installation
6
6
 
@@ -11,25 +11,54 @@ npm install @zudojs/crypto
11
11
  ## Quick Start
12
12
 
13
13
  ```typescript
14
- import { hash, encrypt, decrypt, randomBytes } from "@zudojs/crypto";
14
+ import {
15
+ randomBytesSecure,
16
+ hash,
17
+ hashPassword,
18
+ verifyPassword,
19
+ encryptEnvelope,
20
+ decryptEnvelope,
21
+ generateToken,
22
+ } from "@zudojs/crypto";
15
23
 
16
- const hashed = await hash("password", "salt");
17
- const token = randomBytes(32);
18
- const encrypted = await encrypt("secret", key);
19
- const decrypted = await decrypt(encrypted, key);
24
+ // Hashing (SHA-2 / SHA-3 only; md5 and sha1 are rejected)
25
+ const digest = await hash("hello", { algorithm: "sha256", encoding: "hex" });
26
+ console.log(digest.encoded);
27
+
28
+ // Password hashing (scrypt, self-describing "v1$scrypt$..." string)
29
+ const stored = await hashPassword("correct horse battery staple");
30
+ const ok = await verifyPassword("correct horse battery staple", stored.encoded);
31
+
32
+ // Authenticated encryption (AES-256-GCM, 12-byte IV, 16-byte tag)
33
+ const key = await randomBytesSecure(32);
34
+ const envelope = await encryptEnvelope(new TextEncoder().encode("secret"), key);
35
+ const plaintext = await decryptEnvelope(envelope, key);
36
+
37
+ // Opaque tokens
38
+ const sessionToken = await generateToken({ bytes: 32, prefix: "sess_" });
20
39
  ```
21
40
 
22
41
  ## Features
23
42
 
24
- - Hashing (SHA-256, SHA-512, bcrypt, argon2)
25
- - Symmetric encryption (AES-GCM)
26
- - Secure random generation
27
- - Token generation
28
- - Key derivation functions
43
+ - Hashing: SHA-256/384/512 and SHA3-256/384/512, HMAC (keys of at least 16 bytes)
44
+ - Authenticated encryption: AES-256-GCM with strict IV (12 bytes) and tag (16 bytes) validation, plus a versioned string envelope
45
+ - Password hashing: scrypt (default, OWASP parameters) and PBKDF2-HMAC (provider level), versioned self-describing encoding, bounded parameters on verification
46
+ - Key derivation: PBKDF2 (sha256/384/512, 600 000 iterations by default) and scrypt (cost, block size, parallelization, memory bound)
47
+ - Digital signatures: Ed25519, RSA-SHA256/384/512, ECDSA-SHA256/384/512; the algorithm label is bound to the key type
48
+ - Secure random: unbiased integers up to 2^48, UUID v4, bytes, alphabets, numeric codes
49
+ - Opaque tokens (API keys, sessions, refresh, CSRF, OTP) with SHA-256 storage hashes
50
+ - Encoding helpers (hex, base64, base64url, strict UTF-8) with canonical-form validation and constant-time comparison
51
+ - Provider injection: `setDefaultCryptoProvider`, `createCryptoService({ provider })`, `createCryptoFactory({ provider })`, or a `provider` option on any helper
52
+
53
+ Not implemented (and not advertised by the types): bcrypt, Argon2, ChaCha20-Poly1305, AES-CBC, X25519.
54
+
55
+ ## Errors
56
+
57
+ Failures throw `CryptoError` from `@zudojs/errors` with a stable `code` (`ERR_CRYPTO_CIPHER`, `ERR_CRYPTO_HASH`, ...) and the underlying Node error as `cause`. `verifyPassword` and `verifyTokenHash` return `false` (never throw) for wrong or malformed inputs.
29
58
 
30
59
  ## Use Cases
31
60
 
32
- - Password hashing
33
- - API token generation
61
+ - Password storage and login verification
62
+ - API token generation and storage
34
63
  - Data encryption at rest
35
- - Secure random values
64
+ - Secure random values and one-time codes
@@ -1,8 +1,16 @@
1
1
  /**
2
2
  * Performs a constant-time comparison of two byte arrays.
3
3
  *
4
- * Returns false immediately if the lengths differ.
5
- * Uses XOR accumulation to avoid timing side-channels.
4
+ * Returns false immediately if the lengths differ. This leaks only the
5
+ * fact that the lengths differ, which is acceptable for fixed-size
6
+ * values such as digests, MACs and tokens; do not rely on this function
7
+ * to hide the length of variable-length secrets.
8
+ *
9
+ * The byte-wise comparison is delegated to `node:crypto.timingSafeEqual`.
6
10
  */
7
11
  export declare function timingSafeEqual(left: Uint8Array, right: Uint8Array): boolean;
12
+ /**
13
+ * Performs a constant-time comparison of two strings by their UTF-8 bytes.
14
+ */
15
+ export declare function timingSafeEqualString(left: string, right: string): boolean;
8
16
  //# sourceMappingURL=compare.helper.d.ts.map
@@ -1,17 +1,33 @@
1
+ import { timingSafeEqual as nodeTimingSafeEqual } from "node:crypto";
1
2
  /**
2
3
  * Performs a constant-time comparison of two byte arrays.
3
4
  *
4
- * Returns false immediately if the lengths differ.
5
- * Uses XOR accumulation to avoid timing side-channels.
5
+ * Returns false immediately if the lengths differ. This leaks only the
6
+ * fact that the lengths differ, which is acceptable for fixed-size
7
+ * values such as digests, MACs and tokens; do not rely on this function
8
+ * to hide the length of variable-length secrets.
9
+ *
10
+ * The byte-wise comparison is delegated to `node:crypto.timingSafeEqual`.
6
11
  */
7
12
  export function timingSafeEqual(left, right) {
13
+ if (!(left instanceof Uint8Array) || !(right instanceof Uint8Array)) {
14
+ throw new TypeError("timingSafeEqual arguments must be Uint8Array.");
15
+ }
8
16
  if (left.byteLength !== right.byteLength) {
9
17
  return false;
10
18
  }
11
- let difference = 0;
12
- for (let index = 0; index < left.byteLength; index += 1) {
13
- difference |= left[index] ^ right[index];
19
+ if (left.byteLength === 0) {
20
+ return true;
21
+ }
22
+ return nodeTimingSafeEqual(left, right);
23
+ }
24
+ /**
25
+ * Performs a constant-time comparison of two strings by their UTF-8 bytes.
26
+ */
27
+ export function timingSafeEqualString(left, right) {
28
+ if (typeof left !== "string" || typeof right !== "string") {
29
+ return false;
14
30
  }
15
- return difference === 0;
31
+ return timingSafeEqual(Buffer.from(left, "utf8"), Buffer.from(right, "utf8"));
16
32
  }
17
33
  //# sourceMappingURL=compare.helper.js.map
@@ -1,9 +1,16 @@
1
+ import type { CryptoProvider } from "../cryptoProvider/index.js";
1
2
  /**
2
3
  * Options used when encrypting data.
4
+ *
5
+ * `iv`, when supplied, must be exactly 12 bytes and MUST be unique per
6
+ * key. Reusing an IV under the same key with AES-GCM leaks the XOR of the
7
+ * plaintexts and allows authentication-key recovery; omit it to have a
8
+ * fresh random IV drawn for every call.
3
9
  */
4
10
  export interface CipherOptions {
5
11
  readonly iv?: Uint8Array;
6
12
  readonly aad?: Uint8Array;
13
+ readonly provider?: CryptoProvider;
7
14
  }
8
15
  /**
9
16
  * Authenticated encryption result.
@@ -20,6 +27,9 @@ export interface CipherResult {
20
27
  export declare function encrypt(plaintext: Uint8Array, key: Uint8Array, options?: CipherOptions): Promise<CipherResult>;
21
28
  /**
22
29
  * Decrypts AES-256-GCM ciphertext.
30
+ *
31
+ * The IV must be 12 bytes and the authentication tag 16 bytes; truncated
32
+ * tags are rejected before the cipher is touched.
23
33
  */
24
- export declare function decrypt(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
34
+ export declare function decrypt(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array, aad?: Uint8Array, provider?: CryptoProvider): Promise<Uint8Array>;
25
35
  //# sourceMappingURL=cryptoCipher.core.d.ts.map
@@ -1,9 +1,15 @@
1
- import { createNodeCryptoProvider } from "../node/index.js";
2
- const provider = createNodeCryptoProvider();
1
+ import { getDefaultCryptoProvider } from "../cryptoProvider/cryptoProvider.default.js";
2
+ import { AES_GCM } from "../cryptoConstants/cryptoConstants.type.js";
3
+ import { CryptoOperation } from "@zudojs/errors";
4
+ import { cipherError } from "../cryptoErrors/cryptoErrors.helper.js";
3
5
  /**
4
6
  * Encrypts data using AES-256-GCM.
5
7
  */
6
8
  export async function encrypt(plaintext, key, options = {}) {
9
+ if (options.iv !== undefined && options.iv.byteLength !== AES_GCM.IV_BYTES) {
10
+ throw cipherError(`AES-256-GCM iv must be ${AES_GCM.IV_BYTES} bytes.`, CryptoOperation.ENCRYPT, "aes-256-gcm");
11
+ }
12
+ const provider = options.provider ?? getDefaultCryptoProvider();
7
13
  const encrypted = await provider.encrypt({
8
14
  key,
9
15
  plaintext,
@@ -19,8 +25,18 @@ export async function encrypt(plaintext, key, options = {}) {
19
25
  }
20
26
  /**
21
27
  * Decrypts AES-256-GCM ciphertext.
28
+ *
29
+ * The IV must be 12 bytes and the authentication tag 16 bytes; truncated
30
+ * tags are rejected before the cipher is touched.
22
31
  */
23
- export async function decrypt(ciphertext, key, iv, authTag, aad) {
32
+ export async function decrypt(ciphertext, key, iv, authTag, aad, provider = getDefaultCryptoProvider()) {
33
+ if (!(iv instanceof Uint8Array) || iv.byteLength !== AES_GCM.IV_BYTES) {
34
+ throw cipherError(`AES-256-GCM iv must be ${AES_GCM.IV_BYTES} bytes.`, CryptoOperation.DECRYPT, "aes-256-gcm");
35
+ }
36
+ if (!(authTag instanceof Uint8Array) ||
37
+ authTag.byteLength !== AES_GCM.AUTH_TAG_BYTES) {
38
+ throw cipherError(`AES-256-GCM authentication tag must be ${AES_GCM.AUTH_TAG_BYTES} bytes.`, CryptoOperation.DECRYPT, "aes-256-gcm");
39
+ }
24
40
  return provider.decrypt({
25
41
  key,
26
42
  encrypted: {
@@ -1,3 +1,4 @@
1
+ import type { CryptoProvider } from "../cryptoProvider/index.js";
1
2
  import type { CipherOptions } from "./cryptoCipher.core.js";
2
3
  /**
3
4
  * Creates an encrypted envelope suitable for storage or transport.
@@ -6,11 +7,15 @@ import type { CipherOptions } from "./cryptoCipher.core.js";
6
7
  *
7
8
  * version.algorithm.iv.authTag.ciphertext
8
9
  *
9
- * All binary fields are Base64URL encoded.
10
+ * All binary fields are canonical Base64URL encoded.
10
11
  */
11
12
  export declare function encryptEnvelope(plaintext: Uint8Array, key: Uint8Array, options?: CipherOptions): Promise<string>;
12
13
  /**
13
14
  * Decrypts an encrypted envelope.
15
+ *
16
+ * Every field is validated (version, algorithm, canonical Base64URL, IV and
17
+ * tag lengths) before the cipher is invoked; malformed envelopes and failed
18
+ * authentication both surface as `CryptoError` with code `ERR_CRYPTO_CIPHER`.
14
19
  */
15
- export declare function decryptEnvelope(envelope: string, key: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
20
+ export declare function decryptEnvelope(envelope: string, key: Uint8Array, aad?: Uint8Array, provider?: CryptoProvider): Promise<Uint8Array>;
16
21
  //# sourceMappingURL=cryptoCipher.envelope.d.ts.map
@@ -1,4 +1,8 @@
1
1
  import { encrypt, decrypt } from "./cryptoCipher.core.js";
2
+ import { AES_GCM } from "../cryptoConstants/cryptoConstants.type.js";
3
+ import { fromBase64Url } from "../cryptoEncoding/encoding/cryptoEncoding.base64url.js";
4
+ import { CryptoOperation } from "@zudojs/errors";
5
+ import { cipherError } from "../cryptoErrors/cryptoErrors.helper.js";
2
6
  /**
3
7
  * Creates an encrypted envelope suitable for storage or transport.
4
8
  *
@@ -6,7 +10,7 @@ import { encrypt, decrypt } from "./cryptoCipher.core.js";
6
10
  *
7
11
  * version.algorithm.iv.authTag.ciphertext
8
12
  *
9
- * All binary fields are Base64URL encoded.
13
+ * All binary fields are canonical Base64URL encoded.
10
14
  */
11
15
  export async function encryptEnvelope(plaintext, key, options = {}) {
12
16
  const result = await encrypt(plaintext, key, options);
@@ -20,31 +24,46 @@ export async function encryptEnvelope(plaintext, key, options = {}) {
20
24
  }
21
25
  /**
22
26
  * Decrypts an encrypted envelope.
27
+ *
28
+ * Every field is validated (version, algorithm, canonical Base64URL, IV and
29
+ * tag lengths) before the cipher is invoked; malformed envelopes and failed
30
+ * authentication both surface as `CryptoError` with code `ERR_CRYPTO_CIPHER`.
23
31
  */
24
- export async function decryptEnvelope(envelope, key, aad) {
32
+ export async function decryptEnvelope(envelope, key, aad, provider) {
25
33
  if (typeof envelope !== "string") {
26
- throw new TypeError("Encrypted envelope must be a string.");
34
+ throw envelopeError("Encrypted envelope must be a string.");
27
35
  }
28
36
  const parts = envelope.split(".");
29
37
  if (parts.length !== 5) {
30
- throw new TypeError("Invalid encrypted envelope.");
38
+ throw envelopeError("Invalid encrypted envelope.");
31
39
  }
32
40
  const [version, algorithm, encodedIv, encodedAuthTag, encodedCiphertext] = parts;
33
41
  if (version !== "v1") {
34
- throw new TypeError(`Unsupported encrypted envelope version: ${version}.`);
42
+ throw envelopeError(`Unsupported encrypted envelope version: ${version}.`);
35
43
  }
36
44
  if (algorithm !== "aes-256-gcm") {
37
- throw new TypeError(`Unsupported envelope algorithm: ${algorithm}.`);
45
+ throw envelopeError(`Unsupported envelope algorithm: ${algorithm}.`);
46
+ }
47
+ const iv = decodeField(encodedIv, "iv");
48
+ const authTag = decodeField(encodedAuthTag, "authentication tag");
49
+ const ciphertext = decodeField(encodedCiphertext, "ciphertext");
50
+ if (iv.byteLength !== AES_GCM.IV_BYTES) {
51
+ throw envelopeError(`Encrypted envelope iv must be ${AES_GCM.IV_BYTES} bytes.`);
52
+ }
53
+ if (authTag.byteLength !== AES_GCM.AUTH_TAG_BYTES) {
54
+ throw envelopeError(`Encrypted envelope authentication tag must be ${AES_GCM.AUTH_TAG_BYTES} bytes.`);
38
55
  }
39
- const iv = decodeBase64Url(encodedIv);
40
- const authTag = decodeBase64Url(encodedAuthTag);
41
- const ciphertext = decodeBase64Url(encodedCiphertext);
42
- return decrypt(ciphertext, key, iv, authTag, aad);
56
+ return decrypt(ciphertext, key, iv, authTag, aad, provider);
43
57
  }
44
- function decodeBase64Url(value) {
45
- if (!/^[A-Za-z0-9_-]*$/.test(value)) {
46
- throw new TypeError("Invalid Base64URL value.");
58
+ function decodeField(value, name) {
59
+ try {
60
+ return fromBase64Url(value);
47
61
  }
48
- return new Uint8Array(Buffer.from(value, "base64url"));
62
+ catch (error) {
63
+ throw envelopeError(`Invalid encrypted envelope ${name}.`, error);
64
+ }
65
+ }
66
+ function envelopeError(message, cause) {
67
+ return cipherError(message, CryptoOperation.DECRYPT, "aes-256-gcm", cause);
49
68
  }
50
69
  //# sourceMappingURL=cryptoCipher.envelope.js.map
@@ -1,3 +1,4 @@
1
+ import type { CryptoProvider } from "../cryptoProvider/index.js";
1
2
  import type { CipherOptions, CipherResult } from "./cryptoCipher.core.js";
2
3
  /**
3
4
  * Encrypts a UTF-8 string using AES-256-GCM.
@@ -6,5 +7,5 @@ export declare function encryptString(plaintext: string, key: Uint8Array, option
6
7
  /**
7
8
  * Decrypts AES-256-GCM ciphertext into a UTF-8 string.
8
9
  */
9
- export declare function decryptString(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array, aad?: Uint8Array): Promise<string>;
10
+ export declare function decryptString(ciphertext: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array, aad?: Uint8Array, provider?: CryptoProvider): Promise<string>;
10
11
  //# sourceMappingURL=cryptoCipher.string.d.ts.map
@@ -8,8 +8,8 @@ export async function encryptString(plaintext, key, options = {}) {
8
8
  /**
9
9
  * Decrypts AES-256-GCM ciphertext into a UTF-8 string.
10
10
  */
11
- export async function decryptString(ciphertext, key, iv, authTag, aad) {
12
- const plaintext = await decrypt(ciphertext, key, iv, authTag, aad);
11
+ export async function decryptString(ciphertext, key, iv, authTag, aad, provider) {
12
+ const plaintext = await decrypt(ciphertext, key, iv, authTag, aad, provider);
13
13
  return Buffer.from(plaintext).toString("utf8");
14
14
  }
15
15
  //# sourceMappingURL=cryptoCipher.string.js.map
@@ -15,6 +15,15 @@ export declare function isKeyDerivationAlgorithm(algorithm: CryptoAlgorithm): bo
15
15
  * Returns true when an algorithm is a message authentication algorithm.
16
16
  */
17
17
  export declare function isMacAlgorithm(algorithm: CryptoAlgorithm): boolean;
18
+ /**
19
+ * Returns true when an algorithm is a digital signature algorithm.
20
+ */
21
+ export declare function isSignatureAlgorithm(algorithm: CryptoAlgorithm): boolean;
22
+ /**
23
+ * Returns true when an algorithm is a symmetric key algorithm
24
+ * (encryption, MAC or key derivation output).
25
+ */
26
+ export declare function isSymmetricKeyAlgorithm(algorithm: CryptoAlgorithm): boolean;
18
27
  /**
19
28
  * Returns true when the supplied value is a supported algorithm.
20
29
  */
@@ -1,4 +1,4 @@
1
- import { CryptoAlgorithm, AEAD_ALGORITHMS, HASH_ALGORITHMS, KEY_DERIVATION_ALGORITHMS, MAC_ALGORITHMS, } from "./cryptoConstants.type.js";
1
+ import { CryptoAlgorithm, AEAD_ALGORITHMS, HASH_ALGORITHMS, KEY_DERIVATION_ALGORITHMS, MAC_ALGORITHMS, SIGNATURE_ALGORITHMS, } from "./cryptoConstants.type.js";
2
2
  /**
3
3
  * Returns true when an algorithm provides authenticated encryption.
4
4
  */
@@ -23,6 +23,21 @@ export function isKeyDerivationAlgorithm(algorithm) {
23
23
  export function isMacAlgorithm(algorithm) {
24
24
  return MAC_ALGORITHMS.includes(algorithm);
25
25
  }
26
+ /**
27
+ * Returns true when an algorithm is a digital signature algorithm.
28
+ */
29
+ export function isSignatureAlgorithm(algorithm) {
30
+ return SIGNATURE_ALGORITHMS.includes(algorithm);
31
+ }
32
+ /**
33
+ * Returns true when an algorithm is a symmetric key algorithm
34
+ * (encryption, MAC or key derivation output).
35
+ */
36
+ export function isSymmetricKeyAlgorithm(algorithm) {
37
+ return (isAeadAlgorithm(algorithm) ||
38
+ isMacAlgorithm(algorithm) ||
39
+ isKeyDerivationAlgorithm(algorithm));
40
+ }
26
41
  /**
27
42
  * Returns true when the supplied value is a supported algorithm.
28
43
  */
@@ -1,5 +1,10 @@
1
1
  /**
2
2
  * Password hashing constants.
3
+ *
4
+ * Defaults follow current OWASP Password Storage Cheat Sheet guidance:
5
+ * scrypt N=2^14, r=8, p=1 (minimum) and PBKDF2-HMAC-SHA256 with 600 000
6
+ * iterations. `LIMITS` bounds parameters that are read back from stored
7
+ * hashes so that a tampered or foreign record cannot force unbounded work.
3
8
  */
4
9
  export declare const PASSWORD_HASH: Readonly<{
5
10
  readonly SALT_BYTES: 16;
@@ -10,15 +15,43 @@ export declare const PASSWORD_HASH: Readonly<{
10
15
  PARALLELIZATION: 1;
11
16
  }>;
12
17
  readonly PBKDF2: Readonly<{
13
- ITERATIONS: 310000;
18
+ ITERATIONS: 600000;
19
+ /**
20
+ * Floor for stored or caller-supplied iteration counts. Kept below the
21
+ * default so hashes produced by other systems with older (but still
22
+ * NIST-compliant) parameters remain verifiable; new hashes always use
23
+ * `ITERATIONS`.
24
+ */
25
+ MIN_ITERATIONS: 100000;
14
26
  DIGEST: "sha256";
15
27
  }>;
28
+ readonly LIMITS: Readonly<{
29
+ MIN_SALT_BYTES: 16;
30
+ MAX_SALT_BYTES: 64;
31
+ MIN_KEY_BYTES: 16;
32
+ MAX_KEY_BYTES: 64;
33
+ MIN_SCRYPT_COST: 2;
34
+ MAX_SCRYPT_COST: number;
35
+ MAX_SCRYPT_BLOCK_SIZE: 32;
36
+ MAX_SCRYPT_PARALLELIZATION: 16;
37
+ /**
38
+ * Upper bound on `128 * N * r` (the scrypt working memory in bytes) so
39
+ * that a stored hash cannot combine the individual maxima into a
40
+ * multi-gigabyte allocation.
41
+ */
42
+ MAX_SCRYPT_MEMORY_BYTES: number;
43
+ MAX_PBKDF2_ITERATIONS: 10000000;
44
+ }>;
16
45
  }>;
17
46
  /**
18
47
  * Password policy defaults.
19
48
  *
20
49
  * These values are intentionally conservative defaults.
21
50
  * Applications may impose stricter requirements.
51
+ *
52
+ * `MAX_LENGTH` is measured in UTF-16 code units and is enforced by
53
+ * `hashPassword`/`verifyPassword` to bound the work an unauthenticated
54
+ * caller can trigger.
22
55
  */
23
56
  export declare const PASSWORD_POLICY: Readonly<{
24
57
  readonly MIN_LENGTH: 8;
@@ -1,6 +1,11 @@
1
1
  import { TimeMs } from "@zudojs/constants";
2
2
  /**
3
3
  * Password hashing constants.
4
+ *
5
+ * Defaults follow current OWASP Password Storage Cheat Sheet guidance:
6
+ * scrypt N=2^14, r=8, p=1 (minimum) and PBKDF2-HMAC-SHA256 with 600 000
7
+ * iterations. `LIMITS` bounds parameters that are read back from stored
8
+ * hashes so that a tampered or foreign record cannot force unbounded work.
4
9
  */
5
10
  export const PASSWORD_HASH = Object.freeze({
6
11
  SALT_BYTES: 16,
@@ -11,15 +16,43 @@ export const PASSWORD_HASH = Object.freeze({
11
16
  PARALLELIZATION: 1,
12
17
  }),
13
18
  PBKDF2: Object.freeze({
14
- ITERATIONS: 310_000,
19
+ ITERATIONS: 600_000,
20
+ /**
21
+ * Floor for stored or caller-supplied iteration counts. Kept below the
22
+ * default so hashes produced by other systems with older (but still
23
+ * NIST-compliant) parameters remain verifiable; new hashes always use
24
+ * `ITERATIONS`.
25
+ */
26
+ MIN_ITERATIONS: 100_000,
15
27
  DIGEST: "sha256",
16
28
  }),
29
+ LIMITS: Object.freeze({
30
+ MIN_SALT_BYTES: 16,
31
+ MAX_SALT_BYTES: 64,
32
+ MIN_KEY_BYTES: 16,
33
+ MAX_KEY_BYTES: 64,
34
+ MIN_SCRYPT_COST: 2,
35
+ MAX_SCRYPT_COST: 2 ** 20,
36
+ MAX_SCRYPT_BLOCK_SIZE: 32,
37
+ MAX_SCRYPT_PARALLELIZATION: 16,
38
+ /**
39
+ * Upper bound on `128 * N * r` (the scrypt working memory in bytes) so
40
+ * that a stored hash cannot combine the individual maxima into a
41
+ * multi-gigabyte allocation.
42
+ */
43
+ MAX_SCRYPT_MEMORY_BYTES: 1024 * 1024 * 1024,
44
+ MAX_PBKDF2_ITERATIONS: 10_000_000,
45
+ }),
17
46
  });
18
47
  /**
19
48
  * Password policy defaults.
20
49
  *
21
50
  * These values are intentionally conservative defaults.
22
51
  * Applications may impose stricter requirements.
52
+ *
53
+ * `MAX_LENGTH` is measured in UTF-16 code units and is enforced by
54
+ * `hashPassword`/`verifyPassword` to bound the work an unauthenticated
55
+ * caller can trigger.
23
56
  */
24
57
  export const PASSWORD_POLICY = Object.freeze({
25
58
  MIN_LENGTH: 8,
@@ -15,6 +15,8 @@ export declare const TOKEN: Readonly<{
15
15
  }>;
16
16
  /**
17
17
  * Random value constraints.
18
+ *
19
+ * `MIN_BYTES` is the entropy floor (128 bits) enforced by `generateToken`.
18
20
  */
19
21
  export declare const RANDOM: Readonly<{
20
22
  readonly MIN_BYTES: 16;
@@ -15,6 +15,8 @@ export const TOKEN = Object.freeze({
15
15
  });
16
16
  /**
17
17
  * Random value constraints.
18
+ *
19
+ * `MIN_BYTES` is the entropy floor (128 bits) enforced by `generateToken`.
18
20
  */
19
21
  export const RANDOM = Object.freeze({
20
22
  MIN_BYTES: 16,
@@ -1,10 +1,13 @@
1
1
  /**
2
- * Supported cryptographic algorithms used by Zudojs.
2
+ * Cryptographic algorithms implemented by Zudojs.
3
+ *
4
+ * Every member listed here is implemented by the Node provider. Algorithms
5
+ * that are not implemented (AES-CBC, ChaCha20-Poly1305, Argon2id, X25519,
6
+ * bcrypt) are deliberately absent so that the type system and the runtime
7
+ * agree on what is supported.
3
8
  */
4
9
  export declare enum CryptoAlgorithm {
5
10
  AES_256_GCM = "aes-256-gcm",
6
- AES_256_CBC = "aes-256-cbc",
7
- CHACHA20_POLY1305 = "chacha20-poly1305",
8
11
  SHA_256 = "sha256",
9
12
  SHA_384 = "sha384",
10
13
  SHA_512 = "sha512",
@@ -15,16 +18,15 @@ export declare enum CryptoAlgorithm {
15
18
  HMAC_SHA384 = "hmac-sha384",
16
19
  HMAC_SHA512 = "hmac-sha512",
17
20
  PBKDF2_SHA256 = "pbkdf2-sha256",
21
+ PBKDF2_SHA384 = "pbkdf2-sha384",
18
22
  PBKDF2_SHA512 = "pbkdf2-sha512",
19
23
  SCRYPT = "scrypt",
20
- ARGON2ID = "argon2id",
21
- ED25519 = "ed25519",
22
- X25519 = "x25519"
24
+ ED25519 = "ed25519"
23
25
  }
24
26
  /**
25
27
  * Algorithms that provide authenticated encryption.
26
28
  */
27
- export declare const AEAD_ALGORITHMS: readonly [CryptoAlgorithm.AES_256_GCM, CryptoAlgorithm.CHACHA20_POLY1305];
29
+ export declare const AEAD_ALGORITHMS: readonly [CryptoAlgorithm.AES_256_GCM];
28
30
  /**
29
31
  * Algorithms intended for hashing.
30
32
  */
@@ -32,13 +34,25 @@ export declare const HASH_ALGORITHMS: readonly [CryptoAlgorithm.SHA_256, CryptoA
32
34
  /**
33
35
  * Algorithms intended for password/key derivation.
34
36
  */
35
- export declare const KEY_DERIVATION_ALGORITHMS: readonly [CryptoAlgorithm.PBKDF2_SHA256, CryptoAlgorithm.PBKDF2_SHA512, CryptoAlgorithm.SCRYPT, CryptoAlgorithm.ARGON2ID];
37
+ export declare const KEY_DERIVATION_ALGORITHMS: readonly [CryptoAlgorithm.PBKDF2_SHA256, CryptoAlgorithm.PBKDF2_SHA384, CryptoAlgorithm.PBKDF2_SHA512, CryptoAlgorithm.SCRYPT];
36
38
  /**
37
39
  * Algorithms intended for message authentication.
38
40
  */
39
41
  export declare const MAC_ALGORITHMS: readonly [CryptoAlgorithm.HMAC_SHA256, CryptoAlgorithm.HMAC_SHA384, CryptoAlgorithm.HMAC_SHA512];
42
+ /**
43
+ * Key algorithms intended for digital signatures.
44
+ *
45
+ * Only Ed25519 keys are representable as a `CryptoKey`. RSA and ECDSA
46
+ * signing is supported through `SignatureAlgorithm` with PEM/DER key
47
+ * material rather than through this enum.
48
+ */
49
+ export declare const SIGNATURE_ALGORITHMS: readonly [CryptoAlgorithm.ED25519];
40
50
  /**
41
51
  * AES-GCM constants.
52
+ *
53
+ * The 96-bit IV and 128-bit authentication tag are the only sizes accepted
54
+ * by this package: shorter tags weaken forgery resistance and non-96-bit
55
+ * IVs are GHASH-derived, which shrinks the effective nonce space.
42
56
  */
43
57
  export declare const AES_GCM: Readonly<{
44
58
  readonly KEY_BYTES: 32;
@@ -66,6 +80,7 @@ export declare const KEY_SIZE: Readonly<{
66
80
  readonly AES_256_BITS: 256;
67
81
  readonly ED25519_BITS: 256;
68
82
  readonly MIN_SYMMETRIC_KEY_BITS: 128;
83
+ readonly MIN_HMAC_KEY_BYTES: 16;
69
84
  }>;
70
85
  /**
71
86
  * Encoding constants.
@@ -77,19 +92,26 @@ export declare const ENCODING: Readonly<{
77
92
  readonly UTF8: "utf8";
78
93
  }>;
79
94
  /**
80
- * Cryptographic algorithm identifiers.
95
+ * Cryptographic algorithm identifiers as a plain constant object.
96
+ *
97
+ * Mirrors `CryptoAlgorithm` exactly (same names and values) for callers
98
+ * that prefer `as const` objects over enums.
81
99
  */
82
100
  export declare const CRYPTO_ALGORITHM: Readonly<{
83
- readonly SHA256: "sha256";
84
- readonly SHA384: "sha384";
85
- readonly SHA512: "sha512";
101
+ readonly AES_256_GCM: "aes-256-gcm";
102
+ readonly SHA_256: "sha256";
103
+ readonly SHA_384: "sha384";
104
+ readonly SHA_512: "sha512";
86
105
  readonly SHA3_256: "sha3-256";
87
106
  readonly SHA3_384: "sha3-384";
88
107
  readonly SHA3_512: "sha3-512";
89
- readonly AES_256_GCM: "aes-256-gcm";
90
- readonly ED25519: "ed25519";
108
+ readonly HMAC_SHA256: "hmac-sha256";
109
+ readonly HMAC_SHA384: "hmac-sha384";
110
+ readonly HMAC_SHA512: "hmac-sha512";
91
111
  readonly PBKDF2_SHA256: "pbkdf2-sha256";
112
+ readonly PBKDF2_SHA384: "pbkdf2-sha384";
92
113
  readonly PBKDF2_SHA512: "pbkdf2-sha512";
93
114
  readonly SCRYPT: "scrypt";
115
+ readonly ED25519: "ed25519";
94
116
  }>;
95
117
  //# sourceMappingURL=cryptoConstants.type.d.ts.map