@hashgraphonline/standards-sdk 0.1.159 → 0.1.161

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 (329) hide show
  1. package/dist/cjs/hcs-12/validation/schemas.d.ts +4 -4
  2. package/dist/cjs/hcs-14/index.d.ts +5 -0
  3. package/dist/cjs/hcs-14/index.d.ts.map +1 -1
  4. package/dist/cjs/hcs-14/resolvers/aid-dns-web-profile.d.ts +37 -0
  5. package/dist/cjs/hcs-14/resolvers/aid-dns-web-profile.d.ts.map +1 -0
  6. package/dist/cjs/hcs-14/resolvers/dns.d.ts +3 -0
  7. package/dist/cjs/hcs-14/resolvers/dns.d.ts.map +1 -0
  8. package/dist/cjs/hcs-14/resolvers/hcs-11-profile.d.ts +8 -0
  9. package/dist/cjs/hcs-14/resolvers/hcs-11-profile.d.ts.map +1 -0
  10. package/dist/cjs/hcs-14/resolvers/profile-utils.d.ts +9 -0
  11. package/dist/cjs/hcs-14/resolvers/profile-utils.d.ts.map +1 -0
  12. package/dist/cjs/hcs-14/resolvers/registry.d.ts +38 -1
  13. package/dist/cjs/hcs-14/resolvers/registry.d.ts.map +1 -1
  14. package/dist/cjs/hcs-14/resolvers/types.d.ts +123 -5
  15. package/dist/cjs/hcs-14/resolvers/types.d.ts.map +1 -1
  16. package/dist/cjs/hcs-14/resolvers/uaid-did-resolution-profile.d.ts +10 -0
  17. package/dist/cjs/hcs-14/resolvers/uaid-did-resolution-profile.d.ts.map +1 -0
  18. package/dist/cjs/hcs-14/resolvers/uaid-dns-web-profile.d.ts +22 -0
  19. package/dist/cjs/hcs-14/resolvers/uaid-dns-web-profile.d.ts.map +1 -0
  20. package/dist/cjs/hcs-14/sdk.d.ts +31 -5
  21. package/dist/cjs/hcs-14/sdk.d.ts.map +1 -1
  22. package/dist/cjs/inscribe/inscriber.d.ts.map +1 -1
  23. package/dist/cjs/services/registry-broker/schemas.d.ts +1548 -0
  24. package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
  25. package/dist/cjs/standards-sdk.cjs +3 -3
  26. package/dist/cjs/standards-sdk.cjs.map +1 -1
  27. package/dist/es/hcs-12/validation/schemas.d.ts +4 -4
  28. package/dist/es/hcs-14/index.d.ts +5 -0
  29. package/dist/es/hcs-14/index.d.ts.map +1 -1
  30. package/dist/es/hcs-14/resolvers/aid-dns-web-profile.d.ts +37 -0
  31. package/dist/es/hcs-14/resolvers/aid-dns-web-profile.d.ts.map +1 -0
  32. package/dist/es/hcs-14/resolvers/dns.d.ts +3 -0
  33. package/dist/es/hcs-14/resolvers/dns.d.ts.map +1 -0
  34. package/dist/es/hcs-14/resolvers/hcs-11-profile.d.ts +8 -0
  35. package/dist/es/hcs-14/resolvers/hcs-11-profile.d.ts.map +1 -0
  36. package/dist/es/hcs-14/resolvers/profile-utils.d.ts +9 -0
  37. package/dist/es/hcs-14/resolvers/profile-utils.d.ts.map +1 -0
  38. package/dist/es/hcs-14/resolvers/registry.d.ts +38 -1
  39. package/dist/es/hcs-14/resolvers/registry.d.ts.map +1 -1
  40. package/dist/es/hcs-14/resolvers/types.d.ts +123 -5
  41. package/dist/es/hcs-14/resolvers/types.d.ts.map +1 -1
  42. package/dist/es/hcs-14/resolvers/uaid-did-resolution-profile.d.ts +10 -0
  43. package/dist/es/hcs-14/resolvers/uaid-did-resolution-profile.d.ts.map +1 -0
  44. package/dist/es/hcs-14/resolvers/uaid-dns-web-profile.d.ts +22 -0
  45. package/dist/es/hcs-14/resolvers/uaid-dns-web-profile.d.ts.map +1 -0
  46. package/dist/es/hcs-14/sdk.d.ts +31 -5
  47. package/dist/es/hcs-14/sdk.d.ts.map +1 -1
  48. package/dist/es/inscribe/inscriber.d.ts.map +1 -1
  49. package/dist/es/services/registry-broker/schemas.d.ts +1548 -0
  50. package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
  51. package/dist/es/standards-sdk.es.js +102 -85
  52. package/dist/es/standards-sdk.es.js.map +1 -1
  53. package/dist/es/standards-sdk.es100.js +138 -225
  54. package/dist/es/standards-sdk.es100.js.map +1 -1
  55. package/dist/es/standards-sdk.es101.js +44 -108
  56. package/dist/es/standards-sdk.es101.js.map +1 -1
  57. package/dist/es/standards-sdk.es102.js +255 -24
  58. package/dist/es/standards-sdk.es102.js.map +1 -1
  59. package/dist/es/standards-sdk.es103.js +98 -80
  60. package/dist/es/standards-sdk.es103.js.map +1 -1
  61. package/dist/es/standards-sdk.es104.js +91 -21
  62. package/dist/es/standards-sdk.es104.js.map +1 -1
  63. package/dist/es/standards-sdk.es105.js +29 -251
  64. package/dist/es/standards-sdk.es105.js.map +1 -1
  65. package/dist/es/standards-sdk.es106.js +211 -457
  66. package/dist/es/standards-sdk.es106.js.map +1 -1
  67. package/dist/es/standards-sdk.es107.js +104 -96
  68. package/dist/es/standards-sdk.es107.js.map +1 -1
  69. package/dist/es/standards-sdk.es108.js +26 -152
  70. package/dist/es/standards-sdk.es108.js.map +1 -1
  71. package/dist/es/standards-sdk.es109.js +77 -27
  72. package/dist/es/standards-sdk.es109.js.map +1 -1
  73. package/dist/es/standards-sdk.es11.js +1 -1
  74. package/dist/es/standards-sdk.es110.js +28 -9
  75. package/dist/es/standards-sdk.es110.js.map +1 -1
  76. package/dist/es/standards-sdk.es111.js +247 -137
  77. package/dist/es/standards-sdk.es111.js.map +1 -1
  78. package/dist/es/standards-sdk.es112.js +477 -28
  79. package/dist/es/standards-sdk.es112.js.map +1 -1
  80. package/dist/es/standards-sdk.es113.js +103 -20
  81. package/dist/es/standards-sdk.es113.js.map +1 -1
  82. package/dist/es/standards-sdk.es114.js +141 -141
  83. package/dist/es/standards-sdk.es114.js.map +1 -1
  84. package/dist/es/standards-sdk.es115.js +31 -200
  85. package/dist/es/standards-sdk.es115.js.map +1 -1
  86. package/dist/es/standards-sdk.es116.js +9 -787
  87. package/dist/es/standards-sdk.es116.js.map +1 -1
  88. package/dist/es/standards-sdk.es117.js +140 -11
  89. package/dist/es/standards-sdk.es117.js.map +1 -1
  90. package/dist/es/standards-sdk.es118.js +29 -567
  91. package/dist/es/standards-sdk.es118.js.map +1 -1
  92. package/dist/es/standards-sdk.es119.js +17 -597
  93. package/dist/es/standards-sdk.es119.js.map +1 -1
  94. package/dist/es/standards-sdk.es12.js +1 -1
  95. package/dist/es/standards-sdk.es120.js +159 -12
  96. package/dist/es/standards-sdk.es120.js.map +1 -1
  97. package/dist/es/standards-sdk.es121.js +203 -2
  98. package/dist/es/standards-sdk.es121.js.map +1 -1
  99. package/dist/es/standards-sdk.es122.js +774 -71
  100. package/dist/es/standards-sdk.es122.js.map +1 -1
  101. package/dist/es/standards-sdk.es123.js +11 -38
  102. package/dist/es/standards-sdk.es123.js.map +1 -1
  103. package/dist/es/standards-sdk.es124.js +567 -2
  104. package/dist/es/standards-sdk.es124.js.map +1 -1
  105. package/dist/es/standards-sdk.es125.js +576 -209
  106. package/dist/es/standards-sdk.es125.js.map +1 -1
  107. package/dist/es/standards-sdk.es126.js +12 -1139
  108. package/dist/es/standards-sdk.es126.js.map +1 -1
  109. package/dist/es/standards-sdk.es127.js +2 -306
  110. package/dist/es/standards-sdk.es127.js.map +1 -1
  111. package/dist/es/standards-sdk.es128.js +83 -418
  112. package/dist/es/standards-sdk.es128.js.map +1 -1
  113. package/dist/es/standards-sdk.es129.js +36 -351
  114. package/dist/es/standards-sdk.es129.js.map +1 -1
  115. package/dist/es/standards-sdk.es13.js +1 -1
  116. package/dist/es/standards-sdk.es130.js +2 -1116
  117. package/dist/es/standards-sdk.es130.js.map +1 -1
  118. package/dist/es/standards-sdk.es131.js +215 -188
  119. package/dist/es/standards-sdk.es131.js.map +1 -1
  120. package/dist/es/standards-sdk.es132.js +1055 -1482
  121. package/dist/es/standards-sdk.es132.js.map +1 -1
  122. package/dist/es/standards-sdk.es133.js +306 -1236
  123. package/dist/es/standards-sdk.es133.js.map +1 -1
  124. package/dist/es/standards-sdk.es134.js +419 -14
  125. package/dist/es/standards-sdk.es134.js.map +1 -1
  126. package/dist/es/standards-sdk.es135.js +350 -82
  127. package/dist/es/standards-sdk.es135.js.map +1 -1
  128. package/dist/es/standards-sdk.es136.js +1107 -72
  129. package/dist/es/standards-sdk.es136.js.map +1 -1
  130. package/dist/es/standards-sdk.es137.js +181 -866
  131. package/dist/es/standards-sdk.es137.js.map +1 -1
  132. package/dist/es/standards-sdk.es138.js +1558 -51
  133. package/dist/es/standards-sdk.es138.js.map +1 -1
  134. package/dist/es/standards-sdk.es139.js +1255 -159
  135. package/dist/es/standards-sdk.es139.js.map +1 -1
  136. package/dist/es/standards-sdk.es14.js +1 -1
  137. package/dist/es/standards-sdk.es140.js +17 -7
  138. package/dist/es/standards-sdk.es140.js.map +1 -1
  139. package/dist/es/standards-sdk.es141.js +79 -78
  140. package/dist/es/standards-sdk.es141.js.map +1 -1
  141. package/dist/es/standards-sdk.es142.js +75 -59
  142. package/dist/es/standards-sdk.es142.js.map +1 -1
  143. package/dist/es/standards-sdk.es143.js +893 -30
  144. package/dist/es/standards-sdk.es143.js.map +1 -1
  145. package/dist/es/standards-sdk.es144.js +60 -34
  146. package/dist/es/standards-sdk.es144.js.map +1 -1
  147. package/dist/es/standards-sdk.es145.js +159 -28
  148. package/dist/es/standards-sdk.es145.js.map +1 -1
  149. package/dist/es/standards-sdk.es146.js +7 -138
  150. package/dist/es/standards-sdk.es146.js.map +1 -1
  151. package/dist/es/standards-sdk.es147.js +80 -36
  152. package/dist/es/standards-sdk.es147.js.map +1 -1
  153. package/dist/es/standards-sdk.es148.js +44 -12461
  154. package/dist/es/standards-sdk.es148.js.map +1 -1
  155. package/dist/es/standards-sdk.es149.js +30 -242
  156. package/dist/es/standards-sdk.es149.js.map +1 -1
  157. package/dist/es/standards-sdk.es15.js +1 -1
  158. package/dist/es/standards-sdk.es150.js +34 -172
  159. package/dist/es/standards-sdk.es150.js.map +1 -1
  160. package/dist/es/standards-sdk.es151.js +45 -322
  161. package/dist/es/standards-sdk.es151.js.map +1 -1
  162. package/dist/es/standards-sdk.es152.js +120 -328
  163. package/dist/es/standards-sdk.es152.js.map +1 -1
  164. package/dist/es/standards-sdk.es153.js +40 -451
  165. package/dist/es/standards-sdk.es153.js.map +1 -1
  166. package/dist/es/standards-sdk.es154.js +12418 -267
  167. package/dist/es/standards-sdk.es154.js.map +1 -1
  168. package/dist/es/standards-sdk.es155.js +15 -74
  169. package/dist/es/standards-sdk.es155.js.map +1 -1
  170. package/dist/es/standards-sdk.es156.js +54 -15
  171. package/dist/es/standards-sdk.es156.js.map +1 -1
  172. package/dist/es/standards-sdk.es157.js +70 -59
  173. package/dist/es/standards-sdk.es157.js.map +1 -1
  174. package/dist/es/standards-sdk.es158.js +73 -48
  175. package/dist/es/standards-sdk.es158.js.map +1 -1
  176. package/dist/es/standards-sdk.es159.js +59 -70
  177. package/dist/es/standards-sdk.es159.js.map +1 -1
  178. package/dist/es/standards-sdk.es16.js +5 -5
  179. package/dist/es/standards-sdk.es160.js +160 -160
  180. package/dist/es/standards-sdk.es160.js.map +1 -1
  181. package/dist/es/standards-sdk.es161.js +312 -212
  182. package/dist/es/standards-sdk.es161.js.map +1 -1
  183. package/dist/es/standards-sdk.es162.js +335 -228
  184. package/dist/es/standards-sdk.es162.js.map +1 -1
  185. package/dist/es/standards-sdk.es163.js +446 -112
  186. package/dist/es/standards-sdk.es163.js.map +1 -1
  187. package/dist/es/standards-sdk.es164.js +320 -115
  188. package/dist/es/standards-sdk.es164.js.map +1 -1
  189. package/dist/es/standards-sdk.es165.js +65 -150
  190. package/dist/es/standards-sdk.es165.js.map +1 -1
  191. package/dist/es/standards-sdk.es166.js +223 -166
  192. package/dist/es/standards-sdk.es166.js.map +1 -1
  193. package/dist/es/standards-sdk.es167.js +153 -120
  194. package/dist/es/standards-sdk.es167.js.map +1 -1
  195. package/dist/es/standards-sdk.es168.js +178 -287
  196. package/dist/es/standards-sdk.es168.js.map +1 -1
  197. package/dist/es/standards-sdk.es169.js +218 -238
  198. package/dist/es/standards-sdk.es169.js.map +1 -1
  199. package/dist/es/standards-sdk.es170.js +75 -72
  200. package/dist/es/standards-sdk.es170.js.map +1 -1
  201. package/dist/es/standards-sdk.es171.js +129 -0
  202. package/dist/es/standards-sdk.es171.js.map +1 -0
  203. package/dist/es/standards-sdk.es172.js +164 -0
  204. package/dist/es/standards-sdk.es172.js.map +1 -0
  205. package/dist/es/standards-sdk.es173.js +188 -0
  206. package/dist/es/standards-sdk.es173.js.map +1 -0
  207. package/dist/es/standards-sdk.es174.js +142 -0
  208. package/dist/es/standards-sdk.es174.js.map +1 -0
  209. package/dist/es/standards-sdk.es175.js +334 -0
  210. package/dist/es/standards-sdk.es175.js.map +1 -0
  211. package/dist/es/standards-sdk.es176.js +262 -0
  212. package/dist/es/standards-sdk.es176.js.map +1 -0
  213. package/dist/es/standards-sdk.es177.js +119 -0
  214. package/dist/es/standards-sdk.es177.js.map +1 -0
  215. package/dist/es/standards-sdk.es18.js +12 -12
  216. package/dist/es/standards-sdk.es19.js +9 -9
  217. package/dist/es/standards-sdk.es2.js +2 -2
  218. package/dist/es/standards-sdk.es20.js +1 -1
  219. package/dist/es/standards-sdk.es21.js +1 -1
  220. package/dist/es/standards-sdk.es22.js +1 -1
  221. package/dist/es/standards-sdk.es23.js +1 -1
  222. package/dist/es/standards-sdk.es24.js +1 -1
  223. package/dist/es/standards-sdk.es25.js +1 -1
  224. package/dist/es/standards-sdk.es26.js +1 -1
  225. package/dist/es/standards-sdk.es27.js +12 -12
  226. package/dist/es/standards-sdk.es30.js +2 -2
  227. package/dist/es/standards-sdk.es31.js +4 -4
  228. package/dist/es/standards-sdk.es32.js +1 -1
  229. package/dist/es/standards-sdk.es35.js +6 -6
  230. package/dist/es/standards-sdk.es36.js +4 -4
  231. package/dist/es/standards-sdk.es37.js +2 -2
  232. package/dist/es/standards-sdk.es38.js +2 -2
  233. package/dist/es/standards-sdk.es39.js +1 -1
  234. package/dist/es/standards-sdk.es4.js +2 -2
  235. package/dist/es/standards-sdk.es40.js +1 -1
  236. package/dist/es/standards-sdk.es41.js +2 -2
  237. package/dist/es/standards-sdk.es46.js +1 -1
  238. package/dist/es/standards-sdk.es5.js +2 -2
  239. package/dist/es/standards-sdk.es51.js +1 -1
  240. package/dist/es/standards-sdk.es53.js +1 -1
  241. package/dist/es/standards-sdk.es56.js +2 -2
  242. package/dist/es/standards-sdk.es58.js +11 -55
  243. package/dist/es/standards-sdk.es58.js.map +1 -1
  244. package/dist/es/standards-sdk.es59.js +321 -35
  245. package/dist/es/standards-sdk.es59.js.map +1 -1
  246. package/dist/es/standards-sdk.es6.js +2 -2
  247. package/dist/es/standards-sdk.es60.js +39 -200
  248. package/dist/es/standards-sdk.es60.js.map +1 -1
  249. package/dist/es/standards-sdk.es61.js +103 -25
  250. package/dist/es/standards-sdk.es61.js.map +1 -1
  251. package/dist/es/standards-sdk.es62.js +164 -78
  252. package/dist/es/standards-sdk.es62.js.map +1 -1
  253. package/dist/es/standards-sdk.es63.js +222 -3
  254. package/dist/es/standards-sdk.es63.js.map +1 -1
  255. package/dist/es/standards-sdk.es64.js +122 -92
  256. package/dist/es/standards-sdk.es64.js.map +1 -1
  257. package/dist/es/standards-sdk.es65.js +40 -93
  258. package/dist/es/standards-sdk.es65.js.map +1 -1
  259. package/dist/es/standards-sdk.es66.js +266 -18
  260. package/dist/es/standards-sdk.es66.js.map +1 -1
  261. package/dist/es/standards-sdk.es67.js +34 -77
  262. package/dist/es/standards-sdk.es67.js.map +1 -1
  263. package/dist/es/standards-sdk.es68.js +85 -447
  264. package/dist/es/standards-sdk.es68.js.map +1 -1
  265. package/dist/es/standards-sdk.es69.js +3 -323
  266. package/dist/es/standards-sdk.es69.js.map +1 -1
  267. package/dist/es/standards-sdk.es7.js +1 -1
  268. package/dist/es/standards-sdk.es70.js +87 -194
  269. package/dist/es/standards-sdk.es70.js.map +1 -1
  270. package/dist/es/standards-sdk.es71.js +99 -71
  271. package/dist/es/standards-sdk.es71.js.map +1 -1
  272. package/dist/es/standards-sdk.es72.js +19 -71
  273. package/dist/es/standards-sdk.es72.js.map +1 -1
  274. package/dist/es/standards-sdk.es73.js +77 -143
  275. package/dist/es/standards-sdk.es73.js.map +1 -1
  276. package/dist/es/standards-sdk.es74.js +433 -44
  277. package/dist/es/standards-sdk.es74.js.map +1 -1
  278. package/dist/es/standards-sdk.es75.js +254 -334
  279. package/dist/es/standards-sdk.es75.js.map +1 -1
  280. package/dist/es/standards-sdk.es76.js +166 -454
  281. package/dist/es/standards-sdk.es76.js.map +1 -1
  282. package/dist/es/standards-sdk.es77.js +71 -364
  283. package/dist/es/standards-sdk.es77.js.map +1 -1
  284. package/dist/es/standards-sdk.es78.js +71 -89
  285. package/dist/es/standards-sdk.es78.js.map +1 -1
  286. package/dist/es/standards-sdk.es79.js +143 -125
  287. package/dist/es/standards-sdk.es79.js.map +1 -1
  288. package/dist/es/standards-sdk.es80.js +67 -6
  289. package/dist/es/standards-sdk.es80.js.map +1 -1
  290. package/dist/es/standards-sdk.es81.js +400 -43
  291. package/dist/es/standards-sdk.es81.js.map +1 -1
  292. package/dist/es/standards-sdk.es82.js +476 -81
  293. package/dist/es/standards-sdk.es82.js.map +1 -1
  294. package/dist/es/standards-sdk.es83.js +332 -315
  295. package/dist/es/standards-sdk.es83.js.map +1 -1
  296. package/dist/es/standards-sdk.es84.js +88 -280
  297. package/dist/es/standards-sdk.es84.js.map +1 -1
  298. package/dist/es/standards-sdk.es85.js +125 -61
  299. package/dist/es/standards-sdk.es85.js.map +1 -1
  300. package/dist/es/standards-sdk.es86.js +6 -47
  301. package/dist/es/standards-sdk.es86.js.map +1 -1
  302. package/dist/es/standards-sdk.es87.js +44 -147
  303. package/dist/es/standards-sdk.es87.js.map +1 -1
  304. package/dist/es/standards-sdk.es88.js +94 -60
  305. package/dist/es/standards-sdk.es88.js.map +1 -1
  306. package/dist/es/standards-sdk.es89.js +339 -21
  307. package/dist/es/standards-sdk.es89.js.map +1 -1
  308. package/dist/es/standards-sdk.es9.js +2 -2
  309. package/dist/es/standards-sdk.es90.js +279 -23
  310. package/dist/es/standards-sdk.es90.js.map +1 -1
  311. package/dist/es/standards-sdk.es91.js +51 -230
  312. package/dist/es/standards-sdk.es91.js.map +1 -1
  313. package/dist/es/standards-sdk.es92.js +48 -281
  314. package/dist/es/standards-sdk.es92.js.map +1 -1
  315. package/dist/es/standards-sdk.es93.js +133 -140
  316. package/dist/es/standards-sdk.es93.js.map +1 -1
  317. package/dist/es/standards-sdk.es94.js +54 -132
  318. package/dist/es/standards-sdk.es94.js.map +1 -1
  319. package/dist/es/standards-sdk.es95.js +26 -45
  320. package/dist/es/standards-sdk.es95.js.map +1 -1
  321. package/dist/es/standards-sdk.es96.js +23 -263
  322. package/dist/es/standards-sdk.es96.js.map +1 -1
  323. package/dist/es/standards-sdk.es97.js +233 -95
  324. package/dist/es/standards-sdk.es97.js.map +1 -1
  325. package/dist/es/standards-sdk.es98.js +260 -79
  326. package/dist/es/standards-sdk.es98.js.map +1 -1
  327. package/dist/es/standards-sdk.es99.js +156 -29
  328. package/dist/es/standards-sdk.es99.js.map +1 -1
  329. package/package.json +16 -3
