@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
@@ -2,103 +2,25 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { JwtPayload, jwtDecode } from "jwt-decode";
5
- import EventEmitter from "eventemitter3";
6
- import { EphemeralCertificateVariant, HexInput, SigningScheme } from "../types";
5
+ import { HexInput } from "../types";
7
6
  import { AccountAddress } from "../core/accountAddress";
8
- import {
9
- AnyPublicKey,
10
- AnySignature,
11
- KeylessPublicKey,
12
- KeylessSignature,
13
- EphemeralCertificate,
14
- ZeroKnowledgeSig,
15
- ZkProof,
16
- } from "../core/crypto";
7
+ import { ZeroKnowledgeSig } from "../core/crypto";
17
8
 
18
- import { Account } from "./Account";
19
9
  import { EphemeralKeyPair } from "./EphemeralKeyPair";
20
- import { Hex } from "../core/hex";
21
- import { AccountAuthenticatorSingleKey } from "../transactions/authenticator/account";
22
- import { Deserializer, Serializable, Serializer } from "../bcs";
23
- import { deriveTransactionType, generateSigningMessage } from "../transactions/transactionBuilder/signingMessage";
24
- import { AnyRawTransaction, AnyRawTransactionInstance } from "../transactions/types";
25
- import { base64UrlDecode } from "../utils/helpers";
10
+ import { Deserializer, Serializer } from "../bcs";
11
+ import { AbstractKeylessAccount, ProofFetchCallback } from "./AbstractKeylessAccount";
26
12
 
27
13
  /**
28
14
  * Account implementation for the Keyless authentication scheme.
29
15
  *
30
16
  * Used to represent a Keyless based account and sign transactions with it.
31
17
  *
32
- * Use KeylessAccount.fromJWTAndProof to instantiate a KeylessAccount with a JWT, proof and EphemeralKeyPair.
18
+ * Use KeylessAccount.create to instantiate a KeylessAccount with a JWT, proof and EphemeralKeyPair.
33
19
  *
34
20
  * When the proof expires or the JWT becomes invalid, the KeylessAccount must be instantiated again with a new JWT,
35
21
  * EphemeralKeyPair, and corresponding proof.
36
22
  */
