@aptos-labs/ts-sdk 1.17.0 → 1.18.1

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 (425) hide show
  1. package/dist/common/{accountAddress-ccLvlUQe.d.ts → accountAddress-Lv-GSihU.d.ts} +107 -13
  2. package/dist/common/chunk-BHKSQXUZ.js +2 -0
  3. package/dist/common/chunk-BHKSQXUZ.js.map +1 -0
  4. package/dist/common/cli/index.d.ts +1 -1
  5. package/dist/common/cli/index.js +1 -1
  6. package/dist/common/cli/index.js.map +1 -1
  7. package/dist/common/index.d.ts +808 -117
  8. package/dist/common/index.js +30 -28
  9. package/dist/common/index.js.map +1 -1
  10. package/dist/esm/account/Account.mjs +1 -1
  11. package/dist/esm/account/Ed25519Account.mjs +1 -1
  12. package/dist/esm/account/EphemeralKeyPair.d.mts +85 -0
  13. package/dist/esm/account/EphemeralKeyPair.mjs +2 -0
  14. package/dist/esm/account/KeylessAccount.d.mts +175 -0
  15. package/dist/esm/account/KeylessAccount.mjs +2 -0
  16. package/dist/esm/account/MultiKeyAccount.d.mts +11 -5
  17. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  18. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  19. package/dist/esm/account/index.d.mts +6 -0
  20. package/dist/esm/account/index.mjs +1 -1
  21. package/dist/esm/api/account.d.mts +2 -2
  22. package/dist/esm/api/account.mjs +1 -1
  23. package/dist/esm/api/ans.d.mts +2 -2
  24. package/dist/esm/api/ans.mjs +1 -1
  25. package/dist/esm/api/aptos.d.mts +9 -1
  26. package/dist/esm/api/aptos.mjs +1 -1
  27. package/dist/esm/api/aptosConfig.d.mts +20 -0
  28. package/dist/esm/api/aptosConfig.mjs +1 -1
  29. package/dist/esm/api/coin.d.mts +2 -2
  30. package/dist/esm/api/coin.mjs +1 -1
  31. package/dist/esm/api/digitalAsset.d.mts +2 -2
  32. package/dist/esm/api/digitalAsset.mjs +1 -1
  33. package/dist/esm/api/event.mjs +1 -1
  34. package/dist/esm/api/faucet.mjs +1 -1
  35. package/dist/esm/api/fungibleAsset.mjs +1 -1
  36. package/dist/esm/api/general.mjs +1 -1
  37. package/dist/esm/api/index.d.mts +7 -0
  38. package/dist/esm/api/index.mjs +1 -1
  39. package/dist/esm/api/keyless.d.mts +104 -0
  40. package/dist/esm/api/keyless.mjs +2 -0
  41. package/dist/esm/api/keyless.mjs.map +1 -0
  42. package/dist/esm/api/staking.mjs +1 -1
  43. package/dist/esm/api/table.mjs +1 -1
  44. package/dist/esm/api/transaction.mjs +1 -1
  45. package/dist/esm/api/transactionSubmission/build.d.mts +2 -2
  46. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  47. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  48. package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
  49. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  50. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  51. package/dist/esm/api/transactionSubmission/simulate.d.mts +2 -2
  52. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  53. package/dist/esm/api/transactionSubmission/submit.d.mts +2 -2
  54. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  55. package/dist/esm/api/utils.mjs +1 -1
  56. package/dist/esm/bcs/deserializer.d.mts +32 -0
  57. package/dist/esm/bcs/deserializer.mjs +1 -1
  58. package/dist/esm/bcs/index.mjs +1 -1
  59. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  60. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  61. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  62. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  63. package/dist/esm/bcs/serializer.d.mts +42 -0
  64. package/dist/esm/bcs/serializer.mjs +1 -1
  65. package/dist/esm/{chunk-TQLED4KC.mjs → chunk-2DSPX6BX.mjs} +2 -2
  66. package/dist/esm/chunk-2QWQ6RX5.mjs +2 -0
  67. package/dist/esm/chunk-2QWQ6RX5.mjs.map +1 -0
  68. package/dist/esm/chunk-362JBD4O.mjs +2 -0
  69. package/dist/esm/{chunk-SUAMDMAA.mjs.map → chunk-362JBD4O.mjs.map} +1 -1
  70. package/dist/esm/{chunk-RWXHA4QZ.mjs → chunk-3VUSIKCF.mjs} +2 -2
  71. package/dist/esm/chunk-3ZCQQ3L2.mjs +2 -0
  72. package/dist/esm/chunk-3ZCQQ3L2.mjs.map +1 -0
  73. package/dist/esm/chunk-42SZQH5Z.mjs +2 -0
  74. package/dist/esm/chunk-42SZQH5Z.mjs.map +1 -0
  75. package/dist/esm/{chunk-MCRRHBFQ.mjs → chunk-4EPLOSKY.mjs} +2 -2
  76. package/dist/esm/{chunk-BSVNV6SJ.mjs → chunk-4IBJW3PB.mjs} +2 -2
  77. package/dist/esm/{chunk-J6HKAEKY.mjs → chunk-5X2BJDOB.mjs} +2 -2
  78. package/dist/esm/{chunk-5UKBTF7N.mjs → chunk-5YHI7WOB.mjs} +2 -2
  79. package/dist/esm/{chunk-J5I4OZAS.mjs → chunk-6DYDZSEW.mjs} +2 -2
  80. package/dist/esm/{chunk-J4Z6XR5D.mjs → chunk-6JL2U7JB.mjs} +2 -2
  81. package/dist/esm/{chunk-RNL5TAQT.mjs → chunk-6UDHM6YZ.mjs} +2 -2
  82. package/dist/esm/{chunk-2X7A4HUS.mjs → chunk-6ZQWPHLV.mjs} +2 -2
  83. package/dist/esm/{chunk-4NHWV5AI.mjs → chunk-76OH2Z4Q.mjs} +2 -2
  84. package/dist/esm/{chunk-5EN52MUT.mjs → chunk-77NXCSLY.mjs} +2 -2
  85. package/dist/esm/{chunk-ND6OMSQU.mjs → chunk-7Y45UTRL.mjs} +2 -2
  86. package/dist/esm/chunk-7Z6DYLCA.mjs +1 -0
  87. package/dist/esm/chunk-7Z6DYLCA.mjs.map +1 -0
  88. package/dist/esm/{chunk-T2AGN5YT.mjs → chunk-A2Z7I2EY.mjs} +2 -2
  89. package/dist/esm/{chunk-36QXVFR5.mjs → chunk-A63SMUOU.mjs} +2 -2
  90. package/dist/esm/{chunk-36QXVFR5.mjs.map → chunk-A63SMUOU.mjs.map} +1 -1
  91. package/dist/esm/chunk-AQ4I7VVB.mjs +1 -0
  92. package/dist/esm/chunk-AQ4I7VVB.mjs.map +1 -0
  93. package/dist/esm/{chunk-3XFID2N4.mjs → chunk-AVH5SYTL.mjs} +2 -2
  94. package/dist/esm/{chunk-3N6N3KOS.mjs → chunk-AYKZA676.mjs} +2 -2
  95. package/dist/esm/{chunk-QRS4DGP3.mjs → chunk-BF46IXHH.mjs} +2 -2
  96. package/dist/esm/chunk-BLVYB7Y3.mjs +2 -0
  97. package/dist/esm/chunk-BLVYB7Y3.mjs.map +1 -0
  98. package/dist/esm/{chunk-PF57EOJY.mjs → chunk-BOYYQAB4.mjs} +2 -2
  99. package/dist/esm/{chunk-RPND23OR.mjs → chunk-BS7EVBWX.mjs} +2 -2
  100. package/dist/esm/{chunk-JX75UKJX.mjs → chunk-BVB3QII3.mjs} +2 -2
  101. package/dist/esm/{chunk-KZZWY4YI.mjs → chunk-C5V4EBVP.mjs} +2 -2
  102. package/dist/esm/{chunk-3BNA74V5.mjs → chunk-CZ6TC4GO.mjs} +2 -2
  103. package/dist/esm/{chunk-2HF2XEHO.mjs → chunk-DLDGUTFV.mjs} +2 -2
  104. package/dist/esm/{chunk-YR7JRJ25.mjs → chunk-DPO352QL.mjs} +2 -2
  105. package/dist/esm/{chunk-GM56MMNJ.mjs → chunk-DW2KZREM.mjs} +2 -2
  106. package/dist/esm/chunk-DZXM2MQY.mjs +2 -0
  107. package/dist/esm/chunk-DZXM2MQY.mjs.map +1 -0
  108. package/dist/esm/{chunk-6YV3366Z.mjs → chunk-EAW6AWYD.mjs} +2 -2
  109. package/dist/esm/{chunk-NUK6JT5I.mjs → chunk-EYIJYUN7.mjs} +2 -2
  110. package/dist/esm/{chunk-AF5WNJOP.mjs → chunk-F74FF323.mjs} +2 -2
  111. package/dist/esm/chunk-FM6ALU5B.mjs +2 -0
  112. package/dist/esm/chunk-FM6ALU5B.mjs.map +1 -0
  113. package/dist/esm/{chunk-ISIUQQMV.mjs → chunk-FNFQA7NS.mjs} +2 -2
  114. package/dist/esm/chunk-FTIW5GGG.mjs +2 -0
  115. package/dist/esm/{chunk-BRVWHCP3.mjs.map → chunk-FTIW5GGG.mjs.map} +1 -1
  116. package/dist/esm/{chunk-G2XVNF2T.mjs → chunk-FYB7C42X.mjs} +2 -2
  117. package/dist/esm/chunk-GFRNBBTY.mjs +2 -0
  118. package/dist/esm/chunk-GFRNBBTY.mjs.map +1 -0
  119. package/dist/esm/{chunk-CEHCDA3G.mjs → chunk-H6YNXJNF.mjs} +2 -2
  120. package/dist/esm/{chunk-47IIBESV.mjs → chunk-HCN7YJGB.mjs} +2 -2
  121. package/dist/esm/chunk-HHE63GFW.mjs +2 -0
  122. package/dist/esm/chunk-HHE63GFW.mjs.map +1 -0
  123. package/dist/esm/{chunk-S3EDNXZE.mjs → chunk-HIHKTLLM.mjs} +20 -18
  124. package/dist/esm/chunk-HIHKTLLM.mjs.map +1 -0
  125. package/dist/esm/chunk-IVVWQKCF.mjs +2 -0
  126. package/dist/esm/chunk-IVVWQKCF.mjs.map +1 -0
  127. package/dist/esm/{chunk-53INTTOI.mjs → chunk-JPDT6E3B.mjs} +2 -2
  128. package/dist/esm/{chunk-J4VNDDKJ.mjs → chunk-JSWBLHMX.mjs} +2 -2
  129. package/dist/esm/{chunk-73QJNN7O.mjs → chunk-K4CTCBLY.mjs} +2 -2
  130. package/dist/esm/{chunk-AQAH67IV.mjs → chunk-K7DBDI2I.mjs} +2 -2
  131. package/dist/esm/{chunk-PIVZMT5D.mjs → chunk-L22R3OIW.mjs} +2 -2
  132. package/dist/esm/{chunk-4GWNWSZP.mjs → chunk-LVSOUCFD.mjs} +2 -2
  133. package/dist/esm/{chunk-AHW3SKT7.mjs → chunk-M3JHXCGV.mjs} +2 -2
  134. package/dist/esm/{chunk-ZRKXS7XG.mjs → chunk-MHZ64FIW.mjs} +2 -2
  135. package/dist/esm/{chunk-UGPALAPN.mjs → chunk-MLDQ2TY2.mjs} +2 -2
  136. package/dist/esm/chunk-MQGW234H.mjs +2 -0
  137. package/dist/esm/chunk-MQGW234H.mjs.map +1 -0
  138. package/dist/esm/chunk-NCUBVHUW.mjs +2 -0
  139. package/dist/esm/chunk-NCUBVHUW.mjs.map +1 -0
  140. package/dist/esm/chunk-NMD45OTM.mjs +2 -0
  141. package/dist/esm/chunk-NMD45OTM.mjs.map +1 -0
  142. package/dist/esm/{chunk-R5VVKRJ2.mjs → chunk-NNQYSSLH.mjs} +2 -2
  143. package/dist/esm/{chunk-CZOD4SCZ.mjs → chunk-NSQLZBCA.mjs} +2 -2
  144. package/dist/esm/{chunk-KAGLWBIJ.mjs → chunk-OPGMT27G.mjs} +2 -2
  145. package/dist/esm/{chunk-N3U47Y6Y.mjs → chunk-P5V7OZNN.mjs} +2 -2
  146. package/dist/esm/{chunk-337U6Q6K.mjs → chunk-PTA3VHTQ.mjs} +2 -2
  147. package/dist/esm/chunk-Q6LFIZ3L.mjs +2 -0
  148. package/dist/esm/chunk-Q6LFIZ3L.mjs.map +1 -0
  149. package/dist/esm/chunk-QAMV4L3K.mjs +2 -0
  150. package/dist/esm/chunk-QAMV4L3K.mjs.map +1 -0
  151. package/dist/esm/{chunk-BEVXJJJF.mjs → chunk-QL2QFRKV.mjs} +2 -2
  152. package/dist/esm/chunk-QVWBJJRF.mjs +2 -0
  153. package/dist/esm/chunk-QVWBJJRF.mjs.map +1 -0
  154. package/dist/esm/{chunk-U3YYSIIT.mjs → chunk-RFA7BIDN.mjs} +2 -2
  155. package/dist/esm/{chunk-G56GPLTB.mjs → chunk-RJ4RKVVQ.mjs} +2 -2
  156. package/dist/esm/{chunk-BBVIJO6X.mjs → chunk-S32JHML7.mjs} +2 -2
  157. package/dist/esm/chunk-SCHZ67F3.mjs +2 -0
  158. package/dist/esm/chunk-SCHZ67F3.mjs.map +1 -0
  159. package/dist/esm/chunk-SFUTXSDK.mjs +2 -0
  160. package/dist/esm/chunk-SFUTXSDK.mjs.map +1 -0
  161. package/dist/esm/{chunk-3SPIFLBZ.mjs → chunk-SLFAROVZ.mjs} +2 -2
  162. package/dist/esm/{chunk-CT2BQQTZ.mjs → chunk-TG2LLWVU.mjs} +2 -2
  163. package/dist/esm/{chunk-35EWRSDK.mjs → chunk-TY4IEDJD.mjs} +2 -2
  164. package/dist/esm/chunk-U4A56FN2.mjs +2 -0
  165. package/dist/esm/{chunk-7UBKXR37.mjs.map → chunk-U4A56FN2.mjs.map} +1 -1
  166. package/dist/esm/chunk-U6X2FYNI.mjs +2 -0
  167. package/dist/esm/chunk-U6X2FYNI.mjs.map +1 -0
  168. package/dist/esm/{chunk-G2UPF44Z.mjs → chunk-UAZUO75M.mjs} +2 -2
  169. package/dist/esm/{chunk-HLC4HAYY.mjs → chunk-UGVNOSD3.mjs} +2 -2
  170. package/dist/esm/{chunk-LGNSPATO.mjs → chunk-VCMP3MXN.mjs} +2 -2
  171. package/dist/esm/{chunk-PZ4SAXY7.mjs → chunk-VTKPSYKA.mjs} +2 -2
  172. package/dist/esm/chunk-VTKPSYKA.mjs.map +1 -0
  173. package/dist/esm/chunk-WQHW4WQN.mjs +2 -0
  174. package/dist/esm/chunk-WQHW4WQN.mjs.map +1 -0
  175. package/dist/esm/chunk-WV5AD4IE.mjs +2 -0
  176. package/dist/esm/{chunk-CE65OKFI.mjs → chunk-XWVU4G57.mjs} +2 -2
  177. package/dist/esm/{chunk-ZHCSSCC5.mjs → chunk-XYLM277Z.mjs} +2 -2
  178. package/dist/esm/chunk-YE5B2S5L.mjs +2 -0
  179. package/dist/esm/chunk-YE5B2S5L.mjs.map +1 -0
  180. package/dist/esm/{chunk-FAFJKSVZ.mjs → chunk-YMUCYX3B.mjs} +2 -2
  181. package/dist/esm/{chunk-SRDIYE3M.mjs → chunk-YPHH6CAO.mjs} +2 -2
  182. package/dist/esm/chunk-YTQVMLFD.mjs +2 -0
  183. package/dist/esm/chunk-YTQVMLFD.mjs.map +1 -0
  184. package/dist/esm/{chunk-B7X6PSE7.mjs → chunk-YUNDX5I7.mjs} +2 -2
  185. package/dist/esm/chunk-Z4YHE4A5.mjs +2 -0
  186. package/dist/esm/{chunk-4BJA3QUQ.mjs.map → chunk-Z4YHE4A5.mjs.map} +1 -1
  187. package/dist/esm/cli/index.mjs +1 -1
  188. package/dist/esm/cli/localNode.mjs +1 -1
  189. package/dist/esm/cli/move.mjs +1 -1
  190. package/dist/esm/client/core.mjs +1 -1
  191. package/dist/esm/client/get.d.mts +8 -1
  192. package/dist/esm/client/get.mjs +1 -1
  193. package/dist/esm/client/index.d.mts +2 -2
  194. package/dist/esm/client/index.mjs +1 -1
  195. package/dist/esm/client/post.d.mts +9 -1
  196. package/dist/esm/client/post.mjs +1 -1
  197. package/dist/esm/core/account/index.mjs +1 -1
  198. package/dist/esm/core/account/utils/address.mjs +1 -1
  199. package/dist/esm/core/account/utils/index.mjs +1 -1
  200. package/dist/esm/core/accountAddress.mjs +1 -1
  201. package/dist/esm/core/authenticationKey.mjs +1 -1
  202. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  203. package/dist/esm/core/crypto/ephemeral.d.mts +73 -0
  204. package/dist/esm/core/crypto/ephemeral.mjs +2 -0
  205. package/dist/esm/core/crypto/ephemeral.mjs.map +1 -0
  206. package/dist/esm/core/crypto/index.d.mts +6 -0
  207. package/dist/esm/core/crypto/index.mjs +1 -1
  208. package/dist/esm/core/crypto/keyless.d.mts +321 -0
  209. package/dist/esm/core/crypto/keyless.mjs +2 -0
  210. package/dist/esm/core/crypto/keyless.mjs.map +1 -0
  211. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  212. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  213. package/dist/esm/core/crypto/poseidon.d.mts +19 -0
  214. package/dist/esm/core/crypto/poseidon.mjs +2 -0
  215. package/dist/esm/core/crypto/poseidon.mjs.map +1 -0
  216. package/dist/esm/core/crypto/proof.d.mts +21 -0
  217. package/dist/esm/core/crypto/proof.mjs +2 -0
  218. package/dist/esm/core/crypto/proof.mjs.map +1 -0
  219. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  220. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  221. package/dist/esm/core/crypto/signature.mjs +1 -1
  222. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  223. package/dist/esm/core/index.d.mts +6 -0
  224. package/dist/esm/core/index.mjs +1 -1
  225. package/dist/esm/index.d.mts +11 -4
  226. package/dist/esm/index.mjs +1 -1
  227. package/dist/esm/internal/account.mjs +1 -1
  228. package/dist/esm/internal/ans.mjs +1 -1
  229. package/dist/esm/internal/coin.mjs +1 -1
  230. package/dist/esm/internal/digitalAsset.mjs +1 -1
  231. package/dist/esm/internal/event.mjs +1 -1
  232. package/dist/esm/internal/faucet.mjs +1 -1
  233. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  234. package/dist/esm/internal/general.mjs +1 -1
  235. package/dist/esm/internal/keyless.d.mts +72 -0
  236. package/dist/esm/internal/keyless.mjs +2 -0
  237. package/dist/esm/internal/keyless.mjs.map +1 -0
  238. package/dist/esm/internal/staking.mjs +1 -1
  239. package/dist/esm/internal/table.mjs +1 -1
  240. package/dist/esm/internal/transaction.mjs +1 -1
  241. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  242. package/dist/esm/internal/view.mjs +1 -1
  243. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  244. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  245. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  246. package/dist/esm/transactions/index.mjs +1 -1
  247. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  248. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  249. package/dist/esm/transactions/instances/index.mjs +1 -1
  250. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  251. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  252. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  253. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  254. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  255. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  256. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  257. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  258. package/dist/esm/transactions/management/index.mjs +1 -1
  259. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  260. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  261. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  262. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  263. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +3 -0
  264. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  265. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  266. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  267. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  268. package/dist/esm/types/generated/operations.d.mts +14 -12
  269. package/dist/esm/types/generated/queries.d.mts +4 -4
  270. package/dist/esm/types/generated/queries.mjs +1 -1
  271. package/dist/esm/types/generated/types.d.mts +20 -2
  272. package/dist/esm/types/generated/types.mjs +1 -1
  273. package/dist/esm/types/generated/types.mjs.map +1 -1
  274. package/dist/esm/types/index.d.mts +21 -5
  275. package/dist/esm/types/index.mjs +1 -1
  276. package/dist/esm/types/keyless.d.mts +51 -0
  277. package/dist/esm/types/keyless.mjs +1 -0
  278. package/dist/esm/types/keyless.mjs.map +1 -0
  279. package/dist/esm/utils/apiEndpoints.d.mts +3 -1
  280. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  281. package/dist/esm/utils/const.d.mts +3 -1
  282. package/dist/esm/utils/const.mjs +1 -1
  283. package/dist/esm/utils/helpers.d.mts +4 -1
  284. package/dist/esm/utils/helpers.mjs +1 -1
  285. package/dist/esm/utils/index.d.mts +1 -1
  286. package/dist/esm/utils/index.mjs +1 -1
  287. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  288. package/dist/esm/version.d.mts +1 -1
  289. package/dist/esm/version.mjs +1 -1
  290. package/package.json +9 -3
  291. package/src/account/EphemeralKeyPair.ts +150 -0
  292. package/src/account/KeylessAccount.ts +370 -0
  293. package/src/account/MultiKeyAccount.ts +12 -0
  294. package/src/account/index.ts +2 -0
  295. package/src/api/aptos.ts +6 -0
  296. package/src/api/aptosConfig.ts +46 -1
  297. package/src/api/keyless.ts +78 -0
  298. package/src/bcs/deserializer.ts +40 -0
  299. package/src/bcs/serializer.ts +57 -0
  300. package/src/cli/move.ts +4 -7
  301. package/src/client/core.ts +4 -0
  302. package/src/client/get.ts +12 -0
  303. package/src/client/post.ts +18 -0
  304. package/src/core/crypto/ephemeral.ts +138 -0
  305. package/src/core/crypto/index.ts +2 -0
  306. package/src/core/crypto/keyless.ts +679 -0
  307. package/src/core/crypto/poseidon.ts +144 -0
  308. package/src/core/crypto/proof.ts +16 -0
  309. package/src/core/crypto/singleKey.ts +11 -0
  310. package/src/internal/keyless.ts +129 -0
  311. package/src/internal/queries/getFungibleAssetMetadata.graphql +2 -0
  312. package/src/internal/transactionSubmission.ts +6 -1
  313. package/src/transactions/management/accountSequenceNumber.ts +5 -8
  314. package/src/transactions/transactionBuilder/signingMessage.ts +3 -0
  315. package/src/transactions/transactionBuilder/transactionBuilder.ts +16 -1
  316. package/src/types/generated/operations.ts +14 -12
  317. package/src/types/generated/queries.ts +30 -3
  318. package/src/types/generated/types.ts +20 -2
  319. package/src/types/index.ts +24 -2
  320. package/src/types/keyless.ts +42 -0
  321. package/src/utils/apiEndpoints.ts +16 -0
  322. package/src/utils/const.ts +2 -0
  323. package/src/utils/helpers.ts +22 -0
  324. package/src/version.ts +1 -1
  325. package/dist/common/chunk-KSEUZTKY.js +0 -2
  326. package/dist/common/chunk-KSEUZTKY.js.map +0 -1
  327. package/dist/esm/chunk-3JPVQHOR.mjs +0 -2
  328. package/dist/esm/chunk-3JPVQHOR.mjs.map +0 -1
  329. package/dist/esm/chunk-4BJA3QUQ.mjs +0 -2
  330. package/dist/esm/chunk-6IFMQ5AS.mjs +0 -2
  331. package/dist/esm/chunk-6IFMQ5AS.mjs.map +0 -1
  332. package/dist/esm/chunk-746MU2AB.mjs +0 -2
  333. package/dist/esm/chunk-746MU2AB.mjs.map +0 -1
  334. package/dist/esm/chunk-7UBKXR37.mjs +0 -2
  335. package/dist/esm/chunk-BRVWHCP3.mjs +0 -2
  336. package/dist/esm/chunk-CYNQRMO5.mjs +0 -2
  337. package/dist/esm/chunk-CYNQRMO5.mjs.map +0 -1
  338. package/dist/esm/chunk-D2LNQMKD.mjs +0 -2
  339. package/dist/esm/chunk-D2LNQMKD.mjs.map +0 -1
  340. package/dist/esm/chunk-DLAIJ2UM.mjs +0 -2
  341. package/dist/esm/chunk-DLAIJ2UM.mjs.map +0 -1
  342. package/dist/esm/chunk-HYCGMFC2.mjs +0 -2
  343. package/dist/esm/chunk-HYCGMFC2.mjs.map +0 -1
  344. package/dist/esm/chunk-IENCDVPF.mjs +0 -2
  345. package/dist/esm/chunk-IENCDVPF.mjs.map +0 -1
  346. package/dist/esm/chunk-MM5VMKFE.mjs +0 -2
  347. package/dist/esm/chunk-MM5VMKFE.mjs.map +0 -1
  348. package/dist/esm/chunk-OWW6SIDP.mjs +0 -2
  349. package/dist/esm/chunk-OWW6SIDP.mjs.map +0 -1
  350. package/dist/esm/chunk-PZ4SAXY7.mjs.map +0 -1
  351. package/dist/esm/chunk-ROXFCLDT.mjs +0 -2
  352. package/dist/esm/chunk-RTSWVT2Q.mjs +0 -2
  353. package/dist/esm/chunk-RTSWVT2Q.mjs.map +0 -1
  354. package/dist/esm/chunk-S3EDNXZE.mjs.map +0 -1
  355. package/dist/esm/chunk-SUAMDMAA.mjs +0 -2
  356. package/dist/esm/chunk-UO3NZ5AH.mjs +0 -1
  357. package/dist/esm/chunk-UTKM2WYS.mjs +0 -2
  358. package/dist/esm/chunk-UTKM2WYS.mjs.map +0 -1
  359. package/dist/esm/chunk-UVSRX4SV.mjs +0 -1
  360. package/dist/esm/chunk-W33BZ6IQ.mjs +0 -2
  361. package/dist/esm/chunk-W33BZ6IQ.mjs.map +0 -1
  362. /package/dist/esm/{chunk-UO3NZ5AH.mjs.map → account/EphemeralKeyPair.mjs.map} +0 -0
  363. /package/dist/esm/{chunk-UVSRX4SV.mjs.map → account/KeylessAccount.mjs.map} +0 -0
  364. /package/dist/esm/{chunk-TQLED4KC.mjs.map → chunk-2DSPX6BX.mjs.map} +0 -0
  365. /package/dist/esm/{chunk-RWXHA4QZ.mjs.map → chunk-3VUSIKCF.mjs.map} +0 -0
  366. /package/dist/esm/{chunk-MCRRHBFQ.mjs.map → chunk-4EPLOSKY.mjs.map} +0 -0
  367. /package/dist/esm/{chunk-BSVNV6SJ.mjs.map → chunk-4IBJW3PB.mjs.map} +0 -0
  368. /package/dist/esm/{chunk-J6HKAEKY.mjs.map → chunk-5X2BJDOB.mjs.map} +0 -0
  369. /package/dist/esm/{chunk-5UKBTF7N.mjs.map → chunk-5YHI7WOB.mjs.map} +0 -0
  370. /package/dist/esm/{chunk-J5I4OZAS.mjs.map → chunk-6DYDZSEW.mjs.map} +0 -0
  371. /package/dist/esm/{chunk-J4Z6XR5D.mjs.map → chunk-6JL2U7JB.mjs.map} +0 -0
  372. /package/dist/esm/{chunk-RNL5TAQT.mjs.map → chunk-6UDHM6YZ.mjs.map} +0 -0
  373. /package/dist/esm/{chunk-2X7A4HUS.mjs.map → chunk-6ZQWPHLV.mjs.map} +0 -0
  374. /package/dist/esm/{chunk-4NHWV5AI.mjs.map → chunk-76OH2Z4Q.mjs.map} +0 -0
  375. /package/dist/esm/{chunk-5EN52MUT.mjs.map → chunk-77NXCSLY.mjs.map} +0 -0
  376. /package/dist/esm/{chunk-ND6OMSQU.mjs.map → chunk-7Y45UTRL.mjs.map} +0 -0
  377. /package/dist/esm/{chunk-T2AGN5YT.mjs.map → chunk-A2Z7I2EY.mjs.map} +0 -0
  378. /package/dist/esm/{chunk-3XFID2N4.mjs.map → chunk-AVH5SYTL.mjs.map} +0 -0
  379. /package/dist/esm/{chunk-3N6N3KOS.mjs.map → chunk-AYKZA676.mjs.map} +0 -0
  380. /package/dist/esm/{chunk-QRS4DGP3.mjs.map → chunk-BF46IXHH.mjs.map} +0 -0
  381. /package/dist/esm/{chunk-PF57EOJY.mjs.map → chunk-BOYYQAB4.mjs.map} +0 -0
  382. /package/dist/esm/{chunk-RPND23OR.mjs.map → chunk-BS7EVBWX.mjs.map} +0 -0
  383. /package/dist/esm/{chunk-JX75UKJX.mjs.map → chunk-BVB3QII3.mjs.map} +0 -0
  384. /package/dist/esm/{chunk-KZZWY4YI.mjs.map → chunk-C5V4EBVP.mjs.map} +0 -0
  385. /package/dist/esm/{chunk-3BNA74V5.mjs.map → chunk-CZ6TC4GO.mjs.map} +0 -0
  386. /package/dist/esm/{chunk-2HF2XEHO.mjs.map → chunk-DLDGUTFV.mjs.map} +0 -0
  387. /package/dist/esm/{chunk-YR7JRJ25.mjs.map → chunk-DPO352QL.mjs.map} +0 -0
  388. /package/dist/esm/{chunk-GM56MMNJ.mjs.map → chunk-DW2KZREM.mjs.map} +0 -0
  389. /package/dist/esm/{chunk-6YV3366Z.mjs.map → chunk-EAW6AWYD.mjs.map} +0 -0
  390. /package/dist/esm/{chunk-NUK6JT5I.mjs.map → chunk-EYIJYUN7.mjs.map} +0 -0
  391. /package/dist/esm/{chunk-AF5WNJOP.mjs.map → chunk-F74FF323.mjs.map} +0 -0
  392. /package/dist/esm/{chunk-ISIUQQMV.mjs.map → chunk-FNFQA7NS.mjs.map} +0 -0
  393. /package/dist/esm/{chunk-G2XVNF2T.mjs.map → chunk-FYB7C42X.mjs.map} +0 -0
  394. /package/dist/esm/{chunk-CEHCDA3G.mjs.map → chunk-H6YNXJNF.mjs.map} +0 -0
  395. /package/dist/esm/{chunk-47IIBESV.mjs.map → chunk-HCN7YJGB.mjs.map} +0 -0
  396. /package/dist/esm/{chunk-53INTTOI.mjs.map → chunk-JPDT6E3B.mjs.map} +0 -0
  397. /package/dist/esm/{chunk-J4VNDDKJ.mjs.map → chunk-JSWBLHMX.mjs.map} +0 -0
  398. /package/dist/esm/{chunk-73QJNN7O.mjs.map → chunk-K4CTCBLY.mjs.map} +0 -0
  399. /package/dist/esm/{chunk-AQAH67IV.mjs.map → chunk-K7DBDI2I.mjs.map} +0 -0
  400. /package/dist/esm/{chunk-PIVZMT5D.mjs.map → chunk-L22R3OIW.mjs.map} +0 -0
  401. /package/dist/esm/{chunk-4GWNWSZP.mjs.map → chunk-LVSOUCFD.mjs.map} +0 -0
  402. /package/dist/esm/{chunk-AHW3SKT7.mjs.map → chunk-M3JHXCGV.mjs.map} +0 -0
  403. /package/dist/esm/{chunk-ZRKXS7XG.mjs.map → chunk-MHZ64FIW.mjs.map} +0 -0
  404. /package/dist/esm/{chunk-UGPALAPN.mjs.map → chunk-MLDQ2TY2.mjs.map} +0 -0
  405. /package/dist/esm/{chunk-R5VVKRJ2.mjs.map → chunk-NNQYSSLH.mjs.map} +0 -0
  406. /package/dist/esm/{chunk-CZOD4SCZ.mjs.map → chunk-NSQLZBCA.mjs.map} +0 -0
  407. /package/dist/esm/{chunk-KAGLWBIJ.mjs.map → chunk-OPGMT27G.mjs.map} +0 -0
  408. /package/dist/esm/{chunk-N3U47Y6Y.mjs.map → chunk-P5V7OZNN.mjs.map} +0 -0
  409. /package/dist/esm/{chunk-337U6Q6K.mjs.map → chunk-PTA3VHTQ.mjs.map} +0 -0
  410. /package/dist/esm/{chunk-BEVXJJJF.mjs.map → chunk-QL2QFRKV.mjs.map} +0 -0
  411. /package/dist/esm/{chunk-U3YYSIIT.mjs.map → chunk-RFA7BIDN.mjs.map} +0 -0
  412. /package/dist/esm/{chunk-G56GPLTB.mjs.map → chunk-RJ4RKVVQ.mjs.map} +0 -0
  413. /package/dist/esm/{chunk-BBVIJO6X.mjs.map → chunk-S32JHML7.mjs.map} +0 -0
  414. /package/dist/esm/{chunk-3SPIFLBZ.mjs.map → chunk-SLFAROVZ.mjs.map} +0 -0
  415. /package/dist/esm/{chunk-CT2BQQTZ.mjs.map → chunk-TG2LLWVU.mjs.map} +0 -0
  416. /package/dist/esm/{chunk-35EWRSDK.mjs.map → chunk-TY4IEDJD.mjs.map} +0 -0
  417. /package/dist/esm/{chunk-G2UPF44Z.mjs.map → chunk-UAZUO75M.mjs.map} +0 -0
  418. /package/dist/esm/{chunk-HLC4HAYY.mjs.map → chunk-UGVNOSD3.mjs.map} +0 -0
  419. /package/dist/esm/{chunk-LGNSPATO.mjs.map → chunk-VCMP3MXN.mjs.map} +0 -0
  420. /package/dist/esm/{chunk-ROXFCLDT.mjs.map → chunk-WV5AD4IE.mjs.map} +0 -0
  421. /package/dist/esm/{chunk-CE65OKFI.mjs.map → chunk-XWVU4G57.mjs.map} +0 -0
  422. /package/dist/esm/{chunk-ZHCSSCC5.mjs.map → chunk-XYLM277Z.mjs.map} +0 -0
  423. /package/dist/esm/{chunk-FAFJKSVZ.mjs.map → chunk-YMUCYX3B.mjs.map} +0 -0
  424. /package/dist/esm/{chunk-SRDIYE3M.mjs.map → chunk-YPHH6CAO.mjs.map} +0 -0
  425. /package/dist/esm/{chunk-B7X6PSE7.mjs.map → chunk-YUNDX5I7.mjs.map} +0 -0
