@aeternity/aepp-sdk 12.1.2 → 13.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (475) hide show
  1. package/dist/aepp-sdk.browser-script.js +1 -1
  2. package/dist/aepp-sdk.browser-script.js.map +1 -1
  3. package/dist/aepp-sdk.browser.js +1 -1
  4. package/dist/aepp-sdk.browser.js.map +1 -1
  5. package/dist/aepp-sdk.js +6580 -8860
  6. package/dist/aepp-sdk.js.map +1 -1
  7. package/es/AeSdk.d.ts +7 -3
  8. package/es/AeSdk.mjs +17 -22
  9. package/es/AeSdk.mjs.map +1 -1
  10. package/es/AeSdkAepp.d.ts +6 -5
  11. package/es/AeSdkAepp.mjs +7 -30
  12. package/es/AeSdkAepp.mjs.map +1 -1
  13. package/es/AeSdkBase.d.ts +18 -140
  14. package/es/AeSdkBase.mjs +27 -185
  15. package/es/AeSdkBase.mjs.map +1 -1
  16. package/es/AeSdkMethods.d.ts +124 -0
  17. package/es/AeSdkMethods.mjs +122 -0
  18. package/es/AeSdkMethods.mjs.map +1 -0
  19. package/es/AeSdkWallet.d.ts +7 -21
  20. package/es/AeSdkWallet.mjs +38 -86
  21. package/es/AeSdkWallet.mjs.map +1 -1
  22. package/es/Node.d.ts +7 -12
  23. package/es/Node.mjs +34 -47
  24. package/es/Node.mjs.map +1 -1
  25. package/es/account/Base.d.ts +24 -40
  26. package/es/account/Base.mjs +1 -101
  27. package/es/account/Base.mjs.map +1 -1
  28. package/es/account/Generalized.d.ts +16 -0
  29. package/es/account/Generalized.mjs +111 -0
  30. package/es/account/Generalized.mjs.map +1 -0
  31. package/es/account/Ledger.d.ts +28 -0
  32. package/es/account/Ledger.mjs +101 -0
  33. package/es/account/Ledger.mjs.map +1 -0
  34. package/es/account/LedgerFactory.d.ts +39 -0
  35. package/es/account/LedgerFactory.mjs +81 -0
  36. package/es/account/LedgerFactory.mjs.map +1 -0
  37. package/es/account/Memory.d.ts +13 -17
  38. package/es/account/Memory.mjs +43 -65
  39. package/es/account/Memory.mjs.map +1 -1
  40. package/es/account/Rpc.d.ts +6 -8
  41. package/es/account/Rpc.mjs +14 -32
  42. package/es/account/Rpc.mjs.map +1 -1
  43. package/es/aens.d.ts +3 -3
  44. package/es/aens.mjs +42 -41
  45. package/es/aens.mjs.map +1 -1
  46. package/es/aepp-wallet-communication/connection/Browser.mjs +9 -13
  47. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -1
  48. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +3 -7
  49. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -1
  50. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +1 -1
  51. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +0 -31
  52. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -1
  53. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -1
  54. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +3 -3
  55. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +4 -41
  56. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -1
  57. package/es/aepp-wallet-communication/rpc/types.d.ts +7 -1
  58. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -1
  59. package/es/aepp-wallet-communication/schema.mjs +14 -68
  60. package/es/aepp-wallet-communication/schema.mjs.map +1 -1
  61. package/es/aepp-wallet-communication/wallet-detector.mjs +0 -3
  62. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -1
  63. package/es/apis/compiler/compiler.d.ts +23 -29
  64. package/es/apis/compiler/compiler.mjs +128 -189
  65. package/es/apis/compiler/compiler.mjs.map +1 -1
  66. package/es/apis/compiler/index.mjs.map +1 -1
  67. package/es/apis/compiler/models/index.d.ts +82 -135
  68. package/es/apis/compiler/models/index.mjs +1 -47
  69. package/es/apis/compiler/models/index.mjs.map +1 -1
  70. package/es/apis/compiler/models/mappers.d.ts +8 -8
  71. package/es/apis/compiler/models/mappers.mjs +165 -183
  72. package/es/apis/compiler/models/mappers.mjs.map +1 -1
  73. package/es/apis/compiler/models/parameters.d.ts +0 -1
  74. package/es/apis/compiler/models/parameters.mjs +5 -9
  75. package/es/apis/compiler/models/parameters.mjs.map +1 -1
  76. package/es/apis/node/index.mjs.map +1 -1
  77. package/es/apis/node/models/index.d.ts +48 -48
  78. package/es/apis/node/models/mappers.mjs +12 -6
  79. package/es/apis/node/models/mappers.mjs.map +1 -1
  80. package/es/apis/node/models/parameters.mjs.map +1 -1
  81. package/es/apis/node/node.mjs +43 -84
  82. package/es/apis/node/node.mjs.map +1 -1
  83. package/es/chain.d.ts +1 -1
  84. package/es/chain.mjs +33 -58
  85. package/es/chain.mjs.map +1 -1
  86. package/es/channel/Base.d.ts +195 -0
  87. package/es/channel/Base.mjs +290 -0
  88. package/es/channel/Base.mjs.map +1 -0
  89. package/es/channel/Contract.d.ts +247 -0
  90. package/es/channel/Contract.mjs +420 -0
  91. package/es/channel/Contract.mjs.map +1 -0
  92. package/es/channel/Spend.d.ts +217 -0
  93. package/es/channel/Spend.mjs +383 -0
  94. package/es/channel/Spend.mjs.map +1 -0
  95. package/es/channel/handlers.d.ts +8 -21
  96. package/es/channel/handlers.mjs +141 -891
  97. package/es/channel/handlers.mjs.map +1 -1
  98. package/es/channel/internal.d.ts +27 -21
  99. package/es/channel/internal.mjs +98 -190
  100. package/es/channel/internal.mjs.map +1 -1
  101. package/es/contract/{Compiler.d.ts → CompilerHttp.d.ts} +3 -3
  102. package/es/contract/{Compiler.mjs → CompilerHttp.mjs} +8 -13
  103. package/es/contract/CompilerHttp.mjs.map +1 -0
  104. package/es/contract/Contract.d.ts +235 -0
  105. package/es/contract/Contract.mjs +534 -0
  106. package/es/contract/Contract.mjs.map +1 -0
  107. package/es/contract/ga.d.ts +7 -33
  108. package/es/contract/ga.mjs +20 -112
  109. package/es/contract/ga.mjs.map +1 -1
  110. package/es/index.d.ts +9 -6
  111. package/es/index.mjs +8 -6
  112. package/es/index.mjs.map +1 -1
  113. package/es/oracle.d.ts +5 -5
  114. package/es/oracle.mjs +33 -39
  115. package/es/oracle.mjs.map +1 -1
  116. package/es/spend.d.ts +3 -3
  117. package/es/spend.mjs +17 -20
  118. package/es/spend.mjs.map +1 -1
  119. package/es/tx/builder/constants.d.ts +2 -1
  120. package/es/tx/builder/constants.mjs +12 -12
  121. package/es/tx/builder/constants.mjs.map +1 -1
  122. package/es/tx/builder/field-types/address.d.ts +15 -0
  123. package/es/tx/builder/field-types/address.mjs +42 -0
  124. package/es/tx/builder/field-types/address.mjs.map +1 -0
  125. package/es/tx/builder/field-types/addresses.d.ts +6 -0
  126. package/es/tx/builder/field-types/addresses.mjs +13 -0
  127. package/es/tx/builder/field-types/addresses.mjs.map +1 -0
  128. package/es/tx/builder/field-types/coin-amount.d.ts +1 -2
  129. package/es/tx/builder/field-types/coin-amount.mjs +4 -12
  130. package/es/tx/builder/field-types/coin-amount.mjs.map +1 -1
  131. package/es/tx/builder/field-types/deposit.d.ts +0 -1
  132. package/es/tx/builder/field-types/deposit.mjs +2 -4
  133. package/es/tx/builder/field-types/deposit.mjs.map +1 -1
  134. package/es/tx/builder/field-types/enumeration.d.ts +5 -0
  135. package/es/tx/builder/field-types/enumeration.mjs +21 -0
  136. package/es/tx/builder/field-types/enumeration.mjs.map +1 -0
  137. package/es/tx/builder/field-types/fee.d.ts +1 -9
  138. package/es/tx/builder/field-types/fee.mjs +9 -25
  139. package/es/tx/builder/field-types/fee.mjs.map +1 -1
  140. package/es/tx/builder/field-types/field.mjs +0 -2
  141. package/es/tx/builder/field-types/field.mjs.map +1 -1
  142. package/es/tx/builder/field-types/gas-limit.mjs +4 -9
  143. package/es/tx/builder/field-types/gas-limit.mjs.map +1 -1
  144. package/es/tx/builder/field-types/gas-price.d.ts +1 -2
  145. package/es/tx/builder/field-types/gas-price.mjs +3 -7
  146. package/es/tx/builder/field-types/gas-price.mjs.map +1 -1
  147. package/es/tx/builder/field-types/index.d.ts +23 -11
  148. package/es/tx/builder/field-types/index.mjs +10 -3
  149. package/es/tx/builder/field-types/index.mjs.map +1 -1
  150. package/es/tx/builder/field-types/name-fee.d.ts +0 -1
  151. package/es/tx/builder/field-types/name-fee.mjs +3 -5
  152. package/es/tx/builder/field-types/name-fee.mjs.map +1 -1
  153. package/es/tx/builder/field-types/name-id.d.ts +1 -4
  154. package/es/tx/builder/field-types/name-id.mjs +4 -10
  155. package/es/tx/builder/field-types/name-id.mjs.map +1 -1
  156. package/es/tx/builder/field-types/name.mjs +0 -2
  157. package/es/tx/builder/field-types/name.mjs.map +1 -1
  158. package/es/tx/builder/field-types/pointers.d.ts +23 -0
  159. package/es/tx/builder/field-types/pointers.mjs +36 -0
  160. package/es/tx/builder/field-types/pointers.mjs.map +1 -0
  161. package/es/tx/builder/field-types/short-u-int.mjs +0 -2
  162. package/es/tx/builder/field-types/short-u-int.mjs.map +1 -1
  163. package/es/tx/builder/field-types/u-int.d.ts +1 -1
  164. package/es/tx/builder/field-types/u-int.mjs +3 -4
  165. package/es/tx/builder/field-types/u-int.mjs.map +1 -1
  166. package/es/tx/builder/helpers.d.ts +2 -32
  167. package/es/tx/builder/helpers.mjs +19 -71
  168. package/es/tx/builder/helpers.mjs.map +1 -1
  169. package/es/tx/builder/index.d.ts +1 -21
  170. package/es/tx/builder/index.mjs +29 -148
  171. package/es/tx/builder/index.mjs.map +1 -1
  172. package/es/tx/builder/schema.d.ts +336 -176
  173. package/es/tx/builder/schema.mjs +71 -78
  174. package/es/tx/builder/schema.mjs.map +1 -1
  175. package/es/tx/index.d.ts +3 -33
  176. package/es/tx/index.mjs +26 -43
  177. package/es/tx/index.mjs.map +1 -1
  178. package/es/tx/validator.d.ts +2 -2
  179. package/es/tx/validator.mjs +86 -59
  180. package/es/tx/validator.mjs.map +1 -1
  181. package/es/typings/{@aeternity__argon2-browser → @aeternity__aepp-calldata}/index.d.mjs +0 -0
  182. package/es/typings/@aeternity__aepp-calldata/index.d.mjs.map +1 -0
  183. package/es/utils/amount-formatter.mjs +4 -10
  184. package/es/utils/amount-formatter.mjs.map +1 -1
  185. package/es/utils/autorest.d.ts +1 -0
  186. package/es/utils/autorest.mjs +17 -19
  187. package/es/utils/autorest.mjs.map +1 -1
  188. package/es/utils/bignumber.mjs +4 -7
  189. package/es/utils/bignumber.mjs.map +1 -1
  190. package/es/utils/bytes.d.ts +0 -17
  191. package/es/utils/bytes.mjs +6 -35
  192. package/es/utils/bytes.mjs.map +1 -1
  193. package/es/utils/crypto.d.ts +15 -8
  194. package/es/utils/crypto.mjs +40 -40
  195. package/es/utils/crypto.mjs.map +1 -1
  196. package/es/utils/encoder-types.d.ts +28 -28
  197. package/es/utils/encoder-types.mjs +0 -1
  198. package/es/utils/encoder-types.mjs.map +1 -1
  199. package/es/utils/encoder.d.ts +0 -1
  200. package/es/utils/encoder.mjs +7 -15
  201. package/es/utils/encoder.mjs.map +1 -1
  202. package/es/utils/errors.d.ts +12 -6
  203. package/es/utils/errors.mjs +87 -163
  204. package/es/utils/errors.mjs.map +1 -1
  205. package/es/utils/hd-wallet.d.ts +27 -19
  206. package/es/utils/hd-wallet.mjs +42 -26
  207. package/es/utils/hd-wallet.mjs.map +1 -1
  208. package/es/utils/json-big.mjs +0 -8
  209. package/es/utils/json-big.mjs.map +1 -1
  210. package/es/utils/keystore.d.ts +2 -0
  211. package/es/utils/keystore.mjs +37 -36
  212. package/es/utils/keystore.mjs.map +1 -1
  213. package/es/utils/mptree.d.ts +1 -1
  214. package/es/utils/mptree.mjs +4 -26
  215. package/es/utils/mptree.mjs.map +1 -1
  216. package/es/utils/other.d.ts +3 -1
  217. package/es/utils/other.mjs +11 -7
  218. package/es/utils/other.mjs.map +1 -1
  219. package/es/utils/semver-satisfies.mjs +0 -3
  220. package/es/utils/semver-satisfies.mjs.map +1 -1
  221. package/es/utils/string.d.ts +0 -12
  222. package/es/utils/string.mjs +1 -21
  223. package/es/utils/string.mjs.map +1 -1
  224. package/package.json +87 -48
  225. package/src/AeSdk.ts +15 -11
  226. package/src/AeSdkAepp.ts +9 -7
  227. package/src/AeSdkBase.ts +28 -202
  228. package/src/AeSdkMethods.ts +170 -0
  229. package/src/AeSdkWallet.ts +16 -47
  230. package/src/Node.ts +11 -15
  231. package/src/account/Base.ts +29 -75
  232. package/src/account/Generalized.ts +98 -0
  233. package/src/account/Ledger.ts +131 -0
  234. package/src/account/LedgerFactory.ts +86 -0
  235. package/src/account/Memory.ts +46 -60
  236. package/src/account/Rpc.ts +17 -26
  237. package/src/aens.ts +10 -9
  238. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +5 -4
  239. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +3 -3
  240. package/src/aepp-wallet-communication/rpc/RpcClient.ts +2 -2
  241. package/src/aepp-wallet-communication/rpc/types.ts +11 -1
  242. package/src/aepp-wallet-communication/schema.ts +18 -18
  243. package/src/apis/compiler/code-model-v4.yaml +681 -888
  244. package/src/apis/compiler/compiler.ts +113 -154
  245. package/src/apis/compiler/models/index.ts +80 -140
  246. package/src/apis/compiler/models/mappers.ts +165 -183
  247. package/src/apis/compiler/models/parameters.ts +6 -12
  248. package/src/chain.ts +6 -3
  249. package/src/channel/Base.ts +327 -0
  250. package/src/channel/Contract.ts +487 -0
  251. package/src/channel/Spend.ts +403 -0
  252. package/src/channel/handlers.ts +154 -573
  253. package/src/channel/internal.ts +113 -142
  254. package/src/contract/{Compiler.ts → CompilerHttp.ts} +5 -5
  255. package/src/contract/Contract.ts +620 -0
  256. package/src/contract/ga.ts +18 -104
  257. package/src/index.ts +9 -8
  258. package/src/oracle.ts +7 -7
  259. package/src/spend.ts +5 -13
  260. package/src/tx/builder/constants.ts +1 -0
  261. package/src/tx/builder/field-types/address.ts +52 -0
  262. package/src/tx/builder/field-types/addresses.ts +18 -0
  263. package/src/tx/builder/field-types/coin-amount.ts +2 -8
  264. package/src/tx/builder/field-types/enumeration.ts +21 -0
  265. package/src/tx/builder/field-types/fee.ts +1 -3
  266. package/src/tx/builder/field-types/gas-limit.ts +2 -2
  267. package/src/tx/builder/field-types/gas-price.ts +0 -2
  268. package/src/tx/builder/field-types/index.ts +16 -6
  269. package/src/tx/builder/field-types/name-fee.ts +1 -1
  270. package/src/tx/builder/field-types/name-id.ts +7 -10
  271. package/src/tx/builder/field-types/pointers.ts +41 -0
  272. package/src/tx/builder/field-types/u-int.ts +3 -2
  273. package/src/tx/builder/helpers.ts +10 -60
  274. package/src/tx/builder/index.ts +6 -65
  275. package/src/tx/builder/schema.ts +89 -100
  276. package/src/tx/index.ts +19 -15
  277. package/src/tx/validator.ts +36 -18
  278. package/src/typings/@aeternity__aepp-calldata/index.d.ts +20 -0
  279. package/src/utils/autorest.ts +16 -1
  280. package/src/utils/bytes.ts +5 -33
  281. package/src/utils/crypto.ts +23 -16
  282. package/src/utils/encoder.ts +0 -1
  283. package/src/utils/errors.ts +18 -12
  284. package/src/utils/hd-wallet.ts +30 -9
  285. package/src/utils/keystore.ts +24 -21
  286. package/src/utils/other.ts +16 -1
  287. package/src/utils/string.ts +0 -20
  288. package/types-legacy/ts4.2/AeSdk.d.ts +41 -0
  289. package/types-legacy/ts4.2/AeSdkAepp.d.ts +71 -0
  290. package/types-legacy/ts4.2/AeSdkBase.d.ts +91 -0
  291. package/types-legacy/ts4.2/AeSdkMethods.d.ts +141 -0
  292. package/types-legacy/ts4.2/AeSdkWallet.d.ts +90 -0
  293. package/types-legacy/ts4.2/Node.d.ts +78 -0
  294. package/types-legacy/ts4.2/account/Base.d.ts +52 -0
  295. package/types-legacy/ts4.2/account/Generalized.d.ts +16 -0
  296. package/types-legacy/ts4.2/account/Ledger.d.ts +28 -0
  297. package/types-legacy/ts4.2/account/LedgerFactory.d.ts +39 -0
  298. package/types-legacy/ts4.2/account/Memory.d.ts +22 -0
  299. package/types-legacy/ts4.2/account/Rpc.d.ts +25 -0
  300. package/types-legacy/ts4.2/aens.d.ts +222 -0
  301. package/types-legacy/ts4.2/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  302. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
  303. package/types-legacy/ts4.2/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  304. package/types-legacy/ts4.2/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  305. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  306. package/types-legacy/ts4.2/aepp-wallet-communication/rpc/types.d.ts +83 -0
  307. package/types-legacy/ts4.2/aepp-wallet-communication/schema.d.ts +133 -0
  308. package/types-legacy/ts4.2/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  309. package/types-legacy/ts4.2/apis/compiler/compiler.d.ts +86 -0
  310. package/types-legacy/ts4.2/apis/compiler/index.d.ts +2 -0
  311. package/types-legacy/ts4.2/apis/compiler/models/index.d.ts +195 -0
  312. package/types-legacy/ts4.2/apis/compiler/models/mappers.d.ts +23 -0
  313. package/types-legacy/ts4.2/apis/compiler/models/parameters.d.ts +12 -0
  314. package/types-legacy/ts4.2/apis/node/index.d.ts +2 -0
  315. package/types-legacy/ts4.2/apis/node/models/index.d.ts +1065 -0
  316. package/types-legacy/ts4.2/apis/node/models/mappers.d.ts +95 -0
  317. package/types-legacy/ts4.2/apis/node/models/parameters.d.ts +17 -0
  318. package/types-legacy/ts4.2/apis/node/node.d.ts +215 -0
  319. package/types-legacy/ts4.2/chain.d.ts +248 -0
  320. package/types-legacy/ts4.2/channel/Base.d.ts +194 -0
  321. package/types-legacy/ts4.2/channel/Contract.d.ts +247 -0
  322. package/types-legacy/ts4.2/channel/Spend.d.ts +217 -0
  323. package/types-legacy/ts4.2/channel/handlers.d.ts +21 -0
  324. package/types-legacy/ts4.2/channel/internal.d.ts +107 -0
  325. package/types-legacy/ts4.2/contract/CompilerHttp.d.ts +18 -0
  326. package/types-legacy/ts4.2/contract/Contract.d.ts +237 -0
  327. package/types-legacy/ts4.2/contract/ga.d.ts +43 -0
  328. package/types-legacy/ts4.2/globals.d.ts +16 -0
  329. package/types-legacy/ts4.2/index.d.ts +39 -0
  330. package/types-legacy/ts4.2/oracle.d.ts +161 -0
  331. package/types-legacy/ts4.2/spend.d.ts +62 -0
  332. package/types-legacy/ts4.2/tx/builder/constants.d.ts +71 -0
  333. package/types-legacy/ts4.2/tx/builder/field-types/address.d.ts +22 -0
  334. package/types-legacy/ts4.2/tx/builder/field-types/addresses.d.ts +6 -0
  335. package/types-legacy/ts4.2/tx/builder/field-types/coin-amount.d.ts +12 -0
  336. package/types-legacy/ts4.2/tx/builder/field-types/deposit.d.ts +14 -0
  337. package/types-legacy/ts4.2/tx/builder/field-types/enumeration.d.ts +5 -0
  338. package/types-legacy/ts4.2/tx/builder/field-types/fee.d.ts +17 -0
  339. package/types-legacy/ts4.2/tx/builder/field-types/field.d.ts +6 -0
  340. package/types-legacy/ts4.2/tx/builder/field-types/gas-limit.d.ts +12 -0
  341. package/types-legacy/ts4.2/tx/builder/field-types/gas-price.d.ts +7 -0
  342. package/types-legacy/ts4.2/tx/builder/field-types/index.d.ts +85 -0
  343. package/types-legacy/ts4.2/tx/builder/field-types/name-fee.d.ts +19 -0
  344. package/types-legacy/ts4.2/tx/builder/field-types/name-id.d.ts +11 -0
  345. package/types-legacy/ts4.2/tx/builder/field-types/name.d.ts +13 -0
  346. package/types-legacy/ts4.2/tx/builder/field-types/pointers.d.ts +26 -0
  347. package/types-legacy/ts4.2/tx/builder/field-types/short-u-int.d.ts +6 -0
  348. package/types-legacy/ts4.2/tx/builder/field-types/u-int.d.ts +8 -0
  349. package/types-legacy/ts4.2/tx/builder/helpers.d.ts +112 -0
  350. package/types-legacy/ts4.2/tx/builder/index.d.ts +68 -0
  351. package/types-legacy/ts4.2/tx/builder/schema.d.ts +2963 -0
  352. package/types-legacy/ts4.2/tx/index.d.ts +34 -0
  353. package/types-legacy/ts4.2/tx/validator.d.ts +20 -0
  354. package/types-legacy/ts4.2/utils/amount-formatter.d.ts +42 -0
  355. package/types-legacy/ts4.2/utils/autorest.d.ts +7 -0
  356. package/types-legacy/ts4.2/utils/bignumber.d.ts +13 -0
  357. package/types-legacy/ts4.2/utils/bytes.d.ts +9 -0
  358. package/types-legacy/ts4.2/utils/crypto.d.ts +95 -0
  359. package/types-legacy/ts4.2/utils/encoder-types.d.ts +61 -0
  360. package/types-legacy/ts4.2/utils/encoder.d.ts +24 -0
  361. package/types-legacy/ts4.2/utils/errors.d.ts +480 -0
  362. package/types-legacy/ts4.2/utils/hd-wallet.d.ts +65 -0
  363. package/types-legacy/ts4.2/utils/json-big.d.ts +5 -0
  364. package/types-legacy/ts4.2/utils/keystore.d.ts +53 -0
  365. package/types-legacy/ts4.2/utils/mptree.d.ts +32 -0
  366. package/types-legacy/ts4.2/utils/other.d.ts +31 -0
  367. package/types-legacy/ts4.2/utils/semver-satisfies.d.ts +1 -0
  368. package/types-legacy/ts4.2/utils/string.d.ts +12 -0
  369. package/types-legacy/ts4.5/AeSdk.d.ts +41 -0
  370. package/types-legacy/ts4.5/AeSdkAepp.d.ts +71 -0
  371. package/types-legacy/ts4.5/AeSdkBase.d.ts +91 -0
  372. package/types-legacy/ts4.5/AeSdkMethods.d.ts +141 -0
  373. package/types-legacy/ts4.5/AeSdkWallet.d.ts +90 -0
  374. package/types-legacy/ts4.5/Node.d.ts +78 -0
  375. package/types-legacy/ts4.5/account/Base.d.ts +52 -0
  376. package/types-legacy/ts4.5/account/Generalized.d.ts +16 -0
  377. package/types-legacy/ts4.5/account/Ledger.d.ts +28 -0
  378. package/types-legacy/ts4.5/account/LedgerFactory.d.ts +39 -0
  379. package/types-legacy/ts4.5/account/Memory.d.ts +22 -0
  380. package/types-legacy/ts4.5/account/Rpc.d.ts +25 -0
  381. package/types-legacy/ts4.5/aens.d.ts +222 -0
  382. package/types-legacy/ts4.5/aepp-wallet-communication/connection/Browser.d.ts +33 -0
  383. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserRuntime.d.ts +18 -0
  384. package/types-legacy/ts4.5/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +36 -0
  385. package/types-legacy/ts4.5/aepp-wallet-communication/connection-proxy.d.ts +11 -0
  386. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/RpcClient.d.ts +34 -0
  387. package/types-legacy/ts4.5/aepp-wallet-communication/rpc/types.d.ts +83 -0
  388. package/types-legacy/ts4.5/aepp-wallet-communication/schema.d.ts +133 -0
  389. package/types-legacy/ts4.5/aepp-wallet-communication/wallet-detector.d.ts +25 -0
  390. package/types-legacy/ts4.5/apis/compiler/compiler.d.ts +86 -0
  391. package/types-legacy/ts4.5/apis/compiler/index.d.ts +2 -0
  392. package/types-legacy/ts4.5/apis/compiler/models/index.d.ts +195 -0
  393. package/types-legacy/ts4.5/apis/compiler/models/mappers.d.ts +23 -0
  394. package/types-legacy/ts4.5/apis/compiler/models/parameters.d.ts +12 -0
  395. package/types-legacy/ts4.5/apis/node/index.d.ts +2 -0
  396. package/types-legacy/ts4.5/apis/node/models/index.d.ts +1065 -0
  397. package/types-legacy/ts4.5/apis/node/models/mappers.d.ts +95 -0
  398. package/types-legacy/ts4.5/apis/node/models/parameters.d.ts +17 -0
  399. package/types-legacy/ts4.5/apis/node/node.d.ts +215 -0
  400. package/types-legacy/ts4.5/chain.d.ts +248 -0
  401. package/types-legacy/ts4.5/channel/Base.d.ts +194 -0
  402. package/types-legacy/ts4.5/channel/Contract.d.ts +247 -0
  403. package/types-legacy/ts4.5/channel/Spend.d.ts +217 -0
  404. package/types-legacy/ts4.5/channel/handlers.d.ts +21 -0
  405. package/types-legacy/ts4.5/channel/internal.d.ts +107 -0
  406. package/types-legacy/ts4.5/contract/CompilerHttp.d.ts +18 -0
  407. package/types-legacy/ts4.5/contract/Contract.d.ts +237 -0
  408. package/types-legacy/ts4.5/contract/ga.d.ts +43 -0
  409. package/types-legacy/ts4.5/index.d.ts +38 -0
  410. package/types-legacy/ts4.5/oracle.d.ts +161 -0
  411. package/types-legacy/ts4.5/spend.d.ts +62 -0
  412. package/types-legacy/ts4.5/tx/builder/constants.d.ts +71 -0
  413. package/types-legacy/ts4.5/tx/builder/field-types/address.d.ts +22 -0
  414. package/types-legacy/ts4.5/tx/builder/field-types/addresses.d.ts +6 -0
  415. package/types-legacy/ts4.5/tx/builder/field-types/coin-amount.d.ts +12 -0
  416. package/types-legacy/ts4.5/tx/builder/field-types/deposit.d.ts +14 -0
  417. package/types-legacy/ts4.5/tx/builder/field-types/enumeration.d.ts +5 -0
  418. package/types-legacy/ts4.5/tx/builder/field-types/fee.d.ts +17 -0
  419. package/types-legacy/ts4.5/tx/builder/field-types/field.d.ts +6 -0
  420. package/types-legacy/ts4.5/tx/builder/field-types/gas-limit.d.ts +12 -0
  421. package/types-legacy/ts4.5/tx/builder/field-types/gas-price.d.ts +7 -0
  422. package/types-legacy/ts4.5/tx/builder/field-types/index.d.ts +85 -0
  423. package/types-legacy/ts4.5/tx/builder/field-types/name-fee.d.ts +19 -0
  424. package/types-legacy/ts4.5/tx/builder/field-types/name-id.d.ts +11 -0
  425. package/types-legacy/ts4.5/tx/builder/field-types/name.d.ts +13 -0
  426. package/types-legacy/ts4.5/tx/builder/field-types/pointers.d.ts +26 -0
  427. package/types-legacy/ts4.5/tx/builder/field-types/short-u-int.d.ts +6 -0
  428. package/types-legacy/ts4.5/tx/builder/field-types/u-int.d.ts +8 -0
  429. package/types-legacy/ts4.5/tx/builder/helpers.d.ts +112 -0
  430. package/types-legacy/ts4.5/tx/builder/index.d.ts +68 -0
  431. package/types-legacy/ts4.5/tx/builder/schema.d.ts +2963 -0
  432. package/types-legacy/ts4.5/tx/index.d.ts +34 -0
  433. package/types-legacy/ts4.5/tx/validator.d.ts +20 -0
  434. package/types-legacy/ts4.5/utils/amount-formatter.d.ts +42 -0
  435. package/types-legacy/ts4.5/utils/autorest.d.ts +7 -0
  436. package/types-legacy/ts4.5/utils/bignumber.d.ts +13 -0
  437. package/types-legacy/ts4.5/utils/bytes.d.ts +9 -0
  438. package/types-legacy/ts4.5/utils/crypto.d.ts +95 -0
  439. package/types-legacy/ts4.5/utils/encoder-types.d.ts +61 -0
  440. package/types-legacy/ts4.5/utils/encoder.d.ts +24 -0
  441. package/types-legacy/ts4.5/utils/errors.d.ts +480 -0
  442. package/types-legacy/ts4.5/utils/hd-wallet.d.ts +65 -0
  443. package/types-legacy/ts4.5/utils/json-big.d.ts +5 -0
  444. package/types-legacy/ts4.5/utils/keystore.d.ts +53 -0
  445. package/types-legacy/ts4.5/utils/mptree.d.ts +32 -0
  446. package/types-legacy/ts4.5/utils/other.d.ts +31 -0
  447. package/types-legacy/ts4.5/utils/semver-satisfies.d.ts +1 -0
  448. package/types-legacy/ts4.5/utils/string.d.ts +12 -0
  449. package/es/channel/index.d.ts +0 -625
  450. package/es/channel/index.mjs +0 -975
  451. package/es/channel/index.mjs.map +0 -1
  452. package/es/contract/Compiler.mjs.map +0 -1
  453. package/es/contract/aci.d.ts +0 -127
  454. package/es/contract/aci.mjs +0 -509
  455. package/es/contract/aci.mjs.map +0 -1
  456. package/es/contract/methods.d.ts +0 -71
  457. package/es/contract/methods.mjs +0 -104
  458. package/es/contract/methods.mjs.map +0 -1
  459. package/es/deprecated/index.d.ts +0 -143
  460. package/es/deprecated/index.mjs +0 -162
  461. package/es/deprecated/index.mjs.map +0 -1
  462. package/es/deprecated/methods.d.ts +0 -18
  463. package/es/deprecated/methods.mjs +0 -26
  464. package/es/deprecated/methods.mjs.map +0 -1
  465. package/es/tx/builder/address.d.ts +0 -25
  466. package/es/tx/builder/address.mjs +0 -45
  467. package/es/tx/builder/address.mjs.map +0 -1
  468. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +0 -1
  469. package/src/channel/index.ts +0 -1025
  470. package/src/contract/aci.ts +0 -538
  471. package/src/contract/methods.ts +0 -123
  472. package/src/deprecated/index.ts +0 -172
  473. package/src/deprecated/methods.ts +0 -25
  474. package/src/tx/builder/address.ts +0 -50
  475. package/src/typings/@aeternity__argon2-browser/index.d.ts +0 -3
