@digitaldefiance/node-ecies-lib 4.4.9 → 4.4.10

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 (385) hide show
  1. package/package.json +6 -5
  2. package/src/builders/ecies-builder.d.ts +11 -0
  3. package/src/builders/ecies-builder.d.ts.map +1 -0
  4. package/src/builders/ecies-builder.js +26 -0
  5. package/src/builders/ecies-builder.js.map +1 -0
  6. package/src/builders/{index.ts → index.d.ts} +1 -0
  7. package/src/builders/index.d.ts.map +1 -0
  8. package/src/builders/index.js +6 -0
  9. package/src/builders/index.js.map +1 -0
  10. package/src/builders/member-builder.d.ts +47 -0
  11. package/src/builders/member-builder.d.ts.map +1 -0
  12. package/src/builders/member-builder.js +99 -0
  13. package/src/builders/member-builder.js.map +1 -0
  14. package/src/constants.d.ts +38 -0
  15. package/src/constants.d.ts.map +1 -0
  16. package/src/constants.js +183 -0
  17. package/src/constants.js.map +1 -0
  18. package/src/core/errors/crypto-error.d.ts +6 -0
  19. package/src/core/errors/crypto-error.d.ts.map +1 -0
  20. package/src/core/errors/crypto-error.js +15 -0
  21. package/src/core/errors/crypto-error.js.map +1 -0
  22. package/src/core/{index.ts → index.d.ts} +1 -0
  23. package/src/core/index.d.ts.map +1 -0
  24. package/src/core/index.js +6 -0
  25. package/src/core/index.js.map +1 -0
  26. package/src/core/types/result.d.ts +8 -0
  27. package/src/core/types/result.d.ts.map +1 -0
  28. package/src/core/types/result.js +3 -0
  29. package/src/core/types/result.js.map +1 -0
  30. package/src/enumerations/index.d.ts +2 -0
  31. package/src/enumerations/index.d.ts.map +1 -0
  32. package/src/enumerations/index.js +5 -0
  33. package/src/enumerations/index.js.map +1 -0
  34. package/src/enumerations/pbkdf2-profile.d.ts +9 -0
  35. package/src/enumerations/pbkdf2-profile.d.ts.map +1 -0
  36. package/src/enumerations/pbkdf2-profile.js +13 -0
  37. package/src/enumerations/pbkdf2-profile.js.map +1 -0
  38. package/src/i18n/ecies-i18n-factory.d.ts +28 -0
  39. package/src/i18n/ecies-i18n-factory.d.ts.map +1 -0
  40. package/src/i18n/ecies-i18n-factory.js +89 -0
  41. package/src/i18n/ecies-i18n-factory.js.map +1 -0
  42. package/src/i18n/{index.ts → index.d.ts} +1 -3
  43. package/src/i18n/index.d.ts.map +1 -0
  44. package/src/i18n/index.js +8 -0
  45. package/src/i18n/index.js.map +1 -0
  46. package/src/i18n/node-ecies-i18n-setup.d.ts +5 -0
  47. package/src/i18n/node-ecies-i18n-setup.d.ts.map +1 -0
  48. package/src/i18n/node-ecies-i18n-setup.js +46 -0
  49. package/src/i18n/node-ecies-i18n-setup.js.map +1 -0
  50. package/src/i18n/node-keys.d.ts +57 -0
  51. package/src/i18n/node-keys.d.ts.map +1 -0
  52. package/src/i18n/node-keys.js +67 -0
  53. package/src/i18n/node-keys.js.map +1 -0
  54. package/src/i18n/translations/de.d.ts +3 -0
  55. package/src/i18n/translations/de.d.ts.map +1 -0
  56. package/src/i18n/translations/de.js +57 -0
  57. package/src/i18n/translations/de.js.map +1 -0
  58. package/src/i18n/translations/en-GB.d.ts +3 -0
  59. package/src/i18n/translations/en-GB.d.ts.map +1 -0
  60. package/src/i18n/translations/en-GB.js +61 -0
  61. package/src/i18n/translations/en-GB.js.map +1 -0
  62. package/src/i18n/translations/en-US.d.ts +6 -0
  63. package/src/i18n/translations/en-US.d.ts.map +1 -0
  64. package/src/i18n/translations/en-US.js +65 -0
  65. package/src/i18n/translations/en-US.js.map +1 -0
  66. package/src/i18n/translations/es.d.ts +3 -0
  67. package/src/i18n/translations/es.d.ts.map +1 -0
  68. package/src/i18n/translations/es.js +57 -0
  69. package/src/i18n/translations/es.js.map +1 -0
  70. package/src/i18n/translations/fr.d.ts +3 -0
  71. package/src/i18n/translations/fr.d.ts.map +1 -0
  72. package/src/i18n/translations/fr.js +57 -0
  73. package/src/i18n/translations/fr.js.map +1 -0
  74. package/src/i18n/translations/{index.ts → index.d.ts} +1 -0
  75. package/src/i18n/translations/index.d.ts.map +1 -0
  76. package/src/i18n/translations/index.js +20 -0
  77. package/src/i18n/translations/index.js.map +1 -0
  78. package/src/i18n/translations/ja.d.ts +3 -0
  79. package/src/i18n/translations/ja.d.ts.map +1 -0
  80. package/src/i18n/translations/ja.js +57 -0
  81. package/src/i18n/translations/ja.js.map +1 -0
  82. package/src/i18n/translations/uk.d.ts +3 -0
  83. package/src/i18n/translations/uk.d.ts.map +1 -0
  84. package/src/i18n/translations/uk.js +57 -0
  85. package/src/i18n/translations/uk.js.map +1 -0
  86. package/src/i18n/translations/zh-cn.d.ts +3 -0
  87. package/src/i18n/translations/zh-cn.d.ts.map +1 -0
  88. package/src/i18n/translations/zh-cn.js +57 -0
  89. package/src/i18n/translations/zh-cn.js.map +1 -0
  90. package/src/{index.ts → index.d.ts} +1 -5
  91. package/src/index.d.ts.map +1 -0
  92. package/src/index.js +31 -0
  93. package/src/index.js.map +1 -0
  94. package/src/interfaces/authenticated-cipher.d.ts +12 -0
  95. package/src/interfaces/authenticated-cipher.d.ts.map +1 -0
  96. package/src/interfaces/authenticated-cipher.js +3 -0
  97. package/src/interfaces/authenticated-cipher.js.map +1 -0
  98. package/src/interfaces/authenticated-decipher.d.ts +11 -0
  99. package/src/interfaces/authenticated-decipher.d.ts.map +1 -0
  100. package/src/interfaces/authenticated-decipher.js +3 -0
  101. package/src/interfaces/authenticated-decipher.js.map +1 -0
  102. package/src/interfaces/backend-member-operational.d.ts +48 -0
  103. package/src/interfaces/backend-member-operational.d.ts.map +1 -0
  104. package/src/interfaces/backend-member-operational.js +3 -0
  105. package/src/interfaces/backend-member-operational.js.map +1 -0
  106. package/src/interfaces/checksum-config.d.ts +5 -0
  107. package/src/interfaces/checksum-config.d.ts.map +1 -0
  108. package/src/interfaces/checksum-config.js +3 -0
  109. package/src/interfaces/checksum-config.js.map +1 -0
  110. package/src/interfaces/checksum-consts.d.ts +11 -0
  111. package/src/interfaces/checksum-consts.d.ts.map +1 -0
  112. package/src/interfaces/checksum-consts.js +3 -0
  113. package/src/interfaces/checksum-consts.js.map +1 -0
  114. package/src/interfaces/constants.d.ts +52 -0
  115. package/src/interfaces/constants.d.ts.map +1 -0
  116. package/src/interfaces/constants.js +3 -0
  117. package/src/interfaces/constants.js.map +1 -0
  118. package/src/interfaces/ecies-consts.d.ts +88 -0
  119. package/src/interfaces/ecies-consts.d.ts.map +1 -0
  120. package/src/interfaces/ecies-consts.js +3 -0
  121. package/src/interfaces/ecies-consts.js.map +1 -0
  122. package/src/interfaces/encrypted-chunk.d.ts +12 -0
  123. package/src/interfaces/encrypted-chunk.d.ts.map +1 -0
  124. package/src/interfaces/encrypted-chunk.js +3 -0
  125. package/src/interfaces/encrypted-chunk.js.map +1 -0
  126. package/src/interfaces/encryption-consts.d.ts +11 -0
  127. package/src/interfaces/encryption-consts.d.ts.map +1 -0
  128. package/src/interfaces/encryption-consts.js +3 -0
  129. package/src/interfaces/encryption-consts.js.map +1 -0
  130. package/src/interfaces/{index.ts → index.d.ts} +1 -0
  131. package/src/interfaces/index.d.ts.map +1 -0
  132. package/src/interfaces/index.js +30 -0
  133. package/src/interfaces/index.js.map +1 -0
  134. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts +6 -0
  135. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts.map +1 -0
  136. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.js +3 -0
  137. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.js.map +1 -0
  138. package/src/interfaces/keyring-consts.d.ts +6 -0
  139. package/src/interfaces/keyring-consts.d.ts.map +1 -0
  140. package/src/interfaces/keyring-consts.js +3 -0
  141. package/src/interfaces/keyring-consts.js.map +1 -0
  142. package/src/interfaces/{member-with-mnemonic.ts → member-with-mnemonic.d.ts} +3 -3
  143. package/src/interfaces/member-with-mnemonic.d.ts.map +1 -0
  144. package/src/interfaces/member-with-mnemonic.js +3 -0
  145. package/src/interfaces/member-with-mnemonic.js.map +1 -0
  146. package/src/interfaces/member.d.ts +47 -0
  147. package/src/interfaces/member.d.ts.map +1 -0
  148. package/src/interfaces/member.js +3 -0
  149. package/src/interfaces/member.js.map +1 -0
  150. package/src/interfaces/{multi-encrypted-message.ts → multi-encrypted-message.d.ts} +5 -5
  151. package/src/interfaces/multi-encrypted-message.d.ts.map +1 -0
  152. package/src/interfaces/multi-encrypted-message.js +3 -0
  153. package/src/interfaces/multi-encrypted-message.js.map +1 -0
  154. package/src/interfaces/multi-encrypted-parsed-header.d.ts +27 -0
  155. package/src/interfaces/multi-encrypted-parsed-header.d.ts.map +1 -0
  156. package/src/interfaces/multi-encrypted-parsed-header.js +3 -0
  157. package/src/interfaces/multi-encrypted-parsed-header.js.map +1 -0
  158. package/src/interfaces/multi-recipient-chunk.d.ts +26 -0
  159. package/src/interfaces/multi-recipient-chunk.d.ts.map +1 -0
  160. package/src/interfaces/multi-recipient-chunk.js +13 -0
  161. package/src/interfaces/multi-recipient-chunk.js.map +1 -0
  162. package/src/interfaces/{pbkdf-profiles.ts → pbkdf-profiles.d.ts} +2 -2
  163. package/src/interfaces/pbkdf-profiles.d.ts.map +1 -0
  164. package/src/interfaces/pbkdf-profiles.js +3 -0
  165. package/src/interfaces/pbkdf-profiles.js.map +1 -0
  166. package/src/interfaces/pbkdf2-result.d.ts +6 -0
  167. package/src/interfaces/pbkdf2-result.d.ts.map +1 -0
  168. package/src/interfaces/pbkdf2-result.js +3 -0
  169. package/src/interfaces/pbkdf2-result.js.map +1 -0
  170. package/src/interfaces/signing-key-private-key-info.d.ts +11 -0
  171. package/src/interfaces/signing-key-private-key-info.d.ts.map +1 -0
  172. package/src/interfaces/signing-key-private-key-info.js +3 -0
  173. package/src/interfaces/signing-key-private-key-info.js.map +1 -0
  174. package/src/interfaces/{simple-keypair-buffer.ts → simple-keypair-buffer.d.ts} +3 -3
  175. package/src/interfaces/simple-keypair-buffer.d.ts.map +1 -0
  176. package/src/interfaces/simple-keypair-buffer.js +3 -0
  177. package/src/interfaces/simple-keypair-buffer.js.map +1 -0
  178. package/src/interfaces/{simple-keypair.ts → simple-keypair.d.ts} +3 -3
  179. package/src/interfaces/simple-keypair.d.ts.map +1 -0
  180. package/src/interfaces/simple-keypair.js +3 -0
  181. package/src/interfaces/simple-keypair.js.map +1 -0
  182. package/src/interfaces/simple-public-key-only-buffer.d.ts +4 -0
  183. package/src/interfaces/simple-public-key-only-buffer.d.ts.map +1 -0
  184. package/src/interfaces/simple-public-key-only-buffer.js +3 -0
  185. package/src/interfaces/simple-public-key-only-buffer.js.map +1 -0
  186. package/src/interfaces/simple-public-key-only.d.ts +4 -0
  187. package/src/interfaces/simple-public-key-only.d.ts.map +1 -0
  188. package/src/interfaces/simple-public-key-only.js +3 -0
  189. package/src/interfaces/simple-public-key-only.js.map +1 -0
  190. package/src/interfaces/single-encrypted-parsed-header.d.ts +35 -0
  191. package/src/interfaces/single-encrypted-parsed-header.d.ts.map +1 -0
  192. package/src/interfaces/single-encrypted-parsed-header.js +3 -0
  193. package/src/interfaces/single-encrypted-parsed-header.js.map +1 -0
  194. package/src/interfaces/stream-config.d.ts +6 -0
  195. package/src/interfaces/stream-config.d.ts.map +1 -0
  196. package/src/interfaces/stream-config.js +8 -0
  197. package/src/interfaces/stream-config.js.map +1 -0
  198. package/src/interfaces/stream-progress.d.ts +8 -0
  199. package/src/interfaces/stream-progress.d.ts.map +1 -0
  200. package/src/interfaces/stream-progress.js +3 -0
  201. package/src/interfaces/stream-progress.js.map +1 -0
  202. package/src/interfaces/{wallet-seed.ts → wallet-seed.d.ts} +3 -3
  203. package/src/interfaces/wallet-seed.d.ts.map +1 -0
  204. package/src/interfaces/wallet-seed.js +3 -0
  205. package/src/interfaces/wallet-seed.js.map +1 -0
  206. package/src/interfaces/wrapped-key-consts.d.ts +7 -0
  207. package/src/interfaces/wrapped-key-consts.d.ts.map +1 -0
  208. package/src/interfaces/wrapped-key-consts.js +3 -0
  209. package/src/interfaces/wrapped-key-consts.js.map +1 -0
  210. package/src/lib/crypto-container.d.ts +13 -0
  211. package/src/lib/crypto-container.d.ts.map +1 -0
  212. package/src/lib/crypto-container.js +29 -0
  213. package/src/lib/crypto-container.js.map +1 -0
  214. package/src/lib/{index.ts → index.d.ts} +1 -0
  215. package/src/lib/index.d.ts.map +1 -0
  216. package/src/lib/index.js +7 -0
  217. package/src/lib/index.js.map +1 -0
  218. package/src/lib/invariant-validator.d.ts +62 -0
  219. package/src/lib/invariant-validator.d.ts.map +1 -0
  220. package/src/lib/invariant-validator.js +108 -0
  221. package/src/lib/invariant-validator.js.map +1 -0
  222. package/src/lib/invariants/{index.ts → index.d.ts} +2 -2
  223. package/src/lib/invariants/index.d.ts.map +1 -0
  224. package/src/lib/invariants/index.js +12 -0
  225. package/src/lib/invariants/index.js.map +1 -0
  226. package/src/lib/invariants/recipient-id-consistency.d.ts +22 -0
  227. package/src/lib/invariants/recipient-id-consistency.d.ts.map +1 -0
  228. package/src/lib/invariants/recipient-id-consistency.js +62 -0
  229. package/src/lib/invariants/recipient-id-consistency.js.map +1 -0
  230. package/src/member.d.ts +81 -0
  231. package/src/member.d.ts.map +1 -0
  232. package/src/member.js +285 -0
  233. package/src/member.js.map +1 -0
  234. package/src/services/aes-gcm.d.ts +66 -0
  235. package/src/services/aes-gcm.d.ts.map +1 -0
  236. package/src/services/aes-gcm.js +158 -0
  237. package/src/services/aes-gcm.js.map +1 -0
  238. package/src/services/chunk-processor.d.ts +15 -0
  239. package/src/services/chunk-processor.d.ts.map +1 -0
  240. package/src/services/chunk-processor.js +36 -0
  241. package/src/services/chunk-processor.js.map +1 -0
  242. package/src/services/ecies/crypto-core.d.ts +104 -0
  243. package/src/services/ecies/crypto-core.d.ts.map +1 -0
  244. package/src/services/ecies/crypto-core.js +237 -0
  245. package/src/services/ecies/crypto-core.js.map +1 -0
  246. package/src/services/ecies/file.d.ts +30 -0
  247. package/src/services/ecies/file.d.ts.map +1 -0
  248. package/src/services/ecies/file.js +112 -0
  249. package/src/services/ecies/file.js.map +1 -0
  250. package/src/services/ecies/{index.ts → index.d.ts} +1 -0
  251. package/src/services/ecies/index.d.ts.map +1 -0
  252. package/src/services/ecies/index.js +11 -0
  253. package/src/services/ecies/index.js.map +1 -0
  254. package/src/services/ecies/multi-recipient.d.ts +84 -0
  255. package/src/services/ecies/multi-recipient.d.ts.map +1 -0
  256. package/src/services/ecies/multi-recipient.js +496 -0
  257. package/src/services/ecies/multi-recipient.js.map +1 -0
  258. package/src/services/ecies/service.d.ts +69 -0
  259. package/src/services/ecies/service.d.ts.map +1 -0
  260. package/src/services/ecies/service.js +144 -0
  261. package/src/services/ecies/service.js.map +1 -0
  262. package/src/services/ecies/signature.d.ts +38 -0
  263. package/src/services/ecies/signature.d.ts.map +1 -0
  264. package/src/services/ecies/signature.js +69 -0
  265. package/src/services/ecies/signature.js.map +1 -0
  266. package/src/services/ecies/single-recipient.d.ts +83 -0
  267. package/src/services/ecies/single-recipient.d.ts.map +1 -0
  268. package/src/services/ecies/single-recipient.js +447 -0
  269. package/src/services/ecies/single-recipient.js.map +1 -0
  270. package/src/services/ecies/utilities.d.ts +33 -0
  271. package/src/services/ecies/utilities.d.ts.map +1 -0
  272. package/src/services/ecies/utilities.js +91 -0
  273. package/src/services/ecies/utilities.js.map +1 -0
  274. package/src/services/encryption-stream.d.ts +33 -0
  275. package/src/services/encryption-stream.d.ts.map +1 -0
  276. package/src/services/encryption-stream.js +207 -0
  277. package/src/services/encryption-stream.js.map +1 -0
  278. package/src/services/{index.ts → index.d.ts} +1 -0
  279. package/src/services/index.d.ts.map +1 -0
  280. package/src/services/index.js +11 -0
  281. package/src/services/index.js.map +1 -0
  282. package/src/services/multi-recipient-processor.d.ts +72 -0
  283. package/src/services/multi-recipient-processor.d.ts.map +1 -0
  284. package/src/services/multi-recipient-processor.js +322 -0
  285. package/src/services/multi-recipient-processor.js.map +1 -0
  286. package/src/services/pbkdf2.d.ts +105 -0
  287. package/src/services/pbkdf2.d.ts.map +1 -0
  288. package/src/services/pbkdf2.js +189 -0
  289. package/src/services/pbkdf2.js.map +1 -0
  290. package/src/services/progress-tracker.d.ts +9 -0
  291. package/src/services/progress-tracker.d.ts.map +1 -0
  292. package/src/services/progress-tracker.js +41 -0
  293. package/src/services/progress-tracker.js.map +1 -0
  294. package/src/test-mocks/index.d.ts +2 -0
  295. package/src/test-mocks/index.d.ts.map +1 -0
  296. package/src/test-mocks/index.js +5 -0
  297. package/src/test-mocks/index.js.map +1 -0
  298. package/src/test-mocks/mock-backend-member.d.ts +71 -0
  299. package/src/test-mocks/mock-backend-member.d.ts.map +1 -0
  300. package/src/test-mocks/mock-backend-member.js +133 -0
  301. package/src/test-mocks/mock-backend-member.js.map +1 -0
  302. package/src/testing.d.ts +2 -0
  303. package/src/testing.d.ts.map +1 -0
  304. package/src/testing.js +6 -0
  305. package/src/testing.js.map +1 -0
  306. package/src/types/id-guards.d.ts +39 -0
  307. package/src/types/id-guards.d.ts.map +1 -0
  308. package/src/types/id-guards.js +91 -0
  309. package/src/types/id-guards.js.map +1 -0
  310. package/src/types/index.d.ts +2 -0
  311. package/src/types/index.d.ts.map +1 -0
  312. package/src/types/index.js +5 -0
  313. package/src/types/index.js.map +1 -0
  314. package/src/{types.ts → types.d.ts} +9 -28
  315. package/src/types.d.ts.map +1 -0
  316. package/src/types.js +6 -0
  317. package/src/types.js.map +1 -0
  318. package/src/utils.d.ts +11 -0
  319. package/src/utils.d.ts.map +1 -0
  320. package/src/utils.js +82 -0
  321. package/src/utils.js.map +1 -0
  322. package/LICENSE +0 -21
  323. package/src/builders/ecies-builder.ts +0 -27
  324. package/src/builders/member-builder.ts +0 -158
  325. package/src/constants.ts +0 -251
  326. package/src/core/errors/crypto-error.ts +0 -10
  327. package/src/core/types/result.ts +0 -3
  328. package/src/enumerations/index.ts +0 -2
  329. package/src/enumerations/pbkdf2-profile.ts +0 -8
  330. package/src/i18n/ecies-i18n-factory.ts +0 -111
  331. package/src/i18n/node-ecies-i18n-setup.ts +0 -56
  332. package/src/i18n/node-keys.ts +0 -69
  333. package/src/i18n/translations/de.ts +0 -54
  334. package/src/i18n/translations/en-GB.ts +0 -83
  335. package/src/i18n/translations/en-US.ts +0 -88
  336. package/src/i18n/translations/es.ts +0 -54
  337. package/src/i18n/translations/fr.ts +0 -54
  338. package/src/i18n/translations/ja.ts +0 -54
  339. package/src/i18n/translations/uk.ts +0 -54
  340. package/src/i18n/translations/zh-cn.ts +0 -54
  341. package/src/interfaces/authenticated-cipher.ts +0 -10
  342. package/src/interfaces/authenticated-decipher.ts +0 -9
  343. package/src/interfaces/backend-member-operational.ts +0 -75
  344. package/src/interfaces/checksum-config.ts +0 -4
  345. package/src/interfaces/checksum-consts.ts +0 -13
  346. package/src/interfaces/constants.ts +0 -54
  347. package/src/interfaces/ecies-consts.ts +0 -99
  348. package/src/interfaces/encrypted-chunk.ts +0 -12
  349. package/src/interfaces/encryption-consts.ts +0 -10
  350. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.ts +0 -7
  351. package/src/interfaces/keyring-consts.ts +0 -5
  352. package/src/interfaces/member.ts +0 -76
  353. package/src/interfaces/multi-encrypted-parsed-header.ts +0 -28
  354. package/src/interfaces/multi-recipient-chunk.ts +0 -35
  355. package/src/interfaces/pbkdf2-result.ts +0 -5
  356. package/src/interfaces/signing-key-private-key-info.ts +0 -12
  357. package/src/interfaces/simple-public-key-only-buffer.ts +0 -3
  358. package/src/interfaces/simple-public-key-only.ts +0 -3
  359. package/src/interfaces/single-encrypted-parsed-header.ts +0 -35
  360. package/src/interfaces/stream-config.ts +0 -9
  361. package/src/interfaces/stream-progress.ts +0 -7
  362. package/src/interfaces/wrapped-key-consts.ts +0 -6
  363. package/src/lib/crypto-container.ts +0 -32
  364. package/src/lib/invariant-validator.ts +0 -124
  365. package/src/lib/invariants/recipient-id-consistency.ts +0 -77
  366. package/src/member.ts +0 -511
  367. package/src/services/aes-gcm.ts +0 -260
  368. package/src/services/chunk-processor.ts +0 -47
  369. package/src/services/ecies/crypto-core.ts +0 -319
  370. package/src/services/ecies/file.ts +0 -171
  371. package/src/services/ecies/multi-recipient.ts +0 -782
  372. package/src/services/ecies/service.ts +0 -316
  373. package/src/services/ecies/signature.ts +0 -91
  374. package/src/services/ecies/single-recipient.ts +0 -743
  375. package/src/services/ecies/utilities.ts +0 -128
  376. package/src/services/encryption-stream.ts +0 -432
  377. package/src/services/multi-recipient-processor.ts +0 -505
  378. package/src/services/pbkdf2.ts +0 -304
  379. package/src/services/progress-tracker.ts +0 -43
  380. package/src/test-mocks/index.ts +0 -1
  381. package/src/test-mocks/mock-backend-member.ts +0 -195
  382. package/src/testing.ts +0 -2
  383. package/src/types/id-guards.ts +0 -91
  384. package/src/types/index.ts +0 -1
  385. package/src/utils.ts +0 -124