@@ -0,0 +1,370 @@
1
+ // Copyright © Aptos Foundation
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { JwtPayload, jwtDecode } from "jwt-decode";
5
+ import EventEmitter from "eventemitter3";
6
+ import { EphemeralCertificateVariant, HexInput, SigningScheme } from "../types";
7
+ import { AccountAddress } from "../core/accountAddress";
8
+ import {
9
+ AnyPublicKey,
10
+ AnySignature,
11
+ KeylessPublicKey,
12
+ KeylessSignature,
13
+ EphemeralCertificate,
14
+ Signature,
15
+ ZeroKnowledgeSig,
16
+ ZkProof,
17
+ } from "../core/crypto";
18
+
19
+ import { Account } from "./Account";
20
+ import { EphemeralKeyPair } from "./EphemeralKeyPair";
21
+ import { Hex } from "../core/hex";
22
+ import { AccountAuthenticatorSingleKey } from "../transactions/authenticator/account";
23
+ import { Deserializer, Serializable, Serializer } from "../bcs";
24
+ import { deriveTransactionType, generateSigningMessage } from "../transactions/transactionBuilder/signingMessage";
25
+ import { AnyRawTransaction, AnyRawTransactionInstance } from "../transactions/types";
26
+ import { base64UrlDecode } from "../utils/helpers";
27
+
28
+ /**
29
+ * Account implementation for the Keyless authentication scheme.
30
+ *
31
+ * Used to represent a Keyless based account and sign transactions with it.
32
+ *
33
+ * Use KeylessAccount.fromJWTAndProof to instantiate a KeylessAccount with a JWT, proof and EphemeralKeyPair.
34
+ *
35
+ * When the proof expires or the JWT becomes invalid, the KeylessAccount must be instantiated again with a new JWT,
36
+ * EphemeralKeyPair, and corresponding proof.
37
+ */
38
+ export class KeylessAccount extends Serializable implements Account {
39
+ static readonly PEPPER_LENGTH: number = 31;
40
+
41
+ /**
42
+ * The KeylessPublicKey associated with the account
43
+ */
44
+ readonly publicKey: KeylessPublicKey;
45
+
46
+ /**
47
+ * The EphemeralKeyPair used to generate sign.
48
+ */
49
+ readonly ephemeralKeyPair: EphemeralKeyPair;
50
+
51
+ /**
52
+ * The claim on the JWT to identify a user. This is typically 'sub' or 'email'.
53
+ */
54
+ readonly uidKey: string;
55
+
56
+ /**
57
+ * The value of the uidKey claim on the JWT. This intended to be a stable user identifier.
58
+ */
59
+ readonly uidVal: string;
60
+
61
+ /**
62
+ * The value of the 'aud' claim on the JWT, also known as client ID. This is the identifier for the dApp's
63
+ * OIDC registration with the identity provider.
64
+ */
65
+ readonly aud: string;
66
+
67
+ /**
68
+ * A value contains 31 bytes of entropy that preserves privacy of the account. Typically fetched from a pepper provider.
69
+ */
70
+ readonly pepper: Uint8Array;
71
+
72
+ /**
73
+ * Account address associated with the account
74
+ */
75
+ readonly accountAddress: AccountAddress;
76
+
77
+ /**
78
+ * The zero knowledge signature (if ready) which contains the proof used to validate the EphemeralKeyPair.
79
+ */
80
+ proof: ZeroKnowledgeSig | undefined;
81
+
82
+ /**
83
+ * The proof of the EphemeralKeyPair or a promise that provides the proof. This is used to allow for awaiting on
84
+ * fetching the proof.
85
+ */
86
+ readonly proofOrPromise: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;
87
+
88
+ /**
89
+ * Signing scheme used to sign transactions
90
+ */
91
+ readonly signingScheme: SigningScheme;
92
+
93
+ /**
94
+ * The JWT token used to derive the account
95
+ */
96
+ readonly jwt: string;
97
+
98
+ /**
99
+ * An event emitter used to assist in handling asycronous proof fetching.
100
+ */
101
+ private readonly emitter: EventEmitter<ProofFetchEvents>;
102
+
103
+ // Use the static constructor 'create' instead.
104
+ private constructor(args: {
105
+ address?: AccountAddress;
106
+ ephemeralKeyPair: EphemeralKeyPair;
107
+ iss: string;
108
+ uidKey: string;
109
+ uidVal: string;
110
+ aud: string;
111
+ pepper: HexInput;
112
+ proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;
113
+ proofFetchCallback?: ProofFetchCallback;
114
+ jwt: string;
115
+ }) {
116
+ super();
117
+ const { address, ephemeralKeyPair, uidKey, uidVal, aud, pepper, proof, proofFetchCallback, jwt } = args;
118
+ this.ephemeralKeyPair = ephemeralKeyPair;
119
+ this.publicKey = KeylessPublicKey.create(args);
120
+ this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();
121
+ this.uidKey = uidKey;
122
+ this.uidVal = uidVal;
123
+ this.aud = aud;
124
+ this.jwt = jwt;
125
+ this.emitter = new EventEmitter<ProofFetchEvents>();
126
+ this.proofOrPromise = proof;
127
+ if (proof instanceof ZeroKnowledgeSig) {
128
+ this.proof = proof;
129
+ } else {
130
+ if (proofFetchCallback === undefined) {
131
+ throw new Error("Must provide callback for async proof fetch");
132
+ }
133
+ this.emitter.on("proofFetchFinish", async (status) => {
134
+ await proofFetchCallback(status);
135
+ this.emitter.removeAllListeners();
136
+ });
137
+ this.init(proof);
138
+ }
139
+ this.signingScheme = SigningScheme.SingleKey;
140
+ const pepperBytes = Hex.fromHexInput(pepper).toUint8Array();
141
+ if (pepperBytes.length !== KeylessAccount.PEPPER_LENGTH) {
142
+ throw new Error(`Pepper length in bytes should be ${KeylessAccount.PEPPER_LENGTH}`);
143
+ }
144
+ this.pepper = pepperBytes;
145
+ }
146
+
147
+ /**
148
+ * This initializes the asyncronous proof fetch
149
+ * @return
150
+ */
151
+ async init(promise: Promise<ZeroKnowledgeSig>) {
152
+ try {
153
+ this.proof = await promise;
154
+ this.emitter.emit("proofFetchFinish", { status: "Success" });
155
+ } catch (error) {
156
+ if (error instanceof Error) {
157
+ this.emitter.emit("proofFetchFinish", { status: "Failed", error: error.toString() });
158
+ } else {
159
+ this.emitter.emit("proofFetchFinish", { status: "Failed", error: "Unknown" });
160
+ }
161
+ }
162
+ }
163
+
164
+ serialize(serializer: Serializer): void {
165
+ serializer.serializeStr(this.jwt);
166
+ serializer.serializeStr(this.uidKey);
167
+ serializer.serializeFixedBytes(this.pepper);
168
+ this.ephemeralKeyPair.serialize(serializer);
169
+ if (this.proof === undefined) {
170
+ throw new Error("Connot serialize - proof undefined");
171
+ }
172
+ this.proof.serialize(serializer);
173
+ }
174
+
175
+ static deserialize(deserializer: Deserializer): KeylessAccount {
176
+ const jwt = deserializer.deserializeStr();
177
+ const uidKey = deserializer.deserializeStr();
178
+ const pepper = deserializer.deserializeFixedBytes(31);
179
+ const ephemeralKeyPair = EphemeralKeyPair.deserialize(deserializer);
180
+ const proof = ZeroKnowledgeSig.deserialize(deserializer);
181
+ return KeylessAccount.create({
182
+ proof,
183
+ pepper,
184
+ uidKey,
185
+ jwt,
186
+ ephemeralKeyPair,
187
+ });
188
+ }
189
+
190
+ /**
191
+ * Checks if the proof is expired. If so the account must be rederived with a new EphemeralKeyPair
192
+ * and JWT token.
193
+ * @return boolean
194
+ */
195
+ isExpired(): boolean {
196
+ return this.ephemeralKeyPair.isExpired();
197
+ }
198
+
199
+ /**
200
+ * Sign a message using Keyless.
201
+ * @param message the message to sign, as binary input
202
+ * @return the AccountAuthenticator containing the signature, together with the account's public key
203
+ */
204
+ signWithAuthenticator(message: HexInput): AccountAuthenticatorSingleKey {
205
+ const signature = new AnySignature(this.sign(message));
206
+ const publicKey = new AnyPublicKey(this.publicKey);
207
+ return new AccountAuthenticatorSingleKey(publicKey, signature);
208
+ }
209
+
210
+ /**
211
+ * Sign a transaction using Keyless.
212
+ * @param transaction the raw transaction
213
+ * @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key
214
+ */
215
+ signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorSingleKey {
216
+ const signature = new AnySignature(this.signTransaction(transaction));
217
+ const publicKey = new AnyPublicKey(this.publicKey);
218
+ return new AccountAuthenticatorSingleKey(publicKey, signature);
219
+ }
220
+
221
+ /**
222
+ * Waits for asyncronous proof fetching to finish.
223
+ * @return
224
+ */
225
+ async waitForProofFetch() {
226
+ if (this.proofOrPromise instanceof Promise) {
227
+ await this.proofOrPromise;
228
+ }
229
+ }
230
+
231
+ /**
232
+ * Sign the given message using Keyless.
233
+ * @param message in HexInput format
234
+ * @returns Signature
235
+ */
236
+ sign(data: HexInput): KeylessSignature {
237
+ const { expiryDateSecs } = this.ephemeralKeyPair;
238
+ if (this.isExpired()) {
239
+ throw new Error("EphemeralKeyPair is expired");
240
+ }
241
+ if (this.proof === undefined) {
242
+ throw new Error("Proof not defined");
243
+ }
244
+ const ephemeralPublicKey = this.ephemeralKeyPair.getPublicKey();
245
+ const ephemeralSignature = this.ephemeralKeyPair.sign(data);
246
+
247
+ return new KeylessSignature({
248
+ jwtHeader: base64UrlDecode(this.jwt.split(".")[0]),
249
+ ephemeralCertificate: new EphemeralCertificate(this.proof, EphemeralCertificateVariant.ZkProof),
250
+ expiryDateSecs,
251
+ ephemeralPublicKey,
252
+ ephemeralSignature,
253
+ });
254
+ }
255
+
256
+ /**
257
+ * Sign the given transaction with Keyless.
258
+ * Signs the transaction and proof to guard against proof malleability.
259
+ * @param transaction the transaction to be signed
260
+ * @returns KeylessSignature
261
+ */
262
+ signTransaction(transaction: AnyRawTransaction): KeylessSignature {
263
+ if (this.proof === undefined) {
264
+ throw new Error("Proof not found");
265
+ }
266
+ const raw = deriveTransactionType(transaction);
267
+ const txnAndProof = new TransactionAndProof(raw, this.proof.proof);
268
+ const signMess = txnAndProof.hash();
269
+ return this.sign(signMess);
270
+ }
271
+
272
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this
273
+ verifySignature(args: { message: HexInput; signature: Signature }): boolean {
274
+ throw new Error("Not implemented");
275
+ }
276
+
277
+ static fromBytes(bytes: Uint8Array): KeylessAccount {
278
+ return KeylessAccount.deserialize(new Deserializer(bytes));
279
+ }
280
+
281
+ static create(args: {
282
+ address?: AccountAddress;
283
+ proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;
284
+ jwt: string;
285
+ ephemeralKeyPair: EphemeralKeyPair;
286
+ pepper: HexInput;
287
+ uidKey?: string;
288
+ proofFetchCallback?: ProofFetchCallback;
289
+ }): KeylessAccount {
290
+ const { address, proof, jwt, ephemeralKeyPair, pepper, uidKey = "sub", proofFetchCallback } = args;
291
+
292
+ const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);
293
+ const iss = jwtPayload.iss!;
294
+ if (typeof jwtPayload.aud !== "string") {
295
+ throw new Error("aud was not found or an array of values");
296
+ }
297
+ const aud = jwtPayload.aud!;
298
+ const uidVal = jwtPayload[uidKey];
299
+ return new KeylessAccount({
300
+ address,
301
+ proof,
302
+ ephemeralKeyPair,
303
+ iss,
304
+ uidKey,
305
+ uidVal,
306
+ aud,
307
+ pepper,
308
+ jwt,
309
+ proofFetchCallback,
310
+ });
311
+ }
312
+ }
313
+
314
+ /**
315
+ * A container class to hold a transaction and a proof. It implements CryptoHashable which is used to create
316
+ * the signing message for Keyless transactions. We sign over the proof to ensure non-malleability.
317
+ */
318
+ class TransactionAndProof extends Serializable {
319
+ /**
320
+ * The transaction to sign.
321
+ */
322
+ transaction: AnyRawTransactionInstance;
323
+
324
+ /**
325
+ * The zero knowledge proof used in signing the transaction.
326
+ */
327
+ proof?: ZkProof;
328
+
329
+ /**
330
+ * The domain separator prefix used when hashing.
331
+ */
332
+ readonly domainSeparator = "APTOS::TransactionAndProof";
333
+
334
+ constructor(transaction: AnyRawTransactionInstance, proof?: ZkProof) {
335
+ super();
336
+ this.transaction = transaction;
337
+ this.proof = proof;
338
+ }
339
+
340
+ serialize(serializer: Serializer): void {
341
+ serializer.serializeFixedBytes(this.transaction.bcsToBytes());
342
+ serializer.serializeOption(this.proof);
343
+ }
344
+
345
+ /**
346
+ * Hashes the bcs serialized from of the class. This is the typescript corollary to the BCSCryptoHash macro in aptos-core.
347
+ *
348
+ * @returns Uint8Array
349
+ */
350
+ hash(): Uint8Array {
351
+ return generateSigningMessage(this.bcsToBytes(), this.domainSeparator);
352
+ }
353
+ }
354
+
355
+ export type ProofFetchSuccess = {
356
+ status: "Success";
357
+ };
358
+
359
+ export type ProofFetchFailure = {
360
+ status: "Failed";
361
+ error: string;
362
+ };
363
+
364
+ export type ProofFetchStatus = ProofFetchSuccess | ProofFetchFailure;
365
+
366
+ export type ProofFetchCallback = (status: ProofFetchStatus) => Promise<void>;
367
+
368
+ export interface ProofFetchEvents {
369
+ proofFetchFinish: (status: ProofFetchStatus) => void;
370
+ }
@@ -7,6 +7,7 @@ import { AccountAddress } 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
11
 
