@aptos-labs/ts-sdk 1.28.0 → 1.29.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 (337) hide show
  1. package/README.md +103 -82
  2. package/dist/common/{accountAddress-OVl7-qVN.d.ts → accountAddress-DUCC2ffJ.d.ts} +9 -2
  3. package/dist/common/cli/index.d.ts +1 -1
  4. package/dist/common/index.d.ts +266 -42
  5. package/dist/common/index.js +28 -28
  6. package/dist/common/index.js.map +1 -1
  7. package/dist/esm/account/AbstractKeylessAccount.d.mts +207 -0
  8. package/dist/esm/account/AbstractKeylessAccount.mjs +2 -0
  9. package/dist/esm/account/Account.mjs +1 -1
  10. package/dist/esm/account/Ed25519Account.mjs +1 -1
  11. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  12. package/dist/esm/account/FederatedKeylessAccount.d.mts +75 -0
  13. package/dist/esm/account/FederatedKeylessAccount.mjs +2 -0
  14. package/dist/esm/account/KeylessAccount.d.mts +13 -130
  15. package/dist/esm/account/KeylessAccount.mjs +1 -1
  16. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  17. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  18. package/dist/esm/account/index.d.mts +4 -1
  19. package/dist/esm/account/index.mjs +1 -1
  20. package/dist/esm/api/account.d.mts +1 -1
  21. package/dist/esm/api/account.mjs +1 -1
  22. package/dist/esm/api/ans.mjs +1 -1
  23. package/dist/esm/api/aptos.d.mts +4 -0
  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.d.mts +1 -1
  30. package/dist/esm/api/event.mjs +1 -1
  31. package/dist/esm/api/faucet.mjs +1 -1
  32. package/dist/esm/api/fungibleAsset.d.mts +1 -1
  33. package/dist/esm/api/fungibleAsset.mjs +1 -1
  34. package/dist/esm/api/general.d.mts +2 -2
  35. package/dist/esm/api/general.mjs +1 -1
  36. package/dist/esm/api/index.d.mts +4 -0
  37. package/dist/esm/api/index.mjs +1 -1
  38. package/dist/esm/api/keyless.d.mts +34 -20
  39. package/dist/esm/api/keyless.mjs +1 -1
  40. package/dist/esm/api/object.d.mts +2 -2
  41. package/dist/esm/api/object.mjs +1 -1
  42. package/dist/esm/api/staking.d.mts +2 -2
  43. package/dist/esm/api/staking.mjs +1 -1
  44. package/dist/esm/api/table.d.mts +1 -1
  45. package/dist/esm/api/table.mjs +1 -1
  46. package/dist/esm/api/transaction.d.mts +33 -9
  47. package/dist/esm/api/transaction.mjs +1 -1
  48. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  49. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  50. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  51. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  52. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  53. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  54. package/dist/esm/api/utils.mjs +1 -1
  55. package/dist/esm/bcs/index.mjs +1 -1
  56. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  57. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  58. package/dist/esm/{chunk-OTNGLTKS.mjs → chunk-2BTTX2KO.mjs} +2 -2
  59. package/dist/esm/{chunk-NPFW6ZFY.mjs → chunk-2F7Z7RMW.mjs} +2 -2
  60. package/dist/esm/{chunk-P2EKDA7R.mjs → chunk-367OG3DB.mjs} +2 -2
  61. package/dist/esm/{chunk-5L3UXSQI.mjs → chunk-3W2DHZXK.mjs} +2 -2
  62. package/dist/esm/chunk-44GYWUSH.mjs +2 -0
  63. package/dist/esm/chunk-44GYWUSH.mjs.map +1 -0
  64. package/dist/esm/{chunk-UWPO7WWS.mjs → chunk-45IUUCAV.mjs} +2 -2
  65. package/dist/esm/{chunk-YFMFXRJX.mjs → chunk-4HR32TSY.mjs} +2 -2
  66. package/dist/esm/chunk-4TB3AWQE.mjs +2 -0
  67. package/dist/esm/chunk-4TB3AWQE.mjs.map +1 -0
  68. package/dist/esm/{chunk-3HTSCV3R.mjs → chunk-53RB2PRH.mjs} +2 -2
  69. package/dist/esm/{chunk-GKERWKMB.mjs → chunk-5PCNWXRN.mjs} +2 -2
  70. package/dist/esm/{chunk-OPTI3MH2.mjs → chunk-5VD4MHB3.mjs} +2 -2
  71. package/dist/esm/{chunk-VTEZ6TBO.mjs → chunk-6UZ3VI5Y.mjs} +2 -2
  72. package/dist/esm/{chunk-Z2AJWV6D.mjs → chunk-7VKFXX5Q.mjs} +2 -2
  73. package/dist/esm/{chunk-GR4PHW7K.mjs → chunk-A42BPAD4.mjs} +2 -2
  74. package/dist/esm/{chunk-QQHA2Y46.mjs → chunk-ADE6MVXC.mjs} +2 -2
  75. package/dist/esm/chunk-ADE6MVXC.mjs.map +1 -0
  76. package/dist/esm/{chunk-2CAGPXCX.mjs → chunk-APN6AV5Q.mjs} +2 -2
  77. package/dist/esm/chunk-BA4RBST6.mjs +2 -0
  78. package/dist/esm/chunk-BA4RBST6.mjs.map +1 -0
  79. package/dist/esm/{chunk-4ENUSVZB.mjs → chunk-BSAHPS6E.mjs} +2 -2
  80. package/dist/esm/{chunk-NDJKEFNU.mjs → chunk-BWNTSJOC.mjs} +2 -2
  81. package/dist/esm/chunk-CB6H4VMZ.mjs +2 -0
  82. package/dist/esm/chunk-CB6H4VMZ.mjs.map +1 -0
  83. package/dist/esm/{chunk-LS6G4DZV.mjs → chunk-CRA2MFJC.mjs} +2 -2
  84. package/dist/esm/{chunk-VQVNUN5Y.mjs → chunk-D3Q4BC3I.mjs} +2 -2
  85. package/dist/esm/chunk-E4O26ZJB.mjs +2 -0
  86. package/dist/esm/chunk-E4O26ZJB.mjs.map +1 -0
  87. package/dist/esm/{chunk-5TBIWC7N.mjs → chunk-ELYS7CWV.mjs} +2 -2
  88. package/dist/esm/chunk-F3M2UQA4.mjs +2 -0
  89. package/dist/esm/chunk-F3M2UQA4.mjs.map +1 -0
  90. package/dist/esm/{chunk-ZXYTLPP6.mjs → chunk-F63E4CR7.mjs} +2 -2
  91. package/dist/esm/{chunk-JOROI7FE.mjs → chunk-F76N4MQO.mjs} +2 -2
  92. package/dist/esm/{chunk-F5PNGH44.mjs → chunk-FZ5EYP3D.mjs} +2 -2
  93. package/dist/esm/chunk-G5XLMQ5E.mjs +2 -0
  94. package/dist/esm/chunk-G5XLMQ5E.mjs.map +1 -0
  95. package/dist/esm/chunk-GAEAYY44.mjs +1 -0
  96. package/dist/esm/chunk-GAEAYY44.mjs.map +1 -0
  97. package/dist/esm/{chunk-O4BBULNE.mjs → chunk-GDO6Q2FI.mjs} +2 -2
  98. package/dist/esm/{chunk-WYQLUB4H.mjs → chunk-GDUAFXIQ.mjs} +2 -2
  99. package/dist/esm/chunk-GMBSQDPO.mjs +2 -0
  100. package/dist/esm/chunk-GMBSQDPO.mjs.map +1 -0
  101. package/dist/esm/{chunk-Q7MD4V7H.mjs → chunk-GWSDIX6C.mjs} +2 -2
  102. package/dist/esm/chunk-HEZ2ZYZA.mjs +1 -0
  103. package/dist/esm/chunk-HEZ2ZYZA.mjs.map +1 -0
  104. package/dist/esm/{chunk-WX6P3Q4I.mjs → chunk-HHGJXVAE.mjs} +2 -2
  105. package/dist/esm/{chunk-AVSM2BJR.mjs → chunk-HKBBA653.mjs} +2 -2
  106. package/dist/esm/{chunk-6CHBLB3V.mjs → chunk-HVMFZF6P.mjs} +2 -2
  107. package/dist/esm/{chunk-ZNC3FRSK.mjs → chunk-IR4SLC2M.mjs} +2 -2
  108. package/dist/esm/{chunk-GGPA6QTN.mjs → chunk-J64ARI4E.mjs} +2 -2
  109. package/dist/esm/{chunk-3F3FCWT5.mjs → chunk-JH6VLTMS.mjs} +2 -2
  110. package/dist/esm/{chunk-ORGMRM5K.mjs → chunk-KUOB4DDE.mjs} +2 -2
  111. package/dist/esm/{chunk-2XYA7NOU.mjs → chunk-KUZ2YTJH.mjs} +2 -2
  112. package/dist/esm/{chunk-HBQLX5QF.mjs → chunk-L2QXU6F4.mjs} +2 -2
  113. package/dist/esm/{chunk-QQU4IQ27.mjs → chunk-LNEZEYYE.mjs} +2 -2
  114. package/dist/esm/{chunk-53DBMWMU.mjs → chunk-MAMPMCO7.mjs} +2 -2
  115. package/dist/esm/chunk-MDJ66AA3.mjs +2 -0
  116. package/dist/esm/chunk-MDJ66AA3.mjs.map +1 -0
  117. package/dist/esm/{chunk-56F7EYFE.mjs → chunk-MNVUSJEK.mjs} +2 -2
  118. package/dist/esm/{chunk-SUAA25UP.mjs → chunk-O2BPA6TS.mjs} +2 -2
  119. package/dist/esm/{chunk-NKDHR2DA.mjs → chunk-OKAQO57B.mjs} +2 -2
  120. package/dist/esm/chunk-OMV7445F.mjs +2 -0
  121. package/dist/esm/chunk-OMV7445F.mjs.map +1 -0
  122. package/dist/esm/chunk-P2EIZ7WL.mjs +2 -0
  123. package/dist/esm/chunk-P2EIZ7WL.mjs.map +1 -0
  124. package/dist/esm/{chunk-PDNA4H34.mjs → chunk-P3TAY5PP.mjs} +2 -2
  125. package/dist/esm/{chunk-EJMPY5MF.mjs → chunk-Q3TAEOH5.mjs} +2 -2
  126. package/dist/esm/chunk-Q4XR6QOZ.mjs +2 -0
  127. package/dist/esm/{chunk-F7EMGK4M.mjs.map → chunk-Q4XR6QOZ.mjs.map} +1 -1
  128. package/dist/esm/{chunk-MNVDBUF3.mjs → chunk-QBSU3L5Q.mjs} +2 -2
  129. package/dist/esm/{chunk-3GOJQ5JD.mjs → chunk-QPB6EJVM.mjs} +2 -2
  130. package/dist/esm/{chunk-KRIIRH5L.mjs → chunk-R76DHMGR.mjs} +2 -2
  131. package/dist/esm/{chunk-52HZTDBB.mjs → chunk-RXE6NNOL.mjs} +2 -2
  132. package/dist/esm/chunk-RXE6NNOL.mjs.map +1 -0
  133. package/dist/esm/{chunk-JUNVPIW4.mjs → chunk-S2KDCIZN.mjs} +2 -2
  134. package/dist/esm/{chunk-YPQZJ72F.mjs → chunk-S2W4D6NZ.mjs} +2 -2
  135. package/dist/esm/{chunk-5P7MXLZA.mjs → chunk-SDWE6WMM.mjs} +2 -2
  136. package/dist/esm/chunk-SRPI2FFA.mjs +2 -0
  137. package/dist/esm/chunk-SRPI2FFA.mjs.map +1 -0
  138. package/dist/esm/chunk-STUXKQVZ.mjs +2 -0
  139. package/dist/esm/chunk-STUXKQVZ.mjs.map +1 -0
  140. package/dist/esm/{chunk-WLZYSLHP.mjs → chunk-SWNFKKRE.mjs} +2 -2
  141. package/dist/esm/{chunk-DVIRUFCY.mjs → chunk-TQWGQLM6.mjs} +2 -2
  142. package/dist/esm/chunk-UAEODDZS.mjs +2 -0
  143. package/dist/esm/{chunk-ZXVQ2OBJ.mjs.map → chunk-UAEODDZS.mjs.map} +1 -1
  144. package/dist/esm/{chunk-VYXJ7FUF.mjs → chunk-WJRZWAIS.mjs} +2 -2
  145. package/dist/esm/{chunk-LFUBUXHD.mjs → chunk-X34JJPW5.mjs} +2 -2
  146. package/dist/esm/{chunk-EXMQBH3I.mjs → chunk-XMW65WCQ.mjs} +2 -2
  147. package/dist/esm/chunk-Y2GWUE7C.mjs +2 -0
  148. package/dist/esm/chunk-Y2GWUE7C.mjs.map +1 -0
  149. package/dist/esm/chunk-Y3BATGHX.mjs +2 -0
  150. package/dist/esm/chunk-Y3BATGHX.mjs.map +1 -0
  151. package/dist/esm/{chunk-54QUDAAC.mjs → chunk-YU3IYJRL.mjs} +2 -2
  152. package/dist/esm/{chunk-NBO2BDDZ.mjs → chunk-ZROQH5YL.mjs} +2 -2
  153. package/dist/esm/cli/index.mjs +1 -1
  154. package/dist/esm/client/core.mjs +1 -1
  155. package/dist/esm/client/get.mjs +1 -1
  156. package/dist/esm/client/index.mjs +1 -1
  157. package/dist/esm/client/post.mjs +1 -1
  158. package/dist/esm/core/account/index.mjs +1 -1
  159. package/dist/esm/core/account/utils/address.mjs +1 -1
  160. package/dist/esm/core/account/utils/index.mjs +1 -1
  161. package/dist/esm/core/accountAddress.mjs +1 -1
  162. package/dist/esm/core/authenticationKey.mjs +1 -1
  163. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  164. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  165. package/dist/esm/core/crypto/federatedKeyless.d.mts +97 -0
  166. package/dist/esm/core/crypto/federatedKeyless.mjs +2 -0
  167. package/dist/esm/core/crypto/federatedKeyless.mjs.map +1 -0
  168. package/dist/esm/core/crypto/index.d.mts +4 -2
  169. package/dist/esm/core/crypto/index.mjs +1 -1
  170. package/dist/esm/core/crypto/keyless.mjs +1 -1
  171. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  172. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  173. package/dist/esm/core/crypto/poseidon.d.mts +1 -1
  174. package/dist/esm/core/crypto/poseidon.mjs +1 -1
  175. package/dist/esm/core/crypto/proof.mjs +1 -1
  176. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  177. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  178. package/dist/esm/core/crypto/signature.mjs +1 -1
  179. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  180. package/dist/esm/core/crypto/utils.mjs +1 -1
  181. package/dist/esm/core/index.d.mts +2 -0
  182. package/dist/esm/core/index.mjs +1 -1
  183. package/dist/esm/index.d.mts +6 -1
  184. package/dist/esm/index.mjs +1 -1
  185. package/dist/esm/internal/account.d.mts +1 -7
  186. package/dist/esm/internal/account.mjs +1 -1
  187. package/dist/esm/internal/ans.mjs +1 -1
  188. package/dist/esm/internal/coin.mjs +1 -1
  189. package/dist/esm/internal/digitalAsset.mjs +1 -1
  190. package/dist/esm/internal/event.mjs +1 -1
  191. package/dist/esm/internal/faucet.mjs +1 -1
  192. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  193. package/dist/esm/internal/general.mjs +1 -1
  194. package/dist/esm/internal/keyless.d.mts +25 -14
  195. package/dist/esm/internal/keyless.mjs +1 -1
  196. package/dist/esm/internal/object.mjs +1 -1
  197. package/dist/esm/internal/staking.mjs +1 -1
  198. package/dist/esm/internal/table.mjs +1 -1
  199. package/dist/esm/internal/transaction.mjs +1 -1
  200. package/dist/esm/internal/transactionSubmission.d.mts +22 -2
  201. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  202. package/dist/esm/internal/view.mjs +1 -1
  203. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  204. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  205. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  206. package/dist/esm/transactions/index.mjs +1 -1
  207. package/dist/esm/transactions/instances/index.mjs +1 -1
  208. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  209. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  210. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  211. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  212. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  213. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  214. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  215. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  216. package/dist/esm/transactions/management/index.mjs +1 -1
  217. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  218. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  219. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  220. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  221. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  222. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  223. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  224. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  225. package/dist/esm/types/index.d.mts +8 -1
  226. package/dist/esm/types/index.mjs +1 -1
  227. package/dist/esm/utils/index.mjs +1 -1
  228. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  229. package/dist/esm/version.d.mts +1 -1
  230. package/dist/esm/version.mjs +1 -1
  231. package/package.json +1 -1
  232. package/src/account/AbstractKeylessAccount.ts +329 -0
  233. package/src/account/EphemeralKeyPair.ts +9 -2
  234. package/src/account/FederatedKeylessAccount.ts +116 -0
  235. package/src/account/KeylessAccount.ts +13 -297
  236. package/src/account/MultiKeyAccount.ts +4 -2
  237. package/src/account/index.ts +2 -0
  238. package/src/api/account.ts +68 -22
  239. package/src/api/keyless.ts +50 -4
  240. package/src/api/transaction.ts +40 -20
  241. package/src/core/crypto/federatedKeyless.ts +134 -0
  242. package/src/core/crypto/index.ts +2 -0
  243. package/src/core/crypto/keyless.ts +4 -3
  244. package/src/core/crypto/poseidon.ts +4 -4
  245. package/src/core/crypto/singleKey.ts +6 -0
  246. package/src/core/crypto/utils.ts +2 -2
  247. package/src/internal/account.ts +1 -54
  248. package/src/internal/keyless.ts +86 -8
  249. package/src/internal/transactionSubmission.ts +63 -10
  250. package/src/transactions/transactionBuilder/transactionBuilder.ts +25 -14
  251. package/src/types/index.ts +7 -0
  252. package/src/version.ts +1 -1
  253. package/dist/esm/chunk-52HZTDBB.mjs.map +0 -1
  254. package/dist/esm/chunk-7Z6DYLCA.mjs +0 -1
  255. package/dist/esm/chunk-AQ4I7VVB.mjs +0 -1
  256. package/dist/esm/chunk-BIGX2RJL.mjs +0 -2
  257. package/dist/esm/chunk-BIGX2RJL.mjs.map +0 -1
  258. package/dist/esm/chunk-DCNBMUKN.mjs +0 -2
  259. package/dist/esm/chunk-DCNBMUKN.mjs.map +0 -1
  260. package/dist/esm/chunk-EQSON7Y5.mjs +0 -2
  261. package/dist/esm/chunk-EQSON7Y5.mjs.map +0 -1
  262. package/dist/esm/chunk-F7EMGK4M.mjs +0 -2
  263. package/dist/esm/chunk-G773HST5.mjs +0 -2
  264. package/dist/esm/chunk-G773HST5.mjs.map +0 -1
  265. package/dist/esm/chunk-IVOEXGOG.mjs +0 -2
  266. package/dist/esm/chunk-IVOEXGOG.mjs.map +0 -1
  267. package/dist/esm/chunk-IVVWQKCF.mjs +0 -2
  268. package/dist/esm/chunk-IVVWQKCF.mjs.map +0 -1
  269. package/dist/esm/chunk-LJZPPBTH.mjs +0 -2
  270. package/dist/esm/chunk-LJZPPBTH.mjs.map +0 -1
  271. package/dist/esm/chunk-QQHA2Y46.mjs.map +0 -1
  272. package/dist/esm/chunk-SCYGW3VV.mjs +0 -2
  273. package/dist/esm/chunk-SCYGW3VV.mjs.map +0 -1
  274. package/dist/esm/chunk-T53MZO2U.mjs +0 -2
  275. package/dist/esm/chunk-T53MZO2U.mjs.map +0 -1
  276. package/dist/esm/chunk-VYXS7TLB.mjs +0 -2
  277. package/dist/esm/chunk-VYXS7TLB.mjs.map +0 -1
  278. package/dist/esm/chunk-XSTCHOUI.mjs +0 -2
  279. package/dist/esm/chunk-XSTCHOUI.mjs.map +0 -1
  280. package/dist/esm/chunk-ZWX3NHGU.mjs +0 -2
  281. package/dist/esm/chunk-ZWX3NHGU.mjs.map +0 -1
  282. package/dist/esm/chunk-ZXVQ2OBJ.mjs +0 -2
  283. /package/dist/esm/{chunk-7Z6DYLCA.mjs.map → account/AbstractKeylessAccount.mjs.map} +0 -0
  284. /package/dist/esm/{chunk-AQ4I7VVB.mjs.map → account/FederatedKeylessAccount.mjs.map} +0 -0
  285. /package/dist/esm/{chunk-OTNGLTKS.mjs.map → chunk-2BTTX2KO.mjs.map} +0 -0
  286. /package/dist/esm/{chunk-NPFW6ZFY.mjs.map → chunk-2F7Z7RMW.mjs.map} +0 -0
  287. /package/dist/esm/{chunk-P2EKDA7R.mjs.map → chunk-367OG3DB.mjs.map} +0 -0
  288. /package/dist/esm/{chunk-5L3UXSQI.mjs.map → chunk-3W2DHZXK.mjs.map} +0 -0
  289. /package/dist/esm/{chunk-UWPO7WWS.mjs.map → chunk-45IUUCAV.mjs.map} +0 -0
  290. /package/dist/esm/{chunk-YFMFXRJX.mjs.map → chunk-4HR32TSY.mjs.map} +0 -0
  291. /package/dist/esm/{chunk-3HTSCV3R.mjs.map → chunk-53RB2PRH.mjs.map} +0 -0
  292. /package/dist/esm/{chunk-GKERWKMB.mjs.map → chunk-5PCNWXRN.mjs.map} +0 -0
  293. /package/dist/esm/{chunk-OPTI3MH2.mjs.map → chunk-5VD4MHB3.mjs.map} +0 -0
  294. /package/dist/esm/{chunk-VTEZ6TBO.mjs.map → chunk-6UZ3VI5Y.mjs.map} +0 -0
  295. /package/dist/esm/{chunk-Z2AJWV6D.mjs.map → chunk-7VKFXX5Q.mjs.map} +0 -0
  296. /package/dist/esm/{chunk-GR4PHW7K.mjs.map → chunk-A42BPAD4.mjs.map} +0 -0
  297. /package/dist/esm/{chunk-2CAGPXCX.mjs.map → chunk-APN6AV5Q.mjs.map} +0 -0
  298. /package/dist/esm/{chunk-4ENUSVZB.mjs.map → chunk-BSAHPS6E.mjs.map} +0 -0
  299. /package/dist/esm/{chunk-NDJKEFNU.mjs.map → chunk-BWNTSJOC.mjs.map} +0 -0
  300. /package/dist/esm/{chunk-LS6G4DZV.mjs.map → chunk-CRA2MFJC.mjs.map} +0 -0
  301. /package/dist/esm/{chunk-VQVNUN5Y.mjs.map → chunk-D3Q4BC3I.mjs.map} +0 -0
  302. /package/dist/esm/{chunk-5TBIWC7N.mjs.map → chunk-ELYS7CWV.mjs.map} +0 -0
  303. /package/dist/esm/{chunk-ZXYTLPP6.mjs.map → chunk-F63E4CR7.mjs.map} +0 -0
  304. /package/dist/esm/{chunk-JOROI7FE.mjs.map → chunk-F76N4MQO.mjs.map} +0 -0
  305. /package/dist/esm/{chunk-F5PNGH44.mjs.map → chunk-FZ5EYP3D.mjs.map} +0 -0
  306. /package/dist/esm/{chunk-O4BBULNE.mjs.map → chunk-GDO6Q2FI.mjs.map} +0 -0
  307. /package/dist/esm/{chunk-WYQLUB4H.mjs.map → chunk-GDUAFXIQ.mjs.map} +0 -0
  308. /package/dist/esm/{chunk-Q7MD4V7H.mjs.map → chunk-GWSDIX6C.mjs.map} +0 -0
  309. /package/dist/esm/{chunk-WX6P3Q4I.mjs.map → chunk-HHGJXVAE.mjs.map} +0 -0
  310. /package/dist/esm/{chunk-AVSM2BJR.mjs.map → chunk-HKBBA653.mjs.map} +0 -0
  311. /package/dist/esm/{chunk-6CHBLB3V.mjs.map → chunk-HVMFZF6P.mjs.map} +0 -0
  312. /package/dist/esm/{chunk-ZNC3FRSK.mjs.map → chunk-IR4SLC2M.mjs.map} +0 -0
  313. /package/dist/esm/{chunk-GGPA6QTN.mjs.map → chunk-J64ARI4E.mjs.map} +0 -0
  314. /package/dist/esm/{chunk-3F3FCWT5.mjs.map → chunk-JH6VLTMS.mjs.map} +0 -0
  315. /package/dist/esm/{chunk-ORGMRM5K.mjs.map → chunk-KUOB4DDE.mjs.map} +0 -0
  316. /package/dist/esm/{chunk-2XYA7NOU.mjs.map → chunk-KUZ2YTJH.mjs.map} +0 -0
  317. /package/dist/esm/{chunk-HBQLX5QF.mjs.map → chunk-L2QXU6F4.mjs.map} +0 -0
  318. /package/dist/esm/{chunk-QQU4IQ27.mjs.map → chunk-LNEZEYYE.mjs.map} +0 -0
  319. /package/dist/esm/{chunk-53DBMWMU.mjs.map → chunk-MAMPMCO7.mjs.map} +0 -0
  320. /package/dist/esm/{chunk-56F7EYFE.mjs.map → chunk-MNVUSJEK.mjs.map} +0 -0
  321. /package/dist/esm/{chunk-SUAA25UP.mjs.map → chunk-O2BPA6TS.mjs.map} +0 -0
  322. /package/dist/esm/{chunk-NKDHR2DA.mjs.map → chunk-OKAQO57B.mjs.map} +0 -0
  323. /package/dist/esm/{chunk-PDNA4H34.mjs.map → chunk-P3TAY5PP.mjs.map} +0 -0
  324. /package/dist/esm/{chunk-EJMPY5MF.mjs.map → chunk-Q3TAEOH5.mjs.map} +0 -0
  325. /package/dist/esm/{chunk-MNVDBUF3.mjs.map → chunk-QBSU3L5Q.mjs.map} +0 -0
  326. /package/dist/esm/{chunk-3GOJQ5JD.mjs.map → chunk-QPB6EJVM.mjs.map} +0 -0
  327. /package/dist/esm/{chunk-KRIIRH5L.mjs.map → chunk-R76DHMGR.mjs.map} +0 -0
  328. /package/dist/esm/{chunk-JUNVPIW4.mjs.map → chunk-S2KDCIZN.mjs.map} +0 -0
  329. /package/dist/esm/{chunk-YPQZJ72F.mjs.map → chunk-S2W4D6NZ.mjs.map} +0 -0
  330. /package/dist/esm/{chunk-5P7MXLZA.mjs.map → chunk-SDWE6WMM.mjs.map} +0 -0
  331. /package/dist/esm/{chunk-WLZYSLHP.mjs.map → chunk-SWNFKKRE.mjs.map} +0 -0
  332. /package/dist/esm/{chunk-DVIRUFCY.mjs.map → chunk-TQWGQLM6.mjs.map} +0 -0
  333. /package/dist/esm/{chunk-VYXJ7FUF.mjs.map → chunk-WJRZWAIS.mjs.map} +0 -0
  334. /package/dist/esm/{chunk-LFUBUXHD.mjs.map → chunk-X34JJPW5.mjs.map} +0 -0
  335. /package/dist/esm/{chunk-EXMQBH3I.mjs.map → chunk-XMW65WCQ.mjs.map} +0 -0
  336. /package/dist/esm/{chunk-54QUDAAC.mjs.map → chunk-YU3IYJRL.mjs.map} +0 -0
  337. /package/dist/esm/{chunk-NBO2BDDZ.mjs.map → chunk-ZROQH5YL.mjs.map} +0 -0
