@aptos-labs/ts-sdk 1.16.0-zeta.3 → 1.17.0-zeta.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 (255) hide show
  1. package/dist/common/{accountAddress-YfW6h4Ja.d.ts → accountAddress-jP2Ua0t9.d.ts} +1 -1
  2. package/dist/common/chunk-BHKSQXUZ.js +2 -0
  3. package/dist/common/chunk-BHKSQXUZ.js.map +1 -0
  4. package/dist/common/cli/index.d.ts +1 -1
  5. package/dist/common/cli/index.js +1 -1
  6. package/dist/common/index.d.ts +176 -144
  7. package/dist/common/index.js +27 -27
  8. package/dist/common/index.js.map +1 -1
  9. package/dist/esm/account/Account.mjs +1 -1
  10. package/dist/esm/account/Ed25519Account.mjs +1 -1
  11. package/dist/esm/account/EphemeralKeyPair.d.mts +6 -1
  12. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  13. package/dist/esm/account/KeylessAccount.d.mts +4 -5
  14. package/dist/esm/account/KeylessAccount.mjs +1 -1
  15. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  16. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  17. package/dist/esm/account/index.d.mts +2 -2
  18. package/dist/esm/account/index.mjs +1 -1
  19. package/dist/esm/api/account.d.mts +2 -2
  20. package/dist/esm/api/account.mjs +1 -1
  21. package/dist/esm/api/ans.d.mts +2 -2
  22. package/dist/esm/api/ans.mjs +1 -1
  23. package/dist/esm/api/aptos.d.mts +1 -1
  24. package/dist/esm/api/aptos.mjs +1 -1
  25. package/dist/esm/api/coin.d.mts +2 -2
  26. package/dist/esm/api/coin.mjs +1 -1
  27. package/dist/esm/api/digitalAsset.d.mts +2 -2
  28. package/dist/esm/api/digitalAsset.mjs +1 -1
  29. package/dist/esm/api/event.mjs +1 -1
  30. package/dist/esm/api/faucet.mjs +1 -1
  31. package/dist/esm/api/fungibleAsset.mjs +1 -1
  32. package/dist/esm/api/general.mjs +1 -1
  33. package/dist/esm/api/index.d.mts +1 -1
  34. package/dist/esm/api/index.mjs +1 -1
  35. package/dist/esm/api/keyless.d.mts +8 -3
  36. package/dist/esm/api/keyless.mjs +1 -1
  37. package/dist/esm/api/staking.mjs +1 -1
  38. package/dist/esm/api/table.mjs +1 -1
  39. package/dist/esm/api/transaction.mjs +1 -1
  40. package/dist/esm/api/transactionSubmission/build.d.mts +2 -2
  41. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  42. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  43. package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
  44. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  45. package/dist/esm/api/transactionSubmission/simulate.d.mts +2 -2
  46. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  47. package/dist/esm/api/transactionSubmission/submit.d.mts +2 -2
  48. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  49. package/dist/esm/api/utils.mjs +1 -1
  50. package/dist/esm/{chunk-2SJENNM4.mjs → chunk-2G4IGSGM.mjs} +2 -2
  51. package/dist/esm/{chunk-TEGJAM44.mjs → chunk-3SACE4I2.mjs} +2 -2
  52. package/dist/esm/chunk-4BJA3QUQ.mjs +2 -0
  53. package/dist/esm/{chunk-F7XWXQHU.mjs.map → chunk-4BJA3QUQ.mjs.map} +1 -1
  54. package/dist/esm/{chunk-O3BRX56F.mjs → chunk-4CUDBBTC.mjs} +2 -2
  55. package/dist/esm/chunk-54LCK6EN.mjs +2 -0
  56. package/dist/esm/chunk-54LCK6EN.mjs.map +1 -0
  57. package/dist/esm/{chunk-JBX3JBIW.mjs → chunk-5WFKJO5L.mjs} +2 -2
  58. package/dist/esm/{chunk-AXR47GFL.mjs → chunk-64CUEMFI.mjs} +2 -2
  59. package/dist/esm/{chunk-B74ZAMWR.mjs → chunk-64VPA7CM.mjs} +2 -2
  60. package/dist/esm/{chunk-MPTKOK27.mjs → chunk-7G3RSOWE.mjs} +2 -2
  61. package/dist/esm/{chunk-ARHEUGVT.mjs → chunk-7M4C4OZN.mjs} +2 -2
  62. package/dist/esm/{chunk-AEWSL7BS.mjs → chunk-7UKBRLGM.mjs} +2 -2
  63. package/dist/esm/{chunk-ERPUZQVK.mjs → chunk-B2RYTKNN.mjs} +2 -2
  64. package/dist/esm/chunk-BCZGONNO.mjs +2 -0
  65. package/dist/esm/chunk-BCZGONNO.mjs.map +1 -0
  66. package/dist/esm/{chunk-JEE2OXOZ.mjs → chunk-BLWJZXAD.mjs} +2 -2
  67. package/dist/esm/{chunk-Z6FMMNAL.mjs → chunk-BT6IM25V.mjs} +2 -2
  68. package/dist/esm/{chunk-X2VUS374.mjs → chunk-CPDSBH23.mjs} +2 -2
  69. package/dist/esm/{chunk-LA67NWMV.mjs → chunk-DJPYZIJY.mjs} +2 -2
  70. package/dist/esm/chunk-EHL3WIK3.mjs +2 -0
  71. package/dist/esm/chunk-EHL3WIK3.mjs.map +1 -0
  72. package/dist/esm/{chunk-UBON2G6Y.mjs → chunk-FNFQA7NS.mjs} +2 -2
  73. package/dist/esm/chunk-FR6UGCOX.mjs +2 -0
  74. package/dist/esm/chunk-FR6UGCOX.mjs.map +1 -0
  75. package/dist/esm/{chunk-E62NBNHE.mjs → chunk-FSO54CI4.mjs} +2 -2
  76. package/dist/esm/{chunk-EJQ2EYJ7.mjs → chunk-GBQU2OCK.mjs} +2 -2
  77. package/dist/esm/{chunk-ZNPEUH4I.mjs → chunk-GPWSPT44.mjs} +2 -2
  78. package/dist/esm/{chunk-TV7RXL3V.mjs → chunk-GQC73XWZ.mjs} +2 -2
  79. package/dist/esm/{chunk-QMYYNCC2.mjs → chunk-HGJMVOBH.mjs} +2 -2
  80. package/dist/esm/{chunk-J63BIFB7.mjs → chunk-HP6YVTTT.mjs} +2 -2
  81. package/dist/esm/{chunk-2DESIV2P.mjs → chunk-HXYZECGS.mjs} +2 -2
  82. package/dist/esm/{chunk-PAJXNH6J.mjs → chunk-IBDBKQMF.mjs} +2 -2
  83. package/dist/esm/{chunk-OR27VDOE.mjs → chunk-IPFITPKC.mjs} +2 -2
  84. package/dist/esm/{chunk-2BDKITTE.mjs → chunk-IT7YNITU.mjs} +2 -2
  85. package/dist/esm/chunk-J3DCBYOY.mjs +2 -0
  86. package/dist/esm/chunk-J3DCBYOY.mjs.map +1 -0
  87. package/dist/esm/{chunk-CCIY5VLR.mjs → chunk-JZOTXY77.mjs} +2 -2
  88. package/dist/esm/{chunk-YDSBZMZB.mjs → chunk-L5ZHZWHI.mjs} +2 -2
  89. package/dist/esm/{chunk-NTQLNAKS.mjs → chunk-LDQJ5S77.mjs} +2 -2
  90. package/dist/esm/{chunk-MMM5NTKW.mjs → chunk-LIT6V2A6.mjs} +2 -2
  91. package/dist/esm/{chunk-QNDR3S5U.mjs → chunk-MNTLX37G.mjs} +2 -2
  92. package/dist/esm/{chunk-3TIXNBXM.mjs → chunk-O7VXANBW.mjs} +2 -2
  93. package/dist/esm/{chunk-4AWM7GGV.mjs → chunk-QFVQSFBZ.mjs} +2 -2
  94. package/dist/esm/chunk-QSMVCD52.mjs +2 -0
  95. package/dist/esm/chunk-QSMVCD52.mjs.map +1 -0
  96. package/dist/esm/{chunk-VRO3J43Z.mjs → chunk-R2TZZVTU.mjs} +2 -2
  97. package/dist/esm/chunk-R2TZZVTU.mjs.map +1 -0
  98. package/dist/esm/{chunk-NZBZV7RP.mjs → chunk-S5ABQH5R.mjs} +2 -2
  99. package/dist/esm/{chunk-JV6JCXCH.mjs → chunk-SYRND55P.mjs} +2 -2
  100. package/dist/esm/{chunk-2Y7GVUQQ.mjs → chunk-U3S4AX6K.mjs} +2 -2
  101. package/dist/esm/{chunk-7SOLAI6Q.mjs → chunk-U5F4NL24.mjs} +2 -2
  102. package/dist/esm/{chunk-6OQBDCDK.mjs → chunk-UHZWZWJ7.mjs} +2 -2
  103. package/dist/esm/{chunk-GTXZNAYI.mjs → chunk-UVTJEMV4.mjs} +2 -2
  104. package/dist/esm/{chunk-OAX7LYUZ.mjs → chunk-VIX4BX35.mjs} +2 -2
  105. package/dist/esm/{chunk-5SGAX4VT.mjs → chunk-W63KIXLK.mjs} +2 -2
  106. package/dist/esm/{chunk-OJ6AF4YT.mjs → chunk-WIYDJE6F.mjs} +2 -2
  107. package/dist/esm/{chunk-TDDJZLWB.mjs → chunk-X3HGM2KT.mjs} +2 -2
  108. package/dist/esm/{chunk-EJA532W4.mjs → chunk-X4X5H6NC.mjs} +2 -2
  109. package/dist/esm/{chunk-CI64RKDE.mjs → chunk-YA4XTZNZ.mjs} +2 -2
  110. package/dist/esm/{chunk-LYOUEPDG.mjs → chunk-YD5IB4TH.mjs} +2 -2
  111. package/dist/esm/chunk-YD5IB4TH.mjs.map +1 -0
  112. package/dist/esm/chunk-YTQVMLFD.mjs +2 -0
  113. package/dist/esm/chunk-YTQVMLFD.mjs.map +1 -0
  114. package/dist/esm/{chunk-IPI3VB62.mjs → chunk-ZIDLP5MI.mjs} +2 -2
  115. package/dist/esm/{chunk-66G6MKI6.mjs → chunk-ZV5MKFV7.mjs} +2 -2
  116. package/dist/esm/cli/index.mjs +1 -1
  117. package/dist/esm/cli/localNode.mjs +1 -1
  118. package/dist/esm/client/core.mjs +1 -1
  119. package/dist/esm/client/get.mjs +1 -1
  120. package/dist/esm/client/index.mjs +1 -1
  121. package/dist/esm/client/post.mjs +1 -1
  122. package/dist/esm/core/crypto/cryptoHashable.mjs +2 -0
  123. package/dist/esm/core/crypto/index.d.mts +3 -1
  124. package/dist/esm/core/crypto/index.mjs +1 -1
  125. package/dist/esm/core/crypto/keyless.d.mts +17 -4
  126. package/dist/esm/core/crypto/keyless.mjs +1 -1
  127. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  128. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  129. package/dist/esm/core/index.d.mts +3 -1
  130. package/dist/esm/core/index.mjs +1 -1
  131. package/dist/esm/index.d.mts +4 -4
  132. package/dist/esm/index.mjs +1 -1
  133. package/dist/esm/internal/account.mjs +1 -1
  134. package/dist/esm/internal/ans.mjs +1 -1
  135. package/dist/esm/internal/coin.mjs +1 -1
  136. package/dist/esm/internal/digitalAsset.mjs +1 -1
  137. package/dist/esm/internal/event.mjs +1 -1
  138. package/dist/esm/internal/faucet.mjs +1 -1
  139. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  140. package/dist/esm/internal/general.mjs +1 -1
  141. package/dist/esm/internal/keyless.d.mts +1 -1
  142. package/dist/esm/internal/keyless.mjs +1 -1
  143. package/dist/esm/internal/staking.mjs +1 -1
  144. package/dist/esm/internal/table.mjs +1 -1
  145. package/dist/esm/internal/transaction.mjs +1 -1
  146. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  147. package/dist/esm/internal/view.mjs +1 -1
  148. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  149. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  150. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  151. package/dist/esm/transactions/index.d.mts +1 -1
  152. package/dist/esm/transactions/index.mjs +1 -1
  153. package/dist/esm/transactions/instances/index.mjs +1 -1
  154. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  155. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  156. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  157. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  158. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  159. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  160. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  161. package/dist/esm/transactions/management/index.mjs +1 -1
  162. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  163. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  164. package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
  165. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  166. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  167. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +15 -3
  168. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  169. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  170. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  171. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  172. package/dist/esm/utils/helpers.d.mts +2 -2
  173. package/dist/esm/utils/helpers.mjs +1 -1
  174. package/dist/esm/utils/index.mjs +1 -1
  175. package/dist/esm/version.d.mts +1 -1
  176. package/dist/esm/version.mjs +1 -1
  177. package/package.json +2 -2
  178. package/src/account/EphemeralKeyPair.ts +12 -11
  179. package/src/account/KeylessAccount.ts +1 -5
  180. package/src/api/keyless.ts +7 -2
  181. package/src/core/crypto/keyless.ts +83 -26
  182. package/src/internal/keyless.ts +13 -86
  183. package/src/transactions/management/accountSequenceNumber.ts +5 -8
  184. package/src/transactions/transactionBuilder/signingMessage.ts +16 -0
  185. package/src/utils/helpers.ts +1 -9
  186. package/src/version.ts +1 -1
  187. package/dist/common/chunk-HPZUSDYP.js +0 -2
  188. package/dist/common/chunk-HPZUSDYP.js.map +0 -1
  189. package/dist/esm/chunk-572AE4D7.mjs +0 -2
  190. package/dist/esm/chunk-572AE4D7.mjs.map +0 -1
  191. package/dist/esm/chunk-7FUZE7F4.mjs +0 -2
  192. package/dist/esm/chunk-7FUZE7F4.mjs.map +0 -1
  193. package/dist/esm/chunk-7GU3E2FJ.mjs +0 -2
  194. package/dist/esm/chunk-7GU3E2FJ.mjs.map +0 -1
  195. package/dist/esm/chunk-F7XWXQHU.mjs +0 -2
  196. package/dist/esm/chunk-KGHBTSDR.mjs +0 -2
  197. package/dist/esm/chunk-KGHBTSDR.mjs.map +0 -1
  198. package/dist/esm/chunk-LYOUEPDG.mjs.map +0 -1
  199. package/dist/esm/chunk-QHB5A5YP.mjs +0 -2
  200. package/dist/esm/chunk-QHB5A5YP.mjs.map +0 -1
  201. package/dist/esm/chunk-UKKHWC4Y.mjs +0 -2
  202. package/dist/esm/chunk-UKKHWC4Y.mjs.map +0 -1
  203. package/dist/esm/chunk-VRO3J43Z.mjs.map +0 -1
  204. package/dist/esm/chunk-WT5HOIK6.mjs +0 -2
  205. package/dist/esm/chunk-WT5HOIK6.mjs.map +0 -1
  206. package/dist/esm/core/crypto/cryptoHasher.mjs +0 -2
  207. /package/dist/esm/{chunk-2SJENNM4.mjs.map → chunk-2G4IGSGM.mjs.map} +0 -0
  208. /package/dist/esm/{chunk-TEGJAM44.mjs.map → chunk-3SACE4I2.mjs.map} +0 -0
  209. /package/dist/esm/{chunk-O3BRX56F.mjs.map → chunk-4CUDBBTC.mjs.map} +0 -0
  210. /package/dist/esm/{chunk-JBX3JBIW.mjs.map → chunk-5WFKJO5L.mjs.map} +0 -0
  211. /package/dist/esm/{chunk-AXR47GFL.mjs.map → chunk-64CUEMFI.mjs.map} +0 -0
  212. /package/dist/esm/{chunk-B74ZAMWR.mjs.map → chunk-64VPA7CM.mjs.map} +0 -0
  213. /package/dist/esm/{chunk-MPTKOK27.mjs.map → chunk-7G3RSOWE.mjs.map} +0 -0
  214. /package/dist/esm/{chunk-ARHEUGVT.mjs.map → chunk-7M4C4OZN.mjs.map} +0 -0
  215. /package/dist/esm/{chunk-AEWSL7BS.mjs.map → chunk-7UKBRLGM.mjs.map} +0 -0
  216. /package/dist/esm/{chunk-ERPUZQVK.mjs.map → chunk-B2RYTKNN.mjs.map} +0 -0
  217. /package/dist/esm/{chunk-JEE2OXOZ.mjs.map → chunk-BLWJZXAD.mjs.map} +0 -0
  218. /package/dist/esm/{chunk-Z6FMMNAL.mjs.map → chunk-BT6IM25V.mjs.map} +0 -0
  219. /package/dist/esm/{chunk-X2VUS374.mjs.map → chunk-CPDSBH23.mjs.map} +0 -0
  220. /package/dist/esm/{chunk-LA67NWMV.mjs.map → chunk-DJPYZIJY.mjs.map} +0 -0
  221. /package/dist/esm/{chunk-UBON2G6Y.mjs.map → chunk-FNFQA7NS.mjs.map} +0 -0
  222. /package/dist/esm/{chunk-E62NBNHE.mjs.map → chunk-FSO54CI4.mjs.map} +0 -0
  223. /package/dist/esm/{chunk-EJQ2EYJ7.mjs.map → chunk-GBQU2OCK.mjs.map} +0 -0
  224. /package/dist/esm/{chunk-ZNPEUH4I.mjs.map → chunk-GPWSPT44.mjs.map} +0 -0
  225. /package/dist/esm/{chunk-TV7RXL3V.mjs.map → chunk-GQC73XWZ.mjs.map} +0 -0
  226. /package/dist/esm/{chunk-QMYYNCC2.mjs.map → chunk-HGJMVOBH.mjs.map} +0 -0
  227. /package/dist/esm/{chunk-J63BIFB7.mjs.map → chunk-HP6YVTTT.mjs.map} +0 -0
  228. /package/dist/esm/{chunk-2DESIV2P.mjs.map → chunk-HXYZECGS.mjs.map} +0 -0
  229. /package/dist/esm/{chunk-PAJXNH6J.mjs.map → chunk-IBDBKQMF.mjs.map} +0 -0
  230. /package/dist/esm/{chunk-OR27VDOE.mjs.map → chunk-IPFITPKC.mjs.map} +0 -0
  231. /package/dist/esm/{chunk-2BDKITTE.mjs.map → chunk-IT7YNITU.mjs.map} +0 -0
  232. /package/dist/esm/{chunk-CCIY5VLR.mjs.map → chunk-JZOTXY77.mjs.map} +0 -0
  233. /package/dist/esm/{chunk-YDSBZMZB.mjs.map → chunk-L5ZHZWHI.mjs.map} +0 -0
  234. /package/dist/esm/{chunk-NTQLNAKS.mjs.map → chunk-LDQJ5S77.mjs.map} +0 -0
  235. /package/dist/esm/{chunk-MMM5NTKW.mjs.map → chunk-LIT6V2A6.mjs.map} +0 -0
  236. /package/dist/esm/{chunk-QNDR3S5U.mjs.map → chunk-MNTLX37G.mjs.map} +0 -0
  237. /package/dist/esm/{chunk-3TIXNBXM.mjs.map → chunk-O7VXANBW.mjs.map} +0 -0
  238. /package/dist/esm/{chunk-4AWM7GGV.mjs.map → chunk-QFVQSFBZ.mjs.map} +0 -0
  239. /package/dist/esm/{chunk-NZBZV7RP.mjs.map → chunk-S5ABQH5R.mjs.map} +0 -0
  240. /package/dist/esm/{chunk-JV6JCXCH.mjs.map → chunk-SYRND55P.mjs.map} +0 -0
  241. /package/dist/esm/{chunk-2Y7GVUQQ.mjs.map → chunk-U3S4AX6K.mjs.map} +0 -0
  242. /package/dist/esm/{chunk-7SOLAI6Q.mjs.map → chunk-U5F4NL24.mjs.map} +0 -0
  243. /package/dist/esm/{chunk-6OQBDCDK.mjs.map → chunk-UHZWZWJ7.mjs.map} +0 -0
  244. /package/dist/esm/{chunk-GTXZNAYI.mjs.map → chunk-UVTJEMV4.mjs.map} +0 -0
  245. /package/dist/esm/{chunk-OAX7LYUZ.mjs.map → chunk-VIX4BX35.mjs.map} +0 -0
  246. /package/dist/esm/{chunk-5SGAX4VT.mjs.map → chunk-W63KIXLK.mjs.map} +0 -0
  247. /package/dist/esm/{chunk-OJ6AF4YT.mjs.map → chunk-WIYDJE6F.mjs.map} +0 -0
  248. /package/dist/esm/{chunk-TDDJZLWB.mjs.map → chunk-X3HGM2KT.mjs.map} +0 -0
  249. /package/dist/esm/{chunk-EJA532W4.mjs.map → chunk-X4X5H6NC.mjs.map} +0 -0
  250. /package/dist/esm/{chunk-CI64RKDE.mjs.map → chunk-YA4XTZNZ.mjs.map} +0 -0
  251. /package/dist/esm/{chunk-IPI3VB62.mjs.map → chunk-ZIDLP5MI.mjs.map} +0 -0
  252. /package/dist/esm/{chunk-66G6MKI6.mjs.map → chunk-ZV5MKFV7.mjs.map} +0 -0
  253. /package/dist/esm/core/crypto/{cryptoHasher.d.mts → cryptoHashable.d.mts} +0 -0
  254. /package/dist/esm/core/crypto/{cryptoHasher.mjs.map → cryptoHashable.mjs.map} +0 -0
  255. /package/src/core/crypto/{cryptoHasher.ts → cryptoHashable.ts} +0 -0
