@digitaldefiance/node-ecies-lib 4.4.2 → 4.4.3

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/LICENSE +21 -0
  2. package/package.json +10 -6
  3. package/src/builders/ecies-builder.ts +27 -0
  4. package/src/builders/{index.d.ts → index.ts} +0 -1
  5. package/src/builders/member-builder.ts +158 -0
  6. package/src/constants.ts +251 -0
  7. package/src/core/errors/crypto-error.ts +10 -0
  8. package/src/core/{index.d.ts → index.ts} +0 -1
  9. package/src/core/types/result.ts +3 -0
  10. package/src/enumerations/index.ts +2 -0
  11. package/src/enumerations/pbkdf2-profile.ts +8 -0
  12. package/src/i18n/ecies-i18n-factory.ts +111 -0
  13. package/src/i18n/{index.d.ts → index.ts} +3 -1
  14. package/src/i18n/node-ecies-i18n-setup.ts +56 -0
  15. package/src/i18n/node-keys.ts +69 -0
  16. package/src/i18n/translations/de.ts +54 -0
  17. package/src/i18n/translations/en-GB.ts +83 -0
  18. package/src/i18n/translations/en-US.ts +88 -0
  19. package/src/i18n/translations/es.ts +54 -0
  20. package/src/i18n/translations/fr.ts +54 -0
  21. package/src/i18n/translations/{index.d.ts → index.ts} +0 -1
  22. package/src/i18n/translations/ja.ts +54 -0
  23. package/src/i18n/translations/uk.ts +54 -0
  24. package/src/i18n/translations/zh-cn.ts +54 -0
  25. package/src/{index.d.ts → index.ts} +5 -1
  26. package/src/interfaces/authenticated-cipher.ts +10 -0
  27. package/src/interfaces/authenticated-decipher.ts +9 -0
  28. package/src/interfaces/backend-member-operational.ts +75 -0
  29. package/src/interfaces/checksum-config.ts +4 -0
  30. package/src/interfaces/checksum-consts.ts +13 -0
  31. package/src/interfaces/constants.ts +54 -0
  32. package/src/interfaces/ecies-consts.ts +99 -0
  33. package/src/interfaces/encrypted-chunk.ts +12 -0
  34. package/src/interfaces/encryption-consts.ts +10 -0
  35. package/src/interfaces/{index.d.ts → index.ts} +0 -1
  36. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.ts +7 -0
  37. package/src/interfaces/keyring-consts.ts +5 -0
  38. package/src/interfaces/{member-with-mnemonic.d.ts → member-with-mnemonic.ts} +3 -3
  39. package/src/interfaces/member.ts +76 -0
  40. package/src/interfaces/{multi-encrypted-message.d.ts → multi-encrypted-message.ts} +5 -5
  41. package/src/interfaces/multi-encrypted-parsed-header.ts +28 -0
  42. package/src/interfaces/multi-recipient-chunk.ts +35 -0
  43. package/src/interfaces/{pbkdf-profiles.d.ts → pbkdf-profiles.ts} +2 -2
  44. package/src/interfaces/pbkdf2-result.ts +5 -0
  45. package/src/interfaces/signing-key-private-key-info.ts +12 -0
  46. package/src/interfaces/{simple-keypair-buffer.d.ts → simple-keypair-buffer.ts} +3 -3
  47. package/src/interfaces/{simple-keypair.d.ts → simple-keypair.ts} +3 -3
  48. package/src/interfaces/simple-public-key-only-buffer.ts +3 -0
  49. package/src/interfaces/simple-public-key-only.ts +3 -0
  50. package/src/interfaces/single-encrypted-parsed-header.ts +35 -0
  51. package/src/interfaces/stream-config.ts +9 -0
  52. package/src/interfaces/stream-progress.ts +7 -0
  53. package/src/interfaces/{wallet-seed.d.ts → wallet-seed.ts} +3 -3
  54. package/src/interfaces/wrapped-key-consts.ts +6 -0
  55. package/src/lib/crypto-container.ts +32 -0
  56. package/src/lib/{index.d.ts → index.ts} +0 -1
  57. package/src/lib/invariant-validator.ts +124 -0
  58. package/src/lib/invariants/{index.d.ts → index.ts} +2 -2
  59. package/src/lib/invariants/recipient-id-consistency.ts +77 -0
  60. package/src/member.ts +511 -0
  61. package/src/services/aes-gcm.ts +260 -0
  62. package/src/services/chunk-processor.ts +47 -0
  63. package/src/services/ecies/crypto-core.ts +319 -0
  64. package/src/services/ecies/file.ts +171 -0
  65. package/src/services/ecies/{index.d.ts → index.ts} +0 -1
  66. package/src/services/ecies/multi-recipient.ts +782 -0
  67. package/src/services/ecies/service.ts +316 -0
  68. package/src/services/ecies/signature.ts +91 -0
  69. package/src/services/ecies/single-recipient.ts +743 -0
  70. package/src/services/ecies/utilities.ts +128 -0
  71. package/src/services/encryption-stream.ts +432 -0
  72. package/src/services/{index.d.ts → index.ts} +0 -1
  73. package/src/services/multi-recipient-processor.ts +505 -0
  74. package/src/services/pbkdf2.ts +304 -0
  75. package/src/services/progress-tracker.ts +43 -0
  76. package/src/test-mocks/index.ts +1 -0
  77. package/src/test-mocks/mock-backend-member.ts +195 -0
  78. package/src/testing.ts +2 -0
  79. package/src/types/id-guards.ts +91 -0
  80. package/src/types/index.ts +1 -0
  81. package/src/{types.d.ts → types.ts} +28 -9
  82. package/src/utils.ts +124 -0
  83. package/src/builders/ecies-builder.d.ts +0 -11
  84. package/src/builders/ecies-builder.d.ts.map +0 -1
  85. package/src/builders/ecies-builder.js +0 -26
  86. package/src/builders/ecies-builder.js.map +0 -1
  87. package/src/builders/index.d.ts.map +0 -1
  88. package/src/builders/index.js +0 -6
  89. package/src/builders/index.js.map +0 -1
  90. package/src/builders/member-builder.d.ts +0 -47
  91. package/src/builders/member-builder.d.ts.map +0 -1
  92. package/src/builders/member-builder.js +0 -99
  93. package/src/builders/member-builder.js.map +0 -1
  94. package/src/constants.d.ts +0 -38
  95. package/src/constants.d.ts.map +0 -1
  96. package/src/constants.js +0 -183
  97. package/src/constants.js.map +0 -1
  98. package/src/core/errors/crypto-error.d.ts +0 -6
  99. package/src/core/errors/crypto-error.d.ts.map +0 -1
  100. package/src/core/errors/crypto-error.js +0 -15
  101. package/src/core/errors/crypto-error.js.map +0 -1
  102. package/src/core/index.d.ts.map +0 -1
  103. package/src/core/index.js +0 -6
  104. package/src/core/index.js.map +0 -1
  105. package/src/core/types/result.d.ts +0 -8
  106. package/src/core/types/result.d.ts.map +0 -1
  107. package/src/core/types/result.js +0 -3
  108. package/src/core/types/result.js.map +0 -1
  109. package/src/enumerations/index.d.ts +0 -2
  110. package/src/enumerations/index.d.ts.map +0 -1
  111. package/src/enumerations/index.js +0 -5
  112. package/src/enumerations/index.js.map +0 -1
  113. package/src/enumerations/pbkdf2-profile.d.ts +0 -9
  114. package/src/enumerations/pbkdf2-profile.d.ts.map +0 -1
  115. package/src/enumerations/pbkdf2-profile.js +0 -13
  116. package/src/enumerations/pbkdf2-profile.js.map +0 -1
  117. package/src/i18n/ecies-i18n-factory.d.ts +0 -28
  118. package/src/i18n/ecies-i18n-factory.d.ts.map +0 -1
  119. package/src/i18n/ecies-i18n-factory.js +0 -89
  120. package/src/i18n/ecies-i18n-factory.js.map +0 -1
  121. package/src/i18n/index.d.ts.map +0 -1
  122. package/src/i18n/index.js +0 -8
  123. package/src/i18n/index.js.map +0 -1
  124. package/src/i18n/node-ecies-i18n-setup.d.ts +0 -5
  125. package/src/i18n/node-ecies-i18n-setup.d.ts.map +0 -1
  126. package/src/i18n/node-ecies-i18n-setup.js +0 -46
  127. package/src/i18n/node-ecies-i18n-setup.js.map +0 -1
  128. package/src/i18n/node-keys.d.ts +0 -57
  129. package/src/i18n/node-keys.d.ts.map +0 -1
  130. package/src/i18n/node-keys.js +0 -67
  131. package/src/i18n/node-keys.js.map +0 -1
  132. package/src/i18n/translations/de.d.ts +0 -3
  133. package/src/i18n/translations/de.d.ts.map +0 -1
  134. package/src/i18n/translations/de.js +0 -57
  135. package/src/i18n/translations/de.js.map +0 -1
  136. package/src/i18n/translations/en-GB.d.ts +0 -3
  137. package/src/i18n/translations/en-GB.d.ts.map +0 -1
  138. package/src/i18n/translations/en-GB.js +0 -61
  139. package/src/i18n/translations/en-GB.js.map +0 -1
  140. package/src/i18n/translations/en-US.d.ts +0 -6
  141. package/src/i18n/translations/en-US.d.ts.map +0 -1
  142. package/src/i18n/translations/en-US.js +0 -65
  143. package/src/i18n/translations/en-US.js.map +0 -1
  144. package/src/i18n/translations/es.d.ts +0 -3
  145. package/src/i18n/translations/es.d.ts.map +0 -1
  146. package/src/i18n/translations/es.js +0 -57
  147. package/src/i18n/translations/es.js.map +0 -1
  148. package/src/i18n/translations/fr.d.ts +0 -3
  149. package/src/i18n/translations/fr.d.ts.map +0 -1
  150. package/src/i18n/translations/fr.js +0 -57
  151. package/src/i18n/translations/fr.js.map +0 -1
  152. package/src/i18n/translations/index.d.ts.map +0 -1
  153. package/src/i18n/translations/index.js +0 -20
  154. package/src/i18n/translations/index.js.map +0 -1
  155. package/src/i18n/translations/ja.d.ts +0 -3
  156. package/src/i18n/translations/ja.d.ts.map +0 -1
  157. package/src/i18n/translations/ja.js +0 -57
  158. package/src/i18n/translations/ja.js.map +0 -1
  159. package/src/i18n/translations/uk.d.ts +0 -3
  160. package/src/i18n/translations/uk.d.ts.map +0 -1
  161. package/src/i18n/translations/uk.js +0 -57
  162. package/src/i18n/translations/uk.js.map +0 -1
  163. package/src/i18n/translations/zh-cn.d.ts +0 -3
  164. package/src/i18n/translations/zh-cn.d.ts.map +0 -1
  165. package/src/i18n/translations/zh-cn.js +0 -57
  166. package/src/i18n/translations/zh-cn.js.map +0 -1
  167. package/src/index.d.ts.map +0 -1
  168. package/src/index.js +0 -31
  169. package/src/index.js.map +0 -1
  170. package/src/interfaces/authenticated-cipher.d.ts +0 -12
  171. package/src/interfaces/authenticated-cipher.d.ts.map +0 -1
  172. package/src/interfaces/authenticated-cipher.js +0 -3
  173. package/src/interfaces/authenticated-cipher.js.map +0 -1
  174. package/src/interfaces/authenticated-decipher.d.ts +0 -11
  175. package/src/interfaces/authenticated-decipher.d.ts.map +0 -1
  176. package/src/interfaces/authenticated-decipher.js +0 -3
  177. package/src/interfaces/authenticated-decipher.js.map +0 -1
  178. package/src/interfaces/backend-member-operational.d.ts +0 -48
  179. package/src/interfaces/backend-member-operational.d.ts.map +0 -1
  180. package/src/interfaces/backend-member-operational.js +0 -3
  181. package/src/interfaces/backend-member-operational.js.map +0 -1
  182. package/src/interfaces/checksum-config.d.ts +0 -5
  183. package/src/interfaces/checksum-config.d.ts.map +0 -1
  184. package/src/interfaces/checksum-config.js +0 -3
  185. package/src/interfaces/checksum-config.js.map +0 -1
  186. package/src/interfaces/checksum-consts.d.ts +0 -11
  187. package/src/interfaces/checksum-consts.d.ts.map +0 -1
  188. package/src/interfaces/checksum-consts.js +0 -3
  189. package/src/interfaces/checksum-consts.js.map +0 -1
  190. package/src/interfaces/constants.d.ts +0 -52
  191. package/src/interfaces/constants.d.ts.map +0 -1
  192. package/src/interfaces/constants.js +0 -3
  193. package/src/interfaces/constants.js.map +0 -1
  194. package/src/interfaces/ecies-consts.d.ts +0 -88
  195. package/src/interfaces/ecies-consts.d.ts.map +0 -1
  196. package/src/interfaces/ecies-consts.js +0 -3
  197. package/src/interfaces/ecies-consts.js.map +0 -1
  198. package/src/interfaces/encrypted-chunk.d.ts +0 -12
  199. package/src/interfaces/encrypted-chunk.d.ts.map +0 -1
  200. package/src/interfaces/encrypted-chunk.js +0 -3
  201. package/src/interfaces/encrypted-chunk.js.map +0 -1
  202. package/src/interfaces/encryption-consts.d.ts +0 -11
  203. package/src/interfaces/encryption-consts.d.ts.map +0 -1
  204. package/src/interfaces/encryption-consts.js +0 -3
  205. package/src/interfaces/encryption-consts.js.map +0 -1
  206. package/src/interfaces/index.d.ts.map +0 -1
  207. package/src/interfaces/index.js +0 -30
  208. package/src/interfaces/index.js.map +0 -1
  209. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts +0 -6
  210. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts.map +0 -1
  211. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.js +0 -3
  212. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.js.map +0 -1
  213. package/src/interfaces/keyring-consts.d.ts +0 -6
  214. package/src/interfaces/keyring-consts.d.ts.map +0 -1
  215. package/src/interfaces/keyring-consts.js +0 -3
  216. package/src/interfaces/keyring-consts.js.map +0 -1
  217. package/src/interfaces/member-with-mnemonic.d.ts.map +0 -1
  218. package/src/interfaces/member-with-mnemonic.js +0 -3
  219. package/src/interfaces/member-with-mnemonic.js.map +0 -1
  220. package/src/interfaces/member.d.ts +0 -47
  221. package/src/interfaces/member.d.ts.map +0 -1
  222. package/src/interfaces/member.js +0 -3
  223. package/src/interfaces/member.js.map +0 -1
  224. package/src/interfaces/multi-encrypted-message.d.ts.map +0 -1
  225. package/src/interfaces/multi-encrypted-message.js +0 -3
  226. package/src/interfaces/multi-encrypted-message.js.map +0 -1
  227. package/src/interfaces/multi-encrypted-parsed-header.d.ts +0 -27
  228. package/src/interfaces/multi-encrypted-parsed-header.d.ts.map +0 -1
  229. package/src/interfaces/multi-encrypted-parsed-header.js +0 -3
  230. package/src/interfaces/multi-encrypted-parsed-header.js.map +0 -1
  231. package/src/interfaces/multi-recipient-chunk.d.ts +0 -26
  232. package/src/interfaces/multi-recipient-chunk.d.ts.map +0 -1
  233. package/src/interfaces/multi-recipient-chunk.js +0 -13
  234. package/src/interfaces/multi-recipient-chunk.js.map +0 -1
  235. package/src/interfaces/pbkdf-profiles.d.ts.map +0 -1
  236. package/src/interfaces/pbkdf-profiles.js +0 -3
  237. package/src/interfaces/pbkdf-profiles.js.map +0 -1
  238. package/src/interfaces/pbkdf2-result.d.ts +0 -6
  239. package/src/interfaces/pbkdf2-result.d.ts.map +0 -1
  240. package/src/interfaces/pbkdf2-result.js +0 -3
  241. package/src/interfaces/pbkdf2-result.js.map +0 -1
  242. package/src/interfaces/signing-key-private-key-info.d.ts +0 -11
  243. package/src/interfaces/signing-key-private-key-info.d.ts.map +0 -1
  244. package/src/interfaces/signing-key-private-key-info.js +0 -3
  245. package/src/interfaces/signing-key-private-key-info.js.map +0 -1
  246. package/src/interfaces/simple-keypair-buffer.d.ts.map +0 -1
  247. package/src/interfaces/simple-keypair-buffer.js +0 -3
  248. package/src/interfaces/simple-keypair-buffer.js.map +0 -1
  249. package/src/interfaces/simple-keypair.d.ts.map +0 -1
  250. package/src/interfaces/simple-keypair.js +0 -3
  251. package/src/interfaces/simple-keypair.js.map +0 -1
  252. package/src/interfaces/simple-public-key-only-buffer.d.ts +0 -4
  253. package/src/interfaces/simple-public-key-only-buffer.d.ts.map +0 -1
  254. package/src/interfaces/simple-public-key-only-buffer.js +0 -3
  255. package/src/interfaces/simple-public-key-only-buffer.js.map +0 -1
  256. package/src/interfaces/simple-public-key-only.d.ts +0 -4
  257. package/src/interfaces/simple-public-key-only.d.ts.map +0 -1
  258. package/src/interfaces/simple-public-key-only.js +0 -3
  259. package/src/interfaces/simple-public-key-only.js.map +0 -1
  260. package/src/interfaces/single-encrypted-parsed-header.d.ts +0 -35
  261. package/src/interfaces/single-encrypted-parsed-header.d.ts.map +0 -1
  262. package/src/interfaces/single-encrypted-parsed-header.js +0 -3
  263. package/src/interfaces/single-encrypted-parsed-header.js.map +0 -1
  264. package/src/interfaces/stream-config.d.ts +0 -6
  265. package/src/interfaces/stream-config.d.ts.map +0 -1
  266. package/src/interfaces/stream-config.js +0 -8
  267. package/src/interfaces/stream-config.js.map +0 -1
  268. package/src/interfaces/stream-progress.d.ts +0 -8
  269. package/src/interfaces/stream-progress.d.ts.map +0 -1
  270. package/src/interfaces/stream-progress.js +0 -3
  271. package/src/interfaces/stream-progress.js.map +0 -1
  272. package/src/interfaces/wallet-seed.d.ts.map +0 -1
  273. package/src/interfaces/wallet-seed.js +0 -3
  274. package/src/interfaces/wallet-seed.js.map +0 -1
  275. package/src/interfaces/wrapped-key-consts.d.ts +0 -7
  276. package/src/interfaces/wrapped-key-consts.d.ts.map +0 -1
  277. package/src/interfaces/wrapped-key-consts.js +0 -3
  278. package/src/interfaces/wrapped-key-consts.js.map +0 -1
  279. package/src/lib/crypto-container.d.ts +0 -13
  280. package/src/lib/crypto-container.d.ts.map +0 -1
  281. package/src/lib/crypto-container.js +0 -29
  282. package/src/lib/crypto-container.js.map +0 -1
  283. package/src/lib/index.d.ts.map +0 -1
  284. package/src/lib/index.js +0 -7
  285. package/src/lib/index.js.map +0 -1
  286. package/src/lib/invariant-validator.d.ts +0 -62
  287. package/src/lib/invariant-validator.d.ts.map +0 -1
  288. package/src/lib/invariant-validator.js +0 -108
  289. package/src/lib/invariant-validator.js.map +0 -1
  290. package/src/lib/invariants/index.d.ts.map +0 -1
  291. package/src/lib/invariants/index.js +0 -12
  292. package/src/lib/invariants/index.js.map +0 -1
  293. package/src/lib/invariants/recipient-id-consistency.d.ts +0 -22
  294. package/src/lib/invariants/recipient-id-consistency.d.ts.map +0 -1
  295. package/src/lib/invariants/recipient-id-consistency.js +0 -62
  296. package/src/lib/invariants/recipient-id-consistency.js.map +0 -1
  297. package/src/member.d.ts +0 -81
  298. package/src/member.d.ts.map +0 -1
  299. package/src/member.js +0 -285
  300. package/src/member.js.map +0 -1
  301. package/src/services/aes-gcm.d.ts +0 -66
  302. package/src/services/aes-gcm.d.ts.map +0 -1
  303. package/src/services/aes-gcm.js +0 -158
  304. package/src/services/aes-gcm.js.map +0 -1
  305. package/src/services/chunk-processor.d.ts +0 -15
  306. package/src/services/chunk-processor.d.ts.map +0 -1
  307. package/src/services/chunk-processor.js +0 -36
  308. package/src/services/chunk-processor.js.map +0 -1
  309. package/src/services/ecies/crypto-core.d.ts +0 -104
  310. package/src/services/ecies/crypto-core.d.ts.map +0 -1
  311. package/src/services/ecies/crypto-core.js +0 -237
  312. package/src/services/ecies/crypto-core.js.map +0 -1
  313. package/src/services/ecies/file.d.ts +0 -30
  314. package/src/services/ecies/file.d.ts.map +0 -1
  315. package/src/services/ecies/file.js +0 -112
  316. package/src/services/ecies/file.js.map +0 -1
  317. package/src/services/ecies/index.d.ts.map +0 -1
  318. package/src/services/ecies/index.js +0 -11
  319. package/src/services/ecies/index.js.map +0 -1
  320. package/src/services/ecies/multi-recipient.d.ts +0 -84
  321. package/src/services/ecies/multi-recipient.d.ts.map +0 -1
  322. package/src/services/ecies/multi-recipient.js +0 -496
  323. package/src/services/ecies/multi-recipient.js.map +0 -1
  324. package/src/services/ecies/service.d.ts +0 -69
  325. package/src/services/ecies/service.d.ts.map +0 -1
  326. package/src/services/ecies/service.js +0 -144
  327. package/src/services/ecies/service.js.map +0 -1
  328. package/src/services/ecies/signature.d.ts +0 -38
  329. package/src/services/ecies/signature.d.ts.map +0 -1
  330. package/src/services/ecies/signature.js +0 -69
  331. package/src/services/ecies/signature.js.map +0 -1
  332. package/src/services/ecies/single-recipient.d.ts +0 -83
  333. package/src/services/ecies/single-recipient.d.ts.map +0 -1
  334. package/src/services/ecies/single-recipient.js +0 -447
  335. package/src/services/ecies/single-recipient.js.map +0 -1
  336. package/src/services/ecies/utilities.d.ts +0 -33
  337. package/src/services/ecies/utilities.d.ts.map +0 -1
  338. package/src/services/ecies/utilities.js +0 -91
  339. package/src/services/ecies/utilities.js.map +0 -1
  340. package/src/services/encryption-stream.d.ts +0 -33
  341. package/src/services/encryption-stream.d.ts.map +0 -1
  342. package/src/services/encryption-stream.js +0 -207
  343. package/src/services/encryption-stream.js.map +0 -1
  344. package/src/services/index.d.ts.map +0 -1
  345. package/src/services/index.js +0 -11
  346. package/src/services/index.js.map +0 -1
  347. package/src/services/multi-recipient-processor.d.ts +0 -72
  348. package/src/services/multi-recipient-processor.d.ts.map +0 -1
  349. package/src/services/multi-recipient-processor.js +0 -322
  350. package/src/services/multi-recipient-processor.js.map +0 -1
  351. package/src/services/pbkdf2.d.ts +0 -105
  352. package/src/services/pbkdf2.d.ts.map +0 -1
  353. package/src/services/pbkdf2.js +0 -189
  354. package/src/services/pbkdf2.js.map +0 -1
  355. package/src/services/progress-tracker.d.ts +0 -9
  356. package/src/services/progress-tracker.d.ts.map +0 -1
  357. package/src/services/progress-tracker.js +0 -41
  358. package/src/services/progress-tracker.js.map +0 -1
  359. package/src/test-mocks/index.d.ts +0 -2
  360. package/src/test-mocks/index.d.ts.map +0 -1
  361. package/src/test-mocks/index.js +0 -5
  362. package/src/test-mocks/index.js.map +0 -1
  363. package/src/test-mocks/mock-backend-member.d.ts +0 -71
  364. package/src/test-mocks/mock-backend-member.d.ts.map +0 -1
  365. package/src/test-mocks/mock-backend-member.js +0 -133
  366. package/src/test-mocks/mock-backend-member.js.map +0 -1
  367. package/src/testing.d.ts +0 -2
  368. package/src/testing.d.ts.map +0 -1
  369. package/src/testing.js +0 -6
  370. package/src/testing.js.map +0 -1
  371. package/src/types/id-guards.d.ts +0 -39
  372. package/src/types/id-guards.d.ts.map +0 -1
  373. package/src/types/id-guards.js +0 -91
  374. package/src/types/id-guards.js.map +0 -1
  375. package/src/types/index.d.ts +0 -2
  376. package/src/types/index.d.ts.map +0 -1
  377. package/src/types/index.js +0 -5
  378. package/src/types/index.js.map +0 -1
  379. package/src/types.d.ts.map +0 -1
  380. package/src/types.js +0 -6
  381. package/src/types.js.map +0 -1
  382. package/src/utils.d.ts +0 -11
  383. package/src/utils.d.ts.map +0 -1
  384. package/src/utils.js +0 -82
  385. package/src/utils.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Digital Defiance, Jessica Mulein, All Rights Reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@digitaldefiance/node-ecies-lib",