@@ -1,238 +1,605 @@
1
- import { detectCryptoEnvironment } from "./standards-sdk.es123.js";
2
- import { NodeHashAdapter, WebHashAdapter, FallbackHashAdapter } from "./standards-sdk.es122.js";
3
- class NodeHmacAdapter {
4
- constructor(nodeHmac) {
5
- this.nodeHmac = nodeHmac;
6
- }
7
- update(data) {
8
- this.nodeHmac.update(data);
9
- return this;
10
- }
11
- digest(encoding) {
12
- return this.nodeHmac.digest(encoding);
13
- }
14
- }
15
- class WebHmacAdapter {
16
- constructor(key, algorithm = "sha256") {
17
- this.key = key;
18
- this.algorithm = algorithm;
19
- this.data = [];
20
- }
21
- update(data) {
22
- this.data.push(data);
23
- return this;
24
- }
25
- async digest(encoding) {
26
- const combined = Buffer.concat(this.data);
27
- const keyBytes = new Uint8Array(this.key);
28
- const webCrypto = globalThis.crypto;
29
- if (!webCrypto?.subtle) {
30
- throw new Error("WebCrypto not available");
31
- }
32
- const keyBuffer = await webCrypto.subtle.importKey(
33
- "raw",
34
- keyBytes,
35
- { name: "HMAC", hash: this.mapAlgorithm(this.algorithm) },
36
- false,
37
- ["sign"]
38
- );
39
- const signature = await webCrypto.subtle.sign(
40
- "HMAC",
41
- keyBuffer,
42
- new Uint8Array(combined)
43
- );
44
- if (encoding === "hex") {
45
- return Array.from(new Uint8Array(signature)).map((b) => b.toString(16).padStart(2, "0")).join("");
1
+ import { PrivateKey } from "@hashgraph/sdk";
2
+ var KeyType = /* @__PURE__ */ ((KeyType2) => {
3
+ KeyType2["ED25519"] = "ed25519";
4
+ KeyType2["ECDSA"] = "ecdsa";
5
+ KeyType2["UNKNOWN"] = "unknown";
6
+ return KeyType2;
7
+ })(KeyType || {});
8
+ const _KeyTypeDetector = class _KeyTypeDetector {
9
+ /**
10
+ * Detects private key type from various input formats without throwing errors
11
+ *
12
+ * This detector is designed for private keys only. It uses various heuristics to determine
13
+ * the key type for ambiguous 32-byte keys, including byte patterns and statistical analysis.
14
+ *
15
+ * For ambiguous cases (where confidence is 'uncertain'), if you have the associated account ID,
16
+ * you can use the Hedera mirror node to confirm the key type.
17
+ *
18
+ * @param keyInput - The key to detect, can be a string (hex, base64, PEM), Buffer, or Uint8Array
19
+ * @returns KeyInfo object containing the detected key type and metadata
20
+ *
21
+ * @example
22
+ * // Detect from hex string
23
+ * const info1 = KeyTypeDetector.detect('0x7f96cea0c0d9d5bfb3ab8a42cf0cea44d57f62f2e068f8e5a3251914a9252b04');
24
+ *
25
+ * // Detect from DER-encoded string
26
+ * const info2 = KeyTypeDetector.detect(privateKey.toStringDer());
27
+ *
28
+ * // Detect from PEM format
29
+ * const info3 = KeyTypeDetector.detect(`-----BEGIN PRIVATE KEY-----
30
+ * MC4CAQAwBQYDK2VwBCIEIGRchBsQGQduAAGBQ7GAkKCKkmQ3EGCARwHsHiRqTNR9
31
+ * -----END PRIVATE KEY-----`);
32
+ */
33
+ static detect(keyInput) {
34
+ try {
35
+ let keyBytes;
36
+ let originalFormat = "raw";
37
+ if (typeof keyInput === "string") {
38
+ let trimmed = keyInput.trim();
39
+ if (trimmed.includes("-----BEGIN")) {
40
+ return this.detectFromPem(trimmed);
41
+ }
42
+ if (trimmed.toLowerCase().startsWith("0x")) {
43
+ trimmed = trimmed.substring(2);
44
+ }
45
+ if (this.isValidHex(trimmed)) {
46
+ keyBytes = this.hexToBytes(trimmed);
47
+ originalFormat = "hex";
48
+ } else if (this.isBase64(trimmed)) {
49
+ keyBytes = Buffer.from(trimmed, "base64");
50
+ originalFormat = "der";
51
+ } else {
52
+ return {
53
+ type: "unknown",
54
+ format: "raw",
55
+ isPrivateKey: false,
56
+ confidence: "certain"
57
+ };
58
+ }
59
+ } else if (keyInput instanceof Buffer) {
60
+ keyBytes = new Uint8Array(keyInput);
61
+ } else {
62
+ keyBytes = keyInput;
63
+ }
64
+ return this.detectFromBytes(keyBytes, originalFormat);
65
+ } catch (error) {
66
+ return {
67
+ type: "unknown",
68
+ format: "raw",
69
+ isPrivateKey: false,
70
+ confidence: "certain"
71
+ };
46
72
  }
47
- return Buffer.from(signature);
48
73
  }
49
- mapAlgorithm(algorithm) {
50
- const algorithmMap = {
51
- sha256: "SHA-256",
52
- sha1: "SHA-1",
53
- sha512: "SHA-512"
74
+ /**
75
+ * Detect key type from raw bytes
76
+ *
77
+ * @param bytes - The raw bytes of the key
78
+ * @param format - The original format of the key
79
+ * @returns KeyInfo object with detection results
80
+ * @private
81
+ */
82
+ static detectFromBytes(bytes, format) {
83
+ if (this.hasPrefix(bytes, this.ED25519_PUBLIC_KEY_PREFIX)) {
84
+ const keyStart = this.ED25519_PUBLIC_KEY_PREFIX.length;
85
+ return {
86
+ type: "ed25519",
87
+ format: "der",
88
+ isPrivateKey: false,
89
+ rawBytes: bytes.slice(keyStart),
90
+ confidence: "certain"
91
+ };
92
+ }
93
+ if (this.hasPrefix(bytes, this.ED25519_PRIVATE_KEY_PREFIX)) {
94
+ const keyStart = this.ED25519_PRIVATE_KEY_PREFIX.length;
95
+ if (bytes.length >= keyStart + 32) {
96
+ return {
97
+ type: "ed25519",
98
+ format: "der",
99
+ isPrivateKey: true,
100
+ rawBytes: bytes.slice(keyStart, keyStart + 32),
101
+ confidence: "certain"
102
+ };
103
+ }
104
+ }
105
+ if (this.hasPrefix(bytes, this.ECDSA_SECP256K1_PUBLIC_KEY_PREFIX)) {
106
+ const keyStart = this.ECDSA_SECP256K1_PUBLIC_KEY_PREFIX.length;
107
+ return {
108
+ type: "ecdsa",
109
+ format: "der",
110
+ isPrivateKey: false,
111
+ rawBytes: bytes.slice(keyStart),
112
+ confidence: "certain"
113
+ };
114
+ }
115
+ if (this.hasPrefix(bytes, this.ECDSA_SECP256K1_PRIVATE_KEY_PREFIX_SHORT)) {
116
+ const keyStart = this.ECDSA_SECP256K1_PRIVATE_KEY_PREFIX_SHORT.length;
117
+ return {
118
+ type: "ecdsa",
119
+ format: "der",
120
+ isPrivateKey: true,
121
+ rawBytes: bytes.slice(keyStart),
122
+ confidence: "certain"
123
+ };
124
+ }
125
+ if (this.hasPrefix(bytes, this.ECDSA_SECP256K1_PRIVATE_KEY_PREFIX)) {
126
+ const keyStart = this.ECDSA_SECP256K1_PRIVATE_KEY_PREFIX.length;
127
+ return {
128
+ type: "ecdsa",
129
+ format: "der",
130
+ isPrivateKey: true,
131
+ rawBytes: bytes.slice(keyStart, keyStart + 32),
132
+ confidence: "certain"
133
+ };
134
+ }
135
+ if (this.hasPrefix(bytes, this.ECDSA_SECP256K1_PRIVATE_KEY_PREFIX_LONG)) {
136
+ const keyStart = this.ECDSA_SECP256K1_PRIVATE_KEY_PREFIX_LONG.length;
137
+ return {
138
+ type: "ecdsa",
139
+ format: "der",
140
+ isPrivateKey: true,
141
+ rawBytes: bytes.slice(keyStart, keyStart + 32),
142
+ confidence: "certain"
143
+ };
144
+ }
145
+ if (bytes.length > 36 && this.containsECDSAPrivateKeyPattern(bytes)) {
146
+ return {
147
+ type: "ecdsa",
148
+ format: "der",
149
+ isPrivateKey: true,
150
+ rawBytes: this.extractECDSAPrivateKey(bytes),
151
+ confidence: "certain"
152
+ };
153
+ }
154
+ switch (bytes.length) {
155
+ case this.ED25519_PUBLIC_KEY_LENGTH:
156
+ if (format === "hex") {
157
+ const hexStr = Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
158
+ const privateResult = this.tryCreateKey(hexStr);
159
+ if (privateResult.type !== "unknown") {
160
+ return privateResult;
161
+ }
162
+ }
163
+ return {
164
+ type: "unknown",
165
+ format,
166
+ isPrivateKey: false,
167
+ rawBytes: bytes,
168
+ confidence: "certain"
169
+ };
170
+ case this.ED25519_EXPANDED_PRIVATE_KEY_LENGTH:
171
+ return {
172
+ type: "ed25519",
173
+ format,
174
+ isPrivateKey: true,
175
+ rawBytes: bytes,
176
+ confidence: "certain"
177
+ };
178
+ }
179
+ return {
180
+ type: "unknown",
181
+ format,
182
+ isPrivateKey: false,
183
+ rawBytes: bytes,
184
+ confidence: "certain"
54
185
  };
55
- return algorithmMap[algorithm.toLowerCase()] || "SHA-256";
56
- }
57
- }
58
- class FallbackHmacAdapter {
59
- constructor(key, algorithm = "sha256") {
60
- this.key = key;
61
- this.algorithm = algorithm;
62
- this.data = [];
63
186
  }
64
- update(data) {
65
- this.data.push(data);
66
- return this;
67
- }
68
- digest(encoding) {
69
- const combined = Buffer.concat(this.data);
70
- const hash2 = this.simpleHmac(combined, this.key);
71
- if (encoding === "hex") {
72
- return hash2.toString(16).padStart(8, "0");
187
+ /**
188
+ * Detect key type from PEM format
189
+ *
190
+ * @param pem - The PEM-encoded key string
191
+ * @returns KeyInfo object with detection results
192
+ * @private
193
+ */
194
+ static detectFromPem(pem) {
195
+ const trimmedPem = pem.trim();
196
+ const isPrivateKey = trimmedPem.includes("PRIVATE KEY");
197
+ const pemTypes = {
198
+ EC_PRIVATE: /-----BEGIN EC PRIVATE KEY-----/,
199
+ EC_PUBLIC: /-----BEGIN EC PUBLIC KEY-----/,
200
+ PRIVATE: /-----BEGIN PRIVATE KEY-----/,
201
+ PUBLIC: /-----BEGIN PUBLIC KEY-----/
202
+ };
203
+ let isECKey = false;
204
+ for (const [type, regex] of Object.entries(pemTypes)) {
205
+ if (regex.test(trimmedPem) && type.includes("EC")) {
206
+ isECKey = true;
207
+ break;
208
+ }
73
209
  }
74
- return hash2.toString();
75
- }
76
- simpleHmac(data, key) {
77
- let hash2 = 0;
78
- for (let i = 0; i < data.length; i++) {
79
- const keyByte = key[i % key.length];
80
- hash2 = (hash2 << 5) - hash2 + data[i] + keyByte & 4294967295;
210
+ const base64Match = trimmedPem.match(
211
+ /-----BEGIN[\s\S]+?-----[\r\n]+([\s\S]+?)[\r\n]+-----END/
212
+ );
213
+ if (!base64Match) {
214
+ return {
215
+ type: "unknown",
216
+ format: "pem",
217
+ isPrivateKey,
218
+ confidence: "certain"
219
+ };
81
220
  }
82
- return Math.abs(hash2);
83
- }
84
- }
85
- class NodeCryptoAdapter {
86
- constructor() {
221
+ const base64Content = base64Match[1].replace(/\s/g, "");
87
222
  try {
88
- const moduleName = "crypto";
89
- this.crypto = require(moduleName);
90
- } catch (error) {
91
- throw new Error("Node.js crypto module not available");
223
+ const derBytes = Buffer.from(base64Content, "base64");
224
+ const result = this.detectFromBytes(new Uint8Array(derBytes), "der");
225
+ if (result.type === "unknown" && isECKey) {
226
+ return {
227
+ type: "ecdsa",
228
+ format: "pem",
229
+ isPrivateKey,
230
+ rawBytes: derBytes,
231
+ confidence: "certain"
232
+ };
233
+ }
234
+ return {
235
+ ...result,
236
+ format: "pem"
237
+ };
238
+ } catch {
239
+ return {
240
+ type: "unknown",
241
+ format: "pem",
242
+ isPrivateKey,
243
+ confidence: "certain"
244
+ };
92
245
  }
93
246
  }
94
- createHash(algorithm) {
95
- return new NodeHashAdapter(this.crypto.createHash(algorithm));
96
- }
97
- createHmac(algorithm, key) {
98
- return new NodeHmacAdapter(this.crypto.createHmac(algorithm, key));
99
- }
100
- async pbkdf2(password, salt, iterations, keylen, digest) {
101
- return new Promise((resolve, reject) => {
102
- this.crypto.pbkdf2(
103
- password,
104
- salt,
105
- iterations,
106
- keylen,
107
- digest,
108
- (err, derivedKey) => {
109
- if (err) reject(err);
110
- else resolve(derivedKey);
247
+ /**
248
+ * Try to create a key using Hedera SDK to validate the type
249
+ *
250
+ * @param keyInput - The key input string or bytes
251
+ * @returns KeyInfo object with detection results
252
+ * @private
253
+ */
254
+ static tryCreateKey(keyInput) {
255
+ try {
256
+ if (typeof keyInput === "string") {
257
+ let keyStr = keyInput.trim();
258
+ if (keyStr.toLowerCase().startsWith("0x")) {
259
+ keyStr = keyStr.substring(2);
111
260
  }
112
- );
113
- });
114
- }
115
- timingSafeEqual(a, b) {
116
- return this.crypto.timingSafeEqual(a, b);
117
- }
118
- }
119
- class WebCryptoAdapter {
120
- createHash(algorithm) {
121
- return new WebHashAdapter(algorithm);
122
- }
123
- createHmac(algorithm, key) {
124
- return new WebHmacAdapter(key, algorithm);
261
+ if (this.isValidHex(keyStr) && keyStr.length === 64) {
262
+ const keyBytes = this.hexToBytes(keyStr);
263
+ const signatureResult = this.detectBySignature(keyStr);
264
+ if (signatureResult.type !== "unknown") {
265
+ return {
266
+ type: signatureResult.type,
267
+ format: "hex",
268
+ isPrivateKey: true,
269
+ rawBytes: keyBytes,
270
+ confidence: signatureResult.confidence,
271
+ warning: signatureResult.warning
272
+ };
273
+ }
274
+ return {
275
+ type: "unknown",
276
+ format: "hex",
277
+ isPrivateKey: false,
278
+ rawBytes: keyBytes,
279
+ confidence: "certain"
280
+ };
281
+ }
282
+ }
283
+ } catch {
284
+ }
285
+ return {
286
+ type: "unknown",
287
+ format: "hex",
288
+ isPrivateKey: false,
289
+ rawBytes: new Uint8Array(),
290
+ confidence: "certain"
291
+ };
125
292
  }
126
- async pbkdf2(password, salt, iterations, keylen, digest) {
127
- const encoder = new TextEncoder();
128
- const webCrypto = globalThis.crypto;
129
- if (!webCrypto?.subtle) {
130
- throw new Error("WebCrypto not available");
131
- }
132
- const keyMaterial = await webCrypto.subtle.importKey(
133
- "raw",
134
- encoder.encode(password),
135
- { name: "PBKDF2" },
136
- false,
137
- ["deriveBits"]
293
+ /**
294
+ * Detect key type by attempting to sign a message with both algorithms
295
+ *
296
+ * For ambiguous cases where both algorithms can use the key, this method
297
+ * uses heuristics to make a best-effort determination. For production use
298
+ * with ambiguous keys, consider using the Hedera mirror node to confirm
299
+ * the key type if you have the associated account ID.
300
+ *
301
+ * @param hexKey - The hex string representation of the key
302
+ * @returns Object containing type, confidence level, and optional warning
303
+ * @private
304
+ */
305
+ static detectBySignature(hexKey) {
306
+ const keyBigInt = BigInt("0x" + hexKey);
307
+ const secp256k1Order = BigInt(
308
+ "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"
138
309
  );
139
- const derivedBits = await webCrypto.subtle.deriveBits(
140
- {
141
- name: "PBKDF2",
142
- salt: new Uint8Array(salt),
143
- iterations,
144
- hash: this.mapDigest(digest)
145
- },
146
- keyMaterial,
147
- keylen * 8
148
- );
149
- return Buffer.from(derivedBits);
150
- }
151
- timingSafeEqual(a, b) {
152
- if (a.length !== b.length) return false;
153
- let result = 0;
154
- for (let i = 0; i < a.length; i++) {
155
- result |= a[i] ^ b[i];
310
+ if (keyBigInt === 0n) {
311
+ return {
312
+ type: "ed25519",
313
+ confidence: "certain"
314
+ };
156
315
  }
157
- return result === 0;
158
- }
159
- mapDigest(digest) {
160
- const digestMap = {
161
- sha256: "SHA-256",
162
- sha1: "SHA-1",
163
- sha512: "SHA-512"
316
+ if (keyBigInt >= secp256k1Order) {
317
+ return {
318
+ type: "ed25519",
319
+ confidence: "certain"
320
+ };
321
+ }
322
+ let ed25519CanSign = false;
323
+ let ecdsaCanSign = false;
324
+ try {
325
+ const ed25519Key = PrivateKey.fromStringED25519(hexKey);
326
+ const testMessage = new Uint8Array([1, 2, 3, 4, 5]);
327
+ const signature = ed25519Key.sign(testMessage);
328
+ if (ed25519Key.publicKey.verify(testMessage, signature)) {
329
+ ed25519CanSign = true;
330
+ }
331
+ } catch {
332
+ }
333
+ try {
334
+ const ecdsaKey = PrivateKey.fromStringECDSA(hexKey);
335
+ const testMessage = new Uint8Array([1, 2, 3, 4, 5]);
336
+ const signature = ecdsaKey.sign(testMessage);
337
+ if (ecdsaKey.publicKey.verify(testMessage, signature)) {
338
+ ecdsaCanSign = true;
339
+ }
340
+ } catch {
341
+ }
342
+ if (ed25519CanSign && ecdsaCanSign) {
343
+ const keyBytes = this.hexToBytes(hexKey);
344
+ if (keyBytes[0] === 168 && keyBytes[1] === 1) {
345
+ return {
346
+ type: "ed25519",
347
+ confidence: "uncertain",
348
+ warning: "Detection based on byte pattern heuristic. Both ED25519 and ECDSA accept this key."
349
+ };
350
+ }
351
+ let highBytes = 0;
352
+ for (const byte of keyBytes) {
353
+ if (byte >= 128) highBytes++;
354
+ }
355
+ const highByteRatio = highBytes / keyBytes.length;
356
+ if (highByteRatio >= 0.4 && highByteRatio <= 0.6) {
357
+ return {
358
+ type: "ecdsa",
359
+ confidence: "uncertain",
360
+ warning: "Detection based on entropy heuristic. Both ED25519 and ECDSA accept this key."
361
+ };
362
+ }
363
+ return {
364
+ type: "ecdsa",
365
+ confidence: "uncertain",
366
+ warning: "Detection based on entropy heuristic. Both ED25519 and ECDSA accept this key. Defaulting to ECDSA."
367
+ };
368
+ }
369
+ if (ed25519CanSign && !ecdsaCanSign) {
370
+ return {
371
+ type: "ed25519",
372
+ confidence: "certain"
373
+ };
374
+ }
375
+ if (ecdsaCanSign && !ed25519CanSign) {
376
+ return {
377
+ type: "ecdsa",
378
+ confidence: "certain"
379
+ };
380
+ }
381
+ return {
382
+ type: "unknown",
383
+ confidence: "certain"
164
384
  };
165
- return digestMap[digest.toLowerCase()] || "SHA-256";
166
385
  }
167
- }
168
- class FallbackCryptoAdapter {
169
- createHash(algorithm) {
170
- return new FallbackHashAdapter(algorithm);
386
+ /**
387
+ * Check if a string is valid hexadecimal with even length
388
+ *
389
+ * @param str - The string to check
390
+ * @returns True if the string is valid hex with even length
391
+ * @private
392
+ */
393
+ static isValidHex(str) {
394
+ return /^[0-9a-fA-F]+$/.test(str) && str.length % 2 === 0;
395
+ }
396
+ /**
397
+ * Check if a string is valid base64
398
+ *
399
+ * @param str - The string to check
400
+ * @returns True if the string is valid base64
401
+ * @private
402
+ */
403
+ static isBase64(str) {
404
+ try {
405
+ return Buffer.from(str, "base64").toString("base64") === str;
406
+ } catch {
407
+ return false;
408
+ }
171
409
  }
172
- createHmac(algorithm, key) {
173
- return new FallbackHmacAdapter(key, algorithm);
410
+ /**
411
+ * Convert a hex string to bytes
412
+ *
413
+ * @param hex - The hex string to convert
414
+ * @returns Uint8Array of bytes
415
+ * @private
416
+ */
417
+ static hexToBytes(hex) {
418
+ const bytes = new Uint8Array(hex.length / 2);
419
+ for (let i = 0; i < hex.length; i += 2) {
420
+ bytes[i / 2] = parseInt(hex.substr(i, 2), 16);
421
+ }
422
+ return bytes;
423
+ }
424
+ /**
425
+ * Check if bytes start with a specific prefix
426
+ *
427
+ * @param bytes - The bytes to check
428
+ * @param prefix - The prefix to look for
429
+ * @returns True if bytes start with the prefix
430
+ * @private
431
+ */
432
+ static hasPrefix(bytes, prefix) {
433
+ if (bytes.length < prefix.length) return false;
434
+ for (let i = 0; i < prefix.length; i++) {
435
+ if (bytes[i] !== prefix[i]) return false;
436
+ }
437
+ return true;
174
438
  }
175
- async pbkdf2(password, salt, iterations, keylen, digest) {
176
- const encoder = new TextEncoder();
177
- const passwordBuffer = Buffer.from(encoder.encode(password));
178
- let result = Buffer.alloc(keylen);
179
- for (let i = 0; i < iterations; i++) {
180
- const combined = Buffer.concat([passwordBuffer, salt, Buffer.from([i])]);
181
- let hash2 = 0;
182
- for (let j = 0; j < combined.length; j++) {
183
- hash2 = (hash2 << 5) - hash2 + combined[j] & 4294967295;
439
+ /**
440
+ * Check if bytes contain an ECDSA private key pattern
441
+ *
442
+ * @param bytes - The bytes to check
443
+ * @returns True if ECDSA private key pattern is found
444
+ * @private
445
+ */
446
+ static containsECDSAPrivateKeyPattern(bytes) {
447
+ for (let i = 0; i < bytes.length - 7; i++) {
448
+ if (bytes[i] === 48 && bytes[i + 1] === 116 && bytes[i + 2] === 2 && bytes[i + 3] === 1 && bytes[i + 4] === 1 && bytes[i + 5] === 4 && bytes[i + 6] === 32) {
449
+ return true;
184
450
  }
185
- result[i % keylen] ^= hash2 & 255;
186
451
  }
187
- return result;
452
+ return false;
188
453
  }
189
- timingSafeEqual(a, b) {
190
- if (a.length !== b.length) return false;
191
- let result = 0;
192
- for (let i = 0; i < a.length; i++) {
193
- result |= a[i] ^ b[i];
454
+ /**
455
+ * Extract ECDSA private key from DER structure
456
+ *
457
+ * @param bytes - The DER encoded bytes
458
+ * @returns The extracted private key bytes
459
+ * @private
460
+ */
461
+ static extractECDSAPrivateKey(bytes) {
462
+ for (let i = 0; i < bytes.length - 32; i++) {
463
+ if (bytes[i] === 4 && bytes[i + 1] === 32) {
464
+ return bytes.slice(i + 2, i + 34);
465
+ }
194
466
  }
195
- return result === 0;
467
+ return bytes;
196
468
  }
197
- }
198
- function getCryptoAdapter() {
199
- const env = detectCryptoEnvironment();
200
- switch (env.preferredAPI) {
201
- case "node":
202
- try {
203
- return new NodeCryptoAdapter();
204
- } catch {
205
- const globalCrypto = typeof globalThis !== "undefined" ? globalThis.crypto : void 0;
206
- if (typeof globalCrypto?.subtle !== "undefined") {
207
- return new WebCryptoAdapter();
208
- }
209
- return new FallbackCryptoAdapter();
469
+ };
470
+ _KeyTypeDetector.ED25519_PUBLIC_KEY_LENGTH = 32;
471
+ _KeyTypeDetector.ED25519_EXPANDED_PRIVATE_KEY_LENGTH = 64;
472
+ _KeyTypeDetector.ED25519_PUBLIC_KEY_PREFIX = Buffer.from([
473
+ 48,
474
+ 42,
475
+ 48,
476
+ 5,
477
+ 6,
478
+ 3,
479
+ 43,
480
+ 101,
481
+ 112,
482
+ 3,
483
+ 33,
484
+ 0
485
+ ]);
486
+ _KeyTypeDetector.ED25519_PRIVATE_KEY_PREFIX = Buffer.from([
487
+ 48,
488
+ 46,
489
+ 2,
490
+ 1,
491
+ 0,
492
+ 48,
493
+ 5,
494
+ 6,
495
+ 3,
496
+ 43,
497
+ 101,
498
+ 112,
499
+ 4,
500
+ 34,
501
+ 4,
502
+ 32
503
+ ]);
504
+ _KeyTypeDetector.ECDSA_SECP256K1_PUBLIC_KEY_PREFIX = Buffer.from([
505
+ 48,
506
+ 86,
507
+ 48,
508
+ 16,
509
+ 6,
510
+ 7,
511
+ 42,
512
+ 134,
513
+ 72,
514
+ 206,
515
+ 61,
516
+ 2,
517
+ 1,
518
+ 6,
519
+ 5,
520
+ 43,
521
+ 129,
522
+ 4,
523
+ 0,
524
+ 10,
525
+ 3,
526
+ 66,
527
+ 0
528
+ ]);
529
+ _KeyTypeDetector.ECDSA_SECP256K1_PRIVATE_KEY_PREFIX = Buffer.from([
530
+ 48,
531
+ 116,
532
+ 2,
533
+ 1,
534
+ 1,
535
+ 4,
536
+ 32
537
+ ]);
538
+ _KeyTypeDetector.ECDSA_SECP256K1_PRIVATE_KEY_PREFIX_SHORT = Buffer.from([
539
+ 48,
540
+ 48,
541
+ 2,
542
+ 1,
543
+ 0,
544
+ 48,
545
+ 7,
546
+ 6,
547
+ 5,
548
+ 43,
549
+ 129,
550
+ 4,
551
+ 0,
552
+ 10,
553
+ 4,
554
+ 34,
555
+ 4,
556
+ 32
557
+ ]);
558
+ _KeyTypeDetector.ECDSA_SECP256K1_PRIVATE_KEY_PREFIX_LONG = Buffer.from(
559
+ [48, 119, 2, 1, 1, 4, 32]
560
+ );
561
+ let KeyTypeDetector = _KeyTypeDetector;
562
+ function detectKeyTypeFromString(privateKeyString) {
563
+ const keyInfo = KeyTypeDetector.detect(privateKeyString);
564
+ if (keyInfo.type !== "unknown") {
565
+ try {
566
+ const privateKey = keyInfo.type === "ecdsa" ? PrivateKey.fromStringECDSA(privateKeyString) : PrivateKey.fromStringED25519(privateKeyString);
567
+ const result = {
568
+ detectedType: keyInfo.type,
569
+ privateKey
570
+ };
571
+ if (keyInfo.confidence === "uncertain") {
572
+ result.warning = `Key type detection is uncertain. If you have the associated account ID, consider using the Hedera mirror node to confirm the key type.`;
210
573
  }
211
- case "web":
212
- return new WebCryptoAdapter();
213
- case "none":
214
- default:
215
- return new FallbackCryptoAdapter();
574
+ return result;
575
+ } catch (error) {
576
+ }
216
577
  }
217
- }
218
- async function hash(content, algorithm = "sha256") {
219
- const adapter = getCryptoAdapter();
220
- const hasher = adapter.createHash(algorithm);
221
- const buffer = typeof content === "string" ? Buffer.from(content) : content;
222
- const result = hasher.update(buffer).digest("hex");
223
- if (result instanceof Promise) {
224
- return await result;
578
+ try {
579
+ const privateKey = PrivateKey.fromStringECDSA(privateKeyString);
580
+ return {
581
+ detectedType: "ecdsa",
582
+ privateKey,
583
+ warning: `Using ECDSA as default. If you have the associated account ID, consider using the Hedera mirror node to confirm the key type.`
584
+ };
585
+ } catch (ecdsaError) {
586
+ try {
587
+ const privateKey = PrivateKey.fromStringED25519(privateKeyString);
588
+ return {
589
+ detectedType: "ed25519",
590
+ privateKey,
591
+ warning: `Using ED25519 as fallback. If you have the associated account ID, consider using the Hedera mirror node to confirm the key type.`
592
+ };
593
+ } catch (ed25519Error) {
594
+ throw new Error(
595
+ `Failed to parse private key as either ECDSA or ED25519: ${ecdsaError}`
596
+ );
597
+ }
225
598
  }
226
- return result;
227
599
  }
228
600
  export {
229
- FallbackCryptoAdapter,
230
- FallbackHmacAdapter,
231
- NodeCryptoAdapter,
232
- NodeHmacAdapter,
233
- WebCryptoAdapter,
234
- WebHmacAdapter,
235
- getCryptoAdapter,
236
- hash
601
+ KeyType,
602
+ KeyTypeDetector,
603
+ detectKeyTypeFromString
237
604
  };
238
605
  //# sourceMappingURL=standards-sdk.es125.js.map