37
- export class KeylessAccount extends Serializable implements Account {
38
- static readonly PEPPER_LENGTH: number = 31;
39
-
40
- /**
41
- * The KeylessPublicKey associated with the account
42
- */
43
- readonly publicKey: KeylessPublicKey;
44
-
45
- /**
46
- * The EphemeralKeyPair used to generate sign.
47
- */
48
- readonly ephemeralKeyPair: EphemeralKeyPair;
49
-
50
- /**
51
- * The claim on the JWT to identify a user. This is typically 'sub' or 'email'.
52
- */
53
- readonly uidKey: string;
54
-
55
- /**
56
- * The value of the uidKey claim on the JWT. This intended to be a stable user identifier.
57
- */
58
- readonly uidVal: string;
59
-
60
- /**
61
- * The value of the 'aud' claim on the JWT, also known as client ID. This is the identifier for the dApp's
62
- * OIDC registration with the identity provider.
63
- */
64
- readonly aud: string;
65
-
66
- /**
67
- * A value contains 31 bytes of entropy that preserves privacy of the account. Typically fetched from a pepper provider.
68
- */
69
- readonly pepper: Uint8Array;
70
-
71
- /**
72
- * Account address associated with the account
73
- */
74
- readonly accountAddress: AccountAddress;
75
-
76
- /**
77
- * The zero knowledge signature (if ready) which contains the proof used to validate the EphemeralKeyPair.
78
- */
79
- proof: ZeroKnowledgeSig | undefined;
80
-
81
- /**
82
- * The proof of the EphemeralKeyPair or a promise that provides the proof. This is used to allow for awaiting on
83
- * fetching the proof.
84
- */
85
- readonly proofOrPromise: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;
86
-
87
- /**
88
- * Signing scheme used to sign transactions
89
- */
90
- readonly signingScheme: SigningScheme;
91
-
92
- /**
93
- * The JWT token used to derive the account
94
- */
95
- readonly jwt: string;
96
-
97
- /**
98
- * An event emitter used to assist in handling asycronous proof fetching.
99
- */
100
- private readonly emitter: EventEmitter<ProofFetchEvents>;
101
-
23
+ export class KeylessAccount extends AbstractKeylessAccount {
102
24
  // Use the static constructor 'create' instead.
103
25
  private constructor(args: {
104
26
  address?: AccountAddress;
@@ -112,52 +34,7 @@ export class KeylessAccount extends Serializable implements Account {
112
34
  proofFetchCallback?: ProofFetchCallback;
113
35
  jwt: string;
114
36
  }) {
115
- super();
116
- const { address, ephemeralKeyPair, uidKey, uidVal, aud, pepper, proof, proofFetchCallback, jwt } = args;
117
- this.ephemeralKeyPair = ephemeralKeyPair;
118
- this.publicKey = KeylessPublicKey.create(args);
119
- this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();
120
- this.uidKey = uidKey;
121
- this.uidVal = uidVal;
122
- this.aud = aud;
123
- this.jwt = jwt;
124
- this.emitter = new EventEmitter<ProofFetchEvents>();
125
- this.proofOrPromise = proof;
126
- if (proof instanceof ZeroKnowledgeSig) {
127
- this.proof = proof;
128
- } else {
129
- if (proofFetchCallback === undefined) {
130
- throw new Error("Must provide callback for async proof fetch");
131
- }
132
- this.emitter.on("proofFetchFinish", async (status) => {
133
- await proofFetchCallback(status);
134
- this.emitter.removeAllListeners();
135
- });
136
- this.init(proof);
137
- }
138
- this.signingScheme = SigningScheme.SingleKey;
139
- const pepperBytes = Hex.fromHexInput(pepper).toUint8Array();
140
- if (pepperBytes.length !== KeylessAccount.PEPPER_LENGTH) {
141
- throw new Error(`Pepper length in bytes should be ${KeylessAccount.PEPPER_LENGTH}`);
142
- }
143
- this.pepper = pepperBytes;
144
- }
145
-
146
- /**
147
- * This initializes the asyncronous proof fetch
148
- * @return
149
- */
150
- async init(promise: Promise<ZeroKnowledgeSig>) {
151
- try {
152
- this.proof = await promise;
153
- this.emitter.emit("proofFetchFinish", { status: "Success" });
154
- } catch (error) {
155
- if (error instanceof Error) {
156
- this.emitter.emit("proofFetchFinish", { status: "Failed", error: error.toString() });
157
- } else {
158
- this.emitter.emit("proofFetchFinish", { status: "Failed", error: "Unknown" });
159
- }
160
- }
37
+ super(args);
161
38
  }
162
39
 
163
40
  serialize(serializer: Serializer): void {
@@ -166,7 +43,7 @@ export class KeylessAccount extends Serializable implements Account {
166
43
  serializer.serializeFixedBytes(this.pepper);
167
44
  this.ephemeralKeyPair.serialize(serializer);
168
45
  if (this.proof === undefined) {
169
- throw new Error("Connot serialize - proof undefined");
46
+ throw new Error("Cannot serialize - proof undefined");
170
47
  }
171
48
  this.proof.serialize(serializer);
172
49
  }
@@ -186,110 +63,6 @@ export class KeylessAccount extends Serializable implements Account {
186
63
  });
187
64
  }
188
65
 
189
- /**
190
- * Checks if the proof is expired. If so the account must be rederived with a new EphemeralKeyPair
191
- * and JWT token.
192
- * @return boolean
193
- */
194
- isExpired(): boolean {
195
- return this.ephemeralKeyPair.isExpired();
196
- }
197
-
198
- /**
199
- * Sign a message using Keyless.
200
- * @param message the message to sign, as binary input
201
- * @return the AccountAuthenticator containing the signature, together with the account's public key
202
- */
203
- signWithAuthenticator(message: HexInput): AccountAuthenticatorSingleKey {
204
- const signature = new AnySignature(this.sign(message));
205
- const publicKey = new AnyPublicKey(this.publicKey);
206
- return new AccountAuthenticatorSingleKey(publicKey, signature);
207
- }
208
-
209
- /**
210
- * Sign a transaction using Keyless.
211
- * @param transaction the raw transaction
212
- * @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key
213
- */
214
- signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorSingleKey {
215
- const signature = new AnySignature(this.signTransaction(transaction));
216
- const publicKey = new AnyPublicKey(this.publicKey);
217
- return new AccountAuthenticatorSingleKey(publicKey, signature);
218
- }
219
-
220
- /**
221
- * Waits for asyncronous proof fetching to finish.
222
- * @return
223
- */
224
- async waitForProofFetch() {
225
- if (this.proofOrPromise instanceof Promise) {
226
- await this.proofOrPromise;
227
- }
228
- }
229
-
230
- /**
231
- * Sign the given message using Keyless.
232
- * @param message in HexInput format
233
- * @returns Signature
234
- */
235
- sign(data: HexInput): KeylessSignature {
236
- const { expiryDateSecs } = this.ephemeralKeyPair;
237
- if (this.isExpired()) {
238
- throw new Error("EphemeralKeyPair is expired");
239
- }
240
- if (this.proof === undefined) {
241
- throw new Error("Proof not defined");
242
- }
243
- const ephemeralPublicKey = this.ephemeralKeyPair.getPublicKey();
244
- const ephemeralSignature = this.ephemeralKeyPair.sign(data);
245
-
246
- return new KeylessSignature({
247
- jwtHeader: base64UrlDecode(this.jwt.split(".")[0]),
248
- ephemeralCertificate: new EphemeralCertificate(this.proof, EphemeralCertificateVariant.ZkProof),
249
- expiryDateSecs,
250
- ephemeralPublicKey,
251
- ephemeralSignature,
252
- });
253
- }
254
-
255
- /**
256
- * Sign the given transaction with Keyless.
257
- * Signs the transaction and proof to guard against proof malleability.
258
- * @param transaction the transaction to be signed
259
- * @returns KeylessSignature
260
- */
261
- signTransaction(transaction: AnyRawTransaction): KeylessSignature {
262
- if (this.proof === undefined) {
263
- throw new Error("Proof not found");
264
- }
265
- const raw = deriveTransactionType(transaction);
266
- const txnAndProof = new TransactionAndProof(raw, this.proof.proof);
267
- const signMess = txnAndProof.hash();
268
- return this.sign(signMess);
269
- }
270
-
271
- /**
272
- * Note - This function is currently incomplete and should only be used to verify ownership of the KeylessAccount
273
- *
274
- * Verifies a signature given the message.
275
- *
276
- * TODO: Groth16 proof verification
277
- *
278
- * @param args.message the message that was signed.
279
- * @param args.signature the KeylessSignature to verify
280
- * @returns boolean
281
- */
282
- verifySignature(args: { message: HexInput; signature: KeylessSignature }): boolean {
283
- const { message, signature } = args;
284
- if (this.isExpired()) {
285
- return false;
286
- }
287
- if (!this.ephemeralKeyPair.getPublicKey().verifySignature({ message, signature: signature.ephemeralSignature })) {
288
- return false;
289
- }
290
- return true;
291
- }
292
-
293
66
  static fromBytes(bytes: Uint8Array): KeylessAccount {
294
67
  return KeylessAccount.deserialize(new Deserializer(bytes));
295
68
  }
@@ -306,81 +79,24 @@ export class KeylessAccount extends Serializable implements Account {
306
79
  const { address, proof, jwt, ephemeralKeyPair, pepper, uidKey = "sub", proofFetchCallback } = args;
307
80
 
308
81
  const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);
309
- const iss = jwtPayload.iss!;
82
+ if (typeof jwtPayload.iss !== "string") {
83
+ throw new Error("iss was not found");
84
+ }
310
85
  if (typeof jwtPayload.aud !== "string") {
311
86
  throw new Error("aud was not found or an array of values");
312
87
  }
313
- const aud = jwtPayload.aud!;
314
88
  const uidVal = jwtPayload[uidKey];
315
89
  return new KeylessAccount({
316
90
  address,
317
91
  proof,
318
92
  ephemeralKeyPair,
319
- iss,
93
+ iss: jwtPayload.iss,
320
94
  uidKey,
321
95
  uidVal,
322
- aud,
96
+ aud: jwtPayload.aud,
323
97
  pepper,
324
98
  jwt,
325
99
  proofFetchCallback,
326
100
  });
327
101
  }
328
102
  }