11
12
  export interface VerifyMultiKeySignatureArgs {
12
13
  message: HexInput;
@@ -123,6 +124,17 @@ export class MultiKeyAccount implements Account {
123
124
  return new AccountAuthenticatorMultiKey(this.publicKey, this.signTransaction(transaction));
124
125
  }
125
126
 
127
+ /**
128
+ * Waits for any proofs on any KeylessAccount signers to be fetched. If the proof is fetched a syncronously, call this
129
+ * to ensure signing with the KeylessAccount does not fail as the proof must be ready.
130
+ * @return
131
+ */
132
+ async waitForProofFetch() {
133
+ const keylessSigners = this.signers.filter((signer) => signer instanceof KeylessAccount) as KeylessAccount[];
134
+ const promises = keylessSigners.map(async (signer) => signer.waitForProofFetch());
135
+ await Promise.all(promises);
136
+ }
137
+
126
138
  /**
127
139
  * Sign the given message using the MultiKeyAccount's signers
128
140
  * @param message in HexInput format
@@ -1,4 +1,6 @@
1
1
  export * from "./Ed25519Account";
2
2
  export * from "./Account";
3
3
  export * from "./SingleKeyAccount";
4
+ export * from "./EphemeralKeyPair";
5
+ export * from "./KeylessAccount";
4
6
  export * from "./MultiKeyAccount";
package/src/api/aptos.ts CHANGED
@@ -13,6 +13,7 @@ import { ANS } from "./ans";
13
13
  import { Staking } from "./staking";
14
14
  import { Transaction } from "./transaction";
15
15
  import { Table } from "./table";
16
+ import { Keyless } from "./keyless";
16
17
 
17
18
  /**
18
19
  * This class is the main entry point into Aptos's
@@ -50,6 +51,8 @@ export class Aptos {
50
51
 
51
52
  readonly table: Table;
52
53
 
54
+ readonly keyless: Keyless;
55
+
53
56
  constructor(settings?: AptosConfig) {
54
57
  this.config = new AptosConfig(settings);
55
58
  this.account = new Account(this.config);
@@ -63,6 +66,7 @@ export class Aptos {
63
66
  this.staking = new Staking(this.config);
64
67
  this.transaction = new Transaction(this.config);
65
68
  this.table = new Table(this.config);
69
+ this.keyless = new Keyless(this.config);
66
70
  }
67
71
  }
68
72
 
@@ -77,6 +81,7 @@ export interface Aptos
77
81
  Faucet,
78
82
  FungibleAsset,
79
83
  General,
84
+ Keyless,
80
85
  Staking,
81
86
  Table,
82
87
  Omit<Transaction, "build" | "simulate" | "submit" | "batch"> {}
@@ -113,3 +118,4 @@ applyMixin(Aptos, General, "general");
113
118
  applyMixin(Aptos, Staking, "staking");
114
119
  applyMixin(Aptos, Transaction, "transaction");
115
120
  applyMixin(Aptos, Table, "table");
121
+ applyMixin(Aptos, Keyless, "keyless");
@@ -3,7 +3,14 @@
3
3
 
4
4
  import aptosClient from "@aptos-labs/aptos-client";
5
5
  import { AptosSettings, ClientConfig, Client, FullNodeConfig, IndexerConfig, FaucetConfig } from "../types";
6
- import { NetworkToNodeAPI, NetworkToFaucetAPI, NetworkToIndexerAPI, Network } from "../utils/apiEndpoints";
6
+ import {
7
+ NetworkToNodeAPI,
8
+ NetworkToFaucetAPI,
9
+ NetworkToIndexerAPI,
10
+ Network,
11
+ NetworkToPepperAPI,
12
+ NetworkToProverAPI,
13
+ } from "../utils/apiEndpoints";
7
14
  import { AptosApiType } from "../utils/const";
8
15
 
9
16
  /**
@@ -34,6 +41,16 @@ export class AptosConfig {
34
41
  */
35
42
  readonly faucet?: string;
36
43
 
44
+ /**
45
+ * The optional hardcoded pepper service URL to send requests to instead of using the network
46
+ */
47
+ readonly pepper?: string;
48
+
49
+ /**
50
+ * The optional hardcoded prover service URL to send requests to instead of using the network
51
+ */
52
+ readonly prover?: string;
53
+
37
54
  /**
38
55
  * The optional hardcoded indexer URL to send requests to instead of using the network
39
56
  */
@@ -63,6 +80,8 @@ export class AptosConfig {
63
80
  this.network = settings?.network ?? Network.DEVNET;
64
81
  this.fullnode = settings?.fullnode;
65
82
  this.faucet = settings?.faucet;
83
+ this.pepper = settings?.pepper;
84
+ this.prover = settings?.prover;
66
85
  this.indexer = settings?.indexer;
67
86
  this.client = settings?.client ?? { provider: aptosClient };
68
87
  this.clientConfig = settings?.clientConfig ?? {};
@@ -95,8 +114,34 @@ export class AptosConfig {
95
114
  if (this.indexer !== undefined) return this.indexer;
96
115
  if (this.network === Network.CUSTOM) throw new Error("Please provide a custom indexer url");
97
116
  return NetworkToIndexerAPI[this.network];
117
+ case AptosApiType.PEPPER:
118
+ if (this.pepper !== undefined) return this.pepper;
119
+ if (this.network === Network.CUSTOM) throw new Error("Please provide a custom pepper service url");
120
+ return NetworkToPepperAPI[this.network];
121
+ case AptosApiType.PROVER:
122
+ if (this.prover !== undefined) return this.prover;
123
+ if (this.network === Network.CUSTOM) throw new Error("Please provide a custom prover service url");
124
+ return NetworkToProverAPI[this.network];
98
125
  default:
99
126
  throw Error(`apiType ${apiType} is not supported`);
100
127
  }
101
128
  }
129
+
130
+ /**
131
+ * Checks if the URL is a known pepper service endpoint
132
+ *
133
+ * @internal
134
+ * */
135
+ isPepperServiceRequest(url: string): boolean {
136
+ return NetworkToPepperAPI[this.network] === url;
137
+ }
138
+
139
+ /**
140
+ * Checks if the URL is a known prover service endpoint
141
+ *
142
+ * @internal
143
+ * */
144
+ isProverServiceRequest(url: string): boolean {
145
+ return NetworkToProverAPI[this.network] === url;
146
+ }
102
147
  }