@@ -1,42 +1,39 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
1
5
  import nacl from 'tweetnacl';
2
- import { v4 as uuid } from '@aeternity/uuid'; // js extension is required for mjs build
3
- // eslint-disable-next-line import/extensions
4
-
5
- import _aeternityArgon2BrowserDistArgon2BundledMinJs from '@aeternity/argon2-browser/dist/argon2-bundled.min.js';
6
+ import { v4 as uuid } from '@aeternity/uuid';
7
+ import _aeternityArgon from '@aeternity/argon2';
6
8
  const {
7
- ArgonType,
8
- hash
9
- } = _aeternityArgon2BrowserDistArgon2BundledMinJs;
9
+ hash,
10
+ argon2id
11
+ } = _aeternityArgon;
10
12
  import { getAddressFromPriv } from "./crypto.mjs";
11
- import { bytesToHex, hexToBytes } from "./bytes.mjs";
12
13
  import { InvalidPasswordError } from "./errors.mjs";
13
14
  const DERIVED_KEY_FUNCTIONS = {
14
15
  async argon2id(pass, salt, params) {
15
16
  const {
16
- memlimit_kib: mem,
17
- opslimit: time
17
+ memlimit_kib: memoryCost,
18
+ opslimit: timeCost
18
19
  } = params;
19
- return (await hash({
20
- hashLen: 32,
21
- pass,
20
+ return hash(pass, {
21
+ hashLength: 32,
22
22
  salt,
23
- time,
24
- mem,
25
- type: ArgonType.Argon2id
26
- })).hash;
23
+ timeCost,
24
+ memoryCost,
25
+ type: argon2id
26
+ });
27
27
  }
28
-
29
28
  };
