@digitaldefiance/ecies-lib 4.4.13 → 4.4.15

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 (597) hide show
  1. package/package.json +5 -4
  2. package/src/builders/ecies-builder.d.ts +18 -0
  3. package/src/builders/ecies-builder.d.ts.map +1 -0
  4. package/src/builders/ecies-builder.js +34 -0
  5. package/src/builders/ecies-builder.js.map +1 -0
  6. package/src/builders/{index.ts → index.d.ts} +1 -1
  7. package/src/builders/index.d.ts.map +1 -0
  8. package/src/builders/index.js +9 -0
  9. package/src/builders/index.js.map +1 -0
  10. package/src/builders/member-builder.d.ts +51 -0
  11. package/src/builders/member-builder.d.ts.map +1 -0
  12. package/src/builders/member-builder.js +101 -0
  13. package/src/builders/member-builder.js.map +1 -0
  14. package/src/constants.d.ts +60 -0
  15. package/src/constants.d.ts.map +1 -0
  16. package/src/constants.js +457 -0
  17. package/src/constants.js.map +1 -0
  18. package/src/core/errors/crypto-error.d.ts +34 -0
  19. package/src/core/errors/crypto-error.d.ts.map +1 -0
  20. package/src/core/errors/crypto-error.js +60 -0
  21. package/src/core/errors/crypto-error.js.map +1 -0
  22. package/src/core/{index.ts → index.d.ts} +1 -1
  23. package/src/core/index.d.ts.map +1 -0
  24. package/src/core/index.js +9 -0
  25. package/src/core/index.js.map +1 -0
  26. package/src/core/types/result.d.ts +16 -0
  27. package/src/core/types/result.d.ts.map +1 -0
  28. package/src/core/types/result.js +16 -0
  29. package/src/core/types/result.js.map +1 -0
  30. package/src/email-string.d.ts +42 -0
  31. package/src/email-string.d.ts.map +1 -0
  32. package/src/email-string.js +72 -0
  33. package/src/email-string.js.map +1 -0
  34. package/src/enumerations/disposed-error-type.d.ts +12 -0
  35. package/src/enumerations/disposed-error-type.d.ts.map +1 -0
  36. package/src/enumerations/disposed-error-type.js +16 -0
  37. package/src/enumerations/disposed-error-type.js.map +1 -0
  38. package/src/enumerations/ecies-cipher-suite.d.ts +4 -0
  39. package/src/enumerations/ecies-cipher-suite.d.ts.map +1 -0
  40. package/src/enumerations/ecies-cipher-suite.js +9 -0
  41. package/src/enumerations/ecies-cipher-suite.js.map +1 -0
  42. package/src/enumerations/ecies-encryption-type.d.ts +11 -0
  43. package/src/enumerations/ecies-encryption-type.d.ts.map +1 -0
  44. package/src/enumerations/ecies-encryption-type.js +30 -0
  45. package/src/enumerations/ecies-encryption-type.js.map +1 -0
  46. package/src/enumerations/ecies-error-type.d.ts +44 -0
  47. package/src/enumerations/ecies-error-type.d.ts.map +1 -0
  48. package/src/enumerations/ecies-error-type.js +48 -0
  49. package/src/enumerations/ecies-error-type.js.map +1 -0
  50. package/src/enumerations/ecies-string-key.d.ts +192 -0
  51. package/src/enumerations/ecies-string-key.d.ts.map +1 -0
  52. package/src/enumerations/ecies-string-key.js +202 -0
  53. package/src/enumerations/ecies-string-key.js.map +1 -0
  54. package/src/enumerations/ecies-version.d.ts +4 -0
  55. package/src/enumerations/ecies-version.d.ts.map +1 -0
  56. package/src/enumerations/ecies-version.js +8 -0
  57. package/src/enumerations/ecies-version.js.map +1 -0
  58. package/src/enumerations/guid-brand-type.d.ts +27 -0
  59. package/src/enumerations/guid-brand-type.d.ts.map +1 -0
  60. package/src/enumerations/guid-brand-type.js +31 -0
  61. package/src/enumerations/guid-brand-type.js.map +1 -0
  62. package/src/enumerations/guid-error-type.d.ts +7 -0
  63. package/src/enumerations/guid-error-type.d.ts.map +1 -0
  64. package/src/enumerations/guid-error-type.js +11 -0
  65. package/src/enumerations/guid-error-type.js.map +1 -0
  66. package/src/enumerations/id-provider-error-type.d.ts +43 -0
  67. package/src/enumerations/id-provider-error-type.d.ts.map +1 -0
  68. package/src/enumerations/id-provider-error-type.js +47 -0
  69. package/src/enumerations/id-provider-error-type.js.map +1 -0
  70. package/src/enumerations/{index.ts → index.d.ts} +1 -0
  71. package/src/enumerations/index.d.ts.map +1 -0
  72. package/src/enumerations/index.js +21 -0
  73. package/src/enumerations/index.js.map +1 -0
  74. package/src/enumerations/invalid-email-type.d.ts +6 -0
  75. package/src/enumerations/invalid-email-type.d.ts.map +1 -0
  76. package/src/enumerations/invalid-email-type.js +10 -0
  77. package/src/enumerations/invalid-email-type.js.map +1 -0
  78. package/src/enumerations/length-encoding-type.d.ts +7 -0
  79. package/src/enumerations/length-encoding-type.d.ts.map +1 -0
  80. package/src/enumerations/length-encoding-type.js +11 -0
  81. package/src/enumerations/length-encoding-type.js.map +1 -0
  82. package/src/enumerations/length-error-type.d.ts +6 -0
  83. package/src/enumerations/length-error-type.d.ts.map +1 -0
  84. package/src/enumerations/length-error-type.js +10 -0
  85. package/src/enumerations/length-error-type.js.map +1 -0
  86. package/src/enumerations/member-error-type.d.ts +87 -0
  87. package/src/enumerations/member-error-type.d.ts.map +1 -0
  88. package/src/enumerations/member-error-type.js +91 -0
  89. package/src/enumerations/member-error-type.js.map +1 -0
  90. package/src/enumerations/{member-type.ts → member-type.d.ts} +6 -7
  91. package/src/enumerations/member-type.d.ts.map +1 -0
  92. package/src/enumerations/member-type.js +19 -0
  93. package/src/enumerations/member-type.js.map +1 -0
  94. package/src/enumerations/password-login-error-type.d.ts +5 -0
  95. package/src/enumerations/password-login-error-type.d.ts.map +1 -0
  96. package/src/enumerations/password-login-error-type.js +9 -0
  97. package/src/enumerations/password-login-error-type.js.map +1 -0
  98. package/src/enumerations/pbkdf2-error-type.d.ts +6 -0
  99. package/src/enumerations/pbkdf2-error-type.d.ts.map +1 -0
  100. package/src/enumerations/pbkdf2-error-type.js +10 -0
  101. package/src/enumerations/pbkdf2-error-type.js.map +1 -0
  102. package/src/enumerations/pbkdf2-profile.d.ts +6 -0
  103. package/src/enumerations/pbkdf2-profile.d.ts.map +1 -0
  104. package/src/enumerations/pbkdf2-profile.js +10 -0
  105. package/src/enumerations/pbkdf2-profile.js.map +1 -0
  106. package/src/enumerations/secure-storage-error-type.d.ts +6 -0
  107. package/src/enumerations/secure-storage-error-type.d.ts.map +1 -0
  108. package/src/enumerations/secure-storage-error-type.js +10 -0
  109. package/src/enumerations/secure-storage-error-type.js.map +1 -0
  110. package/src/errors/disposed.d.ts +22 -0
  111. package/src/errors/disposed.d.ts.map +1 -0
  112. package/src/errors/disposed.js +32 -0
  113. package/src/errors/disposed.js.map +1 -0
  114. package/src/errors/ecies.d.ts +52 -0
  115. package/src/errors/ecies.d.ts.map +1 -0
  116. package/src/errors/ecies.js +82 -0
  117. package/src/errors/ecies.js.map +1 -0
  118. package/src/errors/guid.d.ts +49 -0
  119. package/src/errors/guid.d.ts.map +1 -0
  120. package/src/errors/guid.js +100 -0
  121. package/src/errors/guid.js.map +1 -0
  122. package/src/errors/id-provider.d.ts +23 -0
  123. package/src/errors/id-provider.d.ts.map +1 -0
  124. package/src/errors/id-provider.js +33 -0
  125. package/src/errors/id-provider.js.map +1 -0
  126. package/src/errors/{index.ts → index.d.ts} +1 -0
  127. package/src/errors/index.d.ts.map +1 -0
  128. package/src/errors/index.js +13 -0
  129. package/src/errors/index.js.map +1 -0
  130. package/src/errors/invalid-email.d.ts +8 -0
  131. package/src/errors/invalid-email.d.ts.map +1 -0
  132. package/src/errors/invalid-email.js +19 -0
  133. package/src/errors/invalid-email.js.map +1 -0
  134. package/src/errors/length.d.ts +7 -0
  135. package/src/errors/length.d.ts.map +1 -0
  136. package/src/errors/length.js +15 -0
  137. package/src/errors/length.js.map +1 -0
  138. package/src/errors/member.d.ts +7 -0
  139. package/src/errors/member.d.ts.map +1 -0
  140. package/src/errors/member.js +15 -0
  141. package/src/errors/member.js.map +1 -0
  142. package/src/errors/pbkdf2.d.ts +7 -0
  143. package/src/errors/pbkdf2.d.ts.map +1 -0
  144. package/src/errors/pbkdf2.js +15 -0
  145. package/src/errors/pbkdf2.js.map +1 -0
  146. package/src/errors/secure-storage.d.ts +7 -0
  147. package/src/errors/secure-storage.d.ts.map +1 -0
  148. package/src/errors/secure-storage.js +16 -0
  149. package/src/errors/secure-storage.js.map +1 -0
  150. package/src/errors/simple-ecies.d.ts +6 -0
  151. package/src/errors/simple-ecies.d.ts.map +1 -0
  152. package/src/errors/simple-ecies.js +16 -0
  153. package/src/errors/simple-ecies.js.map +1 -0
  154. package/src/errors/simple-test-error.d.ts +4 -0
  155. package/src/errors/simple-test-error.d.ts.map +1 -0
  156. package/src/errors/simple-test-error.js +11 -0
  157. package/src/errors/simple-test-error.js.map +1 -0
  158. package/src/i18n-setup.d.ts +32 -0
  159. package/src/i18n-setup.d.ts.map +1 -0
  160. package/src/i18n-setup.js +109 -0
  161. package/src/i18n-setup.js.map +1 -0
  162. package/src/{index.ts → index.d.ts} +12 -72
  163. package/src/index.d.ts.map +1 -0
  164. package/src/index.js +146 -0
  165. package/src/index.js.map +1 -0
  166. package/src/interfaces/checksum-config.d.ts +5 -0
  167. package/src/interfaces/checksum-config.d.ts.map +1 -0
  168. package/src/interfaces/checksum-config.js +3 -0
  169. package/src/interfaces/checksum-config.js.map +1 -0
  170. package/src/interfaces/checksum-consts.d.ts +11 -0
  171. package/src/interfaces/checksum-consts.d.ts.map +1 -0
  172. package/src/interfaces/checksum-consts.js +3 -0
  173. package/src/interfaces/checksum-consts.js.map +1 -0
  174. package/src/interfaces/configuration-provenance.d.ts +43 -0
  175. package/src/interfaces/configuration-provenance.d.ts.map +1 -0
  176. package/src/interfaces/configuration-provenance.js +8 -0
  177. package/src/interfaces/configuration-provenance.js.map +1 -0
  178. package/src/interfaces/constants.d.ts +70 -0
  179. package/src/interfaces/constants.d.ts.map +1 -0
  180. package/src/interfaces/constants.js +3 -0
  181. package/src/interfaces/constants.js.map +1 -0
  182. package/src/interfaces/ecies-config.d.ts +9 -0
  183. package/src/interfaces/ecies-config.d.ts.map +1 -0
  184. package/src/interfaces/ecies-config.js +3 -0
  185. package/src/interfaces/ecies-config.js.map +1 -0
  186. package/src/interfaces/ecies-consts.d.ts +61 -0
  187. package/src/interfaces/ecies-consts.d.ts.map +1 -0
  188. package/src/interfaces/ecies-consts.js +3 -0
  189. package/src/interfaces/ecies-consts.js.map +1 -0
  190. package/src/interfaces/ecies-file-service.d.ts +7 -0
  191. package/src/interfaces/ecies-file-service.d.ts.map +1 -0
  192. package/src/interfaces/ecies-file-service.js +3 -0
  193. package/src/interfaces/ecies-file-service.js.map +1 -0
  194. package/src/interfaces/encrypted-chunk.d.ts +55 -0
  195. package/src/interfaces/encrypted-chunk.d.ts.map +1 -0
  196. package/src/interfaces/encrypted-chunk.js +15 -0
  197. package/src/interfaces/encrypted-chunk.js.map +1 -0
  198. package/src/interfaces/encryption-state.d.ts +18 -0
  199. package/src/interfaces/encryption-state.d.ts.map +1 -0
  200. package/src/interfaces/encryption-state.js +5 -0
  201. package/src/interfaces/encryption-state.js.map +1 -0
  202. package/src/interfaces/frontend-member-operational.d.ts +51 -0
  203. package/src/interfaces/frontend-member-operational.d.ts.map +1 -0
  204. package/src/interfaces/frontend-member-operational.js +3 -0
  205. package/src/interfaces/frontend-member-operational.js.map +1 -0
  206. package/src/interfaces/guid.d.ts +78 -0
  207. package/src/interfaces/guid.d.ts.map +1 -0
  208. package/src/interfaces/guid.js +3 -0
  209. package/src/interfaces/guid.js.map +1 -0
  210. package/src/interfaces/id-provider.d.ts +107 -0
  211. package/src/interfaces/id-provider.d.ts.map +1 -0
  212. package/src/interfaces/id-provider.js +56 -0
  213. package/src/interfaces/id-provider.js.map +1 -0
  214. package/src/interfaces/{index.ts → index.d.ts} +1 -0
  215. package/src/interfaces/index.d.ts.map +1 -0
  216. package/src/interfaces/index.js +16 -0
  217. package/src/interfaces/index.js.map +1 -0
  218. package/src/interfaces/invariant.d.ts +46 -0
  219. package/src/interfaces/invariant.d.ts.map +1 -0
  220. package/src/interfaces/invariant.js +22 -0
  221. package/src/interfaces/invariant.js.map +1 -0
  222. package/src/interfaces/library-error.d.ts +23 -0
  223. package/src/interfaces/library-error.d.ts.map +1 -0
  224. package/src/interfaces/library-error.js +3 -0
  225. package/src/interfaces/library-error.js.map +1 -0
  226. package/src/interfaces/{member-storage.ts → member-storage.d.ts} +10 -11
  227. package/src/interfaces/member-storage.d.ts.map +1 -0
  228. package/src/interfaces/member-storage.js +3 -0
  229. package/src/interfaces/member-storage.js.map +1 -0
  230. package/src/interfaces/{member-with-mnemonic.ts → member-with-mnemonic.d.ts} +3 -3
  231. package/src/interfaces/member-with-mnemonic.d.ts.map +1 -0
  232. package/src/interfaces/member-with-mnemonic.js +3 -0
  233. package/src/interfaces/member-with-mnemonic.js.map +1 -0
  234. package/src/interfaces/member.d.ts +55 -0
  235. package/src/interfaces/member.d.ts.map +1 -0
  236. package/src/interfaces/member.js +3 -0
  237. package/src/interfaces/member.js.map +1 -0
  238. package/src/interfaces/multi-recipient-chunk.d.ts +54 -0
  239. package/src/interfaces/multi-recipient-chunk.d.ts.map +1 -0
  240. package/src/interfaces/multi-recipient-chunk.js +16 -0
  241. package/src/interfaces/multi-recipient-chunk.js.map +1 -0
  242. package/src/interfaces/pbkdf2-config.d.ts +7 -0
  243. package/src/interfaces/pbkdf2-config.d.ts.map +1 -0
  244. package/src/interfaces/pbkdf2-config.js +3 -0
  245. package/src/interfaces/pbkdf2-config.js.map +1 -0
  246. package/src/interfaces/pbkdf2-consts.d.ts +9 -0
  247. package/src/interfaces/pbkdf2-consts.d.ts.map +1 -0
  248. package/src/interfaces/pbkdf2-consts.js +3 -0
  249. package/src/interfaces/pbkdf2-consts.js.map +1 -0
  250. package/src/interfaces/pbkdf2-result.d.ts +6 -0
  251. package/src/interfaces/pbkdf2-result.d.ts.map +1 -0
  252. package/src/interfaces/pbkdf2-result.js +3 -0
  253. package/src/interfaces/pbkdf2-result.js.map +1 -0
  254. package/src/interfaces/stream-config.d.ts +14 -0
  255. package/src/interfaces/stream-config.d.ts.map +1 -0
  256. package/src/interfaces/stream-config.js +11 -0
  257. package/src/interfaces/stream-config.js.map +1 -0
  258. package/src/interfaces/stream-header.d.ts +29 -0
  259. package/src/interfaces/stream-header.d.ts.map +1 -0
  260. package/src/interfaces/stream-header.js +12 -0
  261. package/src/interfaces/stream-header.js.map +1 -0
  262. package/src/interfaces/stream-progress.d.ts +33 -0
  263. package/src/interfaces/stream-progress.d.ts.map +1 -0
  264. package/src/interfaces/stream-progress.js +3 -0
  265. package/src/interfaces/stream-progress.js.map +1 -0
  266. package/src/lib/configuration-provenance-utils.d.ts +11 -0
  267. package/src/lib/configuration-provenance-utils.d.ts.map +1 -0
  268. package/src/lib/configuration-provenance-utils.js +30 -0
  269. package/src/lib/configuration-provenance-utils.js.map +1 -0
  270. package/src/lib/crypto-container.d.ts +25 -0
  271. package/src/lib/crypto-container.d.ts.map +1 -0
  272. package/src/lib/crypto-container.js +50 -0
  273. package/src/lib/crypto-container.js.map +1 -0
  274. package/src/lib/guid.d.ts +344 -0
  275. package/src/lib/guid.d.ts.map +1 -0
  276. package/src/lib/guid.js +919 -0
  277. package/src/lib/guid.js.map +1 -0
  278. package/src/lib/id-providers/custom-provider.d.ts +46 -0
  279. package/src/lib/id-providers/custom-provider.d.ts.map +1 -0
  280. package/src/lib/id-providers/custom-provider.js +89 -0
  281. package/src/lib/id-providers/custom-provider.js.map +1 -0
  282. package/src/lib/id-providers/guidv4-provider.d.ts +56 -0
  283. package/src/lib/id-providers/guidv4-provider.d.ts.map +1 -0
  284. package/src/lib/id-providers/guidv4-provider.js +126 -0
  285. package/src/lib/id-providers/guidv4-provider.js.map +1 -0
  286. package/src/lib/id-providers/{index.ts → index.d.ts} +5 -6
  287. package/src/lib/id-providers/index.d.ts.map +1 -0
  288. package/src/lib/id-providers/index.js +37 -0
  289. package/src/lib/id-providers/index.js.map +1 -0
  290. package/src/lib/id-providers/objectid-provider.d.ts +43 -0
  291. package/src/lib/id-providers/objectid-provider.d.ts.map +1 -0
  292. package/src/lib/id-providers/objectid-provider.js +108 -0
  293. package/src/lib/id-providers/objectid-provider.js.map +1 -0
  294. package/src/lib/id-providers/uuid-provider.d.ts +52 -0
  295. package/src/lib/id-providers/uuid-provider.d.ts.map +1 -0
  296. package/src/lib/id-providers/uuid-provider.js +114 -0
  297. package/src/lib/id-providers/uuid-provider.js.map +1 -0
  298. package/src/lib/{index.ts → index.d.ts} +2 -2
  299. package/src/lib/index.d.ts.map +1 -0
  300. package/src/lib/index.js +9 -0
  301. package/src/lib/index.js.map +1 -0
  302. package/src/lib/invariant-validator.d.ts +59 -0
  303. package/src/lib/invariant-validator.d.ts.map +1 -0
  304. package/src/lib/invariant-validator.js +101 -0
  305. package/src/lib/invariant-validator.js.map +1 -0
  306. package/src/lib/invariants/encryption-algorithm-consistency.d.ts +17 -0
  307. package/src/lib/invariants/encryption-algorithm-consistency.d.ts.map +1 -0
  308. package/src/lib/invariants/encryption-algorithm-consistency.js +53 -0
  309. package/src/lib/invariants/encryption-algorithm-consistency.js.map +1 -0
  310. package/src/lib/invariants/{index.ts → index.d.ts} +1 -0
  311. package/src/lib/invariants/index.d.ts.map +1 -0
  312. package/src/lib/invariants/index.js +7 -0
  313. package/src/lib/invariants/index.js.map +1 -0
  314. package/src/lib/invariants/pbkdf2-profiles-validity.d.ts +16 -0
  315. package/src/lib/invariants/pbkdf2-profiles-validity.d.ts.map +1 -0
  316. package/src/lib/invariants/pbkdf2-profiles-validity.js +62 -0
  317. package/src/lib/invariants/pbkdf2-profiles-validity.js.map +1 -0
  318. package/src/lib/invariants/recipient-id-consistency.d.ts +18 -0
  319. package/src/lib/invariants/recipient-id-consistency.d.ts.map +1 -0
  320. package/src/lib/invariants/recipient-id-consistency.js +35 -0
  321. package/src/lib/invariants/recipient-id-consistency.js.map +1 -0
  322. package/src/lib/multi-recipient-chunk-utils.d.ts +38 -0
  323. package/src/lib/multi-recipient-chunk-utils.d.ts.map +1 -0
  324. package/src/lib/multi-recipient-chunk-utils.js +45 -0
  325. package/src/lib/multi-recipient-chunk-utils.js.map +1 -0
  326. package/src/member.d.ts +92 -0
  327. package/src/member.d.ts.map +1 -0
  328. package/src/member.js +327 -0
  329. package/src/member.js.map +1 -0
  330. package/src/{pbkdf2-profiles.ts → pbkdf2-profiles.d.ts} +2 -2
  331. package/src/pbkdf2-profiles.d.ts.map +1 -0
  332. package/src/pbkdf2-profiles.js +3 -0
  333. package/src/pbkdf2-profiles.js.map +1 -0
  334. package/src/phone-number.d.ts +6 -0
  335. package/src/phone-number.d.ts.map +1 -0
  336. package/src/phone-number.js +22 -0
  337. package/src/phone-number.js.map +1 -0
  338. package/src/regexes.d.ts +7 -0
  339. package/src/regexes.d.ts.map +1 -0
  340. package/src/regexes.js +10 -0
  341. package/src/regexes.js.map +1 -0
  342. package/src/secure-buffer.d.ts +61 -0
  343. package/src/secure-buffer.d.ts.map +1 -0
  344. package/src/secure-buffer.js +205 -0
  345. package/src/secure-buffer.js.map +1 -0
  346. package/src/secure-string.d.ts +46 -0
  347. package/src/secure-string.d.ts.map +1 -0
  348. package/src/secure-string.js +210 -0
  349. package/src/secure-string.js.map +1 -0
  350. package/src/services/aes-gcm.d.ts +57 -0
  351. package/src/services/aes-gcm.d.ts.map +1 -0
  352. package/src/services/aes-gcm.js +146 -0
  353. package/src/services/aes-gcm.js.map +1 -0
  354. package/src/services/chunk-processor.d.ts +31 -0
  355. package/src/services/chunk-processor.d.ts.map +1 -0
  356. package/src/services/chunk-processor.js +149 -0
  357. package/src/services/chunk-processor.js.map +1 -0
  358. package/src/services/ecies/crypto-core.d.ts +72 -0
  359. package/src/services/ecies/crypto-core.d.ts.map +1 -0
  360. package/src/services/ecies/crypto-core.js +209 -0
  361. package/src/services/ecies/crypto-core.js.map +1 -0
  362. package/src/services/ecies/example.d.ts +25 -0
  363. package/src/services/ecies/example.d.ts.map +1 -0
  364. package/src/services/ecies/example.js +128 -0
  365. package/src/services/ecies/example.js.map +1 -0
  366. package/src/services/ecies/file.d.ts +18 -0
  367. package/src/services/ecies/file.d.ts.map +1 -0
  368. package/src/services/ecies/file.js +110 -0
  369. package/src/services/ecies/file.js.map +1 -0
  370. package/src/services/ecies/{index.ts → index.d.ts} +1 -3
  371. package/src/services/ecies/index.d.ts.map +1 -0
  372. package/src/services/ecies/index.js +44 -0
  373. package/src/services/ecies/index.js.map +1 -0
  374. package/src/services/ecies/integration.d.ts +59 -0
  375. package/src/services/ecies/integration.d.ts.map +1 -0
  376. package/src/services/ecies/integration.js +172 -0
  377. package/src/services/ecies/integration.js.map +1 -0
  378. package/src/services/ecies/interfaces.d.ts +54 -0
  379. package/src/services/ecies/interfaces.d.ts.map +1 -0
  380. package/src/services/ecies/interfaces.js +6 -0
  381. package/src/services/ecies/interfaces.js.map +1 -0
  382. package/src/services/ecies/manual-test.d.ts +29 -0
  383. package/src/services/ecies/manual-test.d.ts.map +1 -0
  384. package/src/services/ecies/manual-test.js +171 -0
  385. package/src/services/ecies/manual-test.js.map +1 -0
  386. package/src/services/ecies/multi-recipient.d.ts +56 -0
  387. package/src/services/ecies/multi-recipient.d.ts.map +1 -0
  388. package/src/services/ecies/multi-recipient.js +348 -0
  389. package/src/services/ecies/multi-recipient.js.map +1 -0
  390. package/src/services/ecies/service.d.ts +120 -0
  391. package/src/services/ecies/service.d.ts.map +1 -0
  392. package/src/services/ecies/service.js +214 -0
  393. package/src/services/ecies/service.js.map +1 -0
  394. package/src/services/ecies/signature.d.ts +27 -0
  395. package/src/services/ecies/signature.d.ts.map +1 -0
  396. package/src/services/ecies/signature.js +76 -0
  397. package/src/services/ecies/signature.js.map +1 -0
  398. package/src/services/ecies/single-recipient.d.ts +46 -0
  399. package/src/services/ecies/single-recipient.d.ts.map +1 -0
  400. package/src/services/ecies/single-recipient.js +326 -0
  401. package/src/services/ecies/single-recipient.js.map +1 -0
  402. package/src/services/encryption-stream.d.ts +71 -0
  403. package/src/services/encryption-stream.d.ts.map +1 -0
  404. package/src/services/encryption-stream.js +299 -0
  405. package/src/services/encryption-stream.js.map +1 -0
  406. package/src/services/{index.ts → index.d.ts} +1 -0
  407. package/src/services/index.d.ts.map +1 -0
  408. package/src/services/index.js +14 -0
  409. package/src/services/index.js.map +1 -0
  410. package/src/services/multi-recipient-processor.d.ts +35 -0
  411. package/src/services/multi-recipient-processor.d.ts.map +1 -0
  412. package/src/services/multi-recipient-processor.js +293 -0
  413. package/src/services/multi-recipient-processor.js.map +1 -0
  414. package/src/services/password-login.d.ts +47 -0
  415. package/src/services/password-login.d.ts.map +1 -0
  416. package/src/services/password-login.js +119 -0
  417. package/src/services/password-login.js.map +1 -0
  418. package/src/services/pbkdf2.d.ts +54 -0
  419. package/src/services/pbkdf2.d.ts.map +1 -0
  420. package/src/services/pbkdf2.js +112 -0
  421. package/src/services/pbkdf2.js.map +1 -0
  422. package/src/services/progress-tracker.d.ts +23 -0
  423. package/src/services/progress-tracker.d.ts.map +1 -0
  424. package/src/services/progress-tracker.js +107 -0
  425. package/src/services/progress-tracker.js.map +1 -0
  426. package/src/services/resumable-encryption.d.ts +19 -0
  427. package/src/services/resumable-encryption.d.ts.map +1 -0
  428. package/src/services/resumable-encryption.js +109 -0
  429. package/src/services/resumable-encryption.js.map +1 -0
  430. package/src/services/xor.d.ts +37 -0
  431. package/src/services/xor.d.ts.map +1 -0
  432. package/src/services/xor.js +67 -0
  433. package/src/services/xor.js.map +1 -0
  434. package/src/test-mocks/index.d.ts +2 -0
  435. package/src/test-mocks/index.d.ts.map +1 -0
  436. package/src/test-mocks/index.js +5 -0
  437. package/src/test-mocks/index.js.map +1 -0
  438. package/src/test-mocks/mock-frontend-member.d.ts +85 -0
  439. package/src/test-mocks/mock-frontend-member.d.ts.map +1 -0
  440. package/src/test-mocks/mock-frontend-member.js +194 -0
  441. package/src/test-mocks/mock-frontend-member.js.map +1 -0
  442. package/src/testing.d.ts +2 -0
  443. package/src/testing.d.ts.map +1 -0
  444. package/src/testing.js +6 -0
  445. package/src/testing.js.map +1 -0
  446. package/src/translations/de.d.ts +4 -0
  447. package/src/translations/de.d.ts.map +1 -0
  448. package/src/translations/de.js +207 -0
  449. package/src/translations/de.js.map +1 -0
  450. package/src/translations/en-US.d.ts +4 -0
  451. package/src/translations/en-US.d.ts.map +1 -0
  452. package/src/translations/en-US.js +207 -0
  453. package/src/translations/en-US.js.map +1 -0
  454. package/src/translations/es.d.ts +4 -0
  455. package/src/translations/es.d.ts.map +1 -0
  456. package/src/translations/es.js +207 -0
  457. package/src/translations/es.js.map +1 -0
  458. package/src/translations/fr.d.ts +4 -0
  459. package/src/translations/fr.d.ts.map +1 -0
  460. package/src/translations/fr.js +207 -0
  461. package/src/translations/fr.js.map +1 -0
  462. package/src/translations/ja.d.ts +4 -0
  463. package/src/translations/ja.d.ts.map +1 -0
  464. package/src/translations/ja.js +206 -0
  465. package/src/translations/ja.js.map +1 -0
  466. package/src/translations/uk.d.ts +4 -0
  467. package/src/translations/uk.d.ts.map +1 -0
  468. package/src/translations/uk.js +209 -0
  469. package/src/translations/uk.js.map +1 -0
  470. package/src/translations/zh-cn.d.ts +4 -0
  471. package/src/translations/zh-cn.d.ts.map +1 -0
  472. package/src/translations/zh-cn.js +206 -0
  473. package/src/translations/zh-cn.js.map +1 -0
  474. package/src/types/deep-partial.d.ts +4 -0
  475. package/src/types/deep-partial.d.ts.map +1 -0
  476. package/src/types/deep-partial.js +3 -0
  477. package/src/types/deep-partial.js.map +1 -0
  478. package/src/{types.ts → types.d.ts} +7 -15
  479. package/src/types.d.ts.map +1 -0
  480. package/src/types.js +3 -0
  481. package/src/types.js.map +1 -0
  482. package/src/utils/encryption-type-utils.d.ts +29 -0
  483. package/src/utils/encryption-type-utils.d.ts.map +1 -0
  484. package/src/utils/encryption-type-utils.js +67 -0
  485. package/src/utils/encryption-type-utils.js.map +1 -0
  486. package/src/utils.d.ts +68 -0
  487. package/src/utils.d.ts.map +1 -0
  488. package/src/utils.js +291 -0
  489. package/src/utils.js.map +1 -0
  490. package/LICENSE +0 -21
  491. package/src/builders/ecies-builder.ts +0 -39
  492. package/src/builders/member-builder.ts +0 -155
  493. package/src/constants.ts +0 -609
  494. package/src/core/errors/crypto-error.ts +0 -78
  495. package/src/core/types/result.ts +0 -19
  496. package/src/email-string.ts +0 -82
  497. package/src/enumerations/disposed-error-type.ts +0 -11
  498. package/src/enumerations/ecies-cipher-suite.ts +0 -4
  499. package/src/enumerations/ecies-encryption-type.ts +0 -41
  500. package/src/enumerations/ecies-error-type.ts +0 -43
  501. package/src/enumerations/ecies-string-key.ts +0 -205
  502. package/src/enumerations/ecies-version.ts +0 -3
  503. package/src/enumerations/guid-brand-type.ts +0 -26
  504. package/src/enumerations/guid-error-type.ts +0 -6
  505. package/src/enumerations/id-provider-error-type.ts +0 -50
  506. package/src/enumerations/invalid-email-type.ts +0 -5
  507. package/src/enumerations/length-encoding-type.ts +0 -6
  508. package/src/enumerations/length-error-type.ts +0 -5
  509. package/src/enumerations/member-error-type.ts +0 -106
  510. package/src/enumerations/password-login-error-type.ts +0 -4
  511. package/src/enumerations/pbkdf2-error-type.ts +0 -5
  512. package/src/enumerations/pbkdf2-profile.ts +0 -5
  513. package/src/enumerations/secure-storage-error-type.ts +0 -5
  514. package/src/errors/disposed.ts +0 -36
  515. package/src/errors/ecies.ts +0 -153
  516. package/src/errors/guid.ts +0 -130
  517. package/src/errors/id-provider.ts +0 -40
  518. package/src/errors/invalid-email.ts +0 -23
  519. package/src/errors/length.ts +0 -19
  520. package/src/errors/member.ts +0 -20
  521. package/src/errors/pbkdf2.ts +0 -20
  522. package/src/errors/secure-storage.ts +0 -17
  523. package/src/errors/simple-ecies.ts +0 -21
  524. package/src/errors/simple-test-error.ts +0 -6
  525. package/src/i18n-setup.ts +0 -130
  526. package/src/interfaces/checksum-config.ts +0 -4
  527. package/src/interfaces/checksum-consts.ts +0 -13
  528. package/src/interfaces/configuration-provenance.ts +0 -54
  529. package/src/interfaces/constants.ts +0 -75
  530. package/src/interfaces/ecies-config.ts +0 -8
  531. package/src/interfaces/ecies-consts.ts +0 -76
  532. package/src/interfaces/ecies-file-service.ts +0 -6
  533. package/src/interfaces/encrypted-chunk.ts +0 -64
  534. package/src/interfaces/encryption-state.ts +0 -19
  535. package/src/interfaces/frontend-member-operational.ts +0 -77
  536. package/src/interfaces/guid.ts +0 -86
  537. package/src/interfaces/id-provider.ts +0 -152
  538. package/src/interfaces/invariant.ts +0 -60
  539. package/src/interfaces/library-error.ts +0 -23
  540. package/src/interfaces/member.ts +0 -84
  541. package/src/interfaces/multi-recipient-chunk.ts +0 -61
  542. package/src/interfaces/pbkdf2-config.ts +0 -6
  543. package/src/interfaces/pbkdf2-consts.ts +0 -10
  544. package/src/interfaces/pbkdf2-result.ts +0 -5
  545. package/src/interfaces/stream-config.ts +0 -17
  546. package/src/interfaces/stream-header.ts +0 -34
  547. package/src/interfaces/stream-progress.ts +0 -31
  548. package/src/lib/configuration-provenance-utils.ts +0 -29
  549. package/src/lib/crypto-container.ts +0 -64
  550. package/src/lib/guid.ts +0 -1097
  551. package/src/lib/id-providers/custom-provider.ts +0 -109
  552. package/src/lib/id-providers/guidv4-provider.ts +0 -141
  553. package/src/lib/id-providers/objectid-provider.ts +0 -125
  554. package/src/lib/id-providers/uuid-provider.ts +0 -133
  555. package/src/lib/invariant-validator.ts +0 -133
  556. package/src/lib/invariants/encryption-algorithm-consistency.ts +0 -73
  557. package/src/lib/invariants/pbkdf2-profiles-validity.ts +0 -78
  558. package/src/lib/invariants/recipient-id-consistency.ts +0 -46
  559. package/src/lib/multi-recipient-chunk-utils.ts +0 -63
  560. package/src/member.ts +0 -495
  561. package/src/phone-number.ts +0 -18
  562. package/src/regexes.ts +0 -10
  563. package/src/secure-buffer.ts +0 -226
  564. package/src/secure-string.ts +0 -244
  565. package/src/services/aes-gcm.ts +0 -220
  566. package/src/services/chunk-processor.ts +0 -188
  567. package/src/services/ecies/README.md +0 -147
  568. package/src/services/ecies/crypto-core.ts +0 -292
  569. package/src/services/ecies/example.ts +0 -185
  570. package/src/services/ecies/file.ts +0 -167
  571. package/src/services/ecies/integration.ts +0 -241
  572. package/src/services/ecies/interfaces.ts +0 -62
  573. package/src/services/ecies/manual-test.ts +0 -219
  574. package/src/services/ecies/multi-recipient.ts +0 -545
  575. package/src/services/ecies/service.ts +0 -370
  576. package/src/services/ecies/signature.ts +0 -93
  577. package/src/services/ecies/single-recipient.ts +0 -476
  578. package/src/services/encryption-stream.ts +0 -435
  579. package/src/services/multi-recipient-processor.ts +0 -377
  580. package/src/services/password-login.ts +0 -226
  581. package/src/services/pbkdf2.ts +0 -169
  582. package/src/services/progress-tracker.ts +0 -128
  583. package/src/services/resumable-encryption.ts +0 -135
  584. package/src/services/xor.ts +0 -65
  585. package/src/test-mocks/index.ts +0 -1
  586. package/src/test-mocks/mock-frontend-member.ts +0 -276
  587. package/src/testing.ts +0 -2
  588. package/src/translations/de.ts +0 -260
  589. package/src/translations/en-US.ts +0 -262
  590. package/src/translations/es.ts +0 -271
  591. package/src/translations/fr.ts +0 -269
  592. package/src/translations/ja.ts +0 -259
  593. package/src/translations/uk.ts +0 -271
  594. package/src/translations/zh-cn.ts +0 -234
  595. package/src/types/deep-partial.ts +0 -11
  596. package/src/utils/encryption-type-utils.ts +0 -76
  597. package/src/utils.ts +0 -329