@@ -0,0 +1,78 @@
1
+ // Copyright © Aptos Foundation
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from "../account";
5
+ import { ZeroKnowledgeSig } from "../core";
6
+ import { deriveKeylessAccount, getPepper, getProof } from "../internal/keyless";
7
+ import { HexInput } from "../types";
8
+ import { AptosConfig } from "./aptosConfig";
9
+
10
+ /**
11
+ * A class to query all `Keyless` related queries on Aptos.
12
+ *
13
+ * More documentation on how to integrate Keyless Accounts see the below
14
+ * https://aptos.dev/guides/keyless-accounts/#aptos-keyless-integration-guide
15
+ */
16
+ export class Keyless {
17
+ constructor(readonly config: AptosConfig) {}
18
+
19
+ /**
20
+ * Fetches the pepper from the Aptos pepper service API.
21
+ *
22
+ * @param args.jwt JWT token
23
+ * @param args.ephemeralKeyPair the EphemeralKeyPair used to generate the nonce in the JWT token
24
+ * @param args.derivationPath a derivation path used for creating multiple accounts per user via the BIP-44 standard. Defaults
25
+ * to "m/44'/637'/0'/0'/0".
26
+ * @returns The pepper which is a Uint8Array of length 31.
27
+ */
28
+ async getPepper(args: {
29
+ jwt: string;
30
+ ephemeralKeyPair: EphemeralKeyPair;
31
+ derivationPath?: string;
32
+ }): Promise<Uint8Array> {
33
+ return getPepper({ aptosConfig: this.config, ...args });
34
+ }
35
+
36
+ /**
37
+ * Fetches a proof from the Aptos prover service API.
38
+ *
39
+ * @param args.jwt JWT token
40
+ * @param args.ephemeralKeyPair the EphemeralKeyPair used to generate the nonce in the JWT token
41
+ * @param args.uidKey a key in the JWT token to use to set the uidVal in the IdCommitment
42
+ * @param args.pepper the pepper used for the account. If not provided it will be fetched from the Aptos pepper service
43
+ *
44
+ * @returns The proof which is represented by a ZeroKnowledgeSig.
45
+ */
46
+ async getProof(args: {
47
+ jwt: string;
48
+ ephemeralKeyPair: EphemeralKeyPair;
49
+ pepper?: HexInput;
50
+ uidKey?: string;
51
+ }): Promise<ZeroKnowledgeSig> {
52
+ return getProof({ aptosConfig: this.config, ...args });
53
+ }
54
+
55
+ /**
56
+ * Derives the Keyless Account from the JWT token and corresponding EphemeralKeyPair. It will lookup the pepper from
57
+ * the pepper service if not explicitly provided. It will compute the proof via the proving service. It will ch
58
+ *
59
+ * @param args.jwt JWT token
60
+ * @param args.ephemeralKeyPair the EphemeralKeyPair used to generate the nonce in the JWT token
61
+ * @param args.uidKey a key in the JWT token to use to set the uidVal in the IdCommitment
62
+ * @param args.pepper the pepper
63
+ * @param args.proofFetchCallback a callback function that if set, the fetch of the proof will be done in the background. Once
64
+ * fetching finishes the callback function will be called. This should be used to provide a more responsive user experience as now
65
+ * they are not blocked on fetching the proof. Thus the function will return much more quickly.
66
+ *
67
+ * @returns A KeylessAccount that can be used to sign transactions
68
+ */
69
+ async deriveKeylessAccount(args: {
70
+ jwt: string;
71
+ ephemeralKeyPair: EphemeralKeyPair;
72
+ uidKey?: string;
73
+ pepper?: HexInput;
74
+ proofFetchCallback?: ProofFetchCallback;
75
+ }): Promise<KeylessAccount> {
76
+ return deriveKeylessAccount({ aptosConfig: this.config, ...args });
77
+ }
78
+ }
@@ -56,6 +56,46 @@ export class Deserializer {
56
56
  return textDecoder.decode(value);
57
57
  }
