@digitaldefiance/node-ecies-lib 4.12.8 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (374) hide show
  1. package/README.md +67 -18
  2. package/package.json +4 -4
  3. package/src/builders/ecies-builder.d.ts +12 -0
  4. package/src/builders/ecies-builder.d.ts.map +1 -1
  5. package/src/builders/ecies-builder.js.map +1 -1
  6. package/src/builders/index.d.ts +3 -0
  7. package/src/builders/index.d.ts.map +1 -1
  8. package/src/builders/index.js +3 -0
  9. package/src/builders/index.js.map +1 -1
  10. package/src/builders/member-builder.d.ts +16 -0
  11. package/src/builders/member-builder.d.ts.map +1 -1
  12. package/src/builders/member-builder.js +16 -0
  13. package/src/builders/member-builder.js.map +1 -1
  14. package/src/constants.d.ts +23 -10
  15. package/src/constants.d.ts.map +1 -1
  16. package/src/constants.js +57 -84
  17. package/src/constants.js.map +1 -1
  18. package/src/core/errors/crypto-error.d.ts +4 -0
  19. package/src/core/errors/crypto-error.d.ts.map +1 -1
  20. package/src/core/errors/crypto-error.js +4 -0
  21. package/src/core/errors/crypto-error.js.map +1 -1
  22. package/src/core/index.d.ts +3 -0
  23. package/src/core/index.d.ts.map +1 -1
  24. package/src/core/index.js +3 -0
  25. package/src/core/index.js.map +1 -1
  26. package/src/core/types/result.d.ts +4 -0
  27. package/src/core/types/result.d.ts.map +1 -1
  28. package/src/enumerations/index.d.ts +3 -0
  29. package/src/enumerations/index.d.ts.map +1 -1
  30. package/src/enumerations/index.js +3 -0
  31. package/src/enumerations/index.js.map +1 -1
  32. package/src/enumerations/pbkdf2-profile.d.ts +4 -0
  33. package/src/enumerations/pbkdf2-profile.d.ts.map +1 -1
  34. package/src/enumerations/pbkdf2-profile.js +4 -0
  35. package/src/enumerations/pbkdf2-profile.js.map +1 -1
  36. package/src/errors/index.d.ts +3 -0
  37. package/src/errors/index.d.ts.map +1 -1
  38. package/src/errors/index.js +3 -0
  39. package/src/errors/index.js.map +1 -1
  40. package/src/errors/translatable.d.ts +9 -0
  41. package/src/errors/translatable.d.ts.map +1 -0
  42. package/src/errors/translatable.js +20 -0
  43. package/src/errors/translatable.js.map +1 -0
  44. package/src/errors/voting.d.ts +5 -0
  45. package/src/errors/voting.d.ts.map +1 -1
  46. package/src/errors/voting.js +5 -0
  47. package/src/errors/voting.js.map +1 -1
  48. package/src/examples/typed-configuration-usage.js +3 -3
  49. package/src/examples/typed-configuration-usage.js.map +1 -1
  50. package/src/i18n/ecies-i18n-factory.d.ts +1 -1
  51. package/src/i18n/ecies-i18n-factory.d.ts.map +1 -1
  52. package/src/i18n/ecies-i18n-factory.js +7 -2
  53. package/src/i18n/ecies-i18n-factory.js.map +1 -1
  54. package/src/i18n/index.d.ts +3 -0
  55. package/src/i18n/index.d.ts.map +1 -1
  56. package/src/i18n/index.js +3 -0
  57. package/src/i18n/index.js.map +1 -1
  58. package/src/i18n/node-ecies-i18n-setup.d.ts +5 -0
  59. package/src/i18n/node-ecies-i18n-setup.d.ts.map +1 -1
  60. package/src/i18n/node-ecies-i18n-setup.js +12 -0
  61. package/src/i18n/node-ecies-i18n-setup.js.map +1 -1
  62. package/src/i18n/translations/de.d.ts +4 -0
  63. package/src/i18n/translations/de.d.ts.map +1 -1
  64. package/src/i18n/translations/de.js +4 -0
  65. package/src/i18n/translations/de.js.map +1 -1
  66. package/src/i18n/translations/en-GB.d.ts +4 -0
  67. package/src/i18n/translations/en-GB.d.ts.map +1 -1
  68. package/src/i18n/translations/en-GB.js +4 -0
  69. package/src/i18n/translations/en-GB.js.map +1 -1
  70. package/src/i18n/translations/en-US.d.ts +5 -0
  71. package/src/i18n/translations/en-US.d.ts.map +1 -1
  72. package/src/i18n/translations/en-US.js +5 -0
  73. package/src/i18n/translations/en-US.js.map +1 -1
  74. package/src/i18n/translations/es.d.ts +4 -0
  75. package/src/i18n/translations/es.d.ts.map +1 -1
  76. package/src/i18n/translations/es.js +4 -0
  77. package/src/i18n/translations/es.js.map +1 -1
  78. package/src/i18n/translations/fr.d.ts +4 -0
  79. package/src/i18n/translations/fr.d.ts.map +1 -1
  80. package/src/i18n/translations/fr.js +4 -0
  81. package/src/i18n/translations/fr.js.map +1 -1
  82. package/src/i18n/translations/index.d.ts +3 -0
  83. package/src/i18n/translations/index.d.ts.map +1 -1
  84. package/src/i18n/translations/index.js +3 -0
  85. package/src/i18n/translations/index.js.map +1 -1
  86. package/src/i18n/translations/ja.d.ts +4 -0
  87. package/src/i18n/translations/ja.d.ts.map +1 -1
  88. package/src/i18n/translations/ja.js +4 -0
  89. package/src/i18n/translations/ja.js.map +1 -1
  90. package/src/i18n/translations/uk.d.ts +4 -0
  91. package/src/i18n/translations/uk.d.ts.map +1 -1
  92. package/src/i18n/translations/uk.js +4 -0
  93. package/src/i18n/translations/uk.js.map +1 -1
  94. package/src/i18n/translations/zh-cn.d.ts +4 -0
  95. package/src/i18n/translations/zh-cn.d.ts.map +1 -1
  96. package/src/i18n/translations/zh-cn.js +4 -0
  97. package/src/i18n/translations/zh-cn.js.map +1 -1
  98. package/src/index.d.ts +12 -0
  99. package/src/index.d.ts.map +1 -1
  100. package/src/index.js +12 -0
  101. package/src/index.js.map +1 -1
  102. package/src/interfaces/authenticated-cipher.d.ts +5 -0
  103. package/src/interfaces/authenticated-cipher.d.ts.map +1 -1
  104. package/src/interfaces/authenticated-decipher.d.ts +3 -0
  105. package/src/interfaces/authenticated-decipher.d.ts.map +1 -1
  106. package/src/interfaces/checksum-config.d.ts +3 -0
  107. package/src/interfaces/checksum-config.d.ts.map +1 -1
  108. package/src/interfaces/checksum-consts.d.ts +3 -0
  109. package/src/interfaces/checksum-consts.d.ts.map +1 -1
  110. package/src/interfaces/configuration-provenance.d.ts +3 -0
  111. package/src/interfaces/configuration-provenance.d.ts.map +1 -1
  112. package/src/interfaces/constants.d.ts +5 -1
  113. package/src/interfaces/constants.d.ts.map +1 -1
  114. package/src/interfaces/ecies-consts.d.ts +5 -2
  115. package/src/interfaces/ecies-consts.d.ts.map +1 -1
  116. package/src/interfaces/encrypted-chunk.d.ts +3 -0
  117. package/src/interfaces/encrypted-chunk.d.ts.map +1 -1
  118. package/src/interfaces/encryption-consts.d.ts +3 -0
  119. package/src/interfaces/encryption-consts.d.ts.map +1 -1
  120. package/src/interfaces/guid.d.ts +3 -0
  121. package/src/interfaces/guid.d.ts.map +1 -1
  122. package/src/interfaces/index.d.ts +4 -0
  123. package/src/interfaces/index.d.ts.map +1 -1
  124. package/src/interfaces/index.js +4 -0
  125. package/src/interfaces/index.js.map +1 -1
  126. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts +3 -0
  127. package/src/interfaces/keypair-buffer-with-un-encrypted-private-key.d.ts.map +1 -1
  128. package/src/interfaces/keyring-consts.d.ts +3 -0
  129. package/src/interfaces/keyring-consts.d.ts.map +1 -1
  130. package/src/interfaces/member-with-mnemonic.d.ts +3 -0
  131. package/src/interfaces/member-with-mnemonic.d.ts.map +1 -1
  132. package/src/interfaces/member.d.ts +3 -0
  133. package/src/interfaces/member.d.ts.map +1 -1
  134. package/src/interfaces/multi-encrypted-message.d.ts +3 -0
  135. package/src/interfaces/multi-encrypted-message.d.ts.map +1 -1
  136. package/src/interfaces/multi-encrypted-parsed-header.d.ts +3 -0
  137. package/src/interfaces/multi-encrypted-parsed-header.d.ts.map +1 -1
  138. package/src/interfaces/multi-recipient-chunk.d.ts +3 -0
  139. package/src/interfaces/multi-recipient-chunk.d.ts.map +1 -1
  140. package/src/interfaces/multi-recipient-chunk.js.map +1 -1
  141. package/src/interfaces/pbkdf-profiles.d.ts +3 -0
  142. package/src/interfaces/pbkdf-profiles.d.ts.map +1 -1
  143. package/src/interfaces/pbkdf2-result.d.ts +3 -0
  144. package/src/interfaces/pbkdf2-result.d.ts.map +1 -1
  145. package/src/interfaces/platform-buffer.d.ts +3 -0
  146. package/src/interfaces/platform-buffer.d.ts.map +1 -1
  147. package/src/interfaces/platform-id.d.ts +3 -0
  148. package/src/interfaces/platform-id.d.ts.map +1 -1
  149. package/src/interfaces/signing-key-private-key-info.d.ts +3 -0
  150. package/src/interfaces/signing-key-private-key-info.d.ts.map +1 -1
  151. package/src/interfaces/simple-keypair-buffer.d.ts +3 -0
  152. package/src/interfaces/simple-keypair-buffer.d.ts.map +1 -1
  153. package/src/interfaces/simple-keypair.d.ts +3 -0
  154. package/src/interfaces/simple-keypair.d.ts.map +1 -1
  155. package/src/interfaces/simple-public-key-only-buffer.d.ts +3 -0
  156. package/src/interfaces/simple-public-key-only-buffer.d.ts.map +1 -1
  157. package/src/interfaces/simple-public-key-only.d.ts +3 -0
  158. package/src/interfaces/simple-public-key-only.d.ts.map +1 -1
  159. package/src/interfaces/single-encrypted-parsed-header.d.ts +3 -0
  160. package/src/interfaces/single-encrypted-parsed-header.d.ts.map +1 -1
  161. package/src/interfaces/stream-config.d.ts +3 -0
  162. package/src/interfaces/stream-config.d.ts.map +1 -1
  163. package/src/interfaces/stream-config.js.map +1 -1
  164. package/src/interfaces/wallet-seed.d.ts +3 -0
  165. package/src/interfaces/wallet-seed.d.ts.map +1 -1
  166. package/src/interfaces/wrapped-key-consts.d.ts +3 -0
  167. package/src/interfaces/wrapped-key-consts.d.ts.map +1 -1
  168. package/src/isolated-private.d.ts.map +1 -1
  169. package/src/isolated-private.js +8 -0
  170. package/src/isolated-private.js.map +1 -1
  171. package/src/isolated-public.d.ts.map +1 -1
  172. package/src/isolated-public.js +8 -0
  173. package/src/isolated-public.js.map +1 -1
  174. package/src/lib/crypto-container.d.ts.map +1 -1
  175. package/src/lib/crypto-container.js +5 -0
  176. package/src/lib/crypto-container.js.map +1 -1
  177. package/src/lib/guid.d.ts +57 -33
  178. package/src/lib/guid.d.ts.map +1 -1
  179. package/src/lib/guid.js +131 -105
  180. package/src/lib/guid.js.map +1 -1
  181. package/src/lib/id-providers/buffer-provider.d.ts.map +1 -1
  182. package/src/lib/id-providers/buffer-provider.js +5 -0
  183. package/src/lib/id-providers/buffer-provider.js.map +1 -1
  184. package/src/lib/id-providers/guidv4-provider.d.ts +62 -0
  185. package/src/lib/id-providers/guidv4-provider.d.ts.map +1 -0
  186. package/src/lib/id-providers/guidv4-provider.js +146 -0
  187. package/src/lib/id-providers/guidv4-provider.js.map +1 -0
  188. package/src/lib/index.d.ts +4 -0
  189. package/src/lib/index.d.ts.map +1 -1
  190. package/src/lib/index.js +4 -0
  191. package/src/lib/index.js.map +1 -1
  192. package/src/lib/invariant-validator.d.ts.map +1 -1
  193. package/src/lib/invariant-validator.js +5 -0
  194. package/src/lib/invariant-validator.js.map +1 -1
  195. package/src/lib/invariants/recipient-id-consistency.d.ts.map +1 -1
  196. package/src/lib/invariants/recipient-id-consistency.js +9 -4
  197. package/src/lib/invariants/recipient-id-consistency.js.map +1 -1
  198. package/src/lib/voting/interfaces/aggregated-tally.d.ts +3 -0
  199. package/src/lib/voting/interfaces/aggregated-tally.d.ts.map +1 -1
  200. package/src/lib/voting/interfaces/audit-entry.d.ts +3 -0
  201. package/src/lib/voting/interfaces/audit-entry.d.ts.map +1 -1
  202. package/src/lib/voting/interfaces/audit-log.d.ts +3 -0
  203. package/src/lib/voting/interfaces/audit-log.d.ts.map +1 -1
  204. package/src/lib/voting/interfaces/bulletin-board-entry.d.ts +3 -0
  205. package/src/lib/voting/interfaces/bulletin-board-entry.d.ts.map +1 -1
  206. package/src/lib/voting/interfaces/bulletin-board.d.ts +3 -0
  207. package/src/lib/voting/interfaces/bulletin-board.d.ts.map +1 -1
  208. package/src/lib/voting/interfaces/checkpoint-manager-extended.d.ts +3 -0
  209. package/src/lib/voting/interfaces/checkpoint-manager-extended.d.ts.map +1 -1
  210. package/src/lib/voting/interfaces/checkpoint-manager.d.ts +3 -0
  211. package/src/lib/voting/interfaces/checkpoint-manager.d.ts.map +1 -1
  212. package/src/lib/voting/interfaces/encrypted-vote.d.ts +3 -0
  213. package/src/lib/voting/interfaces/encrypted-vote.d.ts.map +1 -1
  214. package/src/lib/voting/interfaces/event-log-entry.d.ts +3 -0
  215. package/src/lib/voting/interfaces/event-log-entry.d.ts.map +1 -1
  216. package/src/lib/voting/interfaces/event-logger.d.ts +3 -0
  217. package/src/lib/voting/interfaces/event-logger.d.ts.map +1 -1
  218. package/src/lib/voting/interfaces/jurisdiction-config.d.ts +3 -0
  219. package/src/lib/voting/interfaces/jurisdiction-config.d.ts.map +1 -1
  220. package/src/lib/voting/interfaces/plaintext-vote.d.ts +3 -0
  221. package/src/lib/voting/interfaces/plaintext-vote.d.ts.map +1 -1
  222. package/src/lib/voting/interfaces/poll-tallier.d.ts +3 -0
  223. package/src/lib/voting/interfaces/poll-tallier.d.ts.map +1 -1
  224. package/src/lib/voting/interfaces/poll.d.ts +3 -0
  225. package/src/lib/voting/interfaces/poll.d.ts.map +1 -1
  226. package/src/lib/voting/interfaces/state-snapshot.d.ts +3 -0
  227. package/src/lib/voting/interfaces/state-snapshot.d.ts.map +1 -1
  228. package/src/lib/voting/interfaces/tally-proof.d.ts +3 -0
  229. package/src/lib/voting/interfaces/tally-proof.d.ts.map +1 -1
  230. package/src/lib/voting/interfaces/vote-encoder.d.ts +3 -0
  231. package/src/lib/voting/interfaces/vote-encoder.d.ts.map +1 -1
  232. package/src/lib/voting/interfaces/vote-logger-extended.d.ts +3 -0
  233. package/src/lib/voting/interfaces/vote-logger-extended.d.ts.map +1 -1
  234. package/src/lib/voting/interfaces/vote-logger.d.ts +3 -0
  235. package/src/lib/voting/interfaces/vote-logger.d.ts.map +1 -1
  236. package/src/lib/voting/interfaces/voting-receipt.d.ts +3 -0
  237. package/src/lib/voting/interfaces/voting-receipt.d.ts.map +1 -1
  238. package/src/lib/voting/poll.d.ts.map +1 -1
  239. package/src/lib/voting/poll.js +2 -2
  240. package/src/lib/voting/poll.js.map +1 -1
  241. package/src/lib/voting/test-voter-pool.d.ts.map +1 -1
  242. package/src/lib/voting/test-voter-pool.js +5 -0
  243. package/src/lib/voting/test-voter-pool.js.map +1 -1
  244. package/src/member.d.ts +8 -0
  245. package/src/member.d.ts.map +1 -1
  246. package/src/member.js +28 -20
  247. package/src/member.js.map +1 -1
  248. package/src/secure-buffer.d.ts.map +1 -1
  249. package/src/secure-buffer.js +5 -0
  250. package/src/secure-buffer.js.map +1 -1
  251. package/src/services/aes-gcm.d.ts.map +1 -1
  252. package/src/services/aes-gcm.js +5 -0
  253. package/src/services/aes-gcm.js.map +1 -1
  254. package/src/services/chunk-processor.d.ts +3 -0
  255. package/src/services/chunk-processor.d.ts.map +1 -1
  256. package/src/services/chunk-processor.js +2 -2
  257. package/src/services/chunk-processor.js.map +1 -1
  258. package/src/services/crc.d.ts +3 -0
  259. package/src/services/crc.d.ts.map +1 -1
  260. package/src/services/crc.js +1 -1
  261. package/src/services/crc.js.map +1 -1
  262. package/src/services/ecies/crypto-core.d.ts.map +1 -1
  263. package/src/services/ecies/crypto-core.js +3 -0
  264. package/src/services/ecies/crypto-core.js.map +1 -1
  265. package/src/services/ecies/file.d.ts.map +1 -1
  266. package/src/services/ecies/file.js +10 -7
  267. package/src/services/ecies/file.js.map +1 -1
  268. package/src/services/ecies/index.d.ts +4 -2
  269. package/src/services/ecies/index.d.ts.map +1 -1
  270. package/src/services/ecies/index.js +4 -2
  271. package/src/services/ecies/index.js.map +1 -1
  272. package/src/services/ecies/interfaces/index.d.ts +3 -0
  273. package/src/services/ecies/interfaces/index.d.ts.map +1 -1
  274. package/src/services/ecies/interfaces/multi-encrypted-message.d.ts +3 -0
  275. package/src/services/ecies/interfaces/multi-encrypted-message.d.ts.map +1 -1
  276. package/src/services/ecies/interfaces/multi-encrypted-parsed-header.d.ts +3 -0
  277. package/src/services/ecies/interfaces/multi-encrypted-parsed-header.d.ts.map +1 -1
  278. package/src/services/ecies/interfaces/multi-recipient.d.ts +3 -0
  279. package/src/services/ecies/interfaces/multi-recipient.d.ts.map +1 -1
  280. package/src/services/ecies/interfaces/simple-keypair.d.ts +3 -0
  281. package/src/services/ecies/interfaces/simple-keypair.d.ts.map +1 -1
  282. package/src/services/ecies/interfaces/single-encrypted-parsed-header.d.ts +3 -0
  283. package/src/services/ecies/interfaces/single-encrypted-parsed-header.d.ts.map +1 -1
  284. package/src/services/ecies/interfaces/wallet-seed.d.ts +3 -0
  285. package/src/services/ecies/interfaces/wallet-seed.d.ts.map +1 -1
  286. package/src/services/ecies/multi-recipient.d.ts +5 -5
  287. package/src/services/ecies/multi-recipient.d.ts.map +1 -1
  288. package/src/services/ecies/multi-recipient.js +11 -6
  289. package/src/services/ecies/multi-recipient.js.map +1 -1
  290. package/src/services/ecies/service.d.ts +18 -5
  291. package/src/services/ecies/service.d.ts.map +1 -1
  292. package/src/services/ecies/service.js +29 -21
  293. package/src/services/ecies/service.js.map +1 -1
  294. package/src/services/ecies/signature.d.ts +3 -0
  295. package/src/services/ecies/signature.d.ts.map +1 -1
  296. package/src/services/ecies/signature.js +3 -0
  297. package/src/services/ecies/signature.js.map +1 -1
  298. package/src/services/ecies/single-recipient.d.ts +6 -6
  299. package/src/services/ecies/single-recipient.d.ts.map +1 -1
  300. package/src/services/ecies/single-recipient.js +27 -23
  301. package/src/services/ecies/single-recipient.js.map +1 -1
  302. package/src/services/ecies/utilities.d.ts +3 -0
  303. package/src/services/ecies/utilities.d.ts.map +1 -1
  304. package/src/services/ecies/utilities.js +8 -5
  305. package/src/services/ecies/utilities.js.map +1 -1
  306. package/src/services/encryption-stream.d.ts +8 -2
  307. package/src/services/encryption-stream.d.ts.map +1 -1
  308. package/src/services/encryption-stream.js +9 -2
  309. package/src/services/encryption-stream.js.map +1 -1
  310. package/src/services/index.d.ts +4 -0
  311. package/src/services/index.d.ts.map +1 -1
  312. package/src/services/index.js +4 -0
  313. package/src/services/index.js.map +1 -1
  314. package/src/services/multi-recipient-processor.d.ts +3 -3
  315. package/src/services/multi-recipient-processor.d.ts.map +1 -1
  316. package/src/services/multi-recipient-processor.js +5 -2
  317. package/src/services/multi-recipient-processor.js.map +1 -1
  318. package/src/services/pbkdf2.d.ts.map +1 -1
  319. package/src/services/pbkdf2.js +8 -5
  320. package/src/services/pbkdf2.js.map +1 -1
  321. package/src/services/progress-tracker.d.ts +3 -0
  322. package/src/services/progress-tracker.d.ts.map +1 -1
  323. package/src/services/progress-tracker.js.map +1 -1
  324. package/src/test-mocks/index.d.ts +3 -0
  325. package/src/test-mocks/index.d.ts.map +1 -1
  326. package/src/test-mocks/index.js +3 -0
  327. package/src/test-mocks/index.js.map +1 -1
  328. package/src/test-mocks/mock-backend-member.d.ts.map +1 -1
  329. package/src/test-mocks/mock-backend-member.js +5 -0
  330. package/src/test-mocks/mock-backend-member.js.map +1 -1
  331. package/src/testing.d.ts +4 -0
  332. package/src/testing.d.ts.map +1 -1
  333. package/src/testing.js +4 -1
  334. package/src/testing.js.map +1 -1
  335. package/src/transforms/checksumTransform.d.ts +5 -0
  336. package/src/transforms/checksumTransform.d.ts.map +1 -1
  337. package/src/transforms/checksumTransform.js +5 -0
  338. package/src/transforms/checksumTransform.js.map +1 -1
  339. package/src/transforms/eciesDecryptTransform.d.ts +5 -0
  340. package/src/transforms/eciesDecryptTransform.d.ts.map +1 -1
  341. package/src/transforms/eciesDecryptTransform.js +7 -4
  342. package/src/transforms/eciesDecryptTransform.js.map +1 -1
  343. package/src/transforms/eciesEncryptTransform.d.ts +5 -0
  344. package/src/transforms/eciesEncryptTransform.d.ts.map +1 -1
  345. package/src/transforms/eciesEncryptTransform.js +8 -5
  346. package/src/transforms/eciesEncryptTransform.js.map +1 -1
  347. package/src/transforms/index.d.ts +4 -0
  348. package/src/transforms/index.d.ts.map +1 -1
  349. package/src/transforms/index.js +4 -0
  350. package/src/transforms/index.js.map +1 -1
  351. package/src/transforms/xorMultipleTransform.d.ts +5 -0
  352. package/src/transforms/xorMultipleTransform.d.ts.map +1 -1
  353. package/src/transforms/xorMultipleTransform.js +5 -0
  354. package/src/transforms/xorMultipleTransform.js.map +1 -1
  355. package/src/transforms/xorTransform.d.ts +5 -0
  356. package/src/transforms/xorTransform.d.ts.map +1 -1
  357. package/src/transforms/xorTransform.js +5 -0
  358. package/src/transforms/xorTransform.js.map +1 -1
  359. package/src/typed-configuration.d.ts +1 -1
  360. package/src/typed-configuration.d.ts.map +1 -1
  361. package/src/typed-configuration.js +2 -2
  362. package/src/typed-configuration.js.map +1 -1
  363. package/src/types/guid-versions.d.ts +6 -6
  364. package/src/types/guid-versions.d.ts.map +1 -1
  365. package/src/types/index.d.ts +3 -0
  366. package/src/types/index.d.ts.map +1 -1
  367. package/src/types/index.js +3 -0
  368. package/src/types/index.js.map +1 -1
  369. package/src/types.d.ts +5 -0
  370. package/src/types.d.ts.map +1 -1
  371. package/src/types.js.map +1 -1
  372. package/src/utils.d.ts.map +1 -1
  373. package/src/utils.js +6 -1
  374. package/src/utils.js.map +1 -1