@@ -0,0 +1,447 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EciesSingleRecipientCore = void 0;
4
+ const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
5
+ const crypto_1 = require("crypto");
6
+ const ecies_i18n_factory_1 = require("../../i18n/ecies-i18n-factory");
7
+ const crypto_core_1 = require("./crypto-core");
8
+ class EciesSingleRecipientCore {
9
+ cryptoCore;
10
+ config;
11
+ constructor(config) {
12
+ this.config = config;
13
+ this.cryptoCore = new crypto_core_1.EciesCryptoCore(config);
14
+ }
15
+ /**
16
+ * Get the size of the header for a given encryption type
17
+ * @param encryptionType The encryption type (single, simple, etc.)
18
+ * @returns
19
+ */
20
+ getHeaderSize(encryptionType) {
21
+ switch (encryptionType) {
22
+ case 'simple':
23
+ return this.cryptoCore.consts.SIMPLE.FIXED_OVERHEAD_SIZE;
24
+ case 'single':
25
+ return this.cryptoCore.consts.SINGLE.FIXED_OVERHEAD_SIZE;
26
+ default:
27
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptionType);
28
+ }
29
+ }
30
+ /**
31
+ * Encrypt a message with a public key
32
+ * @param encryptSimple Whether to simple encrypt (without crc, length)
33
+ * @param receiverPublicKey The public key of the receiver
34
+ * @param message The message to encrypt
35
+ * @param preamble Optional preamble to prepend to the encrypted message
36
+ * @param options Optional encryption options
37
+ * @param options.recipientCount The number of recipients for multiple encryption mode
38
+ * @returns The encrypted message
39
+ */
40
+ encrypt(encryptSimple, receiverPublicKey, message, preamble = Buffer.alloc(0)) {
41
+ // Security fix 4: Message size validation
42
+ if (message.length === 0) {
43
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.CannotEncryptEmptyData);
44
+ }
45
+ if (message.length > 0x7fffffff) {
46
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.MessageTooLarge);
47
+ }
48
+ const encryptionType = encryptSimple
49
+ ? 'simple'
50
+ : 'single';
51
+ const encryptionTypeBuffer = Buffer.alloc(1);
52
+ encryptionTypeBuffer.writeUint8(ecies_lib_1.EciesEncryptionTypeMap[encryptionType]);
53
+ const versionBuffer = Buffer.alloc(1);
54
+ versionBuffer.writeUint8(ecies_lib_1.EciesVersionEnum.V1);
55
+ const cipherSuiteBuffer = Buffer.alloc(1);
56
+ cipherSuiteBuffer.writeUint8(ecies_lib_1.EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256);
57
+ if (message.length > this.cryptoCore.consts.MAX_RAW_DATA_SIZE) {
58
+ const pluginEngine = (0, ecies_i18n_factory_1.getEciesPluginI18nEngine)();
59
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength, undefined, undefined, {
60
+ error: pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_MessageLengthExceedsMaximumAllowedSize),
61
+ maxLength: String(ecies_lib_1.UINT32_MAX),
62
+ messageLength: String(message.length),
63
+ });
64
+ }
65
+ // Generate ephemeral ECDH key pair
66
+ // Use cryptoCore to generate keys to ensure compatibility with computeSharedSecret
67
+ const ephemeralPrivateKey = this.cryptoCore.generatePrivateKey();
68
+ let ephemeralPublicKey = this.cryptoCore.getPublicKey(ephemeralPrivateKey);
69
+ // Compute shared secret
70
+ let sharedSecret;
71
+ try {
72
+ // Make sure we normalize the receiver's public key
73
+ const normalizedReceiverPublicKey = this.cryptoCore.normalizePublicKey(receiverPublicKey);
74
+ // Use cryptoCore to compute shared secret (handles compressed keys better)
75
+ sharedSecret = this.cryptoCore.computeSharedSecret(ephemeralPrivateKey, normalizedReceiverPublicKey);
76
+ }
77
+ catch (error) {
78
+ if (process.env.NODE_ENV !== 'test') {
79
+ console.error('[ERROR][encrypt] Failed to compute shared secret:', error);
80
+ }
81
+ if (error instanceof Error) {
82
+ if ('code' in error &&
83
+ error.code === 'ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY') {
84
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidRecipientPublicKey, undefined, undefined, {
85
+ nodeError: error.code,
86
+ });
87
+ }
88
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.SecretComputationFailed, undefined, undefined, {
89
+ error: error.message,
90
+ });
91
+ }
92
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.SecretComputationFailed);
93
+ }
94
+ // Get the ephemeral public key and ensure it has the 0x04 prefix
95
+ // ephemeralPublicKey is already set above and is compressed.
96
+ // Generate random IV
97
+ const iv = (0, crypto_1.randomBytes)(this.cryptoCore.consts.IV_SIZE);
98
+ // Use HKDF to derive the key
99
+ const symKey = this.cryptoCore.deriveSharedKey(sharedSecret, Buffer.alloc(0), // No salt
100
+ Buffer.from('ecies-v2-key-derivation'), // Info
101
+ this.cryptoCore.consts.SYMMETRIC.KEY_SIZE);
102
+ // Create cipher with the derived symmetric key
103
+ const cipher = (0, crypto_1.createCipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symKey, iv);
104
+ // Ensure auto padding is enabled
105
+ cipher.setAutoPadding(true);
106
+ // Construct AAD
107
+ // AAD = Preamble + Version + CipherSuite + EncryptionType + EphemeralPublicKey
108
+ // We don't include IV in AAD as it's already authenticated by GCM mechanism
109
+ // We don't include Length in AAD because it's variable/optional and might complicate things?
110
+ // Actually, let's include what we can.
111
+ // For now, let's stick to the metadata that identifies the context.
112
+ const aad = Buffer.concat([
113
+ preamble,
114
+ versionBuffer,
115
+ cipherSuiteBuffer,
116
+ encryptionTypeBuffer,
117
+ ephemeralPublicKey,
118
+ ]);
119
+ cipher.setAAD(aad);
120
+ // Encrypt the message
121
+ let encrypted = cipher.update(message);
122
+ encrypted = Buffer.concat([encrypted, cipher.final()]);
123
+ // Get and explicitly set the authentication tag to max tag length for consistency
124
+ const authTag = cipher.getAuthTag();
125
+ // Add a length prefix to the encrypted data to ensure we can extract the exact number of bytes during decryption
126
+ const lengthBuffer = encryptionType === 'simple' ? Buffer.alloc(0) : Buffer.alloc(ecies_lib_1.UINT64_SIZE);
127
+ if (encryptionType === 'single') {
128
+ lengthBuffer.writeBigUInt64BE(BigInt(encrypted.length));
129
+ }
130
+ // Security fix 5: Encrypted size validation
131
+ const maxExpectedSize = message.length + 1024;
132
+ if (encrypted.length > maxExpectedSize) {
133
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.EncryptedSizeExceedsExpected);
134
+ }
135
+ // Format: [optional preamble] | version (1) | cipherSuite (1) | type (1) | ephemeralPublicKey (65) | iv (16) | authTag (16) | length (8) | encryptedData
136
+ return Buffer.concat([
137
+ preamble,
138
+ versionBuffer,
139
+ cipherSuiteBuffer,
140
+ encryptionTypeBuffer,
141
+ ephemeralPublicKey,
142
+ iv,
143
+ authTag,
144
+ lengthBuffer,
145
+ encrypted,
146
+ ]);
147
+ }
148
+ /**
149
+ * Parse the header from encrypted data
150
+ * @param encryptionType The type of encryption (single, simple, etc.) or undefined if not known
151
+ * @param data The encrypted data
152
+ * @param preambleSize The size of the preamble, if any
153
+ * @param options Optional parsing options
154
+ * @param options.dataLength The expected length of the data
155
+ * @returns The parsed header components
156
+ */
157
+ parseEncryptedMessage(encryptionType, data, preambleSize = 0, options) {
158
+ let offset = 0;
159
+ const preamble = data.subarray(0, preambleSize);
160
+ offset += preambleSize;
161
+ // Read Version
162
+ const version = data.readUInt8(offset);
163
+ offset += this.cryptoCore.consts.VERSION_SIZE;
164
+ if (version !== ecies_lib_1.EciesVersionEnum.V1) {
165
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidVersionTemplate, undefined, undefined, { version: String(version) });
166
+ }
167
+ // Read CipherSuite
168
+ const cipherSuite = data.readUInt8(offset);
169
+ offset += this.cryptoCore.consts.CIPHER_SUITE_SIZE;
170
+ if (cipherSuite !== ecies_lib_1.EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256) {
171
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidCipherSuiteTemplate, undefined, undefined, { cipherSuite: String(cipherSuite) });
172
+ }
173
+ // read the encryption type from the first byte after the preamble and version/suite
174
+ const actualEncryptionTypeEnum = (0, ecies_lib_1.ensureEciesEncryptionTypeEnum)(data.readUInt8(offset));
175
+ // if a type is provided, ensure it matches the actual type
176
+ if (encryptionType !== undefined &&
177
+ actualEncryptionTypeEnum !== encryptionType) {
178
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptionType, undefined, undefined, {
179
+ expected: (0, ecies_lib_1.encryptionTypeToString)(encryptionType),
180
+ actual: (0, ecies_lib_1.encryptionTypeToString)(actualEncryptionTypeEnum),
181
+ });
182
+ }
183
+ if (actualEncryptionTypeEnum === ecies_lib_1.EciesEncryptionTypeEnum.Multiple) {
184
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptionType, undefined, undefined, {
185
+ expected: 'single or simple',
186
+ actual: (0, ecies_lib_1.encryptionTypeToString)(actualEncryptionTypeEnum),
187
+ });
188
+ }
189
+ const includeLengthAndCrc = actualEncryptionTypeEnum === ecies_lib_1.EciesEncryptionTypeEnum.Single;
190
+ // Security fix 6: Minimum encrypted data size
191
+ const minSize = includeLengthAndCrc
192
+ ? this.cryptoCore.consts.SINGLE.FIXED_OVERHEAD_SIZE
193
+ : this.cryptoCore.consts.SIMPLE.FIXED_OVERHEAD_SIZE;
194
+ if (data.length < minSize) {
195
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedDataLength);
196
+ }
197
+ // skip the already-read encryption type
198
+ offset += 1;
199
+ // Extract components from the header
200
+ const ephemeralPublicKey = data.subarray(offset, offset + this.cryptoCore.consts.PUBLIC_KEY_LENGTH);
201
+ offset += this.cryptoCore.consts.PUBLIC_KEY_LENGTH;
202
+ // Make sure we normalize the ephemeral public key
203
+ const normalizedKey = this.cryptoCore.normalizePublicKey(ephemeralPublicKey);
204
+ const iv = data.subarray(offset, offset + this.cryptoCore.consts.IV_SIZE);
205
+ offset += this.cryptoCore.consts.IV_SIZE;
206
+ const authTag = data.subarray(offset, offset + this.cryptoCore.consts.AUTH_TAG_SIZE);
207
+ offset += this.cryptoCore.consts.AUTH_TAG_SIZE;
208
+ // Extract the length prefix (4 bytes) after the header components
209
+ const dataLengthBuffer = includeLengthAndCrc
210
+ ? data.subarray(offset, offset + this.cryptoCore.consts.SINGLE.DATA_LENGTH_SIZE)
211
+ : Buffer.alloc(0);
212
+ if (includeLengthAndCrc) {
213
+ offset += this.cryptoCore.consts.SINGLE.DATA_LENGTH_SIZE;
214
+ }
215
+ const dataLength = includeLengthAndCrc
216
+ ? Number(dataLengthBuffer.readBigUInt64BE(0))
217
+ : options?.dataLength ?? -1;
218
+ if (includeLengthAndCrc &&
219
+ options?.dataLength !== undefined &&
220
+ dataLength !== options.dataLength) {
221
+ const pluginEngine = (0, ecies_i18n_factory_1.getEciesPluginI18nEngine)();
222
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedDataLength, undefined, undefined, {
223
+ error: pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_EncryptedDataLengthMismatch),
224
+ expected: String(dataLength),
225
+ actual: String(options.dataLength),
226
+ });
227
+ }
228
+ // No CRC in Single encryption (AES-GCM provides authentication)
229
+ const encryptedData = dataLength > 0
230
+ ? data.subarray(offset, offset + dataLength)
231
+ : data.subarray(offset);
232
+ if (includeLengthAndCrc) {
233
+ offset += dataLength;
234
+ }
235
+ if (includeLengthAndCrc && encryptedData.length !== dataLength) {
236
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedDataLength, undefined, undefined, {
237
+ expected: String(dataLength),
238
+ actual: String(encryptedData.length),
239
+ });
240
+ }
241
+ const remainder = includeLengthAndCrc
242
+ ? data.subarray(offset)
243
+ : Buffer.alloc(0);
244
+ // No CRC validation needed (AES-GCM provides authentication)
245
+ // Security fix 7: Component extraction validation
246
+ if (normalizedKey.length !== this.cryptoCore.consts.PUBLIC_KEY_LENGTH) {
247
+ const pluginEngine = (0, ecies_i18n_factory_1.getEciesPluginI18nEngine)();
248
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEphemeralPublicKey, undefined, undefined, {
249
+ error: pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_EphemeralPublicKeyLengthMismatch),
250
+ expected: String(this.cryptoCore.consts.PUBLIC_KEY_LENGTH),
251
+ actual: String(normalizedKey.length),
252
+ });
253
+ }
254
+ if (iv.length !== this.cryptoCore.consts.IV_SIZE) {
255
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidIVLength, undefined, undefined, {
256
+ expected: String(this.cryptoCore.consts.IV_SIZE),
257
+ actual: String(iv.length),
258
+ });
259
+ }
260
+ if (authTag.length !== this.cryptoCore.consts.AUTH_TAG_SIZE) {
261
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidAuthTagLength, undefined, undefined, {
262
+ expected: String(this.cryptoCore.consts.AUTH_TAG_SIZE),
263
+ actual: String(authTag.length),
264
+ });
265
+ }
266
+ return {
267
+ header: {
268
+ preamble,
269
+ encryptionType: actualEncryptionTypeEnum,
270
+ ephemeralPublicKey: normalizedKey,
271
+ iv,
272
+ authTag,
273
+ dataLength,
274
+ headerSize: includeLengthAndCrc
275
+ ? this.cryptoCore.consts.SINGLE.FIXED_OVERHEAD_SIZE
276
+ : this.cryptoCore.consts.SIMPLE.FIXED_OVERHEAD_SIZE,
277
+ },
278
+ data: encryptedData,
279
+ remainder,
280
+ };
281
+ }
282
+ /**
283
+ * Decrypts data encrypted with ECIES using a header
284
+ * This method maintains backward compatibility with the original implementation
285
+ * by returning just the Buffer. For detailed information, use decryptSingleWithHeaderEx
286
+ * @param encryptionType The type of encryption (single, simple, etc.)
287
+ * @param privateKey The private key to decrypt the data
288
+ * @param encryptedData The data to decrypt
289
+ * @param preambleSize The size of the preamble, if any
290
+ * @param options Optional decryption options
291
+ * @param options.dataLength The expected length of the data
292
+ * @returns The decrypted data buffer
293
+ */
294
+ decryptWithHeader(encryptionType, privateKey, encryptedData, preambleSize = 0, options) {
295
+ try {
296
+ // Call the extended version and return only the decrypted buffer for backward compatibility
297
+ const result = this.decryptWithHeaderEx(encryptionType, privateKey, encryptedData, preambleSize, options);
298
+ return result.decrypted;
299
+ }
300
+ catch (error) {
301
+ if (error instanceof ecies_lib_1.ECIESError) {
302
+ throw error;
303
+ }
304
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
305
+ error: error instanceof Error ? error.message : String(error),
306
+ });
307
+ }
308
+ }
309
+ /**
310
+ * Extended version of decryptSingleWithHeader that provides more detailed information
311
+ * @param encryptionType The type of encryption (single, simple, etc.)
312
+ * @param privateKey The private key to decrypt the data
313
+ * @param encryptedData The data to decrypt
314
+ * @param preambleSize The size of the preamble, if any
315
+ * @param options Optional decryption options
316
+ * @param options.dataLength The expected length of the data
317
+ * @returns The decrypted data and the number of bytes consumed from the input buffer
318
+ */
319
+ decryptWithHeaderEx(encryptionType, privateKey, encryptedData, preambleSize = 0, options) {
320
+ try {
321
+ const { data, header } = this.parseEncryptedMessage(encryptionType, encryptedData, preambleSize, options);
322
+ // Normalize the public key (ensuring 0x04 prefix)
323
+ const normalizedKey = this.cryptoCore.normalizePublicKey(header.ephemeralPublicKey);
324
+ // Construct AAD
325
+ const versionBuffer = Buffer.alloc(1);
326
+ versionBuffer.writeUint8(ecies_lib_1.EciesVersionEnum.V1);
327
+ const cipherSuiteBuffer = Buffer.alloc(1);
328
+ cipherSuiteBuffer.writeUint8(ecies_lib_1.EciesCipherSuiteEnum.Secp256k1_Aes256Gcm_Sha256);
329
+ const encryptionTypeBuffer = Buffer.alloc(1);
330
+ encryptionTypeBuffer.writeUint8(header.encryptionType);
331
+ const aad = Buffer.concat([
332
+ header.preamble ?? Buffer.alloc(preambleSize),
333
+ versionBuffer,
334
+ cipherSuiteBuffer,
335
+ encryptionTypeBuffer,
336
+ normalizedKey,
337
+ ]);
338
+ // Decrypt using components with the normalized key
339
+ const decrypted = this.decryptWithComponents(privateKey, normalizedKey, header.iv, header.authTag, data, aad);
340
+ return {
341
+ decrypted,
342
+ consumedBytes: header.dataLength + header.headerSize,
343
+ };
344
+ }
345
+ catch (error) {
346
+ if (error instanceof ecies_lib_1.ECIESError) {
347
+ throw error;
348
+ }
349
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
350
+ error: error instanceof Error ? error.message : String(error),
351
+ });
352
+ }
353
+ }
354
+ /**
355
+ * Decrypts data encrypted with ECIES using components
356
+ * @param privateKey The private key to decrypt the data
357
+ * @param ephemeralPublicKey The ephemeral public key used to encrypt the data
358
+ * @param iv The initialization vector used to encrypt the data
359
+ * @param authTag The authentication tag used to encrypt the data
360
+ * @param encrypted The encrypted data
361
+ * @returns The decrypted data
362
+ */
363
+ decryptWithComponents(privateKey, ephemeralPublicKey, iv, authTag, encrypted, aad) {
364
+ try {
365
+ // Ensure the ephemeral public key has the correct format
366
+ const normalizedEphemeralKey = this.cryptoCore.normalizePublicKey(ephemeralPublicKey);
367
+ // Use cryptoCore to compute shared secret (handles compressed keys better)
368
+ let sharedSecret;
369
+ try {
370
+ sharedSecret = this.cryptoCore.computeSharedSecret(privateKey, normalizedEphemeralKey);
371
+ }
372
+ catch (err) {
373
+ if (process.env.NODE_ENV !== 'test') {
374
+ console.error('[ERROR][decrypt] Failed to compute shared secret:', err);
375
+ }
376
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
377
+ originalError: err instanceof Error ? err.message : String(err),
378
+ stage: 'shared_secret_computation',
379
+ });
380
+ }
381
+ // Use HKDF to derive the key
382
+ const symKey = this.cryptoCore.deriveSharedKey(sharedSecret, Buffer.alloc(0), // No salt
383
+ Buffer.from('ecies-v2-key-derivation'), // Info
384
+ this.cryptoCore.consts.SYMMETRIC.KEY_SIZE);
385
+ // Create decipher with shared secret-derived key
386
+ const decipher = (0, crypto_1.createDecipheriv)(this.cryptoCore.consts.SYMMETRIC_ALGORITHM_CONFIGURATION, symKey, iv);
387
+ // Validate the tag and IV
388
+ if (authTag.length !== this.cryptoCore.consts.AUTH_TAG_SIZE) {
389
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
390
+ expected: String(this.cryptoCore.consts.AUTH_TAG_SIZE),
391
+ actual: String(authTag.length),
392
+ stage: 'auth_tag_validation',
393
+ });
394
+ }
395
+ if (iv.length !== this.cryptoCore.consts.IV_SIZE) {
396
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
397
+ expected: String(this.cryptoCore.consts.IV_SIZE),
398
+ actual: String(iv.length),
399
+ stage: 'iv_validation',
400
+ });
401
+ }
402
+ // Set the authentication tag for GCM mode
403
+ decipher.setAuthTag(authTag);
404
+ if (aad) {
405
+ decipher.setAAD(aad);
406
+ }
407
+ // Decrypt the data
408
+ try {
409
+ // Handle edge case where encrypted data might be empty or malformed
410
+ const pluginEngine = (0, ecies_i18n_factory_1.getEciesPluginI18nEngine)();
411
+ if (encrypted.length === 0) {
412
+ throw new Error(pluginEngine.translate(ecies_i18n_factory_1.NodeEciesComponentId, ecies_i18n_factory_1.NodeEciesStringKey.Error_EncryptedDataIsEmpty));
413
+ }
414
+ const firstPart = decipher.update(encrypted);
415
+ const finalPart = decipher.final();
416
+ const result = Buffer.concat([firstPart, finalPart]);
417
+ // Security fix 8: Decrypted data validation
418
+ if (result.length === 0) {
419
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed);
420
+ }
421
+ return result;
422
+ }
423
+ catch (err) {
424
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
425
+ error: err instanceof Error ? err.message : String(err),
426
+ stage: 'decipher_operation',
427
+ });
428
+ }
429
+ }
430
+ catch (error) {
431
+ if (error instanceof ecies_lib_1.ECIESError) {
432
+ throw error;
433
+ }
434
+ // Wrap non-EciesError in an EciesError
435
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.DecryptionFailed, undefined, undefined, {
436
+ error: error instanceof Error ? error.message : String(error),
437
+ privateKeyLength: String(privateKey.length),
438
+ ephemeralPublicKeyLength: String(ephemeralPublicKey.length),
439
+ ivLength: String(iv.length),
440
+ authTagLength: String(authTag.length),
441
+ encryptedLength: String(encrypted.length),
442
+ });
443
+ }
444
+ }
445
+ }
446
+ exports.EciesSingleRecipientCore = EciesSingleRecipientCore;
447
+ //# sourceMappingURL=single-recipient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-recipient.js","sourceRoot":"","sources":["../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gBAED,OAAO,MAAM,CAAC;YAChB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,IAAI,sBAAU,CAClB,8BAAkB,CAAC,gBAAgB,EACnC,SAAS,EACT,SAAS,EACT;oBACE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;oBACvD,KAAK,EAAE,oBAAoB;iBAC5B,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,sBAAU,EAAE,CAAC;gBAChC,MAAM,KAAK,CAAC;YACd,CAAC;YAED,uCAAuC;YACvC,MAAM,IAAI,sBAAU,CAClB,8BAAkB,CAAC,gBAAgB,EACnC,SAAS,EACT,SAAS,EACT;gBACE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC7D,gBAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;gBAC3C,wBAAwB,EAAE,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC;gBAC3D,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC;gBAC3B,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;gBACrC,eAAe,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;aAC1C,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA7sBD,4DA6sBC"}
@@ -0,0 +1,33 @@
1
+ import { EciesEncryptionType, IConstants as IBaseConstants } from '@digitaldefiance/ecies-lib';
2
+ /**
3
+ * Utility functions for ECIES operations
4
+ */
5
+ export declare class EciesUtilities {
6
+ /**
7
+ * Computes the encrypted length from the data length.
8
+ * @param dataLength - The length of the data.
9
+ * @param encryptionMode - The encryption mode (simple, single, multiple).
10
+ * @param recipientCount - The number of recipients for multiple encryption mode.
11
+ * @param constants - The constants to use for calculations.
12
+ * @returns The encrypted length details.
13
+ */
14
+ computeEncryptedLengthFromDataLength(dataLength: number, encryptionMode: EciesEncryptionType, recipientCount?: number, constants?: IBaseConstants): number;
15
+ /**
16
+ * Calculates the overhead for multiple recipient encryption.
17
+ * This is a pure calculation that doesn't require service instantiation.
18
+ * Matches the logic in EciesMultiRecipient.calculateECIESMultipleRecipientOverhead.
19
+ * @param recipientCount - The number of recipients.
20
+ * @param includeMessageOverhead - Whether to include message overhead.
21
+ * @param eciesConstants - The ECIES constants to use.
22
+ * @returns The overhead in bytes.
23
+ */
24
+ private calculateMultipleRecipientOverhead;
25
+ /**
26
+ * Computes the decrypted length from the encrypted data length.
27
+ * @param encryptedDataLength - The length of the encrypted data.
28
+ * @param padding - Optional padding value.
29
+ * @returns The decrypted length.
30
+ */
31
+ computeDecryptedLengthFromEncryptedDataLength(encryptedDataLength: number, padding?: number, constants?: IBaseConstants): number;
32
+ }
33
+ //# sourceMappingURL=utilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/services/ecies/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAGnB,UAAU,IAAI,cAAc,EAE7B,MAAM,4BAA4B,CAAC;AAGpC;;GAEG;AACH,qBAAa,cAAc;IACzB;;;;;;;OAOG;IACI,oCAAoC,CACzC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,mBAAmB,EACnC,cAAc,CAAC,EAAE,MAAM,EACvB,SAAS,GAAE,cAA8C,GACxD,MAAM;IA4BT;;;;;;;;OAQG;IACH,OAAO,CAAC,kCAAkC;IA4B1C;;;;;OAKG;IACI,6CAA6C,CAClD,mBAAmB,EAAE,MAAM,EAC3B,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,GAAE,cAA8C,GACxD,MAAM;CA0BV"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EciesUtilities = void 0;
4
+ const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
5
+ const constants_1 = require("../../constants");
6
+ /**
7
+ * Utility functions for ECIES operations
8
+ */
9
+ class EciesUtilities {
10
+ /**
11
+ * Computes the encrypted length from the data length.
12
+ * @param dataLength - The length of the data.
13
+ * @param encryptionMode - The encryption mode (simple, single, multiple).
14
+ * @param recipientCount - The number of recipients for multiple encryption mode.
15
+ * @param constants - The constants to use for calculations.
16
+ * @returns The encrypted length details.
17
+ */
18
+ computeEncryptedLengthFromDataLength(dataLength, encryptionMode, recipientCount, constants = (0, constants_1.getNodeRuntimeConfiguration)()) {
19
+ if (dataLength < 0) {
20
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidDataLength);
21
+ }
22
+ const eciesDefaults = constants.ECIES;
23
+ switch (encryptionMode) {
24
+ case 'simple':
25
+ // type (1) + public key (65) + IV (16) + auth tag (16) = 98
26
+ return dataLength + eciesDefaults.SIMPLE.FIXED_OVERHEAD_SIZE;
27
+ case 'single':
28
+ // type (1) + public key (65) + IV (16) + auth tag (16) + data length (4) + crc16 (2) = 104
29
+ return dataLength + eciesDefaults.SINGLE.FIXED_OVERHEAD_SIZE;
30
+ case 'multiple':
31
+ // Calculate multiple recipient overhead without instantiating service
32
+ return (dataLength +
33
+ this.calculateMultipleRecipientOverhead(recipientCount ?? 1, true, eciesDefaults));
34
+ default:
35
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptionType);
36
+ }
37
+ }
38
+ /**
39
+ * Calculates the overhead for multiple recipient encryption.
40
+ * This is a pure calculation that doesn't require service instantiation.
41
+ * Matches the logic in EciesMultiRecipient.calculateECIESMultipleRecipientOverhead.
42
+ * @param recipientCount - The number of recipients.
43
+ * @param includeMessageOverhead - Whether to include message overhead.
44
+ * @param eciesConstants - The ECIES constants to use.
45
+ * @returns The overhead in bytes.
46
+ */
47
+ calculateMultipleRecipientOverhead(recipientCount, includeMessageOverhead, eciesConstants) {
48
+ if (recipientCount < 1) {
49
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidRecipientCount);
50
+ }
51
+ // Calculate encrypted keys size (default assumption: all keys use Simple encryption type)
52
+ const encryptedKeysSize = recipientCount * eciesConstants.MULTIPLE.ENCRYPTED_KEY_SIZE;
53
+ // Base overhead calculation
54
+ const baseOverhead = eciesConstants.VERSION_SIZE +
55
+ eciesConstants.CIPHER_SUITE_SIZE +
56
+ eciesConstants.ENCRYPTION_TYPE_SIZE +
57
+ eciesConstants.MULTIPLE.DATA_LENGTH_SIZE +
58
+ eciesConstants.MULTIPLE.RECIPIENT_COUNT_SIZE +
59
+ recipientCount * eciesConstants.MULTIPLE.RECIPIENT_ID_SIZE + // recipient ids (dynamic based on ID provider)
60
+ encryptedKeysSize; // actual encrypted keys size
61
+ return includeMessageOverhead
62
+ ? baseOverhead + eciesConstants.MULTIPLE.FIXED_OVERHEAD_SIZE
63
+ : baseOverhead;
64
+ }
65
+ /**
66
+ * Computes the decrypted length from the encrypted data length.
67
+ * @param encryptedDataLength - The length of the encrypted data.
68
+ * @param padding - Optional padding value.
69
+ * @returns The decrypted length.
70
+ */
71
+ computeDecryptedLengthFromEncryptedDataLength(encryptedDataLength, padding, constants = (0, constants_1.getNodeRuntimeConfiguration)()) {
72
+ if (encryptedDataLength < 0) {
73
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedDataLength);
74
+ }
75
+ const { ECIES: eciesDefaults } = constants;
76
+ const overhead = eciesDefaults.SINGLE.FIXED_OVERHEAD_SIZE;
77
+ const actualPadding = padding !== undefined ? padding : 0;
78
+ const decryptedLength = encryptedDataLength - overhead - actualPadding;
79
+ if (decryptedLength < 0) {
80
+ throw new ecies_lib_1.ECIESError(ecies_lib_1.ECIESErrorTypeEnum.InvalidEncryptedDataLength, undefined, undefined, {
81
+ encryptedDataLength: String(encryptedDataLength),
82
+ overhead: String(overhead),
83
+ padding: String(actualPadding),
84
+ computedLength: String(decryptedLength),
85
+ });
86
+ }
87
+ return decryptedLength;
88
+ }
89
+ }
90
+ exports.EciesUtilities = EciesUtilities;
91
+ //# sourceMappingURL=utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../../../packages/digitaldefiance-node-ecies-lib/src/services/ecies/utilities.ts"],"names":[],"mappings":";;;AAAA,0DAMoC;AACpC,+CAA8D;AAE9D;;GAEG;AACH,MAAa,cAAc;IACzB;;;;;;;OAOG;IACI,oCAAoC,CACzC,UAAkB,EAClB,cAAmC,EACnC,cAAuB,EACvB,YAA4B,IAAA,uCAA2B,GAAE;QAEzD,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,sBAAU,CAAC,8BAAkB,CAAC,iBAAiB,CAAC,CAAC;QAC7D,CAAC;QACD,MAAM,aAAa,GAAoB,SAAS,CAAC,KAAK,CAAC;QAEvD,QAAQ,cAAc,EAAE,CAAC;YACvB,KAAK,QAAQ;gBACX,4DAA4D;gBAC5D,OAAO,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC;YAC/D,KAAK,QAAQ;gBACX,2FAA2F;gBAC3F,OAAO,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC;YAC/D,KAAK,UAAU;gBACb,sEAAsE;gBACtE,OAAO,CACL,UAAU;oBACV,IAAI,CAAC,kCAAkC,CACrC,cAAc,IAAI,CAAC,EACnB,IAAI,EACJ,aAAa,CACd,CACF,CAAC;YACJ;gBACE,MAAM,IAAI,sBAAU,CAAC,8BAAkB,CAAC,qBAAqB,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACK,kCAAkC,CACxC,cAAsB,EACtB,sBAA+B,EA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kB,CAAC,0BAA0B,EAC7C,SAAS,EACT,SAAS,EACT;gBACE,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,CAAC;gBAChD,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;gBAC1B,OAAO,EAAE,MAAM,CAAC,aAAa,CAAC;gBAC9B,cAAc,EAAE,MAAM,CAAC,eAAe,CAAC;aACxC,CACF,CAAC;QACJ,CAAC;QAED,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AAnHD,wCAmHC"}
@@ -0,0 +1,33 @@
1
+ import { IEncryptedChunk } from '../interfaces/encrypted-chunk';
2
+ import { IMultiRecipientChunk } from '../interfaces/multi-recipient-chunk';
3
+ import { IStreamConfig } from '../interfaces/stream-config';
4
+ import { IStreamProgress } from '../interfaces/stream-progress';
5
+ import { ChunkProcessor } from './chunk-processor';
6
+ import { ECIESService } from './ecies/service';
7
+ import { MultiRecipientProcessor } from './multi-recipient-processor';
8
+ export interface IEncryptStreamOptions {
9
+ chunkSize?: number;
10
+ signal?: AbortSignal;
11
+ includeChecksums?: boolean;
12
+ onProgress?: (progress: IStreamProgress) => void;
13
+ }
14
+ export interface IDecryptStreamOptions {
15
+ signal?: AbortSignal;
16
+ onProgress?: (progress: IStreamProgress) => void;
17
+ }
18
+ export declare class EncryptionStream {
19
+ private readonly ecies;
20
+ private readonly config;
21
+ private readonly processor;
22
+ private readonly multiRecipientProcessor;
23
+ private readonly engine;
24
+ constructor(ecies: ECIESService, config?: IStreamConfig, processor?: ChunkProcessor, multiRecipientProcessor?: MultiRecipientProcessor);
25
+ encryptStream(source: AsyncIterable<Buffer>, publicKey: Buffer, options?: IEncryptStreamOptions): AsyncGenerator<IEncryptedChunk, void, unknown>;
26
+ encryptStreamMultiple(source: AsyncIterable<Buffer>, recipients: Array<{
27
+ id: Buffer;
28
+ publicKey: Buffer;
29
+ }>, options?: IEncryptStreamOptions): AsyncGenerator<IMultiRecipientChunk, void, unknown>;
30
+ decryptStream(source: AsyncIterable<Buffer>, privateKey: Buffer, options?: IDecryptStreamOptions): AsyncGenerator<Buffer, void, unknown>;
31
+ decryptStreamMultiple(source: AsyncIterable<Buffer>, recipientId: Buffer, privateKey: Buffer, options?: IDecryptStreamOptions): AsyncGenerator<Buffer, void, unknown>;
32
+ }
33
+ //# sourceMappingURL=encryption-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption-stream.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-node-ecies-lib/src/services/encryption-stream.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAEL,aAAa,EACd,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAGtE,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;CAClD;AAED,qBAAa,gBAAgB;IAMzB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAC3C,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAA0B;IAClE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