329
-
330
- /**
331
- * A container class to hold a transaction and a proof. It implements CryptoHashable which is used to create
332
- * the signing message for Keyless transactions. We sign over the proof to ensure non-malleability.
333
- */
334
- class TransactionAndProof extends Serializable {
335
- /**
336
- * The transaction to sign.
337
- */
338
- transaction: AnyRawTransactionInstance;
339
-
340
- /**
341
- * The zero knowledge proof used in signing the transaction.
342
- */
343
- proof?: ZkProof;
344
-
345
- /**
346
- * The domain separator prefix used when hashing.
347
- */
348
- readonly domainSeparator = "APTOS::TransactionAndProof";
349
-
350
- constructor(transaction: AnyRawTransactionInstance, proof?: ZkProof) {
351
- super();
352
- this.transaction = transaction;
353
- this.proof = proof;
354
- }
355
-
356
- serialize(serializer: Serializer): void {
357
- serializer.serializeFixedBytes(this.transaction.bcsToBytes());
358
- serializer.serializeOption(this.proof);
359
- }
360
-
361
- /**
362
- * Hashes the bcs serialized from of the class. This is the typescript corollary to the BCSCryptoHash macro in aptos-core.
363
- *
364
- * @returns Uint8Array
365
- */
366
- hash(): Uint8Array {
367
- return generateSigningMessage(this.bcsToBytes(), this.domainSeparator);
368
- }
369
- }
370
-
371
- export type ProofFetchSuccess = {
372
- status: "Success";
373
- };
374
-
375
- export type ProofFetchFailure = {
376
- status: "Failed";
377
- error: string;
378
- };
379
-
380
- export type ProofFetchStatus = ProofFetchSuccess | ProofFetchFailure;
381
-
382
- export type ProofFetchCallback = (status: ProofFetchStatus) => Promise<void>;
383
-
384
- export interface ProofFetchEvents {
385
- proofFetchFinish: (status: ProofFetchStatus) => void;
386
- }
@@ -7,7 +7,7 @@ import { AccountAddress, AccountAddressInput } from "../core/accountAddress";
7
7
  import { HexInput, SigningScheme } from "../types";