package/src/lib/guid.js CHANGED
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Guid = void 0;
3
+ exports.GuidBuffer = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ /**
6
+ * RFC 4122 compliant GUID implementation for Node.js.
7
+ * Provides comprehensive GUID/UUID operations including generation (v1, v3, v4, v5),
8
+ * validation, conversion between formats (hex, base64, bigint, Buffer), and type-safe
9
+ * branded types for compile-time format verification.
10
+ */
5
11
  const ecies_lib_1 = require("@digitaldefiance/ecies-lib");
6
12
  const uuid = tslib_1.__importStar(require("uuid"));
7
13
  /**
@@ -14,7 +20,7 @@ const uuid = tslib_1.__importStar(require("uuid"));
14
20
  * - RawGuidPlatformBuffer: A 16-byte Buffer representation of the GUID
15
21
  * Guid instances can be converted to any of these representations using the appropriate method.
16
22
  */
17
- class Guid {
23
+ class GuidBuffer {
18
24
  /**
19
25
  * GUID is stored internally as a raw 16-byte Buffer.
20
26
  */
@@ -44,6 +50,10 @@ class Guid {
44
50
  * Cached base64 representation for performance
45
51
  */
46
52
  _cachedBase64;
53
+ /**
54
+ * The RFC 4122 version of this GUID (1, 3, 4, 5, or undefined for boundary/invalid)
55
+ */
56
+ __version;
47
57
  /**
48
58
  * Regex for validating hex strings (case insensitive)
49
59
  */
@@ -72,13 +82,13 @@ class Guid {
72
82
  * Empty/nil GUID constant (all zeros)
73
83
  */
74
84
  static get Empty() {
75
- if (!Guid._empty) {
76
- Guid._empty = Object.freeze(new Guid('00000000-0000-0000-0000-000000000000'));
85
+ if (!GuidBuffer._empty) {
86
+ GuidBuffer._empty = Object.freeze(new GuidBuffer('00000000-0000-0000-0000-000000000000'));
77
87
  }
78
- return Guid._empty;
88
+ return GuidBuffer._empty;
79
89
  }
80
90
  constructor(value) {
81
- const buffer = Guid.validateAndConvert(value);
91
+ const buffer = GuidBuffer.validateAndConvert(value);
82
92
  // Note: We cannot freeze a Buffer as it's an ArrayBuffer view
83
93
  // Instead, we ensure the buffer is never directly modified after construction
84
94
  this._value = buffer;
@@ -86,6 +96,7 @@ class Guid {
86
96
  this._cachedFullHex = undefined;
87
97
  this._cachedShortHex = undefined;
88
98
  this._cachedBase64 = undefined;
99
+ this.__version = undefined;
89
100
  // Seal the instance to prevent property addition/deletion
90
101
  // Cache properties can still be set once since they were initialized
91
102
  Object.seal(this);
@@ -116,18 +127,18 @@ class Guid {
116
127
  if (typeof value === 'string') {
117
128
  const isFullHex = value.length === 36 && value.includes('-');
118
129
  const isShortHex = value.length === 32 && !value.includes('-');
119
- if (isFullHex && !Guid.FULL_HEX_PATTERN.test(value)) {
130
+ if (isFullHex && !GuidBuffer.FULL_HEX_PATTERN.test(value)) {
120
131
  const buffer = Buffer.from(value);
121
132
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuidWithDetails, ecies_lib_1.GuidBrandType.FullHexGuid, value.length, buffer);
122
133
  }
123
- else if (isShortHex && !Guid.HEX_PATTERN.test(value)) {
134
+ else if (isShortHex && !GuidBuffer.HEX_PATTERN.test(value)) {
124
135
  const buffer = Buffer.from(value);
125
136
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuidWithDetails, ecies_lib_1.GuidBrandType.ShortHexGuid, value.length, buffer);
126
137
  }
127
138
  }
128
139
  // Determine and verify the brand/type
129
- const expectedBrand = Guid.whichBrand(value);
130
- const verifiedBrand = Guid.verifyGuid(expectedBrand, value);
140
+ const expectedBrand = GuidBuffer.whichBrand(value);
141
+ const verifiedBrand = GuidBuffer.verifyGuid(expectedBrand, value);
131
142
  if (!verifiedBrand) {
132
143
  const valueBuffer = Buffer.isBuffer(value)
133
144
  ? value
@@ -135,11 +146,11 @@ class Guid {
135
146
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuidWithDetails, expectedBrand, undefined, valueBuffer);
136
147
  }
137
148
  // Convert to raw buffer
138
- const buffer = Guid.toRawGuidPlatformBuffer(value);
149
+ const buffer = GuidBuffer.toRawGuidPlatformBuffer(value);
139
150
  // Validate against UUID standard (skip for boundary values)
140
151
  const hexString = buffer.toString('hex');
141
- const fullHex = Guid.toFullHexGuid(hexString);
142
- const isBoundary = Guid.isBoundaryValue(fullHex);
152
+ const fullHex = GuidBuffer.toFullHexGuid(hexString);
153
+ const isBoundary = GuidBuffer.isBoundaryValue(fullHex);
143
154
  if (!isBoundary && !uuid.validate(fullHex)) {
144
155
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuid, expectedBrand, undefined, buffer);
145
156
  }
@@ -167,7 +178,7 @@ class Guid {
167
178
  return this.asBase64Guid;
168
179
  }
169
180
  static hydrate(value) {
170
- return new Guid(value);
181
+ return GuidBuffer.withVersion(new GuidBuffer(value));
171
182
  }
172
183
  static LengthMap = {
173
184
  [ecies_lib_1.GuidBrandType.Unknown]: -1,
@@ -210,6 +221,16 @@ class Guid {
210
221
  get asRawGuidPlatformBufferUnsafe() {
211
222
  return this._value;
212
223
  }
224
+ /**
225
+ * Attaches the RFC 4122 version to a GuidBuffer instance.
226
+ * @param guid The GuidBuffer instance to attach version to
227
+ * @returns The same instance with __version property set
228
+ */
229
+ static withVersion(guid) {
230
+ const version = guid.getVersion();
231
+ guid.__version = version;
232
+ return guid;
233
+ }
213
234
  /**
214
235
  * Generates a new random v4 GUID.
215
236
  * @returns A new Guid instance with a randomly generated value
@@ -220,7 +241,7 @@ class Guid {
220
241
  if (!uuidStr) {
221
242
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuid);
222
243
  }
223
- return new Guid(uuidStr);
244
+ return GuidBuffer.withVersion(new GuidBuffer(uuidStr));
224
245
  }
225
246
  catch (error) {
226
247
  if (error instanceof ecies_lib_1.GuidError) {
@@ -234,34 +255,34 @@ class Guid {
234
255
  * @returns A new Guid instance with a randomly generated v4 value
235
256
  */
236
257
  static v4() {
237
- return Guid.generate();
258
+ return GuidBuffer.generate();
238
259
  }
239
260
  /**
240
261
  * Alias for generate() for backward compatibility.
241
262
  * @deprecated Use generate() instead for clearer intent
242
263
  */
243
264
  static new() {
244
- return Guid.generate();
265
+ return GuidBuffer.generate();
245
266
  }
246
267
  /**
247
268
  * Parses a GUID from any valid format, throwing on invalid input.
248
269
  * This is the primary parsing method for when you expect valid input.
249
270
  * @param value The value to parse
250
- * @returns A new Guid instance
271
+ * @returns A new Guid instance with __version attached
251
272
  * @throws {GuidError} If the value is not a valid GUID
252
273
  */
253
274
  static parse(value) {
254
- return new Guid(value);
275
+ return GuidBuffer.withVersion(new GuidBuffer(value));
255
276
  }
256
277
  /**
257
278
  * Attempts to parse a GUID, returning null on failure instead of throwing.
258
279
  * Use this when you're uncertain if the input is valid.
259
280
  * @param value The value to parse
260
- * @returns A new Guid instance or null if parsing fails
281
+ * @returns A new Guid instance with __version attached, or null if parsing fails
261
282
  */
262
283
  static tryParse(value) {
263
284
  try {
264
- return new Guid(value);
285
+ return GuidBuffer.withVersion(new GuidBuffer(value));
265
286
  }
266
287
  catch {
267
288
  return null;
@@ -277,7 +298,7 @@ class Guid {
277
298
  if (!value)
278
299
  return false;
279
300
  try {
280
- const guid = new Guid(value);
301
+ const guid = new GuidBuffer(value);
281
302
  return guid.isValidV4();
282
303
  }
283
304
  catch {
@@ -287,68 +308,68 @@ class Guid {
287
308
  /**
288
309
  * Factory method to create a GUID from a full hex string.
289
310
  * @param fullHex The full hex string (with dashes)
290
- * @returns A new Guid instance
311
+ * @returns A new Guid instance with __version attached
291
312
  */
292
313
  static fromFullHex(fullHex) {
293
- return new Guid(fullHex);
314
+ return GuidBuffer.withVersion(new GuidBuffer(fullHex));
294
315
  }
295
316
  /**
296
317
  * Factory method to create a GUID from a short hex string.
297
318
  * @param shortHex The short hex string (without dashes)
298
- * @returns A new Guid instance
319
+ * @returns A new Guid instance with __version attached
299
320
  */
300
321
  static fromShortHex(shortHex) {
301
- return new Guid(shortHex);
322
+ return GuidBuffer.withVersion(new GuidBuffer(shortHex));
302
323
  }
303
324
  /**
304
325
  * Factory method to create a GUID from a base64 string.
305
326
  * @param base64 The base64 encoded string
306
- * @returns A new Guid instance
327
+ * @returns A new Guid instance with __version attached
307
328
  */
308
329
  static fromBase64(base64) {
309
- return new Guid(base64);
330
+ return GuidBuffer.withVersion(new GuidBuffer(base64));
310
331
  }
311
332
  /**
312
333
  * Factory method to create a GUID from a bigint.
313
334
  * @param bigint The bigint value
314
- * @returns A new Guid instance
335
+ * @returns A new Guid instance with __version attached
315
336
  */
316
337
  static fromBigInt(bigint) {
317
- return new Guid(bigint);
338
+ return GuidBuffer.withVersion(new GuidBuffer(bigint));
318
339
  }
319
340
  /**
320
341
  * Factory method to create a GUID from a raw buffer.
321
342
  * @param buffer The raw 16-byte buffer
322
- * @returns A new Guid instance
343
+ * @returns A new Guid instance with __version attached
323
344
  */
324
345
  static fromBuffer(buffer) {
325
- return new Guid(buffer);
346
+ return GuidBuffer.withVersion(new GuidBuffer(buffer));
326
347
  }
327
348
  /**
328
349
  * Factory method to create a GUID from a raw Uint8Array.
329
350
  * This converts the Uint8Array to a Buffer first.
330
351
  * @param bytes The raw 16-byte Uint8Array
331
- * @returns A new Guid instance
352
+ * @returns A new Guid instance with __version attached
332
353
  */
333
354
  static fromUint8Array(bytes) {
334
- return new Guid(Buffer.from(bytes));
355
+ return GuidBuffer.withVersion(new GuidBuffer(Buffer.from(bytes)));
335
356
  }
336
357
  /**
337
358
  * Creates a namespace-based v3 GUID (MD5 hash).
338
359
  * Use this for deterministic GUIDs based on a namespace and name.
339
360
  * @param namespace The namespace GUID (e.g., uuid.v3.DNS)
340
361
  * @param name The name to hash within the namespace
341
- * @returns A new Guid instance containing the v3 GUID
362
+ * @returns A new Guid instance containing the v3 GUID with __version attached
342
363
  * @example
343
364
  * const guid = Guid.v3('example.com', uuid.v3.DNS);
344
365
  */
345
366
  static v3(name, namespace) {
346
367
  try {
347
368
  const namespaceStr = Buffer.isBuffer(namespace)
348
- ? Guid.toFullHexGuid(namespace.toString('hex'))
369
+ ? GuidBuffer.toFullHexGuid(namespace.toString('hex'))
349
370
  : namespace;
350
371
  const v3Guid = uuid.v3(name, namespaceStr);
351
- return new Guid(v3Guid);
372
+ return GuidBuffer.withVersion(new GuidBuffer(v3Guid));
352
373
  }
353
374
  catch (error) {
354
375
  if (error instanceof ecies_lib_1.GuidError) {
@@ -363,17 +384,17 @@ class Guid {
363
384
  * Preferred over v3 as SHA-1 is stronger than MD5.
364
385
  * @param namespace The namespace GUID (e.g., uuid.v5.DNS)
365
386
  * @param name The name to hash within the namespace
366
- * @returns A new Guid instance containing the v5 GUID
387
+ * @returns A new Guid instance containing the v5 GUID with __version attached
367
388
  * @example
368
389
  * const guid = Guid.v5('example.com', uuid.v5.DNS);
369
390
  */
370
391
  static v5(name, namespace) {
371
392
  try {
372
393
  const namespaceStr = Buffer.isBuffer(namespace)
373
- ? Guid.toFullHexGuid(namespace.toString('hex'))
394
+ ? GuidBuffer.toFullHexGuid(namespace.toString('hex'))
374
395
  : namespace;
375
396
  const v5Guid = uuid.v5(name, namespaceStr);
376
- return new Guid(v5Guid);
397
+ return GuidBuffer.withVersion(new GuidBuffer(v5Guid));
377
398
  }
378
399
  catch (error) {
379
400
  if (error instanceof ecies_lib_1.GuidError) {
@@ -400,7 +421,7 @@ class Guid {
400
421
  get asFullHexGuid() {
401
422
  if (!this._cachedFullHex) {
402
423
  const hexString = this._value.toString('hex');
403
- this._cachedFullHex = Guid.toFullHexGuid(hexString);
424
+ this._cachedFullHex = GuidBuffer.toFullHexGuid(hexString);
404
425
  }
405
426
  return this._cachedFullHex;
406
427
  }
@@ -422,7 +443,7 @@ class Guid {
422
443
  */
423
444
  get asShortHexGuid() {
424
445
  if (!this._cachedShortHex) {
425
- this._cachedShortHex = Guid.toShortHexGuid(this.asFullHexGuid);
446
+ this._cachedShortHex = GuidBuffer.toShortHexGuid(this.asFullHexGuid);
426
447
  }
427
448
  return this._cachedShortHex;
428
449
  }
@@ -464,10 +485,10 @@ class Guid {
464
485
  * @returns True if the value is a boundary value.
465
486
  */
466
487
  static isBoundaryValue(value) {
467
- return (value === Guid.BOUNDARY_VALUES.ALL_ZEROS_FULL ||
468
- value === Guid.BOUNDARY_VALUES.ALL_ZEROS_SHORT ||
469
- value === Guid.BOUNDARY_VALUES.ALL_FS_FULL ||
470
- value === Guid.BOUNDARY_VALUES.ALL_FS_SHORT);
488
+ return (value === GuidBuffer.BOUNDARY_VALUES.ALL_ZEROS_FULL ||
489
+ value === GuidBuffer.BOUNDARY_VALUES.ALL_ZEROS_SHORT ||
490
+ value === GuidBuffer.BOUNDARY_VALUES.ALL_FS_FULL ||
491
+ value === GuidBuffer.BOUNDARY_VALUES.ALL_FS_SHORT);
471
492
  }
472
493
  /**
473
494
  * Verifies if a given GUID is valid for the given brand.
@@ -480,7 +501,7 @@ class Guid {
480
501
  return false;
481
502
  }
482
503
  try {
483
- const verifyFunc = Guid.VerifyFunctions[guidBrand];
504
+ const verifyFunc = GuidBuffer.VerifyFunctions[guidBrand];
484
505
  return verifyFunc(guid);
485
506
  }
486
507
  catch {
@@ -493,7 +514,7 @@ class Guid {
493
514
  * @returns The length of the GUID for the given brand.
494
515
  */
495
516
  static guidBrandToLength(guidBrand) {
496
- const length = Guid.LengthMap[guidBrand];
517
+ const length = GuidBuffer.LengthMap[guidBrand];
497
518
  if (length <= 0) {
498
519
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuidUnknownBrand, guidBrand);
499
520
  }
@@ -509,7 +530,7 @@ class Guid {
509
530
  if (length <= 0) {
510
531
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuidUnknownLength, undefined, length);
511
532
  }
512
- const brand = Guid.ReverseLengthMap[length];
533
+ const brand = GuidBuffer.ReverseLengthMap[length];
513
534
  if (!brand || brand === ecies_lib_1.GuidBrandType.Unknown) {
514
535
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuidUnknownLength, undefined, length);
515
536
  }
@@ -530,16 +551,16 @@ class Guid {
530
551
  if (fullHexGuidValue === null || fullHexGuidValue === undefined) {
531
552
  return false;
532
553
  }
533
- const expectedLength = Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.FullHexGuid);
554
+ const expectedLength = GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.FullHexGuid);
534
555
  const strValue = String(fullHexGuidValue);
535
556
  if (strValue.length !== expectedLength) {
536
557
  return false;
537
558
  }
538
559
  // Boundary values are always valid
539
- if (Guid.isBoundaryValue(strValue)) {
560
+ if (GuidBuffer.isBoundaryValue(strValue)) {
540
561
  return true;
541
562
  }
542
- return Guid.validateUuid(strValue);
563
+ return GuidBuffer.validateUuid(strValue);
543
564
  }
544
565
  catch {
545
566
  return false;
@@ -555,15 +576,15 @@ class Guid {
555
576
  if (shortHexGuidValue === null || shortHexGuidValue === undefined) {
556
577
  return false;
557
578
  }
558
- const expectedLength = Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.ShortHexGuid);
579
+ const expectedLength = GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.ShortHexGuid);
559
580
  const strValue = String(shortHexGuidValue);
560
581
  if (strValue.length !== expectedLength) {
561
582
  return false;
562
583
  }
563
584
  try {
564
- const fullHexGuid = Guid.toFullHexGuid(strValue);
585
+ const fullHexGuid = GuidBuffer.toFullHexGuid(strValue);
565
586
  // Boundary values are always valid
566
- if (Guid.isBoundaryValue(fullHexGuid)) {
587
+ if (GuidBuffer.isBoundaryValue(fullHexGuid)) {
567
588
  return true;
568
589
  }
569
590
  return uuid.validate(fullHexGuid);
@@ -590,20 +611,20 @@ class Guid {
590
611
  if (typeof value === 'bigint') {
591
612
  valueLength = value.toString(16).length;
592
613
  }
593
- else if (Guid.isBufferLike(value)) {
614
+ else if (GuidBuffer.isBufferLike(value)) {
594
615
  valueLength = value.length;
595
616
  }
596
617
  else {
597
618
  valueLength = String(value).length;
598
619
  }
599
- const result = valueLength === Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.Base64Guid);
620
+ const result = valueLength === GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.Base64Guid);
600
621
  if (result) {
601
622
  try {
602
- const fromBase64 = Guid.toRawGuidPlatformBuffer(value);
623
+ const fromBase64 = GuidBuffer.toRawGuidPlatformBuffer(value);
603
624
  const hexString = fromBase64.toString('hex');
604
- const fullHexGuid = Guid.toFullHexGuid(hexString);
625
+ const fullHexGuid = GuidBuffer.toFullHexGuid(hexString);
605
626
  // Boundary values are always valid
606
- if (Guid.isBoundaryValue(fullHexGuid)) {
627
+ if (GuidBuffer.isBoundaryValue(fullHexGuid)) {
607
628
  return true;
608
629
  }
609
630
  return uuid.validate(fullHexGuid);
@@ -628,12 +649,12 @@ class Guid {
628
649
  if (value === null || value === undefined) {
629
650
  return false;
630
651
  }
631
- const expectedLength = Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.RawGuidPlatformBuffer);
652
+ const expectedLength = GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.RawGuidPlatformBuffer);
632
653
  let valueLength;
633
654
  if (typeof value === 'bigint') {
634
655
  valueLength = value.toString(16).length;
635
656
  }
636
- else if (Guid.isBufferLike(value)) {
657
+ else if (GuidBuffer.isBufferLike(value)) {
637
658
  valueLength = value.length;
638
659
  }
639
660
  else {
@@ -643,18 +664,18 @@ class Guid {
643
664
  return false;
644
665
  }
645
666
  try {
646
- if (!Guid.isBufferLike(value)) {
667
+ if (!GuidBuffer.isBufferLike(value)) {
647
668
  return false;
648
669
  }
649
670
  // Convert Uint8Array to Buffer if needed
650
671
  const buffer = Buffer.isBuffer(value) ? value : Buffer.from(value);
651
672
  const hexString = buffer.toString('hex');
652
- const fullHexGuid = Guid.toFullHexGuid(hexString);
673
+ const fullHexGuid = GuidBuffer.toFullHexGuid(hexString);
653
674
  // Boundary values are always valid
654
- if (Guid.isBoundaryValue(fullHexGuid)) {
675
+ if (GuidBuffer.isBoundaryValue(fullHexGuid)) {
655
676
  return true;
656
677
  }
657
- return Guid.validateUuid(fullHexGuid);
678
+ return GuidBuffer.validateUuid(fullHexGuid);
658
679
  }
659
680
  catch {
660
681
  return false;
@@ -677,13 +698,13 @@ class Guid {
677
698
  if (typeof value !== 'bigint') {
678
699
  return false;
679
700
  }
680
- if (value < 0n || value > Guid.MAX_BIGINT_VALUE) {
701
+ if (value < 0n || value > GuidBuffer.MAX_BIGINT_VALUE) {
681
702
  return false;
682
703
  }
683
704
  try {
684
- const fromBigInt = Guid.toFullHexFromBigInt(value);
705
+ const fromBigInt = GuidBuffer.toFullHexFromBigInt(value);
685
706
  // Boundary values are always valid
686
- if (Guid.isBoundaryValue(fromBigInt)) {
707
+ if (GuidBuffer.isBoundaryValue(fromBigInt)) {
687
708
  return true;
688
709
  }
689
710
  return uuid.validate(fromBigInt);
@@ -708,11 +729,11 @@ class Guid {
708
729
  if (typeof value === 'bigint') {
709
730
  return ecies_lib_1.GuidBrandType.BigIntGuid;
710
731
  }
711
- const isBuffer = Guid.isBufferLike(value);
732
+ const isBuffer = GuidBuffer.isBufferLike(value);
712
733
  const expectedLength = isBuffer
713
734
  ? value.length
714
735
  : String(value).length;
715
- return Guid.lengthToGuidBrand(expectedLength, isBuffer);
736
+ return GuidBuffer.lengthToGuidBrand(expectedLength, isBuffer);
716
737
  }
717
738
  /**
718
739
  * Converts a given short hex GUID to a full hex GUID.
@@ -734,32 +755,34 @@ class Guid {
734
755
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuid);
735
756
  }
736
757
  if (typeof guid === 'bigint') {
737
- return Guid.toFullHexFromBigInt(guid);
758
+ return GuidBuffer.toFullHexFromBigInt(guid);
738
759
  }
739
- else if (Guid.isBufferLike(guid) &&
760
+ else if (GuidBuffer.isBufferLike(guid) &&
740
761
  guid.length ===
741
- Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.RawGuidPlatformBuffer)) {
762
+ GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.RawGuidPlatformBuffer)) {
742
763
  const hexString = guid.toString('hex');
743
764
  const shortHex = hexString;
744
- return Guid.shortGuidToFullGuid(shortHex);
765
+ return GuidBuffer.shortGuidToFullGuid(shortHex);
745
766
  }
746
- else if (Guid.isBufferLike(guid)) {
767
+ else if (GuidBuffer.isBufferLike(guid)) {
747
768
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuid);
748
769
  }
749
770
  // all remaining cases are string types
750
771
  const strValue = String(guid);
751
- if (strValue.length === Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.ShortHexGuid)) {
772
+ if (strValue.length ===
773
+ GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.ShortHexGuid)) {
752
774
  // short hex guid
753
- return Guid.shortGuidToFullGuid(strValue);
775
+ return GuidBuffer.shortGuidToFullGuid(strValue);
754
776
  }
755
- else if (strValue.length === Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.FullHexGuid)) {
777
+ else if (strValue.length ===
778
+ GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.FullHexGuid)) {
756
779
  // already a full hex guid
757
780
  return strValue;
758
781
  }
759
- else if (strValue.length === Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.Base64Guid)) {
782
+ else if (strValue.length === GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.Base64Guid)) {
760
783
  // base64 guid
761
784
  const shortGuid = Buffer.from(strValue, 'base64').toString('hex');
762
- return Guid.shortGuidToFullGuid(shortGuid);
785
+ return GuidBuffer.shortGuidToFullGuid(shortGuid);
763
786
  }
764
787
  else {
765
788
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuid);
@@ -770,28 +793,30 @@ class Guid {
770
793
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuid);
771
794
  }
772
795
  if (typeof guid === 'bigint') {
773
- const fullHex = Guid.toFullHexFromBigInt(guid);
796
+ const fullHex = GuidBuffer.toFullHexFromBigInt(guid);
774
797
  return fullHex.replace(/-/g, '');
775
798
  }
776
- else if (Guid.isBufferLike(guid) &&
799
+ else if (GuidBuffer.isBufferLike(guid) &&
777
800
  guid.length ===
778
- Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.RawGuidPlatformBuffer)) {
801
+ GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.RawGuidPlatformBuffer)) {
779
802
  return guid.toString('hex');
780
803
  }
781
- else if (Guid.isBufferLike(guid)) {
804
+ else if (GuidBuffer.isBufferLike(guid)) {
782
805
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuid);
783
806
  }
784
807
  // all remaining cases are string types
785
808
  const strValue = String(guid);
786
- if (strValue.length === Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.ShortHexGuid)) {
809
+ if (strValue.length ===
810
+ GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.ShortHexGuid)) {
787
811
  // already a short hex guid
788
812
  return strValue;
789
813
  }
790
- else if (strValue.length === Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.FullHexGuid)) {
814
+ else if (strValue.length ===
815
+ GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.FullHexGuid)) {
791
816
  // full hex guid
792
817
  return strValue.replace(/-/g, '');
793
818
  }
794
- else if (strValue.length === Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.Base64Guid)) {
819
+ else if (strValue.length === GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.Base64Guid)) {
795
820
  // base64 guid
796
821
  return Buffer.from(strValue, 'base64').toString('hex');
797
822
  }
@@ -805,7 +830,7 @@ class Guid {
805
830
  * @returns The bigint as a full hex GUID.
806
831
  */
807
832
  static toFullHexFromBigInt(bigInt) {
808
- if (bigInt < 0n || bigInt > Guid.MAX_BIGINT_VALUE) {
833
+ if (bigInt < 0n || bigInt > GuidBuffer.MAX_BIGINT_VALUE) {
809
834
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuid);
810
835
  }
811
836
  const uuidBigInt = bigInt.toString(16).padStart(32, '0');
@@ -830,14 +855,14 @@ class Guid {
830
855
  * @returns The GUID value as a raw GUID buffer.
831
856
  */
832
857
  static toRawGuidPlatformBuffer(value) {
833
- const expectedBrand = Guid.whichBrand(value);
858
+ const expectedBrand = GuidBuffer.whichBrand(value);
834
859
  let rawGuidBufferResult = Buffer.alloc(0);
835
860
  switch (expectedBrand) {
836
861
  case ecies_lib_1.GuidBrandType.FullHexGuid:
837
- rawGuidBufferResult = Buffer.from(Guid.toShortHexGuid(value), 'hex');
862
+ rawGuidBufferResult = Buffer.from(GuidBuffer.toShortHexGuid(value), 'hex');
838
863
  break;
839
864
  case ecies_lib_1.GuidBrandType.ShortHexGuid:
840
- rawGuidBufferResult = Buffer.from(Guid.toShortHexGuid(value), 'hex');
865
+ rawGuidBufferResult = Buffer.from(GuidBuffer.toShortHexGuid(value), 'hex');
841
866
  break;
842
867
  case ecies_lib_1.GuidBrandType.Base64Guid:
843
868
  // Ensure value is a string before using it with Buffer.from
@@ -861,13 +886,13 @@ class Guid {
861
886
  }
862
887
  break;
863
888
  case ecies_lib_1.GuidBrandType.BigIntGuid:
864
- rawGuidBufferResult = Buffer.from(Guid.toShortHexGuid(Guid.toFullHexFromBigInt(value)), 'hex');
889
+ rawGuidBufferResult = Buffer.from(GuidBuffer.toShortHexGuid(GuidBuffer.toFullHexFromBigInt(value)), 'hex');
865
890
  break;
866
891
  default:
867
892
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuidUnknownBrand);
868
893
  }
869
894
  if (rawGuidBufferResult.length !==
870
- Guid.guidBrandToLength(ecies_lib_1.GuidBrandType.RawGuidPlatformBuffer)) {
895
+ GuidBuffer.guidBrandToLength(ecies_lib_1.GuidBrandType.RawGuidPlatformBuffer)) {
871
896
  throw new ecies_lib_1.GuidError(ecies_lib_1.GuidErrorType.InvalidGuidUnknownLength, undefined, rawGuidBufferResult.length);
872
897
  }
873
898
  return rawGuidBufferResult;
@@ -914,14 +939,14 @@ class Guid {
914
939
  * @returns True if the GUID is null, undefined, or empty
915
940
  */
916
941
  static isNilOrEmpty(guid) {
917
- return !guid || (guid instanceof Guid && guid.isEmpty());
942
+ return !guid || (guid instanceof GuidBuffer && guid.isEmpty());
918
943
  }
919
944
  /**
920
945
  * Creates a new Guid instance with the same value as this one.
921
- * @returns A new Guid instance with identical value
946
+ * @returns A new Guid instance with identical value and __version attached
922
947
  */
923
948
  clone() {
924
- return new Guid(Buffer.from(this._value));
949
+ return GuidBuffer.withVersion(new GuidBuffer(Buffer.from(this._value)));
925
950
  }
926
951
  /**
927
952
  * Returns the hash code for this GUID based on its buffer content.
@@ -943,7 +968,7 @@ class Guid {
943
968
  */
944
969
  getVersion() {
945
970
  // Skip boundary values
946
- if (Guid.isBoundaryValue(this.asFullHexGuid)) {
971
+ if (GuidBuffer.isBoundaryValue(this.asFullHexGuid)) {
947
972
  return undefined;
948
973
  }
949
974
  // Version is in bits 48-51 (byte 6, high nibble)
@@ -966,7 +991,7 @@ class Guid {
966
991
  */
967
992
  isValidV4() {
968
993
  // Boundary values are considered valid
969
- if (Guid.isBoundaryValue(this.asFullHexGuid)) {
994
+ if (GuidBuffer.isBoundaryValue(this.asFullHexGuid)) {
970
995
  return true;
971
996
  }
972
997
  const version = this.getVersion();
@@ -1029,12 +1054,12 @@ class Guid {
1029
1054
  }
1030
1055
  /**
1031
1056
  * Creates a v1 GUID (time-based).
1032
- * @returns A new Guid instance containing a v1 GUID
1057
+ * @returns A new Guid instance containing a v1 GUID with __version attached
1033
1058
  */
1034
1059
  static v1() {
1035
1060
  try {
1036
1061
  const v1Guid = uuid.v1();
1037
- return new Guid(v1Guid);
1062
+ return GuidBuffer.withVersion(new GuidBuffer(v1Guid));
1038
1063
  }
1039
1064
  catch (error) {
1040
1065
  if (error instanceof ecies_lib_1.GuidError)
@@ -1061,22 +1086,23 @@ class Guid {
1061
1086
  }
1062
1087
  /**
1063
1088
  * Creates a GUID from URL-safe base64.
1089
+ * @returns A new Guid instance with __version attached
1064
1090
  */
1065
1091
  static fromUrlSafeBase64(urlSafe) {
1066
1092
  const base64 = urlSafe
1067
1093
  .replace(/-/g, '+')
1068
1094
  .replace(/_/g, '/')
1069
1095
  .padEnd(24, '=');
1070
- return new Guid(base64);
1096
+ return GuidBuffer.withVersion(new GuidBuffer(base64));
1071
1097
  }
1072
1098
  /**
1073
1099
  * Alias for isRawGuidPlatformBuffer for backward compatibility
1074
1100
  */
1075
- static isRawGuidBuffer = Guid.isRawGuidPlatformBuffer;
1101
+ static isRawGuidBuffer = GuidBuffer.isRawGuidPlatformBuffer;
1076
1102
  /**
1077
1103
  * Alias for toRawGuidPlatformBuffer for backward compatibility
1078
1104
  */
1079
- static toRawGuidBuffer = Guid.toRawGuidPlatformBuffer;
1105
+ static toRawGuidBuffer = GuidBuffer.toRawGuidPlatformBuffer;
1080
1106
  }
1081
- exports.Guid = Guid;
1107
+ exports.GuidBuffer = GuidBuffer;
1082
1108
  //# sourceMappingURL=guid.js.map