@@ -0,0 +1,919 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GuidV4 = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const uuid = tslib_1.__importStar(require("uuid"));
6
+ const guid_brand_type_1 = require("../enumerations/guid-brand-type");
7
+ const guid_error_type_1 = require("../enumerations/guid-error-type");
8
+ const guid_1 = require("../errors/guid");
9
+ /**
10
+ * GuidV4 represents a GUID (Globally Unique Identifier) that is compliant with the RFC 4122 standard.
11
+ * GuidV4 instances can be created from a variety of input types, including:
12
+ * - FullHexGuid: A 36-character string representation of the GUID, including dashes
13
+ * - ShortHexGuid: A 32-character string representation of the GUID, excluding dashes
14
+ * - Base64Guid: A 24-character base64-encoded string representation of the GUID
15
+ * - BigIntGuid: A bigint representation of the GUID
16
+ * - RawGuidBuffer: A 16-byte Buffer representation of the GUID
17
+ * GuidV4 instances can be converted to any of these representations using the appropriate method.
18
+ */
19
+ class GuidV4 {
20
+ /**
21
+ * GUID is stored internally as a raw 16-byte Buffer.
22
+ */
23
+ _value;
24
+ /**
25
+ * Boundary value constants for special GUID validation
26
+ */
27
+ static BOUNDARY_VALUES = {
28
+ ALL_ZEROS_FULL: '00000000-0000-0000-0000-000000000000',
29
+ ALL_ZEROS_SHORT: '00000000000000000000000000000000',
30
+ ALL_FS_FULL: 'ffffffff-ffff-ffff-ffff-ffffffffffff',
31
+ ALL_FS_SHORT: 'ffffffffffffffffffffffffffffffff',
32
+ };
33
+ /**
34
+ * Maximum valid bigint value for a 128-bit GUID
35
+ */
36
+ static MAX_BIGINT_VALUE = BigInt('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF');
37
+ /**
38
+ * Cached full hex representation for performance
39
+ */
40
+ _cachedFullHex;
41
+ /**
42
+ * Cached short hex representation for performance
43
+ */
44
+ _cachedShortHex;
45
+ /**
46
+ * Cached base64 representation for performance
47
+ */
48
+ _cachedBase64;
49
+ /**
50
+ * Regex for validating hex strings (case insensitive)
51
+ */
52
+ static HEX_PATTERN = /^[0-9a-f]+$/i;
53
+ /**
54
+ * Regex for validating full hex GUID format
55
+ */
56
+ static FULL_HEX_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
57
+ /**
58
+ * Cached empty/nil GUID constant (all zeros)
59
+ */
60
+ static _empty;
61
+ /**
62
+ * Empty/nil GUID constant (all zeros)
63
+ */
64
+ static get Empty() {
65
+ if (!GuidV4._empty) {
66
+ GuidV4._empty = Object.freeze(new GuidV4('00000000-0000-0000-0000-000000000000'));
67
+ }
68
+ return GuidV4._empty;
69
+ }
70
+ constructor(value) {
71
+ const buffer = GuidV4.validateAndConvert(value);
72
+ // Note: We cannot freeze a Buffer as it's an ArrayBuffer view
73
+ // Instead, we ensure the buffer is never directly modified after construction
74
+ this._value = buffer;
75
+ // Initialize cache properties so they exist before sealing
76
+ this._cachedFullHex = undefined;
77
+ this._cachedShortHex = undefined;
78
+ this._cachedBase64 = undefined;
79
+ // Seal the instance to prevent property addition/deletion
80
+ // Cache properties can still be set once since they were initialized
81
+ Object.seal(this);
82
+ }
83
+ /**
84
+ * Validates input and converts to raw buffer with comprehensive error handling.
85
+ * This centralizes all validation logic for better maintainability.
86
+ * @param value The input value to validate and convert
87
+ * @returns The validated raw GUID buffer
88
+ * @throws {GuidError} If validation fails
89
+ */
90
+ static validateAndConvert(value) {
91
+ try {
92
+ // Null/undefined check
93
+ if (value === null || value === undefined) {
94
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
95
+ }
96
+ // Empty string check (but allow 0n bigint)
97
+ const strValue = String(value);
98
+ if (!strValue && value !== 0n) {
99
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
100
+ }
101
+ // Validate bigint is non-negative
102
+ if (typeof value === 'bigint' && value < 0n) {
103
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
104
+ }
105
+ // Validate hex strings contain only valid hex characters
106
+ if (typeof value === 'string') {
107
+ const isFullHex = value.length === 36 && value.includes('-');
108
+ const isShortHex = value.length === 32 && !value.includes('-');
109
+ if (isFullHex && !GuidV4.FULL_HEX_PATTERN.test(value)) {
110
+ const buffer = Buffer.from(value);
111
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuidWithDetails, guid_brand_type_1.GuidBrandType.FullHexGuid, value.length, buffer);
112
+ }
113
+ else if (isShortHex && !GuidV4.HEX_PATTERN.test(value)) {
114
+ const buffer = Buffer.from(value);
115
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuidWithDetails, guid_brand_type_1.GuidBrandType.ShortHexGuid, value.length, buffer);
116
+ }
117
+ }
118
+ // Determine and verify the brand/type
119
+ const expectedBrand = GuidV4.whichBrand(value);
120
+ const verifiedBrand = GuidV4.verifyGuid(expectedBrand, value);
121
+ if (!verifiedBrand) {
122
+ const valueBuffer = Buffer.isBuffer(value)
123
+ ? value
124
+ : Buffer.from(strValue);
125
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuidWithDetails, expectedBrand, undefined, valueBuffer);
126
+ }
127
+ // Convert to raw buffer
128
+ const buffer = GuidV4.toRawGuidBuffer(value);
129
+ // Validate against UUID standard (skip for boundary values)
130
+ const fullHex = GuidV4.toFullHexGuid(buffer.toString('hex'));
131
+ const isBoundary = GuidV4.isBoundaryValue(fullHex);
132
+ if (!isBoundary && !uuid.validate(fullHex)) {
133
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid, expectedBrand, undefined, buffer);
134
+ }
135
+ return buffer;
136
+ }
137
+ catch (error) {
138
+ // Re-throw GuidError as-is
139
+ if (error instanceof guid_1.GuidError) {
140
+ throw error;
141
+ }
142
+ // Wrap other errors with context
143
+ if (typeof value === 'bigint') {
144
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
145
+ }
146
+ const length = value instanceof Buffer ? value.length : String(value).length;
147
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuidUnknownLength, undefined, length);
148
+ }
149
+ }
150
+ static validateUuid(value) {
151
+ return uuid.validate(value);
152
+ }
153
+ serialize() {
154
+ return this.asBase64Guid;
155
+ }
156
+ static hydrate(value) {
157
+ return new GuidV4(value);
158
+ }
159
+ static LengthMap = {
160
+ [guid_brand_type_1.GuidBrandType.Unknown]: -1,
161
+ [guid_brand_type_1.GuidBrandType.FullHexGuid]: 36,
162
+ [guid_brand_type_1.GuidBrandType.ShortHexGuid]: 32,
163
+ [guid_brand_type_1.GuidBrandType.Base64Guid]: 24,
164
+ [guid_brand_type_1.GuidBrandType.RawGuidBuffer]: 16,
165
+ [guid_brand_type_1.GuidBrandType.BigIntGuid]: -1, // Variable length
166
+ };
167
+ static ReverseLengthMap = {
168
+ 0: guid_brand_type_1.GuidBrandType.Unknown,
169
+ 36: guid_brand_type_1.GuidBrandType.FullHexGuid,
170
+ 32: guid_brand_type_1.GuidBrandType.ShortHexGuid,
171
+ 24: guid_brand_type_1.GuidBrandType.Base64Guid,
172
+ 16: guid_brand_type_1.GuidBrandType.RawGuidBuffer,
173
+ // BigIntGuid is variable length, so it is not included in the reverse map
174
+ };
175
+ static VerifyFunctions = {
176
+ [guid_brand_type_1.GuidBrandType.Unknown]: () => false,
177
+ [guid_brand_type_1.GuidBrandType.FullHexGuid]: (guid) => this.isFullHexGuid(guid),
178
+ [guid_brand_type_1.GuidBrandType.ShortHexGuid]: (guid) => this.isShortHexGuid(guid),
179
+ [guid_brand_type_1.GuidBrandType.Base64Guid]: (guid) => this.isBase64Guid(guid),
180
+ [guid_brand_type_1.GuidBrandType.BigIntGuid]: (guid) => this.isBigIntGuid(guid),
181
+ [guid_brand_type_1.GuidBrandType.RawGuidBuffer]: (guid) => this.isRawGuidBuffer(guid),
182
+ };
183
+ /**
184
+ * Returns the GUID as a raw Buffer.
185
+ * NOTE: Returns a defensive copy to prevent external mutation.
186
+ * Use asRawGuidBufferUnsafe() if you need the internal buffer and guarantee no mutation.
187
+ */
188
+ get asRawGuidBuffer() {
189
+ return Buffer.from(this._value);
190
+ }
191
+ /**
192
+ * Returns the internal raw Buffer without copying.
193
+ * ⚠️ WARNING: Do NOT mutate the returned buffer! This is for performance-critical paths only.
194
+ * Mutating this buffer will corrupt the GUID instance.
195
+ * @internal
196
+ */
197
+ get asRawGuidBufferUnsafe() {
198
+ return this._value;
199
+ }
200
+ /**
201
+ * Generates a new random v4 GUID.
202
+ * @returns A new GuidV4 instance with a randomly generated value
203
+ */
204
+ static generate() {
205
+ try {
206
+ const uuidStr = uuid.v4();
207
+ if (!uuidStr) {
208
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
209
+ }
210
+ return new GuidV4(uuidStr);
211
+ }
212
+ catch (error) {
213
+ if (error instanceof guid_1.GuidError) {
214
+ throw error;
215
+ }
216
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
217
+ }
218
+ }
219
+ /**
220
+ * Alias for generate() for backward compatibility.
221
+ * @deprecated Use generate() instead for clearer intent
222
+ */
223
+ static new() {
224
+ return GuidV4.generate();
225
+ }
226
+ /**
227
+ * Parses a GUID from any valid format, throwing on invalid input.
228
+ * This is the primary parsing method for when you expect valid input.
229
+ * @param value The value to parse
230
+ * @returns A new GuidV4 instance
231
+ * @throws {GuidError} If the value is not a valid GUID
232
+ */
233
+ static parse(value) {
234
+ return new GuidV4(value);
235
+ }
236
+ /**
237
+ * Attempts to parse a GUID, returning null on failure instead of throwing.
238
+ * Use this when you're uncertain if the input is valid.
239
+ * @param value The value to parse
240
+ * @returns A new GuidV4 instance or null if parsing fails
241
+ */
242
+ static tryParse(value) {
243
+ try {
244
+ return new GuidV4(value);
245
+ }
246
+ catch {
247
+ return null;
248
+ }
249
+ }
250
+ /**
251
+ * Validates whether a value is a valid GUID without creating an instance.
252
+ * More efficient than tryParse when you only need validation.
253
+ * @param value The value to validate
254
+ * @returns True if valid, false otherwise
255
+ */
256
+ static isValid(value) {
257
+ if (!value)
258
+ return false;
259
+ try {
260
+ const guid = new GuidV4(value);
261
+ return guid.isValidV4();
262
+ }
263
+ catch {
264
+ return false;
265
+ }
266
+ }
267
+ /**
268
+ * Factory method to create a GUID from a full hex string.
269
+ * @param fullHex The full hex string (with dashes)
270
+ * @returns A new GuidV4 instance
271
+ */
272
+ static fromFullHex(fullHex) {
273
+ return new GuidV4(fullHex);
274
+ }
275
+ /**
276
+ * Factory method to create a GUID from a short hex string.
277
+ * @param shortHex The short hex string (without dashes)
278
+ * @returns A new GuidV4 instance
279
+ */
280
+ static fromShortHex(shortHex) {
281
+ return new GuidV4(shortHex);
282
+ }
283
+ /**
284
+ * Factory method to create a GUID from a base64 string.
285
+ * @param base64 The base64 encoded string
286
+ * @returns A new GuidV4 instance
287
+ */
288
+ static fromBase64(base64) {
289
+ return new GuidV4(base64);
290
+ }
291
+ /**
292
+ * Factory method to create a GUID from a bigint.
293
+ * @param bigint The bigint value
294
+ * @returns A new GuidV4 instance
295
+ */
296
+ static fromBigInt(bigint) {
297
+ return new GuidV4(bigint);
298
+ }
299
+ /**
300
+ * Factory method to create a GUID from a raw buffer.
301
+ * @param buffer The raw 16-byte buffer
302
+ * @returns A new GuidV4 instance
303
+ */
304
+ static fromBuffer(buffer) {
305
+ return new GuidV4(buffer);
306
+ }
307
+ /**
308
+ * Creates a namespace-based v3 GUID (MD5 hash).
309
+ * Use this for deterministic GUIDs based on a namespace and name.
310
+ * @param namespace The namespace GUID (e.g., uuid.v3.DNS)
311
+ * @param name The name to hash within the namespace
312
+ * @returns A new GuidV4 instance containing the v3 GUID
313
+ * @example
314
+ * const guid = GuidV4.v3('example.com', uuid.v3.DNS);
315
+ */
316
+ static v3(name, namespace) {
317
+ try {
318
+ const namespaceStr = Buffer.isBuffer(namespace)
319
+ ? GuidV4.toFullHexGuid(namespace.toString('hex'))
320
+ : namespace;
321
+ const v3Guid = uuid.v3(name, namespaceStr);
322
+ return new GuidV4(v3Guid);
323
+ }
324
+ catch (error) {
325
+ if (error instanceof guid_1.GuidError) {
326
+ throw error;
327
+ }
328
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
329
+ }
330
+ }
331
+ /**
332
+ * Creates a namespace-based v5 GUID (SHA-1 hash).
333
+ * Use this for deterministic GUIDs based on a namespace and name.
334
+ * Preferred over v3 as SHA-1 is stronger than MD5.
335
+ * @param namespace The namespace GUID (e.g., uuid.v5.DNS)
336
+ * @param name The name to hash within the namespace
337
+ * @returns A new GuidV4 instance containing the v5 GUID
338
+ * @example
339
+ * const guid = GuidV4.v5('example.com', uuid.v5.DNS);
340
+ */
341
+ static v5(name, namespace) {
342
+ try {
343
+ const namespaceStr = Buffer.isBuffer(namespace)
344
+ ? GuidV4.toFullHexGuid(namespace.toString('hex'))
345
+ : namespace;
346
+ const v5Guid = uuid.v5(name, namespaceStr);
347
+ return new GuidV4(v5Guid);
348
+ }
349
+ catch (error) {
350
+ if (error instanceof guid_1.GuidError) {
351
+ throw error;
352
+ }
353
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
354
+ }
355
+ }
356
+ /**
357
+ * Common namespace constants for use with v3/v5 GUIDs.
358
+ * Re-exported from uuid library for convenience.
359
+ */
360
+ static Namespaces = {
361
+ DNS: uuid.v5.DNS,
362
+ URL: uuid.v5.URL,
363
+ };
364
+ /**
365
+ * Returns the GUID as a full hex string.
366
+ * Result is cached for performance.
367
+ */
368
+ get asFullHexGuid() {
369
+ if (!this._cachedFullHex) {
370
+ this._cachedFullHex = GuidV4.toFullHexGuid(this._value.toString('hex'));
371
+ }
372
+ return this._cachedFullHex;
373
+ }
374
+ /**
375
+ * Returns the GUID as a raw Uint8Array.
376
+ */
377
+ get asUint8Array() {
378
+ return this._value;
379
+ }
380
+ /**
381
+ * Returns the GUID as a short hex string.
382
+ * Result is cached for performance.
383
+ */
384
+ get asShortHexGuid() {
385
+ if (!this._cachedShortHex) {
386
+ this._cachedShortHex = GuidV4.toShortHexGuid(this.asFullHexGuid);
387
+ }
388
+ return this._cachedShortHex;
389
+ }
390
+ /**
391
+ * Returns the GUID as a base64 string.
392
+ */
393
+ toString() {
394
+ return this.asBase64Guid;
395
+ }
396
+ /**
397
+ * Returns the GUID as a JSON string.
398
+ * @returns The GUID as a JSON string.
399
+ */
400
+ toJson() {
401
+ return JSON.stringify(this.asBase64Guid);
402
+ }
403
+ /**
404
+ * Returns the GUID as a bigint.
405
+ */
406
+ get asBigIntGuid() {
407
+ return BigInt('0x' + this._value.toString('hex'));
408
+ }
409
+ /**
410
+ * Returns the GUID as a base64 string.
411
+ * Result is cached for performance.
412
+ */
413
+ get asBase64Guid() {
414
+ if (!this._cachedBase64) {
415
+ this._cachedBase64 = this._value.toString('base64');
416
+ }
417
+ return this._cachedBase64;
418
+ }
419
+ /**
420
+ * Checks if a GUID value is a boundary value (all zeros or all Fs).
421
+ * @param value The GUID value to check.
422
+ * @returns True if the value is a boundary value.
423
+ */
424
+ static isBoundaryValue(value) {
425
+ return (value === GuidV4.BOUNDARY_VALUES.ALL_ZEROS_FULL ||
426
+ value === GuidV4.BOUNDARY_VALUES.ALL_ZEROS_SHORT ||
427
+ value === GuidV4.BOUNDARY_VALUES.ALL_FS_FULL ||
428
+ value === GuidV4.BOUNDARY_VALUES.ALL_FS_SHORT);
429
+ }
430
+ /**
431
+ * Verifies if a given GUID is valid for the given brand.
432
+ * @param guidBrand The brand of the GUID to verify.
433
+ * @param guid The GUID to verify.
434
+ * @returns True if the GUID is valid for the given brand, false otherwise.
435
+ */
436
+ static verifyGuid(guidBrand, guid) {
437
+ if (guid === null || guid === undefined) {
438
+ return false;
439
+ }
440
+ try {
441
+ const verifyFunc = GuidV4.VerifyFunctions[guidBrand];
442
+ return verifyFunc(guid);
443
+ }
444
+ catch {
445
+ return false;
446
+ }
447
+ }
448
+ /**
449
+ * Returns the length of the GUID for the given brand.
450
+ * @param guidBrand The brand of the GUID to get the length for.
451
+ * @returns The length of the GUID for the given brand.
452
+ */
453
+ static guidBrandToLength(guidBrand) {
454
+ const length = GuidV4.LengthMap[guidBrand];
455
+ if (length <= 0) {
456
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuidUnknownBrand, guidBrand);
457
+ }
458
+ return length;
459
+ }
460
+ /**
461
+ * Returns the brand of the GUID for the given length.
462
+ * @param length The length of the GUID to get the brand for.
463
+ * @param isBuffer Whether the GUID is a Buffer.
464
+ * @returns The brand of the GUID for the given length.
465
+ */
466
+ static lengthToGuidBrand(length, isBuffer) {
467
+ if (length <= 0) {
468
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuidUnknownLength, undefined, length);
469
+ }
470
+ const brand = GuidV4.ReverseLengthMap[length];
471
+ if (!brand || brand === guid_brand_type_1.GuidBrandType.Unknown) {
472
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuidUnknownLength, undefined, length);
473
+ }
474
+ // Validate buffer vs string type consistency
475
+ const isBrandBuffer = brand === guid_brand_type_1.GuidBrandType.RawGuidBuffer;
476
+ if (isBuffer !== isBrandBuffer) {
477
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuidUnknownLength, brand, length);
478
+ }
479
+ return brand;
480
+ }
481
+ /**
482
+ * Verifies if a given GUID is a valid full hex GUID.
483
+ * @param fullHexGuidValue The full hex GUID to verify.
484
+ * @returns True if the GUID is a valid full hex GUID, false otherwise.
485
+ */
486
+ static isFullHexGuid(fullHexGuidValue) {
487
+ try {
488
+ if (fullHexGuidValue === null || fullHexGuidValue === undefined) {
489
+ return false;
490
+ }
491
+ const expectedLength = GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.FullHexGuid);
492
+ const strValue = String(fullHexGuidValue);
493
+ if (strValue.length !== expectedLength) {
494
+ return false;
495
+ }
496
+ // Boundary values are always valid
497
+ if (GuidV4.isBoundaryValue(strValue)) {
498
+ return true;
499
+ }
500
+ return GuidV4.validateUuid(strValue);
501
+ }
502
+ catch {
503
+ return false;
504
+ }
505
+ }
506
+ /**
507
+ * Verifies if a given GUID is a valid short hex GUID.
508
+ * @param shortHexGuidValue The short hex GUID to verify.
509
+ * @returns True if the GUID is a valid short hex GUID, false otherwise.
510
+ */
511
+ static isShortHexGuid(shortHexGuidValue) {
512
+ try {
513
+ if (shortHexGuidValue === null || shortHexGuidValue === undefined) {
514
+ return false;
515
+ }
516
+ const expectedLength = GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.ShortHexGuid);
517
+ const strValue = String(shortHexGuidValue);
518
+ if (strValue.length !== expectedLength) {
519
+ return false;
520
+ }
521
+ try {
522
+ const fullHexGuid = GuidV4.toFullHexGuid(strValue);
523
+ // Boundary values are always valid
524
+ if (GuidV4.isBoundaryValue(fullHexGuid)) {
525
+ return true;
526
+ }
527
+ return uuid.validate(fullHexGuid);
528
+ }
529
+ catch {
530
+ return false;
531
+ }
532
+ }
533
+ catch {
534
+ return false;
535
+ }
536
+ }
537
+ /**
538
+ * Verifies if a given GUID is a valid base64 GUID.
539
+ * @param value The base64 GUID to verify.
540
+ * @returns True if the GUID is a valid base64 GUID, false otherwise.
541
+ */
542
+ static isBase64Guid(value) {
543
+ try {
544
+ if (value === null || value === undefined) {
545
+ return false;
546
+ }
547
+ let valueLength;
548
+ if (typeof value === 'bigint') {
549
+ valueLength = value.toString(16).length;
550
+ }
551
+ else if (value instanceof Buffer) {
552
+ valueLength = value.length;
553
+ }
554
+ else {
555
+ valueLength = String(value).length;
556
+ }
557
+ const result = valueLength === GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.Base64Guid);
558
+ if (result) {
559
+ try {
560
+ const fromBase64 = GuidV4.toRawGuidBuffer(value);
561
+ const fullHexGuid = GuidV4.toFullHexGuid(fromBase64.toString('hex'));
562
+ // Boundary values are always valid
563
+ if (GuidV4.isBoundaryValue(fullHexGuid)) {
564
+ return true;
565
+ }
566
+ return uuid.validate(fullHexGuid);
567
+ }
568
+ catch {
569
+ return false;
570
+ }
571
+ }
572
+ return result;
573
+ }
574
+ catch {
575
+ return false;
576
+ }
577
+ }
578
+ /**
579
+ * Verifies if a given GUID is a valid raw GUID buffer.
580
+ * @param value The raw GUID buffer to verify.
581
+ * @returns True if the GUID is a valid raw GUID buffer, false otherwise.
582
+ */
583
+ static isRawGuidBuffer(value) {
584
+ try {
585
+ if (value === null || value === undefined) {
586
+ return false;
587
+ }
588
+ const expectedLength = GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.RawGuidBuffer);
589
+ let valueLength;
590
+ if (typeof value === 'bigint') {
591
+ valueLength = value.toString(16).length;
592
+ }
593
+ else if (value instanceof Buffer) {
594
+ valueLength = value.length;
595
+ }
596
+ else {
597
+ valueLength = String(value).length;
598
+ }
599
+ if (valueLength !== expectedLength) {
600
+ return false;
601
+ }
602
+ try {
603
+ if (!(value instanceof Buffer)) {
604
+ return false;
605
+ }
606
+ const fullHexGuid = GuidV4.toFullHexGuid(value.toString('hex'));
607
+ // Boundary values are always valid
608
+ if (GuidV4.isBoundaryValue(fullHexGuid)) {
609
+ return true;
610
+ }
611
+ return GuidV4.validateUuid(fullHexGuid);
612
+ }
613
+ catch {
614
+ return false;
615
+ }
616
+ }
617
+ catch {
618
+ return false;
619
+ }
620
+ }
621
+ /**
622
+ * Verifies if a given GUID is a valid bigint GUID.
623
+ * @param value The bigint GUID to verify.
624
+ * @returns True if the GUID is a valid bigint GUID, false otherwise.
625
+ */
626
+ static isBigIntGuid(value) {
627
+ try {
628
+ if (value === null || value === undefined) {
629
+ return false;
630
+ }
631
+ if (typeof value !== 'bigint') {
632
+ return false;
633
+ }
634
+ if (value < 0n || value > GuidV4.MAX_BIGINT_VALUE) {
635
+ return false;
636
+ }
637
+ try {
638
+ const fromBigInt = GuidV4.toFullHexFromBigInt(value);
639
+ // Boundary values are always valid
640
+ if (GuidV4.isBoundaryValue(fromBigInt)) {
641
+ return true;
642
+ }
643
+ return uuid.validate(fromBigInt);
644
+ }
645
+ catch {
646
+ return false;
647
+ }
648
+ }
649
+ catch {
650
+ return false;
651
+ }
652
+ }
653
+ /**
654
+ * Determines the brand of a given GUID value.
655
+ * @param value The GUID value to determine the brand of.
656
+ * @returns The brand of the GUID value.
657
+ */
658
+ static whichBrand(value) {
659
+ if (value === null || value === undefined) {
660
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
661
+ }
662
+ if (typeof value === 'bigint') {
663
+ return guid_brand_type_1.GuidBrandType.BigIntGuid;
664
+ }
665
+ const isBuffer = value instanceof Buffer;
666
+ const expectedLength = isBuffer ? value.length : String(value).length;
667
+ return GuidV4.lengthToGuidBrand(expectedLength, isBuffer);
668
+ }
669
+ /**
670
+ * Converts a given short hex GUID to a full hex GUID.
671
+ * @param shortGuid The short hex GUID to convert.
672
+ * @returns The short hex GUID as a full hex GUID.
673
+ */
674
+ static shortGuidToFullGuid(shortGuid) {
675
+ // insert dashes
676
+ const str = shortGuid.replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, '$1-$2-$3-$4-$5');
677
+ return str;
678
+ }
679
+ /**
680
+ * Converts a given GUID value to a full hex GUID.
681
+ * @param guid The GUID value to convert.
682
+ * @returns The GUID value as a full hex GUID.
683
+ */
684
+ static toFullHexGuid(guid) {
685
+ if (guid === null || guid === undefined) {
686
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
687
+ }
688
+ if (typeof guid === 'bigint') {
689
+ return GuidV4.toFullHexFromBigInt(guid);
690
+ }
691
+ else if (Buffer.isBuffer(guid) &&
692
+ guid.length === GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.RawGuidBuffer)) {
693
+ const shortHex = guid.toString('hex');
694
+ return GuidV4.shortGuidToFullGuid(shortHex);
695
+ }
696
+ else if (Buffer.isBuffer(guid)) {
697
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
698
+ }
699
+ // all remaining cases are string types
700
+ const strValue = String(guid);
701
+ if (strValue.length === GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.ShortHexGuid)) {
702
+ // short hex guid
703
+ return GuidV4.shortGuidToFullGuid(strValue);
704
+ }
705
+ else if (strValue.length === GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.FullHexGuid)) {
706
+ // already a full hex guid
707
+ return strValue;
708
+ }
709
+ else if (strValue.length === GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.Base64Guid)) {
710
+ // base64 guid
711
+ const shortGuid = Buffer.from(strValue, 'base64').toString('hex');
712
+ return GuidV4.shortGuidToFullGuid(shortGuid);
713
+ }
714
+ else {
715
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
716
+ }
717
+ }
718
+ static toShortHexGuid(guid) {
719
+ if (guid === null || guid === undefined) {
720
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
721
+ }
722
+ if (typeof guid === 'bigint') {
723
+ const fullHex = GuidV4.toFullHexFromBigInt(guid);
724
+ return fullHex.replace(/-/g, '');
725
+ }
726
+ else if (Buffer.isBuffer(guid) &&
727
+ guid.length === GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.RawGuidBuffer)) {
728
+ return guid.toString('hex');
729
+ }
730
+ else if (Buffer.isBuffer(guid)) {
731
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
732
+ }
733
+ // all remaining cases are string types
734
+ const strValue = String(guid);
735
+ if (strValue.length === GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.ShortHexGuid)) {
736
+ // already a short hex guid
737
+ return strValue;
738
+ }
739
+ else if (strValue.length === GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.FullHexGuid)) {
740
+ // full hex guid
741
+ return strValue.replace(/-/g, '');
742
+ }
743
+ else if (strValue.length === GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.Base64Guid)) {
744
+ // base64 guid
745
+ return Buffer.from(strValue, 'base64').toString('hex');
746
+ }
747
+ else {
748
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
749
+ }
750
+ }
751
+ /**
752
+ * Converts a given bigint to a full hex GUID.
753
+ * @param bigInt The bigint to convert.
754
+ * @returns The bigint as a full hex GUID.
755
+ */
756
+ static toFullHexFromBigInt(bigInt) {
757
+ if (bigInt < 0n || bigInt > GuidV4.MAX_BIGINT_VALUE) {
758
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
759
+ }
760
+ const uuidBigInt = bigInt.toString(16).padStart(32, '0');
761
+ // After padding, should always be exactly 32 characters
762
+ if (uuidBigInt.length !== 32) {
763
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
764
+ }
765
+ const rebuiltUuid = uuidBigInt.slice(0, 8) +
766
+ '-' +
767
+ uuidBigInt.slice(8, 12) +
768
+ '-' +
769
+ uuidBigInt.slice(12, 16) +
770
+ '-' +
771
+ uuidBigInt.slice(16, 20) +
772
+ '-' +
773
+ uuidBigInt.slice(20);
774
+ return rebuiltUuid;
775
+ }
776
+ /**
777
+ * Converts a given GUID value to a raw GUID buffer.
778
+ * @param value The GUID value to convert.
779
+ * @returns The GUID value as a raw GUID buffer.
780
+ */
781
+ static toRawGuidBuffer(value) {
782
+ const expectedBrand = GuidV4.whichBrand(value);
783
+ let rawGuidBufferResult = Buffer.alloc(0);
784
+ switch (expectedBrand) {
785
+ case guid_brand_type_1.GuidBrandType.FullHexGuid:
786
+ rawGuidBufferResult = Buffer.from(GuidV4.toShortHexGuid(value), 'hex');
787
+ break;
788
+ case guid_brand_type_1.GuidBrandType.ShortHexGuid:
789
+ rawGuidBufferResult = Buffer.from(GuidV4.toShortHexGuid(value), 'hex');
790
+ break;
791
+ case guid_brand_type_1.GuidBrandType.Base64Guid:
792
+ // Ensure value is a string before using it with Buffer.from
793
+ if (typeof value === 'string' || value instanceof Buffer) {
794
+ rawGuidBufferResult = Buffer.from(value.toString(), 'base64');
795
+ }
796
+ else {
797
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuid);
798
+ }
799
+ break;
800
+ case guid_brand_type_1.GuidBrandType.RawGuidBuffer:
801
+ rawGuidBufferResult = value;
802
+ break;
803
+ case guid_brand_type_1.GuidBrandType.BigIntGuid:
804
+ rawGuidBufferResult = Buffer.from(GuidV4.toShortHexGuid(GuidV4.toFullHexFromBigInt(value)), 'hex');
805
+ break;
806
+ default:
807
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuidUnknownBrand);
808
+ }
809
+ if (rawGuidBufferResult.length !==
810
+ GuidV4.guidBrandToLength(guid_brand_type_1.GuidBrandType.RawGuidBuffer)) {
811
+ throw new guid_1.GuidError(guid_error_type_1.GuidErrorType.InvalidGuidUnknownLength, undefined, rawGuidBufferResult.length);
812
+ }
813
+ return rawGuidBufferResult;
814
+ }
815
+ /**
816
+ * Compare two GuidV4 instances for equality.
817
+ * @param other - The other GuidV4 instance to compare (can be null/undefined)
818
+ * @param constantTime - Use constant-time comparison to prevent timing attacks (default: false)
819
+ * @returns True if the two GuidV4 instances are equal, false otherwise
820
+ */
821
+ equals(other, constantTime = false) {
822
+ if (!other) {
823
+ return false;
824
+ }
825
+ if (constantTime) {
826
+ // Constant-time comparison to prevent timing attacks
827
+ // Always compare all 16 bytes regardless of early mismatches
828
+ const a = this.asRawGuidBufferUnsafe;
829
+ const b = other.asRawGuidBuffer;
830
+ let result = 0;
831
+ for (let i = 0; i < 16; i++) {
832
+ result |= a[i] ^ b[i];
833
+ }
834
+ return result === 0;
835
+ }
836
+ return Buffer.compare(this.asRawGuidBufferUnsafe, other.asRawGuidBuffer) === 0;
837
+ }
838
+ /**
839
+ * Checks if this GUID is empty (all zeros).
840
+ * @returns True if the GUID is all zeros, false otherwise
841
+ */
842
+ isEmpty() {
843
+ // Check if all bytes are zero
844
+ for (let i = 0; i < this._value.length; i++) {
845
+ if (this._value[i] !== 0) {
846
+ return false;
847
+ }
848
+ }
849
+ return true;
850
+ }
851
+ /**
852
+ * Static helper to check if a GUID is null, undefined, or empty.
853
+ * @param guid The GUID to check
854
+ * @returns True if the GUID is null, undefined, or empty
855
+ */
856
+ static isNilOrEmpty(guid) {
857
+ return !guid || (guid instanceof GuidV4 && guid.isEmpty());
858
+ }
859
+ /**
860
+ * Creates a new GuidV4 instance with the same value as this one.
861
+ * @returns A new GuidV4 instance with identical value
862
+ */
863
+ clone() {
864
+ return new GuidV4(Buffer.from(this._value));
865
+ }
866
+ /**
867
+ * Returns the hash code for this GUID based on its buffer content.
868
+ * Useful for using GUIDs as Map/Set keys.
869
+ * @returns A numeric hash code
870
+ */
871
+ hashCode() {
872
+ let hash = 0;
873
+ for (let i = 0; i < this._value.length; i++) {
874
+ hash = ((hash << 5) - hash) + this._value[i];
875
+ hash = hash & hash; // Convert to 32-bit integer
876
+ }
877
+ return hash;
878
+ }
879
+ /**
880
+ * Extracts the RFC 4122 version from the GUID.
881
+ * Returns undefined for boundary values or invalid GUIDs.
882
+ * @returns The version number (1-5) or undefined
883
+ */
884
+ getVersion() {
885
+ // Skip boundary values
886
+ if (GuidV4.isBoundaryValue(this.asFullHexGuid)) {
887
+ return undefined;
888
+ }
889
+ // Version is in bits 48-51 (byte 6, high nibble)
890
+ const versionByte = this._value[6];
891
+ const version = (versionByte >> 4) & 0x0F;
892
+ // Valid RFC 4122 versions are 1-5
893
+ return version >= 1 && version <= 5 ? version : undefined;
894
+ }
895
+ /**
896
+ * Validates that this GUID is a proper v4 GUID according to RFC 4122.
897
+ * Boundary values (all zeros/all Fs) return true as they're mathematically valid.
898
+ * @returns True if valid v4 GUID or boundary value, false otherwise
899
+ */
900
+ isValidV4() {
901
+ // Boundary values are considered valid
902
+ if (GuidV4.isBoundaryValue(this.asFullHexGuid)) {
903
+ return true;
904
+ }
905
+ const version = this.getVersion();
906
+ return version === 4;
907
+ }
908
+ /**
909
+ * Compares two GUIDs for ordering.
910
+ * Useful for sorting GUID arrays.
911
+ * @param other The other GUID to compare to
912
+ * @returns -1 if this < other, 0 if equal, 1 if this > other
913
+ */
914
+ compareTo(other) {
915
+ return Buffer.compare(this.asRawGuidBufferUnsafe, other.asRawGuidBuffer);
916
+ }
917
+ }
918
+ exports.GuidV4 = GuidV4;
919
+ //# sourceMappingURL=guid.js.map