8
8
  import { AccountAuthenticatorMultiKey } from "../transactions/authenticator/account";
9
9
  import { AnyRawTransaction } from "../transactions/types";
10
- import { KeylessAccount } from "./KeylessAccount";
10
+ import { AbstractKeylessAccount } from "./AbstractKeylessAccount";
11
11
 
12
12
  export interface VerifyMultiKeySignatureArgs {
13
13
  message: HexInput;
@@ -130,7 +130,9 @@ export class MultiKeyAccount implements Account {
130
130
  * @return
131
131
  */
132
132
  async waitForProofFetch() {
133
- const keylessSigners = this.signers.filter((signer) => signer instanceof KeylessAccount) as KeylessAccount[];
133
+ const keylessSigners = this.signers.filter(
134
+ (signer) => signer instanceof AbstractKeylessAccount,
135
+ ) as AbstractKeylessAccount[];
134
136
  const promises = keylessSigners.map(async (signer) => signer.waitForProofFetch());
135
137
  await Promise.all(promises);
136
138
  }
@@ -3,4 +3,6 @@ export * from "./Account";
3
3
  export * from "./SingleKeyAccount";
4
4
  export * from "./EphemeralKeyPair";
5
5
  export * from "./KeylessAccount";
6
+ export * from "./AbstractKeylessAccount";
7
+ export * from "./FederatedKeylessAccount";
6
8
  export * from "./MultiKeyAccount";
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { Account as AccountModule } from "../account";
5
- import { AccountAddress, PrivateKey, AccountAddressInput } from "../core";
5
+ import { AccountAddress, PrivateKey, AccountAddressInput, createObjectAddress } from "../core";
6
6
  import {
7
7
  AccountData,
8
8
  AnyNumber,
@@ -24,7 +24,6 @@ import {
24
24
  } from "../types";
25
25
  import {
26
26
  deriveAccountFromPrivateKey,
27
- getAccountCoinAmount,
28
27
  getAccountCoinsCount,
29
28
  getAccountCoinsData,
30
29
  getAccountCollectionsWithOwnedTokens,
@@ -47,6 +46,7 @@ import { waitForIndexerOnVersion } from "./utils";
47
46
  import { CurrentFungibleAssetBalancesBoolExp } from "../types/generated/types";
48
47
  import { view } from "../internal/view";
49
48
  import { isEncodedStruct, parseEncodedStruct } from "../utils";
49
+ import { memoizeAsync } from "../utils/memoize";
50
50
 
51
51
  /**
52
52
  * A class to query all `Account` related queries on Aptos.
@@ -454,35 +454,81 @@ export class Account {
454
454
  faMetadataAddress?: AccountAddressInput;
455
455
  minimumLedgerVersion?: AnyNumber;
456
456
  }): Promise<number> {
457
- const { coinType, faMetadataAddress } = args;
458
- await waitForIndexerOnVersion({
459
- config: this.config,
460
- minimumLedgerVersion: args.minimumLedgerVersion,
461
- processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,
462
- });
457
+ const { accountAddress, coinType, faMetadataAddress } = args;
463
458
 
464
459
  // Attempt to populate the CoinType field if the FA address is provided.
465
460
  // We cannot do this internally due to dependency cycles issue.
466
461
  let coinAssetType: MoveStructId | undefined = coinType;
467
462
  if (coinType === undefined && faMetadataAddress !== undefined) {
468
- try {
469
- const pairedCoinTypeStruct = (
470
- await view({
471
- aptosConfig: this.config,
472
- payload: { function: "0x1::coin::paired_coin", functionArguments: [faMetadataAddress] },
473
- })
474
- ).at(0) as { vec: MoveValue[] };
463
+ coinAssetType = await memoizeAsync(
464
+ async () => {
465
+ try {
466
+ const pairedCoinTypeStruct = (
467
+ await view({
468
+ aptosConfig: this.config,
469
+ payload: { function: "0x1::coin::paired_coin", functionArguments: [faMetadataAddress] },
470
+ })
471
+ ).at(0) as { vec: MoveValue[] };
472
+
473
+ // Check if the Option has a value, and if so, parse the struct
474
+ if (pairedCoinTypeStruct.vec.length > 0 && isEncodedStruct(pairedCoinTypeStruct.vec[0])) {
475
+ return parseEncodedStruct(pairedCoinTypeStruct.vec[0]) as MoveStructId;
476
+ }
477
+ } catch (error) {
478
+ /* No paired coin type found */
479
+ }
480
+ return undefined;
481
+ },
482
+ `coin-mapping-${faMetadataAddress.toString()}`,
483
+ 1000 * 60 * 5, // 5 minutes
484
+ )();
485
+ }
486
+
487
+ let faAddress: string;
475
488
 
