@aptos-labs/ts-sdk 5.1.0 → 5.1.1-side-effect-free.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/dist/common/{account-BW99GTa5.d.ts → account-Dr4y1uZG.d.ts} +1 -0
- package/dist/common/chunk-AWFAHZSB.js +4 -0
- package/dist/common/{chunk-A2XB7TVI.js.map → chunk-AWFAHZSB.js.map} +1 -1
- 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 +14 -3
- package/dist/common/index.js +34 -34
- package/dist/common/index.js.map +1 -1
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/AbstractKeylessAccount.mjs.map +1 -1
- package/dist/esm/account/AbstractedAccount.mjs +1 -1
- package/dist/esm/account/AbstractedAccount.mjs.map +1 -1
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/Account.mjs.map +1 -1
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/AccountUtils.mjs.map +1 -1
- package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
- package/dist/esm/account/DerivableAbstractedAccount.mjs.map +1 -1
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/Ed25519Account.mjs.map +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs.map +1 -1
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.mjs.map +1 -1
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.mjs.map +1 -1
- package/dist/esm/account/MultiEd25519Account.mjs +1 -1
- package/dist/esm/account/MultiEd25519Account.mjs.map +1 -1
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.mjs.map +1 -1
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.mjs.map +1 -1
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/account/index.mjs.map +1 -1
- package/dist/esm/account/utils.mjs +1 -1
- package/dist/esm/account/utils.mjs.map +1 -1
- package/dist/esm/api/account/abstraction.mjs +1 -1
- package/dist/esm/api/account/abstraction.mjs.map +1 -1
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/account.mjs.map +1 -1
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/ans.mjs.map +1 -1
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptos.mjs.map +1 -1
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/aptosConfig.mjs.map +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/coin.mjs.map +1 -1
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/digitalAsset.mjs.map +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/faucet.mjs.map +1 -1
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/fungibleAsset.mjs.map +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/general.mjs.map +1 -1
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/index.mjs.map +1 -1
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/keyless.mjs.map +1 -1
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/object.mjs.map +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/staking.mjs.map +1 -1
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/table.mjs.map +1 -1
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transaction.mjs.map +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs.map +1 -1
- package/dist/esm/api/transactionSubmission/helpers.mjs +1 -1
- package/dist/esm/api/transactionSubmission/helpers.mjs.map +1 -1
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.mjs.map +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/simulate.mjs.map +1 -1
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.mjs.map +1 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/api/utils.mjs.map +1 -1
- package/dist/esm/bcs/consts.mjs +1 -1
- package/dist/esm/bcs/consts.mjs.map +1 -1
- package/dist/esm/bcs/deserializer.mjs +1 -1
- package/dist/esm/bcs/deserializer.mjs.map +1 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/index.mjs.map +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs.map +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.mjs.map +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs.map +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs.map +1 -1
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/bcs/serializer.mjs.map +1 -1
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/index.mjs.map +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/cli/localNode.mjs.map +1 -1
- package/dist/esm/cli/move.mjs +1 -1
- package/dist/esm/cli/move.mjs.map +1 -1
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/core.mjs.map +1 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/get.mjs.map +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/index.mjs.map +1 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/client/post.mjs.map +1 -1
- package/dist/esm/core/account/index.d.mts +1 -1
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/index.mjs.map +1 -1
- package/dist/esm/core/account/utils/address.d.mts +12 -1
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/address.mjs.map +1 -1
- package/dist/esm/core/account/utils/index.d.mts +1 -1
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/account/utils/index.mjs.map +1 -1
- package/dist/esm/core/accountAddress.mjs +3 -1
- package/dist/esm/core/accountAddress.mjs.map +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/authenticationKey.mjs.map +1 -1
- package/dist/esm/core/common.mjs +1 -1
- package/dist/esm/core/common.mjs.map +1 -1
- package/dist/esm/core/crypto/abstraction.mjs +1 -1
- package/dist/esm/core/crypto/abstraction.mjs.map +1 -1
- package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
- package/dist/esm/core/crypto/deserializationUtils.mjs.map +1 -1
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.mjs.map +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs.map +1 -1
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.mjs.map +1 -1
- package/dist/esm/core/crypto/hdKey.mjs +1 -1
- package/dist/esm/core/crypto/hdKey.mjs.map +1 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/index.mjs.map +1 -1
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/keyless.mjs.map +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs.map +1 -1
- package/dist/esm/core/crypto/multiKey.mjs +3 -1
- package/dist/esm/core/crypto/multiKey.mjs.map +1 -1
- package/dist/esm/core/crypto/poseidon.mjs +1 -1
- package/dist/esm/core/crypto/poseidon.mjs.map +1 -1
- package/dist/esm/core/crypto/privateKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.mjs.map +1 -1
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/proof.mjs.map +1 -1
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.mjs.map +1 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.mjs.map +1 -1
- package/dist/esm/core/crypto/secp256r1.mjs +1 -1
- package/dist/esm/core/crypto/secp256r1.mjs.map +1 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/signature.mjs.map +1 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.mjs.map +1 -1
- package/dist/esm/core/crypto/types.mjs +0 -1
- package/dist/esm/core/crypto/utils.mjs +1 -1
- package/dist/esm/core/crypto/utils.mjs.map +1 -1
- package/dist/esm/core/hex.mjs +1 -1
- package/dist/esm/core/hex.mjs.map +1 -1
- package/dist/esm/core/index.d.mts +1 -1
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/core/index.mjs.map +1 -1
- package/dist/esm/errors/index.mjs +6 -1
- package/dist/esm/errors/index.mjs.map +1 -1
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/internal/abstraction.mjs +1 -1
- package/dist/esm/internal/abstraction.mjs.map +1 -1
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/account.mjs.map +1 -1
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/ans.mjs.map +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/coin.mjs.map +1 -1
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/digitalAsset.mjs.map +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/faucet.mjs.map +1 -1
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.mjs.map +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/general.mjs.map +1 -1
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/keyless.mjs.map +1 -1
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/object.mjs.map +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/staking.mjs.map +1 -1
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/table.mjs.map +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transaction.mjs.map +1 -1
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.mjs.map +1 -1
- package/dist/esm/internal/utils/index.mjs +1 -1
- package/dist/esm/internal/utils/index.mjs.map +1 -1
- package/dist/esm/internal/utils/utils.mjs +1 -1
- package/dist/esm/internal/utils/utils.mjs.map +1 -1
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/internal/view.mjs.map +1 -1
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.mjs.map +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.mjs.map +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs.map +1 -1
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/index.mjs.map +1 -1
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.mjs.map +1 -1
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.mjs.map +1 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/index.mjs.map +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs.map +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs.map +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs.map +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs.map +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs.map +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs.map +1 -1
- package/dist/esm/transactions/instances/transactionArgument.mjs +0 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs.map +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs.map +1 -1
- package/dist/esm/transactions/management/asyncQueue.mjs +1 -1
- package/dist/esm/transactions/management/asyncQueue.mjs.map +1 -1
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/index.mjs.map +1 -1
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.mjs.map +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs.map +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs.map +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs.map +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs.map +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs.map +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.mjs.map +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs.map +1 -1
- package/dist/esm/transactions/types.mjs +0 -1
- package/dist/esm/types/abstraction.mjs +1 -1
- package/dist/esm/types/abstraction.mjs.map +1 -1
- package/dist/esm/types/generated/queries.mjs +493 -1
- package/dist/esm/types/generated/queries.mjs.map +1 -1
- package/dist/esm/types/generated/types.mjs +1 -1
- package/dist/esm/types/generated/types.mjs.map +1 -1
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/index.mjs.map +1 -1
- package/dist/esm/types/indexer.mjs +0 -1
- package/dist/esm/types/types.mjs +1 -1
- package/dist/esm/types/types.mjs.map +1 -1
- package/dist/esm/utils/apiEndpoints.d.mts +1 -0
- package/dist/esm/utils/apiEndpoints.mjs +1 -1
- package/dist/esm/utils/apiEndpoints.mjs.map +1 -1
- package/dist/esm/utils/const.mjs +1 -1
- package/dist/esm/utils/const.mjs.map +1 -1
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/helpers.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/index.mjs.map +1 -1
- package/dist/esm/utils/memoize.mjs +1 -1
- package/dist/esm/utils/memoize.mjs.map +1 -1
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.mjs.map +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/dist/esm/version.mjs.map +1 -1
- package/package.json +39 -20
- package/src/api/aptos.ts +25 -14
- package/src/core/account/utils/address.ts +22 -0
- package/src/internal/ans.ts +1 -0
- package/src/utils/apiEndpoints.ts +7 -0
- package/src/version.ts +1 -1
- package/dist/common/chunk-A2XB7TVI.js +0 -4
- package/dist/esm/chunk-2PASUPUO.mjs +0 -2
- package/dist/esm/chunk-2PASUPUO.mjs.map +0 -1
- package/dist/esm/chunk-2XQKGWHQ.mjs +0 -2
- package/dist/esm/chunk-2XQKGWHQ.mjs.map +0 -1
- package/dist/esm/chunk-35DKMW7Q.mjs +0 -2
- package/dist/esm/chunk-35DKMW7Q.mjs.map +0 -1
- package/dist/esm/chunk-4AI7KQQ7.mjs +0 -2
- package/dist/esm/chunk-4AI7KQQ7.mjs.map +0 -1
- package/dist/esm/chunk-4QMXOWHP.mjs +0 -1
- package/dist/esm/chunk-4QMXOWHP.mjs.map +0 -1
- package/dist/esm/chunk-4RXKALLC.mjs +0 -2
- package/dist/esm/chunk-4RXKALLC.mjs.map +0 -1
- package/dist/esm/chunk-4WPQQPUF.mjs +0 -1
- package/dist/esm/chunk-4WPQQPUF.mjs.map +0 -1
- package/dist/esm/chunk-56CNRT2K.mjs +0 -2
- package/dist/esm/chunk-56CNRT2K.mjs.map +0 -1
- package/dist/esm/chunk-5HXLZHDW.mjs +0 -1
- package/dist/esm/chunk-5HXLZHDW.mjs.map +0 -1
- package/dist/esm/chunk-6OWBKU7N.mjs +0 -2
- package/dist/esm/chunk-6OWBKU7N.mjs.map +0 -1
- package/dist/esm/chunk-6WDVDEQZ.mjs +0 -7
- package/dist/esm/chunk-6WDVDEQZ.mjs.map +0 -1
- package/dist/esm/chunk-7DQDJ2SA.mjs +0 -2
- package/dist/esm/chunk-7DQDJ2SA.mjs.map +0 -1
- package/dist/esm/chunk-7ECCT6PK.mjs +0 -1
- package/dist/esm/chunk-7ECCT6PK.mjs.map +0 -1
- package/dist/esm/chunk-7EER7GWV.mjs +0 -2
- package/dist/esm/chunk-7EER7GWV.mjs.map +0 -1
- package/dist/esm/chunk-A5L76YP7.mjs +0 -2
- package/dist/esm/chunk-A5L76YP7.mjs.map +0 -1
- package/dist/esm/chunk-AMXZQPUQ.mjs +0 -2
- package/dist/esm/chunk-AMXZQPUQ.mjs.map +0 -1
- package/dist/esm/chunk-B563XRSZ.mjs +0 -2
- package/dist/esm/chunk-B563XRSZ.mjs.map +0 -1
- package/dist/esm/chunk-C3Q23D22.mjs +0 -2
- package/dist/esm/chunk-C3Q23D22.mjs.map +0 -1
- package/dist/esm/chunk-CIJA7ONS.mjs +0 -2
- package/dist/esm/chunk-CIJA7ONS.mjs.map +0 -1
- package/dist/esm/chunk-CW35YAMN.mjs +0 -2
- package/dist/esm/chunk-CW35YAMN.mjs.map +0 -1
- package/dist/esm/chunk-EBMEXURY.mjs +0 -2
- package/dist/esm/chunk-EBMEXURY.mjs.map +0 -1
- package/dist/esm/chunk-EF4FA5I6.mjs +0 -2
- package/dist/esm/chunk-EF4FA5I6.mjs.map +0 -1
- package/dist/esm/chunk-FD6FGKYY.mjs +0 -1
- package/dist/esm/chunk-FD6FGKYY.mjs.map +0 -1
- package/dist/esm/chunk-FGFLPH5K.mjs +0 -2
- package/dist/esm/chunk-FGFLPH5K.mjs.map +0 -1
- package/dist/esm/chunk-FLZPUYXQ.mjs +0 -2
- package/dist/esm/chunk-FLZPUYXQ.mjs.map +0 -1
- package/dist/esm/chunk-FZY4PMEE.mjs +0 -1
- package/dist/esm/chunk-FZY4PMEE.mjs.map +0 -1
- package/dist/esm/chunk-G3MHXDYA.mjs +0 -1
- package/dist/esm/chunk-G3MHXDYA.mjs.map +0 -1
- package/dist/esm/chunk-GOXRBEIJ.mjs +0 -2
- package/dist/esm/chunk-GOXRBEIJ.mjs.map +0 -1
- package/dist/esm/chunk-HGLO5LDS.mjs +0 -1
- package/dist/esm/chunk-HGLO5LDS.mjs.map +0 -1
- package/dist/esm/chunk-HNBVYE3N.mjs +0 -2
- package/dist/esm/chunk-HNBVYE3N.mjs.map +0 -1
- package/dist/esm/chunk-I7XT6L7S.mjs +0 -2
- package/dist/esm/chunk-I7XT6L7S.mjs.map +0 -1
- package/dist/esm/chunk-IF4UU2MT.mjs +0 -2
- package/dist/esm/chunk-IF4UU2MT.mjs.map +0 -1
- package/dist/esm/chunk-JABP65XD.mjs +0 -2
- package/dist/esm/chunk-JABP65XD.mjs.map +0 -1
- package/dist/esm/chunk-KDMSOCZY.mjs +0 -2
- package/dist/esm/chunk-KDMSOCZY.mjs.map +0 -1
- package/dist/esm/chunk-L72TIN7T.mjs +0 -4
- package/dist/esm/chunk-L72TIN7T.mjs.map +0 -1
- package/dist/esm/chunk-M3AO73ZL.mjs +0 -2
- package/dist/esm/chunk-M3AO73ZL.mjs.map +0 -1
- package/dist/esm/chunk-MCFQE4GC.mjs +0 -2
- package/dist/esm/chunk-MCFQE4GC.mjs.map +0 -1
- package/dist/esm/chunk-MT2RJ7H3.mjs +0 -2
- package/dist/esm/chunk-MT2RJ7H3.mjs.map +0 -1
- package/dist/esm/chunk-N6YTF76Q.mjs +0 -2
- package/dist/esm/chunk-N6YTF76Q.mjs.map +0 -1
- package/dist/esm/chunk-NECL5FCQ.mjs +0 -1
- package/dist/esm/chunk-NECL5FCQ.mjs.map +0 -1
- package/dist/esm/chunk-OLILO7VD.mjs +0 -2
- package/dist/esm/chunk-OLILO7VD.mjs.map +0 -1
- package/dist/esm/chunk-ORMOQWWH.mjs +0 -2
- package/dist/esm/chunk-ORMOQWWH.mjs.map +0 -1
- package/dist/esm/chunk-Q4W3WJ2U.mjs +0 -2
- package/dist/esm/chunk-Q4W3WJ2U.mjs.map +0 -1
- package/dist/esm/chunk-QP2BY4PK.mjs +0 -2
- package/dist/esm/chunk-QP2BY4PK.mjs.map +0 -1
- package/dist/esm/chunk-QREVMGQZ.mjs +0 -2
- package/dist/esm/chunk-QREVMGQZ.mjs.map +0 -1
- package/dist/esm/chunk-RCSJFTST.mjs +0 -2
- package/dist/esm/chunk-RCSJFTST.mjs.map +0 -1
- package/dist/esm/chunk-RGKRCZ36.mjs +0 -4
- package/dist/esm/chunk-RGKRCZ36.mjs.map +0 -1
- package/dist/esm/chunk-SJDCGNWU.mjs +0 -2
- package/dist/esm/chunk-SJDCGNWU.mjs.map +0 -1
- package/dist/esm/chunk-STY74NUA.mjs +0 -2
- package/dist/esm/chunk-STY74NUA.mjs.map +0 -1
- package/dist/esm/chunk-TOBQ5UE6.mjs +0 -2
- package/dist/esm/chunk-TOBQ5UE6.mjs.map +0 -1
- package/dist/esm/chunk-UL777LTI.mjs +0 -494
- package/dist/esm/chunk-UL777LTI.mjs.map +0 -1
- package/dist/esm/chunk-UYVPNUH3.mjs +0 -1
- package/dist/esm/chunk-UYVPNUH3.mjs.map +0 -1
- package/dist/esm/chunk-V3MBJJTL.mjs +0 -1
- package/dist/esm/chunk-V3MBJJTL.mjs.map +0 -1
- package/dist/esm/chunk-WCMW2L3P.mjs +0 -2
- package/dist/esm/chunk-WCMW2L3P.mjs.map +0 -1
- package/dist/esm/chunk-WHSTLR3F.mjs +0 -2
- package/dist/esm/chunk-WHSTLR3F.mjs.map +0 -1
- package/dist/esm/chunk-WSR5EBJM.mjs +0 -2
- package/dist/esm/chunk-WSR5EBJM.mjs.map +0 -1
- package/dist/esm/chunk-XJJVJOX5.mjs +0 -2
- package/dist/esm/chunk-XJJVJOX5.mjs.map +0 -1
- package/dist/esm/chunk-XKUIMGKU.mjs +0 -2
- package/dist/esm/chunk-XKUIMGKU.mjs.map +0 -1
- package/dist/esm/chunk-YOZBVVKL.mjs +0 -2
- package/dist/esm/chunk-YOZBVVKL.mjs.map +0 -1
- package/dist/esm/chunk-ZP4DWSQA.mjs +0 -2
- package/dist/esm/chunk-ZP4DWSQA.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/crypto/hdKey.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha512 } from \"@noble/hashes/sha512\";\nimport * as bip39 from \"@scure/bip39\";\n\n/**\n * Contains the derived cryptographic key as a Uint8Array.\n * @group Implementation\n * @category Serialization\n */\nexport type DerivedKeys = {\n key: Uint8Array;\n chainCode: Uint8Array;\n};\n\n/**\n * Aptos derive path is 637\n * @group Implementation\n * @category Serialization\n */\nexport const APTOS_HARDENED_REGEX = /^m\\/44'\\/637'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'?$/;\n\n/**\n * @group Implementation\n * @category Serialization\n */\nexport const APTOS_BIP44_REGEX = /^m\\/44'\\/637'\\/[0-9]+'\\/[0-9]+\\/[0-9]+$/;\n\n/**\n * Supported key types and their associated seeds.\n * @group Implementation\n * @category Serialization\n */\nexport enum KeyType {\n ED25519 = \"ed25519 seed\",\n}\n\n/**\n * @group Implementation\n * @category Serialization\n */\nexport const HARDENED_OFFSET = 0x80000000;\n\n/**\n * Validate a BIP-44 derivation path string to ensure it meets the required format.\n * This function checks if the provided path adheres to the BIP-44 standard for Secp256k1.\n * Parse and validate a path that is compliant to BIP-44 in form m/44'/637'/{account_index}'/{change_index}/{address_index}\n * for Secp256k1\n *\n * Note that for Secp256k1, the last two components must be non-hardened.\n *\n * @param path - The path string to validate (e.g. `m/44'/637'/0'/0/0`).\n * @group Implementation\n * @category Serialization\n */\nexport function isValidBIP44Path(path: string): boolean {\n return APTOS_BIP44_REGEX.test(path);\n}\n\n/**\n * Aptos derive path is 637\n *\n * Parse and validate a path that is compliant to SLIP-0010 and BIP-44\n * in form m/44'/637'/{account_index}'/{change_index}'/{address_index}'.\n * See SLIP-0010 {@link https://github.com/satoshilabs/slips/blob/master/slip-0044.md}\n * See BIP-44 {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}\n *\n * Note that for Ed25519, all components must be hardened.\n * This is because non-hardened [PK] derivation would not work due to Ed25519's lack of a key homomorphism.\n * Specifically, you cannot derive the PK associated with derivation path a/b/c given the PK of a/b.\n * This is because the PK in Ed25519 is, more or less, computed as 𝑔𝐻(𝑠𝑘),\n * with the hash function breaking the homomorphism.\n *\n * @param path - The derivation path string to validate (e.g. `m/44'/637'/0'/0'/0'`).\n * @group Implementation\n * @category Serialization\n */\nexport function isValidHardenedPath(path: string): boolean {\n return APTOS_HARDENED_REGEX.test(path);\n}\n\n/**\n * @group Implementation\n * @category Serialization\n */\nexport const deriveKey = (hashSeed: Uint8Array | string, data: Uint8Array | string): DerivedKeys => {\n const digest = hmac.create(sha512, hashSeed).update(data).digest();\n return {\n key: digest.slice(0, 32),\n chainCode: digest.slice(32),\n };\n};\n\n/**\n * Derive a child key from the private key\n * @param key\n * @param chainCode\n * @param index\n * @group Implementation\n * @category Serialization\n */\nexport const CKDPriv = ({ key, chainCode }: DerivedKeys, index: number): DerivedKeys => {\n const buffer = new ArrayBuffer(4);\n new DataView(buffer).setUint32(0, index);\n const indexBytes = new Uint8Array(buffer);\n const zero = new Uint8Array([0]);\n const data = new Uint8Array([...zero, ...key, ...indexBytes]);\n return deriveKey(chainCode, data);\n};\n\nconst removeApostrophes = (val: string): string => val.replace(/'/g, \"\");\n\n/**\n * Splits derive path into segments\n * @param path\n * @group Implementation\n * @category Serialization\n */\nexport const splitPath = (path: string): Array<string> => path.split(\"/\").slice(1).map(removeApostrophes);\n\n/**\n * Normalizes the mnemonic by removing extra whitespace and making it lowercase\n * @param mnemonic the mnemonic seed phrase\n * @group Implementation\n * @category Serialization\n */\nexport const mnemonicToSeed = (mnemonic: string): Uint8Array => {\n const normalizedMnemonic = mnemonic\n .trim()\n .split(/\\s+/)\n .map((part) => part.toLowerCase())\n .join(\" \");\n return bip39.mnemonicToSeedSync(normalizedMnemonic);\n};\n"],"mappings":"AAGA,OAAS,QAAAA,MAAY,qBACrB,OAAS,UAAAC,MAAc,uBACvB,UAAYC,MAAW,eAiBhB,IAAMC,EAAuB,6CAMvBC,EAAoB,0CAOrBC,OACVA,EAAA,QAAU,eADAA,OAAA,IAQCC,EAAkB,WAcxB,SAASC,EAAiBC,EAAuB,CACtD,OAAOJ,EAAkB,KAAKI,CAAI,CACpC,CAoBO,SAASC,EAAoBD,EAAuB,CACzD,OAAOL,EAAqB,KAAKK,CAAI,CACvC,CAMO,IAAME,EAAY,CAACC,EAA+BC,IAA2C,CAClG,IAAMC,EAASb,EAAK,OAAOC,EAAQU,CAAQ,EAAE,OAAOC,CAAI,EAAE,OAAO,EACjE,MAAO,CACL,IAAKC,EAAO,MAAM,EAAG,EAAE,EACvB,UAAWA,EAAO,MAAM,EAAE,CAC5B,CACF,EAUaC,EAAU,CAAC,CAAE,IAAAC,EAAK,UAAAC,CAAU,EAAgBC,IAA+B,CACtF,IAAMC,EAAS,IAAI,YAAY,CAAC,EAChC,IAAI,SAASA,CAAM,EAAE,UAAU,EAAGD,CAAK,EACvC,IAAME,EAAa,IAAI,WAAWD,CAAM,EAClCE,EAAO,IAAI,WAAW,CAAC,CAAC,CAAC,EACzBR,EAAO,IAAI,WAAW,CAAC,GAAGQ,EAAM,GAAGL,EAAK,GAAGI,CAAU,CAAC,EAC5D,OAAOT,EAAUM,EAAWJ,CAAI,CAClC,EAEMS,EAAqBC,GAAwBA,EAAI,QAAQ,KAAM,EAAE,EAQ1DC,EAAaf,GAAgCA,EAAK,MAAM,GAAG,EAAE,MAAM,CAAC,EAAE,IAAIa,CAAiB,EAQ3FG,EAAkBC,GAAiC,CAC9D,IAAMC,EAAqBD,EACxB,KAAK,EACL,MAAM,KAAK,EACX,IAAKE,GAASA,EAAK,YAAY,CAAC,EAChC,KAAK,GAAG,EACX,OAAa,qBAAmBD,CAAkB,CACpD","names":["hmac","sha512","bip39","APTOS_HARDENED_REGEX","APTOS_BIP44_REGEX","KeyType","HARDENED_OFFSET","isValidBIP44Path","path","isValidHardenedPath","deriveKey","hashSeed","data","digest","CKDPriv","key","chainCode","index","buffer","indexBytes","zero","removeApostrophes","val","splitPath","mnemonicToSeed","mnemonic","normalizedMnemonic","part"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/version.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The current version of the SDK\n *\n * hardcoded for now, we would want to have it injected dynamically\n */\nexport const VERSION = \"5.1.0\";\n"],"mappings":"AAQO,IAAMA,EAAU","names":["VERSION"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/normalizeBundle.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Deserializer, Serializable } from \"../bcs\";\n/**\n * @group Implementation\n * @category Utils\n */\nexport type DeserializableClass<T extends Serializable> = {\n /**\n * Deserializes a serialized object using the provided deserializer.\n * This function allows you to reconstruct an object from its serialized form.\n *\n * @param deserializer - An instance of the Deserializer used to read the serialized data.\n * @group Implementation\n * @category Utils\n */\n deserialize(deserializer: Deserializer): T;\n};\n\n/**\n * Normalizes an instance of a class by deserializing it from its byte representation.\n * This function allows the `instanceof` operator to work correctly when the input objects originate from a different bundle.\n *\n * @param cls - The class of the object to normalize.\n * @param value - The instance to normalize.\n * @group Implementation\n * @category Utils\n */\nexport function normalizeBundle<T extends Serializable>(cls: DeserializableClass<T>, value: T) {\n const serializedBytes = value.bcsToBytes();\n const deserializer = new Deserializer(serializedBytes);\n return cls.deserialize(deserializer);\n}\n"],"mappings":"yCA6BO,SAASA,EAAwCC,EAA6BC,EAAU,CAC7F,IAAMC,EAAkBD,EAAM,WAAW,EACnCE,EAAe,IAAIC,EAAaF,CAAe,EACrD,OAAOF,EAAI,YAAYG,CAAY,CACrC","names":["normalizeBundle","cls","value","serializedBytes","deserializer","Deserializer"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as c}from"./chunk-STY74NUA.mjs";import{a as U,b,c as f,d as h,e as l,f as y}from"./chunk-56CNRT2K.mjs";import{a as s}from"./chunk-KDMSOCZY.mjs";var B=class{bcsToBytes(){let e=new n;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return c.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}},n=class{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.offset=0}ensureBufferWillHandleSize(e){for(;this.buffer.byteLength<this.offset+e;){let t=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t}}appendToBuffer(e){this.ensureBufferWillHandleSize(e.length),new Uint8Array(this.buffer,this.offset).set(e),this.offset+=e.length}serializeWithFunction(e,t,i){this.ensureBufferWillHandleSize(t);let a=new DataView(this.buffer,this.offset);e.apply(a,[0,i,!0]),this.offset+=t}serializeStr(e){let t=new TextEncoder;this.serializeBytes(t.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){p(e);let t=e?1:0;this.appendToBuffer(new Uint8Array([t]))}serializeU8(e){this.appendToBuffer(new Uint8Array([e]))}serializeU16(e){this.serializeWithFunction(DataView.prototype.setUint16,2,e)}serializeU32(e){this.serializeWithFunction(DataView.prototype.setUint32,4,e)}serializeU64(e){let t=BigInt(e)&BigInt(f),i=BigInt(e)>>BigInt(32);this.serializeU32(Number(t)),this.serializeU32(Number(i))}serializeU128(e){let t=BigInt(e)&h,i=BigInt(e)>>BigInt(64);this.serializeU64(t),this.serializeU64(i)}serializeU256(e){let t=BigInt(e)&l,i=BigInt(e)>>BigInt(128);this.serializeU128(t),this.serializeU128(i)}serializeU32AsUleb128(e){let t=e,i=[];for(;t>>>7;)i.push(t&127|128),t>>>=7;i.push(t),this.appendToBuffer(new Uint8Array(i))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(e){e.serialize(this)}serializeVector(e){this.serializeU32AsUleb128(e.length),e.forEach(t=>{t.serialize(this)})}serializeOption(e,t){let i=e!==void 0;this.serializeBool(i),i&&(typeof e=="string"?this.serializeStr(e):e instanceof Uint8Array?t!==void 0?this.serializeFixedBytes(e):this.serializeBytes(e):e.serialize(this))}serializeOptionStr(e){e===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(e))}};s([o(0,U)],n.prototype,"serializeU8",1),s([o(0,b)],n.prototype,"serializeU16",1),s([o(0,f)],n.prototype,"serializeU32",1),s([o(BigInt(0),h)],n.prototype,"serializeU64",1),s([o(BigInt(0),l)],n.prototype,"serializeU128",1),s([o(BigInt(0),y)],n.prototype,"serializeU256",1),s([o(0,f)],n.prototype,"serializeU32AsUleb128",1);function p(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}var A=(r,e,t)=>`${r} is out of range: [${e}, ${t}]`;function z(r,e,t){let i=BigInt(r);if(i>BigInt(t)||i<BigInt(e))throw new Error(A(r,e,t))}function o(r,e){return(t,i,a)=>{let g=a.value;return a.value=function(u){return z(u,r,e),g.apply(this,[u])},a}}export{B as a,n as b,p as c,A as d,z as e};
|
|
2
|
-
//# sourceMappingURL=chunk-EBMEXURY.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bcs/serializer.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable no-bitwise */\nimport {\n MAX_U128_BIG_INT,\n MAX_U16_NUMBER,\n MAX_U32_NUMBER,\n MAX_U64_BIG_INT,\n MAX_U8_NUMBER,\n MAX_U256_BIG_INT,\n} from \"./consts\";\nimport { Hex } from \"../core/hex\";\nimport { AnyNumber, Uint16, Uint32, Uint8 } from \"../types\";\n\n/**\n * This class serves as a base class for all serializable types. It facilitates\n * composable serialization of complex types and enables the serialization of\n * instances to their BCS (Binary Canonical Serialization) representation.\n * @group Implementation\n * @category BCS\n */\nexport abstract class Serializable {\n abstract serialize(serializer: Serializer): void;\n\n /**\n * Serializes a `Serializable` value to its BCS representation.\n * This function is the TypeScript SDK equivalent of `bcs::to_bytes` in Move.\n * @returns the BCS representation of the Serializable instance as a byte buffer.\n * @group Implementation\n * @category BCS\n */\n bcsToBytes(): Uint8Array {\n const serializer = new Serializer();\n this.serialize(serializer);\n return serializer.toUint8Array();\n }\n\n /**\n * Converts the BCS-serialized bytes of a value into a Hex instance.\n * This function provides a Hex representation of the BCS-serialized data for easier handling and manipulation.\n * @returns A Hex instance with the BCS-serialized bytes loaded into its underlying Uint8Array.\n * @group Implementation\n * @category BCS\n */\n bcsToHex(): Hex {\n const bcsBytes = this.bcsToBytes();\n return Hex.fromHexInput(bcsBytes);\n }\n\n /**\n * Returns the hex string representation of the `Serializable` value without the 0x prefix.\n * @returns the hex format as a string without `0x` prefix.\n */\n toStringWithoutPrefix(): string {\n return this.bcsToHex().toStringWithoutPrefix();\n }\n\n /**\n * Returns the hex string representation of the `Serializable` value with the 0x prefix.\n * @returns the hex formatas a string prefixed by `0x`.\n */\n toString(): string {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n}\n\n/**\n * A class for serializing various data types into a binary format.\n * It provides methods to serialize strings, bytes, numbers, and other serializable objects\n * using the Binary Coded Serialization (BCS) layout. The serialized data can be retrieved as a\n * Uint8Array.\n * @group Implementation\n * @category BCS\n */\nexport class Serializer {\n private buffer: ArrayBuffer;\n\n private offset: number;\n\n /**\n * Constructs a serializer with a buffer of size `length` bytes, 64 bytes by default.\n * The `length` must be greater than 0.\n *\n * @param length - The size of the buffer in bytes.\n * @group Implementation\n * @category BCS\n */\n constructor(length: number = 64) {\n if (length <= 0) {\n throw new Error(\"Length needs to be greater than 0\");\n }\n this.buffer = new ArrayBuffer(length);\n this.offset = 0;\n }\n\n /**\n * Ensures that the internal buffer can accommodate the specified number of bytes.\n * This function dynamically resizes the buffer if the current size is insufficient.\n *\n * @param bytes - The number of bytes to ensure the buffer can handle.\n * @group Implementation\n * @category BCS\n */\n private ensureBufferWillHandleSize(bytes: number) {\n while (this.buffer.byteLength < this.offset + bytes) {\n const newBuffer = new ArrayBuffer(this.buffer.byteLength * 2);\n new Uint8Array(newBuffer).set(new Uint8Array(this.buffer));\n this.buffer = newBuffer;\n }\n }\n\n /**\n * Appends the specified values to the buffer, ensuring that the buffer can accommodate the new data.\n *\n * @param {Uint8Array} values - The values to be appended to the buffer.\n * @group Implementation\n * @category BCS\n */\n protected appendToBuffer(values: Uint8Array) {\n this.ensureBufferWillHandleSize(values.length);\n new Uint8Array(this.buffer, this.offset).set(values);\n this.offset += values.length;\n }\n\n /**\n * Serializes a value into the buffer using the provided function, ensuring the buffer can accommodate the size.\n *\n * @param fn - The function to serialize the value, which takes a byte offset, the value to serialize, and an optional little-endian flag.\n * @param fn.byteOffset - The byte offset at which to write the value.\n * @param fn.value - The numeric value to serialize into the buffer.\n * @param fn.littleEndian - Optional flag indicating whether to use little-endian byte order (defaults to true).\n * @group Implementation\n * @category BCS\n */\n // TODO: JSDoc bytesLength and value\n private serializeWithFunction(\n fn: (byteOffset: number, value: number, littleEndian?: boolean) => void,\n bytesLength: number,\n value: number,\n ) {\n this.ensureBufferWillHandleSize(bytesLength);\n const dv = new DataView(this.buffer, this.offset);\n fn.apply(dv, [0, value, true]);\n this.offset += bytesLength;\n }\n\n /**\n * Serializes a string. UTF8 string is supported.\n * The number of bytes in the string content is serialized first, as a uleb128-encoded u32 integer.\n * Then the string content is serialized as UTF8 encoded bytes.\n *\n * BCS layout for \"string\": string_length | string_content\n * where string_length is a u32 integer encoded as a uleb128 integer, equal to the number of bytes in string_content.\n *\n * @param value - The string to serialize.\n *\n * @example\n * ```typescript\n * const serializer = new Serializer();\n * serializer.serializeStr(\"1234abcd\");\n * assert(serializer.toUint8Array() === new Uint8Array([8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * ```\n * @group Implementation\n * @category BCS\n */\n serializeStr(value: string) {\n const textEncoder = new TextEncoder();\n this.serializeBytes(textEncoder.encode(value));\n }\n\n /**\n * Serializes an array of bytes.\n *\n * This function encodes the length of the byte array as a u32 integer in uleb128 format, followed by the byte array itself.\n * BCS layout for \"bytes\": bytes_length | bytes\n * where bytes_length is a u32 integer encoded as a uleb128 integer, equal to the length of the bytes array.\n * @param value - The byte array to serialize.\n * @group Implementation\n * @category BCS\n */\n serializeBytes(value: Uint8Array) {\n this.serializeU32AsUleb128(value.length);\n this.appendToBuffer(value);\n }\n\n /**\n * Serializes an array of bytes with a known length, allowing for efficient deserialization without needing to serialize the\n * length itself.\n * When deserializing, the number of bytes to deserialize needs to be passed in.\n\n * @param value - The Uint8Array to be serialized.\n * @group Implementation\n * @category BCS\n */\n serializeFixedBytes(value: Uint8Array) {\n this.appendToBuffer(value);\n }\n\n /**\n * Serializes a boolean value into a byte representation.\n *\n * The BCS layout for a boolean uses one byte, where \"0x01\" represents true and \"0x00\" represents false.\n *\n * @param value - The boolean value to serialize.\n * @group Implementation\n * @category BCS\n */\n serializeBool(value: boolean) {\n /**\n * Ensures that the provided value is a boolean.\n * This function throws an error if the value is not a boolean, helping to enforce type safety in your code.\n *\n * @param value - The value to be checked for boolean type.\n * @throws {Error} Throws an error if the value is not a boolean.\n * @group Implementation\n * @category BCS\n */\n ensureBoolean(value);\n const byteValue = value ? 1 : 0;\n this.appendToBuffer(new Uint8Array([byteValue]));\n }\n\n /**\n * Serializes a Uint8 value and appends it to the buffer.\n * BCS layout for \"uint8\": One byte. Binary format in little-endian representation.\n *\n * @param value - The Uint8 value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(0, MAX_U8_NUMBER)\n serializeU8(value: Uint8) {\n this.appendToBuffer(new Uint8Array([value]));\n }\n\n /**\n * Serializes a uint16 number.\n *\n * @group Implementation\n * @category BCS\n\n */\n\n /**\n * Serializes a 16-bit unsigned integer value into a binary format.\n * BCS layout for \"uint16\": Two bytes. Binary format in little-endian representation.\n *\n * @param value - The 16-bit unsigned integer value to serialize.\n * @example\n * ```typescript\n * const serializer = new Serializer();\n * serializer.serializeU16(4660);\n * assert(serializer.toUint8Array() === new Uint8Array([0x34, 0x12]));\n * ```\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(0, MAX_U16_NUMBER)\n serializeU16(value: Uint16) {\n this.serializeWithFunction(DataView.prototype.setUint16, 2, value);\n }\n\n /**\n * Serializes a 32-bit unsigned integer value into a binary format.\n * This function is useful for encoding data that needs to be stored or transmitted in a compact form.\n * @example\n * ```typescript\n * const serializer = new Serializer();\n * serializer.serializeU32(305419896);\n * assert(serializer.toUint8Array() === new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n * ```\n * @param value - The 32-bit unsigned integer value to serialize.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(0, MAX_U32_NUMBER)\n serializeU32(value: Uint32) {\n this.serializeWithFunction(DataView.prototype.setUint32, 4, value);\n }\n\n /**\n * Serializes a 64-bit unsigned integer into a format suitable for storage or transmission.\n * This function breaks down the value into two 32-bit components and writes them in little-endian order.\n *\n * @param value - The 64-bit unsigned integer to serialize, represented as a number.\n * @example\n * ```ts\n * const serializer = new Serializer();\n * serializer.serializeU64(1311768467750121216);\n * assert(serializer.toUint8Array() === new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12]));\n * ```\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(BigInt(0), MAX_U64_BIG_INT)\n serializeU64(value: AnyNumber) {\n const low = BigInt(value) & BigInt(MAX_U32_NUMBER);\n const high = BigInt(value) >> BigInt(32);\n\n // write little endian number\n this.serializeU32(Number(low));\n this.serializeU32(Number(high));\n }\n\n /**\n * Serializes a U128 value into a format suitable for storage or transmission.\n *\n * @param value - The U128 value to serialize, represented as a number.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(BigInt(0), MAX_U128_BIG_INT)\n serializeU128(value: AnyNumber) {\n const low = BigInt(value) & MAX_U64_BIG_INT;\n const high = BigInt(value) >> BigInt(64);\n\n // write little endian number\n this.serializeU64(low);\n this.serializeU64(high);\n }\n\n /**\n * Serializes a U256 value into a byte representation.\n * This function is essential for encoding large numbers in a compact format suitable for transmission or storage.\n *\n * @param value - The U256 value to serialize, represented as an AnyNumber.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(BigInt(0), MAX_U256_BIG_INT)\n serializeU256(value: AnyNumber) {\n const low = BigInt(value) & MAX_U128_BIG_INT;\n const high = BigInt(value) >> BigInt(128);\n\n // write little endian number\n this.serializeU128(low);\n this.serializeU128(high);\n }\n\n /**\n * Serializes a 32-bit unsigned integer as a variable-length ULEB128 encoded byte array.\n * BCS uses uleb128 encoding in two cases: (1) lengths of variable-length sequences and (2) tags of enum values\n *\n * @param val - The 32-bit unsigned integer value to be serialized.\n * @group Implementation\n * @category BCS\n */\n @checkNumberRange(0, MAX_U32_NUMBER)\n serializeU32AsUleb128(val: Uint32) {\n let value = val;\n const valueArray = [];\n while (value >>> 7 !== 0) {\n valueArray.push((value & 0x7f) | 0x80);\n value >>>= 7;\n }\n valueArray.push(value);\n this.appendToBuffer(new Uint8Array(valueArray));\n }\n\n /**\n * Returns the buffered bytes as a Uint8Array.\n *\n * This function allows you to retrieve the byte representation of the buffer up to the current offset.\n *\n * @returns Uint8Array - The byte array representation of the buffer.\n * @group Implementation\n * @category BCS\n */\n toUint8Array(): Uint8Array {\n return new Uint8Array(this.buffer).slice(0, this.offset);\n }\n\n /**\n * Serializes a `Serializable` value, facilitating composable serialization.\n *\n * @param value The Serializable value to serialize.\n *\n * @returns the serializer instance\n * @group Implementation\n * @category BCS\n */\n serialize<T extends Serializable>(value: T): void {\n // NOTE: The `serialize` method called by `value` is defined in `value`'s\n // Serializable interface, not the one defined in this class.\n value.serialize(this);\n }\n\n /**\n * Serializes an array of BCS Serializable values to a serializer instance.\n * The bytes are added to the serializer instance's byte buffer.\n *\n * @param values The array of BCS Serializable values\n * @example\n * const addresses = new Array<AccountAddress>(\n * AccountAddress.from(\"0x1\"),\n * AccountAddress.from(\"0x2\"),\n * AccountAddress.from(\"0xa\"),\n * AccountAddress.from(\"0xb\"),\n * );\n * const serializer = new Serializer();\n * serializer.serializeVector(addresses);\n * const serializedBytes = serializer.toUint8Array();\n * // serializedBytes is now the BCS-serialized bytes\n * // The equivalent value in Move would be:\n * // `bcs::to_bytes(&vector<address> [@0x1, @0x2, @0xa, @0xb])`;\n * @group Implementation\n * @category BCS\n */\n serializeVector<T extends Serializable>(values: Array<T>): void {\n this.serializeU32AsUleb128(values.length);\n values.forEach((item) => {\n item.serialize(this);\n });\n }\n\n /**\n * Serializes an optional value which can be a Serializable, string, or Uint8Array.\n * For strings and Uint8Arrays, it uses the appropriate serialization method.\n *\n * @param value The value to serialize (Serializable, string, Uint8Array, or undefined)\n * @param len Optional fixed length for Uint8Array serialization. If provided, uses serializeFixedBytes instead of serializeBytes\n *\n * @example\n * ```typescript\n * const serializer = new Serializer();\n * serializer.serializeOption(\"hello\"); // Serializes optional string\n * serializer.serializeOption(new Uint8Array([1, 2, 3])); // Serializes optional bytes\n * serializer.serializeOption(new Uint8Array([1, 2, 3]), 3); // Serializes optional fixed-length bytes\n * serializer.serializeOption(new AccountAddress(...)); // Serializes optional Serializable\n * serializer.serializeOption(undefined); // Serializes none case\n * ```\n * @group Implementation\n * @category BCS\n */\n serializeOption<T extends Serializable | string | Uint8Array>(value?: T, len?: number): void {\n const hasValue = value !== undefined;\n this.serializeBool(hasValue);\n if (hasValue) {\n if (typeof value === \"string\") {\n this.serializeStr(value);\n } else if (value instanceof Uint8Array) {\n if (len !== undefined) {\n this.serializeFixedBytes(value);\n } else {\n this.serializeBytes(value);\n }\n } else {\n value.serialize(this);\n }\n }\n }\n\n /**\n * @deprecated use `serializeOption` instead.\n * Serializes an optional string, supporting UTF8 encoding.\n * The function encodes the existence of the string first, followed by the length and content if it exists.\n *\n * BCS layout for optional \"string\": 1 | string_length | string_content\n * where string_length is a u32 integer encoded as a uleb128 integer, equal to the number of bytes in string_content.\n * BCS layout for undefined: 0\n *\n * @param value - The optional string to serialize. If undefined, it will serialize as 0.\n * @group Implementation\n * @category BCS\n */\n serializeOptionStr(value?: string): void {\n if (value === undefined) {\n this.serializeU32AsUleb128(0);\n } else {\n this.serializeU32AsUleb128(1);\n this.serializeStr(value);\n }\n }\n}\n\n/**\n * @group Implementation\n * @category BCS\n */\nexport function ensureBoolean(value: unknown): asserts value is boolean {\n if (typeof value !== \"boolean\") {\n throw new Error(`${value} is not a boolean value`);\n }\n}\n/**\n * @group Implementation\n * @category BCS\n */\nexport const outOfRangeErrorMessage = (value: AnyNumber, min: AnyNumber, max: AnyNumber) =>\n `${value} is out of range: [${min}, ${max}]`;\n\n/**\n * Validates that a given number is within a specified range.\n * This function throws an error if the value is outside the defined minimum and maximum bounds.\n *\n * @param value - The number to validate.\n * @param minValue - The minimum allowable value (inclusive).\n * @param maxValue - The maximum allowable value (inclusive).\n * @group Implementation\n * @category BCS\n */\nexport function validateNumberInRange<T extends AnyNumber>(value: T, minValue: T, maxValue: T) {\n const valueBigInt = BigInt(value);\n if (valueBigInt > BigInt(maxValue) || valueBigInt < BigInt(minValue)) {\n throw new Error(outOfRangeErrorMessage(value, minValue, maxValue));\n }\n}\n\n/**\n * A decorator that validates that the input argument for a function is within a specified range.\n * This ensures that the function is only called with valid input values, preventing potential errors.\n *\n * @param minValue - The input argument must be greater than or equal to this value.\n * @param maxValue - The input argument must be less than or equal to this value.\n * @group Implementation\n * @category BCS\n */\nfunction checkNumberRange<T extends AnyNumber>(minValue: T, maxValue: T) {\n return (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => {\n const childFunction = descriptor.value;\n // eslint-disable-next-line no-param-reassign\n descriptor.value = function deco(value: AnyNumber) {\n validateNumberInRange(value, minValue, maxValue);\n return childFunction.apply(this, [value]);\n };\n\n return descriptor;\n };\n}\n"],"mappings":"yJAsBO,IAAeA,EAAf,KAA4B,CAUjC,YAAyB,CACvB,IAAMC,EAAa,IAAI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AaC,EAAa,CAC7F,IAAMC,EAAc,OAAO1B,CAAK,EAChC,GAAI0B,EAAc,OAAOD,CAAQ,GAAKC,EAAc,OAAOF,CAAQ,EACjE,MAAM,IAAI,MAAMJ,EAAuBpB,EAAOwB,EAAUC,CAAQ,CAAC,CAErE,CAWA,SAAST,EAAsCQ,EAAaC,EAAa,CACvE,MAAO,CAACE,EAAiBC,EAAqBC,IAAmC,CAC/E,IAAMC,EAAgBD,EAAW,MAEjC,OAAAA,EAAW,MAAQ,SAAc7B,EAAkB,CACjD,OAAAuB,EAAsBvB,EAAOwB,EAAUC,CAAQ,EACxCK,EAAc,MAAM,KAAM,CAAC9B,CAAK,CAAC,CAC1C,EAEO6B,CACT,CACF","names":["Serializable","serializer","Serializer","bcsBytes","Hex","length","bytes","newBuffer","values","fn","bytesLength","value","dv","textEncoder","ensureBoolean","byteValue","low","MAX_U32_NUMBER","high","MAX_U64_BIG_INT","MAX_U128_BIG_INT","val","valueArray","item","len","hasValue","__decorateClass","checkNumberRange","MAX_U8_NUMBER","MAX_U16_NUMBER","MAX_U256_BIG_INT","outOfRangeErrorMessage","min","max","validateNumberInRange","minValue","maxValue","valueBigInt","target","propertyKey","descriptor","childFunction"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as s}from"./chunk-WCMW2L3P.mjs";import{b as o}from"./chunk-WSR5EBJM.mjs";import{a as t}from"./chunk-FGFLPH5K.mjs";import{b as i}from"./chunk-STY74NUA.mjs";var n=class e extends s{constructor(r){super(),this.value=i.fromHexInput(r).toUint8Array()}serialize(r){r.serializeBytes(this.value)}static deserialize(r){return new e(r.deserializeBytes())}},a=class extends o{constructor(r){super(),this.accountAddress=r}authKey(){return new t({data:this.accountAddress.toUint8Array()})}verifySignature(r){throw new Error("This function is not implemented for AbstractPublicKey.")}async verifySignatureAsync(r){throw new Error("This function is not implemented for AbstractPublicKey.")}serialize(r){throw new Error("This function is not implemented for AbstractPublicKey.")}};export{n as a,a as b};
|
|
2
|
-
//# sourceMappingURL=chunk-EF4FA5I6.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/crypto/abstraction.ts"],"sourcesContent":["import { Deserializer, Serializer } from \"../../bcs\";\nimport { HexInput } from \"../../types\";\nimport { AccountAddress } from \"../accountAddress\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Hex } from \"../hex\";\nimport { AccountPublicKey, VerifySignatureArgs, VerifySignatureAsyncArgs } from \"./publicKey\";\nimport { Signature } from \"./signature\";\n\nexport class AbstractSignature extends Signature {\n readonly value: Uint8Array;\n\n constructor(value: HexInput) {\n super();\n this.value = Hex.fromHexInput(value).toUint8Array();\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.value);\n }\n\n static deserialize(deserializer: Deserializer): AbstractSignature {\n return new AbstractSignature(deserializer.deserializeBytes());\n }\n}\n\nexport class AbstractPublicKey extends AccountPublicKey {\n readonly accountAddress: AccountAddress;\n\n constructor(accountAddress: AccountAddress) {\n super();\n this.accountAddress = accountAddress;\n }\n\n authKey(): AuthenticationKey {\n return new AuthenticationKey({ data: this.accountAddress.toUint8Array() });\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n verifySignature(args: VerifySignatureArgs): boolean {\n throw new Error(\"This function is not implemented for AbstractPublicKey.\");\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n async verifySignatureAsync(args: VerifySignatureAsyncArgs): Promise<boolean> {\n throw new Error(\"This function is not implemented for AbstractPublicKey.\");\n }\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n serialize(serializer: Serializer): void {\n throw new Error(\"This function is not implemented for AbstractPublicKey.\");\n }\n}\n"],"mappings":"oKAQO,IAAMA,EAAN,MAAMC,UAA0BC,CAAU,CAG/C,YAAYC,EAAiB,CAC3B,MAAM,EACN,KAAK,MAAQC,EAAI,aAAaD,CAAK,EAAE,aAAa,CACpD,CAEA,UAAUE,EAA8B,CACtCA,EAAW,eAAe,KAAK,KAAK,CACtC,CAEA,OAAO,YAAYC,EAA+C,CAChE,OAAO,IAAIL,EAAkBK,EAAa,iBAAiB,CAAC,CAC9D,CACF,EAEaC,EAAN,cAAgCC,CAAiB,CAGtD,YAAYC,EAAgC,CAC1C,MAAM,EACN,KAAK,eAAiBA,CACxB,CAEA,SAA6B,CAC3B,OAAO,IAAIC,EAAkB,CAAE,KAAM,KAAK,eAAe,aAAa,CAAE,CAAC,CAC3E,CAGA,gBAAgBC,EAAoC,CAClD,MAAM,IAAI,MAAM,yDAAyD,CAC3E,CAGA,MAAM,qBAAqBA,EAAkD,CAC3E,MAAM,IAAI,MAAM,yDAAyD,CAC3E,CAGA,UAAUN,EAA8B,CACtC,MAAM,IAAI,MAAM,yDAAyD,CAC3E,CACF","names":["AbstractSignature","_AbstractSignature","Signature","value","Hex","serializer","deserializer","AbstractPublicKey","AccountPublicKey","accountAddress","AuthenticationKey","args"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-FD6FGKYY.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as c}from"./chunk-RGKRCZ36.mjs";import{a as o}from"./chunk-EBMEXURY.mjs";import{b as n}from"./chunk-STY74NUA.mjs";import{sha3_256 as d}from"@noble/hashes/sha3";var r=class r extends o{constructor(t){super();let{data:e}=t,i=n.fromHexInput(e);if(i.toUint8Array().length!==r.LENGTH)throw new Error(`Authentication Key length should be ${r.LENGTH}`);this.data=i}serialize(t){t.serializeFixedBytes(this.data.toUint8Array())}static deserialize(t){let e=t.deserializeFixedBytes(r.LENGTH);return new r({data:e})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(t){let{scheme:e,input:i}=t,u=n.fromHexInput(i).toUint8Array(),h=new Uint8Array([...u,e]),a=d.create();a.update(h);let y=a.digest();return new r({data:y})}static fromPublicKeyAndScheme(t){let{publicKey:e}=t;return e.authKey()}static fromPublicKey(t){let{publicKey:e}=t;return e.authKey()}derivedAddress(){return new c(this.data.toUint8Array())}};r.LENGTH=32;var s=r;export{s as a};
|
|
2
|
-
//# sourceMappingURL=chunk-FGFLPH5K.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/authenticationKey.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { sha3_256 as sha3Hash } from \"@noble/hashes/sha3\";\nimport { AccountAddress } from \"./accountAddress\";\nimport type { AccountPublicKey } from \"./crypto\";\nimport { Hex } from \"./hex\";\nimport { AuthenticationKeyScheme, HexInput } from \"../types\";\nimport { Serializable, Serializer } from \"../bcs/serializer\";\nimport { Deserializer } from \"../bcs/deserializer\";\n\n/**\n * Represents an authentication key used for account management. Each account stores an authentication key that enables account\n * owners to rotate their private key(s) without changing the address that hosts their account. The authentication key is a\n * SHA3-256 hash of data and is always 32 bytes in length.\n *\n * @see {@link https://aptos.dev/concepts/accounts | Account Basics}\n *\n * Account addresses can be derived from the AuthenticationKey.\n * @group Implementation\n * @category Serialization\n */\nexport class AuthenticationKey extends Serializable {\n /**\n * An authentication key is always a SHA3-256 hash of data, and is always 32 bytes.\n *\n * The data to hash depends on the underlying public key type and the derivation scheme.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The raw bytes of the authentication key.\n * @group Implementation\n * @category Serialization\n */\n public readonly data: Hex;\n\n /**\n * Creates an instance of the AuthenticationKey using the provided hex input.\n * This ensures that the hex input is valid and conforms to the required length for an Authentication Key.\n *\n * @param args - The arguments for constructing the AuthenticationKey.\n * @param args.data - The hex input data to be used for the Authentication Key.\n * @throws {Error} Throws an error if the length of the provided hex input is not equal to the required Authentication Key\n * length.\n * @group Implementation\n * @category Serialization\n */\n constructor(args: { data: HexInput }) {\n super();\n const { data } = args;\n const hex = Hex.fromHexInput(data);\n if (hex.toUint8Array().length !== AuthenticationKey.LENGTH) {\n throw new Error(`Authentication Key length should be ${AuthenticationKey.LENGTH}`);\n }\n this.data = hex;\n }\n\n /**\n * Serializes the fixed bytes data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data.toUint8Array());\n }\n\n /**\n * Deserialize an AuthenticationKey from the byte buffer in a Deserializer instance.\n * @param deserializer - The deserializer to deserialize the AuthenticationKey from.\n * @returns An instance of AuthenticationKey.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): AuthenticationKey {\n const bytes = deserializer.deserializeFixedBytes(AuthenticationKey.LENGTH);\n return new AuthenticationKey({ data: bytes });\n }\n\n /**\n * Convert the internal data representation to a Uint8Array.\n *\n * This function is useful for obtaining a byte representation of the data, which can be utilized for serialization or transmission.\n *\n * @returns Uint8Array representation of the internal data.\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data.toUint8Array();\n }\n\n /**\n * Generates an AuthenticationKey from the specified scheme and input bytes.\n * This function is essential for creating a valid authentication key based on a given scheme.\n *\n * @param args - The arguments for generating the AuthenticationKey.\n * @param args.scheme - The authentication key scheme to use.\n * @param args.input - The input data in hexadecimal format to derive the key.\n * @returns An instance of AuthenticationKey containing the generated key data.\n * @group Implementation\n * @category Serialization\n */\n static fromSchemeAndBytes(args: { scheme: AuthenticationKeyScheme; input: HexInput }): AuthenticationKey {\n const { scheme, input } = args;\n const inputBytes = Hex.fromHexInput(input).toUint8Array();\n const hashInput = new Uint8Array([...inputBytes, scheme]);\n const hash = sha3Hash.create();\n hash.update(hashInput);\n const hashDigest = hash.digest();\n return new AuthenticationKey({ data: hashDigest });\n }\n\n /**\n * Derives an AuthenticationKey from the provided public key using a specified derivation scheme.\n *\n * @deprecated Use `fromPublicKey` instead.\n * @param args - The arguments for deriving the authentication key.\n * @param args.publicKey - The public key used for the derivation.\n * @param args.scheme - The scheme to use for deriving the authentication key.\n * @group Implementation\n * @category Serialization\n */\n public static fromPublicKeyAndScheme(args: { publicKey: AccountPublicKey; scheme: AuthenticationKeyScheme }) {\n const { publicKey } = args;\n return publicKey.authKey();\n }\n\n /**\n * Converts a PublicKey to an AuthenticationKey using the derivation scheme inferred from the provided PublicKey instance.\n *\n * @param args - The arguments for the function.\n * @param args.publicKey - The PublicKey to be converted.\n * @returns AuthenticationKey - The derived AuthenticationKey.\n * @group Implementation\n * @category Serialization\n */\n static fromPublicKey(args: { publicKey: AccountPublicKey }): AuthenticationKey {\n const { publicKey } = args;\n return publicKey.authKey();\n }\n\n /**\n * Derives an account address from an AuthenticationKey by translating the AuthenticationKey bytes directly to an AccountAddress.\n *\n * @returns AccountAddress - The derived account address.\n * @group Implementation\n * @category Serialization\n */\n derivedAddress(): AccountAddress {\n return new AccountAddress(this.data.toUint8Array());\n }\n}\n"],"mappings":"2HAGA,OAAS,YAAYA,MAAgB,qBAmB9B,IAAMC,EAAN,MAAMA,UAA0BC,CAAa,CA4BlD,YAAYC,EAA0B,CACpC,MAAM,EACN,GAAM,CAAE,KAAAC,CAAK,EAAID,EACXE,EAAMC,EAAI,aAAaF,CAAI,EACjC,GAAIC,EAAI,aAAa,EAAE,SAAWJ,EAAkB,OAClD,MAAM,IAAI,MAAM,uCAAuCA,EAAkB,MAAM,EAAE,EAEnF,KAAK,KAAOI,CACd,CASA,UAAUE,EAA8B,CACtCA,EAAW,oBAAoB,KAAK,KAAK,aAAa,CAAC,CACzD,CASA,OAAO,YAAYC,EAA+C,CAChE,IAAMC,EAAQD,EAAa,sBAAsBP,EAAkB,MAAM,EACzE,OAAO,IAAIA,EAAkB,CAAE,KAAMQ,CAAM,CAAC,CAC9C,CAWA,cAA2B,CACzB,OAAO,KAAK,KAAK,aAAa,CAChC,CAaA,OAAO,mBAAmBN,EAA+E,CACvG,GAAM,CAAE,OAAAO,EAAQ,MAAAC,CAAM,EAAIR,EACpBS,EAAaN,EAAI,aAAaK,CAAK,EAAE,aAAa,EAClDE,EAAY,IAAI,WAAW,CAAC,GAAGD,EAAYF,CAAM,CAAC,EAClDI,EAAOC,EAAS,OAAO,EAC7BD,EAAK,OAAOD,CAAS,EACrB,IAAMG,EAAaF,EAAK,OAAO,EAC/B,OAAO,IAAIb,EAAkB,CAAE,KAAMe,CAAW,CAAC,CACnD,CAYA,OAAc,uBAAuBb,EAAwE,CAC3G,GAAM,CAAE,UAAAc,CAAU,EAAId,EACtB,OAAOc,EAAU,QAAQ,CAC3B,CAWA,OAAO,cAAcd,EAA0D,CAC7E,GAAM,CAAE,UAAAc,CAAU,EAAId,EACtB,OAAOc,EAAU,QAAQ,CAC3B,CASA,gBAAiC,CAC/B,OAAO,IAAIC,EAAe,KAAK,KAAK,aAAa,CAAC,CACpD,CACF,EAtIajB,EAQK,OAAiB,GAR5B,IAAMkB,EAANlB","names":["sha3Hash","_AuthenticationKey","Serializable","args","data","hex","Hex","serializer","deserializer","bytes","scheme","input","inputBytes","hashInput","hash","sha3Hash","hashDigest","publicKey","AccountAddress","AuthenticationKey"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as s}from"./chunk-STY74NUA.mjs";import{c as t}from"./chunk-56CNRT2K.mjs";var a=class d{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){let i=s.hexInputToUint8Array(e);return new d(i)}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let i=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,i}remaining(){return this.buffer.byteLength-this.offset}assertFinished(){if(this.remaining()!==0)throw new Error("Buffer has remaining bytes")}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeOption("string")}deserializeOption(e,i){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(i===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(i)}return this.deserialize(e)}}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32(),i=this.deserializeU32();return BigInt(BigInt(i)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),i=this.deserializeU64();return BigInt(i<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),i=this.deserializeU128();return BigInt(i<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),i=0;for(;e<t;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(i),(r&128)===0)break;i+=7}if(e>t)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let i=this.deserializeUleb128AsU32(),r=new Array;for(let n=0;n<i;n+=1)r.push(this.deserialize(e));return r}};export{a};
|
|
2
|
-
//# sourceMappingURL=chunk-FLZPUYXQ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bcs/deserializer.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable no-bitwise */\nimport { MAX_U32_NUMBER } from \"./consts\";\nimport { Uint8, Uint16, Uint32, Uint64, Uint128, Uint256, HexInput } from \"../types\";\nimport { Hex } from \"../core/hex\";\n\n/**\n * This interface exists to define Deserializable<T> inputs for functions that\n * deserialize a byte buffer into a type T.\n * It is not intended to be implemented or extended, because Typescript has no support\n * for static methods in interfaces.\n *\n * @template T - The type that this will deserialize into.\n * @group Implementation\n * @category BCS\n */\nexport interface Deserializable<T> {\n /**\n * Deserializes the buffered bytes into an instance of the specified class type.\n * This function provides an alternative syntax for deserialization, allowing users to call\n * `deserializer.deserialize(MyClass)` instead of `MyClass.deserialize(deserializer)`.\n *\n * @param deserializer - The deserializer instance with the buffered bytes.\n * @returns The deserialized value of class type T.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserialize(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n * // equivalent to `const value = MyClass.deserialize(deserializer)`\n * ```\n * @group Implementation\n * @category BCS\n */\n deserialize(deserializer: Deserializer): T;\n}\n\n/**\n * A class that provides methods for deserializing various data types from a byte buffer.\n * It supports deserialization of primitive types, strings, and complex objects using a BCS (Binary Common Serialization) layout.\n * @group Implementation\n * @category BCS\n */\nexport class Deserializer {\n private buffer: ArrayBuffer;\n\n private offset: number;\n\n /**\n * Creates a new instance of the class with a copy of the provided data buffer.\n * This prevents outside mutation of the buffer.\n *\n * @param data - The data to be copied into the internal buffer as a Uint8Array.\n * @group Implementation\n * @category BCS\n */\n constructor(data: Uint8Array) {\n // copies data to prevent outside mutation of buffer.\n this.buffer = new ArrayBuffer(data.length);\n new Uint8Array(this.buffer).set(data, 0);\n this.offset = 0;\n }\n\n static fromHex(hex: HexInput): Deserializer {\n const data = Hex.hexInputToUint8Array(hex);\n return new Deserializer(data);\n }\n\n /**\n * Reads a specified number of bytes from the buffer and advances the offset.\n *\n * @param length - The number of bytes to read from the buffer.\n * @throws Throws an error if the read operation exceeds the buffer's length.\n * @group Implementation\n * @category BCS\n */\n private read(length: number): ArrayBuffer {\n if (this.offset + length > this.buffer.byteLength) {\n throw new Error(\"Reached to the end of buffer\");\n }\n\n const bytes = this.buffer.slice(this.offset, this.offset + length);\n this.offset += length;\n return bytes;\n }\n\n /**\n * Returns the number of bytes remaining in the buffer.\n *\n * This information is useful to determine if there's more data to be read.\n *\n * @returns The number of bytes remaining in the buffer.\n * @group Implementation\n * @category BCS\n */\n remaining(): number {\n return this.buffer.byteLength - this.offset;\n }\n\n /**\n * Asserts that the buffer has no remaining bytes.\n *\n * @throws {Error} Throws an error if there are remaining bytes in the buffer.\n * @group Implementation\n * @category BCS\n */\n assertFinished(): void {\n if (this.remaining() !== 0) {\n throw new Error(\"Buffer has remaining bytes\");\n }\n }\n\n /**\n * Deserializes a UTF-8 encoded string from a byte array. It first reads the length of the string in bytes,\n * followed by the actual byte content, and decodes it into a string.\n *\n * BCS layout for \"string\": string_length | string_content\n * where string_length is a u32 integer encoded as a uleb128 integer, equal to the number of bytes in string_content.\n *\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * assert(deserializer.deserializeStr() === \"1234abcd\");\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeStr(): string {\n const value = this.deserializeBytes();\n const textDecoder = new TextDecoder();\n return textDecoder.decode(value);\n }\n\n /**\n * @deprecated use `deserializeOption(\"string\")` instead.\n *\n * The BCS layout for Optional<String> is 0 if none, else 1 followed by the string length and string content.\n * @returns The deserialized string if it exists, otherwise undefined.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x00]));\n * assert(deserializer.deserializeOptionStr() === undefined);\n * const deserializer = new Deserializer(new Uint8Array([1, 8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * assert(deserializer.deserializeOptionStr() === \"1234abcd\");\n * ```\n */\n deserializeOptionStr(): string | undefined {\n return this.deserializeOption(\"string\");\n }\n\n /**\n * Deserializes an optional value from the buffer.\n *\n * The BCS layout for Optional<T> starts with a boolean byte (0 if none, 1 if some),\n * followed by the value if present.\n *\n * @template T - The type of the value to deserialize\n * @param type - Either a Deserializable class or one of the string literals: \"string\", \"bytes\", or \"fixedBytes\"\n * @param len - Required length when type is \"fixedBytes\", ignored otherwise\n * @returns The deserialized value if present, undefined otherwise\n *\n * @throws {Error} When \"fixedBytes\" is specified without a length\n *\n * @example\n * ```typescript\n * // Deserialize an optional string\n * const deserializer = new Deserializer(new Uint8Array([1, 3, 97, 98, 99]));\n * const optStr = deserializer.deserializeOption(\"string\");\n * // optStr === \"abc\"\n *\n * // Deserialize an optional custom type\n * const deserializer = new Deserializer(new Uint8Array([0]));\n * const optValue = deserializer.deserializeOption(MyClass);\n * // optValue === undefined\n *\n * // Deserialize optional bytes\n * const deserializer = new Deserializer(new Uint8Array([1, 3, 1, 2, 3]));\n * const optBytes = deserializer.deserializeOption(\"bytes\");\n * // optBytes === Uint8Array[1, 2, 3]\n *\n * // Deserialize optional fixed bytes\n * const deserializer = new Deserializer(new Uint8Array([1, 1, 2, 3, 4]));\n * const optBytes = deserializer.deserializeOption(\"fixedBytes\", 4);\n * // optBytes === Uint8Array[1, 2, 3, 4]\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeOption(type: \"string\"): string | undefined;\n deserializeOption(type: \"bytes\"): Uint8Array | undefined;\n deserializeOption(type: \"fixedBytes\", len: number): Uint8Array | undefined;\n deserializeOption<T>(type: Deserializable<T>): T | undefined;\n deserializeOption<T>(\n type: Deserializable<T> | \"string\" | \"bytes\" | \"fixedBytes\",\n len?: number,\n ): T | string | Uint8Array | undefined {\n const exists = this.deserializeBool();\n if (!exists) return undefined;\n\n if (type === \"string\") {\n return this.deserializeStr();\n }\n if (type === \"bytes\") {\n return this.deserializeBytes();\n }\n if (type === \"fixedBytes\") {\n if (len === undefined) {\n throw new Error(\"Fixed bytes length not provided\");\n }\n return this.deserializeFixedBytes(len);\n }\n\n return this.deserialize(type);\n }\n\n /**\n * Deserializes an array of bytes.\n *\n * The BCS layout for \"bytes\" consists of a bytes_length followed by the bytes themselves, where bytes_length is a u32 integer\n * encoded as a uleb128 integer, indicating the length of the bytes array.\n *\n * @returns {Uint8Array} The deserialized array of bytes.\n * @group Implementation\n * @category BCS\n */\n deserializeBytes(): Uint8Array {\n const len = this.deserializeUleb128AsU32();\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes an array of bytes of a specified length.\n *\n * @param len - The number of bytes to read from the source.\n * @group Implementation\n * @category BCS\n */\n deserializeFixedBytes(len: number): Uint8Array {\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes a boolean value from a byte stream.\n *\n * The BCS layout for a boolean uses one byte, where \"0x01\" represents true and \"0x00\" represents false.\n * An error is thrown if the byte value is not valid.\n *\n * @returns The deserialized boolean value.\n * @throws Throws an error if the boolean value is invalid.\n * @group Implementation\n * @category BCS\n */\n deserializeBool(): boolean {\n const bool = new Uint8Array(this.read(1))[0];\n if (bool !== 1 && bool !== 0) {\n throw new Error(\"Invalid boolean value\");\n }\n return bool === 1;\n }\n\n /**\n * Deserializes a uint8 number from the binary data.\n *\n * BCS layout for \"uint8\": One byte. Binary format in little-endian representation.\n *\n * @returns {number} The deserialized uint8 number.\n * @group Implementation\n * @category BCS\n */\n deserializeU8(): Uint8 {\n return new DataView(this.read(1)).getUint8(0);\n }\n\n /**\n * Deserializes a uint16 number from a binary format in little-endian representation.\n *\n * BCS layout for \"uint16\": Two bytes.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x34, 0x12]));\n * assert(deserializer.deserializeU16() === 4660);\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeU16(): Uint16 {\n return new DataView(this.read(2)).getUint16(0, true);\n }\n\n /**\n * Deserializes a uint32 number from a binary format in little-endian representation.\n *\n * BCS layout for \"uint32\": Four bytes.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU32() === 305419896);\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeU32(): Uint32 {\n return new DataView(this.read(4)).getUint32(0, true);\n }\n\n /**\n * Deserializes a uint64 number.\n *\n * This function combines two 32-bit values to return a 64-bit unsigned integer in little-endian representation.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU64() === 1311768467750121216);\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeU64(): Uint64 {\n const low = this.deserializeU32();\n const high = this.deserializeU32();\n\n // combine the two 32-bit values and return (little endian)\n return BigInt((BigInt(high) << BigInt(32)) | BigInt(low));\n }\n\n /**\n * Deserializes a uint128 number from its binary representation.\n * This function combines two 64-bit values to return a single uint128 value in little-endian format.\n *\n * @returns {BigInt} The deserialized uint128 number.\n * @group Implementation\n * @category BCS\n */\n deserializeU128(): Uint128 {\n const low = this.deserializeU64();\n const high = this.deserializeU64();\n\n // combine the two 64-bit values and return (little endian)\n return BigInt((high << BigInt(64)) | low);\n }\n\n /**\n * Deserializes a uint256 number from its binary representation.\n *\n * The BCS layout for \"uint256\" consists of thirty-two bytes in little-endian format.\n *\n * @returns {BigInt} The deserialized uint256 number.\n * @group Implementation\n * @category BCS\n */\n deserializeU256(): Uint256 {\n const low = this.deserializeU128();\n const high = this.deserializeU128();\n\n // combine the two 128-bit values and return (little endian)\n return BigInt((high << BigInt(128)) | low);\n }\n\n /**\n * Deserializes a uleb128 encoded uint32 number.\n *\n * This function is used for interpreting lengths of variable-length sequences and tags of enum values in BCS encoding.\n *\n * @throws {Error} Throws an error if the parsed value exceeds the maximum uint32 number.\n * @returns {number} The deserialized uint32 value.\n * @group Implementation\n * @category BCS\n */\n deserializeUleb128AsU32(): Uint32 {\n let value: bigint = BigInt(0);\n let shift = 0;\n\n while (value < MAX_U32_NUMBER) {\n const byte = this.deserializeU8();\n value |= BigInt(byte & 0x7f) << BigInt(shift);\n\n if ((byte & 0x80) === 0) {\n break;\n }\n shift += 7;\n }\n\n if (value > MAX_U32_NUMBER) {\n throw new Error(\"Overflow while parsing uleb128-encoded uint32 value\");\n }\n\n return Number(value);\n }\n\n /**\n * Helper function that primarily exists to support alternative syntax for deserialization.\n * That is, if we have a `const deserializer: new Deserializer(...)`, instead of having to use\n * `MyClass.deserialize(deserializer)`, we can call `deserializer.deserialize(MyClass)`.\n *\n * @example const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserialize(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n * // equivalent to `const value = MyClass.deserialize(deserializer)`\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n *\n * @returns the deserialized value of class type T\n * @group Implementation\n * @category BCS\n */\n deserialize<T>(cls: Deserializable<T>): T {\n // NOTE: `deserialize` in `cls.deserialize(this)` here is a static method defined in `cls`,\n // It is separate from the `deserialize` instance method defined here in Deserializer.\n return cls.deserialize(this);\n }\n\n /**\n * Deserializes an array of BCS Deserializable values given an existing Deserializer instance with a loaded byte buffer.\n *\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n * @returns An array of deserialized values of type T.\n * @example\n * // serialize a vector of addresses\n * const addresses = new Array<AccountAddress>(\n * AccountAddress.from(\"0x1\"),\n * AccountAddress.from(\"0x2\"),\n * AccountAddress.from(\"0xa\"),\n * AccountAddress.from(\"0xb\"),\n * );\n * const serializer = new Serializer();\n * serializer.serializeVector(addresses);\n * const serializedBytes = serializer.toUint8Array();\n *\n * // deserialize the bytes into an array of addresses\n * const deserializer = new Deserializer(serializedBytes);\n * const deserializedAddresses = deserializer.deserializeVector(AccountAddress);\n * // deserializedAddresses is now an array of AccountAddress instances\n * @group Implementation\n * @category BCS\n */\n deserializeVector<T>(cls: Deserializable<T>): Array<T> {\n const length = this.deserializeUleb128AsU32();\n const vector = new Array<T>();\n for (let i = 0; i < length; i += 1) {\n vector.push(this.deserialize(cls));\n }\n return vector;\n }\n}\n"],"mappings":"kFA6CO,IAAMA,EAAN,MAAMC,CAAa,CAaxB,YAAYC,EAAkB,CAE5B,KAAK,OAAS,IAAI,YAAYA,EAAK,MAAM,EACzC,IAAI,WAAW,KAAK,MAAM,EAAE,IAAIA,EAAM,CAAC,EACvC,KAAK,OAAS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EAAO,KAAK,KAAK,YAAYD,CAAG,CAAC,EAEnC,OAAOC,CACT,CACF","names":["Deserializer","_Deserializer","data","hex","Hex","length","bytes","value","type","len","bool","low","high","shift","MAX_U32_NUMBER","byte","cls","vector","i"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-FZY4PMEE.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-G3MHXDYA.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{poseidon1 as h,poseidon2 as u,poseidon3 as a,poseidon4 as l,poseidon5 as c,poseidon6 as d,poseidon7 as p,poseidon8 as f,poseidon9 as A,poseidon10 as U,poseidon11 as b,poseidon12 as w,poseidon13 as E,poseidon14 as I,poseidon15 as y,poseidon16 as B}from"poseidon-lite";var i=[h,u,a,l,c,d,p,f,A,U,b,w,E,I,y,B],g=31,m=16,s=(m-1)*g;function C(n,t){let o=new TextEncoder().encode(n);return $(o,t)}function $(n,t){if(n.length>t)throw new Error(`Inputted bytes of length ${n} is longer than ${t}`);let r=_(n,t);return M(r)}function T(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);let r=k(n,t);return P(r)}function _(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);return T(n,t).concat([BigInt(n.length)])}function P(n){if(n.length>s)throw new Error(`Can't pack more than ${s}. Was given ${n.length} bytes`);return L(n,g).map(t=>N(t))}function L(n,t){let r=[];for(let o=0;o<n.length;o+=t)r.push(n.subarray(o,o+t));return r}function N(n){let t=BigInt(0);for(let r=n.length-1;r>=0;r-=1)t=t<<BigInt(8)|BigInt(n[r]);return t}function W(n,t){let r=BigInt(n),o=new Uint8Array(t);for(let e=0;e<t;e+=1)o[e]=Number(r&BigInt(255)),r>>=BigInt(8);return o}function k(n,t){if(t<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let r=new Uint8Array(t);r.set(n);for(let o=n.length;o<t;o+=1)r[o]=0;return r}function M(n){if(n.length>i.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${i.length}`);return i[n.length-1](n)}export{C as a,_ as b,N as c,W as d,M as e};
|
|
2
|
-
//# sourceMappingURL=chunk-GOXRBEIJ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/crypto/poseidon.ts"],"sourcesContent":["/* eslint-disable no-bitwise */\nimport {\n poseidon1,\n poseidon2,\n poseidon3,\n poseidon4,\n poseidon5,\n poseidon6,\n poseidon7,\n poseidon8,\n poseidon9,\n poseidon10,\n poseidon11,\n poseidon12,\n poseidon13,\n poseidon14,\n poseidon15,\n poseidon16,\n} from \"poseidon-lite\";\n\nconst numInputsToPoseidonFunc = [\n poseidon1,\n poseidon2,\n poseidon3,\n poseidon4,\n poseidon5,\n poseidon6,\n poseidon7,\n poseidon8,\n poseidon9,\n poseidon10,\n poseidon11,\n poseidon12,\n poseidon13,\n poseidon14,\n poseidon15,\n poseidon16,\n];\n\nconst BYTES_PACKED_PER_SCALAR = 31;\nconst MAX_NUM_INPUT_SCALARS = 16;\nconst MAX_NUM_INPUT_BYTES = (MAX_NUM_INPUT_SCALARS - 1) * BYTES_PACKED_PER_SCALAR;\n\n/**\n * Hashes a string to a field element via Poseidon hashing.\n * This function is useful for converting a string into a fixed-size hash that can be used in cryptographic applications.\n *\n * @param str - The string to be hashed.\n * @param maxSizeBytes - The maximum size in bytes for the resulting hash.\n * @returns bigint - The result of the hash.\n * @group Implementation\n * @category Serialization\n */\nexport function hashStrToField(str: string, maxSizeBytes: number): bigint {\n const textEncoder = new TextEncoder();\n const strBytes = textEncoder.encode(str);\n return hashBytesWithLen(strBytes, maxSizeBytes);\n}\n\n/**\n * Computes a Poseidon hash of the provided byte array, ensuring that the byte array does not exceed the specified maximum size.\n * This function is useful for generating a hash from a byte array while enforcing size constraints.\n *\n * @param bytes - The byte array to be hashed.\n * @param maxSizeBytes - The maximum allowed size for the byte array.\n * @throws Error if the length of the inputted bytes exceeds the specified maximum size.\n * @group Implementation\n * @category Serialization\n */\nfunction hashBytesWithLen(bytes: Uint8Array, maxSizeBytes: number): bigint {\n if (bytes.length > maxSizeBytes) {\n throw new Error(`Inputted bytes of length ${bytes} is longer than ${maxSizeBytes}`);\n }\n const packed = padAndPackBytesWithLen(bytes, maxSizeBytes);\n return poseidonHash(packed);\n}\n\n/**\n * Pads the input byte array with zeros to a specified maximum size and then packs the bytes.\n * This function ensures that the byte array does not exceed the specified maximum size, throwing an error if it does.\n *\n * @param bytes - The byte array to be padded and packed.\n * @param maxSizeBytes - The maximum size in bytes that the input array can have.\n * @throws Error if the input byte array exceeds the specified maximum size.\n * @group Implementation\n * @category Serialization\n */\nfunction padAndPackBytesNoLen(bytes: Uint8Array, maxSizeBytes: number): bigint[] {\n if (bytes.length > maxSizeBytes) {\n throw new Error(`Input bytes of length ${bytes} is longer than ${maxSizeBytes}`);\n }\n const paddedStrBytes = padUint8ArrayWithZeros(bytes, maxSizeBytes);\n return packBytes(paddedStrBytes);\n}\n\n/**\n * Pads and packs the given byte array to a specified maximum size and appends its length.\n * This function ensures that the byte array does not exceed the maximum size, throwing an error if it does.\n * It is useful for preparing byte data for further processing or transmission by ensuring a consistent format.\n *\n * @param bytes - The byte array to be padded and packed.\n * @param maxSizeBytes - The maximum allowed size for the byte array.\n * @throws Error if the length of the input bytes exceeds the maximum size.\n * @returns A new Uint8Array that contains the padded and packed bytes along with the length of the original byte array.\n * @group Implementation\n * @category Serialization\n */\nexport function padAndPackBytesWithLen(bytes: Uint8Array, maxSizeBytes: number): bigint[] {\n if (bytes.length > maxSizeBytes) {\n throw new Error(`Input bytes of length ${bytes} is longer than ${maxSizeBytes}`);\n }\n return padAndPackBytesNoLen(bytes, maxSizeBytes).concat([BigInt(bytes.length)]);\n}\n\n/**\n * Packs a Uint8Array into an array of BigInts, ensuring the input does not exceed the maximum allowed bytes.\n * @param bytes - The Uint8Array to be packed.\n * @throws {Error} Throws an error if the input exceeds the maximum number of bytes allowed.\n * @group Implementation\n * @category Serialization\n */\nfunction packBytes(bytes: Uint8Array): bigint[] {\n if (bytes.length > MAX_NUM_INPUT_BYTES) {\n throw new Error(`Can't pack more than ${MAX_NUM_INPUT_BYTES}. Was given ${bytes.length} bytes`);\n }\n return chunkUint8Array(bytes, BYTES_PACKED_PER_SCALAR).map((chunk) => bytesToBigIntLE(chunk));\n}\n\n/**\n * Splits a Uint8Array into smaller chunks of the specified size.\n * This function is useful for processing large arrays in manageable segments.\n *\n * @param array - The Uint8Array to be split into chunks.\n * @param chunkSize - The size of each chunk.\n * @returns An array of Uint8Array chunks.\n * @group Implementation\n * @category Serialization\n */\nfunction chunkUint8Array(array: Uint8Array, chunkSize: number): Uint8Array[] {\n const result: Uint8Array[] = [];\n for (let i = 0; i < array.length; i += chunkSize) {\n result.push(array.subarray(i, i + chunkSize));\n }\n return result;\n}\n\n/**\n * Converts a little-endian byte array into a BigInt.\n * This function is useful for interpreting byte data as a numerical value in a way that respects the little-endian format.\n *\n * @param bytes - The byte array to convert.\n * @returns The resulting BigInt representation of the byte array.\n * @group Implementation\n * @category Serialization\n */\nexport function bytesToBigIntLE(bytes: Uint8Array): bigint {\n let result = BigInt(0);\n for (let i = bytes.length - 1; i >= 0; i -= 1) {\n result = (result << BigInt(8)) | BigInt(bytes[i]);\n }\n return result;\n}\n\n/**\n * Converts a bigint value into a little-endian byte array of a specified length.\n * This function is useful for representing large integers in a byte format, which is often required for cryptographic operations\n * or binary data manipulation.\n *\n * @param value - The number to convert into bytes.\n * @param length - The desired length of the resulting byte array.\n * @returns A Uint8Array containing the little-endian representation of the bigint value.\n * @group Implementation\n * @category Serialization\n */\nexport function bigIntToBytesLE(value: bigint | number, length: number): Uint8Array {\n let val = BigInt(value);\n const bytes = new Uint8Array(length);\n for (let i = 0; i < length; i += 1) {\n bytes[i] = Number(val & BigInt(0xff));\n val >>= BigInt(8);\n }\n return bytes;\n}\n\n/**\n * Pads the input Uint8Array with zeros to achieve the specified size.\n * This function is useful for ensuring that a byte array meets a required length for further processing.\n *\n * @param inputArray - The Uint8Array to be padded.\n * @param paddedSize - The desired size of the padded array, which must be greater than or equal to the input array size.\n * @throws Error if paddedSize is less than the length of inputArray.\n * @group Implementation\n * @category Serialization\n */\nfunction padUint8ArrayWithZeros(inputArray: Uint8Array, paddedSize: number): Uint8Array {\n if (paddedSize < inputArray.length) {\n throw new Error(\"Padded size must be greater than or equal to the input array size.\");\n }\n\n // Create a new Uint8Array with the padded size\n const paddedArray = new Uint8Array(paddedSize);\n\n // Copy the content of the input array to the new array\n paddedArray.set(inputArray);\n\n // Fill the remaining space with zeros\n for (let i = inputArray.length; i < paddedSize; i += 1) {\n paddedArray[i] = 0;\n }\n\n return paddedArray;\n}\n\n/**\n * Hashes up to 16 scalar elements via the Poseidon hashing algorithm.\n * Each element must be scalar fields of the BN254 elliptic curve group.\n *\n * @param inputs - An array of elements to be hashed, which can be of type number, bigint, or string.\n * @returns bigint - The result of the hash.\n * @throws Error - Throws an error if the input length exceeds the maximum allowed.\n * @group Implementation\n * @category Serialization\n */\nexport function poseidonHash(inputs: (number | bigint | string)[]): bigint {\n if (inputs.length > numInputsToPoseidonFunc.length) {\n throw new Error(\n `Unable to hash input of length ${inputs.length}. Max input length is ${numInputsToPoseidonFunc.length}`,\n );\n }\n return numInputsToPoseidonFunc[inputs.length - 1](inputs);\n}\n"],"mappings":"AACA,OACE,aAAAA,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,MACK,gB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AAM,OAAQG,GAAKF,EACrCC,EAAO,KAAKF,EAAM,SAASG,EAAGA,EAAIF,CAAS,CAAC,EAE9C,OAAOC,CACT,CAWO,SAASH,EAAgBV,EAA2B,CACzD,IAAIa,EAAS,OAAO,CAAC,EACrB,QAASC,EAAId,EAAM,OAAS,EAAGc,GAAK,EAAGA,GAAK,EAC1CD,EAAUA,GAAU,OAAO,CAAC,EAAK,OAAOb,EAAMc,CAAC,CAAC,EAElD,OAAOD,CACT,CAaO,SAASE,EAAgBC,EAAwBC,EAA4B,CAClF,IAAIC,EAAM,OAAOF,CAAK,EAChBhB,EAAQ,IAAI,WAAWiB,CAAM,EACnC,QAASH,EAAI,EAAGA,EAAIG,EAAQH,GAAK,EAC/Bd,EAAMc,CAAC,EAAI,OAAOI,EAAM,OAAO,GAAI,CAAC,EACpCA,IAAQ,OAAO,CAAC,EAElB,OAAOlB,CACT,CAYA,SAASM,EAAuBa,EAAwBC,EAAgC,CACtF,GAAIA,EAAaD,EAAW,OAC1B,MAAM,IAAI,MAAM,oEAAoE,EAItF,IAAME,EAAc,IAAI,WAAWD,CAAU,EAG7CC,EAAY,IAAIF,CAAU,EAG1B,QAASL,EAAIK,EAAW,OAAQL,EAAIM,EAAYN,GAAK,EACnDO,EAAYP,CAAC,EAAI,EAGnB,OAAOO,CACT,CAYO,SAASlB,EAAamB,EAA8C,CACzE,GAAIA,EAAO,OAAS/B,EAAwB,OAC1C,MAAM,IAAI,MACR,kCAAkC+B,EAAO,MAAM,0BAA0B/B,EAAwB,MAAM,EACzG,EAEF,OAAOA,EAAwB+B,EAAO,OAAS,CAAC,EAAEA,CAAM,CAC1D","names":["poseidon1","poseidon2","poseidon3","poseidon4","poseidon5","poseidon6","poseidon7","poseidon8","poseidon9","poseidon10","poseidon11","poseidon12","poseidon13","poseidon14","poseidon15","poseidon16","numInputsToPoseidonFunc","BYTES_PACKED_PER_SCALAR","MAX_NUM_INPUT_SCALARS","MAX_NUM_INPUT_BYTES","hashStrToField","str","maxSizeBytes","strBytes","hashBytesWithLen","bytes","packed","padAndPackBytesWithLen","poseidonHash","padAndPackBytesNoLen","paddedStrBytes","padUint8ArrayWithZeros","packBytes","chunkUint8Array","chunk","bytesToBigIntLE","array","chunkSize","result","i","bigIntToBytesLE","value","length","val","inputArray","paddedSize","paddedArray","inputs"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-HGLO5LDS.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as c}from"./chunk-RGKRCZ36.mjs";import{sha3_256 as n}from"@noble/hashes/sha3";var d=(e,r)=>{let t=e.bcsToBytes(),s=typeof r=="string"?Buffer.from(r,"utf8"):r,o=new Uint8Array([...t,...s,254]);return new c(n(o))},f=(e,r)=>{let t=e.bcsToBytes(),s=typeof r=="string"?Buffer.from(r,"utf8"):r,o=new Uint8Array([...t,...s,255]);return new c(n(o))},a=(e,r,t)=>{let s=`${r}::${t}`;return d(e,s)};export{d as a,f as b,a as c};
|
|
2
|
-
//# sourceMappingURL=chunk-HNBVYE3N.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/account/utils/address.ts"],"sourcesContent":["import { sha3_256 } from \"@noble/hashes/sha3\";\nimport { AccountAddress } from \"../../accountAddress\";\nimport { DeriveScheme } from \"../../../types\";\n\n/**\n * Creates an object address from creator address and seed\n *\n * @param creatorAddress The object creator account address\n * @param seed The seed in either Uint8Array | string type\n *\n * @returns The object account address\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport const createObjectAddress = (creatorAddress: AccountAddress, seed: Uint8Array | string): AccountAddress => {\n const creatorBytes = creatorAddress.bcsToBytes();\n\n const seedBytes = typeof seed === \"string\" ? Buffer.from(seed, \"utf8\") : seed;\n\n const bytes = new Uint8Array([...creatorBytes, ...seedBytes, DeriveScheme.DeriveObjectAddressFromSeed]);\n\n return new AccountAddress(sha3_256(bytes));\n};\n\n/**\n * Creates a resource address from creator address and seed\n *\n * @param creatorAddress The creator account address\n * @param seed The seed in either Uint8Array | string type\n *\n * @returns The resource account address\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport const createResourceAddress = (creatorAddress: AccountAddress, seed: Uint8Array | string): AccountAddress => {\n const creatorBytes = creatorAddress.bcsToBytes();\n\n const seedBytes = typeof seed === \"string\" ? Buffer.from(seed, \"utf8\") : seed;\n\n const bytes = new Uint8Array([...creatorBytes, ...seedBytes, DeriveScheme.DeriveResourceAccountAddress]);\n\n return new AccountAddress(sha3_256(bytes));\n};\n\n/**\n * Creates a token object address from creator address, collection name and token name\n *\n * @param creatorAddress The token creator account address\n * @param collectionName The collection name\n * @param tokenName The token name\n *\n * @returns The token account address\n * @group Implementation\n * @category Account (On-Chain Model)\n */\nexport const createTokenAddress = (\n creatorAddress: AccountAddress,\n collectionName: string,\n tokenName: string,\n): AccountAddress => {\n const seed = `${collectionName}::${tokenName}`;\n return createObjectAddress(creatorAddress, seed);\n};\n"],"mappings":"yCAAA,OAAS,YAAAA,MAAgB,qBAclB,IAAMC,EAAsB,CAACC,EAAgCC,IAA8C,CAChH,IAAMC,EAAeF,EAAe,WAAW,EAEzCG,EAAY,OAAOF,GAAS,SAAW,OAAO,KAAKA,EAAM,MAAM,EAAIA,EAEnEG,EAAQ,IAAI,WAAW,CAAC,GAAGF,EAAc,GAAGC,KAAmD,CAAC,EAEtG,OAAO,IAAIE,EAAeC,EAASF,CAAK,CAAC,CAC3C,EAYaG,EAAwB,CAACP,EAAgCC,IAA8C,CAClH,IAAMC,EAAeF,EAAe,WAAW,EAEzCG,EAAY,OAAOF,GAAS,SAAW,OAAO,KAAKA,EAAM,MAAM,EAAIA,EAEnEG,EAAQ,IAAI,WAAW,CAAC,GAAGF,EAAc,GAAGC,KAAoD,CAAC,EAEvG,OAAO,IAAIE,EAAeC,EAASF,CAAK,CAAC,CAC3C,EAaaI,EAAqB,CAChCR,EACAS,EACAC,IACmB,CACnB,IAAMT,EAAO,GAAGQ,CAAc,KAAKC,CAAS,GAC5C,OAAOX,EAAoBC,EAAgBC,CAAI,CACjD","names":["sha3_256","createObjectAddress","creatorAddress","seed","creatorBytes","seedBytes","bytes","AccountAddress","sha3_256","createResourceAddress","createTokenAddress","collectionName","tokenName"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as l}from"./chunk-2PASUPUO.mjs";import{a as h}from"./chunk-WCMW2L3P.mjs";import{a as x}from"./chunk-WSR5EBJM.mjs";import{a as m}from"./chunk-FGFLPH5K.mjs";import{b as c}from"./chunk-EBMEXURY.mjs";import{b as n}from"./chunk-STY74NUA.mjs";import{sha3_256 as A}from"@noble/hashes/sha3";import{p256 as y}from"@noble/curves/nist.js";var s=class s extends x{constructor(e){super();this.keyType="secp256r1";let r=n.fromHexInput(e),i=r.toUint8Array().length;if(i!==s.LENGTH&&i!==s.COMPRESSED_LENGTH)throw new Error(`PublicKey length should be ${s.LENGTH} or ${s.COMPRESSED_LENGTH}, received ${i}`);if(i===s.COMPRESSED_LENGTH){let u=y.ProjectivePoint.fromHex(r.toUint8Array());this.key=n.fromHexInput(u.toRawBytes(!1))}else this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}bcsToBytes(){let e=new c;return this.serialize(e),e.toUint8Array()}verifySignature(e){let{message:r,signature:i}=e,u=n.fromHexInput(r).toUint8Array(),f=A(u),U=i.toUint8Array();return y.verify(U,f,this.toUint8Array())}async verifySignatureAsync(e){return this.verifySignature({message:e.message,signature:e.signature})}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new s(r)}static load(e){let r=e.deserializeBytes();return new s(r)}static isInstance(e){return"key"in e&&e.key?.data?.length===s.LENGTH&&"keyType"in e&&e.keyType==="secp256r1"}authKey(){let e=new c;return e.serializeU32AsUleb128(2),e.serializeFixedBytes(this.bcsToBytes()),m.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}};s.LENGTH=65,s.COMPRESSED_LENGTH=33;var g=s,a=class a extends l{constructor(t,e){super();let r=l.parseHexInput(t,"secp256r1",e),i=r.toUint8Array().length;if(i!==a.LENGTH)throw new Error(`PrivateKey length should be ${a.LENGTH}, received ${i}`);this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return l.formatPrivateKey(this.key.toString(),"secp256r1")}toHexString(){return this.key.toString()}sign(t){let e=n.fromHexInput(t),r=A(e.toUint8Array()),i=y.sign(r,this.key.toUint8Array());return new p(i.toCompactRawBytes())}serialize(t){t.serializeBytes(this.toUint8Array())}static deserialize(t){let e=t.deserializeBytes();return new a(e)}static generate(){let t=y.utils.randomPrivateKey();return new a(t)}publicKey(){let t=y.getPublicKey(this.key.toUint8Array(),!1);return new g(t)}};a.LENGTH=32;var H=a,S=class d extends h{constructor(t,e,r){super(),this.signature=n.fromHexInput(t),this.authenticatorData=n.fromHexInput(e),this.clientDataJSON=n.fromHexInput(r)}toUint8Array(){return this.signature.toUint8Array()}serialize(t){t.serializeU32AsUleb128(0),t.serializeBytes(this.signature.toUint8Array()),t.serializeBytes(this.authenticatorData.toUint8Array()),t.serializeBytes(this.clientDataJSON.toUint8Array())}bcsToBytes(){let t=new c;return this.serialize(t),t.toUint8Array()}bcsToHex(){return n.fromHexInput(this.bcsToBytes())}toStringWithoutPrefix(){return n.fromHexInput(this.bcsToBytes()).toString()}static deserialize(t){let e=t.deserializeUleb128AsU32();if(e!==0)throw new Error(`Invalid id for WebAuthnSignature: ${e}`);let r=t.deserializeBytes(),i=t.deserializeBytes(),u=t.deserializeBytes();return new d(r,i,u)}},o=class o extends h{constructor(t){super();let e=n.fromHexInput(t),r=e.toUint8Array().length;if(r!==o.LENGTH)throw new Error(`Signature length should be ${o.LENGTH}, received ${r}`);let i=y.Signature.fromCompact(e.toUint8Array()).normalizeS().toCompactRawBytes();this.data=n.fromHexInput(i)}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(t){t.serializeBytes(this.data.toUint8Array())}static deserialize(t){let e=t.deserializeBytes();return new o(e)}};o.LENGTH=64;var p=o;export{g as a,H as b,S as c,p as d};
|
|
2
|
-
//# sourceMappingURL=chunk-I7XT6L7S.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/crypto/secp256r1.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { sha3_256 } from \"@noble/hashes/sha3\";\nimport { p256 } from \"@noble/curves/nist.js\";\nimport { Deserializer, Serializer } from \"../../bcs\";\nimport { Hex } from \"../hex\";\nimport {\n HexInput,\n PrivateKeyVariants,\n SigningScheme as AuthenticationKeyScheme,\n AnyPublicKeyVariant,\n} from \"../../types\";\nimport { PublicKey, VerifySignatureAsyncArgs } from \"./publicKey\";\nimport { PrivateKey } from \"./privateKey\";\nimport { Signature } from \"./signature\";\nimport { AuthenticationKey } from \"../authenticationKey\";\n\n/**\n * Represents a Secp256r1 ECDSA public key.\n *\n * @extends PublicKey\n * @property LENGTH - The length of the Secp256r1 public key in bytes.\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256r1PublicKey extends PublicKey {\n // Secp256r1 ecdsa public keys contain a prefix indicating compression and two 32-byte coordinates.\n static readonly LENGTH: number = 65;\n\n // If it's compressed, it is only 33 bytes\n static readonly COMPRESSED_LENGTH: number = 33;\n\n // Hex value of the public key\n private readonly key: Hex;\n\n // Identifier to distinguish from Secp256k1PublicKey\n public readonly keyType: string = \"secp256r1\";\n\n /**\n * Create a new PublicKey instance from a HexInput, which can be a string or Uint8Array.\n * This constructor validates the length of the provided public key data.\n *\n * @param hexInput - A HexInput (string or Uint8Array) representing the public key data.\n * @throws Error if the length of the public key data is not equal to Secp256r1PublicKey.LENGTH or COMPRESSED_LENGTH.\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput) {\n super();\n\n const hex = Hex.fromHexInput(hexInput);\n const keyLength = hex.toUint8Array().length;\n if (keyLength !== Secp256r1PublicKey.LENGTH && keyLength !== Secp256r1PublicKey.COMPRESSED_LENGTH) {\n throw new Error(\n `PublicKey length should be ${Secp256r1PublicKey.LENGTH} or ${Secp256r1PublicKey.COMPRESSED_LENGTH}, received ${keyLength}`,\n );\n }\n\n if (keyLength === Secp256r1PublicKey.COMPRESSED_LENGTH) {\n const point = p256.ProjectivePoint.fromHex(hex.toUint8Array());\n this.key = Hex.fromHexInput(point.toRawBytes(false));\n } else {\n this.key = hex;\n }\n }\n\n /**\n * Get the data as a Uint8Array representation.\n *\n * @returns Uint8Array representation of the data.\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.key.toUint8Array();\n }\n\n /**\n * Get the public key as a hex string with the 0x prefix.\n *\n * @returns string representation of the public key.\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return this.key.toString();\n }\n\n /**\n * Converts the public key to BCS (Binary Canonical Serialization) bytes.\n * This function serializes the public key data into a byte array format suitable for transmission or storage.\n *\n * @returns Uint8Array representation of the serialized public key.\n * @group Implementation\n * @category Serialization\n */\n bcsToBytes() {\n const serializer = new Serializer();\n this.serialize(serializer);\n return serializer.toUint8Array();\n }\n\n /**\n * Verifies a Secp256r1 signature against the public key.\n *\n * This function checks the validity of a signature for a given message.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify against the public key.\n * @group Implementation\n * @category Serialization\n */\n verifySignature(args: { message: HexInput; signature: Signature }): boolean {\n const { message, signature } = args;\n\n const msgHex = Hex.fromHexInput(message).toUint8Array();\n const sha3Message = sha3_256(msgHex);\n const rawSignature = signature.toUint8Array();\n\n return p256.verify(rawSignature, sha3Message, this.toUint8Array());\n }\n\n /**\n * Note: Secp256r1Signatures can be verified synchronously.\n *\n * Verifies the provided signature against the given message.\n * This function helps ensure the integrity and authenticity of the message by confirming that the signature is valid.\n *\n * @param args - The arguments for signature verification.\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify, which must be an instance of Secp256r1Signature.\n * @returns A boolean indicating whether the signature is valid for the given message.\n * @group Implementation\n * @category Serialization\n */\n async verifySignatureAsync(args: VerifySignatureAsyncArgs): Promise<boolean> {\n return this.verifySignature({ message: args.message, signature: args.signature });\n }\n\n /**\n * Serializes the data into a byte array using the provided serializer.\n * This function is essential for converting data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to convert the data.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.key.toUint8Array());\n }\n\n /**\n * Deserializes a Secp256r1PublicKey from the provided deserializer.\n * This function allows you to reconstruct a Secp256r1PublicKey object from its serialized byte representation.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): Secp256r1PublicKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256r1PublicKey(bytes);\n }\n\n /**\n * Loads a Secp256r1PublicKey from the provided deserializer.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static load(deserializer: Deserializer): Secp256r1PublicKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256r1PublicKey(bytes);\n }\n\n /**\n * Determines if the provided public key is a valid instance of a Secp256r1 public key.\n * This function checks for the presence of a \"key\" property and validates the length of the key data.\n *\n * @param publicKey - The public key to validate.\n * @returns A boolean indicating whether the public key is a valid Secp256r1 public key.\n * @group Implementation\n * @category Serialization\n */\n static isInstance(publicKey: PublicKey): publicKey is Secp256r1PublicKey {\n return (\n \"key\" in publicKey &&\n (publicKey.key as any)?.data?.length === Secp256r1PublicKey.LENGTH &&\n \"keyType\" in publicKey &&\n (publicKey as any).keyType === \"secp256r1\"\n );\n }\n\n /**\n * Generates an authentication key from the public key using the Secp256r1 scheme.\n * This function is essential for creating a secure authentication key that can be used for further cryptographic operations.\n *\n * @returns {AuthenticationKey} The generated authentication key.\n * @group Implementation\n * @category Serialization\n */\n authKey(): AuthenticationKey {\n const serializer = new Serializer();\n serializer.serializeU32AsUleb128(AnyPublicKeyVariant.Secp256r1);\n serializer.serializeFixedBytes(this.bcsToBytes());\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.SingleKey,\n input: serializer.toUint8Array(),\n });\n }\n}\n\n/**\n * Represents a Secp256r1 ECDSA private key, providing functionality to create, sign messages,\n * derive public keys, and serialize/deserialize the key.\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256r1PrivateKey extends PrivateKey {\n /**\n * Length of Secp256r1 ecdsa private key\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The private key bytes\n * @private\n * @group Implementation\n * @category Serialization\n */\n private readonly key: Hex;\n\n /**\n * Create a new PrivateKey instance from a Uint8Array or String.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @param hexInput A HexInput (string or Uint8Array)\n * @param strict If true, private key must AIP-80 compliant.\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput, strict?: boolean) {\n super();\n\n const privateKeyHex = PrivateKey.parseHexInput(hexInput, PrivateKeyVariants.Secp256r1, strict);\n const keyLength = privateKeyHex.toUint8Array().length;\n if (keyLength !== Secp256r1PrivateKey.LENGTH) {\n throw new Error(`PrivateKey length should be ${Secp256r1PrivateKey.LENGTH}, received ${keyLength}`);\n }\n\n this.key = privateKeyHex;\n }\n\n /**\n * Get the private key in bytes (Uint8Array).\n *\n * @returns\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.key.toUint8Array();\n }\n\n /**\n * Get the private key as a string representation.\n *\n * @returns string representation of the private key\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return PrivateKey.formatPrivateKey(this.key.toString(), PrivateKeyVariants.Secp256r1);\n }\n\n /**\n * Get the private key as a hex string with the 0x prefix.\n *\n * @returns string representation of the private key.\n */\n toHexString(): string {\n return this.key.toString();\n }\n\n /**\n * Sign the given message with the private key.\n * This function generates a cryptographic signature for the provided message.\n *\n * @param message - A message in HexInput format to be signed.\n * @returns Signature - The generated signature for the provided message.\n * @group Implementation\n * @category Serialization\n */\n sign(message: HexInput): Secp256r1Signature {\n const msgHex = Hex.fromHexInput(message);\n const sha3Message = sha3_256(msgHex.toUint8Array());\n const signature = p256.sign(sha3Message, this.key.toUint8Array());\n return new Secp256r1Signature(signature.toCompactRawBytes());\n }\n\n /**\n * Serializes the data into a byte array using the provided serializer.\n * This function is essential for converting data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to convert the data.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.toUint8Array());\n }\n\n /**\n * Deserializes a Secp256r1PrivateKey from the provided deserializer.\n * This function allows you to reconstruct a Secp256r1PrivateKey object from its serialized byte representation.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): Secp256r1PrivateKey {\n const bytes = deserializer.deserializeBytes();\n return new Secp256r1PrivateKey(bytes);\n }\n\n /**\n * Generate a new random private key.\n *\n * @returns Secp256r1PrivateKey - A newly generated Secp256r1 private key.\n * @group Implementation\n * @category Serialization\n */\n static generate(): Secp256r1PrivateKey {\n const hexInput = p256.utils.randomPrivateKey();\n return new Secp256r1PrivateKey(hexInput);\n }\n\n /**\n * Derive the Secp256r1PublicKey from this private key.\n *\n * @returns Secp256r1PublicKey The derived public key.\n * @group Implementation\n * @category Serialization\n */\n publicKey(): Secp256r1PublicKey {\n const bytes = p256.getPublicKey(this.key.toUint8Array(), false);\n return new Secp256r1PublicKey(bytes);\n }\n}\n\nexport class WebAuthnSignature extends Signature {\n signature: Hex;\n\n authenticatorData: Hex;\n\n clientDataJSON: Hex;\n\n constructor(signature: HexInput, authenticatorData: HexInput, clientDataJSON: HexInput) {\n super();\n this.signature = Hex.fromHexInput(signature);\n this.authenticatorData = Hex.fromHexInput(authenticatorData);\n this.clientDataJSON = Hex.fromHexInput(clientDataJSON);\n }\n\n toUint8Array() {\n return this.signature.toUint8Array();\n }\n\n serialize(serializer: Serializer) {\n serializer.serializeU32AsUleb128(0);\n serializer.serializeBytes(this.signature.toUint8Array());\n serializer.serializeBytes(this.authenticatorData.toUint8Array());\n serializer.serializeBytes(this.clientDataJSON.toUint8Array());\n }\n\n bcsToBytes() {\n const serializer = new Serializer();\n this.serialize(serializer);\n return serializer.toUint8Array();\n }\n\n bcsToHex() {\n return Hex.fromHexInput(this.bcsToBytes());\n }\n\n toStringWithoutPrefix() {\n return Hex.fromHexInput(this.bcsToBytes()).toString();\n }\n\n static deserialize(deserializer: Deserializer) {\n const id = deserializer.deserializeUleb128AsU32();\n if (id !== 0) {\n throw new Error(`Invalid id for WebAuthnSignature: ${id}`);\n }\n const signature = deserializer.deserializeBytes();\n const authenticatorData = deserializer.deserializeBytes();\n const clientDataJSON = deserializer.deserializeBytes();\n return new WebAuthnSignature(signature, authenticatorData, clientDataJSON);\n }\n}\n\n/**\n * Represents a signature of a message signed using a Secp256r1 ECDSA private key.\n *\n * @group Implementation\n * @category Serialization\n */\nexport class Secp256r1Signature extends Signature {\n /**\n * Secp256r1 ecdsa signatures are 256-bit.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH = 64;\n\n /**\n * The signature bytes\n * @private\n * @group Implementation\n * @category Serialization\n */\n private readonly data: Hex;\n\n /**\n * Create a new Signature instance from a Uint8Array or String.\n *\n * @param hexInput A HexInput (string or Uint8Array)\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput) {\n super();\n\n const hex = Hex.fromHexInput(hexInput);\n const signatureLength = hex.toUint8Array().length;\n if (signatureLength !== Secp256r1Signature.LENGTH) {\n throw new Error(`Signature length should be ${Secp256r1Signature.LENGTH}, received ${signatureLength}`);\n }\n const signature = p256.Signature.fromCompact(hex.toUint8Array()).normalizeS().toCompactRawBytes();\n this.data = Hex.fromHexInput(signature);\n }\n\n /**\n * Get the signature in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the signature\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data.toUint8Array();\n }\n\n /**\n * Get the signature as a hex string with the 0x prefix.\n *\n * @returns string representation of the signature\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return this.data.toString();\n }\n\n /**\n * Serializes the data into a byte array using the provided serializer.\n * This function is essential for converting data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to convert the data.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.data.toUint8Array());\n }\n\n /**\n * Deserializes a Secp256r1Signature from the provided deserializer.\n * This function allows you to reconstruct a Secp256r1Signature object from its serialized byte representation.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): Secp256r1Signature {\n const hex = deserializer.deserializeBytes();\n return new Secp256r1Signature(hex);\n }\n}\n"],"mappings":"sPAGA,OAAS,YAAAA,MAAgB,qBACzB,OAAS,QAAAC,MAAY,wBAsBd,IAAMC,EAAN,MAAMA,UAA2BC,CAAU,CAsBhD,YAAYC,EAAoB,CAC9B,MAAM,EAZR,KAAgB,QAAkB,YAchC,IAAMC,EAAMC,EAAI,aAAaF,CAAQ,EAC/BG,EAAYF,EAAI,aAAa,EAAE,OACrC,GAAIE,IAAcL,EAAmB,QAAUK,IAAcL,EAAmB,kBAC9E,MAAM,IAAI,MACR,8BAA8BA,EAAmB,MAAM,OAAOA,EAAmB,iBAAiB,cAAcK,CAAS,EAC3H,EAGF,GAAIA,IAAcL,EAAmB,kBAAmB,CACtD,IAAMM,EAAQC,EAAK,gBAAgB,QAAQJ,EAAI,aAAa,CAAC,EAC7D,KAAK,IAAMC,EAAI,aAAaE,EAAM,WAAW,EAAK,CAAC,CACrD,MACE,KAAK,IAAMH,CAEf,CASA,cAA2B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,aAAa,CAChC,CASA,UAAmB,CACjB,OAAO,KAAK,KAAK,SAAS,CAC5B,CAUA,UAAUJ,EAA8B,CACtCA,EAAW,eAAe,KAAK,KAAK,aAAa,CAAC,CACpD,CAUA,OAAO,YAAYS,EAAgD,CACjE,IAAMd,EAAMc,EAAa,iBAAiB,EAC1C,OAAO,IAAIiB,EAAmB/B,CAAG,CACnC,CACF,EAjFa+B,EAMK,OAAS,GANpB,IAAMR,EAANQ","names":["sha3_256","p256","_Secp256r1PublicKey","PublicKey","hexInput","hex","Hex","keyLength","point","p256","serializer","Serializer","args","message","signature","msgHex","sha3Message","sha3_256","rawSignature","deserializer","bytes","publicKey","AuthenticationKey","Secp256r1PublicKey","_Secp256r1PrivateKey","PrivateKey","strict","privateKeyHex","Secp256r1Signature","Secp256r1PrivateKey","WebAuthnSignature","_WebAuthnSignature","Signature","authenticatorData","clientDataJSON","id","_Secp256r1Signature","signatureLength"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/common.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This error is used to explain why parsing failed.\n * @group Implementation\n * @category Serialization\n */\nexport class ParsingError<T> extends Error {\n /**\n * This provides a programmatic way to access why parsing failed. Downstream devs\n * might want to use this to build their own error messages if the default error\n * messages are not suitable for their use case. This should be an enum.\n * @group Implementation\n * @category Serialization\n */\n public invalidReason: T;\n\n /**\n * Creates an instance of the error with a specified message and invalid reason.\n *\n * @param message The error message that describes the issue.\n * @param invalidReason The reason why the input is considered invalid.\n * @group Implementation\n * @category Serialization\n */\n constructor(message: string, invalidReason: T) {\n super(message);\n this.invalidReason = invalidReason;\n }\n}\n\n/**\n * Whereas ParsingError is thrown when parsing fails, e.g. in a fromString function,\n * this type is returned from \"defensive\" functions like isValid.\n * @group Implementation\n * @category Serialization\n */\nexport type ParsingResult<T> = {\n /**\n * True if valid, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n valid: boolean;\n\n /**\n * If valid is false, this will be a code explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReason?: T;\n\n /**\n * If valid is false, this will be a string explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReasonMessage?: string;\n};\n"],"mappings":"AAQO,IAAMA,EAAN,cAA8B,KAAM,CAkBzC,YAAYC,EAAiBC,EAAkB,CAC7C,MAAMD,CAAO,EACb,KAAK,cAAgBC,CACvB,CACF","names":["ParsingError","message","invalidReason"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as d}from"./chunk-YOZBVVKL.mjs";import{b as s}from"./chunk-7EER7GWV.mjs";import{b as r}from"./chunk-RGKRCZ36.mjs";async function g(o){let{aptosConfig:e,accountAddress:t}=o,{data:n}=await s({aptosConfig:e,originMethod:"getInfo",path:`accounts/${r.from(t).toString()}`});return n}async function f(o){return o.options?.ledgerVersion!==void 0?c(o):d(async()=>c(o),`module-${o.accountAddress}-${o.moduleName}`,1e3*60*5)()}async function c(o){let{aptosConfig:e,accountAddress:t,moduleName:n,options:i}=o,{data:u}=await s({aptosConfig:e,originMethod:"getModule",path:`accounts/${r.from(t).toString()}/module/${n}`,params:{ledger_version:i?.ledgerVersion}});return u}export{g as a,f as b};
|
|
2
|
-
//# sourceMappingURL=chunk-JABP65XD.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/internal/utils/utils.ts"],"sourcesContent":["import { AccountAddress, AccountAddressInput } from \"../../core/accountAddress\";\nimport { MoveModuleBytecode, LedgerVersionArg, AccountData } from \"../../types/types\";\nimport { AptosConfig } from \"../../api/aptosConfig\";\nimport { getAptosFullNode } from \"../../client\";\nimport { memoizeAsync } from \"../../utils/memoize\";\n\n/**\n * Retrieves account information for a specified account address.\n *\n * @param args - The arguments for retrieving account information.\n * @param args.aptosConfig - The configuration object for Aptos.\n * @param args.accountAddress - The address of the account to retrieve information for.\n * @group Implementation\n */\nexport async function getInfo(args: {\n aptosConfig: AptosConfig;\n accountAddress: AccountAddressInput;\n}): Promise<AccountData> {\n const { aptosConfig, accountAddress } = args;\n const { data } = await getAptosFullNode<{}, AccountData>({\n aptosConfig,\n originMethod: \"getInfo\",\n path: `accounts/${AccountAddress.from(accountAddress).toString()}`,\n });\n return data;\n}\n\n/**\n * Queries for a move module given an account address and module name.\n * This function can help you retrieve the module's ABI and other relevant information.\n *\n * @param args - The arguments for retrieving the module.\n * @param args.aptosConfig - The configuration for the Aptos client.\n * @param args.accountAddress - The account address in hex-encoded 32 byte format.\n * @param args.moduleName - The name of the module to retrieve.\n * @param args.options - Optional parameters for the request.\n * @param args.options.ledgerVersion - Specifies the ledger version of transactions. By default, the latest version will be used.\n * @returns The move module.\n * @group Implementation\n */\nexport async function getModule(args: {\n aptosConfig: AptosConfig;\n accountAddress: AccountAddressInput;\n moduleName: string;\n options?: LedgerVersionArg;\n}): Promise<MoveModuleBytecode> {\n // We don't memoize the account module by ledger version, as it's not a common use case, this would be handled\n // by the developer directly\n if (args.options?.ledgerVersion !== undefined) {\n return getModuleInner(args);\n }\n\n return memoizeAsync(\n async () => getModuleInner(args),\n `module-${args.accountAddress}-${args.moduleName}`,\n 1000 * 60 * 5, // 5 minutes\n )();\n}\n\n/**\n * Retrieves the bytecode of a specified module from a given account address.\n *\n * @param args - The parameters for retrieving the module bytecode.\n * @param args.aptosConfig - The configuration for connecting to the Aptos network.\n * @param args.accountAddress - The address of the account from which to retrieve the module.\n * @param args.moduleName - The name of the module to retrieve.\n * @param args.options - Optional parameters for specifying the ledger version.\n * @param args.options.ledgerVersion - The specific ledger version to query.\n * @group Implementation\n */\nasync function getModuleInner(args: {\n aptosConfig: AptosConfig;\n accountAddress: AccountAddressInput;\n moduleName: string;\n options?: LedgerVersionArg;\n}): Promise<MoveModuleBytecode> {\n const { aptosConfig, accountAddress, moduleName, options } = args;\n\n const { data } = await getAptosFullNode<{}, MoveModuleBytecode>({\n aptosConfig,\n originMethod: \"getModule\",\n path: `accounts/${AccountAddress.from(accountAddress).toString()}/module/${moduleName}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n return data;\n}\n"],"mappings":"2HAcA,eAAsBA,EAAQC,EAGL,CACvB,GAAM,CAAE,YAAAC,EAAa,eAAAC,CAAe,EAAIF,EAClC,CAAE,KAAAG,CAAK,EAAI,MAAMC,EAAkC,CACvD,YAAAH,EACA,aAAc,UACd,KAAM,YAAYI,EAAe,KAAKH,CAAc,EAAE,SAAS,CAAC,EAClE,CAAC,EACD,OAAOC,CACT,CAeA,eAAsBG,EAAUN,EAKA,CAG9B,OAAIA,EAAK,SAAS,gBAAkB,OAC3BO,EAAeP,CAAI,EAGrBQ,EACL,SAAYD,EAAeP,CAAI,EAC/B,UAAUA,EAAK,cAAc,IAAIA,EAAK,UAAU,GAChD,IAAO,GAAK,CACd,EAAE,CACJ,CAaA,eAAeO,EAAeP,EAKE,CAC9B,GAAM,CAAE,YAAAC,EAAa,eAAAC,EAAgB,WAAAO,EAAY,QAAAC,CAAQ,EAAIV,EAEvD,CAAE,KAAAG,CAAK,EAAI,MAAMC,EAAyC,CAC9D,YAAAH,EACA,aAAc,YACd,KAAM,YAAYI,EAAe,KAAKH,CAAc,EAAE,SAAS,CAAC,WAAWO,CAAU,GACrF,OAAQ,CAAE,eAAgBC,GAAS,aAAc,CACnD,CAAC,EACD,OAAOP,CACT","names":["getInfo","args","aptosConfig","accountAddress","data","getAptosFullNode","AccountAddress","getModule","getModuleInner","memoizeAsync","moduleName","options"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|