3
- "version": "4.4.2",
3
+ "version": "4.4.3",
4
4
  "description": "Digital Defiance Node ECIES Library",
5
+ "homepage": "https://github.com/Digital-Defiance/node-ecies-lib",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Digital-Defiance/node-ecies-lib.git"
9
+ },
5
10
  "main": "src/index.js",
6
11
  "types": "src/index.d.ts",
7
12
  "exports": {
@@ -48,8 +53,8 @@
48
53
  "license": "MIT",
49
54
  "packageManager": "yarn@4.10.3",
50
55
  "dependencies": {
51
- "@digitaldefiance/ecies-lib": "4.4.2",
52
- "@digitaldefiance/i18n-lib": "3.8.0",
56
+ "@digitaldefiance/ecies-lib": "4.4.6",
57
+ "@digitaldefiance/i18n-lib": "3.8.2",
53
58
  "@ethereumjs/wallet": "^10.0.0",
54
59
  "@noble/curves": "^2.0.1",
55
60
  "@noble/hashes": "^2.0.1",
@@ -66,6 +71,5 @@
66
71
  "eslint-plugin-prettier": "^5.5.4",
67
72
  "fast-check": "^4.3.0",
68
73
  "madge": "^8.0.0"
69
- },
70
- "type": "commonjs"
71
- }
74
+ }
75
+ }
@@ -0,0 +1,27 @@
1
+ import { ECIESService } from '../services/ecies';
2
+ import { IECIESConstants, IECIESConfig } from '@digitaldefiance/ecies-lib';
3
+ import { Constants } from '../constants';
4
+
5
+ export class ECIESBuilder {
6
+ private serviceConfig: Partial<IECIESConfig> = {};
7
+ private eciesConsts: Partial<IECIESConstants> = {};
8
+
9
+ static create(): ECIESBuilder {
10
+ return new ECIESBuilder();
11
+ }
12
+
13
+ withServiceConfig(config: Partial<IECIESConfig>): this {
14
+ this.serviceConfig = { ...this.serviceConfig, ...config };
15
+ return this;
16
+ }
17
+
18
+ withConstants(constants: Partial<IECIESConstants>): this {
19
+ this.eciesConsts = { ...this.eciesConsts, ...constants };
20
+ return this;
21
+ }
22
+
23
+ build(): ECIESService {
24
+ const finalConstants = { ...Constants.ECIES, ...this.eciesConsts };
25
+ return new ECIESService(this.serviceConfig, finalConstants);
26
+ }
27
+ }
@@ -1,3 +1,2 @@
1
1
  export * from './ecies-builder';
