@aptos-labs/ts-sdk 1.31.0 → 1.32.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.
- package/README.md +1 -1
- package/dist/common/{accountAddress-DnSqjhSl.d.ts → accountAddress-6RqI8Aam.d.ts} +144 -63
- package/dist/common/chunk-F43XVDYJ.js +2 -0
- package/dist/common/chunk-F43XVDYJ.js.map +1 -0
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +542 -111
- package/dist/common/index.js +36 -29
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-DpH9qAcg.d.mts → Ed25519Account-B3xHXAQe.d.mts} +2 -2
- package/dist/esm/account/AbstractKeylessAccount.d.mts +86 -14
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/Account.d.mts +5 -4
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/Ed25519Account.d.mts +5 -4
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.d.mts +4 -3
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.d.mts +57 -8
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.d.mts +29 -11
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +23 -10
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.d.mts +5 -4
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +6 -5
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/api/account.d.mts +6 -5
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +4 -3
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +6 -4
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +2 -1
- package/dist/esm/api/coin.d.mts +4 -3
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +6 -5
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.d.mts +4 -3
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.d.mts +3 -2
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +6 -5
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +4 -3
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +6 -4
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +7 -6
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.d.mts +4 -3
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.d.mts +4 -3
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.d.mts +4 -3
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +5 -3
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +69 -3
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +5 -4
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +5 -4
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
- package/dist/esm/api/transactionSubmission/simulate.d.mts +4 -3
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.d.mts +4 -3
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.d.mts +3 -2
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/consts.d.mts +3 -2
- package/dist/esm/bcs/deserializer.d.mts +36 -27
- package/dist/esm/bcs/deserializer.mjs +1 -1
- package/dist/esm/bcs/index.d.mts +3 -2
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +3 -2
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.d.mts +3 -2
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.d.mts +3 -2
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.d.mts +12 -12
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +14 -13
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/{chunk-4ZK3JNQT.mjs → chunk-2NHQQQZK.mjs} +2 -2
- package/dist/esm/{chunk-MSHZ4FWB.mjs → chunk-2QBCTW67.mjs} +2 -2
- package/dist/esm/{chunk-MSHZ4FWB.mjs.map → chunk-2QBCTW67.mjs.map} +1 -1
- package/dist/esm/{chunk-F2RY4YQ7.mjs → chunk-37Y54PJ5.mjs} +2 -2
- package/dist/esm/chunk-3DQVGPFE.mjs +2 -0
- package/dist/esm/chunk-3DQVGPFE.mjs.map +1 -0
- package/dist/esm/{chunk-OAEDFM7T.mjs → chunk-3XCYCFYI.mjs} +2 -2
- package/dist/esm/{chunk-6FLHGOKP.mjs → chunk-42H7WETG.mjs} +2 -2
- package/dist/esm/{chunk-AZ6LVQEG.mjs → chunk-46L6BAJG.mjs} +2 -2
- package/dist/esm/{chunk-KW4FVBDD.mjs → chunk-4DNCQM3S.mjs} +2 -2
- package/dist/esm/chunk-4O5XDQDO.mjs +2 -0
- package/dist/esm/chunk-4PBXTMN3.mjs +2 -0
- package/dist/esm/chunk-4PBXTMN3.mjs.map +1 -0
- package/dist/esm/chunk-4YEOOZ2N.mjs +4 -0
- package/dist/esm/{chunk-HM5HITUC.mjs.map → chunk-4YEOOZ2N.mjs.map} +1 -1
- package/dist/esm/{chunk-5N6KJ7KS.mjs → chunk-5AKSORBJ.mjs} +2 -2
- package/dist/esm/chunk-5B3SMBXQ.mjs +2 -0
- package/dist/esm/{chunk-UCRROMZN.mjs → chunk-5NJWJXSS.mjs} +2 -2
- package/dist/esm/{chunk-CL6EEMSL.mjs → chunk-6K4TOFCO.mjs} +2 -2
- package/dist/esm/{chunk-RNJHULIT.mjs → chunk-6LLGRGCN.mjs} +2 -2
- package/dist/esm/chunk-6LLGRGCN.mjs.map +1 -0
- package/dist/esm/{chunk-IAVI3H4V.mjs → chunk-6PJH53CK.mjs} +2 -2
- package/dist/esm/{chunk-PCLU4KLY.mjs → chunk-6ZOVTYLJ.mjs} +2 -2
- package/dist/esm/chunk-7ECCT6PK.mjs +1 -0
- package/dist/esm/chunk-7WXDXBXK.mjs +2 -0
- package/dist/esm/{chunk-WV2VJQDS.mjs.map → chunk-7WXDXBXK.mjs.map} +1 -1
- package/dist/esm/{chunk-RAJTNQNL.mjs → chunk-AAATWCJT.mjs} +2 -2
- package/dist/esm/{chunk-NODYW7DM.mjs → chunk-ACVIE7IE.mjs} +2 -2
- package/dist/esm/chunk-AHWZA3GD.mjs +2 -0
- package/dist/esm/chunk-AHWZA3GD.mjs.map +1 -0
- package/dist/esm/{chunk-QQIVWB6G.mjs → chunk-AJ5JHBAE.mjs} +2 -2
- package/dist/esm/{chunk-QQIVWB6G.mjs.map → chunk-AJ5JHBAE.mjs.map} +1 -1
- package/dist/esm/{chunk-PRZ7AIGA.mjs → chunk-AKIO3OIT.mjs} +2 -2
- package/dist/esm/chunk-AMCJQIOT.mjs +2 -0
- package/dist/esm/{chunk-2CGJLPHP.mjs.map → chunk-AMCJQIOT.mjs.map} +1 -1
- package/dist/esm/{chunk-KRVLR3L4.mjs → chunk-AOROYJ74.mjs} +2 -2
- package/dist/esm/chunk-AVPQOD67.mjs +2 -0
- package/dist/esm/chunk-AVPQOD67.mjs.map +1 -0
- package/dist/esm/chunk-AVZYJAXR.mjs +2 -0
- package/dist/esm/chunk-AVZYJAXR.mjs.map +1 -0
- package/dist/esm/{chunk-6DMDYBV6.mjs → chunk-BLLHTGAP.mjs} +2 -2
- package/dist/esm/{chunk-JGNMNCQB.mjs → chunk-BRV3RLKW.mjs} +2 -2
- package/dist/esm/{chunk-7JK7UG4E.mjs → chunk-CA3Q2X6B.mjs} +2 -2
- package/dist/esm/chunk-D52UKPQF.mjs +2 -0
- package/dist/esm/chunk-D52UKPQF.mjs.map +1 -0
- package/dist/esm/{chunk-SOLWFAUY.mjs → chunk-DDVOBEJA.mjs} +2 -2
- package/dist/esm/chunk-DDVOBEJA.mjs.map +1 -0
- package/dist/esm/{chunk-RNRNGJDA.mjs → chunk-DP3YPGIK.mjs} +2 -2
- package/dist/esm/{chunk-KYJU5PWF.mjs → chunk-DSKAMBBL.mjs} +2 -2
- package/dist/esm/{chunk-L5J3V3HW.mjs → chunk-E2NYQVP3.mjs} +2 -2
- package/dist/esm/chunk-EEB7EZFO.mjs +2 -0
- package/dist/esm/chunk-EEB7EZFO.mjs.map +1 -0
- package/dist/esm/{chunk-4JXB6V5O.mjs → chunk-F2AIWA7L.mjs} +2 -2
- package/dist/esm/chunk-F45G3GP3.mjs +7 -0
- package/dist/esm/chunk-F45G3GP3.mjs.map +1 -0
- package/dist/esm/{chunk-WSZCPSV4.mjs → chunk-FXUI3SSD.mjs} +2 -2
- package/dist/esm/chunk-G2GN4LH5.mjs +2 -0
- package/dist/esm/chunk-G2GN4LH5.mjs.map +1 -0
- package/dist/esm/chunk-GBVRCWCD.mjs +2 -0
- package/dist/esm/chunk-GBVRCWCD.mjs.map +1 -0
- package/dist/esm/chunk-H457BI3I.mjs +2 -0
- package/dist/esm/chunk-H457BI3I.mjs.map +1 -0
- package/dist/esm/{chunk-A2AEFKXS.mjs → chunk-HEHVWRMO.mjs} +2 -2
- package/dist/esm/{chunk-UGL2GPGK.mjs → chunk-HFWFDS6Y.mjs} +2 -2
- package/dist/esm/{chunk-OXM4BVAY.mjs → chunk-HXXELLHN.mjs} +2 -2
- package/dist/esm/{chunk-RBJNSUSU.mjs → chunk-IBMZYDAR.mjs} +2 -2
- package/dist/esm/{chunk-AT2ZGTXQ.mjs → chunk-IDNDUJOK.mjs} +2 -2
- package/dist/esm/{chunk-3H5DGQKX.mjs → chunk-II654QZU.mjs} +2 -2
- package/dist/esm/{chunk-JNRMHDRA.mjs → chunk-JDNI5VIJ.mjs} +2 -2
- package/dist/esm/{chunk-73GCGRFW.mjs → chunk-JJUINAQE.mjs} +2 -2
- package/dist/esm/{chunk-VYMRIKUV.mjs → chunk-JLD7DLKM.mjs} +2 -2
- package/dist/esm/chunk-JNO7KPMG.mjs +4 -0
- package/dist/esm/chunk-JNO7KPMG.mjs.map +1 -0
- package/dist/esm/chunk-K4TJRYGQ.mjs +2 -0
- package/dist/esm/chunk-K4TJRYGQ.mjs.map +1 -0
- package/dist/esm/{chunk-XFJD6QIP.mjs → chunk-KA5FX53Q.mjs} +2 -2
- package/dist/esm/{chunk-2GEIHUHT.mjs → chunk-KT3DT5GV.mjs} +2 -2
- package/dist/esm/chunk-KT3DT5GV.mjs.map +1 -0
- package/dist/esm/chunk-KUL55M2H.mjs +2 -0
- package/dist/esm/chunk-KUL55M2H.mjs.map +1 -0
- package/dist/esm/{chunk-ZPIMARUG.mjs → chunk-L2QVUMBV.mjs} +2 -2
- package/dist/esm/chunk-L2SDI7PI.mjs +2 -0
- package/dist/esm/chunk-L2SDI7PI.mjs.map +1 -0
- package/dist/esm/chunk-L56DQ4N3.mjs +2 -0
- package/dist/esm/chunk-L56DQ4N3.mjs.map +1 -0
- package/dist/esm/{chunk-TPJLAYW6.mjs → chunk-LAAFLCDM.mjs} +2 -2
- package/dist/esm/{chunk-AGBA3Y7A.mjs → chunk-LGTOOAQI.mjs} +2 -2
- package/dist/esm/chunk-MHN6XY4Z.mjs +2 -0
- package/dist/esm/{chunk-JVTDP4KV.mjs → chunk-MOGPSSTD.mjs} +2 -2
- package/dist/esm/{chunk-WZCKSN2U.mjs → chunk-NARS3JDH.mjs} +2 -2
- package/dist/esm/{chunk-YZ5BCOGI.mjs → chunk-NHKAQRJB.mjs} +2 -2
- package/dist/esm/{chunk-PHP47DI4.mjs → chunk-OIOGOW6I.mjs} +1 -1
- package/dist/esm/{chunk-PHP47DI4.mjs.map → chunk-OIOGOW6I.mjs.map} +1 -1
- package/dist/esm/{chunk-T5BCTWGK.mjs → chunk-OJBMR5CT.mjs} +2 -2
- package/dist/esm/chunk-OJBMR5CT.mjs.map +1 -0
- package/dist/esm/{chunk-LDZPO76C.mjs → chunk-OKE3FXIP.mjs} +2 -2
- package/dist/esm/chunk-ONFKJ57C.mjs +2 -0
- package/dist/esm/chunk-ONFKJ57C.mjs.map +1 -0
- package/dist/esm/{chunk-ZINOJTLU.mjs → chunk-OPO5EYF7.mjs} +2 -2
- package/dist/esm/{chunk-BVVHGSWC.mjs → chunk-PW3ISXPN.mjs} +2 -2
- package/dist/esm/{chunk-CC7VOPYH.mjs → chunk-QQM47PHZ.mjs} +2 -2
- package/dist/esm/{chunk-EUGLLGYW.mjs → chunk-SBCLBDCP.mjs} +2 -2
- package/dist/esm/chunk-SPRNSFUV.mjs +2 -0
- package/dist/esm/chunk-SPRNSFUV.mjs.map +1 -0
- package/dist/esm/{chunk-EE7GDBA5.mjs → chunk-SU2WB34N.mjs} +2 -2
- package/dist/esm/{chunk-OTY3NO7Q.mjs → chunk-T6ADNZE5.mjs} +2 -2
- package/dist/esm/{chunk-IECDO22V.mjs → chunk-TM7OZT3W.mjs} +2 -2
- package/dist/esm/chunk-TM7OZT3W.mjs.map +1 -0
- package/dist/esm/chunk-UGTIALNW.mjs +2 -0
- package/dist/esm/chunk-UIRAXHDH.mjs +1 -0
- package/dist/esm/chunk-UZTJWOLS.mjs +2 -0
- package/dist/esm/chunk-V4FKFCBL.mjs +2 -0
- package/dist/esm/chunk-V4FKFCBL.mjs.map +1 -0
- package/dist/esm/{chunk-ZPQUCT22.mjs → chunk-VCY3JGZM.mjs} +2 -2
- package/dist/esm/{chunk-XOCRDV2V.mjs → chunk-VQZMI3EZ.mjs} +2 -2
- package/dist/esm/chunk-WGIYSLH6.mjs +2 -0
- package/dist/esm/chunk-WGIYSLH6.mjs.map +1 -0
- package/dist/esm/{chunk-2652SPOM.mjs → chunk-WKNX43KN.mjs} +2 -2
- package/dist/esm/chunk-WKNX43KN.mjs.map +1 -0
- package/dist/esm/chunk-WQF3IOXC.mjs +2 -0
- package/dist/esm/chunk-WQF3IOXC.mjs.map +1 -0
- package/dist/esm/{chunk-IFXUWUP2.mjs → chunk-WSFHH3BK.mjs} +2 -2
- package/dist/esm/{chunk-4LKLOUMG.mjs → chunk-X3JPX7T6.mjs} +2 -2
- package/dist/esm/{chunk-22ZSW5EN.mjs → chunk-XKOSS5KC.mjs} +2 -2
- package/dist/esm/{chunk-BG2TZI3H.mjs → chunk-XT5T5LAP.mjs} +2 -2
- package/dist/esm/chunk-XUP6VABV.mjs +2 -0
- package/dist/esm/chunk-XUP6VABV.mjs.map +1 -0
- package/dist/esm/{chunk-XQ7ONNII.mjs → chunk-YNT7JHMS.mjs} +2 -2
- package/dist/esm/{chunk-BOWPP6YG.mjs → chunk-YPBNYKOD.mjs} +2 -2
- package/dist/esm/{chunk-MK2QAHXC.mjs → chunk-YZ3YPLEU.mjs} +2 -2
- package/dist/esm/{chunk-OZN3OOJV.mjs → chunk-ZMBXHMVQ.mjs} +2 -2
- package/dist/esm/{chunk-XFY4O2S3.mjs → chunk-ZRWZIAF5.mjs} +2 -2
- package/dist/esm/cli/index.d.mts +3 -2
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/cli/move.d.mts +2 -1
- package/dist/esm/client/core.d.mts +2 -2
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +2 -2
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +3 -3
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +2 -2
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/index.d.mts +3 -2
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.d.mts +3 -2
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.d.mts +3 -2
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.d.mts +20 -10
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.d.mts +4 -3
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +27 -12
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +4 -3
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +5 -4
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/hdKey.d.mts +0 -1
- package/dist/esm/core/crypto/hdKey.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +5 -4
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +73 -11
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.d.mts +4 -3
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +4 -3
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.d.mts +38 -10
- package/dist/esm/core/crypto/privateKey.mjs +1 -1
- package/dist/esm/core/crypto/proof.d.mts +3 -2
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.d.mts +4 -3
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.d.mts +24 -9
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/signature.d.mts +3 -2
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +4 -3
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/utils.d.mts +3 -2
- package/dist/esm/core/crypto/utils.mjs +1 -1
- package/dist/esm/core/hex.d.mts +40 -3
- package/dist/esm/core/hex.mjs +1 -1
- package/dist/esm/core/index.d.mts +6 -5
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.d.mts +123 -0
- package/dist/esm/errors/index.mjs +2 -0
- package/dist/esm/index.d.mts +13 -11
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +5 -4
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +5 -4
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +3 -2
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +5 -4
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +3 -2
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +2 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +5 -4
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.d.mts +3 -2
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +10 -5
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.d.mts +3 -2
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +2 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.d.mts +3 -2
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.d.mts +2 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +4 -3
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/view.d.mts +4 -3
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/{publicKey-_tPa99ea.d.mts → publicKey-BVXX1nVl.d.mts} +2 -2
- package/dist/esm/transactions/authenticator/account.d.mts +4 -3
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +4 -3
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +10 -4
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +7 -5
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.d.mts +3 -2
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.d.mts +3 -2
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/index.d.mts +4 -3
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +3 -2
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +3 -2
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.d.mts +3 -2
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +4 -3
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +4 -3
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.d.mts +3 -2
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionArgument.d.mts +3 -2
- package/dist/esm/transactions/instances/transactionPayload.d.mts +3 -2
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +5 -4
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +5 -4
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +5 -4
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/script-composer/index.d.mts +44 -0
- package/dist/esm/transactions/script-composer/index.mjs +2 -0
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +3 -2
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +5 -4
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +26 -5
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +4 -3
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +4 -3
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.d.mts +3 -2
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.d.mts +3 -2
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +12 -3
- package/dist/esm/types/index.d.mts +4 -1260
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/keyless.d.mts +22 -1
- package/dist/esm/types/types.d.mts +1290 -0
- package/dist/esm/types/types.mjs +2 -0
- package/dist/esm/types/types.mjs.map +1 -0
- package/dist/esm/utils/helpers.d.mts +11 -3
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +3 -2
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.d.mts +3 -2
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -1
- package/src/account/AbstractKeylessAccount.ts +203 -10
- package/src/account/FederatedKeylessAccount.ts +83 -35
- package/src/account/KeylessAccount.ts +44 -37
- package/src/account/MultiKeyAccount.ts +18 -5
- package/src/api/keyless.ts +2 -2
- package/src/api/transactionSubmission/build.ts +82 -1
- package/src/bcs/deserializer.ts +53 -30
- package/src/bcs/serializable/moveStructs.ts +16 -17
- package/src/bcs/serializer.ts +22 -12
- package/src/client/core.ts +2 -2
- package/src/client/get.ts +1 -2
- package/src/client/index.ts +0 -1
- package/src/client/post.ts +1 -2
- package/src/core/accountAddress.ts +36 -9
- package/src/core/crypto/ed25519.ts +34 -14
- package/src/core/crypto/hdKey.ts +0 -1
- package/src/core/crypto/keyless.ts +245 -38
- package/src/core/crypto/privateKey.ts +81 -5
- package/src/core/crypto/secp256k1.ts +31 -11
- package/src/core/hex.ts +47 -0
- package/src/errors/index.ts +406 -0
- package/src/index.ts +1 -0
- package/src/internal/account.ts +6 -6
- package/src/internal/ans.ts +2 -1
- package/src/internal/keyless.ts +46 -18
- package/src/internal/transaction.ts +2 -1
- package/src/internal/transactionSubmission.ts +36 -18
- package/src/transactions/authenticator/transaction.ts +20 -0
- package/src/transactions/index.ts +1 -0
- package/src/transactions/script-composer/index.ts +76 -0
- package/src/transactions/transactionBuilder/remoteAbi.ts +55 -1
- package/src/transactions/types.ts +11 -0
- package/src/types/index.ts +2 -1483
- package/src/types/keyless.ts +19 -0
- package/src/types/types.ts +1512 -0
- package/src/utils/helpers.ts +10 -0
- package/src/version.ts +1 -1
- package/dist/common/chunk-7IYTZDXV.js +0 -2
- package/dist/common/chunk-7IYTZDXV.js.map +0 -1
- package/dist/esm/chunk-2652SPOM.mjs.map +0 -1
- package/dist/esm/chunk-2CGJLPHP.mjs +0 -2
- package/dist/esm/chunk-2GEIHUHT.mjs.map +0 -1
- package/dist/esm/chunk-4CDDWSKZ.mjs +0 -2
- package/dist/esm/chunk-4OV7QU2U.mjs +0 -2
- package/dist/esm/chunk-4VU2ABLU.mjs +0 -2
- package/dist/esm/chunk-4VU2ABLU.mjs.map +0 -1
- package/dist/esm/chunk-5S3Z7MT4.mjs +0 -2
- package/dist/esm/chunk-5S3Z7MT4.mjs.map +0 -1
- package/dist/esm/chunk-5SGSPCOY.mjs +0 -2
- package/dist/esm/chunk-5SGSPCOY.mjs.map +0 -1
- package/dist/esm/chunk-7XS45O6M.mjs +0 -2
- package/dist/esm/chunk-7XS45O6M.mjs.map +0 -1
- package/dist/esm/chunk-BAGUHYFD.mjs +0 -2
- package/dist/esm/chunk-BAGUHYFD.mjs.map +0 -1
- package/dist/esm/chunk-CDQGPCHU.mjs +0 -2
- package/dist/esm/chunk-CDQGPCHU.mjs.map +0 -1
- package/dist/esm/chunk-DMSHPWA5.mjs +0 -2
- package/dist/esm/chunk-DMSHPWA5.mjs.map +0 -1
- package/dist/esm/chunk-FTZGP6XW.mjs +0 -2
- package/dist/esm/chunk-FTZGP6XW.mjs.map +0 -1
- package/dist/esm/chunk-GLATLXF6.mjs +0 -2
- package/dist/esm/chunk-GLATLXF6.mjs.map +0 -1
- package/dist/esm/chunk-GQABU3RQ.mjs +0 -2
- package/dist/esm/chunk-GQABU3RQ.mjs.map +0 -1
- package/dist/esm/chunk-HM5HITUC.mjs +0 -4
- package/dist/esm/chunk-I5OYNCZS.mjs +0 -1
- package/dist/esm/chunk-IBLZ6MZU.mjs +0 -2
- package/dist/esm/chunk-IECDO22V.mjs.map +0 -1
- package/dist/esm/chunk-JN36BNWA.mjs +0 -2
- package/dist/esm/chunk-JN36BNWA.mjs.map +0 -1
- package/dist/esm/chunk-KFNDDPOW.mjs +0 -2
- package/dist/esm/chunk-KFNDDPOW.mjs.map +0 -1
- package/dist/esm/chunk-KIW54KWR.mjs +0 -2
- package/dist/esm/chunk-KM6UXNC7.mjs +0 -2
- package/dist/esm/chunk-KM6UXNC7.mjs.map +0 -1
- package/dist/esm/chunk-KUX6GQ2E.mjs +0 -1
- package/dist/esm/chunk-LEKBJ2EG.mjs +0 -2
- package/dist/esm/chunk-LEKBJ2EG.mjs.map +0 -1
- package/dist/esm/chunk-M22UGFQ5.mjs +0 -2
- package/dist/esm/chunk-M22UGFQ5.mjs.map +0 -1
- package/dist/esm/chunk-N2FKVZ4D.mjs +0 -1
- package/dist/esm/chunk-N47FTRYO.mjs +0 -2
- package/dist/esm/chunk-N47FTRYO.mjs.map +0 -1
- package/dist/esm/chunk-ONBFUPEC.mjs +0 -2
- package/dist/esm/chunk-P3J54CQG.mjs +0 -2
- package/dist/esm/chunk-P3J54CQG.mjs.map +0 -1
- package/dist/esm/chunk-RNJHULIT.mjs.map +0 -1
- package/dist/esm/chunk-SGQFWWLQ.mjs +0 -2
- package/dist/esm/chunk-SGQFWWLQ.mjs.map +0 -1
- package/dist/esm/chunk-SOLWFAUY.mjs.map +0 -1
- package/dist/esm/chunk-T5BCTWGK.mjs.map +0 -1
- package/dist/esm/chunk-WV2VJQDS.mjs +0 -2
- package/dist/esm/chunk-Y267I7DC.mjs +0 -2
- package/dist/esm/chunk-Y267I7DC.mjs.map +0 -1
- package/dist/esm/client/types.d.mts +0 -66
- package/dist/esm/client/types.mjs +0 -2
- package/src/client/types.ts +0 -138
- /package/dist/esm/{chunk-4ZK3JNQT.mjs.map → chunk-2NHQQQZK.mjs.map} +0 -0
- /package/dist/esm/{chunk-F2RY4YQ7.mjs.map → chunk-37Y54PJ5.mjs.map} +0 -0
- /package/dist/esm/{chunk-OAEDFM7T.mjs.map → chunk-3XCYCFYI.mjs.map} +0 -0
- /package/dist/esm/{chunk-6FLHGOKP.mjs.map → chunk-42H7WETG.mjs.map} +0 -0
- /package/dist/esm/{chunk-AZ6LVQEG.mjs.map → chunk-46L6BAJG.mjs.map} +0 -0
- /package/dist/esm/{chunk-KW4FVBDD.mjs.map → chunk-4DNCQM3S.mjs.map} +0 -0
- /package/dist/esm/{chunk-IBLZ6MZU.mjs.map → chunk-4O5XDQDO.mjs.map} +0 -0
- /package/dist/esm/{chunk-5N6KJ7KS.mjs.map → chunk-5AKSORBJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-KIW54KWR.mjs.map → chunk-5B3SMBXQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-UCRROMZN.mjs.map → chunk-5NJWJXSS.mjs.map} +0 -0
- /package/dist/esm/{chunk-CL6EEMSL.mjs.map → chunk-6K4TOFCO.mjs.map} +0 -0
- /package/dist/esm/{chunk-IAVI3H4V.mjs.map → chunk-6PJH53CK.mjs.map} +0 -0
- /package/dist/esm/{chunk-PCLU4KLY.mjs.map → chunk-6ZOVTYLJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-I5OYNCZS.mjs.map → chunk-7ECCT6PK.mjs.map} +0 -0
- /package/dist/esm/{chunk-RAJTNQNL.mjs.map → chunk-AAATWCJT.mjs.map} +0 -0
- /package/dist/esm/{chunk-NODYW7DM.mjs.map → chunk-ACVIE7IE.mjs.map} +0 -0
- /package/dist/esm/{chunk-PRZ7AIGA.mjs.map → chunk-AKIO3OIT.mjs.map} +0 -0
- /package/dist/esm/{chunk-KRVLR3L4.mjs.map → chunk-AOROYJ74.mjs.map} +0 -0
- /package/dist/esm/{chunk-6DMDYBV6.mjs.map → chunk-BLLHTGAP.mjs.map} +0 -0
- /package/dist/esm/{chunk-JGNMNCQB.mjs.map → chunk-BRV3RLKW.mjs.map} +0 -0
- /package/dist/esm/{chunk-7JK7UG4E.mjs.map → chunk-CA3Q2X6B.mjs.map} +0 -0
- /package/dist/esm/{chunk-RNRNGJDA.mjs.map → chunk-DP3YPGIK.mjs.map} +0 -0
- /package/dist/esm/{chunk-KYJU5PWF.mjs.map → chunk-DSKAMBBL.mjs.map} +0 -0
- /package/dist/esm/{chunk-L5J3V3HW.mjs.map → chunk-E2NYQVP3.mjs.map} +0 -0
- /package/dist/esm/{chunk-4JXB6V5O.mjs.map → chunk-F2AIWA7L.mjs.map} +0 -0
- /package/dist/esm/{chunk-WSZCPSV4.mjs.map → chunk-FXUI3SSD.mjs.map} +0 -0
- /package/dist/esm/{chunk-A2AEFKXS.mjs.map → chunk-HEHVWRMO.mjs.map} +0 -0
- /package/dist/esm/{chunk-UGL2GPGK.mjs.map → chunk-HFWFDS6Y.mjs.map} +0 -0
- /package/dist/esm/{chunk-OXM4BVAY.mjs.map → chunk-HXXELLHN.mjs.map} +0 -0
- /package/dist/esm/{chunk-RBJNSUSU.mjs.map → chunk-IBMZYDAR.mjs.map} +0 -0
- /package/dist/esm/{chunk-AT2ZGTXQ.mjs.map → chunk-IDNDUJOK.mjs.map} +0 -0
- /package/dist/esm/{chunk-3H5DGQKX.mjs.map → chunk-II654QZU.mjs.map} +0 -0
- /package/dist/esm/{chunk-JNRMHDRA.mjs.map → chunk-JDNI5VIJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-73GCGRFW.mjs.map → chunk-JJUINAQE.mjs.map} +0 -0
- /package/dist/esm/{chunk-VYMRIKUV.mjs.map → chunk-JLD7DLKM.mjs.map} +0 -0
- /package/dist/esm/{chunk-XFJD6QIP.mjs.map → chunk-KA5FX53Q.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZPIMARUG.mjs.map → chunk-L2QVUMBV.mjs.map} +0 -0
- /package/dist/esm/{chunk-TPJLAYW6.mjs.map → chunk-LAAFLCDM.mjs.map} +0 -0
- /package/dist/esm/{chunk-AGBA3Y7A.mjs.map → chunk-LGTOOAQI.mjs.map} +0 -0
- /package/dist/esm/{chunk-4OV7QU2U.mjs.map → chunk-MHN6XY4Z.mjs.map} +0 -0
- /package/dist/esm/{chunk-JVTDP4KV.mjs.map → chunk-MOGPSSTD.mjs.map} +0 -0
- /package/dist/esm/{chunk-WZCKSN2U.mjs.map → chunk-NARS3JDH.mjs.map} +0 -0
- /package/dist/esm/{chunk-YZ5BCOGI.mjs.map → chunk-NHKAQRJB.mjs.map} +0 -0
- /package/dist/esm/{chunk-LDZPO76C.mjs.map → chunk-OKE3FXIP.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZINOJTLU.mjs.map → chunk-OPO5EYF7.mjs.map} +0 -0
- /package/dist/esm/{chunk-BVVHGSWC.mjs.map → chunk-PW3ISXPN.mjs.map} +0 -0
- /package/dist/esm/{chunk-CC7VOPYH.mjs.map → chunk-QQM47PHZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-EUGLLGYW.mjs.map → chunk-SBCLBDCP.mjs.map} +0 -0
- /package/dist/esm/{chunk-EE7GDBA5.mjs.map → chunk-SU2WB34N.mjs.map} +0 -0
- /package/dist/esm/{chunk-OTY3NO7Q.mjs.map → chunk-T6ADNZE5.mjs.map} +0 -0
- /package/dist/esm/{chunk-ONBFUPEC.mjs.map → chunk-UGTIALNW.mjs.map} +0 -0
- /package/dist/esm/{chunk-KUX6GQ2E.mjs.map → chunk-UIRAXHDH.mjs.map} +0 -0
- /package/dist/esm/{chunk-4CDDWSKZ.mjs.map → chunk-UZTJWOLS.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZPQUCT22.mjs.map → chunk-VCY3JGZM.mjs.map} +0 -0
- /package/dist/esm/{chunk-XOCRDV2V.mjs.map → chunk-VQZMI3EZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-IFXUWUP2.mjs.map → chunk-WSFHH3BK.mjs.map} +0 -0
- /package/dist/esm/{chunk-4LKLOUMG.mjs.map → chunk-X3JPX7T6.mjs.map} +0 -0
- /package/dist/esm/{chunk-22ZSW5EN.mjs.map → chunk-XKOSS5KC.mjs.map} +0 -0
- /package/dist/esm/{chunk-BG2TZI3H.mjs.map → chunk-XT5T5LAP.mjs.map} +0 -0
- /package/dist/esm/{chunk-XQ7ONNII.mjs.map → chunk-YNT7JHMS.mjs.map} +0 -0
- /package/dist/esm/{chunk-BOWPP6YG.mjs.map → chunk-YPBNYKOD.mjs.map} +0 -0
- /package/dist/esm/{chunk-MK2QAHXC.mjs.map → chunk-YZ3YPLEU.mjs.map} +0 -0
- /package/dist/esm/{chunk-OZN3OOJV.mjs.map → chunk-ZMBXHMVQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-XFY4O2S3.mjs.map → chunk-ZRWZIAF5.mjs.map} +0 -0
- /package/dist/esm/{chunk-N2FKVZ4D.mjs.map → errors/index.mjs.map} +0 -0
- /package/dist/esm/{client/types.mjs.map → transactions/script-composer/index.mjs.map} +0 -0
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
|
|
3
|
+
import { HexInput, PrivateKeyVariants } from "../../types";
|
|
4
|
+
import { Hex } from "../hex";
|
|
2
5
|
import { PublicKey } from "./publicKey";
|
|
3
6
|
import { Signature } from "./signature";
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* Represents a private key used for signing messages and deriving the associated public key.
|
|
7
|
-
*
|
|
8
|
-
* @method sign - Signs the given message with the private key.
|
|
9
|
-
* @method publicKey - Derives the public key associated with the private key.
|
|
10
|
-
* @method toUint8Array - Retrieves the private key in bytes.
|
|
11
10
|
*/
|
|
12
11
|
export interface PrivateKey {
|
|
13
12
|
/**
|
|
@@ -27,3 +26,80 @@ export interface PrivateKey {
|
|
|
27
26
|
*/
|
|
28
27
|
toUint8Array(): Uint8Array;
|
|
29
28
|
}
|
|
29
|
+
|
|
30
|
+
export class PrivateKey {
|
|
31
|
+
/**
|
|
32
|
+
* The AIP-80 compliant prefixes for each private key type. Append this to a private key's hex representation
|
|
33
|
+
* to get an AIP-80 compliant string.
|
|
34
|
+
*
|
|
35
|
+
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
36
|
+
*/
|
|
37
|
+
public static readonly AIP80_PREFIXES = {
|
|
38
|
+
[PrivateKeyVariants.Ed25519]: "ed25519-priv-",
|
|
39
|
+
[PrivateKeyVariants.Secp256k1]: "secp256k1-priv-",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Format a HexInput to an AIP-80 compliant string.
|
|
44
|
+
*
|
|
45
|
+
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
46
|
+
*
|
|
47
|
+
* @param privateKey - The HexString or Uint8Array format of the private key.
|
|
48
|
+
* @param privateKeyType - The private key type
|
|
49
|
+
*/
|
|
50
|
+
public static formatPrivateKey(privateKey: HexInput, type: PrivateKeyVariants): string {
|
|
51
|
+
const aip80Prefix = PrivateKey.AIP80_PREFIXES[type];
|
|
52
|
+
return `${aip80Prefix}${Hex.fromHexInput(privateKey).toString()}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Parse a HexInput that may be a HexString, Uint8Array, or a AIP-80 compliant string to a Hex instance.
|
|
57
|
+
*
|
|
58
|
+
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
59
|
+
*
|
|
60
|
+
* @param value - A HexString, Uint8Array, or a AIP-80 compliant string.
|
|
61
|
+
* @param privateKeyType - The private key type
|
|
62
|
+
* @param strict - If true, the value MUST be compliant with AIP-80.
|
|
63
|
+
*/
|
|
64
|
+
public static parseHexInput(value: HexInput, type: PrivateKeyVariants, strict?: boolean): Hex {
|
|
65
|
+
let data: Hex;
|
|
66
|
+
|
|
67
|
+
const aip80Prefix = PrivateKey.AIP80_PREFIXES[type];
|
|
68
|
+
if (typeof value === "string") {
|
|
69
|
+
if (!strict && !value.startsWith(aip80Prefix)) {
|
|
70
|
+
// HexString input
|
|
71
|
+
data = Hex.fromHexInput(value);
|
|
72
|
+
// If the strictness is false, the user has opted into non-AIP-80 compliant private keys.
|
|
73
|
+
if (strict !== false) {
|
|
74
|
+
// eslint-disable-next-line no-console
|
|
75
|
+
console.warn(
|
|
76
|
+
"[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.",
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
} else if (value.startsWith(aip80Prefix)) {
|
|
80
|
+
// AIP-80 Compliant String input
|
|
81
|
+
data = Hex.fromHexString(value.split("-")[2]);
|
|
82
|
+
} else {
|
|
83
|
+
if (strict) {
|
|
84
|
+
// The value does not start with the AIP-80 prefix, and strict is true.
|
|
85
|
+
throw new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string.");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// This condition should never be reached.
|
|
89
|
+
throw new Error("Invalid HexString input while parsing private key.");
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
// The value is an Uint8Array
|
|
93
|
+
data = Hex.fromHexInput(value);
|
|
94
|
+
// If the strictness is false, the user has opted into non-AIP-80 compliant private keys.
|
|
95
|
+
if (strict !== false) {
|
|
96
|
+
// eslint-disable-next-line no-console
|
|
97
|
+
console.warn(
|
|
98
|
+
"[Aptos SDK] It is recommended that private keys are parsed as AIP-80 compliant strings instead of Uint8Array (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: Uint8Array, type: 'ed25519' | 'secp256k1'): string`.",
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -6,7 +6,7 @@ import { secp256k1 } from "@noble/curves/secp256k1";
|
|
|
6
6
|
import { HDKey } from "@scure/bip32";
|
|
7
7
|
import { Serializable, Deserializer, Serializer } from "../../bcs";
|
|
8
8
|
import { Hex } from "../hex";
|
|
9
|
-
import { HexInput } from "../../types";
|
|
9
|
+
import { HexInput, PrivateKeyVariants } from "../../types";
|
|
10
10
|
import { isValidBIP44Path, mnemonicToSeed } from "./hdKey";
|
|
11
11
|
import { PrivateKey } from "./privateKey";
|
|
12
12
|
import { PublicKey, VerifySignatureArgs } from "./publicKey";
|
|
@@ -17,7 +17,6 @@ import { convertSigningMessage } from "./utils";
|
|
|
17
17
|
* Represents a Secp256k1 ECDSA public key.
|
|
18
18
|
*
|
|
19
19
|
* @extends PublicKey
|
|
20
|
-
* @static
|
|
21
20
|
* @property LENGTH - The length of the Secp256k1 public key in bytes.
|
|
22
21
|
*/
|
|
23
22
|
export class Secp256k1PublicKey extends PublicKey {
|
|
@@ -148,12 +147,15 @@ export class Secp256k1PrivateKey extends Serializable implements PrivateKey {
|
|
|
148
147
|
/**
|
|
149
148
|
* Create a new PrivateKey instance from a Uint8Array or String.
|
|
150
149
|
*
|
|
150
|
+
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
151
|
+
*
|
|
151
152
|
* @param hexInput A HexInput (string or Uint8Array)
|
|
153
|
+
* @param strict If true, private key must AIP-80 compliant.
|
|
152
154
|
*/
|
|
153
|
-
constructor(hexInput: HexInput) {
|
|
155
|
+
constructor(hexInput: HexInput, strict?: boolean) {
|
|
154
156
|
super();
|
|
155
157
|
|
|
156
|
-
const privateKeyHex =
|
|
158
|
+
const privateKeyHex = PrivateKey.parseHexInput(hexInput, PrivateKeyVariants.Secp256k1, strict);
|
|
157
159
|
if (privateKeyHex.toUint8Array().length !== Secp256k1PrivateKey.LENGTH) {
|
|
158
160
|
throw new Error(`PrivateKey length should be ${Secp256k1PrivateKey.LENGTH}`);
|
|
159
161
|
}
|
|
@@ -168,7 +170,7 @@ export class Secp256k1PrivateKey extends Serializable implements PrivateKey {
|
|
|
168
170
|
*/
|
|
169
171
|
static generate(): Secp256k1PrivateKey {
|
|
170
172
|
const hexInput = secp256k1.utils.randomPrivateKey();
|
|
171
|
-
return new Secp256k1PrivateKey(hexInput);
|
|
173
|
+
return new Secp256k1PrivateKey(hexInput, false);
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
/**
|
|
@@ -204,7 +206,7 @@ export class Secp256k1PrivateKey extends Serializable implements PrivateKey {
|
|
|
204
206
|
throw new Error("Invalid key");
|
|
205
207
|
}
|
|
206
208
|
|
|
207
|
-
return new Secp256k1PrivateKey(privateKey);
|
|
209
|
+
return new Secp256k1PrivateKey(privateKey, false);
|
|
208
210
|
}
|
|
209
211
|
|
|
210
212
|
// endregion
|
|
@@ -251,9 +253,29 @@ export class Secp256k1PrivateKey extends Serializable implements PrivateKey {
|
|
|
251
253
|
* @returns string representation of the private key
|
|
252
254
|
*/
|
|
253
255
|
toString(): string {
|
|
256
|
+
return this.toHexString();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Get the private key as a hex string with the 0x prefix.
|
|
261
|
+
*
|
|
262
|
+
* @returns string representation of the private key.
|
|
263
|
+
*/
|
|
264
|
+
toHexString(): string {
|
|
254
265
|
return this.key.toString();
|
|
255
266
|
}
|
|
256
267
|
|
|
268
|
+
/**
|
|
269
|
+
* Get the private key as a AIP-80 compliant hex string.
|
|
270
|
+
*
|
|
271
|
+
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
|
|
272
|
+
*
|
|
273
|
+
* @returns AIP-80 compliant string representation of the private key.
|
|
274
|
+
*/
|
|
275
|
+
toAIP80String(): string {
|
|
276
|
+
return PrivateKey.formatPrivateKey(this.key.toString(), PrivateKeyVariants.Secp256k1);
|
|
277
|
+
}
|
|
278
|
+
|
|
257
279
|
// endregion
|
|
258
280
|
|
|
259
281
|
// region Serializable
|
|
@@ -264,7 +286,7 @@ export class Secp256k1PrivateKey extends Serializable implements PrivateKey {
|
|
|
264
286
|
|
|
265
287
|
static deserialize(deserializer: Deserializer): Secp256k1PrivateKey {
|
|
266
288
|
const bytes = deserializer.deserializeBytes();
|
|
267
|
-
return new Secp256k1PrivateKey(bytes);
|
|
289
|
+
return new Secp256k1PrivateKey(bytes, false);
|
|
268
290
|
}
|
|
269
291
|
|
|
270
292
|
// endregion
|
|
@@ -284,13 +306,11 @@ export class Secp256k1PrivateKey extends Serializable implements PrivateKey {
|
|
|
284
306
|
/**
|
|
285
307
|
* Represents a signature of a message signed using a Secp256k1 ECDSA private key.
|
|
286
308
|
*
|
|
287
|
-
* @static
|
|
288
|
-
* @readonly
|
|
289
|
-
* @length The length of Secp256k1 ECDSA signatures, which is 64 bytes.
|
|
290
309
|
*/
|
|
291
310
|
export class Secp256k1Signature extends Signature {
|
|
292
311
|
/**
|
|
293
|
-
* Secp256k1 ecdsa signatures are 256-bit
|
|
312
|
+
* Secp256k1 ecdsa signatures are 256-bit or 64 bytes
|
|
313
|
+
* @readonly
|
|
294
314
|
*/
|
|
295
315
|
static readonly LENGTH = 64;
|
|
296
316
|
|
package/src/core/hex.ts
CHANGED
|
@@ -134,6 +134,51 @@ export class Hex {
|
|
|
134
134
|
return Hex.fromHexString(hexInput);
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.
|
|
139
|
+
*
|
|
140
|
+
* @param hexInput - A HexInput which can be a string or Uint8Array.
|
|
141
|
+
* @returns A Uint8Array created from the provided hexInput.
|
|
142
|
+
*/
|
|
143
|
+
static hexInputToUint8Array(hexInput: HexInput): Uint8Array {
|
|
144
|
+
if (hexInput instanceof Uint8Array) return hexInput;
|
|
145
|
+
return Hex.fromHexString(hexInput).toUint8Array();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.
|
|
150
|
+
*
|
|
151
|
+
* @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array
|
|
152
|
+
* @returns A hex string with '0x' prefix (e.g., "0x1234")
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* Hex.hexInputToString("1234") // returns "0x1234"
|
|
157
|
+
* Hex.hexInputToString("0x1234") // returns "0x1234"
|
|
158
|
+
* Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns "0x1234"
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
static hexInputToString(hexInput: HexInput): string {
|
|
162
|
+
return Hex.fromHexInput(hexInput).toString();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.
|
|
167
|
+
*
|
|
168
|
+
* @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array
|
|
169
|
+
* @returns A hex string without '0x' prefix (e.g., "1234")
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* Hex.hexInputToStringWithoutPrefix("1234") // returns "1234"
|
|
174
|
+
* Hex.hexInputToStringWithoutPrefix("0x1234") // returns "1234"
|
|
175
|
+
* Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns "1234"
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
static hexInputToStringWithoutPrefix(hexInput: HexInput): string {
|
|
179
|
+
return Hex.fromHexInput(hexInput).toStringWithoutPrefix();
|
|
180
|
+
}
|
|
181
|
+
|
|
137
182
|
// ===
|
|
138
183
|
// Methods for checking validity.
|
|
139
184
|
// ===
|
|
@@ -172,3 +217,5 @@ export class Hex {
|
|
|
172
217
|
return this.data.every((value, index) => value === other.data[index]);
|
|
173
218
|
}
|
|
174
219
|
}
|
|
220
|
+
|
|
221
|
+
export const hexToAsciiString = (hex: string) => new TextDecoder().decode(Hex.fromHexInput(hex).toUint8Array());
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { AptosApiType } from "../utils/const";
|
|
2
|
+
import { getErrorMessage } from "../utils/helpers";
|
|
3
|
+
import { AptosRequest, AptosResponse } from "../types";
|
|
4
|
+
|
|
5
|
+
export enum KeylessErrorCategory {
|
|
6
|
+
API_ERROR,
|
|
7
|
+
EXTERNAL_API_ERROR,
|
|
8
|
+
SESSION_EXPIRED,
|
|
9
|
+
INVALID_STATE,
|
|
10
|
+
UNKNOWN,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export enum KeylessErrorResolutionTip {
|
|
14
|
+
REAUTHENTICATE = "Re-authentiate to continue using your keyless account",
|
|
15
|
+
// eslint-disable-next-line max-len
|
|
16
|
+
REAUTHENTICATE_UNSURE = "Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",
|
|
17
|
+
UPDATE_REQUEST_PARAMS = "Update the invalid request parameters and reauthenticate.",
|
|
18
|
+
// eslint-disable-next-line max-len
|
|
19
|
+
RATE_LIMIT_EXCEEDED = "Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",
|
|
20
|
+
// eslint-disable-next-line max-len
|
|
21
|
+
SERVER_ERROR = "Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",
|
|
22
|
+
// eslint-disable-next-line max-len
|
|
23
|
+
CALL_PRECHECK = "Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",
|
|
24
|
+
REINSTANTIATE = "Try instantiating the account again. Avoid manipulating the account object directly",
|
|
25
|
+
JOIN_SUPPORT_GROUP = "For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",
|
|
26
|
+
UNKNOWN = "Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export enum KeylessErrorType {
|
|
30
|
+
EPHEMERAL_KEY_PAIR_EXPIRED,
|
|
31
|
+
|
|
32
|
+
PROOF_NOT_FOUND,
|
|
33
|
+
|
|
34
|
+
ASYNC_PROOF_FETCH_FAILED,
|
|
35
|
+
|
|
36
|
+
INVALID_PROOF_VERIFICATION_FAILED,
|
|
37
|
+
|
|
38
|
+
INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND,
|
|
39
|
+
|
|
40
|
+
INVALID_JWT_SIG,
|
|
41
|
+
|
|
42
|
+
INVALID_JWT_JWK_NOT_FOUND,
|
|
43
|
+
|
|
44
|
+
INVALID_JWT_ISS_NOT_RECOGNIZED,
|
|
45
|
+
|
|
46
|
+
INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED,
|
|
47
|
+
|
|
48
|
+
INVALID_TW_SIG_VERIFICATION_FAILED,
|
|
49
|
+
|
|
50
|
+
INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND,
|
|
51
|
+
|
|
52
|
+
INVALID_EXPIRY_HORIZON,
|
|
53
|
+
|
|
54
|
+
JWT_PARSING_ERROR,
|
|
55
|
+
|
|
56
|
+
JWK_FETCH_FAILED,
|
|
57
|
+
|
|
58
|
+
JWK_FETCH_FAILED_FEDERATED,
|
|
59
|
+
|
|
60
|
+
RATE_LIMIT_EXCEEDED,
|
|
61
|
+
|
|
62
|
+
PEPPER_SERVICE_INTERNAL_ERROR,
|
|
63
|
+
|
|
64
|
+
PEPPER_SERVICE_BAD_REQUEST,
|
|
65
|
+
|
|
66
|
+
PEPPER_SERVICE_OTHER,
|
|
67
|
+
|
|
68
|
+
PROVER_SERVICE_INTERNAL_ERROR,
|
|
69
|
+
|
|
70
|
+
PROVER_SERVICE_BAD_REQUEST,
|
|
71
|
+
|
|
72
|
+
PROVER_SERVICE_OTHER,
|
|
73
|
+
|
|
74
|
+
FULL_NODE_CONFIG_LOOKUP_ERROR,
|
|
75
|
+
|
|
76
|
+
FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR,
|
|
77
|
+
|
|
78
|
+
FULL_NODE_JWKS_LOOKUP_ERROR,
|
|
79
|
+
|
|
80
|
+
FULL_NODE_OTHER,
|
|
81
|
+
|
|
82
|
+
UNKNOWN,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const KeylessErrors: { [key in KeylessErrorType]: [string, KeylessErrorCategory, KeylessErrorResolutionTip] } = {
|
|
86
|
+
[KeylessErrorType.EPHEMERAL_KEY_PAIR_EXPIRED]: [
|
|
87
|
+
"The ephemeral keypair has expired.",
|
|
88
|
+
KeylessErrorCategory.SESSION_EXPIRED,
|
|
89
|
+
KeylessErrorResolutionTip.REAUTHENTICATE,
|
|
90
|
+
],
|
|
91
|
+
[KeylessErrorType.PROOF_NOT_FOUND]: [
|
|
92
|
+
"The required proof could not be found.",
|
|
93
|
+
KeylessErrorCategory.INVALID_STATE,
|
|
94
|
+
KeylessErrorResolutionTip.CALL_PRECHECK,
|
|
95
|
+
],
|
|
96
|
+
[KeylessErrorType.ASYNC_PROOF_FETCH_FAILED]: [
|
|
97
|
+
"The required proof failed to fetch.",
|
|
98
|
+
KeylessErrorCategory.INVALID_STATE,
|
|
99
|
+
KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,
|
|
100
|
+
],
|
|
101
|
+
[KeylessErrorType.INVALID_PROOF_VERIFICATION_FAILED]: [
|
|
102
|
+
"The provided proof is invalid.",
|
|
103
|
+
KeylessErrorCategory.INVALID_STATE,
|
|
104
|
+
KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,
|
|
105
|
+
],
|
|
106
|
+
[KeylessErrorType.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND]: [
|
|
107
|
+
"The verification key used to authenticate was updated.",
|
|
108
|
+
KeylessErrorCategory.SESSION_EXPIRED,
|
|
109
|
+
KeylessErrorResolutionTip.REAUTHENTICATE,
|
|
110
|
+
],
|
|
111
|
+
[KeylessErrorType.INVALID_JWT_SIG]: [
|
|
112
|
+
"The JWK was found, but JWT failed verification",
|
|
113
|
+
KeylessErrorCategory.INVALID_STATE,
|
|
114
|
+
KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,
|
|
115
|
+
],
|
|
116
|
+
[KeylessErrorType.INVALID_JWT_JWK_NOT_FOUND]: [
|
|
117
|
+
"The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",
|
|
118
|
+
KeylessErrorCategory.SESSION_EXPIRED,
|
|
119
|
+
KeylessErrorResolutionTip.REAUTHENTICATE,
|
|
120
|
+
],
|
|
121
|
+
[KeylessErrorType.INVALID_JWT_ISS_NOT_RECOGNIZED]: [
|
|
122
|
+
"The JWT issuer is not recognized.",
|
|
123
|
+
KeylessErrorCategory.INVALID_STATE,
|
|
124
|
+
KeylessErrorResolutionTip.UPDATE_REQUEST_PARAMS,
|
|
125
|
+
],
|
|
126
|
+
[KeylessErrorType.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED]: [
|
|
127
|
+
"The JWT issuer is not supported by the Federated Keyless ",
|
|
128
|
+
KeylessErrorCategory.API_ERROR,
|
|
129
|
+
KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,
|
|
130
|
+
],
|
|
131
|
+
[KeylessErrorType.INVALID_TW_SIG_VERIFICATION_FAILED]: [
|
|
132
|
+
"The training wheels signature is invalid.",
|
|
133
|
+
KeylessErrorCategory.INVALID_STATE,
|
|
134
|
+
KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,
|
|
135
|
+
],
|
|
136
|
+
[KeylessErrorType.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND]: [
|
|
137
|
+
"The public key used to verify the training wheels signature was not found.",
|
|
138
|
+
KeylessErrorCategory.SESSION_EXPIRED,
|
|
139
|
+
KeylessErrorResolutionTip.REAUTHENTICATE,
|
|
140
|
+
],
|
|
141
|
+
[KeylessErrorType.INVALID_EXPIRY_HORIZON]: [
|
|
142
|
+
"The expiry horizon is invalid.",
|
|
143
|
+
KeylessErrorCategory.SESSION_EXPIRED,
|
|
144
|
+
KeylessErrorResolutionTip.REAUTHENTICATE,
|
|
145
|
+
],
|
|
146
|
+
[KeylessErrorType.JWK_FETCH_FAILED]: [
|
|
147
|
+
"Failed to fetch JWKS.",
|
|
148
|
+
KeylessErrorCategory.EXTERNAL_API_ERROR,
|
|
149
|
+
KeylessErrorResolutionTip.JOIN_SUPPORT_GROUP,
|
|
150
|
+
],
|
|
151
|
+
[KeylessErrorType.JWK_FETCH_FAILED_FEDERATED]: [
|
|
152
|
+
"Failed to fetch JWKS for Federated Keyless provider.",
|
|
153
|
+
KeylessErrorCategory.EXTERNAL_API_ERROR,
|
|
154
|
+
KeylessErrorResolutionTip.JOIN_SUPPORT_GROUP,
|
|
155
|
+
],
|
|
156
|
+
[KeylessErrorType.RATE_LIMIT_EXCEEDED]: [
|
|
157
|
+
"Rate limit exceeded. Too many requests in a short period.",
|
|
158
|
+
KeylessErrorCategory.API_ERROR,
|
|
159
|
+
KeylessErrorResolutionTip.RATE_LIMIT_EXCEEDED,
|
|
160
|
+
],
|
|
161
|
+
[KeylessErrorType.PEPPER_SERVICE_INTERNAL_ERROR]: [
|
|
162
|
+
"Internal error from Pepper service.",
|
|
163
|
+
KeylessErrorCategory.API_ERROR,
|
|
164
|
+
KeylessErrorResolutionTip.SERVER_ERROR,
|
|
165
|
+
],
|
|
166
|
+
[KeylessErrorType.PEPPER_SERVICE_BAD_REQUEST]: [
|
|
167
|
+
"Bad request sent to Pepper service.",
|
|
168
|
+
KeylessErrorCategory.API_ERROR,
|
|
169
|
+
KeylessErrorResolutionTip.UPDATE_REQUEST_PARAMS,
|
|
170
|
+
],
|
|
171
|
+
[KeylessErrorType.PEPPER_SERVICE_OTHER]: [
|
|
172
|
+
"Unknown error from Pepper service.",
|
|
173
|
+
KeylessErrorCategory.API_ERROR,
|
|
174
|
+
KeylessErrorResolutionTip.SERVER_ERROR,
|
|
175
|
+
],
|
|
176
|
+
[KeylessErrorType.PROVER_SERVICE_INTERNAL_ERROR]: [
|
|
177
|
+
"Internal error from Prover service.",
|
|
178
|
+
KeylessErrorCategory.API_ERROR,
|
|
179
|
+
KeylessErrorResolutionTip.SERVER_ERROR,
|
|
180
|
+
],
|
|
181
|
+
[KeylessErrorType.PROVER_SERVICE_BAD_REQUEST]: [
|
|
182
|
+
"Bad request sent to Prover service.",
|
|
183
|
+
KeylessErrorCategory.API_ERROR,
|
|
184
|
+
KeylessErrorResolutionTip.UPDATE_REQUEST_PARAMS,
|
|
185
|
+
],
|
|
186
|
+
[KeylessErrorType.PROVER_SERVICE_OTHER]: [
|
|
187
|
+
"Unknown error from Prover service.",
|
|
188
|
+
KeylessErrorCategory.API_ERROR,
|
|
189
|
+
KeylessErrorResolutionTip.SERVER_ERROR,
|
|
190
|
+
],
|
|
191
|
+
[KeylessErrorType.JWT_PARSING_ERROR]: [
|
|
192
|
+
"Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",
|
|
193
|
+
KeylessErrorCategory.INVALID_STATE,
|
|
194
|
+
KeylessErrorResolutionTip.REINSTANTIATE,
|
|
195
|
+
],
|
|
196
|
+
[KeylessErrorType.FULL_NODE_CONFIG_LOOKUP_ERROR]: [
|
|
197
|
+
"Error when looking up on-chain keyless configuration.",
|
|
198
|
+
KeylessErrorCategory.API_ERROR,
|
|
199
|
+
KeylessErrorResolutionTip.SERVER_ERROR,
|
|
200
|
+
],
|
|
201
|
+
[KeylessErrorType.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR]: [
|
|
202
|
+
"Error when looking up on-chain verification key.",
|
|
203
|
+
KeylessErrorCategory.API_ERROR,
|
|
204
|
+
KeylessErrorResolutionTip.SERVER_ERROR,
|
|
205
|
+
],
|
|
206
|
+
[KeylessErrorType.FULL_NODE_JWKS_LOOKUP_ERROR]: [
|
|
207
|
+
"Error when looking up on-chain JWKS.",
|
|
208
|
+
KeylessErrorCategory.API_ERROR,
|
|
209
|
+
KeylessErrorResolutionTip.SERVER_ERROR,
|
|
210
|
+
],
|
|
211
|
+
[KeylessErrorType.FULL_NODE_OTHER]: [
|
|
212
|
+
"Unknown error from full node.",
|
|
213
|
+
KeylessErrorCategory.API_ERROR,
|
|
214
|
+
KeylessErrorResolutionTip.SERVER_ERROR,
|
|
215
|
+
],
|
|
216
|
+
[KeylessErrorType.UNKNOWN]: [
|
|
217
|
+
"An unknown error has occurred.",
|
|
218
|
+
KeylessErrorCategory.UNKNOWN,
|
|
219
|
+
KeylessErrorResolutionTip.UNKNOWN,
|
|
220
|
+
],
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export class KeylessError extends Error {
|
|
224
|
+
readonly innerError?: unknown;
|
|
225
|
+
|
|
226
|
+
readonly category: KeylessErrorCategory;
|
|
227
|
+
|
|
228
|
+
readonly resolutionTip: KeylessErrorResolutionTip;
|
|
229
|
+
|
|
230
|
+
readonly type: KeylessErrorType;
|
|
231
|
+
|
|
232
|
+
readonly details?: string;
|
|
233
|
+
|
|
234
|
+
/** @internal this constructor is for sdk internal use - do not instantiate outside of the SDK codebase */
|
|
235
|
+
constructor(args: {
|
|
236
|
+
innerError?: unknown;
|
|
237
|
+
category: KeylessErrorCategory;
|
|
238
|
+
resolutionTip: KeylessErrorResolutionTip;
|
|
239
|
+
type: KeylessErrorType;
|
|
240
|
+
message?: string;
|
|
241
|
+
details?: string;
|
|
242
|
+
}) {
|
|
243
|
+
const { innerError, category, resolutionTip, type, message = KeylessErrors[type][0], details } = args;
|
|
244
|
+
super(message);
|
|
245
|
+
this.name = "KeylessError";
|
|
246
|
+
this.innerError = innerError;
|
|
247
|
+
this.category = category;
|
|
248
|
+
this.resolutionTip = resolutionTip;
|
|
249
|
+
this.type = type;
|
|
250
|
+
this.details = details;
|
|
251
|
+
this.message = KeylessError.constructMessage(message, resolutionTip, innerError, details);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
static constructMessage(
|
|
255
|
+
message: string,
|
|
256
|
+
tip: KeylessErrorResolutionTip,
|
|
257
|
+
innerError?: unknown,
|
|
258
|
+
details?: string,
|
|
259
|
+
): string {
|
|
260
|
+
let result = `\nMessage: ${message}`;
|
|
261
|
+
if (details) {
|
|
262
|
+
result += `\nDetails: ${details}`;
|
|
263
|
+
}
|
|
264
|
+
if (innerError instanceof AptosApiError) {
|
|
265
|
+
result += `\nAptosApiError: ${innerError.message}`;
|
|
266
|
+
} else if (innerError !== undefined) {
|
|
267
|
+
result += `\nError: ${getErrorMessage(innerError)}`;
|
|
268
|
+
}
|
|
269
|
+
result += `\nKeylessErrorResolutionTip: ${tip}`;
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Static constructor that creates a KeylessError instance using the KeylessErrors constant
|
|
275
|
+
* @param args.type The type of KeylessError
|
|
276
|
+
* @param args.aptosApiError optional AptosApiError supplied for api errors
|
|
277
|
+
* @param args.details optional details to include in the error message
|
|
278
|
+
* @returns A new KeylessError instance
|
|
279
|
+
*/
|
|
280
|
+
static fromErrorType(args: { type: KeylessErrorType; error?: unknown; details?: string }): KeylessError {
|
|
281
|
+
const { error, type, details } = args;
|
|
282
|
+
|
|
283
|
+
const [message, category, resolutionTip] = KeylessErrors[type];
|
|
284
|
+
return new KeylessError({
|
|
285
|
+
message,
|
|
286
|
+
details,
|
|
287
|
+
innerError: error,
|
|
288
|
+
category,
|
|
289
|
+
resolutionTip,
|
|
290
|
+
type,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Options for handling errors in the Aptos API.
|
|
297
|
+
*/
|
|
298
|
+
type AptosApiErrorOpts = {
|
|
299
|
+
apiType: AptosApiType;
|
|
300
|
+
aptosRequest: AptosRequest;
|
|
301
|
+
aptosResponse: AptosResponse<any, any>;
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Represents an error returned from the Aptos API.
|
|
306
|
+
* This class encapsulates the details of the error, including the request URL, response status, and additional data.
|
|
307
|
+
*
|
|
308
|
+
* @param name - The name of the error, which is always "AptosApiError".
|
|
309
|
+
* @param url - The URL to which the request was made.
|
|
310
|
+
* @param status - The HTTP response status code (e.g., 400).
|
|
311
|
+
* @param statusText - The message associated with the response status.
|
|
312
|
+
* @param data - The response data returned from the API.
|
|
313
|
+
* @param request - The original AptosRequest that triggered the error.
|
|
314
|
+
*/
|
|
315
|
+
export class AptosApiError extends Error {
|
|
316
|
+
readonly url: string;
|
|
317
|
+
|
|
318
|
+
readonly status: number;
|
|
319
|
+
|
|
320
|
+
readonly statusText: string;
|
|
321
|
+
|
|
322
|
+
readonly data: any;
|
|
323
|
+
|
|
324
|
+
readonly request: AptosRequest;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Constructs an instance of AptosApiError with relevant error details.
|
|
328
|
+
*
|
|
329
|
+
* @param opts - The options for creating the AptosApiError.
|
|
330
|
+
* @param opts.apiType - The type of API that generated the error.
|
|
331
|
+
* @param opts.aptosRequest - The request object that caused the error.
|
|
332
|
+
* @param opts.aptosResponse - The response object containing error details.
|
|
333
|
+
*
|
|
334
|
+
* @internal This constructor is for SDK internal use - do not instantiate outside the SDK codebase.
|
|
335
|
+
*/
|
|
336
|
+
constructor({ apiType, aptosRequest, aptosResponse }: AptosApiErrorOpts) {
|
|
337
|
+
super(deriveErrorMessage({ apiType, aptosRequest, aptosResponse }));
|
|
338
|
+
|
|
339
|
+
this.name = "AptosApiError";
|
|
340
|
+
this.url = aptosResponse.url;
|
|
341
|
+
this.status = aptosResponse.status;
|
|
342
|
+
this.statusText = aptosResponse.statusText;
|
|
343
|
+
this.data = aptosResponse.data;
|
|
344
|
+
this.request = aptosRequest;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Derives an error message from the Aptos API response, providing context for debugging.
|
|
350
|
+
* This function helps in understanding the nature of the error encountered during an API request.
|
|
351
|
+
*
|
|
352
|
+
* @param {AptosApiErrorOpts} opts - The options for deriving the error message.
|
|
353
|
+
* @param {AptosApiType} opts.apiType - The type of API being called.
|
|
354
|
+
* @param {AptosRequest} opts.aptosRequest - The original request made to the Aptos API.
|
|
355
|
+
* @param {AptosResponse} opts.aptosResponse - The response received from the Aptos API.
|
|
356
|
+
*/
|
|
357
|
+
function deriveErrorMessage({ apiType, aptosRequest, aptosResponse }: AptosApiErrorOpts): string {
|
|
358
|
+
// eslint-disable-next-line max-len
|
|
359
|
+
// extract the W3C trace_id from the response headers if it exists. Some services set this in the response, and it's useful for debugging.
|
|
360
|
+
// See https://www.w3.org/TR/trace-context/#relationship-between-the-headers .
|
|
361
|
+
const traceId = aptosResponse.headers?.traceparent?.split("-")[1];
|
|
362
|
+
const traceIdString = traceId ? `(trace_id:${traceId}) ` : "";
|
|
363
|
+
|
|
364
|
+
const errorPrelude: string = `Request to [${apiType}]: ${aptosRequest.method} ${
|
|
365
|
+
aptosResponse.url ?? aptosRequest.url
|
|
366
|
+
} ${traceIdString}failed with`;
|
|
367
|
+
|
|
368
|
+
// handle graphql responses from indexer api and extract the error message of the first error
|
|
369
|
+
if (apiType === AptosApiType.INDEXER && aptosResponse.data?.errors?.[0]?.message != null) {
|
|
370
|
+
return `${errorPrelude}: ${aptosResponse.data.errors[0].message}`;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// Received well-known structured error response body - simply serialize and return it.
|
|
374
|
+
// We don't need http status codes etc. in this case.
|
|
375
|
+
if (aptosResponse.data?.message != null && aptosResponse.data?.error_code != null) {
|
|
376
|
+
return `${errorPrelude}: ${JSON.stringify(aptosResponse.data)}`;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// This is the generic/catch-all case. We received some response from the API, but it doesn't appear to be a well-known structure.
|
|
380
|
+
// We print http status codes and the response body (after some trimming),
|
|
381
|
+
// in the hope that this gives enough context what went wrong without printing overly huge messages.
|
|
382
|
+
return `${errorPrelude} status: ${aptosResponse.statusText}(code:${
|
|
383
|
+
aptosResponse.status
|
|
384
|
+
}) and response body: ${serializeAnyPayloadForErrorMessage(aptosResponse.data)}`;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH = 400;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* This function accepts a payload of any type (probably an object) and serializes it to a string
|
|
391
|
+
* Since we don't know the type or size of the payload, and we don't want to add a huge object in full to the error message
|
|
392
|
+
* we limit the to the first 200 and last 200 characters of the serialized payload and put a "..." in the middle.
|
|
393
|
+
* @param payload - The payload to serialize, which can be of any type.
|
|
394
|
+
*
|
|
395
|
+
* @returns A string representation of the serialized payload, potentially truncated.
|
|
396
|
+
*/
|
|
397
|
+
function serializeAnyPayloadForErrorMessage(payload: any): string {
|
|
398
|
+
const serializedPayload = JSON.stringify(payload);
|
|
399
|
+
if (serializedPayload.length <= SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH) {
|
|
400
|
+
return serializedPayload;
|
|
401
|
+
}
|
|
402
|
+
return `truncated(original_size:${serializedPayload.length}): ${serializedPayload.slice(
|
|
403
|
+
0,
|
|
404
|
+
SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH / 2,
|
|
405
|
+
)}...${serializedPayload.slice(-SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH / 2)}`;
|
|
406
|
+
}
|