476
- // Check if the Option has a value, and if so, parse the struct
477
- if (pairedCoinTypeStruct.vec.length > 0 && isEncodedStruct(pairedCoinTypeStruct.vec[0])) {
478
- coinAssetType = parseEncodedStruct(pairedCoinTypeStruct.vec[0]);
479
- }
480
- } catch (error) {
481
- /* No paired coin type found */
489
+ if (coinType !== undefined && faMetadataAddress !== undefined) {
490
+ faAddress = AccountAddress.from(faMetadataAddress).toStringLong();
491
+ } else if (coinType !== undefined && faMetadataAddress === undefined) {
492
+ // TODO Move to a separate function as defined in the AIP for coin migration
493
+ if (coinType === APTOS_COIN) {
494
+ faAddress = AccountAddress.A.toStringLong();
495
+ } else {
496
+ faAddress = createObjectAddress(AccountAddress.A, coinType).toStringLong();
497
+ }
498
+ } else if (coinType === undefined && faMetadataAddress !== undefined) {
499
+ const addr = AccountAddress.from(faMetadataAddress);
500
+ faAddress = addr.toStringLong();
501
+ if (addr === AccountAddress.A) {
502
+ coinAssetType = APTOS_COIN;
482
503
  }
504
+ // The paired CoinType should be populated outside of this function in another
505
+ // async call. We cannot do this internally due to dependency cycles issue.
506
+ } else {
507
+ throw new Error("Either coinType, faMetadataAddress, or both must be provided");
483
508
  }
484
509
 
485
- return getAccountCoinAmount({ aptosConfig: this.config, ...args, coinType: coinAssetType });
510
+ // When there is a coin mapping, use that first, otherwise use the fungible asset address
511
+ // TODO: This function's signature at the top, returns number, but it could be greater than can be represented
512
+ if (coinAssetType !== undefined) {
513
+ const [balanceStr] = await view<[string]>({
514
+ aptosConfig: this.config,
515
+ payload: {
516
+ function: "0x1::coin::balance",
517
+ typeArguments: [coinAssetType],
518
+ functionArguments: [accountAddress],
519
+ },
520
+ });
521
+ return parseInt(balanceStr, 10);
522
+ }
523
+ const [balanceStr] = await view<[string]>({
524
+ aptosConfig: this.config,
525
+ payload: {
526
+ function: "0x1::primary_fungible_store::balance",
527
+ typeArguments: ["0x1::object::ObjectCore"],
528
+ functionArguments: [accountAddress, faAddress],
529
+ },
530
+ });
531
+ return parseInt(balanceStr, 10);
486
532
  }