30
29
  const CRYPTO_FUNCTIONS = {
31
30
  'xsalsa20-poly1305': {
32
31
  encrypt: nacl.secretbox,
33
-
34
32
  decrypt() {
35
33
  const res = nacl.secretbox.open(...arguments);
36
34
  if (res == null) throw new InvalidPasswordError();
37
35
  return res;
38
36
  }
39
-
40
37
  }
41
38
  };
42
39
  const CRYPTO_DEFAULTS = {
@@ -49,63 +46,66 @@ const CRYPTO_DEFAULTS = {
49
46
  parallelism: 1
50
47
  }
51
48
  };
49
+
52
50
  /**
53
51
  * Symmetric private key encryption using secret (derived) key.
52
+ * @category keystore
54
53
  * @param plaintext - Data to be encrypted.
55
54
  * @param key - Secret key.
56
55
  * @param nonce - Randomly generated nonce.
57
56
  * @param algo - Encryption algorithm.
58
57
  * @returns Encrypted data.
59
58
  */
60
-
61
59
  function encrypt(plaintext, key, nonce) {
62
60
  let algo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : CRYPTO_DEFAULTS.symmetric_alg;
63
61
  return CRYPTO_FUNCTIONS[algo].encrypt(plaintext, nonce, key);
64
62
  }
63
+
65
64
  /**
66
65
  * Symmetric private key decryption using secret (derived) key.
66
+ * @category keystore
67
67
  * @param ciphertext - Data to be decrypted.
68
68
  * @param key - Secret key.
69
69
  * @param nonce - Nonce from key-object.
70
70
  * @param algo - Encryption algorithm.
71
71
  * @returns Decrypted data.
72
72
  */
73
-
74
-
75
73
  function decrypt(ciphertext, key, nonce) {
76
74
  let algo = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : CRYPTO_DEFAULTS.symmetric_alg;
77
75
  return CRYPTO_FUNCTIONS[algo].decrypt(ciphertext, nonce, key);
78
76
  }
77
+
79
78
  /**
80
79
  * Derive secret key from password with key derivation function.
80
+ * @category keystore
81
81
  * @param password - User-supplied password.
82
82
  * @param nonce - Randomly generated nonce.
83
83
  * @param kdf - Key derivation function.
84
84
  * @param kdfParams - KDF parameters.
85
85
  * @returns Secret key derived from password.
86
86
  */