2
2
  export * from './member-builder';
3
- //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,158 @@
1
+ import {
2
+ EmailString,
3
+ MemberType,
4
+ SecureString,
5
+ } from '@digitaldefiance/ecies-lib';
6
+ import {
7
+ NodeEciesComponentId,
8
+ NodeEciesStringKey,
9
+ } from '../i18n/ecies-i18n-factory';
10
+ import { getNodeEciesI18nEngine } from '../i18n/node-ecies-i18n-setup';
11
+ import { IBackendMemberWithMnemonic } from '../interfaces/member-with-mnemonic';
12
+ import { Member } from '../member';
13
+ import { ECIESService } from '../services/ecies';
14
+
15
+ export class MemberBuilder {
16
+ private eciesService?: ECIESService;
17
+ private type?: MemberType;
18
+ private name?: string;
19
+ private email?: EmailString;
20
+ private mnemonic?: SecureString;
21
+ private createdBy?: Buffer;
22
+
23
+ static create(): MemberBuilder {
24
+ return new MemberBuilder();
25
+ }
26
+
27
+ withEciesService(service: ECIESService): this {
28
+ this.eciesService = service;
29
+ return this;
30
+ }
31
+
32
+ withType(type: MemberType): this {
33
+ this.type = type;
34
+ return this;
35
+ }
36
+
37
+ withName(name: string): this {
38
+ this.name = name;
39
+ return this;
40
+ }
41
+
42
+ withEmail(email: string | EmailString): this {
43
+ this.email = typeof email === 'string' ? new EmailString(email) : email;
44
+ return this;
45
+ }
46
+
47
+ withMnemonic(mnemonic: SecureString): this {
48
+ this.mnemonic = mnemonic;
49
+ return this;
50
+ }
51
+
52
+ withCreatedBy(creatorId: Buffer): this {
53
+ this.createdBy = creatorId;
54
+ return this;
55
+ }
56
+
57
+ generateMnemonic(): this {
58
+ if (!this.eciesService) {
59
+ const engine = getNodeEciesI18nEngine();
60
+ throw new Error(
61
+ engine.translate(
62
+ NodeEciesComponentId,
63
+ NodeEciesStringKey.Error_Builder_ECIESServiceMustBeSetBeforeGeneratingMnemonic
64
+ )
65
+ );
66
+ }
67
+ this.mnemonic = this.eciesService.generateNewMnemonic();
68
+ return this;
69
+ }
70
+
71
+ build(): IBackendMemberWithMnemonic {
72
+ const engine = getNodeEciesI18nEngine();
73
+ if (!this.eciesService) {
74
+ throw new Error(
75
+ engine.translate(
76
+ NodeEciesComponentId,
77
+ NodeEciesStringKey.Error_Builder_ECIESServiceIsRequired
78
+ )
79
+ );
80
+ }
81
+ if (!this.type || !this.name || !this.email) {
82
+ throw new Error(
83
+ engine.translate(
84
+ NodeEciesComponentId,
85
+ NodeEciesStringKey.Error_Builder_TypeNameAndEmailAreRequired
86
+ )
87
+ );
88
+ }
89
+
90
+ return Member.newMember(
91
+ this.eciesService,
92
+ this.type,
93
+ this.name,
94
+ this.email,
95
+ this.mnemonic,
96
+ this.createdBy
97
+ );
98
+ }
99
+
100
+ /**
101
+ * Convenience factory method to create a new member with default ECIESService
102
+ * @param type - The member type
103
+ * @param name - The member name
104
+ * @param email - The member email
105
+ * @param forceMnemonic - Optional mnemonic to use instead of generating a new one
106
+ * @param createdBy - Optional creator ID
107
+ * @returns Member with mnemonic
108
+ */
109
+ static newMember(
110
+ type: MemberType,
111
+ name: string,
112
+ email: EmailString | string,
113
+ forceMnemonic?: SecureString,
114
+ createdBy?: Buffer
115
+ ): IBackendMemberWithMnemonic {
116
+ const service = new ECIESService();
117
+ const emailObj = typeof email === 'string' ? new EmailString(email) : email;
118
+
119
+ return Member.newMember(
120
+ service,
121
+ type,
122
+ name,
123
+ emailObj,
124
+ forceMnemonic,
125
+ createdBy
126
+ );
127
+ }
128
+
129
+ /**
130
+ * Convenience factory method to create a member from JSON with default ECIESService
131
+ * @param json - JSON string representation of member
132
+ * @returns Member instance
133
+ */
134
+ static fromJson(json: string): Member {
135
+ const service = new ECIESService();
136
+ return Member.fromJson(json, service);
137
+ }
138
+
139
+ /**
140
+ * Convenience factory method to create a member from mnemonic with default ECIESService
141
+ * @param mnemonic - The mnemonic to use
142
+ * @param memberType - Optional member type (defaults to MemberType.User)
143
+ * @param name - Optional member name (defaults to 'Test User')
144
+ * @param email - Optional member email (defaults to 'test@example.com')
145
+ * @returns Member instance
146
+ */
147
+ static fromMnemonic(
148
+ mnemonic: SecureString,
149
+ memberType = MemberType.User,
150
+ name = 'Test User',
151
+ email: EmailString | string = 'test@example.com'
152
+ ): Member {
153
+ const service = new ECIESService();
154
+ const emailObj = typeof email === 'string' ? new EmailString(email) : email;
155
+
156
+ return Member.fromMnemonic(mnemonic, service, memberType, name, emailObj);
157
+ }
158
+ }
@@ -0,0 +1,251 @@
1
+ import type {
2
+ IConstants as IBaseConstants,
3
+ IPBkdf2Consts,
4
+ } from '@digitaldefiance/ecies-lib';
5
+ import {
6
+ Constants as BaseConstants,
7
+ OBJECT_ID_LENGTH,
8
+ ObjectIdProvider,
9
+ registerRuntimeConfiguration,
10
+ } from '@digitaldefiance/ecies-lib';
11
+ import { CipherGCMTypes } from 'crypto';
12
+ import { Pbkdf2ProfileEnum as NodePbkdf2ProfileEnum } from './enumerations/pbkdf2-profile';
13
+ import {
14
+ getNodeEciesI18nEngine,
15
+ NodeEciesComponentId,
16
+ NodeEciesStringKey,
17
+ } from './i18n';
18
+ import type { IChecksumConsts } from './interfaces/checksum-consts';
19
+ import type { IConstants } from './interfaces/constants';
20
+ import type { IEncryptionConsts } from './interfaces/encryption-consts';
21
+ import type { IKeyringConsts } from './interfaces/keyring-consts';
22
+ import type { PbkdfProfiles } from './interfaces/pbkdf-profiles';
23
+ import type { IWrappedKeyConsts } from './interfaces/wrapped-key-consts';
24
+
25
+ /**
26
+ * Constants for checksum operations
27
+ * These values are critical for data integrity and MUST NOT be changed
28
+ * in an already established system as it will break all existing checksums.
29
+ */
30
+ export const NODE_RUNTIME_CONFIGURATION_KEY = Symbol.for(
31
+ 'digitaldefiance.node.ecies.defaults'
32
+ );
33
+
34
+ /**
35
+ * Node runtime configuration type (extends base IConstants)
36
+ */
37
+ export type NodeRuntimeConfiguration = IBaseConstants;
38
+
39
+ /**
40
+ * Overrides for node runtime configuration
41
+ */
42
+ export type NodeRuntimeOverrides = Parameters<
43
+ typeof registerRuntimeConfiguration
44
+ >[1];
45
+
46
+ export const NODE_DEFAULTS_OVERRIDES: NodeRuntimeOverrides = Object.freeze({
47
+ PBKDF2: {
48
+ ALGORITHM: 'sha256',
49
+ },
50
+ });
51
+
52
+ let runtimeDefaults: NodeRuntimeConfiguration = registerRuntimeConfiguration(
53
+ NODE_RUNTIME_CONFIGURATION_KEY,
54
+ NODE_DEFAULTS_OVERRIDES
55
+ );
56
+
57
+ export function getNodeRuntimeConfiguration(): NodeRuntimeConfiguration {
58
+ return runtimeDefaults;
59
+ }
60
+
61
+ export function registerNodeRuntimeConfiguration(
62
+ configOrOverrides?: NodeRuntimeOverrides | NodeRuntimeConfiguration,
63
+ options?: Parameters<typeof registerRuntimeConfiguration>[2]
64
+ ): NodeRuntimeConfiguration {
65
+ // Register configuration through ecies-lib's system
66
+ // This handles auto-sync of idProvider -> MEMBER_ID_LENGTH and ECIES.MULTIPLE.RECIPIENT_ID_SIZE
67
+ runtimeDefaults = registerRuntimeConfiguration(
68
+ NODE_RUNTIME_CONFIGURATION_KEY,
69
+ configOrOverrides,
70
+ options
71
+ );
72
+
73
+ // Note: ENCRYPTION.RECIPIENT_ID_SIZE is set at module initialization
74
+ // and uses DEFAULT_ID_PROVIDER.byteLength. For runtime configurations with
75
+ // different providers, code should reference config.ECIES.MULTIPLE.RECIPIENT_ID_SIZE
76
+ // which is auto-synced by ecies-lib's createRuntimeConfiguration.
77
+
78
+ // Validate Node-specific invariants (base ecies-lib invariants already validated)
79
+ // Note: Validation temporarily disabled for configs without ENCRYPTION property
80
+ // as runtimeDefaults doesn't include node-specific constants
81
+ // InvariantValidator.validateAll(runtimeDefaults as IConstants);
82
+
83
+ return runtimeDefaults;
84
+ }
85
+
86
+ export const CHECKSUM: IChecksumConsts = runtimeDefaults.CHECKSUM;
87
+
88
+ export const KEYRING: IKeyringConsts = Object.freeze({
89
+ ALGORITHM: 'aes' as const,
90
+ KEY_BITS: 256 as const,
91
+ MODE: 'gcm' as const,
92
+ } as const);
93
+
94
+ export const PBKDF2: IPBkdf2Consts = runtimeDefaults.PBKDF2;
95
+
96
+ export const PBKDF2_PROFILES: PbkdfProfiles = Object.freeze({
97
+ // Align browser password profile with high security expectations (sha512, 64-byte salt/hash, 2M iterations)
98
+ [NodePbkdf2ProfileEnum.BROWSER_PASSWORD]: Object.freeze({
99
+ saltBytes: 64,
100
+ iterations: 2000000,
101
+ algorithm: 'sha512',
102
+ hashBytes: 64,
103
+ }),
104
+ // High security profile (sha512, 64-byte salt/hash, 2M iterations)
105
+ [NodePbkdf2ProfileEnum.HIGH_SECURITY]: Object.freeze({
106
+ saltBytes: 64,
107
+ iterations: 2000000,
108
+ algorithm: 'sha512',
109
+ hashBytes: 64,
110
+ }),
111
+ // Fast test profile (small salt and iterations for speed)
112
+ [NodePbkdf2ProfileEnum.TEST_FAST]: Object.freeze({
113
+ saltBytes: 16,
114
+ iterations: 1000, // Minimum required by PBKDF2 validation
115
+ algorithm: 'sha256',
116
+ hashBytes: 32,
117
+ }),
118
+ [NodePbkdf2ProfileEnum.USER_LOGIN]: Object.freeze({
119
+ saltBytes: 32,
120
+ iterations: 1304000,
121
+ algorithm: 'sha256',
122
+ hashBytes: 32,
123
+ }),
124
+ [NodePbkdf2ProfileEnum.KEY_WRAPPING]: Object.freeze({
125
+ saltBytes: 32,
126
+ iterations: 100000,
127
+ algorithm: 'sha256',
128
+ hashBytes: 32,
129
+ }),
130
+ [NodePbkdf2ProfileEnum.BACKUP_CODES]: Object.freeze({
131
+ saltBytes: 32,
132
+ iterations: 1304000,
133
+ algorithm: 'sha256',
134
+ hashBytes: 32,
135
+ }),
136
+ } as const);
137
+
138
+ export const WRAPPED_KEY: IWrappedKeyConsts = Object.freeze({
139
+ SALT_SIZE: PBKDF2.SALT_BYTES, // Use PBKDF2 standard salt size
140
+ IV_SIZE: 16 as const,
141
+ MASTER_KEY_SIZE: 32 as const,
142
+ MIN_ITERATIONS: 100000 as const, // Keep lower for key-wrapping operations
143
+ } as const);
144
+
145
+ export const KEYRING_ALGORITHM_CONFIGURATION =
146
+ `${KEYRING.ALGORITHM}-${KEYRING.KEY_BITS}-${KEYRING.MODE}` as CipherGCMTypes;
147
+
148
+ /**
149
+ * Default ID provider instance (singleton).
150
+ * Uses MongoDB ObjectID format (12 bytes).
151
+ */
152
+ const DEFAULT_ID_PROVIDER = new ObjectIdProvider();
153
+
154
+ /**
155
+ * Constants for encrypted data
156
+ */
157
+ export const ENCRYPTION: IEncryptionConsts = Object.freeze({
158
+ ENCRYPTION_TYPE_SIZE: 1 as const,
159
+ RECIPIENT_ID_SIZE: DEFAULT_ID_PROVIDER.byteLength,
160
+ } as const);
161
+
162
+ export const Constants: IConstants = Object.freeze({
163
+ ...BaseConstants,
164
+ ECIES: {
165
+ ...BaseConstants.ECIES,
166
+ // Override public key length for compressed keys
167
+ PUBLIC_KEY_LENGTH: 33,
168
+ // Override IV size for AES-GCM (standard is 12 bytes)
169
+ IV_SIZE: 12,
170
+ SINGLE: {
171
+ ...BaseConstants.ECIES.SINGLE,
172
+ FIXED_OVERHEAD_SIZE: 72,
173
+ },
174
+ SIMPLE: {
175
+ ...BaseConstants.ECIES.SIMPLE,
176
+ FIXED_OVERHEAD_SIZE: 64,
177
+ },
178
+ MULTIPLE: {
179
+ ...BaseConstants.ECIES.MULTIPLE,
180
+ ENCRYPTED_KEY_SIZE: 60,
181
+ },
182
+ },
183
+ // Node-specific overrides and additions
184
+ /**
185
+ * PBKDF2 constants (Node.js crypto implementation)
186
+ */
187
+ PBKDF2: PBKDF2,
188
+ /**
189
+ * PBKDF2 configuration profiles
190
+ */
191
+ PBKDF2_PROFILES: PBKDF2_PROFILES,
192
+ /**
193
+ * Key Wrapping Service constants
194
+ */
195
+ WRAPPED_KEY: WRAPPED_KEY,
196
+ /**
197
+ * Checksum constants used for data integrity
198
+ */
199
+ CHECKSUM: CHECKSUM,
200
+ /**
201
+ * Keyring constants used for key management
202
+ */
203
+ KEYRING: KEYRING,
204
+ /**
205
+ * Encryption constants used for encrypted data
206
+ */
207
+ ENCRYPTION: ENCRYPTION,
208
+ /**
209
+ * Algorithm configuration string for keyring operations
210
+ */
211
+ KEYRING_ALGORITHM_CONFIGURATION: KEYRING_ALGORITHM_CONFIGURATION,
212
+ } as const);
213
+
214
+ /**
215
+ * Safe translation helper for early initialization
216
+ * During module initialization, i18n may not be fully available.
217
+ * This function attempts to use i18n but falls back to a basic error message.
218
+ *
219
+ * @param key - The translation key
220
+ * @param fallback - The fallback message if i18n is not available
221
+ * @returns The translated message or fallback
222
+ */
223
+ function safeTranslate(key: NodeEciesStringKey, fallback: string): string {
224
+ try {
225
+ const engine = getNodeEciesI18nEngine();
226
+ return engine.translate(NodeEciesComponentId, key);
227
+ } catch {
228
+ return fallback;
229
+ }
230
+ }
231
+
232
+ // Validate checksum constants during module initialization
233
+ // Use safeTranslate to handle the case where i18n is not yet fully initialized
234
+ if (
235
+ CHECKSUM.SHA3_BUFFER_LENGTH !== CHECKSUM.SHA3_DEFAULT_HASH_BITS / 8 ||
236
+ CHECKSUM.SHA3_BUFFER_LENGTH !== CHECKSUM.SHA3_DEFAULT_HASH_BITS / 8
237
+ ) {
238
+ throw new Error(
239
+ safeTranslate(
240
+ NodeEciesStringKey.Error_InvalidChecksumConstants,
241
+ 'Invalid checksum constants: SHA3_BUFFER_LENGTH must equal SHA3_DEFAULT_HASH_BITS / 8'
242
+ )
243
+ );
244
+ }
245
+
246
+ if (OBJECT_ID_LENGTH !== 12) {
247
+ console.warn(
248
+ 'ObjectID length may have changed, breaking encryption',
249
+ OBJECT_ID_LENGTH
250
+ );
251
+ }
@@ -0,0 +1,10 @@
1
+ export class CryptoError extends Error {
2
+ constructor(
3
+ public readonly code: string,
4
+ message: string,
5
+ public readonly metadata?: Record<string, unknown>
6
+ ) {
7
+ super(message);
8
+ this.name = 'CryptoError';
9
+ }
10
+ }
@@ -1,3 +1,2 @@
1
1
  export * from './errors/crypto-error';