487
533
 
488
534
  /**
@@ -1,9 +1,16 @@
1
1
  // Copyright © Aptos Foundation
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from "../account";
5
- import { ZeroKnowledgeSig } from "../core";
6
- import { deriveKeylessAccount, getPepper, getProof } from "../internal/keyless";
4
+ import { Account, EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from "../account";
5
+ import { FederatedKeylessAccount } from "../account/FederatedKeylessAccount";
6
+ import { AccountAddressInput, ZeroKnowledgeSig } from "../core";
7
+ import {
8
+ deriveKeylessAccount,
9
+ getPepper,
10
+ getProof,
11
+ updateFederatedKeylessJwkSetTransaction,
12
+ } from "../internal/keyless";
13
+ import { SimpleTransaction } from "../transactions";
7
14
  import { HexInput } from "../types";
8
15
  import { AptosConfig } from "./aptosConfig";
9
16
 
@@ -52,12 +59,30 @@ export class Keyless {
52
59
  return getProof({ aptosConfig: this.config, ...args });
53
60
  }
54
61
 
62
+ async deriveKeylessAccount(args: {
63
+ jwt: string;
64
+ ephemeralKeyPair: EphemeralKeyPair;
65
+ uidKey?: string;
66
+ pepper?: HexInput;
67
+ proofFetchCallback?: ProofFetchCallback;
68
+ }): Promise<KeylessAccount>;
69
+
70
+ async deriveKeylessAccount(args: {
71
+ jwt: string;
72
+ ephemeralKeyPair: EphemeralKeyPair;
73
+ jwkAddress: AccountAddressInput;
74
+ uidKey?: string;
75
+ pepper?: HexInput;
76
+ proofFetchCallback?: ProofFetchCallback;
77
+ }): Promise<FederatedKeylessAccount>;
78
+
55
79
  /**
56
80
  * Derives the Keyless Account from the JWT token and corresponding EphemeralKeyPair. It will lookup the pepper from
57
81
  * the pepper service if not explicitly provided. It will compute the proof via the proving service. It will ch
58
82
  *
59
83
  * @param args.jwt JWT token
60
84
  * @param args.ephemeralKeyPair the EphemeralKeyPair used to generate the nonce in the JWT token
85
+ * @param args.jwkAddress the where the JWKs used to verify signatures are found. Setting the value derives a FederatedKeylessAccount
61
86
  * @param args.uidKey a key in the JWT token to use to set the uidVal in the IdCommitment
62
87
  * @param args.pepper the pepper
63
88
  * @param args.proofFetchCallback a callback function that if set, the fetch of the proof will be done in the background. Once
@@ -69,10 +94,31 @@ export class Keyless {
69
94
  async deriveKeylessAccount(args: {
70
95
  jwt: string;
71
96
  ephemeralKeyPair: EphemeralKeyPair;
97
+ jwkAddress?: AccountAddressInput;
72
98
  uidKey?: string;
73
99
  pepper?: HexInput;
74
100
  proofFetchCallback?: ProofFetchCallback;
75
- }): Promise<KeylessAccount> {
101
+ }): Promise<KeylessAccount | FederatedKeylessAccount> {
76
102
  return deriveKeylessAccount({ aptosConfig: this.config, ...args });
77
103
  }
104
+
105
+ /**
106
+ * This installs a set of FederatedJWKs at an address for a given iss.
107
+ *
108
+ * It will fetch the JWK set from the well-known endpoint and update the FederatedJWKs at the sender's address
109
+ * to reflect it.
110
+ *
111
+ * @param args.sender The account that will install the JWKs
112
+ * @param args.iss the iss claim of the federated OIDC provider.
113
+ * @param args.jwksUrl the URL to find the corresponding JWKs. For supported IDP providers this parameter in not necessary.
114
+ *
115
+ * @returns The pending transaction that results from submission.
116
+ */
117
+ async updateFederatedKeylessJwkSetTransaction(args: {
118
+ sender: Account;
119
+ iss: string;
120
+ jwksUrl?: string;
121
+ }): Promise<SimpleTransaction> {
122
+ return updateFederatedKeylessJwkSetTransaction({ aptosConfig: this.config, ...args });
123
+ }
78
124
  }