87
-
88
-
89
87
  async function deriveKey(password, nonce, kdf, kdfParams) {
90
88
  return DERIVED_KEY_FUNCTIONS[kdf](password, nonce, kdfParams);
91
89
  }
90
+
92
91
  /**
93
92
  * Recover plaintext private key from secret-storage key object.
93
+ * @category keystore
94
94
  * @param password - Keystore object password.
95
95
  * @param keystore - Keystore object.
96
96
  * @returns Plaintext private key.
97
97
  */
98
-
99
-
100
98
  export async function recover(password, _ref) {
101
99
  let {
102
100
  crypto
103
101
  } = _ref;
104
- const salt = hexToBytes(crypto.kdf_params.salt);
105
- return bytesToHex(decrypt(hexToBytes(crypto.ciphertext), await deriveKey(password, salt, crypto.kdf, crypto.kdf_params), hexToBytes(crypto.cipher_params.nonce), crypto.symmetric_alg));
102
+ const salt = _Buffer.from(crypto.kdf_params.salt, 'hex');
103
+ return _Buffer.from(decrypt(_Buffer.from(crypto.ciphertext, 'hex'), await deriveKey(password, salt, crypto.kdf, crypto.kdf_params), _Buffer.from(crypto.cipher_params.nonce, 'hex'), crypto.symmetric_alg)).toString('hex');
106
104
  }
105
+
107
106
  /**
108
107
  * Export private key to keystore secret-storage format.
108
+ * @category keystore
109
109
  * @param name - Key name.
110
110
  * @param password - User-supplied password.
111
111
  * @param privateKey - Private key as hex-string or a Buffer.
@@ -115,16 +115,16 @@ export async function recover(password, _ref) {
115
115
  * @param options.kdf - Key derivation function.
116
116
  * @param options.kdf_params - KDF parameters.
117
117
  */