2
2
  export * from './types/result';
3
- //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export type Result<T, E = Error> =
2
+ | { success: true; data: T }
3
+ | { success: false; error: E };
@@ -0,0 +1,2 @@
1
+ export * from './pbkdf2-profile';
2
+
@@ -0,0 +1,8 @@
1
+ export enum Pbkdf2ProfileEnum {
2
+ USER_LOGIN = 'USER_LOGIN',
3
+ KEY_WRAPPING = 'KEY_WRAPPING',
4
+ BACKUP_CODES = 'BACKUP_CODES',
5
+ HIGH_SECURITY = 'HIGH_SECURITY',
6
+ BROWSER_PASSWORD = 'BROWSER_PASSWORD',
7
+ TEST_FAST = 'TEST_FAST',
8
+ }
@@ -0,0 +1,111 @@
1
+ import {
2
+ ComponentDefinition,
3
+ ComponentRegistration,
4
+ createCoreI18nEngine,
5
+ PluginI18nEngine,
6
+ LanguageCodes,
7
+ CoreLanguageCode,
8
+ RegistryConfig,
9
+ EngineConfig,
10
+ } from '@digitaldefiance/i18n-lib';
11
+ import { getEciesI18nEngine } from '@digitaldefiance/ecies-lib';
12
+
13
+ import { NodeEciesStringKey, NodeEciesComponentId } from './node-keys';
14
+
15
+ // Import translations
16
+ import { englishTranslations } from './translations/en-US';
17
+
18
+ export { NodeEciesStringKey, NodeEciesComponentId };
19
+ import { britishEnglishTranslations } from './translations/en-GB';
20
+ import { frenchTranslations, germanTranslations, japaneseTranslations, mandarinTranslations, spanishTranslations, ukrainianTranslations } from './translations';
21
+
22
+ /**
23
+ * Component definition for Node ECIES strings
24
+ */
25
+ export function createNodeEciesComponentDefinition(): ComponentDefinition<NodeEciesStringKey> {
26
+ const NodeEciesComponent: ComponentDefinition<NodeEciesStringKey> = {
27
+ id: NodeEciesComponentId,
28
+ name: 'Node ECIES Library Strings',
29
+ stringKeys: Object.values(NodeEciesStringKey),
30
+ };
31
+ return NodeEciesComponent;
32
+ };
33
+
34
+ export function createNodeEciesComponentRegistration(): ComponentRegistration<NodeEciesStringKey, string> {
35
+ const component = createNodeEciesComponentDefinition();
36
+
37
+ return {
38
+ component,
39
+ strings: {
40
+ [LanguageCodes.EN_US]: englishTranslations,
41
+ [LanguageCodes.EN_GB]: britishEnglishTranslations,
42
+ [LanguageCodes.FR]: frenchTranslations,
43
+ [LanguageCodes.ES]: spanishTranslations,
44
+ [LanguageCodes.DE]: germanTranslations,
45
+ [LanguageCodes.ZH_CN]: mandarinTranslations,
46
+ [LanguageCodes.JA]: japaneseTranslations,
47
+ [LanguageCodes.UK]: ukrainianTranslations,
48
+ },
49
+ };
50
+ }
51
+
52
+ /**
53
+ * Singleton instance of the ECIES I18n engine
54
+ */
55
+ let eciesI18nEngineInstance: PluginI18nEngine<CoreLanguageCode> | null = null;
56
+
57
+ /**
58
+ * Create or get the ECIES I18n engine with proper component registration
59
+ * This replaces the legacy getEciesI18nEngine() function
60
+ */
61
+ export function getEciesPluginI18nEngine(config?: Partial<RegistryConfig<string>>): PluginI18nEngine<CoreLanguageCode> {
62
+ if (!eciesI18nEngineInstance) {
63
+ // Create core engine with system strings
64
+ eciesI18nEngineInstance = createCoreI18nEngine(
65
+ NodeEciesComponentId,
66
+ config,
67
+ ) as PluginI18nEngine<CoreLanguageCode>;
68
+
69
+ const result = eciesI18nEngineInstance.registerComponent(createNodeEciesComponentRegistration());
70
+ if (!result.isValid) {
71
+ console.warn(
72
+ 'Node ECIES component registration incomplete:',
73
+ result.missingKeys,
74
+ );
75
+ }
76
+ }
77
+
78
+ return eciesI18nEngineInstance!;
79
+ }
80
+
81
+ /**
82
+ * Reset the engine instance (useful for testing)
83
+ */
84
+ export function resetEciesPluginI18nEngine(): void {
85
+ eciesI18nEngineInstance = null;
86
+ }
87
+
88
+ /**
89
+ * Get a translation from the Node ECIES component
90
+ */
91
+ export function getNodeEciesTranslation(
92
+ key: NodeEciesStringKey,
93
+ variables?: Record<string, string | number>,
94
+ language?: CoreLanguageCode,
95
+ ): string {
96
+ // Import here to avoid circular dependency
97
+ const { getNodeEciesI18nEngine } = require('../i18n/node-ecies-i18n-setup');
98
+ const engine = getNodeEciesI18nEngine();
99
+ return engine.translate(NodeEciesComponentId, key, variables, language);
100
+ }
101
+
102
+ /**
103
+ * Get the ECIES PluginI18nEngine for use in node-ecies services
104
+ * Uses the base ecies-lib's engine which has all EciesStringKey translations
105
+ * Cast to any to handle cross-package type compatibility
106
+ */
107
+ export function createEciesTranslationEngine(config?: EngineConfig): any {
108
+ return getEciesI18nEngine(config);
109
+ }
110
+
111
+
@@ -1,3 +1,5 @@
1
+ // V2 i18n exports
1
2
  export * from './node-ecies-i18n-setup';
3
+
4
+ // Legacy exports (deprecated)
2
5
  export * from './ecies-i18n-factory';
3
- //# sourceMappingURL=index.d.ts.map