@@ -21,10 +21,13 @@ import {
21
21
  WaitForTransactionOptions,
22
22
  } from "../types";
23
23
  import {
24
+ FeePayerOrFeePayerAuthenticatorOrNeither,
24
25
  getSigningMessage,
25
26
  publicPackageTransaction,
26
27
  rotateAuthKey,
28
+ signAndSubmitAsFeePayer,
27
29
  signAndSubmitTransaction,
30
+ signAsFeePayer,
28
31
  signTransaction,
29
32
  } from "../internal/transactionSubmission";
30
33
  import {
@@ -290,20 +293,8 @@ export class Transaction {
290
293
  */
291
294
  // eslint-disable-next-line class-methods-use-this
292
295
  signAsFeePayer(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {
293
- const { signer, transaction } = args;
294
-
295
- // if transaction doesnt hold a "feePayerAddress" prop it means
296
- // this is not a fee payer transaction
297
- if (!transaction.feePayerAddress) {
298
- throw new Error(`Transaction ${transaction} is not a Fee Payer transaction`);
299
- }
300
-
301
- // Set the feePayerAddress to the signer account address
302
- transaction.feePayerAddress = signer.accountAddress;
303
-
304
- return signTransaction({
305
- signer,
306
- transaction,
296
+ return signAsFeePayer({
297
+ ...args,
307
298
  });
308
299
  }
309
300
 
@@ -355,15 +346,44 @@ export class Transaction {
355
346
  *
356
347
  * @return PendingTransactionResponse
357
348
  */
358
- async signAndSubmitTransaction(args: {
359
- signer: Account;
349
+ async signAndSubmitTransaction(
350
+ args: FeePayerOrFeePayerAuthenticatorOrNeither & {
351
+ signer: Account;
352
+ transaction: AnyRawTransaction;
353
+ },
354
+ ): Promise<PendingTransactionResponse> {
355
+ return signAndSubmitTransaction({
356
+ aptosConfig: this.config,
357
+ ...args,
358
+ });
359
+ }
360
+
361
+ /**
362
+ * Sign and submit a single signer transaction as the fee payer to chain given an authenticator by the sender of the transaction.
363
+ *
364
+ * @param args.feePayer The fee payer account to sign the transaction
365
+ * @param args.senderAuthenticator The AccountAuthenticator signed by the sender of the transaction
366
+ * @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses
367
+ *
368
+ * @example
369
+ * const transaction = await aptos.transaction.build.simple({sender: alice.accountAddress, feePayer: true ...})
370
+ * const senderAuthenticator = alice.signTransactionWithAuthenticator(transaction)
371
+ * const pendingTransaction = await aptos.signAndSubmitAsFeePayer({
372
+ * senderAuthenticator,
373
+ * feePayer: bob,
374
+ * transaction,
375
+ * })
376
+ *
377
+ * @return PendingTransactionResponse
378
+ */
379
+ async signAndSubmitAsFeePayer(args: {
380
+ feePayer: Account;
381
+ senderAuthenticator: AccountAuthenticator;
360
382
  transaction: AnyRawTransaction;
361
383
  }): Promise<PendingTransactionResponse> {
362
- const { signer, transaction } = args;
363
- return signAndSubmitTransaction({
384
+ return signAndSubmitAsFeePayer({
364
385
  aptosConfig: this.config,
365
- signer,
366
- transaction,
386
+ ...args,
367
387
  });
368
388
  }
369
389
  }
@@ -0,0 +1,134 @@
1
+ // Copyright © Aptos Foundation
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { AccountPublicKey, PublicKey } from "./publicKey";
5
+ import { Deserializer, Serializer } from "../../bcs";
6
+ import { Hex } from "../hex";
7
+ import { HexInput, AnyPublicKeyVariant, SigningScheme } from "../../types";
8
+ import { AuthenticationKey } from "../authenticationKey";
9
+ import { AccountAddress, AccountAddressInput } from "../accountAddress";
10
+ import { KeylessPublicKey, KeylessSignature } from "./keyless";
11
+
12
+ /**
13
+ * Represents the FederatedKeylessPublicKey public key
14
+ *
15
+ * These keys use an onchain address as a source of truth for the JWK used to verify signatures.
16
+ *
17
+ * FederatedKeylessPublicKey authentication key is represented in the SDK as `AnyPublicKey`.
18
+ */
19
+ export class FederatedKeylessPublicKey extends AccountPublicKey {
20
+ /**
21
+ * The address that contains the JWK set to be used for verification.
22
+ */
23
+ readonly jwkAddress: AccountAddress;
24
+
25
+ /**
26
+ * The inner public key which contains the standard Keyless public key.
27
+ */
28
+ readonly keylessPublicKey: KeylessPublicKey;
29
+
30
+ constructor(jwkAddress: AccountAddressInput, keylessPublicKey: KeylessPublicKey) {
31
+ super();
32
+ this.jwkAddress = AccountAddress.from(jwkAddress);
33
+ this.keylessPublicKey = keylessPublicKey;
34
+ }
35
+
36
+ /**
37
+ * Get the authentication key for the federated keyless public key
38
+ *
39
+ * @returns AuthenticationKey
40
+ */
41
+ authKey(): AuthenticationKey {
42
+ const serializer = new Serializer();
43
+ serializer.serializeU32AsUleb128(AnyPublicKeyVariant.FederatedKeyless);
44
+ serializer.serializeFixedBytes(this.bcsToBytes());
45
+ return AuthenticationKey.fromSchemeAndBytes({
46
+ scheme: SigningScheme.SingleKey,
47
+ input: serializer.toUint8Array(),
48
+ });
49
+ }
50
+
51
+ /**
52
+ * Get the public key in bytes (Uint8Array).
53
+ *
54
+ * @returns Uint8Array representation of the public key
55
+ */
56
+ toUint8Array(): Uint8Array {
57
+ return this.bcsToBytes();
58
+ }
59
+
60
+ /**
61
+ * Get the public key as a hex string with the 0x prefix.
62
+ *
63
+ * @returns string representation of the public key
64
+ */
65
+ toString(): string {
66
+ return Hex.fromHexInput(this.toUint8Array()).toString();
67
+ }
68
+
69
+ /**
70
+ * Verifies a signed data with a public key
71
+ *
72
+ * @param args.message message
73
+ * @param args.signature The signature
74
+ * @returns true if the signature is valid
75
+ */
76
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
77
+ verifySignature(args: { message: HexInput; signature: KeylessSignature }): boolean {
78
+ throw new Error("Not yet implemented");
79
+ }
80
+
81
+ serialize(serializer: Serializer): void {
82
+ this.jwkAddress.serialize(serializer);
83
+ this.keylessPublicKey.serialize(serializer);
84
+ }
85
+
86
+ static deserialize(deserializer: Deserializer): FederatedKeylessPublicKey {
87
+ const jwkAddress = AccountAddress.deserialize(deserializer);
88
+ const keylessPublicKey = KeylessPublicKey.deserialize(deserializer);
89
+ return new FederatedKeylessPublicKey(jwkAddress, keylessPublicKey);
90
+ }
91
+
92
+ static isPublicKey(publicKey: PublicKey): publicKey is FederatedKeylessPublicKey {
93
+ return publicKey instanceof FederatedKeylessPublicKey;
94
+ }
95
+
96
+ /**
97
+ * Creates a FederatedKeylessPublicKey from the JWT components plus pepper
98
+ *
99
+ * @param args.iss the iss of the identity
100
+ * @param args.uidKey the key to use to get the uidVal in the JWT token
101
+ * @param args.uidVal the value of the uidKey in the JWT token
102
+ * @param args.aud the client ID of the application
103
+ * @param args.pepper The pepper used to maintain privacy of the account
104
+ * @returns FederatedKeylessPublicKey
105
+ */
106
+ static create(args: {
107
+ iss: string;
108
+ uidKey: string;
109
+ uidVal: string;
110
+ aud: string;
111
+ pepper: HexInput;
112
+ jwkAddress: AccountAddressInput;
113
+ }): FederatedKeylessPublicKey {
114
+ return new FederatedKeylessPublicKey(args.jwkAddress, KeylessPublicKey.create(args));
115
+ }
116
+
117
+ static fromJwtAndPepper(args: {
118
+ jwt: string;
119
+ pepper: HexInput;
120
+ jwkAddress: AccountAddressInput;
121
+ uidKey?: string;
122
+ }): FederatedKeylessPublicKey {
123
+ return new FederatedKeylessPublicKey(args.jwkAddress, KeylessPublicKey.fromJwtAndPepper(args));
124
+ }
125
+
126
+ static isInstance(publicKey: PublicKey) {
127
+ return (
128
+ "jwkAddress" in publicKey &&
129
+ publicKey.jwkAddress instanceof AccountAddress &&
130
+ "keylessPublicKey" in publicKey &&
131
+ publicKey.keylessPublicKey instanceof KeylessPublicKey
132
+ );
133
+ }
134
+ }
@@ -6,7 +6,9 @@ export * from "./hdKey";
6
6
  export * from "./multiEd25519";
7
7
  export * from "./multiKey";
8
8
  export * from "./ephemeral";
9
+ export * from "./federatedKeyless";
9
10
  export * from "./keyless";
11
+ export * from "./poseidon";
10
12
  export * from "./privateKey";
11
13
  export * from "./publicKey";
12
14
  export * from "./secp256k1";
@@ -158,13 +158,14 @@ export class KeylessPublicKey extends AccountPublicKey {
158
158
  static fromJwtAndPepper(args: { jwt: string; pepper: HexInput; uidKey?: string }): KeylessPublicKey {
159
159
  const { jwt, pepper, uidKey = "sub" } = args;
160
160
  const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);
161
- const iss = jwtPayload.iss!;
161
+ if (typeof jwtPayload.iss !== "string") {
162
+ throw new Error("iss was not found");
163
+ }
162
164
  if (typeof jwtPayload.aud !== "string") {
163
165
  throw new Error("aud was not found or an array of values");
164
166
  }
165
- const aud = jwtPayload.aud!;
166
167
  const uidVal = jwtPayload[uidKey];
167
- return KeylessPublicKey.create({ iss, uidKey, uidVal, aud, pepper });
168
+ return KeylessPublicKey.create({ iss: jwtPayload.iss, uidKey, uidVal, aud: jwtPayload.aud, pepper });
168
169
  }
169
170
 
170
171
  static isInstance(publicKey: PublicKey) {
@@ -98,12 +98,12 @@ export function bytesToBigIntLE(bytes: Uint8Array): bigint {
98
98
  return result;
99
99
  }
100
100
 
101
- export function bigIntToBytesLE(value: bigint, length: number): Uint8Array {
101
+ export function bigIntToBytesLE(value: bigint | number, length: number): Uint8Array {
102
+ let val = BigInt(value);
102
103
  const bytes = new Uint8Array(length);
103
104
  for (let i = 0; i < length; i += 1) {
104
- bytes[i] = Number(value & BigInt(0xff));
105
- // eslint-disable-next-line no-param-reassign
106
- value >>= BigInt(8);
105
+ bytes[i] = Number(val & BigInt(0xff));
106
+ val >>= BigInt(8);
107
107
  }
108
108
  return bytes;
109
109
  }
@@ -6,6 +6,7 @@ import { AccountPublicKey, PublicKey, VerifySignatureArgs } from "./publicKey";
6
6
  import { Secp256k1PublicKey, Secp256k1Signature } from "./secp256k1";
7
7
  import { KeylessPublicKey, KeylessSignature } from "./keyless";
8
8
  import { Signature } from "./signature";
9
+ import { FederatedKeylessPublicKey } from "./federatedKeyless";
9
10
 
10
11
  /**
11
12
  * Represents any public key supported by Aptos.
@@ -37,6 +38,8 @@ export class AnyPublicKey extends AccountPublicKey {
37
38
  this.variant = AnyPublicKeyVariant.Secp256k1;
38
39
  } else if (publicKey instanceof KeylessPublicKey) {
39
40
  this.variant = AnyPublicKeyVariant.Keyless;
41
+ } else if (publicKey instanceof FederatedKeylessPublicKey) {
42
+ this.variant = AnyPublicKeyVariant.FederatedKeyless;
40
43
  } else {
41
44
  throw new Error("Unsupported public key type");
42
45
  }
@@ -91,6 +94,9 @@ export class AnyPublicKey extends AccountPublicKey {
91
94
  case AnyPublicKeyVariant.Keyless:
92
95
  publicKey = KeylessPublicKey.deserialize(deserializer);
93
96
  break;
97
+ case AnyPublicKeyVariant.FederatedKeyless:
98
+ publicKey = FederatedKeylessPublicKey.deserialize(deserializer);
99
+ break;
94
100
  default:
95
101
  throw new Error(`Unknown variant index for AnyPublicKey: ${variantIndex}`);
96
102
  }
@@ -12,9 +12,9 @@ export const convertSigningMessage = (message: HexInput): HexInput => {
12
12
  // if message is of type string, verify it is a valid Hex string
13
13
  if (typeof message === "string") {
14
14
  const isValid = Hex.isValid(message);
15
- // If message is not a valid Hex string, convert it into a Buffer
15
+ // If message is not a valid Hex string, convert it
16
16
  if (!isValid.valid) {
17
- return Buffer.from(message, "utf8");
17
+ return new TextEncoder().encode(message);
18
18
  }
19
19
  // If message is a valid Hex string, return it
20
20
  return message;
@@ -52,10 +52,9 @@ import {
52
52
  GetAccountTransactionsCount,
53
53
  } from "../types/generated/queries";
54
54
  import { memoizeAsync } from "../utils/memoize";
55
- import { Secp256k1PrivateKey, AuthenticationKey, Ed25519PrivateKey, createObjectAddress } from "../core";
55
+ import { Secp256k1PrivateKey, AuthenticationKey, Ed25519PrivateKey } from "../core";
56
56
  import { CurrentFungibleAssetBalancesBoolExp } from "../types/generated/types";
57
57
  import { getTableItem } from "./table";
58
- import { APTOS_COIN } from "../utils";
59
58
 
60
59
  export async function getInfo(args: {
61
60
  aptosConfig: AptosConfig;
@@ -402,58 +401,6 @@ export async function getAccountTransactionsCount(args: {
402
401
  return data.account_transactions_aggregate.aggregate ? data.account_transactions_aggregate.aggregate.count : 0;
403
402
  }
404
403
 
405
- export async function getAccountCoinAmount(args: {
406
- aptosConfig: AptosConfig;
407
- accountAddress: AccountAddressInput;
408
- coinType?: MoveStructId;
409
- faMetadataAddress?: AccountAddressInput;
410
- }): Promise<number> {
411
- const { aptosConfig, accountAddress, coinType, faMetadataAddress } = args;
412
-
413
- let coinAssetType: string | undefined = coinType;
414
- let faAddress: string;
415
-
416
- if (coinType !== undefined && faMetadataAddress !== undefined) {
417
- faAddress = AccountAddress.from(faMetadataAddress).toStringLong();
418
- } else if (coinType !== undefined && faMetadataAddress === undefined) {
419
- // TODO Move to a separate function as defined in the AIP for coin migration
420
- if (coinType === APTOS_COIN) {
421
- faAddress = AccountAddress.A.toStringLong();
422
- } else {
423
- faAddress = createObjectAddress(AccountAddress.A, coinType).toStringLong();
424
- }
425
- } else if (coinType === undefined && faMetadataAddress !== undefined) {
426
- const addr = AccountAddress.from(faMetadataAddress);
427
- faAddress = addr.toStringLong();
428
- if (addr === AccountAddress.A) {
429
- coinAssetType = APTOS_COIN;
430
- }
431
- // The paired CoinType should be populated outside of this function in another
432
- // async call. We cannot do this internally due to dependency cycles issue.
433
- } else {
434
- throw new Error("Either coinType, fungibleAssetAddress, or both must be provided");
435
- }
436
- const address = AccountAddress.from(accountAddress).toStringLong();
437
-
438
- // Search by fungible asset address, unless it has a coin it migrated from
439
- let where: any = { asset_type: { _eq: faAddress } };
440
- if (coinAssetType !== undefined) {
441
- where = { asset_type: { _in: [coinAssetType, faAddress] } };
442
- }
443
-
444
- const data = await getAccountCoinsData({
445
- aptosConfig,
446
- accountAddress: address,
447
- options: {
448
- where,
449
- },
450
- });
451
-
452
- // commonjs (aka cjs) doesnt handle Nullish Coalescing for some reason
453
- // might be because of how ts infer the graphql generated scheme type
454
- return data[0] ? data[0].amount : 0;
455
- }
456
-
457
404
  export async function getAccountCoinsData(args: {
458
405
  aptosConfig: AptosConfig;
459
406
  accountAddress: AccountAddressInput;
@@ -7,9 +7,11 @@
7
7
  * other namespaces and processes can access these methods without depending on the entire
8
8
  * keyless namespace and without having a dependency cycle error.
9
9
  */
10
+ import { jwtDecode, JwtPayload } from "jwt-decode";
10
11
  import { AptosConfig } from "../api/aptosConfig";
11
12
  import { postAptosPepperService, postAptosProvingService } from "../client";
12
13
  import {
14
+ AccountAddressInput,
13
15
  EphemeralSignature,
14
16
  Groth16Zkp,
15
17
  Hex,
@@ -19,10 +21,14 @@ import {
19
21
  getKeylessConfig,
20
22
  } from "../core";
21
23
  import { HexInput, ZkpVariant } from "../types";
22
- import { EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from "../account";
24
+ import { Account, EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from "../account";
23
25
  import { PepperFetchRequest, PepperFetchResponse, ProverRequest, ProverResponse } from "../types/keyless";
24
- import { nowInSeconds } from "../utils/helpers";
25
26
  import { lookupOriginalAccountAddress } from "./account";
27
+ import { FederatedKeylessPublicKey } from "../core/crypto/federatedKeyless";
28
+ import { FederatedKeylessAccount } from "../account/FederatedKeylessAccount";
29
+ import { MoveVector } from "../bcs";
30
+ import { generateTransaction } from "./transactionSubmission";
31
+ import { SimpleTransaction } from "../transactions";
26
32
 
27
33
  export async function getPepper(args: {
28
34
  aptosConfig: AptosConfig;
@@ -63,7 +69,11 @@ export async function getProof(args: {
63
69
  throw new Error(`Pepper needs to be ${KeylessAccount.PEPPER_LENGTH} bytes`);
64
70
  }
65
71
  const { maxExpHorizonSecs } = await getKeylessConfig({ aptosConfig });
66
- if (maxExpHorizonSecs < ephemeralKeyPair.expiryDateSecs - nowInSeconds()) {
72
+ const decodedJwt = jwtDecode<JwtPayload>(jwt);
73
+ if (typeof decodedJwt.iat !== "number") {
74
+ throw new Error("iat was not found");
75
+ }
76
+ if (maxExpHorizonSecs < ephemeralKeyPair.expiryDateSecs - decodedJwt.iat) {
67
77
  throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${maxExpHorizonSecs}`);
68
78
  }
69
79
  const json = {
@@ -106,8 +116,28 @@ export async function deriveKeylessAccount(args: {
106
116
  uidKey?: string;
107
117
  pepper?: HexInput;
108
118
  proofFetchCallback?: ProofFetchCallback;
109
- }): Promise<KeylessAccount> {
110
- const { aptosConfig, jwt, uidKey, proofFetchCallback, pepper = await getPepper(args) } = args;
119
+ }): Promise<KeylessAccount>;
120
+
121
+ export async function deriveKeylessAccount(args: {
122
+ aptosConfig: AptosConfig;
123
+ jwt: string;
124
+ ephemeralKeyPair: EphemeralKeyPair;
125
+ jwkAddress: AccountAddressInput;
126
+ uidKey?: string;
127
+ pepper?: HexInput;
128
+ proofFetchCallback?: ProofFetchCallback;
129
+ }): Promise<FederatedKeylessAccount>;
130
+
131
+ export async function deriveKeylessAccount(args: {
132
+ aptosConfig: AptosConfig;
133
+ jwt: string;
134
+ ephemeralKeyPair: EphemeralKeyPair;
135
+ jwkAddress?: AccountAddressInput;
136
+ uidKey?: string;
137
+ pepper?: HexInput;
138
+ proofFetchCallback?: ProofFetchCallback;
139
+ }): Promise<KeylessAccount | FederatedKeylessAccount> {
140
+ const { aptosConfig, jwt, jwkAddress, uidKey, proofFetchCallback, pepper = await getPepper(args) } = args;
111
141
  const proofPromise = getProof({ ...args, pepper });
112
142
  // If a callback is provided, pass in the proof as a promise to KeylessAccount.create. This will make the proof be fetched in the
113
143
  // background and the callback will handle the outcome of the fetch. This allows the developer to not have to block on the proof fetch
@@ -116,14 +146,62 @@ export async function deriveKeylessAccount(args: {
116
146
  // If no callback is provided, the just await the proof fetch and continue syncronously.
117
147
  const proof = proofFetchCallback ? proofPromise : await proofPromise;
118
148
 
119
- // Look up the original address to handle key rotations
149
+ // Look up the original address to handle key rotations and then instantiate the account.
150
+ if (jwkAddress !== undefined) {
151
+ const publicKey = FederatedKeylessPublicKey.fromJwtAndPepper({ jwt, pepper, jwkAddress, uidKey });
152
+ const address = await lookupOriginalAccountAddress({
153
+ aptosConfig,
154
+ authenticationKey: publicKey.authKey().derivedAddress(),
155
+ });
156
+
157
+ return FederatedKeylessAccount.create({ ...args, address, proof, pepper, proofFetchCallback, jwkAddress });
158
+ }
159
+
120
160
  const publicKey = KeylessPublicKey.fromJwtAndPepper({ jwt, pepper, uidKey });
121
161
  const address = await lookupOriginalAccountAddress({
122
162
  aptosConfig,
123
163
  authenticationKey: publicKey.authKey().derivedAddress(),
124
164
  });
165
+ return KeylessAccount.create({ ...args, address, proof, pepper, proofFetchCallback });
166
+ }
125
167
 
126
- const keylessAccount = KeylessAccount.create({ ...args, address, proof, pepper, proofFetchCallback });
168
+ interface JWK {
169
+ kty: string; // Key type
170
+ kid: string; // Key ID
171
+ alg: string; // Algorithm used with the key
172
+ n: string; // Modulus (for RSA keys)
173
+ e: string; // Exponent (for RSA keys)
174
+ }
175
+
176
+ interface JWKS {
177
+ keys: JWK[];
178
+ }
127
179
 
128
- return keylessAccount;
180
+ export async function updateFederatedKeylessJwkSetTransaction(args: {
181
+ aptosConfig: AptosConfig;
182
+ sender: Account;
183
+ iss: string;
184
+ jwksUrl?: string;
185
+ }): Promise<SimpleTransaction> {
186
+ const { aptosConfig, sender, iss } = args;
187
+ const jwksUrl = args.jwksUrl ?? (iss.endsWith("/") ? `${iss}.well-known/jwks.json` : `${iss}/.well-known/jwks.json`);
188
+ const response = await fetch(jwksUrl);
189
+ if (!response.ok) {
190
+ throw new Error(`Failed to fetch JWKS: ${response.status} ${response.statusText}`);
191
+ }
192
+ const jwks: JWKS = await response.json();
193
+ return generateTransaction({
194
+ aptosConfig,
195
+ sender: sender.accountAddress,
196
+ data: {
197
+ function: "0x1::jwks::update_federated_jwk_set",
198
+ functionArguments: [
199
+ iss,
200
+ MoveVector.MoveString(jwks.keys.map((key) => key.kid)),
201
+ MoveVector.MoveString(jwks.keys.map((key) => key.alg)),
202
+ MoveVector.MoveString(jwks.keys.map((key) => key.e)),
203
+ MoveVector.MoveString(jwks.keys.map((key) => key.n)),
204
+ ],
205
+ },
206
+ });
129
207
  }
@@ -8,7 +8,7 @@
8
8
  import { AptosConfig } from "../api/aptosConfig";
9
9
  import { MoveVector, U8 } from "../bcs";
10
10
  import { postAptosFullNode } from "../client";
11
- import { Account, KeylessAccount, MultiKeyAccount } from "../account";
11
+ import { Account, AbstractKeylessAccount, MultiKeyAccount } from "../account";
12
12
  import { AccountAddress, AccountAddressInput } from "../core/accountAddress";
13
13
  import { PrivateKey } from "../core/crypto";
14
14
  import { AccountAuthenticator } from "../transactions/authenticator/account";
@@ -206,6 +206,24 @@ export function signTransaction(args: { signer: Account; transaction: AnyRawTran
206
206
  return signer.signTransactionWithAuthenticator(transaction);
207
207
  }
208
208
 
209
+ export function signAsFeePayer(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {
210
+ const { signer, transaction } = args;
211
+
212
+ // if transaction doesnt hold a "feePayerAddress" prop it means
213
+ // this is not a fee payer transaction
214
+ if (!transaction.feePayerAddress) {
215
+ throw new Error(`Transaction ${transaction} is not a Fee Payer transaction`);
216
+ }
217
+
218
+ // Set the feePayerAddress to the signer account address
219
+ transaction.feePayerAddress = signer.accountAddress;
220
+
221
+ return signTransaction({
222
+ signer,
223
+ transaction,
224
+ });
225
+ }
226
+
209
227
  /**
210
228
  * Simulates a transaction before singing it.
211
229
  *
@@ -268,23 +286,58 @@ export async function submitTransaction(
268
286
  });
269
287
  return data;
270
288
  }
289
+ export type FeePayerOrFeePayerAuthenticatorOrNeither =
290
+ | { feePayer: Account; feePayerAuthenticator?: never }
291
+ | { feePayer?: never; feePayerAuthenticator: AccountAuthenticator }
292
+ | { feePayer?: never; feePayerAuthenticator?: never };
271
293
 
272
- export async function signAndSubmitTransaction(args: {
273
- aptosConfig: AptosConfig;
274
- signer: Account;
275
- transaction: AnyRawTransaction;
276
- }): Promise<PendingTransactionResponse> {
277
- const { aptosConfig, signer, transaction } = args;
294
+ export async function signAndSubmitTransaction(
295
+ args: FeePayerOrFeePayerAuthenticatorOrNeither & {
296
+ aptosConfig: AptosConfig;
297
+ signer: Account;
298
+ transaction: AnyRawTransaction;
299
+ },
300
+ ): Promise<PendingTransactionResponse> {
301
+ const { aptosConfig, signer, feePayer, transaction } = args;
278
302
  // If the signer contains a KeylessAccount, await proof fetching in case the proof
279
303
  // was fetched asyncronously.
280
- if (signer instanceof KeylessAccount || signer instanceof MultiKeyAccount) {
304
+ if (signer instanceof AbstractKeylessAccount || signer instanceof MultiKeyAccount) {
281
305
  await signer.waitForProofFetch();
282
306
  }
283
- const authenticator = signTransaction({ signer, transaction });
307
+ if (feePayer instanceof AbstractKeylessAccount || feePayer instanceof MultiKeyAccount) {
308
+ await feePayer.waitForProofFetch();
309
+ }
310
+ const feePayerAuthenticator =
311
+ args.feePayerAuthenticator || (feePayer && signAsFeePayer({ signer: feePayer, transaction }));
312
+
313
+ const senderAuthenticator = signTransaction({ signer, transaction });
314
+ return submitTransaction({
315
+ aptosConfig,
316
+ transaction,
317
+ senderAuthenticator,
318
+ feePayerAuthenticator,
319
+ });
320
+ }
321
+
322
+ export async function signAndSubmitAsFeePayer(args: {
323
+ aptosConfig: AptosConfig;
324
+ feePayer: Account;
325
+ senderAuthenticator: AccountAuthenticator;
326
+ transaction: AnyRawTransaction;
327
+ }): Promise<PendingTransactionResponse> {
328
+ const { aptosConfig, senderAuthenticator, feePayer, transaction } = args;
329
+
330
+ if (feePayer instanceof AbstractKeylessAccount || feePayer instanceof MultiKeyAccount) {
331
+ await feePayer.waitForProofFetch();
332
+ }
333
+
334
+ const feePayerAuthenticator = signAsFeePayer({ signer: feePayer, transaction });
335
+
284
336
  return submitTransaction({
285
337
  aptosConfig,
286
338
  transaction,
287
- senderAuthenticator: authenticator,
339
+ senderAuthenticator,
340
+ feePayerAuthenticator,
288
341
  });
289
342
  }
290
343
 
@@ -9,7 +9,14 @@
9
9
  import { sha3_256 as sha3Hash } from "@noble/hashes/sha3";
10
10
  import { AptosConfig } from "../../api/aptosConfig";
11
11
  import { AccountAddress, AccountAddressInput, Hex, PublicKey } from "../../core";
12
- import { AnyPublicKey, AnySignature, KeylessPublicKey, KeylessSignature, Secp256k1PublicKey } from "../../core/crypto";
12
+ import {
13
+ AnyPublicKey,
14
+ AnySignature,
15
+ KeylessPublicKey,
16
+ KeylessSignature,
17
+ Secp256k1PublicKey,
18
+ FederatedKeylessPublicKey,
19
+ } from "../../core/crypto";
13
20
  import { Ed25519PublicKey, Ed25519Signature } from "../../core/crypto/ed25519";
14
21
  import { getInfo } from "../../internal/account";
15
22
  import { getLedgerInfo } from "../../internal/general";
@@ -445,25 +452,29 @@ export function generateSignedTransactionForSimulation(args: InputSimulateTransa
445
452
  }
446
453
 
447
454
  export function getAuthenticatorForSimulation(publicKey: PublicKey) {
455
+ // Wrap the public key types below with AnyPublicKey as they are only support through single sender.
456
+ // Learn more about AnyPublicKey here - https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-55.md
457
+ const convertToAnyPublicKey =
458
+ KeylessPublicKey.isInstance(publicKey) ||
459
+ FederatedKeylessPublicKey.isInstance(publicKey) ||
460
+ Secp256k1PublicKey.isInstance(publicKey);
461
+ const accountPublicKey = convertToAnyPublicKey ? new AnyPublicKey(publicKey) : publicKey;
462
+
448
463
  // No need to for the signature to be matching in scheme. All that matters for simulations is that it's not valid
449
464
  const invalidSignature = new Ed25519Signature(new Uint8Array(64));
450
465
 
451
- if (Ed25519PublicKey.isInstance(publicKey)) {
452
- return new AccountAuthenticatorEd25519(publicKey, invalidSignature);
466
+ if (Ed25519PublicKey.isInstance(accountPublicKey)) {
467
+ return new AccountAuthenticatorEd25519(accountPublicKey, invalidSignature);
453
468
  }
454
469
 
455
- if (AnyPublicKey.isInstance(publicKey)) {
456
- if (KeylessPublicKey.isInstance(publicKey.publicKey)) {
457
- return new AccountAuthenticatorSingleKey(publicKey, new AnySignature(KeylessSignature.getSimulationSignature()));
470
+ if (AnyPublicKey.isInstance(accountPublicKey)) {
471
+ if (KeylessPublicKey.isInstance(accountPublicKey.publicKey)) {
472
+ return new AccountAuthenticatorSingleKey(
473
+ accountPublicKey,
474
+ new AnySignature(KeylessSignature.getSimulationSignature()),
475
+ );
458
476
  }
459
- return new AccountAuthenticatorSingleKey(publicKey, new AnySignature(invalidSignature));
460
- }
461
-
462
- // TODO: remove this, non-account public keys should never make it here
463
- if (KeylessPublicKey.isInstance(publicKey) || Secp256k1PublicKey.isInstance(publicKey)) {
464
- // eslint-disable-next-line no-console
465
- console.warn("Expected AccountPublicKey, but got PublicKey. Please wrap your public key with AnyPublicKey.");
466
- return new AccountAuthenticatorSingleKey(new AnyPublicKey(publicKey), new AnySignature(invalidSignature));
477
+ return new AccountAuthenticatorSingleKey(accountPublicKey, new AnySignature(invalidSignature));
467
478
  }
468
479
 
469
480
  // TODO add support for AnyMultiKey