118
-
119
118
  export async function dump(name, password, privateKey) {
120
119
  let nonce = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : nacl.randomBytes(24);
121
120
  let salt = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : nacl.randomBytes(16);
122
121
  let options = arguments.length > 5 ? arguments[5] : undefined;
123
- const opt = { ...CRYPTO_DEFAULTS,
122
+ const opt = {
123
+ ...CRYPTO_DEFAULTS,
124
124
  ...options
125
125
  };
126
126
  const derivedKey = await deriveKey(password, salt, opt.kdf, opt.kdf_params);
127
- const payload = typeof privateKey === 'string' ? hexToBytes(privateKey) : privateKey;
127
+ const payload = typeof privateKey === 'string' ? _Buffer.from(privateKey, 'hex') : privateKey;
128
128
  return {
129
129
  name,
130
130
  version: 1,
@@ -133,13 +133,14 @@ export async function dump(name, password, privateKey) {
133
133
  crypto: {
134
134
  secret_type: opt.secret_type,
135
135
  symmetric_alg: opt.symmetric_alg,
136
- ciphertext: bytesToHex(encrypt(payload, derivedKey, nonce, opt.symmetric_alg)),
136
+ ciphertext: _Buffer.from(encrypt(payload, derivedKey, nonce, opt.symmetric_alg)).toString('hex'),
137
137
  cipher_params: {
138
- nonce: bytesToHex(nonce)
138
+ nonce: _Buffer.from(nonce).toString('hex')
139
139
  },
140
140
  kdf: opt.kdf,
141
- kdf_params: { ...opt.kdf_params,
142
- salt: bytesToHex(salt)
141
+ kdf_params: {
142
+ ...opt.kdf_params,
143
+ salt: _Buffer.from(salt).toString('hex')
143
144
  }
144
145
  }
145
146
  };
@@ -1 +1 @@
1
- {"version":3,"file":"keystore.mjs","names":["nacl","v4","uuid","getAddressFromPriv","bytesToHex","hexToBytes","InvalidPasswordError","DERIVED_KEY_FUNCTIONS","argon2id","pass","salt","params","memlimit_kib","mem","opslimit","time","hash","hashLen","type","ArgonType","Argon2id","CRYPTO_FUNCTIONS","encrypt","secretbox","decrypt","res","open","CRYPTO_DEFAULTS","secret_type","symmetric_alg","kdf","kdf_params","parallelism","plaintext","key","nonce","algo","ciphertext","deriveKey","password","kdfParams","recover","crypto","cipher_params","dump","name","privateKey","randomBytes","options","opt","derivedKey","payload","version","public_key","id"],"sources":["../../src/utils/keystore.ts"],"sourcesContent":["import nacl from 'tweetnacl';\nimport { v4 as uuid } from '@aeternity/uuid';\n// js extension is required for mjs build\n// eslint-disable-next-line import/extensions\nimport { ArgonType, hash } from '@aeternity/argon2-browser/dist/argon2-bundled.min.js';\nimport { getAddressFromPriv } from './crypto';\nimport { bytesToHex, hexToBytes } from './bytes';\nimport { InvalidPasswordError } from './errors';\n\nconst DERIVED_KEY_FUNCTIONS = {\n async argon2id(\n pass: string | Uint8Array,\n salt: string | Uint8Array,\n params: Partial<Keystore['crypto']['kdf_params']>,\n ): Promise<Uint8Array> {\n const { memlimit_kib: mem, opslimit: time } = params;\n\n return (await hash({\n hashLen: 32,\n pass,\n salt,\n time,\n mem,\n type: ArgonType.Argon2id,\n })).hash;\n },\n};\n\nconst CRYPTO_FUNCTIONS = {\n 'xsalsa20-poly1305': {\n encrypt: nacl.secretbox,\n decrypt(...args: Parameters<typeof nacl.secretbox.open>): Uint8Array {\n const res = nacl.secretbox.open(...args);\n if (res == null) throw new InvalidPasswordError();\n return res;\n },\n },\n};\n\nexport interface Keystore {\n name: string;\n version: 1;\n public_key: string;\n id: string;\n crypto: {\n secret_type: 'ed25519';\n symmetric_alg: keyof typeof CRYPTO_FUNCTIONS;\n ciphertext: string;\n cipher_params: {\n nonce: string;\n };\n kdf: keyof typeof DERIVED_KEY_FUNCTIONS;\n kdf_params: {\n memlimit_kib: number;\n opslimit: number;\n parallelism: number;\n salt: string;\n };\n };\n}\n\nconst CRYPTO_DEFAULTS = {\n secret_type: 'ed25519',\n symmetric_alg: 'xsalsa20-poly1305',\n kdf: 'argon2id',\n kdf_params: {\n memlimit_kib: 65536,\n opslimit: 3,\n parallelism: 1,\n },\n} as const;\n\n/**\n * Symmetric private key encryption using secret (derived) key.\n * @param plaintext - Data to be encrypted.\n * @param key - Secret key.\n * @param nonce - Randomly generated nonce.\n * @param algo - Encryption algorithm.\n * @returns Encrypted data.\n */\nfunction encrypt(\n plaintext: Uint8Array,\n key: Uint8Array,\n nonce: Uint8Array,\n algo: keyof typeof CRYPTO_FUNCTIONS = CRYPTO_DEFAULTS.symmetric_alg,\n): Uint8Array {\n return CRYPTO_FUNCTIONS[algo].encrypt(plaintext, nonce, key);\n}\n\n/**\n * Symmetric private key decryption using secret (derived) key.\n * @param ciphertext - Data to be decrypted.\n * @param key - Secret key.\n * @param nonce - Nonce from key-object.\n * @param algo - Encryption algorithm.\n * @returns Decrypted data.\n */\nfunction decrypt(\n ciphertext: Uint8Array,\n key: Uint8Array,\n nonce: Uint8Array,\n algo: keyof typeof CRYPTO_FUNCTIONS = CRYPTO_DEFAULTS.symmetric_alg,\n): Uint8Array {\n return CRYPTO_FUNCTIONS[algo].decrypt(ciphertext, nonce, key);\n}\n\n/**\n * Derive secret key from password with key derivation function.\n * @param password - User-supplied password.\n * @param nonce - Randomly generated nonce.\n * @param kdf - Key derivation function.\n * @param kdfParams - KDF parameters.\n * @returns Secret key derived from password.\n */\nasync function deriveKey(\n password: string | Uint8Array,\n nonce: string | Uint8Array,\n kdf: Keystore['crypto']['kdf'],\n kdfParams: Omit<Keystore['crypto']['kdf_params'], 'salt'>,\n): Promise<Uint8Array> {\n return DERIVED_KEY_FUNCTIONS[kdf](password, nonce, kdfParams);\n}\n\n/**\n * Recover plaintext private key from secret-storage key object.\n * @param password - Keystore object password.\n * @param keystore - Keystore object.\n * @returns Plaintext private key.\n */\nexport async function recover(\n password: string | Uint8Array,\n { crypto }: Keystore,\n): Promise<string> {\n const salt = hexToBytes(crypto.kdf_params.salt);\n return bytesToHex(decrypt(\n hexToBytes(crypto.ciphertext),\n await deriveKey(password, salt, crypto.kdf, crypto.kdf_params),\n hexToBytes(crypto.cipher_params.nonce),\n crypto.symmetric_alg,\n ));\n}\n\n/**\n * Export private key to keystore secret-storage format.\n * @param name - Key name.\n * @param password - User-supplied password.\n * @param privateKey - Private key as hex-string or a Buffer.\n * @param nonce - Randomly generated 24byte nonce.\n * @param salt - Randomly generated 16byte salt.\n * @param options - Encryption parameters.\n * @param options.kdf - Key derivation function.\n * @param options.kdf_params - KDF parameters.\n */\nexport async function dump(\n name: string,\n password: string | Uint8Array,\n privateKey: string | Uint8Array,\n nonce: Uint8Array = nacl.randomBytes(24),\n salt: Uint8Array = nacl.randomBytes(16),\n options?: Partial<Keystore['crypto']>,\n): Promise<Keystore> {\n const opt = { ...CRYPTO_DEFAULTS, ...options };\n const derivedKey = await deriveKey(password, salt, opt.kdf, opt.kdf_params);\n const payload = typeof privateKey === 'string' ? hexToBytes(privateKey) : privateKey;\n return {\n name,\n version: 1,\n public_key: getAddressFromPriv(payload),\n id: uuid(),\n crypto: {\n secret_type: opt.secret_type,\n symmetric_alg: opt.symmetric_alg,\n ciphertext: bytesToHex(encrypt(payload, derivedKey, nonce, opt.symmetric_alg)),\n cipher_params: { nonce: bytesToHex(nonce) },\n kdf: opt.kdf,\n kdf_params: {\n ...opt.kdf_params,\n salt: bytesToHex(salt),\n },\n },\n };\n}\n"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,WAAjB;AACA,SAASC,EAAE,IAA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WAAL,CAAiB,EAAjB,CAEA;EAAA,IADnBC,OACmB;EACnB,MAAMC,GAAG,GAAG,EAAE,GAAGtB,eAAL;IAAsB,GAAGqB;EAAzB,CAAZ;EACA,MAAME,UAAU,GAAG,MAAMZ,SAAS,CAACC,QAAD,EAAW7B,IAAX,EAAiBuC,GAAG,CAACnB,GAArB,EAA0BmB,GAAG,CAAClB,UAA9B,CAAlC;EACA,MAAMoB,OAAO,GAAG,OAAOL,UAAP,KAAsB,QAAtB,GAAiCzC,UAAU,CAACyC,UAAD,CAA3C,GAA0DA,UAA1E;EACA,OAAO;IACLD,IADK;IAELO,OAAO,EAAE,CAFJ;IAGLC,UAAU,EAAElD,kBAAkB,CAACgD,OAAD,CAHzB;IAILG,EAAE,EAAEpD,IAAI,EAJH;IAKLwC,MAAM,EAAE;MACNd,WAAW,EAAEqB,GAAG,CAACrB,WADX;MAENC,aAAa,EAAEoB,GAAG,CAACpB,aAFb;MAGNQ,UAAU,EAAEjC,UAAU,CAACkB,OAAO,CAAC6B,OAAD,EAAUD,UAAV,EAAsBf,KAAtB,EAA6Bc,GAAG,CAACpB,aAAjC,CAAR,CAHhB;MAINc,aAAa,EAAE;QAAER,KAAK,EAAE/B,UAAU,CAAC+B,KAAD;MAAnB,CAJT;MAKNL,GAAG,EAAEmB,GAAG,CAACnB,GALH;MAMNC,UAAU,EAAE,EACV,GAAGkB,GAAG,CAAClB,UADG;QAEVrB,IAAI,EAAEN,UAAU,CAACM,IAAD;MAFN;IANN;EALH,CAAP;AAiBD"}
1
+ {"version":3,"file":"keystore.mjs","names":["nacl","v4","uuid","getAddressFromPriv","InvalidPasswordError","DERIVED_KEY_FUNCTIONS","argon2id","pass","salt","params","memlimit_kib","memoryCost","opslimit","timeCost","hash","hashLength","type","CRYPTO_FUNCTIONS","encrypt","secretbox","decrypt","res","open","CRYPTO_DEFAULTS","secret_type","symmetric_alg","kdf","kdf_params","parallelism","plaintext","key","nonce","algo","ciphertext","deriveKey","password","kdfParams","recover","crypto","from","cipher_params","toString","dump","name","privateKey","randomBytes","options","opt","derivedKey","payload","version","public_key","id"],"sources":["../../src/utils/keystore.ts"],"sourcesContent":["import nacl from 'tweetnacl';\nimport { v4 as uuid } from '@aeternity/uuid';\nimport { hash, argon2id } from '@aeternity/argon2';\nimport { getAddressFromPriv } from './crypto';\nimport { InvalidPasswordError } from './errors';\n\nconst DERIVED_KEY_FUNCTIONS = {\n async argon2id(\n pass: string | Uint8Array,\n salt: string | Uint8Array,\n params: Partial<Keystore['crypto']['kdf_params']>,\n ): Promise<Uint8Array> {\n const { memlimit_kib: memoryCost, opslimit: timeCost } = params;\n\n return hash(pass, {\n hashLength: 32,\n salt,\n timeCost,\n memoryCost,\n type: argon2id,\n });\n },\n};\n\nconst CRYPTO_FUNCTIONS = {\n 'xsalsa20-poly1305': {\n encrypt: nacl.secretbox,\n decrypt(...args: Parameters<typeof nacl.secretbox.open>): Uint8Array {\n const res = nacl.secretbox.open(...args);\n if (res == null) throw new InvalidPasswordError();\n return res;\n },\n },\n};\n\nexport interface Keystore {\n name: string;\n version: 1;\n public_key: string;\n id: string;\n crypto: {\n secret_type: 'ed25519';\n symmetric_alg: keyof typeof CRYPTO_FUNCTIONS;\n ciphertext: string;\n cipher_params: {\n nonce: string;\n };\n kdf: keyof typeof DERIVED_KEY_FUNCTIONS;\n kdf_params: {\n memlimit_kib: number;\n opslimit: number;\n parallelism: number;\n salt: string;\n };\n };\n}\n\nconst CRYPTO_DEFAULTS = {\n secret_type: 'ed25519',\n symmetric_alg: 'xsalsa20-poly1305',\n kdf: 'argon2id',\n kdf_params: {\n memlimit_kib: 65536,\n opslimit: 3,\n parallelism: 1,\n },\n} as const;\n\n/**\n * Symmetric private key encryption using secret (derived) key.\n * @category keystore\n * @param plaintext - Data to be encrypted.\n * @param key - Secret key.\n * @param nonce - Randomly generated nonce.\n * @param algo - Encryption algorithm.\n * @returns Encrypted data.\n */\nfunction encrypt(\n plaintext: Uint8Array,\n key: Uint8Array,\n nonce: Uint8Array,\n algo: keyof typeof CRYPTO_FUNCTIONS = CRYPTO_DEFAULTS.symmetric_alg,\n): Uint8Array {\n return CRYPTO_FUNCTIONS[algo].encrypt(plaintext, nonce, key);\n}\n\n/**\n * Symmetric private key decryption using secret (derived) key.\n * @category keystore\n * @param ciphertext - Data to be decrypted.\n * @param key - Secret key.\n * @param nonce - Nonce from key-object.\n * @param algo - Encryption algorithm.\n * @returns Decrypted data.\n */\nfunction decrypt(\n ciphertext: Uint8Array,\n key: Uint8Array,\n nonce: Uint8Array,\n algo: keyof typeof CRYPTO_FUNCTIONS = CRYPTO_DEFAULTS.symmetric_alg,\n): Uint8Array {\n return CRYPTO_FUNCTIONS[algo].decrypt(ciphertext, nonce, key);\n}\n\n/**\n * Derive secret key from password with key derivation function.\n * @category keystore\n * @param password - User-supplied password.\n * @param nonce - Randomly generated nonce.\n * @param kdf - Key derivation function.\n * @param kdfParams - KDF parameters.\n * @returns Secret key derived from password.\n */\nasync function deriveKey(\n password: string | Uint8Array,\n nonce: string | Uint8Array,\n kdf: Keystore['crypto']['kdf'],\n kdfParams: Omit<Keystore['crypto']['kdf_params'], 'salt'>,\n): Promise<Uint8Array> {\n return DERIVED_KEY_FUNCTIONS[kdf](password, nonce, kdfParams);\n}\n\n/**\n * Recover plaintext private key from secret-storage key object.\n * @category keystore\n * @param password - Keystore object password.\n * @param keystore - Keystore object.\n * @returns Plaintext private key.\n */\nexport async function recover(\n password: string | Uint8Array,\n { crypto }: Keystore,\n): Promise<string> {\n const salt = Buffer.from(crypto.kdf_params.salt, 'hex');\n return Buffer.from(decrypt(\n Buffer.from(crypto.ciphertext, 'hex'),\n await deriveKey(password, salt, crypto.kdf, crypto.kdf_params),\n Buffer.from(crypto.cipher_params.nonce, 'hex'),\n crypto.symmetric_alg,\n )).toString('hex');\n}\n\n/**\n * Export private key to keystore secret-storage format.\n * @category keystore\n * @param name - Key name.\n * @param password - User-supplied password.\n * @param privateKey - Private key as hex-string or a Buffer.\n * @param nonce - Randomly generated 24byte nonce.\n * @param salt - Randomly generated 16byte salt.\n * @param options - Encryption parameters.\n * @param options.kdf - Key derivation function.\n * @param options.kdf_params - KDF parameters.\n */\nexport async function dump(\n name: string,\n password: string | Uint8Array,\n privateKey: string | Uint8Array,\n nonce: Uint8Array = nacl.randomBytes(24),\n salt: Uint8Array = nacl.randomBytes(16),\n options?: Partial<Keystore['crypto']>,\n): Promise<Keystore> {\n const opt = { ...CRYPTO_DEFAULTS, ...options };\n const derivedKey = await deriveKey(password, salt, opt.kdf, opt.kdf_params);\n const payload = typeof privateKey === 'string' ? Buffer.from(privateKey, 'hex') : privateKey;\n return {\n name,\n version: 1,\n public_key: getAddressFromPriv(payload),\n id: uuid(),\n crypto: {\n secret_type: opt.secret_type,\n symmetric_alg: opt.symmetric_alg,\n ciphertext: Buffer.from(\n encrypt(payload, derivedKey, nonce, opt.symmetric_alg),\n ).toString('hex'),\n cipher_params: { nonce: Buffer.from(nonce).toString('hex') },\n kdf: opt.kdf,\n kdf_params: {\n ...opt.kdf_params,\n salt: Buffer.from(salt).toString('hex'),\n },\n },\n };\n}\n"],"mappings":";;;;AAAA,OAAOA,IAAI,MAAM,WAAW;AAC5B,SAASC,EAAE,IAAIC,IAAI,QAAQ,iBAAiB;AAC5C,4BAA+B,mBAAmB;AAAC;EAAA;EAAA;AAAA;AAAA,SAC1CC,kBAAkB;AAAA,SAClBC,oBAAoB;AAE7B,MAAMC,qBAAqB,GAAG;EAC5B,MAAMC,QAAQ,CACZC,IAAyB,EACzBC,IAAyB,EACzBC,MAAiD,EAC5B;IACrB,MAAM;MAAEC,YAAY,EAAEC,UAAU;MAAEC,QAAQ,EAAEC;IAAS,CAAC,GAAGJ,MAAM;IAE/D,OAAOK,IAAI,CAACP,IAAI,EAAE;MAChBQ,UAAU,EAAE,EAAE;MACdP,IAAI;MACJK,QAAQ;MACRF,UAAU;MACVK,IAAI,EAAEV;IACR,CAAC,CAAC;EACJ;AACF,CAAC;AAED,MAAMW,gBAAgB,G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,EAAEhD,kBAAkB,CAAC8C,OAAO,CAAC;IACvCG,EAAE,EAAElD,IAAI,EAAE;IACVoC,MAAM,EAAE;MACNd,WAAW,EAAEuB,GAAG,CAACvB,WAAW;MAC5BC,aAAa,EAAEsB,GAAG,CAACtB,aAAa;MAChCQ,UAAU,EAAE,QAAOM,IAAI,CACrBrB,OAAO,CAAC+B,OAAO,EAAED,UAAU,EAAEjB,KAAK,EAAEgB,GAAG,CAACtB,aAAa,CAAC,CACvD,CAACgB,QAAQ,CAAC,KAAK,CAAC;MACjBD,aAAa,EAAE;QAAET,KAAK,EAAE,QAAOQ,IAAI,CAACR,KAAK,CAAC,CAACU,QAAQ,CAAC,KAAK;MAAE,CAAC;MAC5Df,GAAG,EAAEqB,GAAG,CAACrB,GAAG;MACZC,UAAU,EAAE;QACV,GAAGoB,GAAG,CAACpB,UAAU;QACjBnB,IAAI,EAAE,QAAO+B,IAAI,CAAC/B,IAAI,CAAC,CAACiC,QAAQ,CAAC,KAAK;MACxC;IACF;EACF,CAAC;AACH"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- export declare type MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>];
2
+ export type MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>];
3
3
  export default class MPTree {
4
4
  private readonly rootHash;
5
5
  private readonly nodes;
@@ -1,9 +1,7 @@
1
1
  import _buffer from "buffer";
2
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
2
  const {
4
3
  Buffer: _Buffer
5
4
  } = _buffer;
6
-
7
5
  /*
8
6
  * ISC License (ISC)
9
7
  * Copyright (c) 2021 aeternity developers
@@ -29,24 +27,21 @@ const {
29
27
  import { hash } from "./crypto.mjs";
30
28
  import { MerkleTreeHashMismatchError, MissingNodeInTreeError, UnknownPathNibbleError, UnknownNodeLengthError } from "./errors.mjs";
31
29
  var NodeType;
32
-
33
30
  (function (NodeType) {
34
31
  NodeType[NodeType["Branch"] = 0] = "Branch";
35
32
  NodeType[NodeType["Extension"] = 1] = "Extension";
36
33
  NodeType[NodeType["Leaf"] = 2] = "Leaf";
37
34
  })(NodeType || (NodeType = {}));
38
-
39
35
  export default class MPTree {
40
36
  static nodeHash(node) {
41
37
  return _Buffer.from(hash(rlpEncode(node))).toString('hex');
42
38
  }
39
+
43
40
  /**
44
41
  * Deserialize Merkle Patricia Tree
45
42
  * @param binary - Binary
46
43
  * @returns Merkle Patricia Tree
47
44
  */
48
-
49
-
50
45
  constructor(binary) {
51
46
  this.rootHash = binary[0].toString('hex');
52
47
  this.nodes = Object.fromEntries(binary[1].map(node => [node[0].toString('hex'), node[1]]));
@@ -58,7 +53,6 @@ export default class MPTree {
58
53
  type,
59
54
  payload
60
55
  } = MPTree.parseNode(node);
61
-
62
56
  switch (type) {
63
57
  case NodeType.Branch:
64
58
  payload.slice(0, 16).filter(n => n.length).forEach(n => {
@@ -67,20 +61,16 @@ export default class MPTree {
67
61
  }
68
62
  });
69
63
  break;
70
-
71
64
  case NodeType.Extension:
72
65
  if (this.nodes[payload[0].toString('hex')] === undefined) {
73
66
  throw new MissingNodeInTreeError('Can\'t find a node by hash in extension node');
74
67
  }
75
-
76
68
  }
77
69
  });
78
70
  }
79
-
80
71
  isEqual(tree) {
81
72
  return this.rootHash === tree.rootHash;
82
73
  }
83
-
84
74
  static parseNode(node) {
85
75
  switch (node.length) {
86
76
  case 17:
@@ -89,50 +79,42 @@ export default class MPTree {
89
79
  payload: node,
90
80
  path: null
91
81
  };
92
-
93
82
  case 2:
94
83
  {
95
- var _context;
96
-
97
84
  const nibble = node[0][0] >> 4; // eslint-disable-line no-bitwise
98
-
99
85
  if (nibble > 3) throw new UnknownPathNibbleError(nibble);
100
86
  const type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf;
101
- const slice = _includesInstanceProperty(_context = [0, 2]).call(_context, nibble) ? 2 : 1;
87
+ const slice = [0, 2].includes(nibble) ? 2 : 1;
102
88
  return {
103
89
  type,
104
90
  payload: [node[1]],
105
91
  path: node[0].toString('hex').slice(slice)
106
92
  };
107
93
  }
108
-
109
94
  default:
110
95
  throw new UnknownNodeLengthError(node.length);
111
96
  }
112
97
  }
98
+
113
99
  /**
114
100
  * Serialize Merkle Patricia Tree
115
101
  * @returns Binary
116
102
  */
117
-
118
-
119
103
  serialize() {
120
104
  return [_Buffer.from(this.rootHash, 'hex'), Object.entries(this.nodes).map(_ref2 => {
121
105
  let [mptHash, value] = _ref2;
122
106
  return [_Buffer.from(mptHash, 'hex'), value];
123
107
  })];
124
108
  }
109
+
125
110
  /**
126
111
  * Retrieve value from Merkle Patricia Tree
127
112
  * @param _key - The key of the element to retrieve
128
113
  * @returns Value associated to the specified key
129
114
  */
130
-
131
-
132
115
  get(_key) {
133
116
  let searchFrom = this.rootHash;
134
117
  let key = _key;
135
-
136
118
  while (true) {
137
119
  // eslint-disable-line no-constant-condition
138
120
  const {
@@ -140,26 +122,22 @@ export default class MPTree {
140
122
  payload,
141
123
  path
142
124
  } = MPTree.parseNode(this.nodes[searchFrom]);
143
-
144
125
  switch (type) {
145
126
  case NodeType.Branch:
146
127
  if (key.length === 0) return payload[16];
147
128
  searchFrom = payload[+`0x${key[0]}`].toString('hex');
148
129
  key = key.substring(1);
149
130
  break;
150
-
151
131
  case NodeType.Extension:
152
132
  if (key.substring(0, path === null || path === void 0 ? void 0 : path.length) !== path) return undefined;
153
133
  searchFrom = payload[0].toString('hex');
154
134
  key = key.substring(path.length);
155
135
  break;
156
-
157
136
  case NodeType.Leaf:
158
137
  if (path !== key) return undefined;
159
138
  return payload[0];
160
139
  }
161
140
  }
162
141
  }
163
-
164
142
  }
165
143
  //# sourceMappingURL=mptree.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mptree.mjs","names":["hash","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownPathNibbleError","UnknownNodeLengthError","NodeType","MPTree","nodeHash","node","from","rlpEncode","toString","constructor","binary","rootHash","nodes","Object","fromEntries","map","undefined","entries","forEach","key","type","payload","parseNode","Branch","slice","filter","n","length","Extension","isEqual","tree","path","nibble","Leaf","serialize","mptHash","value","get","_key","searchFrom","substring"],"sources":["../../src/utils/mptree.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2021 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/* eslint-disable default-case */\nimport { encode as rlpEncode } from 'rlp';\nimport type { Input } from 'rlp';\nimport { hash } from './crypto';\nimport {\n MerkleTreeHashMismatchError,\n MissingNodeInTreeError,\n UnknownPathNibbleError,\n UnknownNodeLengthError,\n} from './errors';\n\nenum NodeType {\n Branch,\n Extension,\n Leaf,\n}\n\nexport type MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>];\n\nexport default class MPTree {\n private readonly rootHash: string;\n\n private readonly nodes: { [key: string]: Buffer[] };\n\n private static nodeHash(node: Input): string {\n return Buffer.from(hash(rlpEncode(node))).toString('hex');\n }\n\n /**\n * Deserialize Merkle Patricia Tree\n * @param binary - Binary\n * @returns Merkle Patricia Tree\n */\n constructor(binary: MPTreeBinary) {\n this.rootHash = binary[0].toString('hex');\n this.nodes = Object.fromEntries(\n binary[1].map((node) => [node[0].toString('hex'), node[1]]),\n );\n\n if (this.nodes[this.rootHash] === undefined) throw new MissingNodeInTreeError('Can\\'t find a node by root hash');\n Object.entries(this.nodes).forEach(([key, node]) => {\n if (MPTree.nodeHash(node) !== key) throw new MerkleTreeHashMismatchError();\n const { type, payload } = MPTree.parseNode(node);\n switch (type) {\n case NodeType.Branch:\n payload\n .slice(0, 16)\n .filter((n) => n.length)\n .forEach((n) => {\n if (this.nodes[n.toString('hex')] === undefined) {\n throw new MissingNodeInTreeError('Can\\'t find a node by hash in branch node');\n }\n });\n break;\n case NodeType.Extension:\n if (this.nodes[payload[0].toString('hex')] === undefined) {\n throw new MissingNodeInTreeError('Can\\'t find a node by hash in extension node');\n }\n }\n });\n }\n\n isEqual(tree: MPTree): boolean {\n return this.rootHash === tree.rootHash;\n }\n\n private static parseNode(node: Buffer[]): {\n type: NodeType;\n payload: Buffer[];\n path: string | null;\n } {\n switch (node.length) {\n case 17:\n return { type: NodeType.Branch, payload: node, path: null };\n case 2: {\n const nibble = node[0][0] >> 4; // eslint-disable-line no-bitwise\n if (nibble > 3) throw new UnknownPathNibbleError(nibble);\n const type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf;\n const slice = [0, 2].includes(nibble) ? 2 : 1;\n return { type, payload: [node[1]], path: node[0].toString('hex').slice(slice) };\n }\n default:\n throw new UnknownNodeLengthError(node.length);\n }\n }\n\n /**\n * Serialize Merkle Patricia Tree\n * @returns Binary\n */\n serialize(): MPTreeBinary {\n return [\n Buffer.from(this.rootHash, 'hex'),\n Object.entries(this.nodes).map(([mptHash, value]) => ([\n Buffer.from(mptHash, 'hex'),\n value,\n ])),\n ];\n }\n\n /**\n * Retrieve value from Merkle Patricia Tree\n * @param _key - The key of the element to retrieve\n * @returns Value associated to the specified key\n */\n get(_key: string): Buffer | undefined {\n let searchFrom = this.rootHash;\n let key = _key;\n while (true) { // eslint-disable-line no-constant-condition\n const { type, payload, path } = MPTree.parseNode(this.nodes[searchFrom]);\n switch (type) {\n case NodeType.Branch:\n if (key.length === 0) return payload[16];\n searchFrom = payload[+`0x${key[0]}`].toString('hex');\n key = key.substring(1);\n break;\n case NodeType.Extension:\n if (key.substring(0, path?.length) !== path) return undefined;\n searchFrom = payload[0].toString('hex');\n key = key.substring(path.length);\n break;\n case NodeType.Leaf:\n if (path !== key) return undefined;\n return payload[0];\n }\n }\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iBAAoC,KAApC;;;;SAESA,I;SAEPC,2B,EACAC,sB,EACAC,sB,EACAC,sB;IAGGC,Q;;WAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;EAAAA,Q,CAAAA,Q;GAAAA,Q,KAAAA,Q;;AAQL,eAAe,MAAMC,MAAN,CAAa;EAKH,OAARC,QAAQ,CAACC,IAAD,EAAsB;IAC3C,OAAO,QAAOC,IAAP,CAAYT,IAAI,CAACU,SAAS,CAACF,IAAD,CAAV,CAAhB,EAAmCG,QAAnC,CAA4C,KAA5C,CAAP;EACD;EAED;AACF;AACA;AACA;AACA;;;EACEC,WAAW,CAACC,MAAD,EAAuB;IAChC,KAAKC,QAAL,GAAgBD,MAAM,CAAC,CAAD,CAAN,CAAUF,QAAV,CAAmB,KAAnB,CAAhB;IACA,KAAKI,KAAL,GAAaC,MAAM,CAACC,WAAP,CACXJ,MAAM,CAAC,CAAD,CAAN,CAAUK,GAAV,CAAeV,IAAD,IAAU,CAACA,IAAI,CAAC,CAAD,CAAJ,CAAQG,QAAR,CAAiB,KAAjB,CAAD,EAA0BH,IAAI,CAAC,CAAD,CAA9B,CAAxB,CADW,CAAb;IAIA,IAAI,KAAKO,KAAL,CAAW,KAAKD,QAAhB,MAA8BK,SAAlC,EAA6C,MAAM,IAAIjB,sBAAJ,CAA2B,iCAA3B,CAAN;IAC7Cc,MAAM,CAACI,OAAP,CAAe,KAAKL,KAApB,EAA2BM,OAA3B,CA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X,CAAjB,CAAhC;;MACA,QAAQnB,IAAR;QACE,KAAKlB,QAAQ,CAACqB,MAAd;UACE,IAAIJ,GAAG,CAACQ,MAAJ,KAAe,CAAnB,EAAsB,OAAON,OAAO,CAAC,EAAD,CAAd;UACtBkB,UAAU,GAAGlB,OAAO,CAAC,CAAE,KAAIF,GAAG,CAAC,CAAD,CAAI,EAAd,CAAP,CAAwBX,QAAxB,CAAiC,KAAjC,CAAb;UACAW,GAAG,GAAGA,GAAG,CAACqB,SAAJ,CAAc,CAAd,CAAN;UACA;;QACF,KAAKtC,QAAQ,CAAC0B,SAAd;UACE,IAAIT,GAAG,CAACqB,SAAJ,CAAc,CAAd,EAAiBT,IAAjB,aAAiBA,IAAjB,uBAAiBA,IAAI,CAAEJ,MAAvB,MAAmCI,IAAvC,EAA6C,OAAOf,SAAP;UAC7CuB,UAAU,GAAGlB,OAAO,CAAC,CAAD,CAAP,CAAWb,QAAX,CAAoB,KAApB,CAAb;UACAW,GAAG,GAAGA,GAAG,CAACqB,SAAJ,CAAcT,IAAI,CAACJ,MAAnB,CAAN;UACA;;QACF,KAAKzB,QAAQ,CAAC+B,IAAd;UACE,IAAIF,IAAI,KAAKZ,GAAb,EAAkB,OAAOH,SAAP;UAClB,OAAOK,OAAO,CAAC,CAAD,CAAd;MAbJ;IAeD;EACF;;AA3GyB"}
1
+ {"version":3,"file":"mptree.mjs","names":["hash","MerkleTreeHashMismatchError","MissingNodeInTreeError","UnknownPathNibbleError","UnknownNodeLengthError","NodeType","MPTree","nodeHash","node","from","rlpEncode","toString","constructor","binary","rootHash","nodes","Object","fromEntries","map","undefined","entries","forEach","key","type","payload","parseNode","Branch","slice","filter","n","length","Extension","isEqual","tree","path","nibble","Leaf","includes","serialize","mptHash","value","get","_key","searchFrom","substring"],"sources":["../../src/utils/mptree.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2021 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/* eslint-disable default-case */\nimport { encode as rlpEncode } from 'rlp';\nimport type { Input } from 'rlp';\nimport { hash } from './crypto';\nimport {\n MerkleTreeHashMismatchError,\n MissingNodeInTreeError,\n UnknownPathNibbleError,\n UnknownNodeLengthError,\n} from './errors';\n\nenum NodeType {\n Branch,\n Extension,\n Leaf,\n}\n\nexport type MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>];\n\nexport default class MPTree {\n private readonly rootHash: string;\n\n private readonly nodes: { [key: string]: Buffer[] };\n\n private static nodeHash(node: Input): string {\n return Buffer.from(hash(rlpEncode(node))).toString('hex');\n }\n\n /**\n * Deserialize Merkle Patricia Tree\n * @param binary - Binary\n * @returns Merkle Patricia Tree\n */\n constructor(binary: MPTreeBinary) {\n this.rootHash = binary[0].toString('hex');\n this.nodes = Object.fromEntries(\n binary[1].map((node) => [node[0].toString('hex'), node[1]]),\n );\n\n if (this.nodes[this.rootHash] === undefined) throw new MissingNodeInTreeError('Can\\'t find a node by root hash');\n Object.entries(this.nodes).forEach(([key, node]) => {\n if (MPTree.nodeHash(node) !== key) throw new MerkleTreeHashMismatchError();\n const { type, payload } = MPTree.parseNode(node);\n switch (type) {\n case NodeType.Branch:\n payload\n .slice(0, 16)\n .filter((n) => n.length)\n .forEach((n) => {\n if (this.nodes[n.toString('hex')] === undefined) {\n throw new MissingNodeInTreeError('Can\\'t find a node by hash in branch node');\n }\n });\n break;\n case NodeType.Extension:\n if (this.nodes[payload[0].toString('hex')] === undefined) {\n throw new MissingNodeInTreeError('Can\\'t find a node by hash in extension node');\n }\n }\n });\n }\n\n isEqual(tree: MPTree): boolean {\n return this.rootHash === tree.rootHash;\n }\n\n private static parseNode(node: Buffer[]): {\n type: NodeType;\n payload: Buffer[];\n path: string | null;\n } {\n switch (node.length) {\n case 17:\n return { type: NodeType.Branch, payload: node, path: null };\n case 2: {\n const nibble = node[0][0] >> 4; // eslint-disable-line no-bitwise\n if (nibble > 3) throw new UnknownPathNibbleError(nibble);\n const type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf;\n const slice = [0, 2].includes(nibble) ? 2 : 1;\n return { type, payload: [node[1]], path: node[0].toString('hex').slice(slice) };\n }\n default:\n throw new UnknownNodeLengthError(node.length);\n }\n }\n\n /**\n * Serialize Merkle Patricia Tree\n * @returns Binary\n */\n serialize(): MPTreeBinary {\n return [\n Buffer.from(this.rootHash, 'hex'),\n Object.entries(this.nodes).map(([mptHash, value]) => ([\n Buffer.from(mptHash, 'hex'),\n value,\n ])),\n ];\n }\n\n /**\n * Retrieve value from Merkle Patricia Tree\n * @param _key - The key of the element to retrieve\n * @returns Value associated to the specified key\n */\n get(_key: string): Buffer | undefined {\n let searchFrom = this.rootHash;\n let key = _key;\n while (true) { // eslint-disable-line no-constant-condition\n const { type, payload, path } = MPTree.parseNode(this.nodes[searchFrom]);\n switch (type) {\n case NodeType.Branch:\n if (key.length === 0) return payload[16];\n searchFrom = payload[+`0x${key[0]}`].toString('hex');\n key = key.substring(1);\n break;\n case NodeType.Extension:\n if (key.substring(0, path?.length) !== path) return undefined;\n searchFrom = payload[0].toString('hex');\n key = key.substring(path.length);\n break;\n case NodeType.Leaf:\n if (path !== key) return undefined;\n return payload[0];\n }\n }\n }\n}\n"],"m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B,MAAM;UAClB,IAAIJ,GAAG,CAACQ,MAAM,KAAK,CAAC,EAAE,OAAON,OAAO,CAAC,EAAE,CAAC;UACxCmB,UAAU,GAAGnB,OAAO,CAAC,CAAE,KAAIF,GAAG,CAAC,CAAC,CAAE,EAAC,CAAC,CAACX,QAAQ,CAAC,KAAK,CAAC;UACpDW,GAAG,GAAGA,GAAG,CAACsB,SAAS,CAAC,CAAC,CAAC;UACtB;QACF,KAAKvC,QAAQ,CAAC0B,SAAS;UACrB,IAAIT,GAAG,CAACsB,SAAS,CAAC,CAAC,EAAEV,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEJ,MAAM,CAAC,KAAKI,IAAI,EAAE,OAAOf,SAAS;UAC7DwB,UAAU,GAAGnB,OAAO,CAAC,CAAC,CAAC,CAACb,QAAQ,CAAC,KAAK,CAAC;UACvCW,GAAG,GAAGA,GAAG,CAACsB,SAAS,CAACV,IAAI,CAACJ,MAAM,CAAC;UAChC;QACF,KAAKzB,QAAQ,CAAC+B,IAAI;UAChB,IAAIF,IAAI,KAAKZ,GAAG,EAAE,OAAOH,SAAS;UAClC,OAAOK,OAAO,CAAC,CAAC,CAAC;MAAC;IAExB;EACF;AACF"}
@@ -11,10 +11,12 @@ export declare const concatBuffers: (list: readonly Uint8Array[], totalLength?:
11
11
  * @param key - Maybe object key
12
12
  * @param object - Object
13
13
  */
14
- export declare function isKeyOfObject<T>(key: string | number | symbol, object: T): key is keyof T;
14
+ export declare function isKeyOfObject<T extends object>(key: string | number | symbol, object: T): key is keyof T;
15
15
  /**
16
16
  * Array item type guard
17
17
  * @param item - Maybe array item
18
18
  * @param array - Array
19
19
  */
20
20
  export declare function isItemOfArray<T>(item: any, array: readonly T[]): item is T;
21
+ export declare function isAccountNotFoundError(error: Error): boolean;
22
+ export type UnionToIntersection<Union> = (Union extends any ? (k: Union) => void : never) extends ((k: infer Intersection) => void) ? Intersection : never;
@@ -1,40 +1,44 @@
1
1
  import _buffer from "buffer";
2
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
2
  const {
4
3
  Buffer: _Buffer
5
4
  } = _buffer;
5
+ import { RestError } from '@azure/core-rest-pipeline';
6
6
  export const pause = async duration => new Promise(resolve => {
7
7
  setTimeout(resolve, duration);
8
8
  });
9
- export const mapObject = (object, fn) => Object.fromEntries(Object.entries(object).map(fn)); // remove after dropping webpack4 support
9
+ export const mapObject = (object, fn) => Object.fromEntries(Object.entries(object).map(fn));
10
10
 
11
+ // remove after dropping webpack4 support
11
12
  const isWebpack4Buffer = (() => {
12
13
  try {
13
14
  _Buffer.concat([Uint8Array.from([])]);
14
-
15
15
  return false;
16
16
  } catch (error) {
17
17
  return true;
18
18
  }
19
19
  })();
20
-
21
20
  export const concatBuffers = isWebpack4Buffer ? (list, totalLength) => _Buffer.concat(list.map(el => _Buffer.from(el)), totalLength) : _Buffer.concat;
21
+
22
22
  /**
23
23
  * Object key type guard
24
24
  * @param key - Maybe object key
25
25
  * @param object - Object
26
26
  */
27
-
28
27
  export function isKeyOfObject(key, object) {
29
28
  return key in object;
30
29
  }
30
+
31
31
  /**
32
32
  * Array item type guard
33
33
  * @param item - Maybe array item
34
34
  * @param array - Array
35
35
  */
36
-
37
36
  export function isItemOfArray(item, array) {
38
- return _includesInstanceProperty(array).call(array, item);
37
+ return array.includes(item);
39
38
  }
39
+ export function isAccountNotFoundError(error) {
40
+ return error instanceof RestError && error.statusCode === 404 && error.message.includes('Account not found');
41
+ }
42
+
43
+ // based on https://stackoverflow.com/a/50375286/6176994
40
44
  //# sourceMappingURL=other.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"other.mjs","names":["pause","duration","Promise","resolve","setTimeout","mapObject","object","fn","Object","fromEntries","entries","map","isWebpack4Buffer","concat","Uint8Array","from","error","concatBuffers","list","totalLength","el","isKeyOfObject","key","isItemOfArray","item","array"],"sources":["../../src/utils/other.ts"],"sourcesContent":["export const pause = async (duration: number): Promise<void> => new Promise((resolve) => {\n setTimeout(resolve, duration);\n});\n\nexport const mapObject = <InputV, OutputV>(\n object: { [k: string]: InputV },\n fn: (\n value: [string, InputV], index: number, array: Array<[string, InputV]>\n ) => [number | string, OutputV],\n): { [k: string]: OutputV } => Object.fromEntries(Object.entries(object).map(fn));\n\n// remove after dropping webpack4 support\nconst isWebpack4Buffer = (() => {\n try {\n Buffer.concat([Uint8Array.from([])]);\n return false;\n } catch (error) {\n return true;\n }\n})();\n\nexport const concatBuffers = isWebpack4Buffer\n ? (list: readonly Uint8Array[], totalLength?: number): Buffer => (\n Buffer.concat(list.map((el) => Buffer.from(el)), totalLength)\n )\n : Buffer.concat;\n\n/**\n * Object key type guard\n * @param key - Maybe object key\n * @param object - Object\n */\nexport function isKeyOfObject<T>(key: string | number | symbol, object: T): key is keyof T {\n return key in object;\n}\n\n/**\n * Array item type guard\n * @param item - Maybe array item\n * @param array - Array\n */\nexport function isItemOfArray<T>(item: any, array: readonly T[]): item is T {\n return array.includes(item);\n}\n"],"mappings":";;;;;AAAA,OAAO,MAAMA,KAAK,GAAG,MAAOC,QAAP,IAA2C,IAAIC,OAAJ,CAAaC,OAAD,IAAa;EACvFC,UAAU,CAACD,OAAD,EAAUF,QAAV,CAAV;AACD,CAF+D,CAAzD;AAIP,OAAO,MAAMI,SAAS,GAAG,CACvBC,MADuB,EAEvBC,EAFuB,KAKMC,MAAM,CAACC,WAAP,CAAmBD,MAAM,CAACE,OAAP,CAAeJ,MAAf,EAAuBK,GAAvB,CAA2BJ,EAA3B,CAAnB,CALxB,C,CAOP;;AACA,MAAMK,gBAAgB,GAAG,CAAC,MAAM;EAC9B,IAAI;IACF,QAAOC,MAAP,CAAc,CAACC,UAAU,CAACC,IAAX,CAAgB,EAAhB,CAAD,CAAd;;IACA,OAAO,KAAP;EACD,CAHD,CAGE,OAAOC,KAAP,EAAc;IACd,OAAO,IAAP;EACD;AACF,CAPwB,GAAzB;;AASA,OAAO,MAAMC,aAAa,GAAGL,gBAAgB,GACzC,CAACM,IAAD,EAA8BC,WAA9B,KACA,QAAON,MAAP,CAAcK,IAAI,CAACP,GAAL,CAAUS,EAAD,IAAQ,QAAOL,IAAP,CAAYK,EAAZ,CAAjB,CAAd,EAAiDD,WAAjD,CAFyC,GAIzC,QAAON,MAJJ;AAMP;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASQ,aAAT,CAA0BC,GAA1B,EAAyDhB,MAAzD,EAAoF;EACzF,OAAOgB,GAAG,IAAIhB,MAAd;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASiB,aAAT,CAA0BC,IAA1B,EAAqCC,KAArC,EAAqE;EAC1E,OAAO,0BAAAA,KAAK,MAAL,CAAAA,KAAK,EAAUD,IAAV,CAAZ;AACD"}
1
+ {"version":3,"file":"other.mjs","names":["RestError","pause","duration","Promise","resolve","setTimeout","mapObject","object","fn","Object","fromEntries","entries","map","isWebpack4Buffer","concat","Uint8Array","from","error","concatBuffers","list","totalLength","el","isKeyOfObject","key","isItemOfArray","item","array","includes","isAccountNotFoundError","statusCode","message"],"sources":["../../src/utils/other.ts"],"sourcesContent":["import { RestError } from '@azure/core-rest-pipeline';\n\nexport const pause = async (duration: number): Promise<void> => new Promise((resolve) => {\n setTimeout(resolve, duration);\n});\n\nexport const mapObject = <InputV, OutputV>(\n object: { [k: string]: InputV },\n fn: (\n value: [string, InputV], index: number, array: Array<[string, InputV]>\n ) => [number | string, OutputV],\n): { [k: string]: OutputV } => Object.fromEntries(Object.entries(object).map(fn));\n\n// remove after dropping webpack4 support\nconst isWebpack4Buffer = (() => {\n try {\n Buffer.concat([Uint8Array.from([])]);\n return false;\n } catch (error) {\n return true;\n }\n})();\n\nexport const concatBuffers = isWebpack4Buffer\n ? (list: readonly Uint8Array[], totalLength?: number): Buffer => (\n Buffer.concat(list.map((el) => Buffer.from(el)), totalLength)\n )\n : Buffer.concat;\n\n/**\n * Object key type guard\n * @param key - Maybe object key\n * @param object - Object\n */\nexport function isKeyOfObject<T extends object>(\n key: string | number | symbol,\n object: T,\n): key is keyof T {\n return key in object;\n}\n\n/**\n * Array item type guard\n * @param item - Maybe array item\n * @param array - Array\n */\nexport function isItemOfArray<T>(item: any, array: readonly T[]): item is T {\n return array.includes(item);\n}\n\nexport function isAccountNotFoundError(error: Error): boolean {\n return error instanceof RestError && error.statusCode === 404\n && error.message.includes('Account not found');\n}\n\n// based on https://stackoverflow.com/a/50375286/6176994\nexport type UnionToIntersection<Union> =\n (Union extends any ? (k: Union) => void : never) extends ((k: infer Intersection) => void)\n ? Intersection : never;\n"],"mappings":";;;;AAAA,SAASA,SAAS,QAAQ,2BAA2B;AAErD,OAAO,MAAMC,KAAK,GAAG,MAAOC,QAAgB,IAAoB,IAAIC,OAAO,CAAEC,OAAO,IAAK;EACvFC,UAAU,CAACD,OAAO,EAAEF,QAAQ,CAAC;AAC/B,CAAC,CAAC;AAEF,OAAO,MAAMI,SAAS,GAAG,CACvBC,MAA+B,EAC/BC,EAE+B,KACFC,MAAM,CAACC,WAAW,CAACD,MAAM,CAACE,OAAO,CAACJ,MAAM,CAAC,CAACK,GAAG,CAACJ,EAAE,CAAC,CAAC;;AAEjF;AACA,MAAMK,gBAAgB,GAAG,CAAC,MAAM;EAC9B,IAAI;IACF,QAAOC,MAAM,CAAC,CAACC,UAAU,CAACC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,OAAO,KAAK;EACd,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,OAAO,IAAI;EACb;AACF,CAAC,GAAG;AAEJ,OAAO,MAAMC,aAAa,GAAGL,gBAAgB,GACzC,CAACM,IAA2B,EAAEC,WAAoB,KAClD,QAAON,MAAM,CAACK,IAAI,CAACP,GAAG,CAAES,EAAE,IAAK,QAAOL,IAAI,CAACK,EAAE,CAAC,CAAC,EAAED,WAAW,CAC7D,GACC,QAAON,MAAM;;AAEjB;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,aAAa,CAC3BC,GAA6B,EAC7BhB,MAAS,EACO;EAChB,OAAOgB,GAAG,IAAIhB,MAAM;AACtB;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASiB,aAAa,CAAIC,IAAS,EAAEC,KAAmB,EAAa;EAC1E,OAAOA,KAAK,CAACC,QAAQ,CAACF,IAAI,CAAC;AAC7B;AAEA,OAAO,SAASG,sBAAsB,CAACX,KAAY,EAAW;EAC5D,OAAOA,KAAK,YAAYjB,SAAS,IAAIiB,KAAK,CAACY,UAAU,KAAK,GAAG,IACxDZ,KAAK,CAACa,OAAO,CAACH,QAAQ,CAAC,mBAAmB,CAAC;AAClD;;AAEA"}
@@ -1,13 +1,10 @@
1
1
  export default function semverSatisfies(version, geVersion, ltVersion) {
2
2
  const getComponents = v => v.split(/[-+]/)[0].split('.').map(i => +i);
3
-
4
3
  const versionComponents = getComponents(version);
5
4
  const geComponents = getComponents(geVersion);
6
5
  const ltComponents = getComponents(ltVersion);
7
6
  const base = Math.max(...versionComponents, ...geComponents, ...ltComponents) + 1;
8
-
9
7
  const componentsToNumber = components => components.reverse().reduce((acc, n, idx) => acc + n * base ** idx, 0);
10
-
11
8
  const vNumber = componentsToNumber(versionComponents);
12
9
  const geNumber = componentsToNumber(geComponents);
13
10
  const ltNumber = componentsToNumber(ltComponents);
@@ -1 +1 @@
1
- {"version":3,"file":"semver-satisfies.mjs","names":["semverSatisfies","version","geVersion","ltVersion","getComponents","v","split","map","i","versionComponents","geComponents","ltComponents","base","Math","max","componentsToNumber","components","reverse","reduce","acc","n","idx","vNumber","geNumber","ltNumber"],"sources":["../../src/utils/semver-satisfies.ts"],"sourcesContent":["export default function semverSatisfies(\n version: string,\n geVersion: string,\n ltVersion: string,\n): boolean {\n const getComponents = (v: string): number[] => v\n .split(/[-+]/)[0].split('.').map((i) => +i);\n\n const versionComponents = getComponents(version);\n const geComponents = getComponents(geVersion);\n const ltComponents = getComponents(ltVersion);\n\n const base = Math.max(...versionComponents, ...geComponents, ...ltComponents) + 1;\n const componentsToNumber = (components: number[]): number => components.reverse()\n .reduce((acc, n, idx) => acc + n * base ** idx, 0);\n\n const vNumber = componentsToNumber(versionComponents);\n const geNumber = componentsToNumber(geComponents);\n const ltNumber = componentsToNumber(ltComponents);\n return vNumber >= geNumber && vNumber < ltNumber;\n}\n"],"mappings":"AAAA,eAAe,SAASA,eAAT,CACbC,OADa,EAEbC,SAFa,EAGbC,SAHa,EAIJ;EACT,MAAMC,aAAa,GAAIC,CAAD,IAAyBA,CAAC,CAC7CC,KAD4C,CACtC,MADsC,EAC9B,CAD8B,EAC3BA,KAD2B,CACrB,GADqB,EAChBC,GADgB,CACXC,CAAD,IAAO,CAACA,CADI,CAA/C;;EAGA,MAAMC,iBAAiB,GAAGL,aAAa,CAACH,OAAD,CAAvC;EACA,MAAMS,YAAY,GAAGN,aAAa,CAACF,SAAD,CAAlC;EACA,MAAMS,YAAY,GAAGP,aAAa,CAACD,SAAD,CAAlC;EAEA,MAAMS,IAAI,GAAGC,IAAI,CAACC,GAAL,CAAS,GAAGL,iBAAZ,EAA+B,GAAGC,YAAlC,EAAgD,GAAGC,YAAnD,IAAmE,CAAhF;;EACA,MAAMI,kBAAkB,GAAIC,UAAD,IAAkCA,UAAU,CAACC,OAAX,GAC1DC,MAD0D,CACnD,CAACC,GAAD,EAAMC,CAAN,EAASC,GAAT,KAAiBF,GAAG,GAAGC,CAAC,GAAGR,IAAI,IAAIS,GADgB,EACX,CADW,CAA7D;;EAGA,MAAMC,OAAO,GAAGP,kBAAkB,CAACN,iBAAD,CAAlC;EACA,MAAMc,QAAQ,GAAGR,kBAAkB,CAACL,YAAD,CAAnC;EACA,MAAMc,QAAQ,GAAGT,kBAAkB,CAACJ,YAAD,CAAnC;EACA,OAAOW,OAAO,IAAIC,QAAX,IAAuBD,OAAO,GAAGE,QAAxC;AACD"}
1
+ {"version":3,"file":"semver-satisfies.mjs","names":["semverSatisfies","version","geVersion","ltVersion","getComponents","v","split","map","i","versionComponents","geComponents","ltComponents","base","Math","max","componentsToNumber","components","reverse","reduce","acc","n","idx","vNumber","geNumber","ltNumber"],"sources":["../../src/utils/semver-satisfies.ts"],"sourcesContent":["export default function semverSatisfies(\n version: string,\n geVersion: string,\n ltVersion: string,\n): boolean {\n const getComponents = (v: string): number[] => v\n .split(/[-+]/)[0].split('.').map((i) => +i);\n\n const versionComponents = getComponents(version);\n const geComponents = getComponents(geVersion);\n const ltComponents = getComponents(ltVersion);\n\n const base = Math.max(...versionComponents, ...geComponents, ...ltComponents) + 1;\n const componentsToNumber = (components: number[]): number => components.reverse()\n .reduce((acc, n, idx) => acc + n * base ** idx, 0);\n\n const vNumber = componentsToNumber(versionComponents);\n const geNumber = componentsToNumber(geComponents);\n const ltNumber = componentsToNumber(ltComponents);\n return vNumber >= geNumber && vNumber < ltNumber;\n}\n"],"mappings":"AAAA,eAAe,SAASA,eAAe,CACrCC,OAAe,EACfC,SAAiB,EACjBC,SAAiB,EACR;EACT,MAAMC,aAAa,GAAIC,CAAS,IAAeA,CAAC,CAC7CC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAACA,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAAEC,CAAC,IAAK,CAACA,CAAC,CAAC;EAE7C,MAAMC,iBAAiB,GAAGL,aAAa,CAACH,OAAO,CAAC;EAChD,MAAMS,YAAY,GAAGN,aAAa,CAACF,SAAS,CAAC;EAC7C,MAAMS,YAAY,GAAGP,aAAa,CAACD,SAAS,CAAC;EAE7C,MAAMS,IAAI,GAAGC,IAAI,CAACC,GAAG,CAAC,GAAGL,iBAAiB,EAAE,GAAGC,YAAY,EAAE,GAAGC,YAAY,CAAC,GAAG,CAAC;EACjF,MAAMI,kBAAkB,GAAIC,UAAoB,IAAaA,UAAU,CAACC,OAAO,EAAE,CAC9EC,MAAM,CAAC,CAACC,GAAG,EAAEC,CAAC,EAAEC,GAAG,KAAKF,GAAG,GAAGC,CAAC,GAAGR,IAAI,IAAIS,GAAG,EAAE,CAAC,CAAC;EAEpD,MAAMC,OAAO,GAAGP,kBAAkB,CAACN,iBAAiB,CAAC;EACrD,MAAMc,QAAQ,GAAGR,kBAAkB,CAACL,YAAY,CAAC;EACjD,MAAMc,QAAQ,GAAGT,kBAAkB,CAACJ,YAAY,CAAC;EACjD,OAAOW,OAAO,IAAIC,QAAQ,IAAID,OAAO,GAAGE,QAAQ;AAClD"}
@@ -10,15 +10,3 @@ export declare function snakeToPascal(s: string): string;
10
10
  * @returns Converted string
11
11
  */
12
12
  export declare function pascalToSnake(s: string): string;
13
- /**
14
- * Check whether a string is valid hex.
15
- * @param str - String to validate.
16
- * @returns True if the string is valid hex, false otherwise.
17
- */
18
- export declare function isHex(str: string): boolean;
19
- /**
20
- * Check whether a string is valid base-64.
21
- * @param str - String to validate.
22
- * @returns True if the string is valid base-64, false otherwise.
23
- */
24
- export declare function isBase64(str: string): boolean;
@@ -23,33 +23,13 @@
23
23
  export function snakeToPascal(s) {
24
24
  return s.replace(/_./g, match => match[1].toUpperCase());
25
25
  }
26
+
26
27
  /**
27
28
  * Convert string from PascalCase to snake_case
28
29
  * @param s - String to convert
29
30
  * @returns Converted string
30
31
  */
31
-
32
32
  export function pascalToSnake(s) {
33
33
  return s.replace(/[A-Z]/g, match => `_${match.toLowerCase()}`);
34
34
  }
35
- /**
36
- * Check whether a string is valid hex.
37
- * @param str - String to validate.
38
- * @returns True if the string is valid hex, false otherwise.
39
- */
40
-
41
- export function isHex(str) {
42
- return str.length % 2 === 0 && /^[0-9a-f]+$/i.test(str);
43
- }
44
- /**
45
- * Check whether a string is valid base-64.
46
- * @param str - String to validate.
47
- * @returns True if the string is valid base-64, false otherwise.
48
- */
49
-
50
- export function isBase64(str) {
51
- if (str.length % 4 > 0 || /[^0-9a-z+/=]/i.test(str)) return false;
52
- const index = str.indexOf('=');
53
- return index === -1 || /={1,2}/.test(str.slice(index));
54
- }
55
35
  //# sourceMappingURL=string.mjs.map