@aeternity/aepp-sdk 10.0.0 → 12.0.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 (424) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +15 -14
  3. package/dist/aepp-sdk.browser-script.js +1 -1
  4. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +13 -40
  5. package/dist/aepp-sdk.browser-script.js.map +1 -1
  6. package/dist/aepp-sdk.browser.js +1 -1
  7. package/dist/aepp-sdk.browser.js.map +1 -1
  8. package/dist/aepp-sdk.js +1 -1
  9. package/dist/aepp-sdk.js.map +1 -1
  10. package/es/AeSdk.d.ts +37 -0
  11. package/es/AeSdk.mjs +81 -0
  12. package/es/AeSdk.mjs.map +1 -0
  13. package/es/AeSdkAepp.d.ts +69 -0
  14. package/es/AeSdkAepp.mjs +175 -0
  15. package/es/AeSdkAepp.mjs.map +1 -0
  16. package/es/AeSdkBase.d.ts +212 -0
  17. package/es/AeSdkBase.mjs +310 -0
  18. package/es/AeSdkBase.mjs.map +1 -0
  19. package/es/AeSdkWallet.d.ts +103 -0
  20. package/es/AeSdkWallet.mjs +322 -0
  21. package/es/AeSdkWallet.mjs.map +1 -0
  22. package/es/Node.d.ts +44 -0
  23. package/es/Node.mjs +141 -0
  24. package/es/Node.mjs.map +1 -0
  25. package/es/account/Base.d.ts +65 -0
  26. package/es/account/Base.mjs +123 -0
  27. package/es/account/Base.mjs.map +1 -0
  28. package/es/account/Memory.d.ts +25 -0
  29. package/es/account/Memory.mjs +81 -0
  30. package/es/account/Memory.mjs.map +1 -0
  31. package/es/account/Rpc.d.ts +27 -0
  32. package/es/account/Rpc.mjs +79 -0
  33. package/es/account/Rpc.mjs.map +1 -0
  34. package/es/aens.d.ts +209 -0
  35. package/es/aens.mjs +332 -0
  36. package/es/aens.mjs.map +1 -0
  37. package/es/aepp-wallet-communication/connection/Browser.d.ts +32 -0
  38. package/es/aepp-wallet-communication/connection/Browser.mjs +70 -0
  39. package/es/aepp-wallet-communication/connection/Browser.mjs.map +1 -0
  40. package/es/aepp-wallet-communication/connection/BrowserRuntime.d.ts +17 -0
  41. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs +57 -0
  42. package/es/aepp-wallet-communication/connection/BrowserRuntime.mjs.map +1 -0
  43. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.d.ts +35 -0
  44. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs +142 -0
  45. package/es/aepp-wallet-communication/connection/BrowserWindowMessage.mjs.map +1 -0
  46. package/es/aepp-wallet-communication/connection-proxy.d.ts +10 -0
  47. package/{src/utils/crypto-ts.ts → es/aepp-wallet-communication/connection-proxy.mjs} +15 -11
  48. package/es/aepp-wallet-communication/connection-proxy.mjs.map +1 -0
  49. package/es/aepp-wallet-communication/rpc/RpcClient.d.ts +33 -0
  50. package/es/aepp-wallet-communication/rpc/RpcClient.mjs +169 -0
  51. package/es/aepp-wallet-communication/rpc/RpcClient.mjs.map +1 -0
  52. package/es/aepp-wallet-communication/rpc/types.d.ts +77 -0
  53. package/es/aepp-wallet-communication/rpc/types.mjs +3 -0
  54. package/es/aepp-wallet-communication/rpc/types.mjs.map +1 -0
  55. package/es/aepp-wallet-communication/schema.d.ts +118 -0
  56. package/es/aepp-wallet-communication/schema.mjs +214 -0
  57. package/es/aepp-wallet-communication/schema.mjs.map +1 -0
  58. package/es/aepp-wallet-communication/wallet-detector.d.ts +24 -0
  59. package/es/aepp-wallet-communication/wallet-detector.mjs +63 -0
  60. package/es/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
  61. package/es/apis/compiler/compiler.d.ts +92 -0
  62. package/es/apis/compiler/compiler.mjs +576 -0
  63. package/es/apis/compiler/compiler.mjs.map +1 -0
  64. package/es/apis/compiler/index.d.ts +2 -0
  65. package/es/apis/compiler/index.mjs +3 -0
  66. package/es/apis/compiler/index.mjs.map +1 -0
  67. package/es/apis/compiler/models/index.d.ts +248 -0
  68. package/es/apis/compiler/models/index.mjs +48 -0
  69. package/es/apis/compiler/models/index.mjs.map +1 -0
  70. package/es/apis/compiler/models/mappers.d.ts +23 -0
  71. package/es/apis/compiler/models/mappers.mjs +585 -0
  72. package/es/apis/compiler/models/mappers.mjs.map +1 -0
  73. package/es/apis/compiler/models/parameters.d.ts +13 -0
  74. package/es/apis/compiler/models/parameters.mjs +71 -0
  75. package/es/apis/compiler/models/parameters.mjs.map +1 -0
  76. package/es/apis/node/index.d.ts +2 -0
  77. package/es/apis/node/index.mjs +3 -0
  78. package/es/apis/node/index.mjs.map +1 -0
  79. package/es/apis/node/models/index.d.ts +1061 -0
  80. package/es/apis/node/models/index.mjs +2 -0
  81. package/es/apis/node/models/index.mjs.map +1 -0
  82. package/es/apis/node/models/mappers.d.ts +95 -0
  83. package/es/apis/node/models/mappers.mjs +4164 -0
  84. package/es/apis/node/models/mappers.mjs.map +1 -0
  85. package/es/apis/node/models/parameters.d.ts +17 -0
  86. package/es/apis/node/models/parameters.mjs +165 -0
  87. package/es/apis/node/models/parameters.mjs.map +1 -0
  88. package/es/apis/node/node.d.ts +215 -0
  89. package/es/apis/node/node.mjs +1165 -0
  90. package/es/apis/node/node.mjs.map +1 -0
  91. package/es/chain.d.ts +220 -0
  92. package/es/chain.mjs +524 -0
  93. package/es/chain.mjs.map +1 -0
  94. package/es/channel/handlers.d.ts +34 -0
  95. package/es/channel/{handlers.js → handlers.mjs} +163 -130
  96. package/es/channel/handlers.mjs.map +1 -0
  97. package/es/channel/index.d.ts +634 -0
  98. package/es/channel/index.mjs +978 -0
  99. package/es/channel/index.mjs.map +1 -0
  100. package/es/channel/internal.d.ts +100 -0
  101. package/es/channel/internal.mjs +328 -0
  102. package/es/channel/internal.mjs.map +1 -0
  103. package/es/contract/Compiler.d.ts +17 -0
  104. package/es/contract/Compiler.mjs +67 -0
  105. package/es/contract/Compiler.mjs.map +1 -0
  106. package/es/contract/aci.d.ts +125 -0
  107. package/es/contract/aci.mjs +496 -0
  108. package/es/contract/aci.mjs.map +1 -0
  109. package/es/contract/ga.d.ts +68 -0
  110. package/es/contract/ga.mjs +190 -0
  111. package/es/contract/ga.mjs.map +1 -0
  112. package/es/contract/methods.d.ts +68 -0
  113. package/es/contract/methods.mjs +101 -0
  114. package/es/contract/methods.mjs.map +1 -0
  115. package/es/index.d.ts +32 -0
  116. package/es/index.mjs +49 -0
  117. package/es/index.mjs.map +1 -0
  118. package/es/oracle.d.ts +154 -0
  119. package/es/oracle.mjs +288 -0
  120. package/es/oracle.mjs.map +1 -0
  121. package/es/spend.d.ts +61 -0
  122. package/es/spend.mjs +122 -0
  123. package/es/spend.mjs.map +1 -0
  124. package/es/tx/builder/constants.d.ts +41 -0
  125. package/es/tx/builder/constants.mjs +100 -0
  126. package/es/tx/builder/constants.mjs.map +1 -0
  127. package/es/tx/builder/field-types.d.ts +62 -0
  128. package/es/tx/builder/field-types.mjs +126 -0
  129. package/es/tx/builder/field-types.mjs.map +1 -0
  130. package/es/tx/builder/helpers.d.ts +131 -0
  131. package/es/tx/builder/helpers.mjs +223 -0
  132. package/es/tx/builder/helpers.mjs.map +1 -0
  133. package/es/tx/builder/index.d.ts +75 -0
  134. package/es/tx/builder/index.mjs +424 -0
  135. package/es/tx/builder/index.mjs.map +1 -0
  136. package/es/tx/builder/schema.d.ts +350 -0
  137. package/es/tx/builder/schema.mjs +320 -0
  138. package/es/tx/builder/schema.mjs.map +1 -0
  139. package/es/tx/index.d.ts +63 -0
  140. package/es/tx/index.mjs +209 -0
  141. package/es/tx/index.mjs.map +1 -0
  142. package/es/tx/min-fee.d.ts +20 -0
  143. package/es/tx/min-fee.mjs +148 -0
  144. package/es/tx/min-fee.mjs.map +1 -0
  145. package/es/tx/validator.d.ts +19 -0
  146. package/es/tx/validator.mjs +240 -0
  147. package/es/tx/validator.mjs.map +1 -0
  148. package/es/typings/@aeternity__argon2-browser/index.d.mjs +2 -0
  149. package/es/typings/@aeternity__argon2-browser/index.d.mjs.map +1 -0
  150. package/es/typings/@aeternity__uuid/index.d.mjs +2 -0
  151. package/es/typings/@aeternity__uuid/index.d.mjs.map +1 -0
  152. package/es/typings/bip32-path/index.d.mjs +2 -0
  153. package/es/typings/bip32-path/index.d.mjs.map +1 -0
  154. package/es/typings/blakejs/index.d.mjs +2 -0
  155. package/es/typings/blakejs/index.d.mjs.map +1 -0
  156. package/es/typings/tweetnacl-auth/index.d.mjs +2 -0
  157. package/es/typings/tweetnacl-auth/index.d.mjs.map +1 -0
  158. package/es/utils/amount-formatter.d.ts +42 -0
  159. package/es/utils/{amount-formatter.js → amount-formatter.mjs} +38 -44
  160. package/es/utils/amount-formatter.mjs.map +1 -0
  161. package/es/utils/autorest.d.ts +6 -0
  162. package/es/utils/autorest.mjs +97 -0
  163. package/es/utils/autorest.mjs.map +1 -0
  164. package/es/utils/bignumber.d.ts +13 -0
  165. package/es/utils/bignumber.mjs +23 -0
  166. package/es/utils/bignumber.mjs.map +1 -0
  167. package/es/{bytes.d.ts → utils/bytes.d.ts} +10 -13
  168. package/es/utils/{bytes.js → bytes.mjs} +26 -22
  169. package/es/utils/bytes.mjs.map +1 -0
  170. package/es/utils/crypto.d.ts +103 -0
  171. package/es/utils/crypto.mjs +221 -0
  172. package/es/utils/crypto.mjs.map +1 -0
  173. package/es/utils/encoder.d.ts +26 -0
  174. package/es/utils/encoder.mjs +102 -0
  175. package/es/utils/encoder.mjs.map +1 -0
  176. package/es/utils/errors.d.ts +481 -0
  177. package/es/utils/errors.mjs +882 -0
  178. package/es/utils/errors.mjs.map +1 -0
  179. package/es/utils/hd-wallet.d.ts +34 -0
  180. package/es/utils/hd-wallet.mjs +122 -0
  181. package/es/utils/hd-wallet.mjs.map +1 -0
  182. package/es/utils/json-big.d.ts +5 -0
  183. package/es/utils/json-big.mjs +41 -0
  184. package/es/utils/json-big.mjs.map +1 -0
  185. package/es/utils/keystore.d.ts +51 -0
  186. package/es/utils/keystore.mjs +145 -0
  187. package/es/utils/keystore.mjs.map +1 -0
  188. package/es/{mptree.d.ts → utils/mptree.d.ts} +5 -8
  189. package/es/utils/{mptree.js → mptree.mjs} +33 -25
  190. package/es/utils/mptree.mjs.map +1 -0
  191. package/es/utils/other.d.ts +14 -0
  192. package/es/utils/other.mjs +28 -0
  193. package/es/utils/other.mjs.map +1 -0
  194. package/es/{semver-satisfies.d.ts → utils/semver-satisfies.d.ts} +0 -0
  195. package/es/utils/{semver-satisfies.js → semver-satisfies.mjs} +1 -1
  196. package/es/utils/semver-satisfies.mjs.map +1 -0
  197. package/es/utils/string.d.ts +24 -0
  198. package/es/utils/{string.js → string.mjs} +9 -11
  199. package/es/utils/string.mjs.map +1 -0
  200. package/package.json +67 -64
  201. package/src/AeSdk.ts +65 -0
  202. package/src/AeSdkAepp.ts +167 -0
  203. package/src/AeSdkBase.ts +320 -0
  204. package/src/AeSdkWallet.ts +332 -0
  205. package/src/Node.ts +167 -0
  206. package/src/account/Base.ts +114 -0
  207. package/src/account/Memory.ts +83 -0
  208. package/src/account/Rpc.ts +67 -0
  209. package/src/aens.ts +391 -0
  210. package/src/aepp-wallet-communication/connection/Browser.ts +68 -0
  211. package/src/aepp-wallet-communication/connection/BrowserRuntime.ts +58 -0
  212. package/src/aepp-wallet-communication/connection/BrowserWindowMessage.ts +111 -0
  213. package/{es/utils/crypto-ts.js → src/aepp-wallet-communication/connection-proxy.ts} +16 -9
  214. package/src/aepp-wallet-communication/rpc/RpcClient.ts +137 -0
  215. package/src/aepp-wallet-communication/rpc/types.ts +66 -0
  216. package/src/aepp-wallet-communication/schema.ts +181 -0
  217. package/src/aepp-wallet-communication/wallet-detector.ts +71 -0
  218. package/src/apis/compiler/code-model-v4.yaml +2649 -0
  219. package/src/apis/compiler/compiler.ts +585 -0
  220. package/src/apis/compiler/index.ts +2 -0
  221. package/src/apis/compiler/models/index.ts +301 -0
  222. package/src/apis/compiler/models/mappers.ts +583 -0
  223. package/src/apis/compiler/models/parameters.ts +93 -0
  224. package/src/apis/node/code-model-v4.yaml +10046 -0
  225. package/src/apis/node/index.ts +2 -0
  226. package/src/apis/node/models/index.ts +1253 -0
  227. package/src/apis/node/models/mappers.ts +4278 -0
  228. package/src/apis/node/models/parameters.ts +188 -0
  229. package/src/apis/node/node.ts +1299 -0
  230. package/src/chain.ts +444 -0
  231. package/src/channel/{handlers.js → handlers.ts} +238 -143
  232. package/src/channel/index.ts +991 -0
  233. package/src/channel/internal.ts +345 -0
  234. package/src/contract/Compiler.ts +66 -0
  235. package/src/contract/aci.ts +529 -0
  236. package/src/contract/ga.ts +178 -0
  237. package/src/contract/methods.ts +118 -0
  238. package/src/index.ts +51 -0
  239. package/src/oracle.ts +342 -0
  240. package/src/spend.ts +152 -0
  241. package/src/tx/builder/constants.ts +96 -0
  242. package/src/tx/builder/field-types.ts +111 -0
  243. package/src/tx/builder/helpers.ts +253 -0
  244. package/src/tx/builder/index.ts +394 -0
  245. package/src/tx/builder/schema.ts +771 -0
  246. package/src/tx/index.ts +199 -0
  247. package/src/tx/min-fee.ts +136 -0
  248. package/src/tx/validator.ts +226 -0
  249. package/src/typings/@aeternity__argon2-browser/index.d.ts +3 -0
  250. package/src/typings/@aeternity__uuid/index.d.ts +3 -0
  251. package/src/typings/bip32-path/index.d.ts +33 -0
  252. package/src/typings/tweetnacl-auth/index.d.ts +14 -0
  253. package/src/utils/amount-formatter.ts +29 -41
  254. package/src/utils/autorest.ts +90 -0
  255. package/src/utils/bignumber.ts +9 -19
  256. package/src/utils/bytes.ts +15 -16
  257. package/src/utils/crypto.ts +217 -0
  258. package/src/utils/encoder.ts +98 -0
  259. package/src/utils/errors.ts +817 -0
  260. package/src/utils/hd-wallet.ts +134 -0
  261. package/src/utils/json-big.ts +26 -0
  262. package/src/utils/keystore.ts +179 -0
  263. package/src/utils/mptree.ts +26 -20
  264. package/src/utils/other.ts +28 -43
  265. package/src/utils/string.ts +8 -10
  266. package/CHANGELOG.md +0 -1603
  267. package/es/account/base.js +0 -169
  268. package/es/account/base.js.map +0 -1
  269. package/es/account/memory.js +0 -84
  270. package/es/account/memory.js.map +0 -1
  271. package/es/account/multiple.js +0 -178
  272. package/es/account/multiple.js.map +0 -1
  273. package/es/ae/aens.js +0 -408
  274. package/es/ae/aens.js.map +0 -1
  275. package/es/ae/aepp.js +0 -45
  276. package/es/ae/aepp.js.map +0 -1
  277. package/es/ae/contract.js +0 -312
  278. package/es/ae/contract.js.map +0 -1
  279. package/es/ae/index.js +0 -206
  280. package/es/ae/index.js.map +0 -1
  281. package/es/ae/oracle.js +0 -322
  282. package/es/ae/oracle.js.map +0 -1
  283. package/es/ae/universal.js +0 -45
  284. package/es/ae/universal.js.map +0 -1
  285. package/es/ae/wallet.js +0 -50
  286. package/es/ae/wallet.js.map +0 -1
  287. package/es/amount-formatter.d.ts +0 -58
  288. package/es/bignumber.d.ts +0 -24
  289. package/es/chain/index.js +0 -256
  290. package/es/chain/index.js.map +0 -1
  291. package/es/chain/node.js +0 -394
  292. package/es/chain/node.js.map +0 -1
  293. package/es/channel/handlers.js.map +0 -1
  294. package/es/channel/index.js +0 -980
  295. package/es/channel/index.js.map +0 -1
  296. package/es/channel/internal.js +0 -266
  297. package/es/channel/internal.js.map +0 -1
  298. package/es/contract/aci/helpers.js +0 -298
  299. package/es/contract/aci/helpers.js.map +0 -1
  300. package/es/contract/aci/index.js +0 -361
  301. package/es/contract/aci/index.js.map +0 -1
  302. package/es/contract/aci/transformation.js +0 -66
  303. package/es/contract/aci/transformation.js.map +0 -1
  304. package/es/contract/compiler.js +0 -244
  305. package/es/contract/compiler.js.map +0 -1
  306. package/es/contract/ga/helpers.js +0 -22
  307. package/es/contract/ga/helpers.js.map +0 -1
  308. package/es/contract/ga/index.js +0 -170
  309. package/es/contract/ga/index.js.map +0 -1
  310. package/es/contract/index.js +0 -162
  311. package/es/contract/index.js.map +0 -1
  312. package/es/crypto-ts.d.ts +0 -9
  313. package/es/index.js +0 -57
  314. package/es/index.js.map +0 -1
  315. package/es/node-pool/index.js +0 -187
  316. package/es/node-pool/index.js.map +0 -1
  317. package/es/node.js +0 -132
  318. package/es/node.js.map +0 -1
  319. package/es/other.d.ts +0 -31
  320. package/es/string.d.ts +0 -26
  321. package/es/tx/builder/helpers.js +0 -305
  322. package/es/tx/builder/helpers.js.map +0 -1
  323. package/es/tx/builder/index.js +0 -595
  324. package/es/tx/builder/index.js.map +0 -1
  325. package/es/tx/builder/schema.js +0 -814
  326. package/es/tx/builder/schema.js.map +0 -1
  327. package/es/tx/index.js +0 -300
  328. package/es/tx/index.js.map +0 -1
  329. package/es/tx/tx-object.js +0 -276
  330. package/es/tx/tx-object.js.map +0 -1
  331. package/es/tx/tx.js +0 -937
  332. package/es/tx/tx.js.map +0 -1
  333. package/es/tx/validator.js +0 -208
  334. package/es/tx/validator.js.map +0 -1
  335. package/es/typings/blakejs/index.d.js +0 -2
  336. package/es/typings/blakejs/index.d.js.map +0 -1
  337. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -131
  338. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
  339. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -184
  340. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
  341. package/es/utils/aepp-wallet-communication/connection/index.js +0 -84
  342. package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
  343. package/es/utils/aepp-wallet-communication/content-script-bridge.js +0 -97
  344. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
  345. package/es/utils/aepp-wallet-communication/helpers.js +0 -103
  346. package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
  347. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -329
  348. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
  349. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -270
  350. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
  351. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -533
  352. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
  353. package/es/utils/aepp-wallet-communication/schema.js +0 -107
  354. package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
  355. package/es/utils/aepp-wallet-communication/wallet-detector.js +0 -109
  356. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
  357. package/es/utils/amount-formatter.js.map +0 -1
  358. package/es/utils/async-init.js +0 -67
  359. package/es/utils/async-init.js.map +0 -1
  360. package/es/utils/bignumber.js +0 -28
  361. package/es/utils/bignumber.js.map +0 -1
  362. package/es/utils/bytes.js.map +0 -1
  363. package/es/utils/crypto-ts.js.map +0 -1
  364. package/es/utils/crypto.js +0 -304
  365. package/es/utils/crypto.js.map +0 -1
  366. package/es/utils/hd-wallet.js +0 -112
  367. package/es/utils/hd-wallet.js.map +0 -1
  368. package/es/utils/json-big.js +0 -45
  369. package/es/utils/json-big.js.map +0 -1
  370. package/es/utils/keystore.js +0 -228
  371. package/es/utils/keystore.js.map +0 -1
  372. package/es/utils/mptree.js.map +0 -1
  373. package/es/utils/other.js +0 -43
  374. package/es/utils/other.js.map +0 -1
  375. package/es/utils/semver-satisfies.js.map +0 -1
  376. package/es/utils/string.js.map +0 -1
  377. package/es/utils/swagger.js +0 -132
  378. package/es/utils/swagger.js.map +0 -1
  379. package/src/account/base.js +0 -153
  380. package/src/account/memory.js +0 -78
  381. package/src/account/multiple.js +0 -154
  382. package/src/ae/aens.js +0 -366
  383. package/src/ae/aepp.js +0 -45
  384. package/src/ae/contract.js +0 -285
  385. package/src/ae/index.js +0 -167
  386. package/src/ae/oracle.js +0 -296
  387. package/src/ae/universal.js +0 -47
  388. package/src/ae/wallet.js +0 -50
  389. package/src/chain/index.js +0 -250
  390. package/src/chain/node.js +0 -293
  391. package/src/channel/index.js +0 -898
  392. package/src/channel/internal.js +0 -231
  393. package/src/contract/aci/index.js +0 -317
  394. package/src/contract/aci/transformation.js +0 -72
  395. package/src/contract/compiler.js +0 -195
  396. package/src/contract/ga/helpers.js +0 -17
  397. package/src/contract/ga/index.js +0 -147
  398. package/src/contract/index.js +0 -163
  399. package/src/index.js +0 -90
  400. package/src/node-pool/index.js +0 -171
  401. package/src/node.js +0 -118
  402. package/src/tx/builder/helpers.js +0 -325
  403. package/src/tx/builder/index.js +0 -460
  404. package/src/tx/builder/schema.js +0 -1211
  405. package/src/tx/index.js +0 -301
  406. package/src/tx/tx-object.js +0 -186
  407. package/src/tx/tx.js +0 -622
  408. package/src/tx/validator.js +0 -161
  409. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +0 -114
  410. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -161
  411. package/src/utils/aepp-wallet-communication/connection/index.js +0 -85
  412. package/src/utils/aepp-wallet-communication/content-script-bridge.js +0 -85
  413. package/src/utils/aepp-wallet-communication/helpers.js +0 -70
  414. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -268
  415. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -223
  416. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -390
  417. package/src/utils/aepp-wallet-communication/schema.js +0 -108
  418. package/src/utils/aepp-wallet-communication/wallet-detector.js +0 -91
  419. package/src/utils/async-init.js +0 -41
  420. package/src/utils/crypto.js +0 -312
  421. package/src/utils/hd-wallet.js +0 -115
  422. package/src/utils/json-big.js +0 -26
  423. package/src/utils/keystore.js +0 -223
  424. package/src/utils/swagger.js +0 -133