@@ -26,10 +26,7 @@
26
26
  import { AptosConfig } from "../../api/aptosConfig";
27
27
  import { Account } from "../../account";
28
28
  import { getInfo } from "../../internal/account";
29
- import { sleep } from "../../utils/helpers";
30
-
31
- // returns `now` time in seconds
32
- const now = () => Math.floor(Date.now() / 1000);
29
+ import { nowInSeconds, sleep } from "../../utils/helpers";
33
30
 
34
31
  export class AccountSequenceNumber {
35
32
  readonly aptosConfig: AptosConfig;
@@ -96,10 +93,10 @@ export class AccountSequenceNumber {
96
93
  if (this.currentNumber! - this.lastUncommintedNumber! >= this.maximumInFlight) {
97
94
  await this.update();
98
95
 
99
- const startTime = now();
96
+ const startTime = nowInSeconds();
100
97
  while (this.currentNumber! - this.lastUncommintedNumber! >= this.maximumInFlight) {
101
98
  await sleep(this.sleepTime);
102
- if (now() - startTime > this.maxWaitTime) {
99
+ if (nowInSeconds() - startTime > this.maxWaitTime) {
103
100
  /* eslint-disable no-console */
104
101
  console.warn(
105
102
  `Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`,
@@ -164,9 +161,9 @@ export class AccountSequenceNumber {
164
161
 
165
162
  try {
166
163
  await this.update();
167
- const startTime = now();
164
+ const startTime = nowInSeconds();
168
165
  while (this.lastUncommintedNumber !== this.currentNumber) {
169
- if (now() - startTime > this.maxWaitTime) {
166
+ if (nowInSeconds() - startTime > this.maxWaitTime) {
170
167
  /* eslint-disable no-console */
171
168
  console.warn(
172
169
  `Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`,
@@ -8,6 +8,7 @@ import { sha3_256 as sha3Hash } from "@noble/hashes/sha3";
8
8
  import { RAW_TRANSACTION_SALT, RAW_TRANSACTION_WITH_DATA_SALT } from "../../utils/const";
9
9
  import { FeePayerRawTransaction, MultiAgentRawTransaction } from "../instances";
10
10
  import { AnyRawTransaction, AnyRawTransactionInstance } from "../types";
11
+ import { Serializable } from "../../bcs/serializer";
11
12
 
12
13
  /**
13
14
  * Derive the raw transaction type - FeePayerRawTransaction or MultiAgentRawTransaction or RawTransaction
@@ -59,6 +60,21 @@ export function generateSigningMessage(bytes: Uint8Array, domainSeparator: strin
59
60
  return mergedArray;
60
61
  }
61
62
 
63
+ /**
64
+ * @deprected
65
+ * Use CryptoHashable instead by having your class implement it and call hash() to get the signing message.
66
+ *
67
+ * Generates the 'signing message' form of a serilizable value. It bcs serializes the value and uses the name of
68
+ * its constructor as the domain separator.
69
+ *
70
+ * @param serializable An object that has a bcs serialized form
71
+ *
72
+ * @returns The Uint8Array of the signing message
73
+ */
74
+ export function generateSigningMessageForSerializable(serializable: Serializable): Uint8Array {
75
+ return generateSigningMessage(serializable.bcsToBytes(), `APTOS::${serializable.constructor.name}`);
76
+ }
77
+
62
78
  /**
63
79
  * Generates the 'signing message' form of a transaction. It derives the type of transaction and
64
80
  * applies the appropriate domain separator based on if there is extra data such as a fee payer or
@@ -13,9 +13,7 @@ export async function sleep(timeMs: number): Promise<null> {
13
13
  });
14
14
  }
15
15
 
16
- export function currentTimeInSeconds(): number {
17
- return Math.floor(new Date().getTime() / 1000);
18
- }
16
+ export const nowInSeconds = () => Math.floor(Date.now() / 1000);
19
17
 
20
18
  export function floorToWholeHour(timestampInSeconds: number): number {
21
19
  const date = new Date(timestampInSeconds * 1000);
@@ -26,12 +24,6 @@ export function floorToWholeHour(timestampInSeconds: number): number {
26
24
  return Math.floor(date.getTime() / 1000);
27
25
  }
28
26
 
29
- export function ceilingToWholeHour(timestampInSeconds: number): number {
30
- const date = new Date(timestampInSeconds * 1000);
31
- date.setHours(date.getHours() + 1);
32
- return floorToWholeHour(date.getTime() / 1000)
33
- }
34
-
35
27
  export function base64UrlDecode(base64Url: string): string {
36
28
  // Replace base64url-specific characters
37
29
  const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
package/src/version.ts CHANGED
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * hardcoded for now, we would want to have it injected dynamically
8
8
  */
9
- export const VERSION = "1.16.0-zeta.3";
9
+ export const VERSION = "1.17.0";
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var i=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=(n,e,r,o)=>{for(var t=o>1?void 0:o?u(e,r):e,s=n.length-1,c;s>=0;s--)(c=n[s])&&(t=(o?c(e,r,t):c(t))||t);return o&&t&&i(e,r,t),t};var _jsbase64 = require('js-base64');async function g(n){return new Promise(e=>{setTimeout(e,n)})}function p(){return Math.floor(new Date().getTime()/1e3)}function f(n){let e=new Date(n*1e3);return e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),Math.floor(e.getTime()/1e3)}function b(n){let e=n.replace(/-/g,"+").replace(/_/g,"/"),r=e+"==".substring(0,(3-e.length%3)%3);return _jsbase64.decode.call(void 0, r)}exports.a = l; exports.b = g; exports.c = p; exports.d = f; exports.e = b;
2
- //# sourceMappingURL=chunk-HPZUSDYP.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/helpers.ts"],"names":["decode","sleep","timeMs","resolve","currentTimeInSeconds","floorToWholeHour","timestampInSeconds","date","base64UrlDecode","base64Url","base64","paddedBase64"],"mappings":"wMAGA,OAAS,UAAAA,MAAc,YAMvB,eAAsBC,EAAMC,EAA+B,CACzD,OAAO,IAAI,QAASC,GAAY,CAC9B,WAAWA,EAASD,CAAM,CAC5B,CAAC,CACH,CAEO,SAASE,GAA+B,CAC7C,OAAO,KAAK,MAAM,IAAI,KAAK,EAAE,QAAQ,EAAI,GAAI,CAC/C,CAEO,SAASC,EAAiBC,EAAoC,CACnE,IAAMC,EAAO,IAAI,KAAKD,EAAqB,GAAI,EAE/C,OAAAC,EAAK,WAAW,CAAC,EACjBA,EAAK,WAAW,CAAC,EACjBA,EAAK,gBAAgB,CAAC,EACf,KAAK,MAAMA,EAAK,QAAQ,EAAI,GAAI,CACzC,CAEO,SAASC,EAAgBC,EAA2B,CAEzD,IAAMC,EAASD,EAAU,QAAQ,KAAM,GAAG,EAAE,QAAQ,KAAM,GAAG,EAEvDE,EAAeD,EAAS,KAAK,UAAU,GAAI,EAAKA,EAAO,OAAS,GAAM,CAAC,EAE7E,OADsBV,EAAOW,CAAY,CAE3C","sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { decode } from \"js-base64\";\n\n/**\n * Sleep the current thread for the given amount of time\n * @param timeMs time in milliseconds to sleep\n */\nexport async function sleep(timeMs: number): Promise<null> {\n return new Promise((resolve) => {\n setTimeout(resolve, timeMs);\n });\n}\n\nexport function currentTimeInSeconds(): number {\n return Math.floor(new Date().getTime() / 1000);\n}\n\nexport function floorToWholeHour(timestampInSeconds: number): number {\n const date = new Date(timestampInSeconds * 1000);\n // Reset minutes and seconds to zero\n date.setMinutes(0);\n date.setSeconds(0);\n date.setMilliseconds(0);\n return Math.floor(date.getTime() / 1000);\n}\n\nexport function base64UrlDecode(base64Url: string): string {\n // Replace base64url-specific characters\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n // Pad the string with '=' characters if needed\n const paddedBase64 = base64 + \"==\".substring(0, (3 - (base64.length % 3)) % 3);\n const decodedString = decode(paddedBase64);\n return decodedString;\n}\n"]}
@@ -1,2 +0,0 @@
1
- import{b,c as K}from"./chunk-QHB5A5YP.mjs";import{a as d}from"./chunk-UKKHWC4Y.mjs";import{a as l,b as y}from"./chunk-L5CPAOUM.mjs";import{b as u,c as h,e as m}from"./chunk-IVVWQKCF.mjs";import{b as a}from"./chunk-XVZBWW46.mjs";import{a as o}from"./chunk-3IFR6T3V.mjs";import{a as p}from"./chunk-UMLUOYFK.mjs";import{b as c}from"./chunk-AOCNYMMX.mjs";import{randomBytes as E}from"@noble/hashes/utils";var i=class i extends p{constructor(e){super();let{privateKey:r,expiryDateSecs:t,blinder:n}=e;this.privateKey=r,this.publicKey=new l(r.publicKey()),this.expiryDateSecs=t||K(b()+d),this.blinder=n!==void 0?c.fromHexInput(n).toUint8Array():S(),this.nonce=this.generateNonce()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let r=e.deserializeUleb128AsU32(),t;switch(r){case 0:t=a.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${r}`)}let n=e.deserializeU64(),x=e.deserializeFixedBytes(31);return new i({privateKey:t,expiryDateSecs:Number(n),blinder:x})}static fromBytes(e){return i.deserialize(new o(e))}static generate(e){let r;switch(e?.scheme){case 0:default:r=a.generate()}return new i({privateKey:r,expiryDateSecs:e?.expiryDateSecs})}generateNonce(){let e=u(this.publicKey.bcsToBytes(),93);return e.push(BigInt(this.expiryDateSecs)),e.push(h(this.blinder)),m(e).toString()}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new y(this.privateKey.sign(e))}};i.BLINDER_LENGTH=31;var s=i;function S(){return E(s.BLINDER_LENGTH)}export{s as a};
2
- //# sourceMappingURL=chunk-572AE4D7.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/account/EphemeralKeyPair.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { randomBytes } from \"@noble/hashes/utils\";\n\nimport {\n EPK_HORIZON_SECS,\n Ed25519PrivateKey,\n EphemeralPublicKey,\n EphemeralSignature,\n PrivateKey,\n} from \"../core/crypto\";\nimport { Hex } from \"../core/hex\";\nimport { bytesToBigIntLE, padAndPackBytesWithLen, poseidonHash } from \"../core/crypto/poseidon\";\nimport { EphemeralPublicKeyVariant, HexInput } from \"../types\";\nimport { Deserializer, Serializable, Serializer } from \"../bcs\";\nimport { currentTimeInSeconds, floorToWholeHour } from \"../utils/helpers\";\n\nexport class EphemeralKeyPair extends Serializable {\n static readonly BLINDER_LENGTH: number = 31;\n\n /**\n * A byte array of length BLINDER_LENGTH used to obfuscate the public key from the IdP.\n * Used in calculating the nonce passed to the IdP and as a secret witness in proof generation.\n */\n readonly blinder: Uint8Array;\n\n /**\n * A timestamp in seconds indicating when the ephemeral key pair is expired. After expiry, a new\n * EphemeralKeyPair must be generated and a new JWT needs to be created.\n */\n readonly expiryDateSecs: number;\n\n /**\n * The value passed to the IdP when the user authenticates. It comprises of a hash of the\n * ephermeral public key, expiry date, and blinder.\n */\n readonly nonce: string;\n\n /**\n * A private key used to sign transactions. This private key is not tied to any account on the chain as it\n * is ephemeral (not permanent) in nature.\n */\n private privateKey: PrivateKey;\n\n /**\n * A public key used to verify transactions. This public key is not tied to any account on the chain as it\n * is ephemeral (not permanent) in nature.\n */\n private publicKey: EphemeralPublicKey;\n\n constructor(args: { privateKey: PrivateKey; expiryDateSecs?: number; blinder?: HexInput }) {\n super();\n const { privateKey, expiryDateSecs, blinder } = args;\n this.privateKey = privateKey;\n this.publicKey = new EphemeralPublicKey(privateKey.publicKey());\n // We set the expiry date to be the nearest floored hour\n this.expiryDateSecs = expiryDateSecs || floorToWholeHour(currentTimeInSeconds() + EPK_HORIZON_SECS);\n // Generate the blinder if not provided\n this.blinder = blinder !== undefined ? Hex.fromHexInput(blinder).toUint8Array() : generateBlinder();\n // Calculate the nonce\n this.nonce = this.generateNonce();\n }\n\n /**\n * Returns the public key of the key pair.\n * @return EphemeralPublicKey\n */\n getPublicKey(): EphemeralPublicKey {\n return this.publicKey;\n }\n\n /**\n * Returns the public key of the key pair.\n * @return boolean\n */\n isExpired(): boolean {\n const currentTimeSecs: number = Math.floor(Date.now() / 1000);\n return currentTimeSecs > this.expiryDateSecs;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.publicKey.variant);\n serializer.serializeBytes(this.privateKey.toUint8Array());\n serializer.serializeU64(this.expiryDateSecs);\n serializer.serializeFixedBytes(this.blinder);\n }\n\n static deserialize(deserializer: Deserializer): EphemeralKeyPair {\n const variantIndex = deserializer.deserializeUleb128AsU32();\n let privateKey: PrivateKey;\n switch (variantIndex) {\n case EphemeralPublicKeyVariant.Ed25519:\n privateKey = Ed25519PrivateKey.deserialize(deserializer);\n break;\n default:\n throw new Error(`Unknown variant index for EphemeralPublicKey: ${variantIndex}`);\n }\n const expiryDateSecs = deserializer.deserializeU64();\n const blinder = deserializer.deserializeFixedBytes(31);\n return new EphemeralKeyPair({ privateKey, expiryDateSecs: Number(expiryDateSecs), blinder });\n }\n\n static fromBytes(bytes: Uint8Array): EphemeralKeyPair {\n return EphemeralKeyPair.deserialize(new Deserializer(bytes));\n }\n\n /**\n * Returns the public key of the key pair.\n * @param scheme the type of keypair to use for the EphemeralKeyPair. Only Ed25519 supported for now.\n * @param expiryDateSecs the date of expiry.\n * @return boolean\n */\n static generate(args?: { scheme: EphemeralPublicKeyVariant; expiryDateSecs?: number }): EphemeralKeyPair {\n let privateKey: PrivateKey;\n\n switch (args?.scheme) {\n case EphemeralPublicKeyVariant.Ed25519:\n default:\n privateKey = Ed25519PrivateKey.generate();\n }\n\n return new EphemeralKeyPair({ privateKey, expiryDateSecs: args?.expiryDateSecs });\n }\n\n /**\n * From the ephemeral public key, expiry timestamp, and blinder, calculate the nonce to be used at authentication via OIDC.\n * @returns string\n */\n private generateNonce(): string {\n const fields = padAndPackBytesWithLen(this.publicKey.bcsToBytes(), 93);\n fields.push(BigInt(this.expiryDateSecs));\n fields.push(bytesToBigIntLE(this.blinder));\n const nonceHash = poseidonHash(fields);\n return nonceHash.toString();\n }\n\n /**\n * Sign the given message with the private key.\n * @param data in HexInput format\n * @returns EphemeralSignature\n */\n sign(data: HexInput): EphemeralSignature {\n if (this.isExpired()) {\n throw new Error(\"EphemeralKeyPair has expired\");\n }\n return new EphemeralSignature(this.privateKey.sign(data));\n }\n}\n\n/**\n * Generates a random byte array of length EphemeralKeyPair.BLINDER_LENGTH\n * @returns Uint8Array\n */\nfunction generateBlinder(): Uint8Array {\n return randomBytes(EphemeralKeyPair.BLINDER_LENGTH);\n}\n"],"mappings":"+VAGA,OAAS,eAAAA,MAAmB,sBAerB,IAAMC,EAAN,MAAMA,UAAyBC,CAAa,CAiCjD,YAAYC,EAA+E,CACzF,MAAM,EACN,GAAM,CAAE,WAAAC,EAAY,eAAAC,EAAgB,QAAAC,CAAQ,EAAIH,EAChD,KAAK,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G,EAAE,EACrE,OAAAD,EAAO,KAAK,OAAO,KAAK,cAAc,CAAC,EACvCA,EAAO,KAAKE,EAAgB,KAAK,OAAO,CAAC,EACvBC,EAAaH,CAAM,EACpB,SAAS,CAC5B,CAOA,KAAKI,EAAoC,CACvC,GAAI,KAAK,UAAU,EACjB,MAAM,IAAI,MAAM,8BAA8B,EAEhD,OAAO,IAAIC,EAAmB,KAAK,WAAW,KAAKD,CAAI,CAAC,CAC1D,CACF,EAlIatB,EACK,eAAyB,GADpC,IAAMwB,EAANxB,EAwIP,SAASW,GAA8B,CACrC,OAAOc,EAAYD,EAAiB,cAAc,CACpD","names":["randomBytes","_EphemeralKeyPair","Serializable","args","privateKey","expiryDateSecs","blinder","EphemeralPublicKey","floorToWholeHour","currentTimeInSeconds","EPK_HORIZON_SECS","Hex","generateBlinder","serializer","deserializer","variantIndex","Ed25519PrivateKey","bytes","Deserializer","fields","padAndPackBytesWithLen","bytesToBigIntLE","poseidonHash","data","EphemeralSignature","EphemeralKeyPair","randomBytes"]}
@@ -1,2 +0,0 @@
1
- import{a as v}from"./chunk-LYOUEPDG.mjs";import{a as x}from"./chunk-572AE4D7.mjs";import{d as b}from"./chunk-QHB5A5YP.mjs";import{a as E}from"./chunk-KGHBTSDR.mjs";import{d as y}from"./chunk-J63BIFB7.mjs";import{a as d,b as f}from"./chunk-O3BRX56F.mjs";import{i as S,j as F,k as A,n as u}from"./chunk-UKKHWC4Y.mjs";import{b as K}from"./chunk-F3ZVWLDH.mjs";import{a as g}from"./chunk-3IFR6T3V.mjs";import{a as P}from"./chunk-UMLUOYFK.mjs";import{b as w}from"./chunk-AOCNYMMX.mjs";import{jwtDecode as H}from"jwt-decode";import Z from"eventemitter3";var ee={"https://accounts.google.com":"https://www.googleapis.com/oauth2/v3/certs"},s=class s extends P{constructor(e){super();let{address:r,ephemeralKeyPair:t,uidKey:i,uidVal:a,aud:n,pepper:h,proofOrFetcher:o,proofFetchCallback:c,jwt:l}=e;if(this.ephemeralKeyPair=t,this.publicKey=S.create(e),this.accountAddress=r?K.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=i,this.uidVal=a,this.aud=n,this.jwt=l,this.emitter=new Z,this.proofOrPromise=o,o instanceof u)this.proof=o;else{if(c===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async z=>{await c(z),this.emitter.removeAllListeners()}),this.init(o)}this.signingScheme=2;let p=w.fromHexInput(h).toUint8Array();if(p.length!==s.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${s.PEPPER_LENGTH}`);this.pepper=p,this.isJwtValid=!0}async init(e){try{this.proof=await e,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(e){if(e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),this.proof===void 0)throw new Error("Connot serialize - proof undefined");this.proof.serialize(e)}static deserialize(e){let r=e.deserializeStr(),t=e.deserializeStr(),i=e.deserializeFixedBytes(31),a=x.deserialize(e),n=u.deserialize(e);return s.create({proof:n,pepper:i,uidKey:t,jwt:r,ephemeralKeyPair:a})}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(e){let r=new f(this.sign(e)),t=new d(this.publicKey);return new y(t,r)}signTransactionWithAuthenticator(e){let r=new f(this.signTransaction(e)),t=new d(this.publicKey);return new y(t,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}sign(e){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw new Error("EphemeralKeyPair is expired");if(this.proof===void 0)throw new Error("Proof not defined");let t=this.ephemeralKeyPair.getPublicKey(),i=this.ephemeralKeyPair.sign(e);return new F({jwtHeader:b(this.jwt.split(".")[0]),ephemeralCertificate:new A(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:t,ephemeralSignature:i})}signTransaction(e){if(this.proof===void 0)throw new Error("Proof not found");let r=E(e),i=new m(r,this.proof.proof).hash();return this.sign(i)}verifySignature(e){throw new Error("Not implemented")}static fromBytes(e){return s.deserialize(new g(e))}static create(e){let{proof:r,jwt:t,ephemeralKeyPair:i,pepper:a,uidKey:n="sub",proofFetchCallback:h}=e,o=H(t),c=o.iss;if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let l=o.aud,p=o[n];return new s({proofOrFetcher:r,ephemeralKeyPair:i,iss:c,uidKey:n,uidVal:p,aud:l,pepper:a,jwt:t,proofFetchCallback:h})}};s.PEPPER_LENGTH=31;var T=s,m=class extends v{constructor(e,r){super();this.transaction=e,this.proof=r,this.domainSeparator="APTOS::TransactionAndProof"}serialize(e){e.serializeFixedBytes(this.transaction.bcsToBytes()),e.serializeOption(this.proof)}};export{ee as a,T as b,m as c};
2
- //# sourceMappingURL=chunk-7FUZE7F4.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/account/KeylessAccount.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { JwtPayload, jwtDecode } from \"jwt-decode\";\nimport EventEmitter from \"eventemitter3\";\nimport { EphemeralCertificateVariant, HexInput, SigningScheme } from \"../types\";\nimport { AccountAddress } from \"../core/accountAddress\";\nimport {\n AnyPublicKey,\n AnySignature,\n KeylessPublicKey,\n KeylessSignature,\n EphemeralCertificate,\n Signature,\n ZeroKnowledgeSig,\n ZkProof,\n} from \"../core/crypto\";\n\nimport { Account } from \"./Account\";\nimport { EphemeralKeyPair } from \"./EphemeralKeyPair\";\nimport { Hex } from \"../core/hex\";\nimport { AccountAuthenticatorSingleKey } from \"../transactions/authenticator/account\";\nimport { Deserializer, Serializable, Serializer } from \"../bcs\";\nimport { deriveTransactionType } from \"../transactions/transactionBuilder/signingMessage\";\nimport { AnyRawTransaction, AnyRawTransactionInstance } from \"../transactions/types\";\nimport { AptsoDomainSeparator, CryptoHashable } from \"../core/crypto/cryptoHasher\";\nimport { base64UrlDecode } from \"../utils/helpers\";\n\nexport const IssuerToJwkEndpoint: Record<string, string> = {\n \"https://accounts.google.com\": \"https://www.googleapis.com/oauth2/v3/certs\",\n};\n\n/**\n * Account implementation for the Keyless authentication scheme.\n *\n * Used to represent a Keyless based account and sign transactions with it.\n *\n * Use KeylessAccount.fromJWTAndProof to instantiate a KeylessAccount with a JWT, proof and EphemeralKeyPair.\n *\n * When the proof expires or the JWT becomes invalid, the KeylessAccount must be instantiated again with a new JWT,\n * EphemeralKeyPair, and corresponding proof.\n */\nexport class KeylessAccount extends Serializable implements Account {\n static readonly PEPPER_LENGTH: number = 31;\n\n /**\n * The KeylessPublicKey associated with the account\n */\n readonly publicKey: KeylessPublicKey;\n\n /**\n * The EphemeralKeyPair used to generate sign.\n */\n readonly ephemeralKeyPair: EphemeralKeyPair;\n\n /**\n * The claim on the JWT to identify a user. This is typically 'sub' or 'email'.\n */\n readonly uidKey: string;\n\n /**\n * The value of the uidKey claim on the JWT. This intended to be a stable user identifier.\n */\n readonly uidVal: string;\n\n /**\n * The value of the 'aud' claim on the JWT, also known as client ID. This is the identifier for the dApp's\n * OIDC registration with the identity provider.\n */\n readonly aud: string;\n\n /**\n * A value contains 31 bytes of entropy that preserves privacy of the account. Typically fetched from a pepper provider.\n */\n readonly pepper: Uint8Array;\n\n /**\n * Account address associated with the account\n */\n readonly accountAddress: AccountAddress;\n\n /**\n * The zero knowledge signature (if ready) which contains the proof used to validate the EphemeralKeyPair.\n */\n proof: ZeroKnowledgeSig | undefined;\n\n /**\n * The proof of the EphemeralKeyPair or a promise that provides the proof. This is used to allow for awaiting on\n * fetching the proof.\n */\n readonly proofOrPromise: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n\n /**\n * Signing scheme used to sign transactions\n */\n readonly signingScheme: SigningScheme;\n\n /**\n * The JWT token used to derive the account\n */\n private jwt: string;\n\n /**\n * A value that caches the JWT's validity. A JWT becomes invalid when it's corresponding JWK is rotated from the\n * identity provider's JWK keyset.\n */\n private isJwtValid: boolean;\n\n /**\n * An event emitter used to assist in handling asycronous proof fetching.\n */\n private readonly emitter: EventEmitter<ProofFetchEvents>;\n\n constructor(args: {\n address?: AccountAddress;\n ephemeralKeyPair: EphemeralKeyPair;\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n proofOrFetcher: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n proofFetchCallback?: ProofFetchCallback;\n jwt: string;\n }) {\n super();\n const { address, ephemeralKeyPair, uidKey, uidVal, aud, pepper, proofOrFetcher, proofFetchCallback, jwt } = args;\n this.ephemeralKeyPair = ephemeralKeyPair;\n this.publicKey = KeylessPublicKey.create(args);\n this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();\n this.uidKey = uidKey;\n this.uidVal = uidVal;\n this.aud = aud;\n this.jwt = jwt;\n this.emitter = new EventEmitter<ProofFetchEvents>();\n this.proofOrPromise = proofOrFetcher;\n if (proofOrFetcher instanceof ZeroKnowledgeSig) {\n this.proof = proofOrFetcher;\n } else {\n if (proofFetchCallback === undefined) {\n throw new Error(\"Must provide callback for async proof fetch\");\n }\n this.emitter.on(\"proofFetchFinish\", async (status) => {\n await proofFetchCallback(status);\n this.emitter.removeAllListeners();\n });\n this.init(proofOrFetcher);\n }\n this.signingScheme = SigningScheme.SingleKey;\n const pepperBytes = Hex.fromHexInput(pepper).toUint8Array();\n if (pepperBytes.length !== KeylessAccount.PEPPER_LENGTH) {\n throw new Error(`Pepper length in bytes should be ${KeylessAccount.PEPPER_LENGTH}`);\n }\n this.pepper = pepperBytes;\n this.isJwtValid = true;\n }\n\n /**\n * This initializes the asyncronous proof fetch\n * @return\n */\n async init(promise: Promise<ZeroKnowledgeSig>) {\n try {\n this.proof = await promise;\n this.emitter.emit(\"proofFetchFinish\", { status: \"Success\" });\n } catch (error) {\n if (error instanceof Error) {\n this.emitter.emit(\"proofFetchFinish\", { status: \"Failed\", error: error.toString() });\n } else {\n this.emitter.emit(\"proofFetchFinish\", { status: \"Failed\", error: \"Unknown\" });\n }\n }\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.jwt);\n serializer.serializeStr(this.uidKey);\n serializer.serializeFixedBytes(this.pepper);\n this.ephemeralKeyPair.serialize(serializer);\n if (this.proof === undefined) {\n throw new Error(\"Connot serialize - proof undefined\");\n }\n this.proof.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): KeylessAccount {\n const jwt = deserializer.deserializeStr();\n const uidKey = deserializer.deserializeStr();\n const pepper = deserializer.deserializeFixedBytes(31);\n const ephemeralKeyPair = EphemeralKeyPair.deserialize(deserializer);\n const proof = ZeroKnowledgeSig.deserialize(deserializer);\n return KeylessAccount.create({\n proof,\n pepper,\n uidKey,\n jwt,\n ephemeralKeyPair,\n });\n }\n\n /**\n * Checks if the proof is expired. If so the account must be rederived with a new EphemeralKeyPair\n * and JWT token.\n * @return boolean\n */\n isExpired(): boolean {\n return this.ephemeralKeyPair.isExpired();\n }\n\n /**\n * Sign a message using Keyless.\n * @param message the message to sign, as binary input\n * @return the AccountAuthenticator containing the signature, together with the account's public key\n */\n signWithAuthenticator(message: HexInput): AccountAuthenticatorSingleKey {\n const signature = new AnySignature(this.sign(message));\n const publicKey = new AnyPublicKey(this.publicKey);\n return new AccountAuthenticatorSingleKey(publicKey, signature);\n }\n\n /**\n * Sign a transaction using Keyless.\n * @param transaction the raw transaction\n * @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key\n */\n signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorSingleKey {\n const signature = new AnySignature(this.signTransaction(transaction));\n const publicKey = new AnyPublicKey(this.publicKey);\n return new AccountAuthenticatorSingleKey(publicKey, signature);\n }\n\n /**\n * Waits for asyncronous proof fetching to finish.\n * @return\n */\n async waitForProofFetch() {\n if (this.proofOrPromise instanceof Promise) {\n await this.proofOrPromise;\n }\n }\n\n /**\n * Sign the given message using Keyless.\n * @param message in HexInput format\n * @returns Signature\n */\n sign(data: HexInput): KeylessSignature {\n const { expiryDateSecs } = this.ephemeralKeyPair;\n if (this.isExpired()) {\n throw new Error(\"EphemeralKeyPair is expired\");\n }\n if (this.proof === undefined) {\n throw new Error(\"Proof not defined\");\n }\n const ephemeralPublicKey = this.ephemeralKeyPair.getPublicKey();\n const ephemeralSignature = this.ephemeralKeyPair.sign(data);\n\n return new KeylessSignature({\n jwtHeader: base64UrlDecode(this.jwt.split(\".\")[0]),\n ephemeralCertificate: new EphemeralCertificate(this.proof, EphemeralCertificateVariant.ZkProof),\n expiryDateSecs,\n ephemeralPublicKey,\n ephemeralSignature,\n });\n }\n\n /**\n * Sign the given transaction with Keyless.\n * Signs the transaction and proof to guard against proof malleability.\n * @param transaction the transaction to be signed\n * @returns KeylessSignature\n */\n signTransaction(transaction: AnyRawTransaction): KeylessSignature {\n if (this.proof === undefined) {\n throw new Error(\"Proof not found\");\n }\n const raw = deriveTransactionType(transaction);\n const txnAndProof = new TransactionAndProof(raw, this.proof.proof);\n const signMess = txnAndProof.hash();\n return this.sign(signMess);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this\n verifySignature(args: { message: HexInput; signature: Signature }): boolean {\n throw new Error(\"Not implemented\");\n }\n\n static fromBytes(bytes: Uint8Array): KeylessAccount {\n return KeylessAccount.deserialize(new Deserializer(bytes));\n }\n\n static create(args: {\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper: HexInput;\n uidKey?: string;\n proofFetchCallback?: ProofFetchCallback;\n }): KeylessAccount {\n const { proof, jwt, ephemeralKeyPair, pepper, uidKey = \"sub\", proofFetchCallback } = args;\n\n const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);\n const iss = jwtPayload.iss!;\n if (typeof jwtPayload.aud !== \"string\") {\n throw new Error(\"aud was not found or an array of values\");\n }\n const aud = jwtPayload.aud!;\n const uidVal = jwtPayload[uidKey];\n return new KeylessAccount({\n proofOrFetcher: proof,\n ephemeralKeyPair,\n iss,\n uidKey,\n uidVal,\n aud,\n pepper,\n jwt,\n proofFetchCallback,\n });\n }\n}\n\n/**\n * A container class to hold a transaction and a proof. It implements CryptoHashable which is used to create\n * the signing message for Keyless transactions. We sign over the proof to ensure non-malleability.\n */\nexport class TransactionAndProof extends CryptoHashable {\n /**\n * The transaction to sign.\n */\n transaction: AnyRawTransactionInstance;\n\n /**\n * The zero knowledge proof used in signing the transaction.\n */\n proof?: ZkProof;\n\n /**\n * The domain separator prefix used when hashing.\n */\n domainSeparator: AptsoDomainSeparator;\n\n constructor(transaction: AnyRawTransactionInstance, proof?: ZkProof) {\n super();\n this.transaction = transaction;\n this.proof = proof;\n this.domainSeparator = \"APTOS::TransactionAndProof\";\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.transaction.bcsToBytes());\n serializer.serializeOption(this.proof);\n }\n}\n\nexport type ProofFetchSuccess = {\n status: \"Success\";\n};\n\nexport type ProofFetchFailure = {\n status: \"Failed\";\n error: string;\n};\n\nexport type ProofFetchStatus = ProofFetchSuccess | ProofFetchFailure;\n\nexport type ProofFetchCallback = (status: ProofFetchStatus) => Promise<void>;\n\nexport interface ProofFetchEvents {\n proofFetchFinish: (status: ProofFetchStatus) => void;\n}\n"],"mappings":"+dAGA,OAAqB,aAAAA,MAAiB,aACtC,OAAOC,MAAkB,gBAwBlB,IAAMC,GAA8C,CACzD,8BAA+B,4CACjC,EAYaC,EAAN,MAAMA,UAAuBC,CAAgC,CAuElE,YAAYC,EAWT,CACD,MAAM,EACN,GAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,OAAAC,EAAQ,OAAAC,EAAQ,IAAAC,EAAK,OAAAC,EAAQ,eAAAC,EAAgB,mBAAAC,EAAoB,IAAAC,CAAI,EAAIT,EAU5G,GATA,KAAK,iBAAmBE,EACxB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Key","uidVal","aud","pepper","proofOrFetcher","proofFetchCallback","jwt","KeylessPublicKey","AccountAddress","EventEmitter","ZeroKnowledgeSig","status","pepperBytes","Hex","promise","error","serializer","deserializer","EphemeralKeyPair","proof","message","signature","AnySignature","publicKey","AnyPublicKey","AccountAuthenticatorSingleKey","transaction","data","expiryDateSecs","ephemeralPublicKey","ephemeralSignature","KeylessSignature","base64UrlDecode","EphemeralCertificate","raw","deriveTransactionType","signMess","TransactionAndProof","bytes","Deserializer","jwtPayload","jwtDecode","iss","KeylessAccount","CryptoHashable"]}
@@ -1,2 +0,0 @@
1
- import{a as C}from"./chunk-AH44UPM4.mjs";import{b as u}from"./chunk-PAJXNH6J.mjs";import{e as K,f as x}from"./chunk-2SJENNM4.mjs";import{b as a}from"./chunk-7FUZE7F4.mjs";import{l as P,m as h,n as d,o as m}from"./chunk-UKKHWC4Y.mjs";import{b as l}from"./chunk-L5CPAOUM.mjs";import{b as g}from"./chunk-F3ZVWLDH.mjs";import{b as i}from"./chunk-AOCNYMMX.mjs";async function _(e){let{aptosConfig:r}=e;return C(async()=>{let o=await w(e),t=await b(e);return m.create(t,Number(o.max_exp_horizon_secs))},`keyless-configuration-${r.network}`,1e3*60*5)()}async function w(e){let{aptosConfig:r,options:o}=e,t="0x1::keyless_account::Configuration",{data:n}=await u({aptosConfig:r,originMethod:"getKeylessConfiguration",path:`accounts/${g.from("0x1").toString()}/resource/${t}`,params:{ledger_version:o?.ledgerVersion}});return n.data}async function b(e){let{aptosConfig:r,options:o}=e,t="0x1::keyless_account::Groth16VerificationKey",{data:n}=await u({aptosConfig:r,originMethod:"getGroth16VerificationKey",path:`accounts/${g.from("0x1").toString()}/resource/${t}`,params:{ledger_version:o?.ledgerVersion}});return n.data}async function R(e){let{aptosConfig:r,jwt:o,ephemeralKeyPair:t,uidKey:n="sub",derivationPath:s}=e,p={jwt_b64:o,epk:t.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:t.expiryDateSecs,epk_blinder:i.fromHexInput(t.blinder).toStringWithoutPrefix(),uid_key:n,derivation_path:s},{data:c}=await K({aptosConfig:r,path:"fetch",body:p,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return i.fromHexInput(c.pepper).toUint8Array()}async function k(e){let{aptosConfig:r,jwt:o,ephemeralKeyPair:t,pepper:n,uidKey:s="sub"}=e,{maxExpHorizonSecs:p}=await _({aptosConfig:r}),c={jwt_b64:o,epk:t.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:i.fromHexInput(t.blinder).toStringWithoutPrefix(),exp_date_secs:t.expiryDateSecs,exp_horizon_secs:p,pepper:i.fromHexInput(n).toStringWithoutPrefix(),uid_key:s},{data:y}=await x({aptosConfig:r,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),f=y.proof,A=new P({a:f.a,b:f.b,c:f.c});return new d({proof:new h(A,0),trainingWheelsSignature:l.fromHex(y.training_wheels_signature),expHorizonSecs:p})}async function M(e){let{proofFetchCallback:r}=e,{pepper:o}=e;if(o===void 0?o=await R(e):o=i.fromHexInput(o).toUint8Array(),o.length!==a.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${a.PEPPER_LENGTH} bytes`);let t=k({...e,pepper:o}),n=r?t:await t;return a.create({...e,proof:n,pepper:o,proofFetchCallback:r})}export{R as a,k as b,M as c};
2
- //# sourceMappingURL=chunk-7GU3E2FJ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/internal/keyless.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file contains the underlying implementations for exposed API surface in\n * the {@link api/keyless}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * keyless namespace and without having a dependency cycle error.\n */\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { getAptosFullNode, postAptosPepperService, postAptosProvingService } from \"../client\";\nimport {\n AccountAddress,\n EphemeralSignature,\n Groth16Zkp,\n Hex,\n KeylessConfiguration,\n ZeroKnowledgeSig,\n ZkProof,\n} from \"../core\";\nimport { HexInput, LedgerVersionArg, MoveResource, ZkpVariant } from \"../types\";\nimport { EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from \"../account\";\nimport {\n Groth16VerificationKeyResponse,\n KeylessConfigurationResponse,\n PepperFetchRequest,\n PepperFetchResponse,\n ProverRequest,\n ProverResponse,\n} from \"../types/keyless\";\nimport { memoizeAsync } from \"../utils/memoize\";\n\n/**\n * Gets the parameters of how Keyless Accounts are configured on chain including the verifying key and the max expiry horizon\n *\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n * @returns KeylessConfiguration\n */\nasync function getKeylessConfig(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<KeylessConfiguration> {\n const { aptosConfig } = args;\n return memoizeAsync(\n async () => {\n const config = await getKeylessConfigurationResource(args);\n const vk = await getGroth16VerificationKeyResource(args);\n return KeylessConfiguration.create(vk, Number(config.max_exp_horizon_secs));\n },\n `keyless-configuration-${aptosConfig.network}`,\n 1000 * 60 * 5, // 5 minutes\n )();\n}\n\n/**\n * Gets the KeylessConfiguration set on chain\n *\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n * @returns KeylessConfigurationResponse\n */\nasync function getKeylessConfigurationResource(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<KeylessConfigurationResponse> {\n const { aptosConfig, options } = args;\n const resourceType = \"0x1::keyless_account::Configuration\";\n const { data } = await getAptosFullNode<{}, MoveResource<KeylessConfigurationResponse>>({\n aptosConfig,\n originMethod: \"getKeylessConfiguration\",\n path: `accounts/${AccountAddress.from(\"0x1\").toString()}/resource/${resourceType}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n\n return data.data;\n}\n\n/**\n * Gets the Groth16VerificationKey set on chain\n *\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n * @returns Groth16VerificationKeyResponse\n */\nasync function getGroth16VerificationKeyResource(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<Groth16VerificationKeyResponse> {\n const { aptosConfig, options } = args;\n const resourceType = \"0x1::keyless_account::Groth16VerificationKey\";\n const { data } = await getAptosFullNode<{}, MoveResource<Groth16VerificationKeyResponse>>({\n aptosConfig,\n originMethod: \"getGroth16VerificationKey\",\n path: `accounts/${AccountAddress.from(\"0x1\").toString()}/resource/${resourceType}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n\n return data.data;\n}\n\nexport async function getPepper(args: {\n aptosConfig: AptosConfig;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n uidKey?: string;\n derivationPath?: string;\n}): Promise<Uint8Array> {\n const { aptosConfig, jwt, ephemeralKeyPair, uidKey = \"sub\", derivationPath } = args;\n\n const body = {\n jwt_b64: jwt,\n epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),\n exp_date_secs: ephemeralKeyPair.expiryDateSecs,\n epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),\n uid_key: uidKey,\n derivation_path: derivationPath,\n };\n const { data } = await postAptosPepperService<PepperFetchRequest, PepperFetchResponse>({\n aptosConfig,\n path: \"fetch\",\n body,\n originMethod: \"getPepper\",\n overrides: { WITH_CREDENTIALS: false },\n });\n return Hex.fromHexInput(data.pepper).toUint8Array();\n}\n\nexport async function getProof(args: {\n aptosConfig: AptosConfig;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper: HexInput;\n uidKey?: string;\n}): Promise<ZeroKnowledgeSig> {\n const { aptosConfig, jwt, ephemeralKeyPair, pepper, uidKey = \"sub\" } = args;\n const { maxExpHorizonSecs } = await getKeylessConfig({ aptosConfig });\n const json = {\n jwt_b64: jwt,\n epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),\n epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),\n exp_date_secs: ephemeralKeyPair.expiryDateSecs,\n exp_horizon_secs: maxExpHorizonSecs,\n pepper: Hex.fromHexInput(pepper).toStringWithoutPrefix(),\n uid_key: uidKey,\n };\n\n const { data } = await postAptosProvingService<ProverRequest, ProverResponse>({\n aptosConfig,\n path: \"prove\",\n body: json,\n originMethod: \"getProof\",\n overrides: { WITH_CREDENTIALS: false },\n });\n\n const proofPoints = data.proof;\n const groth16Zkp = new Groth16Zkp({\n a: proofPoints.a,\n b: proofPoints.b,\n c: proofPoints.c,\n });\n\n const signedProof = new ZeroKnowledgeSig({\n proof: new ZkProof(groth16Zkp, ZkpVariant.Groth16),\n trainingWheelsSignature: EphemeralSignature.fromHex(data.training_wheels_signature),\n expHorizonSecs: maxExpHorizonSecs,\n });\n return signedProof;\n}\n\nexport async function deriveKeylessAccount(args: {\n aptosConfig: AptosConfig;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n uidKey?: string;\n pepper?: HexInput;\n proofFetchCallback?: ProofFetchCallback;\n}): Promise<KeylessAccount> {\n const { proofFetchCallback } = args;\n let { pepper } = args;\n if (pepper === undefined) {\n pepper = await getPepper(args);\n } else {\n pepper = Hex.fromHexInput(pepper).toUint8Array();\n }\n\n if (pepper.length !== KeylessAccount.PEPPER_LENGTH) {\n throw new Error(`Pepper needs to be ${KeylessAccount.PEPPER_LENGTH} bytes`);\n }\n\n const proofPromise = getProof({ ...args, pepper });\n const proof = proofFetchCallback ? proofPromise : await proofPromise;\n\n const keylessAccount = KeylessAccount.create({ ...args, proof, pepper, proofFetchCallback });\n\n return keylessAccount;\n}\n"],"mappings":"oWAsCA,eAAeA,EAAiBC,EAGE,CAChC,GAAM,CAAE,YAAAC,CAAY,EAAID,EACxB,OAAOE,EACL,SAAY,CACV,IAAMC,EAAS,MAAMC,EAAgCJ,CAAI,EACnDK,EAAK,MAAMC,EAAkCN,CAAI,EACvD,OAAOO,EAAqB,OAAOF,EAAI,OAAOF,EAAO,oBAAoB,CAAC,CAC5E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GlC,EAAM,MAAAoC,EAAO,OAAAd,EAAQ,mBAAAW,CAAmB,CAAC,CAG7F","names":["getKeylessConfig","args","aptosConfig","memoizeAsync","config","getKeylessConfigurationResource","vk","getGroth16VerificationKeyResource","KeylessConfiguration","options","resourceType","data","getAptosFullNode","AccountAddress","getPepper","jwt","ephemeralKeyPair","uidKey","derivationPath","body","Hex","postAptosPepperService","getProof","pepper","maxExpHorizonSecs","json","postAptosProvingService","proofPoints","groth16Zkp","Groth16Zkp","ZeroKnowledgeSig","ZkProof","EphemeralSignature","deriveKeylessAccount","proofFetchCallback","KeylessAccount","proofPromise","proof"]}
@@ -1,2 +0,0 @@
1
- var t="1.16.0-zeta.3";export{t as a};
2
- //# sourceMappingURL=chunk-F7XWXQHU.mjs.map
@@ -1,2 +0,0 @@
1
- import{c as T,d}from"./chunk-472OGHMG.mjs";import{f as A,g as t}from"./chunk-YE5B2S5L.mjs";import{sha3_256 as y}from"@noble/hashes/sha3";function c(e){return e.feePayerAddress?new d(e.rawTransaction,e.secondarySignerAddresses??[],e.feePayerAddress):e.secondarySignerAddresses?new T(e.rawTransaction,e.secondarySignerAddresses):e.rawTransaction}function a(e,r){let i=y.create();if(!r.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${r}`);i.update(r);let n=i.digest(),o=e,s=new Uint8Array(n.length+o.length);return s.set(n),s.set(o,n.length),s}function u(e){let r=c(e);return e.feePayerAddress?a(r.bcsToBytes(),t):e.secondarySignerAddresses?a(r.bcsToBytes(),t):a(r.bcsToBytes(),A)}export{c as a,a as b,u as c};
2
- //# sourceMappingURL=chunk-KGHBTSDR.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/transactions/transactionBuilder/signingMessage.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file handles the generation of the signing message.\n */\nimport { sha3_256 as sha3Hash } from \"@noble/hashes/sha3\";\nimport { RAW_TRANSACTION_SALT, RAW_TRANSACTION_WITH_DATA_SALT } from \"../../utils/const\";\nimport { FeePayerRawTransaction, MultiAgentRawTransaction } from \"../instances\";\nimport { AnyRawTransaction, AnyRawTransactionInstance } from \"../types\";\n\n/**\n * Derive the raw transaction type - FeePayerRawTransaction or MultiAgentRawTransaction or RawTransaction\n *\n * @param transaction A aptos transaction type\n *\n * @returns FeePayerRawTransaction | MultiAgentRawTransaction | RawTransaction\n */\nexport function deriveTransactionType(transaction: AnyRawTransaction): AnyRawTransactionInstance {\n if (transaction.feePayerAddress) {\n return new FeePayerRawTransaction(\n transaction.rawTransaction,\n transaction.secondarySignerAddresses ?? [],\n transaction.feePayerAddress,\n );\n }\n if (transaction.secondarySignerAddresses) {\n return new MultiAgentRawTransaction(transaction.rawTransaction, transaction.secondarySignerAddresses);\n }\n\n return transaction.rawTransaction;\n}\n\n/**\n * Generates the 'signing message' form of a message to be signed.\n *\n * @param bytes The byte representation of the message to be signed and sent to the chain\n * @param domainSeparator A domain separator that starts with 'APTOS::'\n *\n * @returns The Uint8Array of the signing message\n */\nexport function generateSigningMessage(bytes: Uint8Array, domainSeparator: string): Uint8Array {\n const hash = sha3Hash.create();\n\n if (!domainSeparator.startsWith(\"APTOS::\")) {\n throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${domainSeparator}`);\n }\n\n hash.update(domainSeparator);\n\n const prefix = hash.digest();\n\n const body = bytes;\n\n const mergedArray = new Uint8Array(prefix.length + body.length);\n mergedArray.set(prefix);\n mergedArray.set(body, prefix.length);\n\n return mergedArray;\n}\n\n/**\n * Generates the 'signing message' form of a transaction. It derives the type of transaction and\n * applies the appropriate domain separator based on if there is extra data such as a fee payer or\n * secondary signers.\n *\n * @param transaction A transaction that is to be signed\n *\n * @returns The Uint8Array of the signing message\n */\nexport function generateSigningMessageForTransaction(transaction: AnyRawTransaction): Uint8Array {\n const rawTxn = deriveTransactionType(transaction);\n if (transaction.feePayerAddress) {\n return generateSigningMessage(rawTxn.bcsToBytes(), RAW_TRANSACTION_WITH_DATA_SALT);\n }\n if (transaction.secondarySignerAddresses) {\n return generateSigningMessage(rawTxn.bcsToBytes(), RAW_TRANSACTION_WITH_DATA_SALT);\n }\n return generateSigningMessage(rawTxn.bcsToBytes(), RAW_TRANSACTION_SALT);\n}\n"],"mappings":"2FAMA,OAAS,YAAYA,MAAgB,qBAY9B,SAASC,EAAsBC,EAA2D,CAC/F,OAAIA,EAAY,gBACP,IAAIC,EACTD,EAAY,eACZA,EAAY,0BAA4B,CAAC,EACzCA,EAAY,eACd,EAEEA,EAAY,yBACP,IAAIE,EAAyBF,EAAY,eAAgBA,EAAY,wBAAwB,EAG/FA,EAAY,cACrB,CAUO,SAASG,EAAuBC,EAAmBC,EAAqC,CAC7F,IAAMC,EAAOC,EAAS,OAAO,EAE7B,GAAI,CAACF,EAAgB,WAAW,SAAS,EACvC,MAAM,IAAI,MAAM,+DAA+DA,CAAe,EAAE,EAGlGC,EAAK,OAAOD,CAAe,EAE3B,IAAMG,EAASF,EAAK,OAAO,EAErBG,EAAOL,EAEPM,EAAc,IAAI,WAAWF,EAAO,OAASC,EAAK,MAAM,EAC9D,OAAAC,EAAY,IAAIF,CAAM,EACtBE,EAAY,IAAID,EAAMD,EAAO,MAAM,EAE5BE,CACT,CAWO,SAASC,EAAqCX,EAA4C,CAC/F,IAAMY,EAASb,EAAsBC,CAAW,EAChD,OAAIA,EAAY,gBACPG,EAAuBS,EAAO,WAAW,EAAGC,CAA8B,EAE/Eb,EAAY,yBACPG,EAAuBS,EAAO,WAAW,EAAGC,CAA8B,EAE5EV,EAAuBS,EAAO,WAAW,EAAGE,CAAoB,CACzE","names":["sha3Hash","deriveTransactionType","transaction","FeePayerRawTransaction","MultiAgentRawTransaction","generateSigningMessage","bytes","domainSeparator","hash","sha3Hash","prefix","body","mergedArray","generateSigningMessageForTransaction","rawTxn","RAW_TRANSACTION_WITH_DATA_SALT","RAW_TRANSACTION_SALT"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/crypto/cryptoHasher.ts"],"sourcesContent":["import { generateSigningMessage } from \"../../transactions/transactionBuilder/signingMessage\";\nimport { Serializable } from \"../../bcs/serializer\";\n\nexport type AptsoDomainSeparator = `APTOS::${string}`;\nexport abstract class CryptoHashable extends Serializable {\n abstract readonly domainSeparator: AptsoDomainSeparator;\n\n /**\n * Hashes the bcs serialized from of the class. This is the typescript corollary to the BCSCryptoHash macro in aptos-core.\n *\n * @returns Uint8Array\n */\n hash(): Uint8Array {\n return generateSigningMessage(this.bcsToBytes(), this.domainSeparator);\n }\n}\n"],"mappings":"kFAIO,IAAeA,EAAf,cAAsCC,CAAa,CAQxD,MAAmB,CACjB,OAAOC,EAAuB,KAAK,WAAW,EAAG,KAAK,eAAe,CACvE,CACF","names":["CryptoHashable","Serializable","generateSigningMessage"]}
@@ -1,2 +0,0 @@
1
- import{decode as r}from"js-base64";async function c(n){return new Promise(e=>{setTimeout(e,n)})}function i(){return Math.floor(new Date().getTime()/1e3)}function u(n){let e=new Date(n*1e3);return e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),Math.floor(e.getTime()/1e3)}function d(n){let e=n.replace(/-/g,"+").replace(/_/g,"/"),t=e+"==".substring(0,(3-e.length%3)%3);return r(t)}export{c as a,i as b,u as c,d};
2
- //# sourceMappingURL=chunk-QHB5A5YP.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/helpers.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { decode } from \"js-base64\";\n\n/**\n * Sleep the current thread for the given amount of time\n * @param timeMs time in milliseconds to sleep\n */\nexport async function sleep(timeMs: number): Promise<null> {\n return new Promise((resolve) => {\n setTimeout(resolve, timeMs);\n });\n}\n\nexport function currentTimeInSeconds(): number {\n return Math.floor(new Date().getTime() / 1000);\n}\n\nexport function floorToWholeHour(timestampInSeconds: number): number {\n const date = new Date(timestampInSeconds * 1000);\n // Reset minutes and seconds to zero\n date.setMinutes(0);\n date.setSeconds(0);\n date.setMilliseconds(0);\n return Math.floor(date.getTime() / 1000);\n}\n\nexport function base64UrlDecode(base64Url: string): string {\n // Replace base64url-specific characters\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n // Pad the string with '=' characters if needed\n const paddedBase64 = base64 + \"==\".substring(0, (3 - (base64.length % 3)) % 3);\n const decodedString = decode(paddedBase64);\n return decodedString;\n}\n"],"mappings":"AAGA,OAAS,UAAAA,MAAc,YAMvB,eAAsBC,EAAMC,EAA+B,CACzD,OAAO,IAAI,QAASC,GAAY,CAC9B,WAAWA,EAASD,CAAM,CAC5B,CAAC,CACH,CAEO,SAASE,GAA+B,CAC7C,OAAO,KAAK,MAAM,IAAI,KAAK,EAAE,QAAQ,EAAI,GAAI,CAC/C,CAEO,SAASC,EAAiBC,EAAoC,CACnE,IAAMC,EAAO,IAAI,KAAKD,EAAqB,GAAI,EAE/C,OAAAC,EAAK,WAAW,CAAC,EACjBA,EAAK,WAAW,CAAC,EACjBA,EAAK,gBAAgB,CAAC,EACf,KAAK,MAAMA,EAAK,QAAQ,EAAI,GAAI,CACzC,CAEO,SAASC,EAAgBC,EAA2B,CAEzD,IAAMC,EAASD,EAAU,QAAQ,KAAM,GAAG,EAAE,QAAQ,KAAM,GAAG,EAEvDE,EAAeD,EAAS,KAAK,UAAU,GAAI,EAAKA,EAAO,OAAS,GAAM,CAAC,EAE7E,OADsBV,EAAOW,CAAY,CAE3C","names":["decode","sleep","timeMs","resolve","currentTimeInSeconds","floorToWholeHour","timestampInSeconds","date","base64UrlDecode","base64Url","base64","paddedBase64"]}
@@ -1,2 +0,0 @@
1
- import{a as D}from"./chunk-37FFZSIM.mjs";import{a as S,b as d}from"./chunk-L5CPAOUM.mjs";import{a as b,c as I,d as B,e as P}from"./chunk-IVVWQKCF.mjs";import{a as H,c as U}from"./chunk-XVZBWW46.mjs";import{b as G}from"./chunk-WA2NTBYY.mjs";import{a as g}from"./chunk-4VPCPASN.mjs";import{a as K}from"./chunk-EFMAZTIM.mjs";import{a as A}from"./chunk-3IFR6T3V.mjs";import{a as m,b as E}from"./chunk-UMLUOYFK.mjs";import{b as u}from"./chunk-AOCNYMMX.mjs";import{jwtDecode as M}from"jwt-decode";var se=1e7,O=120,F=30,N=330,oe=120,le=350,ce=300,pe=93,l=class l extends G{constructor(e,t){super();let r=u.fromHexInput(t).toUint8Array();if(r.length!==l.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${l.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new E;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),K.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}toString(){return u.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new l(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new l(t,r)}static isPublicKey(e){return e instanceof l}static create(e){return T(e),new l(e.iss,T(e))}static fromJWTAndPepper(e){let{jwt:t,pepper:r,uidKey:n="sub"}=e,s=M(t),o=s.iss;if(typeof s.aud!="string")throw new Error("aud was not found or an array of values");let C=s.aud,_=s[n];return l.create({iss:o,uidKey:n,uidVal:_,aud:C,pepper:r})}};l.ID_COMMITMENT_LENGTH=32;var w=l;function T(a){let{uidKey:i,uidVal:e,aud:t,pepper:r}=a,n=[I(u.fromHexInput(r).toUint8Array()),b(t,O),b(e,N),b(i,F)];return B(P(n),w.ID_COMMITMENT_LENGTH)}var v=class a extends g{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:r,expiryDateSecs:n,ephemeralPublicKey:s,ephemeralSignature:o}=e;this.jwtHeader=t,this.ephemeralCertificate=r,this.expiryDateSecs=n,this.ephemeralPublicKey=s,this.ephemeralSignature=o}toUint8Array(){return this.bcsToBytes()}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=y.deserialize(e),r=e.deserializeStr(),n=e.deserializeU64(),s=S.deserialize(e),o=d.deserialize(e);return new a({jwtHeader:r,expiryDateSecs:Number(n),ephemeralCertificate:t,ephemeralPublicKey:s,ephemeralSignature:o})}static load(e){let t=y.deserialize(e),r=e.deserializeStr(),n=e.deserializeU64(),s=S.deserialize(e),o=d.deserialize(e);return new a({jwtHeader:r,expiryDateSecs:Number(n),ephemeralCertificate:t,ephemeralPublicKey:s,ephemeralSignature:o})}static getSimulationSignature(){return new a({jwtHeader:"{}",ephemeralCertificate:new y(new f({proof:new h(new x({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new S(new H(new Uint8Array(32))),ephemeralSignature:new d(new U(new Uint8Array(64)))})}static isSignature(e){return e instanceof a}},y=class a extends g{constructor(e,t){super();this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new a(f.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},c=class a extends m{constructor(e){super();if(this.data=u.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new a(t)}},p=class a extends m{constructor(e){super();if(this.data=u.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new a(t)}},x=class a extends D{constructor(e){super();let{a:t,b:r,c:n}=e;this.a=new c(t),this.b=new p(r),this.c=new c(n)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=c.deserialize(e).bcsToBytes(),r=p.deserialize(e).bcsToBytes(),n=c.deserialize(e).bcsToBytes();return new a({a:t,b:r,c:n})}},h=class a extends m{constructor(e,t){super();this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new a(x.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},f=class a extends g{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:n,extraField:s,overrideAudVal:o}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=n,this.extraField=s,this.overrideAudVal=o}toUint8Array(){return this.bcsToBytes()}static fromBytes(e){return a.deserialize(new A(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOptionStr(this.extraField),e.serializeOptionStr(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=h.deserialize(e),r=Number(e.deserializeU64()),n=e.deserializeOptionStr(),s=e.deserializeOptionStr(),o=e.deserializeOption(d);return new a({proof:t,expHorizonSecs:r,trainingWheelsSignature:o,extraField:n,overrideAudVal:s})}static load(e){let t=h.deserialize(e),r=Number(e.deserializeU64()),n=e.deserializeOptionStr(),s=e.deserializeOptionStr(),o=e.deserializeOption(d);return new a({proof:t,expHorizonSecs:r,trainingWheelsSignature:o,extraField:n,overrideAudVal:s})}},V=class a{constructor(i,e){this.verficationKey=i,this.maxExpHorizonSecs=e}static create(i,e){return new a(new z({alphaG1:i.alpha_g1,betaG2:i.beta_g2,deltaG2:i.delta_g2,gammaAbcG1:i.gamma_abc_g1,gammaG2:i.gamma_g2}),e)}},z=class a{constructor(i){let{alphaG1:e,betaG2:t,deltaG2:r,gammaAbcG1:n,gammaG2:s}=i;this.alphaG1=new c(e),this.betaG2=new p(t),this.deltaG2=new p(r),this.gammaAbcG1=[new c(n[0]),new c(n[1])],this.gammaG2=new p(s)}static fromGroth16VerificationKeyResponse(i){return new a({alphaG1:i.alpha_g1,betaG2:i.beta_g2,deltaG2:i.delta_g2,gammaAbcG1:i.gamma_abc_g1,gammaG2:i.gamma_g2})}};export{se as a,O as b,F as c,N as d,oe as e,le as f,ce as g,pe as h,w as i,v as j,y as k,x as l,h as m,f as n,V as o};
2
- //# sourceMappingURL=chunk-UKKHWC4Y.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/crypto/keyless.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { JwtPayload, jwtDecode } from \"jwt-decode\";\nimport { AccountPublicKey, PublicKey } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { Deserializer, Serializable, Serializer } from \"../../bcs\";\nimport { Hex } from \"../hex\";\nimport { HexInput, EphemeralCertificateVariant, AnyPublicKeyVariant, SigningScheme, ZkpVariant } from \"../../types\";\nimport { EphemeralPublicKey, EphemeralSignature } from \"./ephemeral\";\nimport { bigIntToBytesLE, bytesToBigIntLE, hashStrToField, poseidonHash } from \"./poseidon\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Proof } from \"./proof\";\nimport { Ed25519PublicKey, Ed25519Signature } from \"./ed25519\";\nimport { Groth16VerificationKeyResponse } from \"../../types/keyless\";\n\nexport const EPK_HORIZON_SECS = 10000000;\nexport const MAX_AUD_VAL_BYTES = 120;\nexport const MAX_UID_KEY_BYTES = 30;\nexport const MAX_UID_VAL_BYTES = 330;\nexport const MAX_ISS_VAL_BYTES = 120;\nexport const MAX_EXTRA_FIELD_BYTES = 350;\nexport const MAX_JWT_HEADER_B64_BYTES = 300;\nexport const MAX_COMMITED_EPK_BYTES = 93;\n\n/**\n * Represents the KeylessPublicKey public key\n *\n * KeylessPublicKey authentication key is represented in the SDK as `AnyPublicKey`.\n */\nexport class KeylessPublicKey extends AccountPublicKey {\n static readonly ID_COMMITMENT_LENGTH: number = 32;\n\n /**\n * The value of the 'iss' claim on the JWT which identifies the OIDC provider.\n */\n readonly iss: string;\n\n /**\n * A value representing a cryptographic commitment to a user identity.\n *\n * It is calculated from the aud, uidKey, uidVal, pepper.\n */\n readonly idCommitment: Uint8Array;\n\n constructor(iss: string, idCommitment: HexInput) {\n super();\n const idcBytes = Hex.fromHexInput(idCommitment).toUint8Array();\n if (idcBytes.length !== KeylessPublicKey.ID_COMMITMENT_LENGTH) {\n throw new Error(`Id Commitment length in bytes should be ${KeylessPublicKey.ID_COMMITMENT_LENGTH}`);\n }\n this.iss = iss;\n this.idCommitment = idcBytes;\n }\n\n /**\n * Get the authentication key for the keyless public key\n *\n * @returns AuthenticationKey\n */\n authKey(): AuthenticationKey {\n const serializer = new Serializer();\n serializer.serializeU32AsUleb128(AnyPublicKeyVariant.Keyless);\n serializer.serializeFixedBytes(this.bcsToBytes());\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: SigningScheme.SingleKey,\n input: serializer.toUint8Array(),\n });\n }\n\n /**\n * Get the public key in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the public key\n */\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n /**\n * Get the public key as a hex string with the 0x prefix.\n *\n * @returns string representation of the public key\n */\n toString(): string {\n return Hex.fromHexInput(this.toUint8Array()).toString();\n }\n\n /**\n * Verifies a signed data with a public key\n *\n * @param args.message message\n * @param args.signature The signature\n * @returns true if the signature is valid\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this\n verifySignature(args: { message: HexInput; signature: KeylessSignature }): boolean {\n throw new Error(\"Not yet implemented\");\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.iss);\n serializer.serializeBytes(this.idCommitment);\n }\n\n static deserialize(deserializer: Deserializer): KeylessPublicKey {\n const iss = deserializer.deserializeStr();\n const addressSeed = deserializer.deserializeBytes();\n return new KeylessPublicKey(iss, addressSeed);\n }\n\n static load(deserializer: Deserializer): KeylessPublicKey {\n const iss = deserializer.deserializeStr();\n const addressSeed = deserializer.deserializeBytes();\n return new KeylessPublicKey(iss, addressSeed);\n }\n\n static isPublicKey(publicKey: PublicKey): publicKey is KeylessPublicKey {\n return publicKey instanceof KeylessPublicKey;\n }\n\n /**\n * Creates a KeylessPublicKey from the JWT components plus pepper\n *\n * @param args.iss the iss of the identity\n * @param args.uidKey the key to use to get the uidVal in the JWT token\n * @param args.uidVal the value of the uidKey in the JWT token\n * @param args.aud the client ID of the application\n * @param args.pepper The pepper used to maintain privacy of the account\n * @returns KeylessPublicKey\n */\n static create(args: {\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n }): KeylessPublicKey {\n computeIdCommitment(args);\n return new KeylessPublicKey(args.iss, computeIdCommitment(args));\n }\n\n static fromJWTAndPepper(args: { jwt: string; pepper: HexInput; uidKey?: string }): KeylessPublicKey {\n const { jwt, pepper, uidKey = \"sub\" } = args;\n const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);\n const iss = jwtPayload.iss!;\n if (typeof jwtPayload.aud !== \"string\") {\n throw new Error(\"aud was not found or an array of values\");\n }\n const aud = jwtPayload.aud!;\n const uidVal = jwtPayload[uidKey];\n return KeylessPublicKey.create({ iss, uidKey, uidVal, aud, pepper });\n }\n}\n\nfunction computeIdCommitment(args: { uidKey: string; uidVal: string; aud: string; pepper: HexInput }): Uint8Array {\n const { uidKey, uidVal, aud, pepper } = args;\n\n const fields = [\n bytesToBigIntLE(Hex.fromHexInput(pepper).toUint8Array()),\n hashStrToField(aud, MAX_AUD_VAL_BYTES),\n hashStrToField(uidVal, MAX_UID_VAL_BYTES),\n hashStrToField(uidKey, MAX_UID_KEY_BYTES),\n ];\n\n return bigIntToBytesLE(poseidonHash(fields), KeylessPublicKey.ID_COMMITMENT_LENGTH);\n}\n\n/**\n * A signature of a message signed via Keyless Accounnt that uses proofs or the jwt token to authenticate.\n */\nexport class KeylessSignature extends Signature {\n /**\n * The inner signature ZeroKnowledgeSigniature or OpenIdSignature\n */\n readonly ephemeralCertificate: EphemeralCertificate;\n\n /**\n * The jwt header in the token used to create the proof/signature. In json string representation.\n */\n readonly jwtHeader: string;\n\n /**\n * The expiry timestamp in seconds of the EphemeralKeyPair used to sign\n */\n readonly expiryDateSecs: number;\n\n /**\n * The ephemeral public key used to verify the signature\n */\n readonly ephemeralPublicKey: EphemeralPublicKey;\n\n /**\n * The signature resulting from signing with the private key of the EphemeralKeyPair\n */\n readonly ephemeralSignature: EphemeralSignature;\n\n constructor(args: {\n jwtHeader: string;\n ephemeralCertificate: EphemeralCertificate;\n expiryDateSecs: number;\n ephemeralPublicKey: EphemeralPublicKey;\n ephemeralSignature: EphemeralSignature;\n }) {\n super();\n const { jwtHeader, ephemeralCertificate, expiryDateSecs, ephemeralPublicKey, ephemeralSignature } = args;\n this.jwtHeader = jwtHeader;\n this.ephemeralCertificate = ephemeralCertificate;\n this.expiryDateSecs = expiryDateSecs;\n this.ephemeralPublicKey = ephemeralPublicKey;\n this.ephemeralSignature = ephemeralSignature;\n }\n\n /**\n * Get the signature in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the signature\n */\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n serialize(serializer: Serializer): void {\n this.ephemeralCertificate.serialize(serializer);\n serializer.serializeStr(this.jwtHeader);\n serializer.serializeU64(this.expiryDateSecs);\n this.ephemeralPublicKey.serialize(serializer);\n this.ephemeralSignature.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): KeylessSignature {\n const ephemeralCertificate = EphemeralCertificate.deserialize(deserializer);\n const jwtHeader = deserializer.deserializeStr();\n const expiryDateSecs = deserializer.deserializeU64();\n const ephemeralPublicKey = EphemeralPublicKey.deserialize(deserializer);\n const ephemeralSignature = EphemeralSignature.deserialize(deserializer);\n return new KeylessSignature({\n jwtHeader,\n expiryDateSecs: Number(expiryDateSecs),\n ephemeralCertificate,\n ephemeralPublicKey,\n ephemeralSignature,\n });\n }\n\n static load(deserializer: Deserializer): KeylessSignature {\n const ephemeralCertificate = EphemeralCertificate.deserialize(deserializer);\n const jwtHeader = deserializer.deserializeStr();\n const expiryDateSecs = deserializer.deserializeU64();\n const ephemeralPublicKey = EphemeralPublicKey.deserialize(deserializer);\n const ephemeralSignature = EphemeralSignature.deserialize(deserializer);\n return new KeylessSignature({\n jwtHeader,\n expiryDateSecs: Number(expiryDateSecs),\n ephemeralCertificate,\n ephemeralPublicKey,\n ephemeralSignature,\n });\n }\n\n static getSimulationSignature(): KeylessSignature {\n return new KeylessSignature({\n jwtHeader: \"{}\",\n ephemeralCertificate: new EphemeralCertificate(\n new ZeroKnowledgeSig({\n proof: new ZkProof(\n new Groth16Zkp({ a: new Uint8Array(32), b: new Uint8Array(64), c: new Uint8Array(32) }),\n ZkpVariant.Groth16,\n ),\n expHorizonSecs: 0,\n }),\n EphemeralCertificateVariant.ZkProof,\n ),\n expiryDateSecs: 0,\n ephemeralPublicKey: new EphemeralPublicKey(new Ed25519PublicKey(new Uint8Array(32))),\n ephemeralSignature: new EphemeralSignature(new Ed25519Signature(new Uint8Array(64))),\n });\n }\n\n static isSignature(signature: Signature): signature is KeylessSignature {\n return signature instanceof KeylessSignature;\n }\n}\n\n/**\n * A container for a signature that is a ZeroKnowledgeSig. Can be expanded to support OpenIdSignature.\n */\nexport class EphemeralCertificate extends Signature {\n public readonly signature: Signature;\n\n /**\n * Index of the underlying enum variant\n */\n private readonly variant: EphemeralCertificateVariant;\n\n constructor(signature: Signature, variant: EphemeralCertificateVariant) {\n super();\n this.signature = signature;\n this.variant = variant;\n }\n\n /**\n * Get the public key in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the public key\n */\n toUint8Array(): Uint8Array {\n return this.signature.toUint8Array();\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.signature.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): EphemeralCertificate {\n const variant = deserializer.deserializeUleb128AsU32();\n switch (variant) {\n case EphemeralCertificateVariant.ZkProof:\n return new EphemeralCertificate(ZeroKnowledgeSig.deserialize(deserializer), variant);\n default:\n throw new Error(`Unknown variant index for EphemeralCertificate: ${variant}`);\n }\n }\n}\n\nclass G1Bytes extends Serializable {\n data: Uint8Array;\n\n constructor(data: HexInput) {\n super();\n this.data = Hex.fromHexInput(data).toUint8Array();\n if (this.data.length !== 32) {\n throw new Error(\"Input needs to be 32 bytes\");\n }\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n static deserialize(deserializer: Deserializer): G1Bytes {\n const bytes = deserializer.deserializeFixedBytes(32);\n return new G1Bytes(bytes);\n }\n}\n\nclass G2Bytes extends Serializable {\n data: Uint8Array;\n\n constructor(data: HexInput) {\n super();\n this.data = Hex.fromHexInput(data).toUint8Array();\n if (this.data.length !== 64) {\n throw new Error(\"Input needs to be 64 bytes\");\n }\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n static deserialize(deserializer: Deserializer): G2Bytes {\n const bytes = deserializer.deserializeFixedBytes(64);\n return new G2Bytes(bytes);\n }\n}\n\n/**\n * A representation of a Groth16 proof. The points are the compressed serialization of affine reprentation of the proof.\n */\nexport class Groth16Zkp extends Proof {\n /**\n * The bytes of G1 proof point a\n */\n a: G1Bytes;\n\n /**\n * The bytes of G2 proof point b\n */\n b: G2Bytes;\n\n /**\n * The bytes of G1 proof point c\n */\n c: G1Bytes;\n\n constructor(args: { a: HexInput; b: HexInput; c: HexInput }) {\n super();\n const { a, b, c } = args;\n this.a = new G1Bytes(a);\n this.b = new G2Bytes(b);\n this.c = new G1Bytes(c);\n }\n\n serialize(serializer: Serializer): void {\n this.a.serialize(serializer);\n this.b.serialize(serializer);\n this.c.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): Groth16Zkp {\n const a = G1Bytes.deserialize(deserializer).bcsToBytes();\n const b = G2Bytes.deserialize(deserializer).bcsToBytes();\n const c = G1Bytes.deserialize(deserializer).bcsToBytes();\n return new Groth16Zkp({ a, b, c });\n }\n}\n\n/**\n * A container for a different zero knowledge proof types\n */\nexport class ZkProof extends Serializable {\n public readonly proof: Proof;\n\n /**\n * Index of the underlying enum variant\n */\n private readonly variant: ZkpVariant;\n\n constructor(proof: Proof, variant: ZkpVariant) {\n super();\n this.proof = proof;\n this.variant = variant;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.proof.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): ZkProof {\n const variant = deserializer.deserializeUleb128AsU32();\n switch (variant) {\n case ZkpVariant.Groth16:\n return new ZkProof(Groth16Zkp.deserialize(deserializer), variant);\n default:\n throw new Error(`Unknown variant index for ZkProof: ${variant}`);\n }\n }\n}\n\n/**\n * The signature representation of a proof\n */\nexport class ZeroKnowledgeSig extends Signature {\n /**\n * The proof\n */\n readonly proof: ZkProof;\n\n /**\n * The max lifespan of the proof\n */\n readonly expHorizonSecs: number;\n\n /**\n * A key value pair on the JWT token that can be specified on the signature which would reveal the value on chain.\n * Can be used to assert identity or other attributes.\n */\n readonly extraField?: string;\n\n /**\n * The 'aud' value of the recovery service which is set when recovering an account.\n */\n readonly overrideAudVal?: string;\n\n /**\n * The training wheels signature\n */\n readonly trainingWheelsSignature?: EphemeralSignature;\n\n constructor(args: {\n proof: ZkProof;\n expHorizonSecs: number;\n extraField?: string;\n overrideAudVal?: string;\n trainingWheelsSignature?: EphemeralSignature;\n }) {\n super();\n const { proof, expHorizonSecs, trainingWheelsSignature, extraField, overrideAudVal } = args;\n this.proof = proof;\n this.expHorizonSecs = expHorizonSecs;\n this.trainingWheelsSignature = trainingWheelsSignature;\n this.extraField = extraField;\n this.overrideAudVal = overrideAudVal;\n }\n\n /**\n * Get the signature in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the signature\n */\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n /**\n * Return a ZeroKnowledgeSig object from its bcs serialization in bytes.\n *\n * @returns ZeroKnowledgeSig\n */\n static fromBytes(bytes: Uint8Array): ZeroKnowledgeSig {\n return ZeroKnowledgeSig.deserialize(new Deserializer(bytes));\n }\n\n serialize(serializer: Serializer): void {\n this.proof.serialize(serializer);\n serializer.serializeU64(this.expHorizonSecs);\n serializer.serializeOptionStr(this.extraField);\n serializer.serializeOptionStr(this.overrideAudVal);\n serializer.serializeOption(this.trainingWheelsSignature);\n }\n\n static deserialize(deserializer: Deserializer): ZeroKnowledgeSig {\n const proof = ZkProof.deserialize(deserializer);\n const expHorizonSecs = Number(deserializer.deserializeU64());\n const extraField = deserializer.deserializeOptionStr();\n const overrideAudVal = deserializer.deserializeOptionStr();\n const trainingWheelsSignature = deserializer.deserializeOption(EphemeralSignature);\n return new ZeroKnowledgeSig({ proof, expHorizonSecs, trainingWheelsSignature, extraField, overrideAudVal });\n }\n\n static load(deserializer: Deserializer): ZeroKnowledgeSig {\n const proof = ZkProof.deserialize(deserializer);\n const expHorizonSecs = Number(deserializer.deserializeU64());\n const extraField = deserializer.deserializeOptionStr();\n const overrideAudVal = deserializer.deserializeOptionStr();\n const trainingWheelsSignature = deserializer.deserializeOption(EphemeralSignature);\n return new ZeroKnowledgeSig({ proof, expHorizonSecs, trainingWheelsSignature, extraField, overrideAudVal });\n }\n}\n\n/**\n * A class which represents the on-chain configuration for how Keyless accounts work\n */\nexport class KeylessConfiguration {\n /**\n * The verification key used to verify Groth16 proofs on chain\n */\n readonly verficationKey: Groth16VerificationKey;\n\n /**\n * The maximum lifespan of an ephemeral key pair. This is configured on chain.\n */\n readonly maxExpHorizonSecs: number;\n\n constructor(verficationKey: Groth16VerificationKey, maxExpHorizonSecs: number) {\n this.verficationKey = verficationKey;\n this.maxExpHorizonSecs = maxExpHorizonSecs;\n }\n\n static create(res: Groth16VerificationKeyResponse, maxExpHorizonSecs: number): KeylessConfiguration {\n return new KeylessConfiguration(\n new Groth16VerificationKey({\n alphaG1: res.alpha_g1,\n betaG2: res.beta_g2,\n deltaG2: res.delta_g2,\n gammaAbcG1: res.gamma_abc_g1,\n gammaG2: res.gamma_g2,\n }),\n maxExpHorizonSecs,\n );\n }\n}\n\n/**\n * A representation of the verification key stored on chain used to verify Groth16 proofs\n */\nclass Groth16VerificationKey {\n // The docstrings below are borrowed from ark-groth16\n\n /**\n * The `alpha * G`, where `G` is the generator of G1\n */\n readonly alphaG1: G1Bytes;\n\n /**\n * The `alpha * H`, where `H` is the generator of G2\n */\n readonly betaG2: G2Bytes;\n\n /**\n * The `delta * H`, where `H` is the generator of G2\n */\n readonly deltaG2: G2Bytes;\n\n /**\n * The `gamma^{-1} * (beta * a_i + alpha * b_i + c_i) * H`, where H is the generator of G1\n */\n readonly gammaAbcG1: G1Bytes[];\n\n /**\n * The `gamma * H`, where `H` is the generator of G2\n */\n readonly gammaG2: G2Bytes;\n\n constructor(args: {\n alphaG1: HexInput;\n betaG2: HexInput;\n deltaG2: HexInput;\n gammaAbcG1: [HexInput, HexInput];\n gammaG2: HexInput;\n }) {\n const { alphaG1, betaG2, deltaG2, gammaAbcG1, gammaG2 } = args;\n this.alphaG1 = new G1Bytes(alphaG1);\n this.betaG2 = new G2Bytes(betaG2);\n this.deltaG2 = new G2Bytes(deltaG2);\n this.gammaAbcG1 = [new G1Bytes(gammaAbcG1[0]), new G1Bytes(gammaAbcG1[1])];\n this.gammaG2 = new G2Bytes(gammaG2);\n }\n\n static fromGroth16VerificationKeyResponse(res: Groth16VerificationKeyResponse): Groth16VerificationKey {\n return new Groth16VerificationKey({\n alphaG1: res.alpha_g1,\n betaG2: res.beta_g2,\n deltaG2: res.delta_g2,\n gammaAbcG1: res.gamma_abc_g1,\n gammaG2: res.gamma_g2,\n });\n }\n}\n"],"mappings":"ocAGA,OAAqB,aAAAA,MAAiB,aAa/B,IAAMC,GAAmB,IACnBC,EAAoB,IACpBC,EAAoB,GACpBC,EAAoB,IACpBC,GAAoB,IACp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,OAAO,OAAOC,EAAqCD,EAAiD,CAClG,OAAO,IAAIF,EACT,IAAII,EAAuB,CACzB,QAASD,EAAI,SACb,OAAQA,EAAI,QACZ,QAASA,EAAI,SACb,WAAYA,EAAI,aAChB,QAASA,EAAI,QACf,CAAC,EACDD,CACF,CACF,CACF,EAKME,EAAN,MAAMC,CAAuB,CA4B3B,YAAY/D,EAMT,CACD,GAAM,CAAE,QAAAgE,EAAS,OAAAC,EAAQ,QAAAC,EAAS,WAAAC,EAAY,QAAAC,CAAQ,EAAIpE,EAC1D,KAAK,QAAU,IAAIqC,EAAQ2B,CAAO,EAClC,KAAK,OAAS,IAAItB,EAAQuB,CAAM,EAChC,KAAK,QAAU,IAAIvB,EAAQwB,CAAO,EAClC,KAAK,WAAa,CAAC,IAAI7B,EAAQ8B,EAAW,CAAC,CAAC,EAAG,IAAI9B,EAAQ8B,EAAW,CAAC,CAAC,CAAC,EACzE,KAAK,QAAU,IAAIzB,EAAQ0B,CAAO,CACpC,CAEA,OAAO,mCAAmCP,EAA6D,CACrG,OAAO,IAAIE,EAAuB,CAChC,QAASF,EAAI,SACb,OAAQA,EAAI,QACZ,QAASA,EAAI,SACb,WAAYA,EAAI,aAChB,QAASA,EAAI,QACf,CAAC,CACH,CACF","names":["jwtDecode","EPK_HORIZON_SECS","MAX_AUD_VAL_BYTES","MAX_UID_KEY_BYTES","MAX_UID_VAL_BYTES","MAX_ISS_VAL_BYTES","MAX_EXTRA_FIELD_BYTES","MAX_JWT_HEADER_B64_BYTES","MAX_COMMITED_EPK_BYTES","_KeylessPublicKey","AccountPublicKey","iss","idCommitment","idcBytes","Hex","serializer","Serializer","AuthenticationKey","args","deserializer","addressSeed","publicKey","computeIdCommitment","jwt","pepper","uidKey","jwtPayload","jwtDecode","aud","uidVal","KeylessPublicKey","fields","bytesToBigIntLE","hashStrToField","bigIntToBytesLE","poseidonHash","KeylessSignature","_KeylessSignature","Signature","jwtHeader","ephemeralCertificate","expiryDateSecs","ephemeralPublicKey","ephemeralSignature","EphemeralCertificate","EphemeralPublicKey","EphemeralSignature","ZeroKnowledgeSig","ZkProof","Groth16Zkp","Ed25519PublicKey","Ed25519Signature","signature","_EphemeralCertificate","variant","G1Bytes","_G1Bytes","Serializable","data","bytes","G2Bytes","_G2Bytes","_Groth16Zkp","Proof","a","b","c","_ZkProof","proof","_ZeroKnowledgeSig","expHorizonSecs","trainingWheelsSignature","extraField","overrideAudVal","Deserializer","KeylessConfiguration","_KeylessConfiguration","verficationKey","maxExpHorizonSecs","res","Groth16VerificationKey","_Groth16VerificationKey","alphaG1","betaG2","deltaG2","gammaAbcG1","gammaG2"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/keyless.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from \"../account\";\nimport { deriveKeylessAccount, getPepper } from \"../internal/keyless\";\nimport { HexInput } from \"../types\";\nimport { AptosConfig } from \"./aptosConfig\";\n\n/**\n * A class to query all `Keyless` related queries on Aptos.\n */\nexport class Keyless {\n constructor(readonly config: AptosConfig) {}\n\n /**\n * Fetches the pepper from the Aptos pepper service API.\n *\n * @param args.jwt JWT token\n * @param args.ephemeralKeyPair the EphemeralKeyPair used to generate the nonce in the JWT token\n * @returns The pepper which is a Uint8Array of length 31.\n */\n async getPepper(args: { jwt: string; ephemeralKeyPair: EphemeralKeyPair }): Promise<Uint8Array> {\n return getPepper({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches the pepper from the Aptos pepper service API.\n *\n * @param args.jwt JWT token\n * @param args.ephemeralKeyPair the EphemeralKeyPair used to generate the nonce in the JWT token\n * @param args.uidKey a key in the JWT token to use to set the uidVal in the IdCommitment\n * @param args.pepper the pepper\n * @param args.proofFetchCallback a callback function that if set, the fetch of the proof will be done asyncronously. Once\n * if finishes the callback function will be called.\n * @returns A KeylessAccount that can be used to sign transactions\n */\n async deriveKeylessAccount(args: {\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n uidKey?: string;\n pepper?: HexInput;\n proofFetchCallback?: ProofFetchCallback;\n }): Promise<KeylessAccount> {\n return deriveKeylessAccount({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"gDAWO,IAAMA,EAAN,KAAc,CACnB,YAAqBC,EAAqB,CAArB,YAAAA,CAAsB,CAS3C,MAAM,UAAUC,EAAgF,CAC9F,OAAOC,EAAU,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CACxD,CAaA,MAAM,qBAAqBA,EAMC,CAC1B,OAAOE,EAAqB,CAAE,YAAa,KAAK,OAAQ,GAAGF,CAAK,CAAC,CACnE,CACF","names":["Keyless","config","args","getPepper","deriveKeylessAccount"]}
@@ -1,2 +0,0 @@
1
- import{a as s}from"./chunk-2DESIV2P.mjs";import{a as e}from"./chunk-QHB5A5YP.mjs";var n=()=>Math.floor(Date.now()/1e3),r=class{constructor(t,i,o,a,c){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=i,this.maxWaitTime=o,this.maximumInFlight=a,this.sleepTime=c}async nextSequenceNumber(){for(;this.lock;)await e(this.sleepTime);this.lock=!0;let t=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let i=n();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await e(this.sleepTime),n()-i>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}t=this.currentNumber,this.currentNumber+=BigInt(1)}catch(i){console.error("error in getting next sequence number for this account",i)}finally{this.lock=!1}return t}async initialize(){let{sequence_number:t}=await s({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await s({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(t),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await e(this.sleepTime);this.lock=!0;try{await this.update();let t=n();for(;this.lastUncommintedNumber!==this.currentNumber;)n()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await e(this.sleepTime),await this.update())}catch(t){console.error("error in synchronizing this account sequence number with the one on chain",t)}finally{this.lock=!1}}}};export{r as a};
2
- //# sourceMappingURL=chunk-WT5HOIK6.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/transactions/management/accountSequenceNumber.ts"],"sourcesContent":["/**\n * A wrapper that handles and manages an account sequence number.\n *\n * Submit up to `maximumInFlight` transactions per account in parallel with a timeout of `sleepTime`\n * If local assumes `maximumInFlight` are in flight, determine the actual committed state from the network\n * If there are less than `maximumInFlight` due to some being committed, adjust the window\n * If `maximumInFlight` are in flight, wait `sleepTime` seconds before re-evaluating\n * If ever waiting more than `maxWaitTime` restart the sequence number to the current on-chain state\n *\n * Assumptions:\n * Accounts are expected to be managed by a single AccountSequenceNumber and not used otherwise.\n * They are initialized to the current on-chain state, so if there are already transactions in\n * flight, they may take some time to reset.\n * Accounts are automatically initialized if not explicitly\n *\n * Notes:\n * This is co-routine safe, that is many async tasks can be reading from this concurrently.\n * The state of an account cannot be used across multiple AccountSequenceNumber services.\n * The synchronize method will create a barrier that prevents additional nextSequenceNumber\n * calls until it is complete.\n * This only manages the distribution of sequence numbers it does not help handle transaction\n * failures.\n * If a transaction fails, you should call synchronize and wait for timeouts.\n */\n\nimport { AptosConfig } from \"../../api/aptosConfig\";\nimport { Account } from \"../../account\";\nimport { getInfo } from \"../../internal/account\";\nimport { sleep } from \"../../utils/helpers\";\n\n// returns `now` time in seconds\nconst now = () => Math.floor(Date.now() / 1000);\n\nexport class AccountSequenceNumber {\n readonly aptosConfig: AptosConfig;\n\n readonly account: Account;\n\n // sequence number on chain\n lastUncommintedNumber: bigint | null = null;\n\n // local sequence number\n currentNumber: bigint | null = null;\n\n /**\n * We want to guarantee that we preserve ordering of workers to requests.\n *\n * `lock` is used to try to prevent multiple coroutines from accessing a shared resource at the same time,\n * which can result in race conditions and data inconsistency.\n * This code actually doesn't do it though, since we aren't giving out a slot, it is still somewhat a race condition.\n *\n * The ideal solution is likely that each thread grabs the next number from a incremental integer.\n * When they complete, they increment that number and that entity is able to enter the `lock`.\n * That would guarantee ordering.\n */\n lock = false;\n\n maxWaitTime: number;\n\n maximumInFlight: number;\n\n sleepTime: number;\n\n constructor(\n aptosConfig: AptosConfig,\n account: Account,\n maxWaitTime: number,\n maximumInFlight: number,\n sleepTime: number,\n ) {\n this.aptosConfig = aptosConfig;\n this.account = account;\n this.maxWaitTime = maxWaitTime;\n this.maximumInFlight = maximumInFlight;\n this.sleepTime = sleepTime;\n }\n\n /**\n * Returns the next available sequence number for this account\n *\n * @returns next available sequence number\n */\n async nextSequenceNumber(): Promise<bigint | null> {\n /* eslint-disable no-await-in-loop */\n while (this.lock) {\n await sleep(this.sleepTime);\n }\n\n this.lock = true;\n let nextNumber = BigInt(0);\n try {\n if (this.lastUncommintedNumber === null || this.currentNumber === null) {\n await this.initialize();\n }\n\n if (this.currentNumber! - this.lastUncommintedNumber! >= this.maximumInFlight) {\n await this.update();\n\n const startTime = now();\n while (this.currentNumber! - this.lastUncommintedNumber! >= this.maximumInFlight) {\n await sleep(this.sleepTime);\n if (now() - startTime > this.maxWaitTime) {\n /* eslint-disable no-console */\n console.warn(\n `Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`,\n );\n await this.initialize();\n } else {\n await this.update();\n }\n }\n }\n nextNumber = this.currentNumber!;\n this.currentNumber! += BigInt(1);\n } catch (e) {\n console.error(\"error in getting next sequence number for this account\", e);\n } finally {\n this.lock = false;\n }\n return nextNumber;\n }\n\n /**\n * Initializes this account with the sequence number on chain\n */\n async initialize(): Promise<void> {\n const { sequence_number: sequenceNumber } = await getInfo({\n aptosConfig: this.aptosConfig,\n accountAddress: this.account.accountAddress,\n });\n this.currentNumber = BigInt(sequenceNumber);\n this.lastUncommintedNumber = BigInt(sequenceNumber);\n }\n\n /**\n * Updates this account sequence number with the one on-chain\n *\n * @returns on-chain sequence number for this account\n */\n async update(): Promise<bigint> {\n const { sequence_number: sequenceNumber } = await getInfo({\n aptosConfig: this.aptosConfig,\n accountAddress: this.account.accountAddress,\n });\n this.lastUncommintedNumber = BigInt(sequenceNumber);\n return this.lastUncommintedNumber;\n }\n\n /**\n * Synchronizes local sequence number with the seqeunce number on chain for this account.\n *\n * Poll the network until all submitted transactions have either been committed or until\n * the maximum wait time has elapsed\n */\n async synchronize(): Promise<void> {\n if (this.lastUncommintedNumber === this.currentNumber) return;\n\n /* eslint-disable no-await-in-loop */\n while (this.lock) {\n await sleep(this.sleepTime);\n }\n\n this.lock = true;\n\n try {\n await this.update();\n const startTime = now();\n while (this.lastUncommintedNumber !== this.currentNumber) {\n if (now() - startTime > this.maxWaitTime) {\n /* eslint-disable no-console */\n console.warn(\n `Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`,\n );\n await this.initialize();\n } else {\n await sleep(this.sleepTime);\n await this.update();\n }\n }\n } catch (e) {\n console.error(\"error in synchronizing this account sequence number with the one on chain\", e);\n } finally {\n this.lock = false;\n }\n }\n}\n"],"mappings":"kFA+BA,IAAMA,EAAM,IAAM,KAAK,MAAM,KAAK,IAAI,EAAI,GAAI,EAEjCC,EAAN,KAA4B,CA8BjC,YACEC,EACAC,EACAC,EACAC,EACAC,EACA,CA9BF,2BAAuC,KAGvC,mBAA+B,KAa/B,UAAO,GAeL,KAAK,YAAcJ,EACnB,KAAK,QAAUC,EACf,KAAK,YAAcC,EACnB,KAAK,gBAAkBC,EACvB,KAAK,UAAYC,CACnB,CAOA,MAAM,oBAA6C,CAEjD,KAAO,KAAK,MACV,MA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wBAA0B,KAAK,eACrCA,EAAI,EAAIS,EAAY,KAAK,aAE3B,QAAQ,KACN,iEAAiE,KAAK,QAAQ,eAAe,SAAS,CAAC,EACzG,EACA,MAAM,KAAK,WAAW,IAEtB,MAAMF,EAAM,KAAK,SAAS,EAC1B,MAAM,KAAK,OAAO,EAGxB,OAASG,EAAG,CACV,QAAQ,MAAM,4EAA6EA,CAAC,CAC9F,QAAE,CACA,KAAK,KAAO,EACd,EACF,CACF","names":["now","AccountSequenceNumber","aptosConfig","account","maxWaitTime","maximumInFlight","sleepTime","sleep","nextNumber","startTime","e","sequenceNumber","getInfo"]}
@@ -1,2 +0,0 @@
1
- import{a}from"../../chunk-LYOUEPDG.mjs";import"../../chunk-KGHBTSDR.mjs";import"../../chunk-4NMDYPUD.mjs";import"../../chunk-2BDKITTE.mjs";import"../../chunk-YDNOKWV3.mjs";import"../../chunk-UYVPNUH3.mjs";import"../../chunk-YRUF6N3U.mjs";import"../../chunk-472OGHMG.mjs";import"../../chunk-FIG65OJD.mjs";import"../../chunk-MLX6DFMR.mjs";import"../../chunk-NW3WUTTD.mjs";import"../../chunk-TUCCV62K.mjs";import"../../chunk-GSCM444Z.mjs";import"../../chunk-IXFYYWAC.mjs";import"../../chunk-7SOLAI6Q.mjs";import"../../chunk-J63BIFB7.mjs";import"../../chunk-RFSO3JRG.mjs";import"../../chunk-YE5B2S5L.mjs";import"../../chunk-AQ4I7VVB.mjs";import"../../chunk-SNDFJWYM.mjs";import"../../chunk-66G6MKI6.mjs";import"../../chunk-O3BRX56F.mjs";import"../../chunk-BO44HPGU.mjs";import"../../chunk-UKKHWC4Y.mjs";import"../../chunk-37FFZSIM.mjs";import"../../chunk-L5CPAOUM.mjs";import"../../chunk-IVVWQKCF.mjs";import"../../chunk-KUX6GQ2E.mjs";import"../../chunk-XVZBWW46.mjs";import"../../chunk-WA2NTBYY.mjs";import"../../chunk-4VPCPASN.mjs";import"../../chunk-TJDC5PWD.mjs";import"../../chunk-LR65XHSF.mjs";import"../../chunk-EFMAZTIM.mjs";import"../../chunk-F3ZVWLDH.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-GRHLQDHF.mjs";import"../../chunk-7BW2N4IE.mjs";import"../../chunk-FGGRPEQ3.mjs";import"../../chunk-IBN7ETCB.mjs";import"../../chunk-Q6LFIZ3L.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-3IFR6T3V.mjs";import"../../chunk-UMLUOYFK.mjs";import"../../chunk-AOCNYMMX.mjs";import"../../chunk-FBPNHF54.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-FVA2OPG4.mjs";export{a as CryptoHashable};
2
- //# sourceMappingURL=cryptoHasher.mjs.map