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