@sravankumar02/sdk-core 1.0.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/LICENSE +11 -0
- package/README.md +94 -0
- package/out/abi/argSerializer.d.ts +45 -0
- package/out/abi/argSerializer.js +171 -0
- package/out/abi/argSerializer.js.map +1 -0
- package/out/abi/argumentErrorContext.d.ts +12 -0
- package/out/abi/argumentErrorContext.js +34 -0
- package/out/abi/argumentErrorContext.js.map +1 -0
- package/out/abi/code.d.ts +23 -0
- package/out/abi/code.js +41 -0
- package/out/abi/code.js.map +1 -0
- package/out/abi/codec/address.d.ts +24 -0
- package/out/abi/codec/address.js +41 -0
- package/out/abi/codec/address.js.map +1 -0
- package/out/abi/codec/arrayVec.d.ts +11 -0
- package/out/abi/codec/arrayVec.js +39 -0
- package/out/abi/codec/arrayVec.js.map +1 -0
- package/out/abi/codec/binary.d.ts +30 -0
- package/out/abi/codec/binary.js +134 -0
- package/out/abi/codec/binary.js.map +1 -0
- package/out/abi/codec/binaryCodecUtils.d.ts +6 -0
- package/out/abi/codec/binaryCodecUtils.js +35 -0
- package/out/abi/codec/binaryCodecUtils.js.map +1 -0
- package/out/abi/codec/boolean.d.ts +13 -0
- package/out/abi/codec/boolean.js +57 -0
- package/out/abi/codec/boolean.js.map +1 -0
- package/out/abi/codec/bytes.d.ts +11 -0
- package/out/abi/codec/bytes.js +30 -0
- package/out/abi/codec/bytes.js.map +1 -0
- package/out/abi/codec/codemetadata.d.ts +8 -0
- package/out/abi/codec/codemetadata.js +23 -0
- package/out/abi/codec/codemetadata.js.map +1 -0
- package/out/abi/codec/constants.d.ts +1 -0
- package/out/abi/codec/constants.js +5 -0
- package/out/abi/codec/constants.js.map +1 -0
- package/out/abi/codec/enum.d.ts +13 -0
- package/out/abi/codec/enum.js +49 -0
- package/out/abi/codec/enum.js.map +1 -0
- package/out/abi/codec/explicit-enum.d.ts +10 -0
- package/out/abi/codec/explicit-enum.js +30 -0
- package/out/abi/codec/explicit-enum.js.map +1 -0
- package/out/abi/codec/fields.d.ts +9 -0
- package/out/abi/codec/fields.js +31 -0
- package/out/abi/codec/fields.js.map +1 -0
- package/out/abi/codec/h256.d.ts +24 -0
- package/out/abi/codec/h256.js +39 -0
- package/out/abi/codec/h256.js.map +1 -0
- package/out/abi/codec/index.d.ts +6 -0
- package/out/abi/codec/index.js +19 -0
- package/out/abi/codec/index.js.map +1 -0
- package/out/abi/codec/list.d.ts +14 -0
- package/out/abi/codec/list.js +67 -0
- package/out/abi/codec/list.js.map +1 -0
- package/out/abi/codec/managedDecimal.d.ts +11 -0
- package/out/abi/codec/managedDecimal.js +53 -0
- package/out/abi/codec/managedDecimal.js.map +1 -0
- package/out/abi/codec/managedDecimalSigned.d.ts +11 -0
- package/out/abi/codec/managedDecimalSigned.js +53 -0
- package/out/abi/codec/managedDecimalSigned.js.map +1 -0
- package/out/abi/codec/nothing.d.ts +8 -0
- package/out/abi/codec/nothing.js +20 -0
- package/out/abi/codec/nothing.js.map +1 -0
- package/out/abi/codec/numerical.d.ts +13 -0
- package/out/abi/codec/numerical.js +122 -0
- package/out/abi/codec/numerical.js.map +1 -0
- package/out/abi/codec/option.d.ts +14 -0
- package/out/abi/codec/option.js +66 -0
- package/out/abi/codec/option.js.map +1 -0
- package/out/abi/codec/primitive.d.ts +20 -0
- package/out/abi/codec/primitive.js +81 -0
- package/out/abi/codec/primitive.js.map +1 -0
- package/out/abi/codec/string.d.ts +9 -0
- package/out/abi/codec/string.js +28 -0
- package/out/abi/codec/string.js.map +1 -0
- package/out/abi/codec/struct.d.ts +11 -0
- package/out/abi/codec/struct.js +30 -0
- package/out/abi/codec/struct.js.map +1 -0
- package/out/abi/codec/tokenIdentifier.d.ts +9 -0
- package/out/abi/codec/tokenIdentifier.js +28 -0
- package/out/abi/codec/tokenIdentifier.js.map +1 -0
- package/out/abi/codec/tuple.d.ts +11 -0
- package/out/abi/codec/tuple.js +23 -0
- package/out/abi/codec/tuple.js.map +1 -0
- package/out/abi/codec/utils.d.ts +20 -0
- package/out/abi/codec/utils.js +69 -0
- package/out/abi/codec/utils.js.map +1 -0
- package/out/abi/function.d.ts +24 -0
- package/out/abi/function.js +56 -0
- package/out/abi/function.js.map +1 -0
- package/out/abi/index.d.ts +12 -0
- package/out/abi/index.js +25 -0
- package/out/abi/index.js.map +1 -0
- package/out/abi/interaction.d.ts +67 -0
- package/out/abi/interaction.js +146 -0
- package/out/abi/interaction.js.map +1 -0
- package/out/abi/interface.d.ts +85 -0
- package/out/abi/interface.js +3 -0
- package/out/abi/interface.js.map +1 -0
- package/out/abi/nativeSerializer.d.ts +27 -0
- package/out/abi/nativeSerializer.js +343 -0
- package/out/abi/nativeSerializer.js.map +1 -0
- package/out/abi/query.d.ts +18 -0
- package/out/abi/query.js +19 -0
- package/out/abi/query.js.map +1 -0
- package/out/abi/returnCode.d.ts +26 -0
- package/out/abi/returnCode.js +45 -0
- package/out/abi/returnCode.js.map +1 -0
- package/out/abi/smartContract.d.ts +74 -0
- package/out/abi/smartContract.js +208 -0
- package/out/abi/smartContract.js.map +1 -0
- package/out/abi/typeFormula.d.ts +7 -0
- package/out/abi/typeFormula.js +20 -0
- package/out/abi/typeFormula.js.map +1 -0
- package/out/abi/typeFormulaParser.d.ts +14 -0
- package/out/abi/typeFormulaParser.js +126 -0
- package/out/abi/typeFormulaParser.js.map +1 -0
- package/out/abi/typesystem/abi.d.ts +64 -0
- package/out/abi/typesystem/abi.js +208 -0
- package/out/abi/typesystem/abi.js.map +1 -0
- package/out/abi/typesystem/address.d.ts +23 -0
- package/out/abi/typesystem/address.js +41 -0
- package/out/abi/typesystem/address.js.map +1 -0
- package/out/abi/typesystem/algebraic.d.ts +24 -0
- package/out/abi/typesystem/algebraic.js +59 -0
- package/out/abi/typesystem/algebraic.js.map +1 -0
- package/out/abi/typesystem/boolean.d.ts +24 -0
- package/out/abi/typesystem/boolean.js +46 -0
- package/out/abi/typesystem/boolean.js.map +1 -0
- package/out/abi/typesystem/bytes.d.ts +28 -0
- package/out/abi/typesystem/bytes.js +58 -0
- package/out/abi/typesystem/bytes.js.map +1 -0
- package/out/abi/typesystem/codeMetadata.d.ts +11 -0
- package/out/abi/typesystem/codeMetadata.js +24 -0
- package/out/abi/typesystem/codeMetadata.js.map +1 -0
- package/out/abi/typesystem/collections.d.ts +9 -0
- package/out/abi/typesystem/collections.js +32 -0
- package/out/abi/typesystem/collections.js.map +1 -0
- package/out/abi/typesystem/composite.d.ts +16 -0
- package/out/abi/typesystem/composite.js +53 -0
- package/out/abi/typesystem/composite.js.map +1 -0
- package/out/abi/typesystem/endpoint.d.ts +41 -0
- package/out/abi/typesystem/endpoint.js +78 -0
- package/out/abi/typesystem/endpoint.js.map +1 -0
- package/out/abi/typesystem/enum.d.ts +51 -0
- package/out/abi/typesystem/enum.js +137 -0
- package/out/abi/typesystem/enum.js.map +1 -0
- package/out/abi/typesystem/event.d.ts +25 -0
- package/out/abi/typesystem/event.js +36 -0
- package/out/abi/typesystem/event.js.map +1 -0
- package/out/abi/typesystem/explicit-enum.d.ts +33 -0
- package/out/abi/typesystem/explicit-enum.js +63 -0
- package/out/abi/typesystem/explicit-enum.js.map +1 -0
- package/out/abi/typesystem/factory.d.ts +4 -0
- package/out/abi/typesystem/factory.js +19 -0
- package/out/abi/typesystem/factory.js.map +1 -0
- package/out/abi/typesystem/fields.d.ts +24 -0
- package/out/abi/typesystem/fields.js +90 -0
- package/out/abi/typesystem/fields.js.map +1 -0
- package/out/abi/typesystem/generic.d.ts +47 -0
- package/out/abi/typesystem/generic.js +120 -0
- package/out/abi/typesystem/generic.js.map +1 -0
- package/out/abi/typesystem/genericArray.d.ts +17 -0
- package/out/abi/typesystem/genericArray.js +44 -0
- package/out/abi/typesystem/genericArray.js.map +1 -0
- package/out/abi/typesystem/h256.d.ts +18 -0
- package/out/abi/typesystem/h256.js +35 -0
- package/out/abi/typesystem/h256.js.map +1 -0
- package/out/abi/typesystem/index.d.ts +33 -0
- package/out/abi/typesystem/index.js +46 -0
- package/out/abi/typesystem/index.js.map +1 -0
- package/out/abi/typesystem/managedDecimal.d.ts +26 -0
- package/out/abi/typesystem/managedDecimal.js +62 -0
- package/out/abi/typesystem/managedDecimal.js.map +1 -0
- package/out/abi/typesystem/managedDecimalSigned.d.ts +26 -0
- package/out/abi/typesystem/managedDecimalSigned.js +62 -0
- package/out/abi/typesystem/managedDecimalSigned.js.map +1 -0
- package/out/abi/typesystem/matchers.d.ts +51 -0
- package/out/abi/typesystem/matchers.js +185 -0
- package/out/abi/typesystem/matchers.js.map +1 -0
- package/out/abi/typesystem/nothing.d.ts +13 -0
- package/out/abi/typesystem/nothing.js +31 -0
- package/out/abi/typesystem/nothing.js.map +1 -0
- package/out/abi/typesystem/numerical.d.ts +130 -0
- package/out/abi/typesystem/numerical.js +286 -0
- package/out/abi/typesystem/numerical.js.map +1 -0
- package/out/abi/typesystem/string.d.ts +26 -0
- package/out/abi/typesystem/string.js +51 -0
- package/out/abi/typesystem/string.js.map +1 -0
- package/out/abi/typesystem/struct.d.ts +30 -0
- package/out/abi/typesystem/struct.js +78 -0
- package/out/abi/typesystem/struct.js.map +1 -0
- package/out/abi/typesystem/tokenIdentifier.d.ts +21 -0
- package/out/abi/typesystem/tokenIdentifier.js +51 -0
- package/out/abi/typesystem/tokenIdentifier.js.map +1 -0
- package/out/abi/typesystem/tuple.d.ts +16 -0
- package/out/abi/typesystem/tuple.js +71 -0
- package/out/abi/typesystem/tuple.js.map +1 -0
- package/out/abi/typesystem/typeExpressionParser.d.ts +8 -0
- package/out/abi/typesystem/typeExpressionParser.js +30 -0
- package/out/abi/typesystem/typeExpressionParser.js.map +1 -0
- package/out/abi/typesystem/typeMapper.d.ts +20 -0
- package/out/abi/typesystem/typeMapper.js +215 -0
- package/out/abi/typesystem/typeMapper.js.map +1 -0
- package/out/abi/typesystem/types.d.ts +129 -0
- package/out/abi/typesystem/types.js +285 -0
- package/out/abi/typesystem/types.js.map +1 -0
- package/out/abi/typesystem/variadic.d.ts +35 -0
- package/out/abi/typesystem/variadic.js +81 -0
- package/out/abi/typesystem/variadic.js.map +1 -0
- package/out/accountManagement/accountController.d.ts +18 -0
- package/out/accountManagement/accountController.js +54 -0
- package/out/accountManagement/accountController.js.map +1 -0
- package/out/accountManagement/accountTransactionsFactory.d.ts +27 -0
- package/out/accountManagement/accountTransactionsFactory.js +78 -0
- package/out/accountManagement/accountTransactionsFactory.js.map +1 -0
- package/out/accountManagement/index.d.ts +3 -0
- package/out/accountManagement/index.js +16 -0
- package/out/accountManagement/index.js.map +1 -0
- package/out/accountManagement/resources.d.ts +8 -0
- package/out/accountManagement/resources.js +3 -0
- package/out/accountManagement/resources.js.map +1 -0
- package/out/accounts/account.d.ts +94 -0
- package/out/accounts/account.js +154 -0
- package/out/accounts/account.js.map +1 -0
- package/out/accounts/index.d.ts +1 -0
- package/out/accounts/index.js +14 -0
- package/out/accounts/index.js.map +1 -0
- package/out/core/address.d.ts +105 -0
- package/out/core/address.js +313 -0
- package/out/core/address.js.map +1 -0
- package/out/core/asyncTimer.d.ts +27 -0
- package/out/core/asyncTimer.js +91 -0
- package/out/core/asyncTimer.js.map +1 -0
- package/out/core/baseController.d.ts +16 -0
- package/out/core/baseController.js +34 -0
- package/out/core/baseController.js.map +1 -0
- package/out/core/codeMetadata.d.ts +74 -0
- package/out/core/codeMetadata.js +146 -0
- package/out/core/codeMetadata.js.map +1 -0
- package/out/core/compatibility.d.ts +10 -0
- package/out/core/compatibility.js +22 -0
- package/out/core/compatibility.js.map +1 -0
- package/out/core/config.d.ts +15 -0
- package/out/core/config.js +20 -0
- package/out/core/config.js.map +1 -0
- package/out/core/constants.d.ts +28 -0
- package/out/core/constants.js +32 -0
- package/out/core/constants.js.map +1 -0
- package/out/core/errors.d.ts +279 -0
- package/out/core/errors.js +437 -0
- package/out/core/errors.js.map +1 -0
- package/out/core/globals.d.ts +0 -0
- package/out/core/globals.js +5 -0
- package/out/core/globals.js.map +1 -0
- package/out/core/index.d.ts +21 -0
- package/out/core/index.js +35 -0
- package/out/core/index.js.map +1 -0
- package/out/core/interfaces.d.ts +40 -0
- package/out/core/interfaces.js +3 -0
- package/out/core/interfaces.js.map +1 -0
- package/out/core/logger.d.ts +17 -0
- package/out/core/logger.js +50 -0
- package/out/core/logger.js.map +1 -0
- package/out/core/message.d.ts +57 -0
- package/out/core/message.js +71 -0
- package/out/core/message.js.map +1 -0
- package/out/core/networkParams.d.ts +57 -0
- package/out/core/networkParams.js +112 -0
- package/out/core/networkParams.js.map +1 -0
- package/out/core/reflection.d.ts +1 -0
- package/out/core/reflection.js +14 -0
- package/out/core/reflection.js.map +1 -0
- package/out/core/signature.d.ts +17 -0
- package/out/core/signature.js +82 -0
- package/out/core/signature.js.map +1 -0
- package/out/core/smartContractQuery.d.ts +35 -0
- package/out/core/smartContractQuery.js +34 -0
- package/out/core/smartContractQuery.js.map +1 -0
- package/out/core/tokenTransfersDataBuilder.d.ts +10 -0
- package/out/core/tokenTransfersDataBuilder.js +44 -0
- package/out/core/tokenTransfersDataBuilder.js.map +1 -0
- package/out/core/tokens.d.ts +130 -0
- package/out/core/tokens.js +287 -0
- package/out/core/tokens.js.map +1 -0
- package/out/core/transaction.d.ts +263 -0
- package/out/core/transaction.js +323 -0
- package/out/core/transaction.js.map +1 -0
- package/out/core/transactionBuilder.d.ts +32 -0
- package/out/core/transactionBuilder.js +45 -0
- package/out/core/transactionBuilder.js.map +1 -0
- package/out/core/transactionComputer.d.ts +51 -0
- package/out/core/transactionComputer.js +163 -0
- package/out/core/transactionComputer.js.map +1 -0
- package/out/core/transactionEvents.d.ts +17 -0
- package/out/core/transactionEvents.js +27 -0
- package/out/core/transactionEvents.js.map +1 -0
- package/out/core/transactionLogs.d.ts +11 -0
- package/out/core/transactionLogs.js +38 -0
- package/out/core/transactionLogs.js.map +1 -0
- package/out/core/transactionOnNetwork.d.ts +40 -0
- package/out/core/transactionOnNetwork.js +164 -0
- package/out/core/transactionOnNetwork.js.map +1 -0
- package/out/core/transactionStatus.d.ts +45 -0
- package/out/core/transactionStatus.js +71 -0
- package/out/core/transactionStatus.js.map +1 -0
- package/out/core/transactionWatcher.d.ts +48 -0
- package/out/core/transactionWatcher.js +148 -0
- package/out/core/transactionWatcher.js.map +1 -0
- package/out/core/transactionsFactoryConfig.d.ts +54 -0
- package/out/core/transactionsFactoryConfig.js +66 -0
- package/out/core/transactionsFactoryConfig.js.map +1 -0
- package/out/core/utils.codec.d.ts +8 -0
- package/out/core/utils.codec.js +75 -0
- package/out/core/utils.codec.js.map +1 -0
- package/out/core/utils.d.ts +20 -0
- package/out/core/utils.js +86 -0
- package/out/core/utils.js.map +1 -0
- package/out/delegation/delegationController.d.ts +37 -0
- package/out/delegation/delegationController.js +215 -0
- package/out/delegation/delegationController.js.map +1 -0
- package/out/delegation/delegationTransactionsFactory.d.ts +48 -0
- package/out/delegation/delegationTransactionsFactory.js +311 -0
- package/out/delegation/delegationTransactionsFactory.js.map +1 -0
- package/out/delegation/delegationTransactionsOutcomeParser.d.ts +10 -0
- package/out/delegation/delegationTransactionsOutcomeParser.js +35 -0
- package/out/delegation/delegationTransactionsOutcomeParser.js.map +1 -0
- package/out/delegation/index.d.ts +4 -0
- package/out/delegation/index.js +17 -0
- package/out/delegation/index.js.map +1 -0
- package/out/delegation/resources.d.ts +38 -0
- package/out/delegation/resources.js +3 -0
- package/out/delegation/resources.js.map +1 -0
- package/out/entrypoints/config.d.ts +29 -0
- package/out/entrypoints/config.js +36 -0
- package/out/entrypoints/config.js.map +1 -0
- package/out/entrypoints/entrypoints.d.ts +92 -0
- package/out/entrypoints/entrypoints.js +203 -0
- package/out/entrypoints/entrypoints.js.map +1 -0
- package/out/entrypoints/index.d.ts +2 -0
- package/out/entrypoints/index.js +15 -0
- package/out/entrypoints/index.js.map +1 -0
- package/out/governance/governanceController.d.ts +33 -0
- package/out/governance/governanceController.js +205 -0
- package/out/governance/governanceController.js.map +1 -0
- package/out/governance/governanceTransactionsFactory.d.ts +16 -0
- package/out/governance/governanceTransactionsFactory.js +99 -0
- package/out/governance/governanceTransactionsFactory.js.map +1 -0
- package/out/governance/governanceTransactionsOutcomeParser.d.ts +15 -0
- package/out/governance/governanceTransactionsOutcomeParser.js +99 -0
- package/out/governance/governanceTransactionsOutcomeParser.js.map +1 -0
- package/out/governance/index.d.ts +4 -0
- package/out/governance/index.js +17 -0
- package/out/governance/index.js.map +1 -0
- package/out/governance/resources.d.ts +82 -0
- package/out/governance/resources.js +11 -0
- package/out/governance/resources.js.map +1 -0
- package/out/index.d.ts +19 -0
- package/out/index.js +32 -0
- package/out/index.js.map +1 -0
- package/out/multisig/index.d.ts +3 -0
- package/out/multisig/index.js +16 -0
- package/out/multisig/index.js.map +1 -0
- package/out/multisig/multisigController.d.ts +221 -0
- package/out/multisig/multisigController.js +540 -0
- package/out/multisig/multisigController.js.map +1 -0
- package/out/multisig/multisigTransactionsFactory.d.ts +110 -0
- package/out/multisig/multisigTransactionsFactory.js +355 -0
- package/out/multisig/multisigTransactionsFactory.js.map +1 -0
- package/out/multisig/multisigTransactionsOutcomeParser.d.ts +31 -0
- package/out/multisig/multisigTransactionsOutcomeParser.js +41 -0
- package/out/multisig/multisigTransactionsOutcomeParser.js.map +1 -0
- package/out/multisig/proposeTransferExecuteContractInput.d.ts +32 -0
- package/out/multisig/proposeTransferExecuteContractInput.js +65 -0
- package/out/multisig/proposeTransferExecuteContractInput.js.map +1 -0
- package/out/multisig/resources.d.ts +182 -0
- package/out/multisig/resources.js +125 -0
- package/out/multisig/resources.js.map +1 -0
- package/out/networkProviders/accountAwaiter.d.ts +35 -0
- package/out/networkProviders/accountAwaiter.js +67 -0
- package/out/networkProviders/accountAwaiter.js.map +1 -0
- package/out/networkProviders/accounts.d.ts +55 -0
- package/out/networkProviders/accounts.js +154 -0
- package/out/networkProviders/accounts.js.map +1 -0
- package/out/networkProviders/apiNetworkProvider.d.ts +48 -0
- package/out/networkProviders/apiNetworkProvider.js +235 -0
- package/out/networkProviders/apiNetworkProvider.js.map +1 -0
- package/out/networkProviders/blocks.d.ts +48 -0
- package/out/networkProviders/blocks.js +76 -0
- package/out/networkProviders/blocks.js.map +1 -0
- package/out/networkProviders/config.d.ts +6 -0
- package/out/networkProviders/config.js +18 -0
- package/out/networkProviders/config.js.map +1 -0
- package/out/networkProviders/constants.d.ts +9 -0
- package/out/networkProviders/constants.js +16 -0
- package/out/networkProviders/constants.js.map +1 -0
- package/out/networkProviders/contractQueryRequest.d.ts +6 -0
- package/out/networkProviders/contractQueryRequest.js +20 -0
- package/out/networkProviders/contractQueryRequest.js.map +1 -0
- package/out/networkProviders/index.d.ts +11 -0
- package/out/networkProviders/index.js +28 -0
- package/out/networkProviders/index.js.map +1 -0
- package/out/networkProviders/interface.d.ts +110 -0
- package/out/networkProviders/interface.js +3 -0
- package/out/networkProviders/interface.js.map +1 -0
- package/out/networkProviders/networkConfig.d.ts +48 -0
- package/out/networkProviders/networkConfig.js +41 -0
- package/out/networkProviders/networkConfig.js.map +1 -0
- package/out/networkProviders/networkProviderConfig.d.ts +4 -0
- package/out/networkProviders/networkProviderConfig.js +3 -0
- package/out/networkProviders/networkProviderConfig.js.map +1 -0
- package/out/networkProviders/networkStatus.d.ts +31 -0
- package/out/networkProviders/networkStatus.js +31 -0
- package/out/networkProviders/networkStatus.js.map +1 -0
- package/out/networkProviders/proxyNetworkProvider.d.ts +51 -0
- package/out/networkProviders/proxyNetworkProvider.js +261 -0
- package/out/networkProviders/proxyNetworkProvider.js.map +1 -0
- package/out/networkProviders/resources.d.ts +12 -0
- package/out/networkProviders/resources.js +29 -0
- package/out/networkProviders/resources.js.map +1 -0
- package/out/networkProviders/tokenDefinitions.d.ts +49 -0
- package/out/networkProviders/tokenDefinitions.js +152 -0
- package/out/networkProviders/tokenDefinitions.js.map +1 -0
- package/out/networkProviders/tokens.d.ts +40 -0
- package/out/networkProviders/tokens.js +106 -0
- package/out/networkProviders/tokens.js.map +1 -0
- package/out/networkProviders/userAgent.d.ts +2 -0
- package/out/networkProviders/userAgent.js +30 -0
- package/out/networkProviders/userAgent.js.map +1 -0
- package/out/proto/compiled.d.ts +2 -0
- package/out/proto/compiled.js +719 -0
- package/out/proto/compiled.js.map +1 -0
- package/out/proto/index.d.ts +5 -0
- package/out/proto/index.js +18 -0
- package/out/proto/index.js.map +1 -0
- package/out/proto/serializer.d.ts +22 -0
- package/out/proto/serializer.js +114 -0
- package/out/proto/serializer.js.map +1 -0
- package/out/smartContracts/index.d.ts +4 -0
- package/out/smartContracts/index.js +17 -0
- package/out/smartContracts/index.js.map +1 -0
- package/out/smartContracts/resources.d.ts +38 -0
- package/out/smartContracts/resources.js +3 -0
- package/out/smartContracts/resources.js.map +1 -0
- package/out/smartContracts/smartContractController.d.ts +32 -0
- package/out/smartContracts/smartContractController.js +128 -0
- package/out/smartContracts/smartContractController.js.map +1 -0
- package/out/smartContracts/smartContractTransactionsFactory.d.ts +42 -0
- package/out/smartContracts/smartContractTransactionsFactory.js +165 -0
- package/out/smartContracts/smartContractTransactionsFactory.js.map +1 -0
- package/out/smartContracts/smartContractTransactionsOutcomeParser.d.ts +28 -0
- package/out/smartContracts/smartContractTransactionsOutcomeParser.js +189 -0
- package/out/smartContracts/smartContractTransactionsOutcomeParser.js.map +1 -0
- package/out/tokenManagement/index.d.ts +4 -0
- package/out/tokenManagement/index.js +17 -0
- package/out/tokenManagement/index.js.map +1 -0
- package/out/tokenManagement/resources.d.ts +220 -0
- package/out/tokenManagement/resources.js +3 -0
- package/out/tokenManagement/resources.js.map +1 -0
- package/out/tokenManagement/tokenManagementController.d.ts +108 -0
- package/out/tokenManagement/tokenManagementController.js +582 -0
- package/out/tokenManagement/tokenManagementController.js.map +1 -0
- package/out/tokenManagement/tokenManagementTransactionsFactory.d.ts +82 -0
- package/out/tokenManagement/tokenManagementTransactionsFactory.js +684 -0
- package/out/tokenManagement/tokenManagementTransactionsFactory.js.map +1 -0
- package/out/tokenManagement/tokenManagementTransactionsOutcomeParser.d.ts +109 -0
- package/out/tokenManagement/tokenManagementTransactionsOutcomeParser.js +356 -0
- package/out/tokenManagement/tokenManagementTransactionsOutcomeParser.js.map +1 -0
- package/out/tokenOperations/codec.d.ts +7 -0
- package/out/tokenOperations/codec.js +55 -0
- package/out/tokenOperations/codec.js.map +1 -0
- package/out/transactionsOutcomeParsers/index.d.ts +4 -0
- package/out/transactionsOutcomeParsers/index.js +17 -0
- package/out/transactionsOutcomeParsers/index.js.map +1 -0
- package/out/transactionsOutcomeParsers/resources.d.ts +23 -0
- package/out/transactionsOutcomeParsers/resources.js +48 -0
- package/out/transactionsOutcomeParsers/resources.js.map +1 -0
- package/out/transactionsOutcomeParsers/transactionEventsParser.d.ts +16 -0
- package/out/transactionsOutcomeParsers/transactionEventsParser.js +48 -0
- package/out/transactionsOutcomeParsers/transactionEventsParser.js.map +1 -0
- package/out/transfers/index.d.ts +3 -0
- package/out/transfers/index.js +16 -0
- package/out/transfers/index.js.map +1 -0
- package/out/transfers/resources.d.ts +17 -0
- package/out/transfers/resources.js +3 -0
- package/out/transfers/resources.js.map +1 -0
- package/out/transfers/transferTransactionsFactory.d.ts +32 -0
- package/out/transfers/transferTransactionsFactory.js +131 -0
- package/out/transfers/transferTransactionsFactory.js.map +1 -0
- package/out/transfers/transfersControllers.d.ts +11 -0
- package/out/transfers/transfersControllers.js +43 -0
- package/out/transfers/transfersControllers.js.map +1 -0
- package/out/wallet/assertions.d.ts +3 -0
- package/out/wallet/assertions.js +12 -0
- package/out/wallet/assertions.js.map +1 -0
- package/out/wallet/crypto/constants.d.ts +6 -0
- package/out/wallet/crypto/constants.js +11 -0
- package/out/wallet/crypto/constants.js.map +1 -0
- package/out/wallet/crypto/decryptor.d.ts +5 -0
- package/out/wallet/crypto/decryptor.js +29 -0
- package/out/wallet/crypto/decryptor.js.map +1 -0
- package/out/wallet/crypto/derivationParams.d.ts +23 -0
- package/out/wallet/crypto/derivationParams.js +38 -0
- package/out/wallet/crypto/derivationParams.js.map +1 -0
- package/out/wallet/crypto/encryptedData.d.ts +15 -0
- package/out/wallet/crypto/encryptedData.js +52 -0
- package/out/wallet/crypto/encryptedData.js.map +1 -0
- package/out/wallet/crypto/encryptor.d.ts +14 -0
- package/out/wallet/crypto/encryptor.js +39 -0
- package/out/wallet/crypto/encryptor.js.map +1 -0
- package/out/wallet/crypto/index.d.ts +7 -0
- package/out/wallet/crypto/index.js +20 -0
- package/out/wallet/crypto/index.js.map +1 -0
- package/out/wallet/crypto/pubkeyDecryptor.d.ts +6 -0
- package/out/wallet/crypto/pubkeyDecryptor.js +38 -0
- package/out/wallet/crypto/pubkeyDecryptor.js.map +1 -0
- package/out/wallet/crypto/pubkeyEncryptor.d.ts +6 -0
- package/out/wallet/crypto/pubkeyEncryptor.js +54 -0
- package/out/wallet/crypto/pubkeyEncryptor.js.map +1 -0
- package/out/wallet/crypto/randomness.d.ts +7 -0
- package/out/wallet/crypto/randomness.js +15 -0
- package/out/wallet/crypto/randomness.js.map +1 -0
- package/out/wallet/crypto/x25519EncryptedData.d.ts +15 -0
- package/out/wallet/crypto/x25519EncryptedData.js +37 -0
- package/out/wallet/crypto/x25519EncryptedData.js.map +1 -0
- package/out/wallet/index.d.ts +11 -0
- package/out/wallet/index.js +24 -0
- package/out/wallet/index.js.map +1 -0
- package/out/wallet/keypair.d.ts +12 -0
- package/out/wallet/keypair.js +32 -0
- package/out/wallet/keypair.js.map +1 -0
- package/out/wallet/mnemonic.d.ts +13 -0
- package/out/wallet/mnemonic.js +74 -0
- package/out/wallet/mnemonic.js.map +1 -0
- package/out/wallet/pem.d.ts +8 -0
- package/out/wallet/pem.js +60 -0
- package/out/wallet/pem.js.map +1 -0
- package/out/wallet/pemEntry.d.ts +10 -0
- package/out/wallet/pemEntry.js +73 -0
- package/out/wallet/pemEntry.js.map +1 -0
- package/out/wallet/userKeys.d.ts +23 -0
- package/out/wallet/userKeys.js +99 -0
- package/out/wallet/userKeys.js.map +1 -0
- package/out/wallet/userPem.d.ts +15 -0
- package/out/wallet/userPem.js +51 -0
- package/out/wallet/userPem.js.map +1 -0
- package/out/wallet/userSigner.d.ts +16 -0
- package/out/wallet/userSigner.js +41 -0
- package/out/wallet/userSigner.js.map +1 -0
- package/out/wallet/userVerifier.d.ts +18 -0
- package/out/wallet/userVerifier.js +27 -0
- package/out/wallet/userVerifier.js.map +1 -0
- package/out/wallet/userWallet.d.ts +54 -0
- package/out/wallet/userWallet.js +206 -0
- package/out/wallet/userWallet.js.map +1 -0
- package/out/wallet/validatorKeys.d.ts +26 -0
- package/out/wallet/validatorKeys.js +77 -0
- package/out/wallet/validatorKeys.js.map +1 -0
- package/out/wallet/validatorSigner.d.ts +10 -0
- package/out/wallet/validatorSigner.js +25 -0
- package/out/wallet/validatorSigner.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PemEntry = void 0;
|
|
4
|
+
class PemEntry {
|
|
5
|
+
constructor(label, message) {
|
|
6
|
+
this.label = label;
|
|
7
|
+
this.message = message;
|
|
8
|
+
}
|
|
9
|
+
static fromTextAll(pemText) {
|
|
10
|
+
const lines = PemEntry.cleanLines(pemText.split("\n"));
|
|
11
|
+
// Group PEM entries into blocks of header, content, and footer
|
|
12
|
+
const blocks = PemEntry.groupBlocks(lines);
|
|
13
|
+
return blocks.map((block) => {
|
|
14
|
+
// Extract label from the header line
|
|
15
|
+
const header = block[0];
|
|
16
|
+
const footer = block[block.length - 1];
|
|
17
|
+
if (!header.startsWith("-----BEGIN PRIVATE KEY for") || !footer.startsWith("-----END PRIVATE KEY for")) {
|
|
18
|
+
throw new Error("Invalid PEM format");
|
|
19
|
+
}
|
|
20
|
+
const label = header.replace("-----BEGIN PRIVATE KEY for", "").replace("-----", "").trim();
|
|
21
|
+
// Join all content lines between header and footer
|
|
22
|
+
const base64Message = block.slice(1, block.length - 1).join("");
|
|
23
|
+
// Decode Base64 to Uint8Array
|
|
24
|
+
const messageBytes = Buffer.from(Buffer.from(base64Message, "base64").toString(), "hex");
|
|
25
|
+
return new PemEntry(label, messageBytes);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
static groupBlocks(lines) {
|
|
29
|
+
const blocks = [];
|
|
30
|
+
let currentBlock = [];
|
|
31
|
+
for (const line of lines) {
|
|
32
|
+
if (line.startsWith("-----BEGIN PRIVATE KEY for")) {
|
|
33
|
+
if (currentBlock.length > 0) {
|
|
34
|
+
blocks.push(currentBlock);
|
|
35
|
+
}
|
|
36
|
+
currentBlock = [line]; // Start a new block
|
|
37
|
+
}
|
|
38
|
+
else if (line.startsWith("-----END PRIVATE KEY for")) {
|
|
39
|
+
currentBlock.push(line);
|
|
40
|
+
blocks.push(currentBlock); // Finalize the current block
|
|
41
|
+
currentBlock = [];
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
currentBlock.push(line); // Add content to the current block
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (currentBlock.length > 0) {
|
|
48
|
+
throw new Error("Invalid PEM format: Missing END line for a block");
|
|
49
|
+
}
|
|
50
|
+
return blocks;
|
|
51
|
+
}
|
|
52
|
+
toText() {
|
|
53
|
+
const header = `-----BEGIN PRIVATE KEY for ${this.label}-----`;
|
|
54
|
+
const footer = `-----END PRIVATE KEY for ${this.label}-----`;
|
|
55
|
+
const messageHex = Buffer.from(this.message).toString("hex");
|
|
56
|
+
const messageBase64 = Buffer.from(messageHex, "utf-8").toString("base64");
|
|
57
|
+
const payloadLines = PemEntry.wrapText(messageBase64, 64);
|
|
58
|
+
const payload = payloadLines.join("\n");
|
|
59
|
+
return [header, payload, footer].join("\n");
|
|
60
|
+
}
|
|
61
|
+
static cleanLines(lines) {
|
|
62
|
+
return lines.map((line) => line.trim()).filter((line) => line.length > 0);
|
|
63
|
+
}
|
|
64
|
+
static wrapText(text, width) {
|
|
65
|
+
const lines = [];
|
|
66
|
+
for (let i = 0; i < text.length; i += width) {
|
|
67
|
+
lines.push(text.slice(i, i + width));
|
|
68
|
+
}
|
|
69
|
+
return lines;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.PemEntry = PemEntry;
|
|
73
|
+
//# sourceMappingURL=pemEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pemEntry.js","sourceRoot":"","sources":["../../src/wallet/pemEntry.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAQ;IAIjB,YAAY,KAAa,EAAE,OAAmB;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,OAAe;QAC9B,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QAEvD,+DAA+D;QAC/D,MAAM,MAAM,GAAe,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEvD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACxB,qCAAqC;YACrC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACxB,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACvC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,4BAA4B,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,0BAA0B,CAAC,EAAE;gBACpG,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;aACzC;YAED,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,4BAA4B,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YAE3F,mDAAmD;YACnD,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAA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
|
|
5
|
+
export declare class UserSecretKey {
|
|
6
|
+
private readonly buffer;
|
|
7
|
+
constructor(buffer: Uint8Array);
|
|
8
|
+
static fromString(value: string): UserSecretKey;
|
|
9
|
+
static fromPem(text: string, index?: number): UserSecretKey;
|
|
10
|
+
generatePublicKey(): UserPublicKey;
|
|
11
|
+
static generate(): UserSecretKey;
|
|
12
|
+
sign(message: Uint8Array): Uint8Array;
|
|
13
|
+
hex(): string;
|
|
14
|
+
valueOf(): Buffer;
|
|
15
|
+
}
|
|
16
|
+
export declare class UserPublicKey {
|
|
17
|
+
private readonly buffer;
|
|
18
|
+
constructor(buffer: Uint8Array);
|
|
19
|
+
verify(data: Buffer | Uint8Array, signature: Buffer | Uint8Array): Promise<boolean>;
|
|
20
|
+
hex(): string;
|
|
21
|
+
toAddress(hrp?: string): Address;
|
|
22
|
+
valueOf(): Buffer;
|
|
23
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.UserPublicKey = exports.UserSecretKey = exports.USER_PUBKEY_LENGTH = exports.USER_SEED_LENGTH = void 0;
|
|
26
|
+
const ed = __importStar(require("@noble/ed25519"));
|
|
27
|
+
const sha512_1 = require("@noble/hashes/sha512");
|
|
28
|
+
const tweetnacl_1 = __importDefault(require("tweetnacl"));
|
|
29
|
+
const address_1 = require("../core/address");
|
|
30
|
+
const assertions_1 = require("./assertions");
|
|
31
|
+
const pem_1 = require("./pem");
|
|
32
|
+
exports.USER_SEED_LENGTH = 32;
|
|
33
|
+
exports.USER_PUBKEY_LENGTH = 32;
|
|
34
|
+
// See: https://github.com/paulmillr/noble-ed25519
|
|
35
|
+
// In a future version of sdk-wallet, we'll switch to using the async functions of noble-ed25519.
|
|
36
|
+
ed.utils.sha512Sync = (...m) => sha512_1.sha512(ed.utils.concatBytes(...m));
|
|
37
|
+
class UserSecretKey {
|
|
38
|
+
constructor(buffer) {
|
|
39
|
+
assertions_1.guardLength(buffer, exports.USER_SEED_LENGTH);
|
|
40
|
+
this.buffer = Buffer.from(buffer);
|
|
41
|
+
}
|
|
42
|
+
static fromString(value) {
|
|
43
|
+
assertions_1.guardLength(value, exports.USER_SEED_LENGTH * 2);
|
|
44
|
+
const buffer = Buffer.from(value, "hex");
|
|
45
|
+
return new UserSecretKey(buffer);
|
|
46
|
+
}
|
|
47
|
+
static fromPem(text, index = 0) {
|
|
48
|
+
return pem_1.parseUserKey(text, index);
|
|
49
|
+
}
|
|
50
|
+
generatePublicKey() {
|
|
51
|
+
const buffer = ed.sync.getPublicKey(new Uint8Array(this.buffer));
|
|
52
|
+
return new UserPublicKey(buffer);
|
|
53
|
+
}
|
|
54
|
+
static generate() {
|
|
55
|
+
// Generates a new signing keypair
|
|
56
|
+
const keyPair = tweetnacl_1.default.sign.keyPair();
|
|
57
|
+
// Extract only the private key part
|
|
58
|
+
const secretKey = keyPair.secretKey.subarray(0, exports.USER_SEED_LENGTH);
|
|
59
|
+
return new UserSecretKey(secretKey);
|
|
60
|
+
}
|
|
61
|
+
sign(message) {
|
|
62
|
+
const signature = ed.sync.sign(new Uint8Array(message), new Uint8Array(this.buffer));
|
|
63
|
+
return signature;
|
|
64
|
+
}
|
|
65
|
+
hex() {
|
|
66
|
+
return this.buffer.toString("hex");
|
|
67
|
+
}
|
|
68
|
+
valueOf() {
|
|
69
|
+
return this.buffer;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.UserSecretKey = UserSecretKey;
|
|
73
|
+
class UserPublicKey {
|
|
74
|
+
constructor(buffer) {
|
|
75
|
+
assertions_1.guardLength(buffer, exports.USER_PUBKEY_LENGTH);
|
|
76
|
+
this.buffer = Buffer.from(buffer);
|
|
77
|
+
}
|
|
78
|
+
async verify(data, signature) {
|
|
79
|
+
try {
|
|
80
|
+
const ok = ed.sync.verify(new Uint8Array(signature), new Uint8Array(data), new Uint8Array(this.buffer));
|
|
81
|
+
return ok;
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
console.error(err);
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
hex() {
|
|
89
|
+
return this.buffer.toString("hex");
|
|
90
|
+
}
|
|
91
|
+
toAddress(hrp) {
|
|
92
|
+
return new address_1.Address(this.buffer, hrp);
|
|
93
|
+
}
|
|
94
|
+
valueOf() {
|
|
95
|
+
return this.buffer;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.UserPublicKey = UserPublicKey;
|
|
99
|
+
//# sourceMappingURL=userKeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userKeys.js","sourceRoot":"","sources":["../../src/wallet/userKeys.ts"],"names":[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BAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IAED,OAAO;QACH,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CACJ;AA9BD,sCA8BC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { PathLike } from "fs";
|
|
3
|
+
import { UserPublicKey, UserSecretKey } from "./userKeys";
|
|
4
|
+
export declare class UserPem {
|
|
5
|
+
label: string;
|
|
6
|
+
secretKey: UserSecretKey;
|
|
7
|
+
publicKey: UserPublicKey;
|
|
8
|
+
constructor(label: string, secretKey: UserSecretKey);
|
|
9
|
+
static fromFile(path: PathLike, index?: number): UserPem;
|
|
10
|
+
static fromFileAll(path: PathLike): UserPem[];
|
|
11
|
+
static fromText(text: string, index?: number): UserPem;
|
|
12
|
+
static fromTextAll(text: string): UserPem[];
|
|
13
|
+
save(path: PathLike): void;
|
|
14
|
+
toText(): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserPem = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const pemEntry_1 = require("./pemEntry");
|
|
7
|
+
const userKeys_1 = require("./userKeys");
|
|
8
|
+
class UserPem {
|
|
9
|
+
constructor(label, secretKey) {
|
|
10
|
+
this.label = label;
|
|
11
|
+
this.secretKey = secretKey;
|
|
12
|
+
this.publicKey = secretKey.generatePublicKey();
|
|
13
|
+
}
|
|
14
|
+
static fromFile(path, index = 0) {
|
|
15
|
+
return this.fromFileAll(path)[index];
|
|
16
|
+
}
|
|
17
|
+
static fromFileAll(path) {
|
|
18
|
+
const resolvedPath = path_1.isAbsolute(path.toString())
|
|
19
|
+
? path_1.resolve(path.toString())
|
|
20
|
+
: path_1.resolve(path_1.join(process.cwd(), path.toString()));
|
|
21
|
+
const text = fs_1.readFileSync(resolvedPath, "utf-8");
|
|
22
|
+
return this.fromTextAll(text);
|
|
23
|
+
}
|
|
24
|
+
static fromText(text, index = 0) {
|
|
25
|
+
const items = this.fromTextAll(text);
|
|
26
|
+
return items[index];
|
|
27
|
+
}
|
|
28
|
+
static fromTextAll(text) {
|
|
29
|
+
const entries = pemEntry_1.PemEntry.fromTextAll(text);
|
|
30
|
+
const resultItems = [];
|
|
31
|
+
for (const entry of entries) {
|
|
32
|
+
const secretKey = new userKeys_1.UserSecretKey(entry.message.slice(0, userKeys_1.USER_SEED_LENGTH));
|
|
33
|
+
const item = new UserPem(entry.label, secretKey);
|
|
34
|
+
resultItems.push(item);
|
|
35
|
+
}
|
|
36
|
+
return resultItems;
|
|
37
|
+
}
|
|
38
|
+
save(path) {
|
|
39
|
+
const resolvedPath = path_1.isAbsolute(path.toString())
|
|
40
|
+
? path_1.resolve(path.toString())
|
|
41
|
+
: path_1.resolve(path_1.join(process.cwd(), path.toString()));
|
|
42
|
+
fs_1.writeFileSync(resolvedPath, this.toText(), { encoding: "utf-8" });
|
|
43
|
+
}
|
|
44
|
+
toText() {
|
|
45
|
+
const message = new Uint8Array([...this.secretKey.valueOf(), ...this.publicKey.valueOf()]);
|
|
46
|
+
const pemEntry = new pemEntry_1.PemEntry(this.label, message);
|
|
47
|
+
return pemEntry.toText();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.UserPem = UserPem;
|
|
51
|
+
//# sourceMappingURL=userPem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userPem.js","sourceRoot":"","sources":["../../src/wallet/userPem.ts"],"names":[],"mappings":";;;AAAA,2BAA2D;AAC3D,+BAAiD;AACjD,yCAAsC;AACtC,yCAA4E;AAE5E,MAAa,OAAO;IAKhB,YAAY,KAAa,EAAE,SAAwB;QAC/C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAA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AAC,IAAI,CAAC,CAAC;SAC1B;QAED,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,IAAI,CAAC,IAAc;QACf,MAAM,YAAY,GAAG,iBAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5C,CAAC,CAAC,cAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,CAAC,CAAC,cAAO,CAAC,WAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACpD,kBAAa,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,MAAM;QACF,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC3F,MAAM,QAAQ,GAAG,IAAI,mBAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACnD,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC7B,CAAC;CACJ;AArDD,0BAqDC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Address } from "../core/address";
|
|
2
|
+
import { UserSecretKey } from "./userKeys";
|
|
3
|
+
/**
|
|
4
|
+
* ed25519 signer
|
|
5
|
+
*/
|
|
6
|
+
export declare class UserSigner {
|
|
7
|
+
readonly secretKey: UserSecretKey;
|
|
8
|
+
constructor(secretKey: UserSecretKey);
|
|
9
|
+
static fromWallet(keyFileObject: any, password: string, addressIndex?: number): UserSigner;
|
|
10
|
+
static fromPem(text: string, index?: number): UserSigner;
|
|
11
|
+
sign(data: Uint8Array): Promise<Uint8Array>;
|
|
12
|
+
/**
|
|
13
|
+
* Gets the address of the signer.
|
|
14
|
+
*/
|
|
15
|
+
getAddress(hrp?: string): Address;
|
|
16
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserSigner = void 0;
|
|
4
|
+
const address_1 = require("../core/address");
|
|
5
|
+
const errors_1 = require("../core/errors");
|
|
6
|
+
const userKeys_1 = require("./userKeys");
|
|
7
|
+
const userWallet_1 = require("./userWallet");
|
|
8
|
+
/**
|
|
9
|
+
* ed25519 signer
|
|
10
|
+
*/
|
|
11
|
+
class UserSigner {
|
|
12
|
+
constructor(secretKey) {
|
|
13
|
+
this.secretKey = secretKey;
|
|
14
|
+
}
|
|
15
|
+
static fromWallet(keyFileObject, password, addressIndex) {
|
|
16
|
+
const secretKey = userWallet_1.UserWallet.decrypt(keyFileObject, password, addressIndex);
|
|
17
|
+
return new UserSigner(secretKey);
|
|
18
|
+
}
|
|
19
|
+
static fromPem(text, index = 0) {
|
|
20
|
+
let secretKey = userKeys_1.UserSecretKey.fromPem(text, index);
|
|
21
|
+
return new UserSigner(secretKey);
|
|
22
|
+
}
|
|
23
|
+
async sign(data) {
|
|
24
|
+
try {
|
|
25
|
+
const signature = this.secretKey.sign(data);
|
|
26
|
+
return signature;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
throw new errors_1.ErrSignerCannotSign(err);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets the address of the signer.
|
|
34
|
+
*/
|
|
35
|
+
getAddress(hrp) {
|
|
36
|
+
const bech32 = this.secretKey.generatePublicKey().toAddress(hrp).toBech32();
|
|
37
|
+
return address_1.Address.newFromBech32(bech32);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.UserSigner = UserSigner;
|
|
41
|
+
//# sourceMappingURL=userSigner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userSigner.js","sourceRoot":"","sources":["../../src/wallet/userSigner.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAC1C,2CAAqD;AACrD,yCAA2C;AAC3C,6CAA0C;AAE1C;;GAEG;AACH,MAAa,UAAU;IAGnB,YAAY,SAAwB;QAChC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,aAAkB,EAAE,QAAgB,EAAE,YAAqB;QACzE,MAAM,SAAS,GAAG,uBAAU,CAAC,OAAO,CAAC,aAAa,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC5E,OAAO,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,IAAY,EAAE,QAAgB,CAAC;QAC1C,IAAI,SAAS,GAAG,wBAAa,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACnD,OAAO,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAgB;QACvB,IAAI;YACA,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5C,OAAO,SAAS,CAAC;SACpB;QAAC,OAAO,GAAQ,EAAE;YACf,MAAM,IAAI,4BAAmB,CAAC,GAAG,CAAC,CAAC;SACtC;IACL,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,GAAY;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC5E,OAAO,iBAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;CACJ;AAjCD,gCAiCC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Address } from "../core/address";
|
|
3
|
+
import { UserPublicKey } from "./userKeys";
|
|
4
|
+
/**
|
|
5
|
+
* ed25519 signature verification
|
|
6
|
+
*/
|
|
7
|
+
export declare class UserVerifier {
|
|
8
|
+
publicKey: UserPublicKey;
|
|
9
|
+
constructor(publicKey: UserPublicKey);
|
|
10
|
+
static fromAddress(address: Address): UserVerifier;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param data the raw data to be verified (e.g. an already-serialized enveloped message)
|
|
14
|
+
* @param signature the signature to be verified
|
|
15
|
+
* @returns true if the signature is valid, false otherwise
|
|
16
|
+
*/
|
|
17
|
+
verify(data: Buffer | Uint8Array, signature: Buffer | Uint8Array): Promise<boolean>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserVerifier = void 0;
|
|
4
|
+
const userKeys_1 = require("./userKeys");
|
|
5
|
+
/**
|
|
6
|
+
* ed25519 signature verification
|
|
7
|
+
*/
|
|
8
|
+
class UserVerifier {
|
|
9
|
+
constructor(publicKey) {
|
|
10
|
+
this.publicKey = publicKey;
|
|
11
|
+
}
|
|
12
|
+
static fromAddress(address) {
|
|
13
|
+
let publicKey = new userKeys_1.UserPublicKey(address.getPublicKey());
|
|
14
|
+
return new UserVerifier(publicKey);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param data the raw data to be verified (e.g. an already-serialized enveloped message)
|
|
19
|
+
* @param signature the signature to be verified
|
|
20
|
+
* @returns true if the signature is valid, false otherwise
|
|
21
|
+
*/
|
|
22
|
+
async verify(data, signature) {
|
|
23
|
+
return this.publicKey.verify(data, signature);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.UserVerifier = UserVerifier;
|
|
27
|
+
//# sourceMappingURL=userVerifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userVerifier.js","sourceRoot":"","sources":["../../src/wallet/userVerifier.ts"],"names":[],"mappings":";;;AACA,yCAA2C;AAE3C;;GAEG;AACH,MAAa,YAAY;IAGrB,YAAY,SAAwB;QAChC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,OAAgB;QAC/B,IAAI,SAAS,GAAG,IAAI,wBAAa,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;QAC1D,OAAO,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,IAAyB,EAAE,SAA8B;QAClE,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAClD,CAAC;CACJ;AArBD,oCAqBC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { PathLike } from "fs";
|
|
3
|
+
import { EncryptedData } from "./crypto";
|
|
4
|
+
import { Mnemonic } from "./mnemonic";
|
|
5
|
+
import { UserSecretKey } from "./userKeys";
|
|
6
|
+
interface IRandomness {
|
|
7
|
+
id: string;
|
|
8
|
+
iv: Buffer;
|
|
9
|
+
salt: Buffer;
|
|
10
|
+
}
|
|
11
|
+
export declare enum UserWalletKind {
|
|
12
|
+
SecretKey = "secretKey",
|
|
13
|
+
Mnemonic = "mnemonic"
|
|
14
|
+
}
|
|
15
|
+
export declare class UserWallet {
|
|
16
|
+
private readonly kind;
|
|
17
|
+
private readonly encryptedData;
|
|
18
|
+
private readonly publicKeyWhenKindIsSecretKey?;
|
|
19
|
+
private constructor();
|
|
20
|
+
static fromSecretKey({ secretKey, password, randomness, }: {
|
|
21
|
+
secretKey: UserSecretKey;
|
|
22
|
+
password: string;
|
|
23
|
+
randomness?: IRandomness;
|
|
24
|
+
}): UserWallet;
|
|
25
|
+
static fromMnemonic({ mnemonic, password, randomness, }: {
|
|
26
|
+
mnemonic: string;
|
|
27
|
+
password: string;
|
|
28
|
+
randomness?: IRandomness;
|
|
29
|
+
}): UserWallet;
|
|
30
|
+
static loadSecretKey(filePath: string, password: string, addressIndex?: number): UserSecretKey;
|
|
31
|
+
static decrypt(keyFileObject: any, password: string, addressIndex?: number): UserSecretKey;
|
|
32
|
+
/**
|
|
33
|
+
* Copied from: https://github.com/terradharitri/drt-js-deprecated-core/blob/v1.28.0/src/account.js#L42
|
|
34
|
+
* Notes: adjustements (code refactoring, no change in logic), in terms of:
|
|
35
|
+
* - typing (since this is the TypeScript version)
|
|
36
|
+
* - error handling (in line with sdk-core's error system)
|
|
37
|
+
* - references to crypto functions
|
|
38
|
+
* - references to object members
|
|
39
|
+
*
|
|
40
|
+
* From an encrypted keyfile, given the password, loads the secret key and the public key.
|
|
41
|
+
*/
|
|
42
|
+
static decryptSecretKey(keyFileObject: any, password: string): UserSecretKey;
|
|
43
|
+
static decryptMnemonic(keyFileObject: any, password: string): Mnemonic;
|
|
44
|
+
static edFromJSON(keyfileObject: any): EncryptedData;
|
|
45
|
+
/**
|
|
46
|
+
* Converts the encrypted keyfile to plain JavaScript object.
|
|
47
|
+
*/
|
|
48
|
+
toJSON(addressHrp?: string): any;
|
|
49
|
+
private toJSONWhenKindIsSecretKey;
|
|
50
|
+
getCryptoSectionAsJSON(): any;
|
|
51
|
+
toJSONWhenKindIsMnemonic(): any;
|
|
52
|
+
save(path: PathLike, addressHrp?: string): void;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.UserWallet = exports.UserWalletKind = void 0;
|
|
23
|
+
const fs_1 = require("fs");
|
|
24
|
+
const path_1 = __importStar(require("path"));
|
|
25
|
+
const config_1 = require("../core/config");
|
|
26
|
+
const errors_1 = require("../core/errors");
|
|
27
|
+
const logger_1 = require("../core/logger");
|
|
28
|
+
const crypto_1 = require("./crypto");
|
|
29
|
+
const derivationParams_1 = require("./crypto/derivationParams");
|
|
30
|
+
const mnemonic_1 = require("./mnemonic");
|
|
31
|
+
const userKeys_1 = require("./userKeys");
|
|
32
|
+
var UserWalletKind;
|
|
33
|
+
(function (UserWalletKind) {
|
|
34
|
+
UserWalletKind["SecretKey"] = "secretKey";
|
|
35
|
+
UserWalletKind["Mnemonic"] = "mnemonic";
|
|
36
|
+
})(UserWalletKind = exports.UserWalletKind || (exports.UserWalletKind = {}));
|
|
37
|
+
class UserWallet {
|
|
38
|
+
constructor({ kind, encryptedData, publicKeyWhenKindIsSecretKey, }) {
|
|
39
|
+
this.kind = kind;
|
|
40
|
+
this.encryptedData = encryptedData;
|
|
41
|
+
this.publicKeyWhenKindIsSecretKey = publicKeyWhenKindIsSecretKey;
|
|
42
|
+
}
|
|
43
|
+
static fromSecretKey({ secretKey, password, randomness, }) {
|
|
44
|
+
randomness = randomness || new crypto_1.Randomness();
|
|
45
|
+
const publicKey = secretKey.generatePublicKey();
|
|
46
|
+
const data = Buffer.concat([secretKey.valueOf(), publicKey.valueOf()]);
|
|
47
|
+
const encryptedData = crypto_1.Encryptor.encrypt(data, password, randomness);
|
|
48
|
+
return new UserWallet({
|
|
49
|
+
kind: UserWalletKind.SecretKey,
|
|
50
|
+
encryptedData,
|
|
51
|
+
publicKeyWhenKindIsSecretKey: publicKey,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
static fromMnemonic({ mnemonic, password, randomness, }) {
|
|
55
|
+
randomness = randomness || new crypto_1.Randomness();
|
|
56
|
+
mnemonic_1.Mnemonic.assertTextIsValid(mnemonic);
|
|
57
|
+
const data = Buffer.from(mnemonic);
|
|
58
|
+
const encryptedData = crypto_1.Encryptor.encrypt(data, password, randomness);
|
|
59
|
+
return new UserWallet({
|
|
60
|
+
kind: UserWalletKind.Mnemonic,
|
|
61
|
+
encryptedData,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
static loadSecretKey(filePath, password, addressIndex) {
|
|
65
|
+
// Load and parse the keystore file
|
|
66
|
+
const keyFileJson = fs_1.readFileSync(path_1.default.resolve(filePath), "utf8");
|
|
67
|
+
const keyFileObject = JSON.parse(keyFileJson);
|
|
68
|
+
const kind = keyFileObject.kind || UserWalletKind.SecretKey.valueOf();
|
|
69
|
+
logger_1.Logger.debug(`UserWallet.loadSecretKey(), kind = ${kind}`);
|
|
70
|
+
let secretKey;
|
|
71
|
+
if (kind === UserWalletKind.SecretKey.valueOf()) {
|
|
72
|
+
if (addressIndex !== undefined) {
|
|
73
|
+
throw new Error("address_index must not be provided when kind == 'secretKey'");
|
|
74
|
+
}
|
|
75
|
+
secretKey = UserWallet.decryptSecretKey(keyFileObject, password);
|
|
76
|
+
}
|
|
77
|
+
else if (kind === UserWalletKind.Mnemonic.valueOf()) {
|
|
78
|
+
const mnemonic = UserWallet.decryptMnemonic(keyFileObject, password);
|
|
79
|
+
secretKey = mnemonic.deriveKey(addressIndex || 0);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
throw new Error(`Unknown kind: ${kind}`);
|
|
83
|
+
}
|
|
84
|
+
return secretKey;
|
|
85
|
+
}
|
|
86
|
+
static decrypt(keyFileObject, password, addressIndex) {
|
|
87
|
+
const kind = keyFileObject.kind || UserWalletKind.SecretKey;
|
|
88
|
+
if (kind == UserWalletKind.SecretKey) {
|
|
89
|
+
if (addressIndex !== undefined) {
|
|
90
|
+
throw new errors_1.Err("addressIndex must not be provided when kind == 'secretKey'");
|
|
91
|
+
}
|
|
92
|
+
return UserWallet.decryptSecretKey(keyFileObject, password);
|
|
93
|
+
}
|
|
94
|
+
if (kind == UserWalletKind.Mnemonic) {
|
|
95
|
+
const mnemonic = this.decryptMnemonic(keyFileObject, password);
|
|
96
|
+
return mnemonic.deriveKey(addressIndex || 0);
|
|
97
|
+
}
|
|
98
|
+
throw new errors_1.Err(`Unknown kind: ${kind}`);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Copied from: https://github.com/terradharitri/drt-js-deprecated-core/blob/v1.28.0/src/account.js#L42
|
|
102
|
+
* Notes: adjustements (code refactoring, no change in logic), in terms of:
|
|
103
|
+
* - typing (since this is the TypeScript version)
|
|
104
|
+
* - error handling (in line with sdk-core's error system)
|
|
105
|
+
* - references to crypto functions
|
|
106
|
+
* - references to object members
|
|
107
|
+
*
|
|
108
|
+
* From an encrypted keyfile, given the password, loads the secret key and the public key.
|
|
109
|
+
*/
|
|
110
|
+
static decryptSecretKey(keyFileObject, password) {
|
|
111
|
+
// Here, we check the "kind" field only for files that have it. Older keystore files (holding only secret keys) do not have this field.
|
|
112
|
+
const kind = keyFileObject.kind;
|
|
113
|
+
if (kind && kind !== UserWalletKind.SecretKey) {
|
|
114
|
+
throw new errors_1.Err(`Expected keystore kind to be ${UserWalletKind.SecretKey}, but it was ${kind}.`);
|
|
115
|
+
}
|
|
116
|
+
const encryptedData = UserWallet.edFromJSON(keyFileObject);
|
|
117
|
+
let text = crypto_1.Decryptor.decrypt(encryptedData, password);
|
|
118
|
+
while (text.length < 32) {
|
|
119
|
+
let zeroPadding = Buffer.from([0x00]);
|
|
120
|
+
text = Buffer.concat([zeroPadding, text]);
|
|
121
|
+
}
|
|
122
|
+
const seed = text.slice(0, 32);
|
|
123
|
+
return new userKeys_1.UserSecretKey(seed);
|
|
124
|
+
}
|
|
125
|
+
static decryptMnemonic(keyFileObject, password) {
|
|
126
|
+
if (keyFileObject.kind != UserWalletKind.Mnemonic) {
|
|
127
|
+
throw new errors_1.Err(`Expected keystore kind to be ${UserWalletKind.Mnemonic}, but it was ${keyFileObject.kind}.`);
|
|
128
|
+
}
|
|
129
|
+
const encryptedData = UserWallet.edFromJSON(keyFileObject);
|
|
130
|
+
const data = crypto_1.Decryptor.decrypt(encryptedData, password);
|
|
131
|
+
const mnemonic = mnemonic_1.Mnemonic.fromString(data.toString());
|
|
132
|
+
return mnemonic;
|
|
133
|
+
}
|
|
134
|
+
static edFromJSON(keyfileObject) {
|
|
135
|
+
return new crypto_1.EncryptedData({
|
|
136
|
+
version: keyfileObject.version,
|
|
137
|
+
id: keyfileObject.id,
|
|
138
|
+
cipher: keyfileObject.crypto.cipher,
|
|
139
|
+
ciphertext: keyfileObject.crypto.ciphertext,
|
|
140
|
+
iv: keyfileObject.crypto.cipherparams.iv,
|
|
141
|
+
kdf: keyfileObject.crypto.kdf,
|
|
142
|
+
kdfparams: new derivationParams_1.ScryptKeyDerivationParams(keyfileObject.crypto.kdfparams.n, keyfileObject.crypto.kdfparams.r, keyfileObject.crypto.kdfparams.p, keyfileObject.crypto.kdfparams.dklen),
|
|
143
|
+
salt: keyfileObject.crypto.kdfparams.salt,
|
|
144
|
+
mac: keyfileObject.crypto.mac,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Converts the encrypted keyfile to plain JavaScript object.
|
|
149
|
+
*/
|
|
150
|
+
toJSON(addressHrp) {
|
|
151
|
+
if (this.kind == UserWalletKind.SecretKey) {
|
|
152
|
+
return this.toJSONWhenKindIsSecretKey(addressHrp);
|
|
153
|
+
}
|
|
154
|
+
return this.toJSONWhenKindIsMnemonic();
|
|
155
|
+
}
|
|
156
|
+
toJSONWhenKindIsSecretKey(addressHrp) {
|
|
157
|
+
if (!this.publicKeyWhenKindIsSecretKey) {
|
|
158
|
+
throw new errors_1.Err("Public key isn't available");
|
|
159
|
+
}
|
|
160
|
+
const cryptoSection = this.getCryptoSectionAsJSON();
|
|
161
|
+
const envelope = {
|
|
162
|
+
version: this.encryptedData.version,
|
|
163
|
+
kind: this.kind,
|
|
164
|
+
id: this.encryptedData.id,
|
|
165
|
+
address: this.publicKeyWhenKindIsSecretKey.hex(),
|
|
166
|
+
bech32: this.publicKeyWhenKindIsSecretKey.toAddress(addressHrp).toString(),
|
|
167
|
+
crypto: cryptoSection,
|
|
168
|
+
};
|
|
169
|
+
return envelope;
|
|
170
|
+
}
|
|
171
|
+
getCryptoSectionAsJSON() {
|
|
172
|
+
const cryptoSection = {
|
|
173
|
+
ciphertext: this.encryptedData.ciphertext,
|
|
174
|
+
cipherparams: { iv: this.encryptedData.iv },
|
|
175
|
+
cipher: crypto_1.CipherAlgorithm,
|
|
176
|
+
kdf: crypto_1.KeyDerivationFunction,
|
|
177
|
+
kdfparams: {
|
|
178
|
+
dklen: this.encryptedData.kdfparams.dklen,
|
|
179
|
+
salt: this.encryptedData.salt,
|
|
180
|
+
n: this.encryptedData.kdfparams.n,
|
|
181
|
+
r: this.encryptedData.kdfparams.r,
|
|
182
|
+
p: this.encryptedData.kdfparams.p,
|
|
183
|
+
},
|
|
184
|
+
mac: this.encryptedData.mac,
|
|
185
|
+
};
|
|
186
|
+
return cryptoSection;
|
|
187
|
+
}
|
|
188
|
+
toJSONWhenKindIsMnemonic() {
|
|
189
|
+
const cryptoSection = this.getCryptoSectionAsJSON();
|
|
190
|
+
return {
|
|
191
|
+
version: this.encryptedData.version,
|
|
192
|
+
id: this.encryptedData.id,
|
|
193
|
+
kind: this.kind,
|
|
194
|
+
crypto: cryptoSection,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
save(path, addressHrp = config_1.LibraryConfig.DefaultAddressHrp) {
|
|
198
|
+
const resolvedPath = path_1.isAbsolute(path.toString())
|
|
199
|
+
? path_1.resolve(path.toString())
|
|
200
|
+
: path_1.resolve(path_1.join(process.cwd(), path.toString()));
|
|
201
|
+
const jsonContent = this.toJSON(addressHrp);
|
|
202
|
+
fs_1.writeFileSync(resolvedPath, JSON.stringify(jsonContent, null, 4), { encoding: "utf-8" });
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.UserWallet = UserWallet;
|
|
206
|
+
//# sourceMappingURL=userWallet.js.map
|