@@ -0,0 +1,103 @@
1
+ /// <reference types="node" />
2
+ import { SignKeyPair } from 'tweetnacl';
3
+ import { Data } from 'blakejs';
4
+ import { sha256hash, EncodedData, EncodingType } from './encoder';
5
+ export { sha256hash };
6
+ /**
7
+ * Generate address from secret key
8
+ * @param secret - Private key
9
+ * @returns Public key encoded as address
10
+ */
11
+ export declare function getAddressFromPriv(secret: string | Uint8Array): EncodedData<'ak'>;
12
+ /**
13
+ * Check if address is valid
14
+ * @param address - Address
15
+ * @param prefix - Transaction prefix. Default: 'ak'
16
+ * @returns is valid
17
+ */
18
+ export declare function isAddressValid(address: string, prefix?: EncodingType): boolean;
19
+ /**
20
+ * Generate a random salt (positive integer)
21
+ * @returns random salt
22
+ */
23
+ export declare function salt(): number;
24
+ /**
25
+ * Converts a positive integer to the smallest possible
26
+ * representation in a binary digit representation
27
+ * @param value - Value to encode
28
+ * @returns Encoded number
29
+ */
30
+ export declare function encodeUnsigned(value: number): Buffer;
31
+ /**
32
+ * Calculate 256bits Blake2b hash of `input`
33
+ * @param input - Data to hash
34
+ * @returns Hash
35
+ */
36
+ export declare function hash(input: Data): Buffer;
37
+ /**
38
+ * Compute contract address
39
+ * @param owner - Address of contract owner
40
+ * @param nonce - Round when contract was created
41
+ * @returns Contract address
42
+ */
43
+ export declare function encodeContractAddress(owner: EncodedData<'ak'>, nonce: number): EncodedData<'ct'>;
44
+ /**
45
+ * Generate keyPair from secret key
46
+ * @param secret - secret key
47
+ * @returns Object with Private(privateKey) and Public(publicKey) keys
48
+ */
49
+ export declare function generateKeyPairFromSecret(secret: Uint8Array): SignKeyPair;
50
+ /**
51
+ * Generate a random ED25519 keypair
52
+ * @param raw - Whether to return raw (binary) keys
53
+ * @returns Key pair
54
+ */
55
+ export declare function generateKeyPair(raw: true): {
56
+ publicKey: Buffer;
57
+ secretKey: Buffer;
58
+ };
59
+ export declare function generateKeyPair(raw?: false): {
60
+ publicKey: EncodedData<'ak'>;
61
+ secretKey: string;
62
+ };
63
+ /**
64
+ * Encrypt given data using `password`
65
+ * @param password - Password to encrypt with
66
+ * @param binaryData - Data to encrypt
67
+ * @returns Encrypted data
68
+ */
69
+ export declare function encryptKey(password: string, binaryData: Uint8Array): Uint8Array;
70
+ /**
71
+ * Decrypt given data using `password`
72
+ * @param password - Password to decrypt with
73
+ * @param encrypted - Data to decrypt
74
+ * @returns Decrypted data
75
+ */
76
+ export declare function decryptKey(password: string, encrypted: Uint8Array): Uint8Array;
77
+ /**
78
+ * Generate signature
79
+ * @param data - Data to sign
80
+ * @param privateKey - Key to sign with
81
+ * @returns Signature
82
+ */
83
+ export declare function sign(data: string | Uint8Array, privateKey: string | Uint8Array): Uint8Array;
84
+ /**
85
+ * Verify that signature was signed by public key
86
+ * @param data - Data to verify
87
+ * @param signature - Signature to verify
88
+ * @param publicKey - Key to verify against
89
+ * @returns Valid?
90
+ */
91
+ export declare function verify(data: Uint8Array, signature: Uint8Array, publicKey: string | Uint8Array): boolean;
92
+ export declare function messageToHash(message: string): Buffer;
93
+ export declare function signMessage(message: string, privateKey: string | Buffer): Uint8Array;
94
+ export declare function verifyMessage(str: string, signature: Uint8Array, publicKey: string | Uint8Array): boolean;
95
+ /**
96
+ * Check key pair for validity
97
+ *
98
+ * Sign a message, and then verifying that signature
99
+ * @param privateKey - Private key to verify
100
+ * @param publicKey - Public key to verify
101
+ * @returns Valid?
102
+ */
103
+ export declare function isValidKeypair(privateKey: string | Uint8Array, publicKey: string | Uint8Array): boolean;
@@ -0,0 +1,221 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+
6
+ /*
7
+ * ISC License (ISC)
8
+ * Copyright 2018 aeternity developers
9
+ *
10
+ * Permission to use, copy, modify, and/or distribute this software for any
11
+ * purpose with or without fee is hereby granted, provided that the above
12
+ * copyright notice and this permission notice appear in all copies.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16
+ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
+ * PERFORMANCE OF THIS SOFTWARE.
21
+ */
22
+ import nacl from 'tweetnacl';
23
+ import aesjs from 'aes-js';
24
+ import _blakejs from 'blakejs';
25
+ const {
26
+ blake2b
27
+ } = _blakejs;
28
+ import _varuintBitcoin from 'varuint-bitcoin';
29
+ const {
30
+ encode: varuintEncode
31
+ } = _varuintBitcoin;
32
+ import { str2buf } from "./bytes.mjs";
33
+ import { concatBuffers } from "./other.mjs";
34
+ import { encode, decode, sha256hash } from "./encoder.mjs";
35
+ export { sha256hash };
36
+ const Ecb = aesjs.ModeOfOperation.ecb;
37
+ /**
38
+ * Generate address from secret key
39
+ * @param secret - Private key
40
+ * @returns Public key encoded as address
41
+ */
42
+
43
+ export function getAddressFromPriv(secret) {
44
+ const secretBuffer = typeof secret === 'string' ? str2buf(secret) : secret;
45
+ const keys = nacl.sign.keyPair.fromSecretKey(secretBuffer);
46
+ return encode(keys.publicKey, 'ak');
47
+ }
48
+ /**
49
+ * Check if address is valid
50
+ * @param address - Address
51
+ * @param prefix - Transaction prefix. Default: 'ak'
52
+ * @returns is valid
53
+ */
54
+
55
+ export function isAddressValid(address) {
56
+ let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'ak';
57
+
58
+ try {
59
+ decode(address);
60
+ return true;
61
+ } catch (e) {
62
+ return false;
63
+ }
64
+ }
65
+ /**
66
+ * Generate a random salt (positive integer)
67
+ * @returns random salt
68
+ */
69
+
70
+ export function salt() {
71
+ return Math.floor(Math.random() * Math.floor(Number.MAX_SAFE_INTEGER));
72
+ }
73
+ /**
74
+ * Converts a positive integer to the smallest possible
75
+ * representation in a binary digit representation
76
+ * @param value - Value to encode
77
+ * @returns Encoded number
78
+ */
79
+
80
+ export function encodeUnsigned(value) {
81
+ const binary = _Buffer.allocUnsafe(4);
82
+
83
+ binary.writeUInt32BE(value);
84
+ return binary.slice(binary.findIndex(i => i !== 0));
85
+ }
86
+ /**
87
+ * Calculate 256bits Blake2b hash of `input`
88
+ * @param input - Data to hash
89
+ * @returns Hash
90
+ */
91
+
92
+ export function hash(input) {
93
+ return _Buffer.from(blake2b(input, undefined, 32)); // 256 bits
94
+ } // Todo Duplicated in tx builder. remove
95
+
96
+ /**
97
+ * Compute contract address
98
+ * @param owner - Address of contract owner
99
+ * @param nonce - Round when contract was created
100
+ * @returns Contract address
101
+ */
102
+
103
+ export function encodeContractAddress(owner, nonce) {
104
+ const publicKey = decode(owner);
105
+ const binary = concatBuffers([publicKey, encodeUnsigned(nonce)]);
106
+ return encode(hash(binary), 'ct');
107
+ } // KEY-PAIR HELPERS
108
+
109
+ /**
110
+ * Generate keyPair from secret key
111
+ * @param secret - secret key
112
+ * @returns Object with Private(privateKey) and Public(publicKey) keys
113
+ */
114
+
115
+ export function generateKeyPairFromSecret(secret) {
116
+ return nacl.sign.keyPair.fromSecretKey(secret);
117
+ }
118
+ /**
119
+ * Generate a random ED25519 keypair
120
+ * @param raw - Whether to return raw (binary) keys
121
+ * @returns Key pair
122
+ */
123
+
124
+ export function generateKeyPair() {
125
+ let raw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
126
+ const keyPair = nacl.sign.keyPair();
127
+
128
+ const publicBuffer = _Buffer.from(keyPair.publicKey);
129
+
130
+ const secretBuffer = _Buffer.from(keyPair.secretKey);
131
+
132
+ if (raw) {
133
+ return {
134
+ publicKey: publicBuffer,
135
+ secretKey: secretBuffer
136
+ };
137
+ } else {
138
+ return {
139
+ publicKey: encode(publicBuffer, 'ak'),
140
+ secretKey: secretBuffer.toString('hex')
141
+ };
142
+ }
143
+ }
144
+ /**
145
+ * Encrypt given data using `password`
146
+ * @param password - Password to encrypt with
147
+ * @param binaryData - Data to encrypt
148
+ * @returns Encrypted data
149
+ */
150
+
151
+ export function encryptKey(password, binaryData) {
152
+ const hashedPasswordBytes = sha256hash(password);
153
+ const aesEcb = new Ecb(hashedPasswordBytes);
154
+ return aesEcb.encrypt(binaryData);
155
+ }
156
+ /**
157
+ * Decrypt given data using `password`
158
+ * @param password - Password to decrypt with
159
+ * @param encrypted - Data to decrypt
160
+ * @returns Decrypted data
161
+ */
162
+
163
+ export function decryptKey(password, encrypted) {
164
+ const encryptedBytes = _Buffer.from(encrypted);
165
+
166
+ const hashedPasswordBytes = sha256hash(password);
167
+ const aesEcb = new Ecb(hashedPasswordBytes);
168
+ return aesEcb.decrypt(encryptedBytes);
169
+ } // SIGNATURES
170
+
171
+ /**
172
+ * Generate signature
173
+ * @param data - Data to sign
174
+ * @param privateKey - Key to sign with
175
+ * @returns Signature
176
+ */
177
+
178
+ export function sign(data, privateKey) {
179
+ return nacl.sign.detached(_Buffer.from(data), _Buffer.from(privateKey));
180
+ }
181
+ /**
182
+ * Verify that signature was signed by public key
183
+ * @param data - Data to verify
184
+ * @param signature - Signature to verify
185
+ * @param publicKey - Key to verify against
186
+ * @returns Valid?
187
+ */
188
+
189
+ export function verify(data, signature, publicKey) {
190
+ const publicKeyBuffer = typeof publicKey === 'string' ? str2buf(publicKey) : publicKey;
191
+ return nacl.sign.detached.verify(data, signature, publicKeyBuffer);
192
+ }
193
+ export function messageToHash(message) {
194
+ const p = _Buffer.from('aeternity Signed Message:\n', 'utf8');
195
+
196
+ const msg = _Buffer.from(message, 'utf8');
197
+
198
+ return hash(concatBuffers([varuintEncode(p.length), p, varuintEncode(msg.length), msg]));
199
+ }
200
+ export function signMessage(message, privateKey) {
201
+ return sign(messageToHash(message), privateKey);
202
+ }
203
+ export function verifyMessage(str, signature, publicKey) {
204
+ return verify(messageToHash(str), signature, publicKey);
205
+ }
206
+ /**
207
+ * Check key pair for validity
208
+ *
209
+ * Sign a message, and then verifying that signature
210
+ * @param privateKey - Private key to verify
211
+ * @param publicKey - Public key to verify
212
+ * @returns Valid?
213
+ */
214
+
215
+ export function isValidKeypair(privateKey, publicKey) {
216
+ const message = _Buffer.from('TheMessage');
217
+
218
+ const signature = sign(message, privateKey);
219
+ return verify(message, signature, publicKey);
220
+ }
221
+ //# sourceMappingURL=crypto.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.mjs","names":["nacl","aesjs","str2buf","concatBuffers","encode","decode","sha256hash","Ecb","ModeOfOperation","ecb","getAddressFromPriv","secret","secretBuffer","keys","sign","keyPair","fromSecretKey","publicKey","isAddressValid","address","prefix","e","salt","Math","floor","random","Number","MAX_SAFE_INTEGER","encodeUnsigned","value","binary","allocUnsafe","writeUInt32BE","slice","findIndex","i","hash","input","from","blake2b","undefined","encodeContractAddress","owner","nonce","generateKeyPairFromSecret","generateKeyPair","raw","publicBuffer","secretKey","toString","encryptKey","password","binaryData","hashedPasswordBytes","aesEcb","encrypt","decryptKey","encrypted","encryptedBytes","decrypt","data","privateKey","detached","verify","signature","publicKeyBuffer","messageToHash","message","p","msg","varuintEncode","length","signMessage","verifyMessage","str","isValidKeypair"],"sources":["../../src/utils/crypto.ts"],"sourcesContent":["/*\n * ISC License (ISC)\n * Copyright 2018 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 */\nimport nacl, { SignKeyPair } from 'tweetnacl'\nimport aesjs from 'aes-js'\nimport { blake2b, Data } from 'blakejs'\nimport { encode as varuintEncode } from 'varuint-bitcoin'\n\nimport { str2buf } from './bytes'\nimport { concatBuffers } from './other'\nimport { encode, decode, sha256hash, EncodedData, EncodingType } from './encoder'\n\nexport { sha256hash }\n\nconst Ecb = aesjs.ModeOfOperation.ecb\n\n/**\n * Generate address from secret key\n * @param secret - Private key\n * @returns Public key encoded as address\n */\nexport function getAddressFromPriv (secret: string | Uint8Array): EncodedData<'ak'> {\n const secretBuffer = typeof secret === 'string' ? str2buf(secret) : secret\n const keys = nacl.sign.keyPair.fromSecretKey(secretBuffer)\n return encode(keys.publicKey, 'ak')\n}\n\n/**\n * Check if address is valid\n * @param address - Address\n * @param prefix - Transaction prefix. Default: 'ak'\n * @returns is valid\n */\nexport function isAddressValid (address: string, prefix: EncodingType = 'ak'): boolean {\n try {\n decode(address as EncodedData<typeof prefix>)\n return true\n } catch (e) {\n return false\n }\n}\n\n/**\n * Generate a random salt (positive integer)\n * @returns random salt\n */\nexport function salt (): number {\n return Math.floor(Math.random() * Math.floor(Number.MAX_SAFE_INTEGER))\n}\n\n/**\n * Converts a positive integer to the smallest possible\n * representation in a binary digit representation\n * @param value - Value to encode\n * @returns Encoded number\n */\nexport function encodeUnsigned (value: number): Buffer {\n const binary = Buffer.allocUnsafe(4)\n binary.writeUInt32BE(value)\n return binary.slice(binary.findIndex(i => i !== 0))\n}\n\n/**\n * Calculate 256bits Blake2b hash of `input`\n * @param input - Data to hash\n * @returns Hash\n */\nexport function hash (input: Data): Buffer {\n return Buffer.from(blake2b(input, undefined, 32)) // 256 bits\n}\n\n// Todo Duplicated in tx builder. remove\n/**\n * Compute contract address\n * @param owner - Address of contract owner\n * @param nonce - Round when contract was created\n * @returns Contract address\n */\nexport function encodeContractAddress (owner: EncodedData<'ak'>, nonce: number): EncodedData<'ct'> {\n const publicKey = decode(owner)\n const binary = concatBuffers([publicKey, encodeUnsigned(nonce)])\n return encode(hash(binary), 'ct')\n}\n\n// KEY-PAIR HELPERS\n\n/**\n * Generate keyPair from secret key\n * @param secret - secret key\n * @returns Object with Private(privateKey) and Public(publicKey) keys\n */\nexport function generateKeyPairFromSecret (secret: Uint8Array): SignKeyPair {\n return nacl.sign.keyPair.fromSecretKey(secret)\n}\n\n/**\n * Generate a random ED25519 keypair\n * @param raw - Whether to return raw (binary) keys\n * @returns Key pair\n */\nexport function generateKeyPair (raw: true): { publicKey: Buffer, secretKey: Buffer }\nexport function generateKeyPair (raw?: false): { publicKey: EncodedData<'ak'>, secretKey: string }\nexport function generateKeyPair (raw: boolean = false): {\n publicKey: EncodedData<'ak'> | Buffer\n secretKey: string | Buffer\n} {\n const keyPair = nacl.sign.keyPair()\n const publicBuffer = Buffer.from(keyPair.publicKey)\n const secretBuffer = Buffer.from(keyPair.secretKey)\n\n if (raw) {\n return {\n publicKey: publicBuffer,\n secretKey: secretBuffer\n }\n } else {\n return {\n publicKey: encode(publicBuffer, 'ak'),\n secretKey: secretBuffer.toString('hex')\n }\n }\n}\n\n/**\n * Encrypt given data using `password`\n * @param password - Password to encrypt with\n * @param binaryData - Data to encrypt\n * @returns Encrypted data\n */\nexport function encryptKey (password: string, binaryData: Uint8Array): Uint8Array {\n const hashedPasswordBytes = sha256hash(password)\n const aesEcb = new Ecb(hashedPasswordBytes)\n return aesEcb.encrypt(binaryData)\n}\n\n/**\n * Decrypt given data using `password`\n * @param password - Password to decrypt with\n * @param encrypted - Data to decrypt\n * @returns Decrypted data\n */\nexport function decryptKey (password: string, encrypted: Uint8Array): Uint8Array {\n const encryptedBytes = Buffer.from(encrypted)\n const hashedPasswordBytes = sha256hash(password)\n const aesEcb = new Ecb(hashedPasswordBytes)\n return aesEcb.decrypt(encryptedBytes)\n}\n\n// SIGNATURES\n\n/**\n * Generate signature\n * @param data - Data to sign\n * @param privateKey - Key to sign with\n * @returns Signature\n */\nexport function sign (data: string | Uint8Array, privateKey: string | Uint8Array): Uint8Array {\n return nacl.sign.detached(Buffer.from(data), Buffer.from(privateKey))\n}\n\n/**\n * Verify that signature was signed by public key\n * @param data - Data to verify\n * @param signature - Signature to verify\n * @param publicKey - Key to verify against\n * @returns Valid?\n */\nexport function verify (\n data: Uint8Array, signature: Uint8Array, publicKey: string | Uint8Array\n): boolean {\n const publicKeyBuffer = typeof publicKey === 'string' ? str2buf(publicKey) : publicKey\n return nacl.sign.detached.verify(data, signature, publicKeyBuffer)\n}\n\nexport function messageToHash (message: string): Buffer {\n const p = Buffer.from('aeternity Signed Message:\\n', 'utf8')\n const msg = Buffer.from(message, 'utf8')\n return hash(concatBuffers([varuintEncode(p.length), p, varuintEncode(msg.length), msg]))\n}\n\nexport function signMessage (message: string, privateKey: string | Buffer): Uint8Array {\n return sign(messageToHash(message), privateKey)\n}\n\nexport function verifyMessage (\n str: string, signature: Uint8Array, publicKey: string | Uint8Array): boolean {\n return verify(messageToHash(str), signature, publicKey)\n}\n\n/**\n * Check key pair for validity\n *\n * Sign a message, and then verifying that signature\n * @param privateKey - Private key to verify\n * @param publicKey - Public key to verify\n * @returns Valid?\n */\nexport function isValidKeypair (\n privateKey: string | Uint8Array, publicKey: string | Uint8Array\n): boolean {\n const message = Buffer.from('TheMessage')\n const signature = sign(message, privateKey)\n return verify(message, signature, publicKey)\n}\n"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,IAAP,MAAkC,WAAlC;AACA,OAAOC,KAAP,MAAkB,QAAlB;AACA,qBAA8B,SAA9B;;;;AACA,4BAAwC,iBAAxC;;;;SAESC,O;SACAC,a;SACAC,M,EAAQC,M,EAAQC,U;AAEzB,SAASA,UAAT;AAEA,MAAMC,GAAG,GAAGN,KAAK,CAACO,eAAN,CAAsBC,GAAlC;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CAA6BC,MAA7B,EAA6E;EAClF,MAAMC,YAAY,GAAG,OAAOD,MAAP,KAAkB,QAAlB,GAA6BT,OAAO,CAACS,MAAD,CAApC,GAA+CA,MAApE;EACA,MAAME,IAAI,GAAGb,IAAI,CAACc,IAAL,CAAUC,OAAV,CAAkBC,aAAlB,CAAgCJ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AX;AACD;AAED,OAAO,SAASY,aAAT,CACLC,GADK,EACQV,SADR,EAC+B/C,SAD/B,EACwE;EAC7E,OAAO8C,MAAM,CAACG,aAAa,CAACQ,GAAD,CAAd,EAAqBV,SAArB,EAAgC/C,SAAhC,CAAb;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAAS0D,cAAT,CACLd,UADK,EAC4B5C,SAD5B,EAEI;EACT,MAAMkD,OAAO,GAAG,QAAO7B,IAAP,CAAY,YAAZ,CAAhB;;EACA,MAAM0B,SAAS,GAAGlD,IAAI,CAACqD,OAAD,EAAUN,UAAV,CAAtB;EACA,OAAOE,MAAM,CAACI,OAAD,EAAUH,SAAV,EAAqB/C,SAArB,CAAb;AACD"}
@@ -0,0 +1,26 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Calculate SHA256 hash of `input`
4
+ * @param input - Data to hash
5
+ * @returns Hash
6
+ */
7
+ export declare function sha256hash(input: Uint8Array | string): Buffer;
8
+ declare const base64Types: readonly ["ba", "cb", "or", "ov", "pi", "ss", "cs", "ck", "cv", "st", "tx"];
9
+ declare const base58Types: readonly ["ak", "bf", "bs", "bx", "ch", "cm", "ct", "kh", "mh", "nm", "ok", "oq", "pp", "sg", "th"];
10
+ export declare type EncodingType = typeof base64Types[number] | typeof base58Types[number];
11
+ export declare type EncodedData<Type extends EncodingType> = `${Type}_${string}`;
12
+ /**
13
+ * Decode data using the default encoding/decoding algorithm
14
+ * @param data - An Base58/64check encoded and prefixed string
15
+ * (ex tx_..., sg_..., ak_....)
16
+ * @returns Decoded data
17
+ */
18
+ export declare function decode(data: EncodedData<EncodingType>): Buffer;
19
+ /**
20
+ * Encode data using the default encoding/decoding algorithm
21
+ * @param data - An decoded data
22
+ * @param type - Prefix of Transaction
23
+ * @returns Encoded string Base58check or Base64check data
24
+ */
25
+ export declare function encode<Type extends EncodingType>(data: Uint8Array, type: Type): EncodedData<Type>;
26
+ export {};
@@ -0,0 +1,102 @@
1
+ import _buffer from "buffer";
2
+ const {
3
+ Buffer: _Buffer
4
+ } = _buffer;
5
+ import _bs from 'bs58';
6
+ const {
7
+ encode: bs58Encode,
8
+ decode: bs58Decode
9
+ } = _bs;
10
+ import _shaJs from 'sha.js';
11
+ const {
12
+ sha256: Sha256
13
+ } = _shaJs;
14
+ import { DecodeError, ArgumentError, InvalidChecksumError, PayloadLengthError } from "./errors.mjs";
15
+ import { concatBuffers } from "./other.mjs";
16
+ /**
17
+ * Calculate SHA256 hash of `input`
18
+ * @param input - Data to hash
19
+ * @returns Hash
20
+ */
21
+
22
+ export function sha256hash(input) {
23
+ return new Sha256().update(input).digest();
24
+ } // based on https://github.com/aeternity/protocol/blob/master/node/api/api_encoding.md
25
+
26
+ const base64Types = ['ba', 'cb', 'or', 'ov', 'pi', 'ss', 'cs', 'ck', 'cv', 'st', 'tx'];
27
+ const base58Types = ['ak', 'bf', 'bs', 'bx', 'ch', 'cm', 'ct', 'kh', 'mh', 'nm', 'ok', 'oq', 'pp', 'sg', 'th'];
28
+ // TODO: add all types with a fixed length
29
+ const typesLength = {
30
+ ak: 32,
31
+ ct: 32,
32
+ ok: 32
33
+ };
34
+
35
+ function ensureValidLength(data, type) {
36
+ const reqLen = typesLength[type];
37
+ if (reqLen == null || data.length === reqLen) return;
38
+ throw new PayloadLengthError(`Payload should be ${reqLen} bytes, got ${data.length} instead`);
39
+ }
40
+
41
+ const getChecksum = payload => sha256hash(sha256hash(payload)).slice(0, 4);
42
+
43
+ const addChecksum = payload => {
44
+ return concatBuffers([payload, getChecksum(payload)]);
45
+ };
46
+
47
+ function getPayload(buffer) {
48
+ const payload = buffer.slice(0, -4);
49
+ if (!getChecksum(payload).equals(buffer.slice(-4))) throw new InvalidChecksumError();
50
+ return payload;
51
+ }
52
+
53
+ const base64 = {
54
+ encode: buffer => addChecksum(buffer).toString('base64'),
55
+ decode: string => getPayload(_Buffer.from(string, 'base64'))
56
+ };
57
+ const base58 = {
58
+ encode: buffer => bs58Encode(addChecksum(buffer)),
59
+ decode: string => getPayload(_Buffer.from(bs58Decode(string)))
60
+ };
61
+
62
+ const parseType = maybeType => {
63
+ const base64Type = base64Types.find(t => t === maybeType);
64
+ if (base64Type != null) return [base64Type, base64];
65
+ const base58Type = base58Types.find(t => t === maybeType);
66
+ if (base58Type != null) return [base58Type, base58];
67
+ throw new ArgumentError('prefix', `one of ${[...base58Types, ...base64Types].join(', ')}`, maybeType);
68
+ };
69
+ /**
70
+ * Decode data using the default encoding/decoding algorithm
71
+ * @param data - An Base58/64check encoded and prefixed string
72
+ * (ex tx_..., sg_..., ak_....)
73
+ * @returns Decoded data
74
+ */
75
+
76
+
77
+ export function decode(data) {
78
+ const [prefix, encodedPayload, extra] = data.split('_');
79
+ if (encodedPayload == null) throw new DecodeError(`Encoded string missing payload: ${data}`);
80
+ if (extra != null) throw new DecodeError(`Encoded string have extra parts: ${data}`);
81
+ const [type, {
82
+ decode
83
+ }] = parseType(prefix);
84
+ const payload = decode(encodedPayload);
85
+ ensureValidLength(payload, type);
86
+ return payload;
87
+ }
88
+ /**
89
+ * Encode data using the default encoding/decoding algorithm
90
+ * @param data - An decoded data
91
+ * @param type - Prefix of Transaction
92
+ * @returns Encoded string Base58check or Base64check data
93
+ */
94
+
95
+ export function encode(data, type) {
96
+ const [, {
97
+ encode
98
+ }] = parseType(type);
99
+ ensureValidLength(data, type);
100
+ return `${type}_${encode(data)}`;
101
+ }
102
+ //# sourceMappingURL=encoder.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoder.mjs","names":["DecodeError","ArgumentError","InvalidChecksumError","PayloadLengthError","concatBuffers","sha256hash","input","Sha256","update","digest","base64Types","base58Types","typesLength","ak","ct","ok","ensureValidLength","data","type","reqLen","length","getChecksum","payload","slice","addChecksum","getPayload","buffer","equals","base64","encode","toString","decode","string","from","base58","bs58Encode","bs58Decode","parseType","maybeType","base64Type","find","t","base58Type","join","prefix","encodedPayload","extra","split"],"sources":["../../src/utils/encoder.ts"],"sourcesContent":["import { encode as bs58Encode, decode as bs58Decode } from 'bs58'\nimport { sha256 as Sha256 } from 'sha.js'\nimport {\n DecodeError,\n ArgumentError,\n InvalidChecksumError,\n PayloadLengthError\n} from './errors'\nimport { concatBuffers } from './other'\n\n/**\n * Calculate SHA256 hash of `input`\n * @param input - Data to hash\n * @returns Hash\n */\nexport function sha256hash (input: Uint8Array | string): Buffer {\n return new Sha256().update(input).digest()\n}\n\n// based on https://github.com/aeternity/protocol/blob/master/node/api/api_encoding.md\nconst base64Types = ['ba', 'cb', 'or', 'ov', 'pi', 'ss', 'cs', 'ck', 'cv', 'st', 'tx'] as const\nconst base58Types = ['ak', 'bf', 'bs', 'bx', 'ch', 'cm', 'ct', 'kh', 'mh', 'nm', 'ok', 'oq', 'pp', 'sg', 'th'] as const\n\nexport type EncodingType = typeof base64Types[number] | typeof base58Types[number]\nexport type EncodedData<Type extends EncodingType> = `${Type}_${string}`\n// TODO: add all types with a fixed length\nconst typesLength: { [name in EncodingType]?: number } = {\n ak: 32,\n ct: 32,\n ok: 32\n} as const\n\nfunction ensureValidLength (data: Uint8Array, type: EncodingType): void {\n const reqLen = typesLength[type]\n if (reqLen == null || data.length === reqLen) return\n throw new PayloadLengthError(`Payload should be ${reqLen} bytes, got ${data.length} instead`)\n}\n\nconst getChecksum = (payload: Uint8Array): Buffer =>\n sha256hash(sha256hash(payload)).slice(0, 4)\n\nconst addChecksum = (payload: Uint8Array): Buffer => {\n return concatBuffers([payload, getChecksum(payload)])\n}\n\nfunction getPayload (buffer: Buffer): Buffer {\n const payload = buffer.slice(0, -4)\n if (!getChecksum(payload).equals(buffer.slice(-4))) throw new InvalidChecksumError()\n return payload\n}\n\nconst base64 = {\n encode: (buffer: Uint8Array) => addChecksum(buffer).toString('base64'),\n decode: (string: string) => getPayload(Buffer.from(string, 'base64'))\n}\n\nconst base58 = {\n encode: (buffer: Uint8Array) => bs58Encode(addChecksum(buffer)),\n decode: (string: string) => getPayload(Buffer.from(bs58Decode(string)))\n}\n\nconst parseType = (maybeType: unknown): [EncodingType, typeof base64] => {\n const base64Type = base64Types.find(t => t === maybeType)\n if (base64Type != null) return [base64Type, base64]\n const base58Type = base58Types.find(t => t === maybeType)\n if (base58Type != null) return [base58Type, base58]\n throw new ArgumentError('prefix', `one of ${[...base58Types, ...base64Types].join(', ')}`, maybeType)\n}\n\n/**\n * Decode data using the default encoding/decoding algorithm\n * @param data - An Base58/64check encoded and prefixed string\n * (ex tx_..., sg_..., ak_....)\n * @returns Decoded data\n */\nexport function decode (data: EncodedData<EncodingType>): Buffer {\n const [prefix, encodedPayload, extra] = data.split('_')\n if (encodedPayload == null) throw new DecodeError(`Encoded string missing payload: ${data}`)\n if (extra != null) throw new DecodeError(`Encoded string have extra parts: ${data}`)\n const [type, { decode }] = parseType(prefix)\n const payload = decode(encodedPayload)\n ensureValidLength(payload, type)\n return payload\n}\n\n/**\n * Encode data using the default encoding/decoding algorithm\n * @param data - An decoded data\n * @param type - Prefix of Transaction\n * @returns Encoded string Base58check or Base64check data\n */\nexport function encode<Type extends EncodingType> (\n data: Uint8Array, type: Type\n): EncodedData<Type> {\n const [, { encode }] = parseType(type)\n ensureValidLength(data, type)\n return `${type}_${encode(data)}`\n}\n"],"mappings":";;;;AAAA,gBAA2D,MAA3D;;;;;AACA,mBAAiC,QAAjC;;;;SAEEA,W,EACAC,a,EACAC,oB,EACAC,kB;SAEOC,a;AAET;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,UAAT,CAAqBC,KAArB,EAAyD;EAC9D,OAAO,IAAIC,MAAJ,GAAaC,MAAb,CAAoBF,KAApB,EAA2BG,MAA3B,EAAP;AACD,C,CAED;;AACA,MAAMC,WAAW,GAAG,CAAC,IAAD,EAAO,IAAP,EAAa,IAAb,EAAmB,IAAnB,EAAyB,IAAzB,EAA+B,IAA/B,EAAqC,IAArC,EAA2C,IAA3C,EAAiD,IAAjD,EAAuD,IAAvD,EAA6D,IAA7D,CAApB;AACA,MAAMC,WAAW,GAAG,C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