58
58
 
59
+ /**
60
+ * Deserializes a an optional string.
61
+ *
62
+ * BCS layout for Optional<String>: 0 if none, else 1 | string_length | string_content
63
+ * @example
64
+ * ```ts
65
+ * const deserializer = new Deserializer(new Uint8Array([0x00]));
66
+ * assert(deserializer.deserializeOptionStr() === undefined);
67
+ * const deserializer = new Deserializer(new Uint8Array([1, 8, 49, 50, 51, 52, 97, 98, 99, 100]));
68
+ * assert(deserializer.deserializeOptionStr() === "1234abcd");
69
+ * ```
70
+ */
71
+ deserializeOptionStr(): string | undefined {
72
+ const exists = this.deserializeBool();
73
+ return exists ? this.deserializeStr() : undefined;
74
+ }
75
+
76
+ /**
77
+ * Deserializes a an optional deserializable class.
78
+ *
79
+ * BCS layout for Optional<T>: 0 if none, else 1 | bcs representation of class
80
+ *
81
+ * @example
82
+ * const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));
83
+ * const value = deserializer.deserializeOption(MyClass); // where MyClass has a `deserialize` function
84
+ * // value is now an instance of MyClass
85
+ *
86
+ * const deserializer = new Deserializer(new Uint8Array([0]));
87
+ * const value = deserializer.deserializeOption(MyClass); // where MyClass has a `deserialize` function
88
+ * // value is undefined
89
+ *
90
+ * @param cls The BCS-deserializable class to deserialize the buffered bytes into.
91
+ *
92
+ * @returns the deserialized value of class type T
93
+ */
94
+ deserializeOption<T>(cls: Deserializable<T>): T | undefined {
95
+ const exists = this.deserializeBool();
96
+ return exists ? this.deserialize(cls) : undefined;
97
+ }
98
+
59
99
  /**
60
100
  * Deserializes an array of bytes.
61
101
  *