@hiero-ledger/sdk 2.76.0 → 2.78.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/umd.js +1017 -673
- package/dist/umd.min.js +14 -14
- package/lib/Cache.cjs +6 -6
- package/lib/Cache.d.ts +12 -12
- package/lib/Cache.js.map +1 -1
- package/lib/Duration.cjs +1 -1
- package/lib/Duration.d.ts +2 -2
- package/lib/Duration.js.map +1 -1
- package/lib/EntityIdHelper.cjs +1 -1
- package/lib/EntityIdHelper.js +1 -1
- package/lib/EntityIdHelper.js.map +1 -1
- package/lib/EthereumFlow.cjs +7 -7
- package/lib/EthereumFlow.d.ts +14 -14
- package/lib/EthereumFlow.js.map +1 -1
- package/lib/EthereumTransaction.cjs +7 -7
- package/lib/EthereumTransaction.d.ts +14 -14
- package/lib/EthereumTransaction.js.map +1 -1
- package/lib/EvmAddress.cjs +1 -1
- package/lib/EvmAddress.d.ts +2 -2
- package/lib/EvmAddress.js.map +1 -1
- package/lib/ExchangeRate.cjs +2 -2
- package/lib/ExchangeRate.d.ts +4 -4
- package/lib/ExchangeRate.js.map +1 -1
- package/lib/ExchangeRates.cjs +1 -1
- package/lib/ExchangeRates.d.ts +1 -1
- package/lib/ExchangeRates.js +1 -1
- package/lib/ExchangeRates.js.map +1 -1
- package/lib/Executable.cjs +13 -3
- package/lib/Executable.js +1 -1
- package/lib/Executable.js.map +1 -1
- package/lib/FeeComponents.cjs +1 -1
- package/lib/FeeComponents.d.ts +1 -1
- package/lib/FeeComponents.js +1 -1
- package/lib/FeeComponents.js.map +1 -1
- package/lib/FeeData.cjs +1 -1
- package/lib/FeeData.d.ts +1 -1
- package/lib/FeeData.js +1 -1
- package/lib/FeeData.js.map +1 -1
- package/lib/FeeDataType.cjs +1 -1
- package/lib/FeeDataType.d.ts +2 -2
- package/lib/FeeDataType.js.map +1 -1
- package/lib/FeeSchedule.cjs +1 -1
- package/lib/FeeSchedule.d.ts +1 -1
- package/lib/FeeSchedule.js +1 -1
- package/lib/FeeSchedule.js.map +1 -1
- package/lib/FeeSchedules.cjs +1 -1
- package/lib/FeeSchedules.d.ts +1 -1
- package/lib/FeeSchedules.js +1 -1
- package/lib/FeeSchedules.js.map +1 -1
- package/lib/FreezeType.cjs +1 -1
- package/lib/FreezeType.d.ts +2 -2
- package/lib/FreezeType.js.map +1 -1
- package/lib/Key.cjs +1 -1
- package/lib/Key.d.ts +2 -2
- package/lib/Key.js.map +1 -1
- package/lib/KeyList.cjs +3 -3
- package/lib/KeyList.d.ts +6 -6
- package/lib/KeyList.js.map +1 -1
- package/lib/Mnemonic.cjs +1 -1
- package/lib/Mnemonic.d.ts +1 -1
- package/lib/Mnemonic.js +1 -1
- package/lib/Mnemonic.js.map +1 -1
- package/lib/PrivateKey.cjs +7 -7
- package/lib/PrivateKey.d.ts +11 -11
- package/lib/PrivateKey.js +1 -1
- package/lib/PrivateKey.js.map +1 -1
- package/lib/PrngTransaction.cjs +9 -9
- package/lib/PrngTransaction.d.ts +18 -18
- package/lib/PrngTransaction.js.map +1 -1
- package/lib/PublicKey.cjs +5 -5
- package/lib/PublicKey.d.ts +9 -9
- package/lib/PublicKey.js +1 -1
- package/lib/PublicKey.js.map +1 -1
- package/lib/RequestType.cjs +1 -1
- package/lib/RequestType.d.ts +2 -2
- package/lib/RequestType.js.map +1 -1
- package/lib/StakingInfo.cjs +1 -1
- package/lib/StakingInfo.d.ts +1 -1
- package/lib/StakingInfo.js +1 -1
- package/lib/StakingInfo.js.map +1 -1
- package/lib/Status.cjs +1 -1
- package/lib/Status.d.ts +2 -2
- package/lib/Status.js.map +1 -1
- package/lib/Timestamp.cjs +1 -1
- package/lib/Timestamp.d.ts +1 -1
- package/lib/Timestamp.js.map +1 -1
- package/lib/TransactionFeeSchedule.cjs +1 -1
- package/lib/TransactionFeeSchedule.d.ts +1 -1
- package/lib/TransactionFeeSchedule.js +1 -1
- package/lib/TransactionFeeSchedule.js.map +1 -1
- package/lib/Transfer.cjs +2 -2
- package/lib/Transfer.d.ts +4 -4
- package/lib/Transfer.js.map +1 -1
- package/lib/account/AccountAllowanceAdjustTransaction.cjs +7 -7
- package/lib/account/AccountAllowanceAdjustTransaction.d.ts +14 -14
- package/lib/account/AccountAllowanceAdjustTransaction.js.map +1 -1
- package/lib/account/AccountAllowanceApproveTransaction.cjs +8 -8
- package/lib/account/AccountAllowanceApproveTransaction.d.ts +16 -16
- package/lib/account/AccountAllowanceApproveTransaction.js.map +1 -1
- package/lib/account/AccountAllowanceDeleteTransaction.cjs +7 -7
- package/lib/account/AccountAllowanceDeleteTransaction.d.ts +14 -14
- package/lib/account/AccountAllowanceDeleteTransaction.js.map +1 -1
- package/lib/account/AccountBalance.cjs +1 -1
- package/lib/account/AccountBalance.d.ts +1 -1
- package/lib/account/AccountBalance.js +1 -1
- package/lib/account/AccountBalance.js.map +1 -1
- package/lib/account/AccountBalanceQuery.cjs +6 -6
- package/lib/account/AccountBalanceQuery.d.ts +12 -12
- package/lib/account/AccountBalanceQuery.js.map +1 -1
- package/lib/account/AccountCreateTransaction.cjs +1 -1
- package/lib/account/AccountCreateTransaction.d.ts +1 -1
- package/lib/account/AccountCreateTransaction.js +1 -1
- package/lib/account/AccountCreateTransaction.js.map +1 -1
- package/lib/account/AccountDeleteTransaction.cjs +7 -7
- package/lib/account/AccountDeleteTransaction.d.ts +14 -14
- package/lib/account/AccountDeleteTransaction.js.map +1 -1
- package/lib/account/AccountId.cjs +1 -1
- package/lib/account/AccountId.d.ts +1 -1
- package/lib/account/AccountId.js +1 -1
- package/lib/account/AccountId.js.map +1 -1
- package/lib/account/AccountInfo.cjs +1 -1
- package/lib/account/AccountInfo.d.ts +1 -1
- package/lib/account/AccountInfo.js +1 -1
- package/lib/account/AccountInfo.js.map +1 -1
- package/lib/account/AccountInfoQuery.cjs +7 -7
- package/lib/account/AccountInfoQuery.d.ts +14 -14
- package/lib/account/AccountInfoQuery.js.map +1 -1
- package/lib/account/AccountRecordsQuery.cjs +7 -7
- package/lib/account/AccountRecordsQuery.d.ts +14 -14
- package/lib/account/AccountRecordsQuery.js.map +1 -1
- package/lib/account/AccountUpdateTransaction.cjs +7 -7
- package/lib/account/AccountUpdateTransaction.d.ts +14 -14
- package/lib/account/AccountUpdateTransaction.js.map +1 -1
- package/lib/account/HbarAllowance.cjs +3 -3
- package/lib/account/HbarAllowance.d.ts +6 -6
- package/lib/account/HbarAllowance.js.map +1 -1
- package/lib/account/HbarTransferMap.cjs +2 -2
- package/lib/account/HbarTransferMap.d.ts +4 -4
- package/lib/account/HbarTransferMap.js.map +1 -1
- package/lib/account/LiveHash.cjs +3 -3
- package/lib/account/LiveHash.d.ts +6 -6
- package/lib/account/LiveHash.js.map +1 -1
- package/lib/account/LiveHashAddTransaction.cjs +7 -7
- package/lib/account/LiveHashAddTransaction.d.ts +14 -14
- package/lib/account/LiveHashAddTransaction.js.map +1 -1
- package/lib/account/LiveHashDeleteTransaction.cjs +6 -6
- package/lib/account/LiveHashDeleteTransaction.d.ts +12 -12
- package/lib/account/LiveHashDeleteTransaction.js.map +1 -1
- package/lib/account/LiveHashQuery.cjs +7 -7
- package/lib/account/LiveHashQuery.d.ts +14 -14
- package/lib/account/LiveHashQuery.js.map +1 -1
- package/lib/account/NullableTokenDecimalMap.cjs +2 -2
- package/lib/account/NullableTokenDecimalMap.d.ts +4 -4
- package/lib/account/NullableTokenDecimalMap.js.map +1 -1
- package/lib/account/ProxyStaker.cjs +2 -2
- package/lib/account/ProxyStaker.d.ts +4 -4
- package/lib/account/ProxyStaker.js.map +1 -1
- package/lib/account/TokenAllowance.cjs +4 -4
- package/lib/account/TokenAllowance.d.ts +8 -8
- package/lib/account/TokenAllowance.js.map +1 -1
- package/lib/account/TokenBalanceMap.cjs +2 -2
- package/lib/account/TokenBalanceMap.d.ts +4 -4
- package/lib/account/TokenBalanceMap.js.map +1 -1
- package/lib/account/TokenDecimalMap.cjs +2 -2
- package/lib/account/TokenDecimalMap.d.ts +4 -4
- package/lib/account/TokenDecimalMap.js.map +1 -1
- package/lib/account/TokenNftAllowance.cjs +5 -5
- package/lib/account/TokenNftAllowance.d.ts +10 -10
- package/lib/account/TokenNftAllowance.js.map +1 -1
- package/lib/account/TokenNftTransferMap.cjs +5 -5
- package/lib/account/TokenNftTransferMap.d.ts +10 -10
- package/lib/account/TokenNftTransferMap.js.map +1 -1
- package/lib/account/TokenRelationship.cjs +4 -4
- package/lib/account/TokenRelationship.d.ts +8 -8
- package/lib/account/TokenRelationship.js.map +1 -1
- package/lib/account/TokenRelationshipMap.cjs +2 -2
- package/lib/account/TokenRelationshipMap.d.ts +4 -4
- package/lib/account/TokenRelationshipMap.js.map +1 -1
- package/lib/account/TokenTransferMap.cjs +4 -4
- package/lib/account/TokenTransferMap.d.ts +8 -8
- package/lib/account/TokenTransferMap.js.map +1 -1
- package/lib/account/TransferTransaction.cjs +6 -6
- package/lib/account/TransferTransaction.d.ts +12 -12
- package/lib/account/TransferTransaction.js.map +1 -1
- package/lib/address_book/AddressBooks.cjs +1 -1
- package/lib/address_book/AddressBooks.js +1 -1
- package/lib/address_book/AddressBooks.js.map +1 -1
- package/lib/address_book/Endpoint.cjs +1 -1
- package/lib/address_book/Endpoint.d.ts +2 -2
- package/lib/address_book/Endpoint.js.map +1 -1
- package/lib/address_book/NodeAddress.cjs +1 -1
- package/lib/address_book/NodeAddress.d.ts +2 -2
- package/lib/address_book/NodeAddress.js.map +1 -1
- package/lib/address_book/NodeAddressBook.cjs +1 -1
- package/lib/address_book/NodeAddressBook.d.ts +1 -1
- package/lib/address_book/NodeAddressBook.js +1 -1
- package/lib/address_book/NodeAddressBook.js.map +1 -1
- package/lib/browser.js +1 -1
- package/lib/channel/Channel.cjs +26 -2
- package/lib/channel/Channel.d.ts +21 -1
- package/lib/channel/Channel.js +1 -1
- package/lib/channel/Channel.js.map +1 -1
- package/lib/channel/NativeChannel.cjs +96 -2
- package/lib/channel/NativeChannel.d.ts +21 -1
- package/lib/channel/NativeChannel.js +1 -1
- package/lib/channel/NativeChannel.js.map +1 -1
- package/lib/channel/NodeChannel.cjs +4 -5
- package/lib/channel/NodeChannel.d.ts +2 -3
- package/lib/channel/NodeChannel.js +1 -1
- package/lib/channel/NodeChannel.js.map +1 -1
- package/lib/channel/WebChannel.cjs +163 -13
- package/lib/channel/WebChannel.d.ts +51 -1
- package/lib/channel/WebChannel.js +1 -1
- package/lib/channel/WebChannel.js.map +1 -1
- package/lib/client/Client.cjs +62 -5
- package/lib/client/Client.d.ts +26 -3
- package/lib/client/Client.js +1 -1
- package/lib/client/Client.js.map +1 -1
- package/lib/client/NativeClient.cjs +1 -1
- package/lib/client/NativeClient.js +1 -1
- package/lib/client/NativeClient.js.map +1 -1
- package/lib/client/NodeClient.cjs +7 -6
- package/lib/client/NodeClient.d.ts +3 -3
- package/lib/client/NodeClient.js +1 -1
- package/lib/client/NodeClient.js.map +1 -1
- package/lib/client/WebClient.cjs +55 -27
- package/lib/client/WebClient.d.ts +6 -0
- package/lib/client/WebClient.js +1 -1
- package/lib/client/WebClient.js.map +1 -1
- package/lib/client/addressbooks/mainnet.cjs +1 -1
- package/lib/client/addressbooks/mainnet.d.ts +1 -1
- package/lib/client/addressbooks/mainnet.js +1 -1
- package/lib/client/addressbooks/mainnet.js.map +1 -1
- package/lib/client/addressbooks/previewnet.cjs +1 -1
- package/lib/client/addressbooks/previewnet.d.ts +1 -1
- package/lib/client/addressbooks/previewnet.js +1 -1
- package/lib/client/addressbooks/previewnet.js.map +1 -1
- package/lib/client/addressbooks/testnet.cjs +1 -1
- package/lib/client/addressbooks/testnet.d.ts +1 -1
- package/lib/client/addressbooks/testnet.js +1 -1
- package/lib/client/addressbooks/testnet.js.map +1 -1
- package/lib/constants/ClientConstants.cjs +17 -1
- package/lib/constants/ClientConstants.d.ts +14 -0
- package/lib/constants/ClientConstants.js +1 -1
- package/lib/constants/ClientConstants.js.map +1 -1
- package/lib/contract/ContractByteCodeQuery.cjs +6 -6
- package/lib/contract/ContractByteCodeQuery.d.ts +12 -12
- package/lib/contract/ContractByteCodeQuery.js.map +1 -1
- package/lib/contract/ContractCallQuery.cjs +1 -1
- package/lib/contract/ContractCallQuery.d.ts +1 -1
- package/lib/contract/ContractCallQuery.js +1 -1
- package/lib/contract/ContractCallQuery.js.map +1 -1
- package/lib/contract/ContractCreateTransaction.cjs +8 -8
- package/lib/contract/ContractCreateTransaction.d.ts +16 -16
- package/lib/contract/ContractCreateTransaction.js.map +1 -1
- package/lib/contract/ContractDeleteTransaction.cjs +8 -8
- package/lib/contract/ContractDeleteTransaction.d.ts +16 -16
- package/lib/contract/ContractDeleteTransaction.js.map +1 -1
- package/lib/contract/ContractExecuteTransaction.cjs +9 -9
- package/lib/contract/ContractExecuteTransaction.d.ts +18 -18
- package/lib/contract/ContractExecuteTransaction.js.map +1 -1
- package/lib/contract/ContractFunctionResult.cjs +2 -2
- package/lib/contract/ContractFunctionResult.d.ts +4 -4
- package/lib/contract/ContractFunctionResult.js.map +1 -1
- package/lib/contract/ContractId.cjs +1 -1
- package/lib/contract/ContractId.d.ts +1 -1
- package/lib/contract/ContractId.js +1 -1
- package/lib/contract/ContractId.js.map +1 -1
- package/lib/contract/ContractInfo.cjs +1 -1
- package/lib/contract/ContractInfo.d.ts +1 -1
- package/lib/contract/ContractInfo.js +1 -1
- package/lib/contract/ContractInfo.js.map +1 -1
- package/lib/contract/ContractInfoQuery.cjs +7 -7
- package/lib/contract/ContractInfoQuery.d.ts +14 -14
- package/lib/contract/ContractInfoQuery.js.map +1 -1
- package/lib/contract/ContractLogInfo.cjs +2 -2
- package/lib/contract/ContractLogInfo.d.ts +4 -4
- package/lib/contract/ContractLogInfo.js.map +1 -1
- package/lib/contract/ContractNonceInfo.cjs +3 -3
- package/lib/contract/ContractNonceInfo.d.ts +4 -4
- package/lib/contract/ContractNonceInfo.js +1 -1
- package/lib/contract/ContractNonceInfo.js.map +1 -1
- package/lib/contract/ContractStateChange.cjs +1 -1
- package/lib/contract/ContractStateChange.d.ts +1 -1
- package/lib/contract/ContractUpdateTransaction.cjs +10 -10
- package/lib/contract/ContractUpdateTransaction.d.ts +18 -18
- package/lib/contract/ContractUpdateTransaction.js +1 -1
- package/lib/contract/ContractUpdateTransaction.js.map +1 -1
- package/lib/contract/DelegateContractId.cjs +2 -2
- package/lib/contract/DelegateContractId.d.ts +4 -4
- package/lib/contract/DelegateContractId.js.map +1 -1
- package/lib/contract/StorageChange.cjs +1 -1
- package/lib/contract/StorageChange.d.ts +1 -1
- package/lib/exports.cjs +1 -1
- package/lib/exports.d.ts +1 -1
- package/lib/exports.js +1 -1
- package/lib/exports.js.map +1 -1
- package/lib/file/FileAppendTransaction.cjs +7 -7
- package/lib/file/FileAppendTransaction.d.ts +14 -14
- package/lib/file/FileAppendTransaction.js.map +1 -1
- package/lib/file/FileContentsQuery.cjs +7 -7
- package/lib/file/FileContentsQuery.d.ts +14 -14
- package/lib/file/FileContentsQuery.js.map +1 -1
- package/lib/file/FileCreateTransaction.cjs +6 -6
- package/lib/file/FileCreateTransaction.d.ts +12 -12
- package/lib/file/FileCreateTransaction.js.map +1 -1
- package/lib/file/FileDeleteTransaction.cjs +7 -7
- package/lib/file/FileDeleteTransaction.d.ts +14 -14
- package/lib/file/FileDeleteTransaction.js.map +1 -1
- package/lib/file/FileId.cjs +1 -1
- package/lib/file/FileId.d.ts +1 -1
- package/lib/file/FileId.js +1 -1
- package/lib/file/FileId.js.map +1 -1
- package/lib/file/FileInfo.cjs +1 -1
- package/lib/file/FileInfo.d.ts +1 -1
- package/lib/file/FileInfo.js +1 -1
- package/lib/file/FileInfo.js.map +1 -1
- package/lib/file/FileInfoQuery.cjs +7 -7
- package/lib/file/FileInfoQuery.d.ts +14 -14
- package/lib/file/FileInfoQuery.js.map +1 -1
- package/lib/file/FileUpdateTransaction.cjs +6 -6
- package/lib/file/FileUpdateTransaction.d.ts +12 -12
- package/lib/file/FileUpdateTransaction.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/native.js +1 -1
- package/lib/network/AddressBookQuery.cjs +1 -5
- package/lib/network/AddressBookQuery.js +1 -1
- package/lib/network/AddressBookQuery.js.map +1 -1
- package/lib/network/AddressBookQueryWeb.cjs +1 -5
- package/lib/network/AddressBookQueryWeb.js +1 -1
- package/lib/network/AddressBookQueryWeb.js.map +1 -1
- package/lib/network/NetworkVersionInfo.cjs +1 -1
- package/lib/network/NetworkVersionInfo.d.ts +1 -1
- package/lib/network/NetworkVersionInfo.js +1 -1
- package/lib/network/NetworkVersionInfo.js.map +1 -1
- package/lib/network/NetworkVersionInfoQuery.cjs +6 -6
- package/lib/network/NetworkVersionInfoQuery.d.ts +12 -12
- package/lib/network/NetworkVersionInfoQuery.js.map +1 -1
- package/lib/network/SemanticVersion.cjs +1 -1
- package/lib/network/SemanticVersion.d.ts +1 -1
- package/lib/network/SemanticVersion.js +1 -1
- package/lib/network/SemanticVersion.js.map +1 -1
- package/lib/node/NodeCreateTransaction.cjs +6 -6
- package/lib/node/NodeCreateTransaction.d.ts +12 -12
- package/lib/node/NodeCreateTransaction.js.map +1 -1
- package/lib/node/NodeDeleteTransaction.cjs +6 -6
- package/lib/node/NodeDeleteTransaction.d.ts +12 -12
- package/lib/node/NodeDeleteTransaction.js.map +1 -1
- package/lib/node/NodeUpdateTransaction.cjs +6 -6
- package/lib/node/NodeUpdateTransaction.d.ts +12 -12
- package/lib/node/NodeUpdateTransaction.js.map +1 -1
- package/lib/node/ServiceEndpoint.cjs +1 -1
- package/lib/node/ServiceEndpoint.d.ts +2 -2
- package/lib/node/ServiceEndpoint.js.map +1 -1
- package/lib/query/CostQuery.cjs +1 -1
- package/lib/query/CostQuery.d.ts +1 -1
- package/lib/query/CostQuery.js +1 -1
- package/lib/query/CostQuery.js.map +1 -1
- package/lib/query/Query.cjs +1 -1
- package/lib/query/Query.d.ts +1 -1
- package/lib/query/Query.js +1 -1
- package/lib/query/Query.js.map +1 -1
- package/lib/query/QueryBase.cjs +1 -1
- package/lib/query/QueryBase.d.ts +1 -1
- package/lib/query/QueryBase.js +1 -1
- package/lib/query/QueryBase.js.map +1 -1
- package/lib/schedule/ScheduleCreateTransaction.cjs +1 -1
- package/lib/schedule/ScheduleCreateTransaction.d.ts +1 -1
- package/lib/schedule/ScheduleCreateTransaction.js +1 -1
- package/lib/schedule/ScheduleCreateTransaction.js.map +1 -1
- package/lib/schedule/ScheduleDeleteTransaction.cjs +8 -8
- package/lib/schedule/ScheduleDeleteTransaction.d.ts +16 -16
- package/lib/schedule/ScheduleDeleteTransaction.js.map +1 -1
- package/lib/schedule/ScheduleId.cjs +1 -1
- package/lib/schedule/ScheduleId.d.ts +1 -1
- package/lib/schedule/ScheduleId.js +1 -1
- package/lib/schedule/ScheduleId.js.map +1 -1
- package/lib/schedule/ScheduleInfo.cjs +1 -1
- package/lib/schedule/ScheduleInfo.d.ts +1 -1
- package/lib/schedule/ScheduleInfo.js +1 -1
- package/lib/schedule/ScheduleInfo.js.map +1 -1
- package/lib/schedule/ScheduleInfoQuery.cjs +7 -7
- package/lib/schedule/ScheduleInfoQuery.d.ts +14 -14
- package/lib/schedule/ScheduleInfoQuery.js.map +1 -1
- package/lib/schedule/ScheduleSignTransaction.cjs +10 -10
- package/lib/schedule/ScheduleSignTransaction.d.ts +20 -20
- package/lib/schedule/ScheduleSignTransaction.js.map +1 -1
- package/lib/system/FreezeTransaction.cjs +6 -6
- package/lib/system/FreezeTransaction.d.ts +12 -12
- package/lib/system/FreezeTransaction.js.map +1 -1
- package/lib/system/SystemDeleteTransaction.cjs +8 -8
- package/lib/system/SystemDeleteTransaction.d.ts +16 -16
- package/lib/system/SystemDeleteTransaction.js.map +1 -1
- package/lib/system/SystemUndeleteTransaction.cjs +8 -8
- package/lib/system/SystemUndeleteTransaction.d.ts +16 -16
- package/lib/system/SystemUndeleteTransaction.js.map +1 -1
- package/lib/token/AbstractTokenTransferTransaction.cjs +1 -1
- package/lib/token/AbstractTokenTransferTransaction.d.ts +2 -2
- package/lib/token/AbstractTokenTransferTransaction.js.map +1 -1
- package/lib/token/AssessedCustomFee.cjs +1 -1
- package/lib/token/AssessedCustomFee.d.ts +2 -2
- package/lib/token/AssessedCustomFee.js.map +1 -1
- package/lib/token/CustomFee.cjs +1 -1
- package/lib/token/CustomFee.d.ts +2 -2
- package/lib/token/CustomFee.js.map +1 -1
- package/lib/token/CustomFixedFee.cjs +3 -3
- package/lib/token/CustomFixedFee.d.ts +6 -6
- package/lib/token/CustomFixedFee.js.map +1 -1
- package/lib/token/CustomFractionalFee.cjs +3 -3
- package/lib/token/CustomFractionalFee.d.ts +6 -6
- package/lib/token/CustomFractionalFee.js.map +1 -1
- package/lib/token/CustomRoyaltyFee.cjs +4 -4
- package/lib/token/CustomRoyaltyFee.d.ts +8 -8
- package/lib/token/CustomRoyaltyFee.js.map +1 -1
- package/lib/token/NftId.cjs +1 -1
- package/lib/token/NftId.d.ts +1 -1
- package/lib/token/NftId.js +1 -1
- package/lib/token/NftId.js.map +1 -1
- package/lib/token/PendingAirdropId.cjs +1 -1
- package/lib/token/PendingAirdropId.d.ts +1 -1
- package/lib/token/PendingAirdropId.js.map +1 -1
- package/lib/token/PendingAirdropRecord.cjs +1 -1
- package/lib/token/PendingAirdropRecord.d.ts +1 -1
- package/lib/token/PendingAirdropRecord.js.map +1 -1
- package/lib/token/TokenAirdropTransaction.cjs +8 -8
- package/lib/token/TokenAirdropTransaction.d.ts +16 -16
- package/lib/token/TokenAirdropTransaction.js.map +1 -1
- package/lib/token/TokenAssociateTransaction.cjs +7 -7
- package/lib/token/TokenAssociateTransaction.d.ts +14 -14
- package/lib/token/TokenAssociateTransaction.js.map +1 -1
- package/lib/token/TokenAssociation.cjs +1 -1
- package/lib/token/TokenAssociation.d.ts +2 -2
- package/lib/token/TokenAssociation.js.map +1 -1
- package/lib/token/TokenBurnTransaction.cjs +7 -7
- package/lib/token/TokenBurnTransaction.d.ts +14 -14
- package/lib/token/TokenBurnTransaction.js.map +1 -1
- package/lib/token/TokenCancelAirdropTransaction.cjs +6 -6
- package/lib/token/TokenCancelAirdropTransaction.d.ts +12 -12
- package/lib/token/TokenCancelAirdropTransaction.js.map +1 -1
- package/lib/token/TokenClaimAirdropTransaction.cjs +6 -6
- package/lib/token/TokenClaimAirdropTransaction.d.ts +12 -12
- package/lib/token/TokenClaimAirdropTransaction.js.map +1 -1
- package/lib/token/TokenCreateTransaction.cjs +7 -7
- package/lib/token/TokenCreateTransaction.d.ts +14 -14
- package/lib/token/TokenCreateTransaction.js.map +1 -1
- package/lib/token/TokenDeleteTransaction.cjs +7 -7
- package/lib/token/TokenDeleteTransaction.d.ts +14 -14
- package/lib/token/TokenDeleteTransaction.js.map +1 -1
- package/lib/token/TokenDissociateTransaction.cjs +7 -7
- package/lib/token/TokenDissociateTransaction.d.ts +14 -14
- package/lib/token/TokenDissociateTransaction.js.map +1 -1
- package/lib/token/TokenFeeScheduleUpdateTransaction.cjs +7 -7
- package/lib/token/TokenFeeScheduleUpdateTransaction.d.ts +14 -14
- package/lib/token/TokenFeeScheduleUpdateTransaction.js.map +1 -1
- package/lib/token/TokenFreezeTransaction.cjs +7 -7
- package/lib/token/TokenFreezeTransaction.d.ts +14 -14
- package/lib/token/TokenFreezeTransaction.js.map +1 -1
- package/lib/token/TokenGrantKycTransaction.cjs +7 -7
- package/lib/token/TokenGrantKycTransaction.d.ts +14 -14
- package/lib/token/TokenGrantKycTransaction.js.map +1 -1
- package/lib/token/TokenId.cjs +1 -1
- package/lib/token/TokenId.d.ts +1 -1
- package/lib/token/TokenId.js +1 -1
- package/lib/token/TokenId.js.map +1 -1
- package/lib/token/TokenInfo.cjs +1 -1
- package/lib/token/TokenInfo.d.ts +1 -1
- package/lib/token/TokenInfo.js +1 -1
- package/lib/token/TokenInfo.js.map +1 -1
- package/lib/token/TokenInfoQuery.cjs +7 -7
- package/lib/token/TokenInfoQuery.d.ts +14 -14
- package/lib/token/TokenInfoQuery.js.map +1 -1
- package/lib/token/TokenKeyValidation.cjs +1 -1
- package/lib/token/TokenKeyValidation.d.ts +2 -2
- package/lib/token/TokenKeyValidation.js.map +1 -1
- package/lib/token/TokenMintTransaction.cjs +7 -7
- package/lib/token/TokenMintTransaction.d.ts +14 -14
- package/lib/token/TokenMintTransaction.js.map +1 -1
- package/lib/token/TokenNftInfo.cjs +10 -10
- package/lib/token/TokenNftInfo.d.ts +20 -20
- package/lib/token/TokenNftInfo.js.map +1 -1
- package/lib/token/TokenNftInfoQuery.cjs +11 -11
- package/lib/token/TokenNftInfoQuery.d.ts +22 -22
- package/lib/token/TokenNftInfoQuery.js.map +1 -1
- package/lib/token/TokenNftTransfer.cjs +5 -5
- package/lib/token/TokenNftTransfer.d.ts +10 -10
- package/lib/token/TokenNftTransfer.js.map +1 -1
- package/lib/token/TokenNftsUpdateTransaction.cjs +7 -7
- package/lib/token/TokenNftsUpdateTransaction.d.ts +14 -14
- package/lib/token/TokenPauseTransaction.cjs +7 -7
- package/lib/token/TokenPauseTransaction.d.ts +14 -14
- package/lib/token/TokenPauseTransaction.js.map +1 -1
- package/lib/token/TokenReference.cjs +1 -1
- package/lib/token/TokenReference.d.ts +2 -2
- package/lib/token/TokenReference.js.map +1 -1
- package/lib/token/TokenRejectTransaction.cjs +7 -7
- package/lib/token/TokenRejectTransaction.d.ts +14 -14
- package/lib/token/TokenRejectTransaction.js.map +1 -1
- package/lib/token/TokenRevokeKycTransaction.cjs +7 -7
- package/lib/token/TokenRevokeKycTransaction.d.ts +14 -14
- package/lib/token/TokenRevokeKycTransaction.js.map +1 -1
- package/lib/token/TokenSupplyType.cjs +1 -1
- package/lib/token/TokenSupplyType.d.ts +2 -2
- package/lib/token/TokenSupplyType.js.map +1 -1
- package/lib/token/TokenTransfer.cjs +4 -4
- package/lib/token/TokenTransfer.d.ts +8 -8
- package/lib/token/TokenTransfer.js.map +1 -1
- package/lib/token/TokenType.cjs +1 -1
- package/lib/token/TokenType.d.ts +2 -2
- package/lib/token/TokenType.js.map +1 -1
- package/lib/token/TokenUnfreezeTransaction.cjs +7 -7
- package/lib/token/TokenUnfreezeTransaction.d.ts +14 -14
- package/lib/token/TokenUnfreezeTransaction.js.map +1 -1
- package/lib/token/TokenUnpauseTransaction.cjs +7 -7
- package/lib/token/TokenUnpauseTransaction.d.ts +14 -14
- package/lib/token/TokenUnpauseTransaction.js.map +1 -1
- package/lib/token/TokenUpdateNftsTransaction.cjs +7 -7
- package/lib/token/TokenUpdateNftsTransaction.d.ts +14 -14
- package/lib/token/TokenUpdateNftsTransaction.js.map +1 -1
- package/lib/token/TokenUpdateTransaction.cjs +7 -7
- package/lib/token/TokenUpdateTransaction.d.ts +14 -14
- package/lib/token/TokenUpdateTransaction.js.map +1 -1
- package/lib/token/TokenWipeTransaction.cjs +7 -7
- package/lib/token/TokenWipeTransaction.d.ts +14 -14
- package/lib/token/TokenWipeTransaction.js.map +1 -1
- package/lib/topic/TopicCreateTransaction.cjs +6 -6
- package/lib/topic/TopicCreateTransaction.d.ts +12 -12
- package/lib/topic/TopicCreateTransaction.js.map +1 -1
- package/lib/topic/TopicDeleteTransaction.cjs +6 -6
- package/lib/topic/TopicDeleteTransaction.d.ts +12 -12
- package/lib/topic/TopicDeleteTransaction.js.map +1 -1
- package/lib/topic/TopicId.cjs +1 -1
- package/lib/topic/TopicId.d.ts +1 -1
- package/lib/topic/TopicId.js +1 -1
- package/lib/topic/TopicId.js.map +1 -1
- package/lib/topic/TopicInfo.cjs +1 -1
- package/lib/topic/TopicInfo.d.ts +1 -1
- package/lib/topic/TopicInfo.js +1 -1
- package/lib/topic/TopicInfo.js.map +1 -1
- package/lib/topic/TopicInfoQuery.cjs +7 -7
- package/lib/topic/TopicInfoQuery.d.ts +14 -14
- package/lib/topic/TopicInfoQuery.js.map +1 -1
- package/lib/topic/TopicMessage.cjs +2 -2
- package/lib/topic/TopicMessage.d.ts +4 -4
- package/lib/topic/TopicMessage.js.map +1 -1
- package/lib/topic/TopicMessageChunk.cjs +2 -2
- package/lib/topic/TopicMessageChunk.d.ts +4 -4
- package/lib/topic/TopicMessageChunk.js.map +1 -1
- package/lib/topic/TopicMessageQuery.cjs +1 -1
- package/lib/topic/TopicMessageQuery.js +1 -1
- package/lib/topic/TopicMessageQuery.js.map +1 -1
- package/lib/topic/TopicMessageSubmitTransaction.cjs +9 -9
- package/lib/topic/TopicMessageSubmitTransaction.d.ts +18 -18
- package/lib/topic/TopicMessageSubmitTransaction.js.map +1 -1
- package/lib/topic/TopicUpdateTransaction.cjs +6 -6
- package/lib/topic/TopicUpdateTransaction.d.ts +12 -12
- package/lib/topic/TopicUpdateTransaction.js.map +1 -1
- package/lib/transaction/BatchTransaction.cjs +5 -5
- package/lib/transaction/BatchTransaction.d.ts +9 -9
- package/lib/transaction/BatchTransaction.js +1 -1
- package/lib/transaction/BatchTransaction.js.map +1 -1
- package/lib/transaction/CustomFeeLimit.cjs +2 -2
- package/lib/transaction/CustomFeeLimit.d.ts +4 -4
- package/lib/transaction/CustomFeeLimit.js.map +1 -1
- package/lib/transaction/NodeAccountIdSignatureMap.cjs +2 -2
- package/lib/transaction/NodeAccountIdSignatureMap.d.ts +2 -2
- package/lib/transaction/NodeAccountIdSignatureMap.js +1 -1
- package/lib/transaction/NodeAccountIdSignatureMap.js.map +1 -1
- package/lib/transaction/NodeAccountIdSignatureMapLegacy.cjs +1 -1
- package/lib/transaction/NodeAccountIdSignatureMapLegacy.d.ts +2 -2
- package/lib/transaction/NodeAccountIdSignatureMapLegacy.js.map +1 -1
- package/lib/transaction/SignatureMap.cjs +1 -1
- package/lib/transaction/SignatureMap.js.map +1 -1
- package/lib/transaction/SignaturePairMap.cjs +1 -1
- package/lib/transaction/SignaturePairMap.d.ts +2 -2
- package/lib/transaction/SignaturePairMap.js.map +1 -1
- package/lib/transaction/Transaction.cjs +1 -1
- package/lib/transaction/Transaction.d.ts +1 -1
- package/lib/transaction/Transaction.js +1 -1
- package/lib/transaction/Transaction.js.map +1 -1
- package/lib/transaction/TransactionHashMap.cjs +1 -1
- package/lib/transaction/TransactionHashMap.d.ts +2 -2
- package/lib/transaction/TransactionHashMap.js.map +1 -1
- package/lib/transaction/TransactionId.cjs +1 -1
- package/lib/transaction/TransactionId.d.ts +1 -1
- package/lib/transaction/TransactionId.js +1 -1
- package/lib/transaction/TransactionId.js.map +1 -1
- package/lib/transaction/TransactionReceipt.cjs +1 -1
- package/lib/transaction/TransactionReceipt.d.ts +1 -1
- package/lib/transaction/TransactionReceipt.js +1 -1
- package/lib/transaction/TransactionReceipt.js.map +1 -1
- package/lib/transaction/TransactionReceiptQuery.cjs +1 -1
- package/lib/transaction/TransactionReceiptQuery.d.ts +1 -1
- package/lib/transaction/TransactionReceiptQuery.js +1 -1
- package/lib/transaction/TransactionReceiptQuery.js.map +1 -1
- package/lib/transaction/TransactionRecord.cjs +1 -1
- package/lib/transaction/TransactionRecord.d.ts +1 -1
- package/lib/transaction/TransactionRecord.js +1 -1
- package/lib/transaction/TransactionRecord.js.map +1 -1
- package/lib/transaction/TransactionRecordQuery.cjs +1 -1
- package/lib/transaction/TransactionRecordQuery.d.ts +1 -1
- package/lib/transaction/TransactionRecordQuery.js +1 -1
- package/lib/transaction/TransactionRecordQuery.js.map +1 -1
- package/lib/util/ASN1-Decoder.cjs +1 -1
- package/lib/util/ASN1-Decoder.js +1 -1
- package/lib/util/ASN1-Decoder.js.map +1 -1
- package/lib/version.js +1 -1
- package/package.json +6 -8
- package/src/Cache.js +6 -6
- package/src/Duration.js +1 -1
- package/src/EntityIdHelper.js +1 -1
- package/src/EthereumFlow.js +7 -7
- package/src/EthereumTransaction.js +7 -7
- package/src/EvmAddress.js +1 -1
- package/src/ExchangeRate.js +2 -2
- package/src/ExchangeRates.js +1 -1
- package/src/Executable.js +18 -2
- package/src/FeeComponents.js +1 -1
- package/src/FeeData.js +1 -1
- package/src/FeeDataType.js +1 -1
- package/src/FeeSchedule.js +1 -1
- package/src/FeeSchedules.js +1 -1
- package/src/FreezeType.js +1 -1
- package/src/Key.js +1 -1
- package/src/KeyList.js +3 -3
- package/src/Mnemonic.js +1 -1
- package/src/PrivateKey.js +7 -7
- package/src/PrngTransaction.js +9 -9
- package/src/PublicKey.js +5 -5
- package/src/RequestType.js +1 -1
- package/src/StakingInfo.js +1 -1
- package/src/Status.js +1 -1
- package/src/Timestamp.js +1 -1
- package/src/TransactionFeeSchedule.js +1 -1
- package/src/Transfer.js +2 -2
- package/src/account/AccountAllowanceAdjustTransaction.js +7 -7
- package/src/account/AccountAllowanceApproveTransaction.js +8 -8
- package/src/account/AccountAllowanceDeleteTransaction.js +7 -7
- package/src/account/AccountBalance.js +1 -1
- package/src/account/AccountBalanceQuery.js +6 -6
- package/src/account/AccountCreateTransaction.js +1 -1
- package/src/account/AccountDeleteTransaction.js +7 -7
- package/src/account/AccountId.js +1 -1
- package/src/account/AccountInfo.js +1 -1
- package/src/account/AccountInfoQuery.js +7 -7
- package/src/account/AccountRecordsQuery.js +7 -7
- package/src/account/AccountUpdateTransaction.js +7 -7
- package/src/account/HbarAllowance.js +3 -3
- package/src/account/HbarTransferMap.js +2 -2
- package/src/account/LiveHash.js +3 -3
- package/src/account/LiveHashAddTransaction.js +7 -7
- package/src/account/LiveHashDeleteTransaction.js +6 -6
- package/src/account/LiveHashQuery.js +7 -7
- package/src/account/NullableTokenDecimalMap.js +2 -2
- package/src/account/ProxyStaker.js +2 -2
- package/src/account/TokenAllowance.js +4 -4
- package/src/account/TokenBalanceMap.js +2 -2
- package/src/account/TokenDecimalMap.js +2 -2
- package/src/account/TokenNftAllowance.js +5 -5
- package/src/account/TokenNftTransferMap.js +5 -5
- package/src/account/TokenRelationship.js +4 -4
- package/src/account/TokenRelationshipMap.js +2 -2
- package/src/account/TokenTransferMap.js +4 -4
- package/src/account/TransferTransaction.js +6 -6
- package/src/address_book/AddressBooks.js +1 -1
- package/src/address_book/Endpoint.js +1 -1
- package/src/address_book/NodeAddress.js +1 -1
- package/src/address_book/NodeAddressBook.js +1 -1
- package/src/channel/Channel.js +26 -2
- package/src/channel/NativeChannel.js +111 -2
- package/src/channel/NodeChannel.js +4 -7
- package/src/channel/WebChannel.js +189 -21
- package/src/client/Client.js +79 -5
- package/src/client/NativeClient.js +1 -1
- package/src/client/NodeClient.js +7 -6
- package/src/client/WebClient.js +64 -31
- package/src/client/addressbooks/mainnet.js +1 -1
- package/src/client/addressbooks/previewnet.js +1 -1
- package/src/client/addressbooks/testnet.js +1 -1
- package/src/constants/ClientConstants.js +16 -0
- package/src/contract/ContractByteCodeQuery.js +6 -6
- package/src/contract/ContractCallQuery.js +1 -1
- package/src/contract/ContractCreateTransaction.js +8 -8
- package/src/contract/ContractDeleteTransaction.js +8 -8
- package/src/contract/ContractExecuteTransaction.js +9 -9
- package/src/contract/ContractFunctionResult.js +2 -2
- package/src/contract/ContractId.js +1 -1
- package/src/contract/ContractInfo.js +1 -1
- package/src/contract/ContractInfoQuery.js +7 -7
- package/src/contract/ContractLogInfo.js +2 -2
- package/src/contract/ContractNonceInfo.js +3 -3
- package/src/contract/ContractStateChange.js +1 -1
- package/src/contract/ContractUpdateTransaction.js +10 -10
- package/src/contract/DelegateContractId.js +2 -2
- package/src/contract/StorageChange.js +1 -1
- package/src/exports.js +1 -1
- package/src/file/FileAppendTransaction.js +7 -7
- package/src/file/FileContentsQuery.js +7 -7
- package/src/file/FileCreateTransaction.js +6 -6
- package/src/file/FileDeleteTransaction.js +7 -7
- package/src/file/FileId.js +1 -1
- package/src/file/FileInfo.js +1 -1
- package/src/file/FileInfoQuery.js +7 -7
- package/src/file/FileUpdateTransaction.js +6 -6
- package/src/network/AddressBookQuery.js +1 -8
- package/src/network/AddressBookQueryWeb.js +1 -8
- package/src/network/NetworkVersionInfo.js +1 -1
- package/src/network/NetworkVersionInfoQuery.js +6 -6
- package/src/network/SemanticVersion.js +1 -1
- package/src/node/NodeCreateTransaction.js +6 -6
- package/src/node/NodeDeleteTransaction.js +6 -6
- package/src/node/NodeUpdateTransaction.js +6 -6
- package/src/node/ServiceEndpoint.js +1 -1
- package/src/query/CostQuery.js +1 -1
- package/src/query/Query.js +1 -1
- package/src/query/QueryBase.js +1 -1
- package/src/schedule/ScheduleCreateTransaction.js +1 -1
- package/src/schedule/ScheduleDeleteTransaction.js +8 -8
- package/src/schedule/ScheduleId.js +1 -1
- package/src/schedule/ScheduleInfo.js +1 -1
- package/src/schedule/ScheduleInfoQuery.js +7 -7
- package/src/schedule/ScheduleSignTransaction.js +10 -10
- package/src/system/FreezeTransaction.js +6 -6
- package/src/system/SystemDeleteTransaction.js +8 -8
- package/src/system/SystemUndeleteTransaction.js +8 -8
- package/src/token/AbstractTokenTransferTransaction.js +1 -1
- package/src/token/AssessedCustomFee.js +1 -1
- package/src/token/CustomFee.js +1 -1
- package/src/token/CustomFixedFee.js +3 -3
- package/src/token/CustomFractionalFee.js +3 -3
- package/src/token/CustomRoyaltyFee.js +4 -4
- package/src/token/NftId.js +1 -1
- package/src/token/PendingAirdropId.js +1 -1
- package/src/token/PendingAirdropRecord.js +1 -1
- package/src/token/TokenAirdropTransaction.js +8 -8
- package/src/token/TokenAssociateTransaction.js +7 -7
- package/src/token/TokenAssociation.js +1 -1
- package/src/token/TokenBurnTransaction.js +7 -7
- package/src/token/TokenCancelAirdropTransaction.js +6 -6
- package/src/token/TokenClaimAirdropTransaction.js +6 -6
- package/src/token/TokenCreateTransaction.js +7 -7
- package/src/token/TokenDeleteTransaction.js +7 -7
- package/src/token/TokenDissociateTransaction.js +7 -7
- package/src/token/TokenFeeScheduleUpdateTransaction.js +7 -7
- package/src/token/TokenFreezeTransaction.js +7 -7
- package/src/token/TokenGrantKycTransaction.js +7 -7
- package/src/token/TokenId.js +1 -1
- package/src/token/TokenInfo.js +1 -1
- package/src/token/TokenInfoQuery.js +7 -7
- package/src/token/TokenKeyValidation.js +1 -1
- package/src/token/TokenMintTransaction.js +7 -7
- package/src/token/TokenNftInfo.js +10 -10
- package/src/token/TokenNftInfoQuery.js +11 -11
- package/src/token/TokenNftTransfer.js +5 -5
- package/src/token/TokenNftsUpdateTransaction.js +7 -7
- package/src/token/TokenPauseTransaction.js +7 -7
- package/src/token/TokenReference.js +1 -1
- package/src/token/TokenRejectTransaction.js +7 -7
- package/src/token/TokenRevokeKycTransaction.js +7 -7
- package/src/token/TokenSupplyType.js +1 -1
- package/src/token/TokenTransfer.js +4 -4
- package/src/token/TokenType.js +1 -1
- package/src/token/TokenUnfreezeTransaction.js +7 -7
- package/src/token/TokenUnpauseTransaction.js +7 -7
- package/src/token/TokenUpdateNftsTransaction.js +7 -7
- package/src/token/TokenUpdateTransaction.js +7 -7
- package/src/token/TokenWipeTransaction.js +7 -7
- package/src/topic/TopicCreateTransaction.js +6 -6
- package/src/topic/TopicDeleteTransaction.js +6 -6
- package/src/topic/TopicId.js +1 -1
- package/src/topic/TopicInfo.js +1 -1
- package/src/topic/TopicInfoQuery.js +7 -7
- package/src/topic/TopicMessage.js +2 -2
- package/src/topic/TopicMessageChunk.js +2 -2
- package/src/topic/TopicMessageQuery.js +1 -1
- package/src/topic/TopicMessageSubmitTransaction.js +9 -9
- package/src/topic/TopicUpdateTransaction.js +6 -6
- package/src/transaction/BatchTransaction.js +5 -5
- package/src/transaction/CustomFeeLimit.js +2 -2
- package/src/transaction/NodeAccountIdSignatureMap.js +2 -2
- package/src/transaction/NodeAccountIdSignatureMapLegacy.js +1 -1
- package/src/transaction/SignatureMap.js +1 -1
- package/src/transaction/SignaturePairMap.js +1 -1
- package/src/transaction/Transaction.js +1 -1
- package/src/transaction/TransactionHashMap.js +1 -1
- package/src/transaction/TransactionId.js +1 -1
- package/src/transaction/TransactionReceipt.js +1 -1
- package/src/transaction/TransactionReceiptQuery.js +1 -1
- package/src/transaction/TransactionRecord.js +1 -1
- package/src/transaction/TransactionRecordQuery.js +1 -1
- package/src/util/ASN1-Decoder.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeChannel.js","sources":["../../src/channel/NodeChannel.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport tls from \"tls\";\nimport { Client, credentials, Metadata } from \"@grpc/grpc-js\";\nimport Channel from \"./Channel.js\";\nimport GrpcServicesError from \"../grpc/GrpcServiceError.js\";\nimport GrpcStatus from \"../grpc/GrpcStatus.js\";\nimport { ALL_NETWORK_IPS } from \"../constants/ClientConstants.js\";\nimport { SDK_NAME, SDK_VERSION } from \"../version.js\";\n\n/** @type {{ [key: string]: Client }} */\nconst clientCache = {};\n\nexport default class NodeChannel extends Channel {\n /**\n * @internal\n * @param {string} address\n * @param {number=}
|
|
1
|
+
{"version":3,"file":"NodeChannel.js","sources":["../../src/channel/NodeChannel.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport tls from \"tls\";\nimport { Client, credentials, Metadata } from \"@grpc/grpc-js\";\nimport Channel from \"./Channel.js\";\nimport GrpcServicesError from \"../grpc/GrpcServiceError.js\";\nimport GrpcStatus from \"../grpc/GrpcStatus.js\";\nimport { ALL_NETWORK_IPS } from \"../constants/ClientConstants.js\";\nimport { SDK_NAME, SDK_VERSION } from \"../version.js\";\n\n/** @type {{ [key: string]: Client }} */\nconst clientCache = {};\n\nexport default class NodeChannel extends Channel {\n /**\n * @internal\n * @param {string} address\n * @param {number=} grpcDeadline\n */\n constructor(address, grpcDeadline) {\n super(grpcDeadline);\n\n /** @type {Client | null} */\n this._client = null;\n\n this.address = address;\n\n const { ip, port } = this.parseAddress(address);\n this.nodeIp = ip;\n this.nodePort = port;\n }\n\n /**\n * Convert certificate bytes to PEM format\n * @param {Buffer} certBytes\n * @returns {string}\n */\n bytesToPem(certBytes) {\n const base64Cert = certBytes.toString(\"base64\");\n const lines = base64Cert.match(/.{1,64}/g)?.join(\"\\n\") || \"\";\n return `-----BEGIN CERTIFICATE-----\\n${lines}\\n-----END CERTIFICATE-----`;\n }\n\n /**\n * Validates and parses an address in the \"IP:Port\" format.\n * @param {string} address\n * @returns {{ ip: string, port: string }}\n */\n parseAddress(address) {\n const [ip, port] = address.split(\":\");\n if (!ip || !port) {\n throw new Error(\n \"Invalid address format. Expected format: 'IP:Port'\",\n );\n }\n return { ip, port };\n }\n\n /**\n * Retrieve the server's certificate dynamically.\n * @returns {Promise<string>}\n */\n async _retrieveCertificate() {\n return new Promise((resolve, reject) => {\n const socket = tls.connect(\n {\n host: this.nodeIp,\n port: Number(this.nodePort),\n rejectUnauthorized: false,\n },\n () => {\n try {\n const cert = socket.getPeerCertificate();\n\n if (cert && cert.raw) {\n resolve(this.bytesToPem(cert.raw));\n } else {\n reject(new Error(\"No certificate retrieved.\"));\n }\n } catch (err) {\n reject(err);\n } finally {\n socket.end();\n }\n },\n );\n\n socket.on(\"error\", reject);\n });\n }\n\n /**\n * Initialize the gRPC client\n * @returns {Promise<void>}\n */\n async _initializeClient() {\n if (clientCache[this.address]) {\n this._client = clientCache[this.address];\n return;\n }\n\n let security;\n const options = {\n \"grpc.ssl_target_name_override\": \"127.0.0.1\",\n \"grpc.default_authority\": \"127.0.0.1\",\n \"grpc.http_connect_creds\": \"0\",\n \"grpc.keepalive_time_ms\": 100000,\n \"grpc.keepalive_timeout_ms\": 10000,\n \"grpc.keepalive_permit_without_calls\": 1,\n \"grpc.enable_retries\": 1,\n };\n\n // If the port is 50212, use TLS\n if (this.nodePort === \"50212\") {\n const certificate = Buffer.from(await this._retrieveCertificate());\n\n security = credentials.createSsl(certificate);\n } else {\n security = credentials.createInsecure();\n }\n\n this._client = new Client(this.address, security, options);\n\n clientCache[this.address] = this._client;\n }\n\n /**\n * @override\n * @returns {void}\n */\n close() {\n if (this._client) {\n this._client.close();\n delete clientCache[this.address];\n }\n }\n\n /**\n * @override\n * @protected\n * @param {string} serviceName\n * @returns {import(\"protobufjs\").RPCImpl}\n */\n _createUnaryClient(serviceName) {\n return (method, requestData, callback) => {\n this._initializeClient()\n .then(() => {\n const deadline = new Date();\n const milliseconds = this.grpcDeadline;\n deadline.setMilliseconds(\n deadline.getMilliseconds() + milliseconds,\n );\n\n this._client?.waitForReady(deadline, (err) => {\n if (err) {\n callback(\n new GrpcServicesError(\n GrpcStatus.Timeout,\n // Added colons to the IP address to resolve a SonarCloud IP issue.\n ALL_NETWORK_IPS[`${this.nodeIp}:`],\n ),\n );\n } else {\n // Create metadata with user agent\n const metadata = new Metadata();\n\n metadata.set(\n \"x-user-agent\",\n `${SDK_NAME}/${SDK_VERSION}`,\n );\n\n this._client?.makeUnaryRequest(\n `/proto.${serviceName}/${method.name}`,\n (value) => value,\n (value) => value,\n Buffer.from(requestData),\n metadata,\n (e, r) => {\n callback(e, r);\n },\n );\n }\n });\n })\n .catch((err) => {\n if (err instanceof Error) {\n callback(err);\n } else {\n callback(new Error(\"An unexpected error occurred\"));\n }\n });\n };\n }\n}\n"],"names":["clientCache","NodeChannel","Channel","constructor","address","grpcDeadline","super","this","_client","ip","port","parseAddress","nodeIp","nodePort","bytesToPem","certBytes","base64Cert","toString","match","join","split","Error","_retrieveCertificate","Promise","resolve","reject","socket","tls","connect","host","Number","rejectUnauthorized","cert","getPeerCertificate","raw","err","end","on","_initializeClient","security","certificate","Buffer","from","credentials","createSsl","createInsecure","Client","close","_createUnaryClient","serviceName","method","requestData","callback","then","deadline","Date","milliseconds","setMilliseconds","getMilliseconds","waitForReady","GrpcServicesError","GrpcStatus","Timeout","ALL_NETWORK_IPS","metadata","Metadata","set","SDK_NAME","SDK_VERSION","makeUnaryRequest","name","value","e","r","catch"],"mappings":"iUAUA,MAAMA,EAAc,CAAE,EAEP,MAAMC,UAAoBC,EAMrC,WAAAC,CAAYC,EAASC,GACjBC,MAAMD,GAGNE,KAAKC,QAAU,KAEfD,KAAKH,QAAUA,EAEf,MAAMK,GAAEA,EAAEC,KAAEA,GAASH,KAAKI,aAAaP,GACvCG,KAAKK,OAASH,EACdF,KAAKM,SAAWH,CACxB,CAOI,UAAAI,CAAWC,GACP,MAAMC,EAAaD,EAAUE,SAAS,UAEtC,MAAO,gCADOD,EAAWE,MAAM,aAAaC,KAAK,OAAS,+BAElE,CAOI,YAAAR,CAAaP,GACT,MAAOK,EAAIC,GAAQN,EAAQgB,MAAM,KACjC,IAAKX,IAAOC,EACR,MAAM,IAAIW,MACN,sDAGR,MAAO,CAAEZ,KAAIC,OACrB,CAMI,0BAAMY,GACF,OAAO,IAAIC,QAAQ,CAACC,EAASC,KACzB,MAAMC,EAASC,EAAIC,QACf,CACIC,KAAMtB,KAAKK,OACXF,KAAMoB,OAAOvB,KAAKM,UAClBkB,oBAAoB,GAExB,KACI,IACI,MAAMC,EAAON,EAAOO,qBAEhBD,GAAQA,EAAKE,IACbV,EAAQjB,KAAKO,WAAWkB,EAAKE,MAE7BT,EAAO,IAAIJ,MAAM,6BAExB,CAAC,MAAOc,GACLV,EAAOU,EAC/B,CAA8B,QACNT,EAAOU,KAC/B,IAIYV,EAAOW,GAAG,QAASZ,IAE/B,CAMI,uBAAMa,GACF,GAAItC,EAAYO,KAAKH,SAEjB,YADAG,KAAKC,QAAUR,EAAYO,KAAKH,UAIpC,IAAImC,EAYJ,GAAsB,UAAlBhC,KAAKM,SAAsB,CAC3B,MAAM2B,EAAcC,OAAOC,WAAWnC,KAAKe,wBAE3CiB,EAAWI,EAAYC,UAAUJ,EAC7C,MACYD,EAAWI,EAAYE,iBAG3BtC,KAAKC,QAAU,IAAIsC,EAAOvC,KAAKH,QAASmC,EAnBxB,CACZ,gCAAiC,YACjC,yBAA0B,YAC1B,0BAA2B,IAC3B,yBAA0B,IAC1B,4BAA6B,IAC7B,sCAAuC,EACvC,sBAAuB,IAc3BvC,EAAYO,KAAKH,SAAWG,KAAKC,OACzC,CAMI,KAAAuC,GACQxC,KAAKC,UACLD,KAAKC,QAAQuC,eACN/C,EAAYO,KAAKH,SAEpC,CAQI,kBAAA4C,CAAmBC,GACf,MAAO,CAACC,EAAQC,EAAaC,KACzB7C,KAAK+B,oBACAe,KAAK,KACF,MAAMC,EAAW,IAAIC,KACfC,EAAejD,KAAKF,aAC1BiD,EAASG,gBACLH,EAASI,kBAAoBF,GAGjCjD,KAAKC,SAASmD,aAAaL,EAAWnB,IAClC,GAAIA,EACAiB,EACI,IAAIQ,EACAC,EAAWC,QAEXC,EAAgB,GAAGxD,KAAKK,iBAG7B,CAEH,MAAMoD,EAAW,IAAIC,EAErBD,EAASE,IACL,eACA,GAAGC,KAAYC,KAGnB7D,KAAKC,SAAS6D,iBACV,UAAUpB,KAAeC,EAAOoB,OAC/BC,GAAUA,EACVA,GAAUA,EACX9B,OAAOC,KAAKS,GACZa,EACA,CAACQ,EAAGC,KACArB,EAASoB,EAAGC,IAGhD,MAGiBC,MAAOvC,IACAA,aAAed,MACf+B,EAASjB,GAETiB,EAAS,IAAI/B,MAAM,mCAI3C"}
|
|
@@ -18,15 +18,161 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
18
18
|
class WebChannel extends _Channel.default {
|
|
19
19
|
/**
|
|
20
20
|
* @param {string} address
|
|
21
|
+
* @param {number=} grpcDeadline
|
|
21
22
|
*/
|
|
22
|
-
constructor(address) {
|
|
23
|
-
super();
|
|
23
|
+
constructor(address, grpcDeadline) {
|
|
24
|
+
super(grpcDeadline);
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* @type {string}
|
|
27
28
|
* @private
|
|
28
29
|
*/
|
|
29
30
|
this._address = address;
|
|
31
|
+
|
|
32
|
+
// Set the gRPC deadline using the base class method
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Flag indicating if the connection is ready (health check has passed)
|
|
36
|
+
* Set to true after the first successful health check
|
|
37
|
+
*
|
|
38
|
+
* @type {boolean}
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
this._isReady = false;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Promise that resolves when the health check is complete
|
|
45
|
+
* Used to prevent multiple concurrent health checks
|
|
46
|
+
*
|
|
47
|
+
* @type {Promise<void>|null}
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
this._healthCheckPromise = null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Determines whether to use HTTPS based on the address
|
|
55
|
+
* @param {string} address - The address to check
|
|
56
|
+
* @returns {boolean} - True if HTTPS should be used, false for HTTP
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
_shouldUseHttps(address) {
|
|
60
|
+
return !(address.includes("localhost") || address.includes("127.0.0.1"));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Builds the full URL with appropriate scheme (http/https)
|
|
65
|
+
* @param {string} address - The base address
|
|
66
|
+
* @returns {string} - The full URL with scheme
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
_buildUrl(address) {
|
|
70
|
+
// Check if address already contains a scheme
|
|
71
|
+
const hasScheme = address.startsWith("http://") || address.startsWith("https://");
|
|
72
|
+
if (hasScheme) {
|
|
73
|
+
// Use the address as-is if it already has a scheme
|
|
74
|
+
return address;
|
|
75
|
+
} else {
|
|
76
|
+
// Only prepend scheme if none exists
|
|
77
|
+
const shouldUseHttps = this._shouldUseHttps(address);
|
|
78
|
+
return shouldUseHttps ? `https://${address}` : `http://${address}`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Check if the gRPC-Web proxy is reachable and healthy
|
|
84
|
+
* Performs a POST request and verifies the response has gRPC-Web headers,
|
|
85
|
+
* which indicates the proxy is running and processing gRPC requests.
|
|
86
|
+
* Results are cached per address for the entire lifecycle.
|
|
87
|
+
* Uses promise-based synchronization to prevent multiple concurrent health checks.
|
|
88
|
+
*
|
|
89
|
+
* @param {Date} deadline - Deadline for the health check
|
|
90
|
+
* @returns {Promise<void>}
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
async _waitForReady(deadline) {
|
|
94
|
+
// Check if we've already validated this address
|
|
95
|
+
if (this._isReady) {
|
|
96
|
+
return; // Health check already passed for this address
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// If a health check is already in progress, wait for it to complete
|
|
100
|
+
if (this._healthCheckPromise) {
|
|
101
|
+
return this._healthCheckPromise;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Start a new health check and store the promise
|
|
105
|
+
this._healthCheckPromise = this._performHealthCheck(deadline);
|
|
106
|
+
try {
|
|
107
|
+
await this._healthCheckPromise;
|
|
108
|
+
} finally {
|
|
109
|
+
// Clear the promise when done (success or failure)
|
|
110
|
+
this._healthCheckPromise = null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Performs the actual health check request
|
|
116
|
+
* @param {Date} deadline - Deadline for the health check
|
|
117
|
+
* @returns {Promise<void>}
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
async _performHealthCheck(deadline) {
|
|
121
|
+
const address = this._buildUrl(this._address);
|
|
122
|
+
|
|
123
|
+
// Calculate remaining time until deadline
|
|
124
|
+
const timeoutMs = deadline.getTime() - Date.now();
|
|
125
|
+
if (timeoutMs <= 0) {
|
|
126
|
+
throw new _GrpcServiceError.default(_GrpcStatus.default.Timeout, _ClientConstants.ALL_WEB_NETWORK_NODES?.[this._address]?.toString());
|
|
127
|
+
}
|
|
128
|
+
const abortController = new AbortController();
|
|
129
|
+
const timeoutId = setTimeout(() => abortController.abort(), timeoutMs);
|
|
130
|
+
try {
|
|
131
|
+
// Make a POST request to verify the gRPC-Web proxy is running
|
|
132
|
+
// We use a minimal gRPC-Web compatible request
|
|
133
|
+
//eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
134
|
+
const response = await fetch(address, {
|
|
135
|
+
method: "POST",
|
|
136
|
+
headers: {
|
|
137
|
+
"content-type": "application/grpc-web+proto",
|
|
138
|
+
"x-user-agent": `${_version.SDK_NAME}/${_version.SDK_VERSION}`,
|
|
139
|
+
"x-grpc-web": "1"
|
|
140
|
+
},
|
|
141
|
+
body: new Uint8Array(0),
|
|
142
|
+
// Empty body for health check
|
|
143
|
+
signal: abortController.signal
|
|
144
|
+
});
|
|
145
|
+
clearTimeout(timeoutId);
|
|
146
|
+
|
|
147
|
+
// Check if response is successful (200) or indicates a redirect (3xx)
|
|
148
|
+
// 3xx status codes indicate the resource has moved, which is valid for proxies
|
|
149
|
+
if (response.ok || response.status >= 300 && response.status < 400) {
|
|
150
|
+
const grpcStatus = response.headers.get("grpc-status");
|
|
151
|
+
const grpcMessage = response.headers.get("grpc-message");
|
|
152
|
+
|
|
153
|
+
// If gRPC headers exist, the proxy is running and processing requests
|
|
154
|
+
if (grpcStatus != null || grpcMessage != null) {
|
|
155
|
+
// Mark this connection as ready
|
|
156
|
+
this._isReady = true;
|
|
157
|
+
return; // Healthy - gRPC-Web proxy is responding
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// If we get here, either status isn't 200/3xx or no gRPC headers present
|
|
162
|
+
// This means the proxy might not be configured correctly or not running
|
|
163
|
+
throw new _GrpcServiceError.default(_GrpcStatus.default.Unavailable, _ClientConstants.ALL_WEB_NETWORK_NODES?.[this._address]?.toString());
|
|
164
|
+
} catch (error) {
|
|
165
|
+
clearTimeout(timeoutId);
|
|
166
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
167
|
+
throw new _GrpcServiceError.default(_GrpcStatus.default.Timeout, _ClientConstants.ALL_WEB_NETWORK_NODES?.[this._address]?.toString());
|
|
168
|
+
}
|
|
169
|
+
if (error instanceof _GrpcServiceError.default) {
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Network error - server is not reachable
|
|
174
|
+
throw new _GrpcServiceError.default(_GrpcStatus.default.Unavailable, _ClientConstants.ALL_WEB_NETWORK_NODES?.[this._address]?.toString());
|
|
175
|
+
}
|
|
30
176
|
}
|
|
31
177
|
|
|
32
178
|
/**
|
|
@@ -46,18 +192,16 @@ class WebChannel extends _Channel.default {
|
|
|
46
192
|
_createUnaryClient(serviceName) {
|
|
47
193
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
48
194
|
return async (method, requestData, callback) => {
|
|
195
|
+
// Calculate deadline for connection check
|
|
196
|
+
const deadline = new Date();
|
|
197
|
+
const milliseconds = this._grpcDeadline;
|
|
198
|
+
deadline.setMilliseconds(deadline.getMilliseconds() + milliseconds);
|
|
49
199
|
try {
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
address = this._address;
|
|
56
|
-
} else {
|
|
57
|
-
// Only prepend scheme if none exists
|
|
58
|
-
const shouldUseHttps = !(this._address.includes("localhost") || this._address.includes("127.0.0.1"));
|
|
59
|
-
address = shouldUseHttps ? `https://${this._address}` : `http://${this._address}`;
|
|
60
|
-
}
|
|
200
|
+
// Wait for connection to be ready (similar to gRPC waitForReady)
|
|
201
|
+
await this._waitForReady(deadline);
|
|
202
|
+
|
|
203
|
+
// Build the full URL with appropriate scheme
|
|
204
|
+
const address = this._buildUrl(this._address);
|
|
61
205
|
// this will be executed in a browser environment so eslint is
|
|
62
206
|
// disabled for the fetch call
|
|
63
207
|
//eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
@@ -73,6 +217,7 @@ class WebChannel extends _Channel.default {
|
|
|
73
217
|
if (!response.ok) {
|
|
74
218
|
const error = new _HttpError.default(_HttpStatus.default._fromValue(response.status));
|
|
75
219
|
callback(error, null);
|
|
220
|
+
return;
|
|
76
221
|
}
|
|
77
222
|
|
|
78
223
|
// Check headers for gRPC errors
|
|
@@ -82,11 +227,16 @@ class WebChannel extends _Channel.default {
|
|
|
82
227
|
const error = new _GrpcServiceError.default(_GrpcStatus.default._fromValue(parseInt(grpcStatus)), _ClientConstants.ALL_WEB_NETWORK_NODES?.[this._address]?.toString());
|
|
83
228
|
error.message = grpcMessage;
|
|
84
229
|
callback(error, null);
|
|
230
|
+
return;
|
|
85
231
|
}
|
|
86
232
|
const responseBuffer = await response.arrayBuffer();
|
|
87
233
|
const unaryResponse = (0, _Channel.decodeUnaryResponse)(responseBuffer);
|
|
88
234
|
callback(null, unaryResponse);
|
|
89
235
|
} catch (error) {
|
|
236
|
+
if (error instanceof _GrpcServiceError.default) {
|
|
237
|
+
callback(error, null);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
90
240
|
const err = new _GrpcServiceError.default(
|
|
91
241
|
// retry on grpc web errors
|
|
92
242
|
_GrpcStatus.default._fromValue(18), _ClientConstants.ALL_WEB_NETWORK_NODES?.[this._address]?.toString());
|
|
@@ -1,12 +1,62 @@
|
|
|
1
1
|
export default class WebChannel extends Channel {
|
|
2
2
|
/**
|
|
3
3
|
* @param {string} address
|
|
4
|
+
* @param {number=} grpcDeadline
|
|
4
5
|
*/
|
|
5
|
-
constructor(address: string);
|
|
6
|
+
constructor(address: string, grpcDeadline?: number | undefined);
|
|
6
7
|
/**
|
|
7
8
|
* @type {string}
|
|
8
9
|
* @private
|
|
9
10
|
*/
|
|
10
11
|
private _address;
|
|
12
|
+
/**
|
|
13
|
+
* Flag indicating if the connection is ready (health check has passed)
|
|
14
|
+
* Set to true after the first successful health check
|
|
15
|
+
*
|
|
16
|
+
* @type {boolean}
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
private _isReady;
|
|
20
|
+
/**
|
|
21
|
+
* Promise that resolves when the health check is complete
|
|
22
|
+
* Used to prevent multiple concurrent health checks
|
|
23
|
+
*
|
|
24
|
+
* @type {Promise<void>|null}
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
private _healthCheckPromise;
|
|
28
|
+
/**
|
|
29
|
+
* Determines whether to use HTTPS based on the address
|
|
30
|
+
* @param {string} address - The address to check
|
|
31
|
+
* @returns {boolean} - True if HTTPS should be used, false for HTTP
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
private _shouldUseHttps;
|
|
35
|
+
/**
|
|
36
|
+
* Builds the full URL with appropriate scheme (http/https)
|
|
37
|
+
* @param {string} address - The base address
|
|
38
|
+
* @returns {string} - The full URL with scheme
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
private _buildUrl;
|
|
42
|
+
/**
|
|
43
|
+
* Check if the gRPC-Web proxy is reachable and healthy
|
|
44
|
+
* Performs a POST request and verifies the response has gRPC-Web headers,
|
|
45
|
+
* which indicates the proxy is running and processing gRPC requests.
|
|
46
|
+
* Results are cached per address for the entire lifecycle.
|
|
47
|
+
* Uses promise-based synchronization to prevent multiple concurrent health checks.
|
|
48
|
+
*
|
|
49
|
+
* @param {Date} deadline - Deadline for the health check
|
|
50
|
+
* @returns {Promise<void>}
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
private _waitForReady;
|
|
54
|
+
/**
|
|
55
|
+
* Performs the actual health check request
|
|
56
|
+
* @param {Date} deadline - Deadline for the health check
|
|
57
|
+
* @returns {Promise<void>}
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
private _performHealthCheck;
|
|
11
61
|
}
|
|
12
62
|
import Channel from "./Channel.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ALL_WEB_NETWORK_NODES as t}from"../constants/ClientConstants.js";import
|
|
1
|
+
import{ALL_WEB_NETWORK_NODES as t}from"../constants/ClientConstants.js";import e from"../grpc/GrpcServiceError.js";import s from"../grpc/GrpcStatus.js";import r from"../http/HttpError.js";import i from"../http/HttpStatus.js";import{SDK_NAME as a,SDK_VERSION as o}from"../version.js";import n,{encodeRequest as h,decodeUnaryResponse as l}from"./Channel.js";class c extends n{constructor(t,e){super(e),this._address=t,this._isReady=!1,this._healthCheckPromise=null}_shouldUseHttps(t){return!(t.includes("localhost")||t.includes("127.0.0.1"))}_buildUrl(t){if(t.startsWith("http://")||t.startsWith("https://"))return t;return this._shouldUseHttps(t)?`https://${t}`:`http://${t}`}async _waitForReady(t){if(!this._isReady){if(this._healthCheckPromise)return this._healthCheckPromise;this._healthCheckPromise=this._performHealthCheck(t);try{await this._healthCheckPromise}finally{this._healthCheckPromise=null}}}async _performHealthCheck(r){const i=this._buildUrl(this._address),n=r.getTime()-Date.now();if(n<=0)throw new e(s.Timeout,t?.[this._address]?.toString());const h=new AbortController,l=setTimeout(()=>h.abort(),n);try{const r=await fetch(i,{method:"POST",headers:{"content-type":"application/grpc-web+proto","x-user-agent":`${a}/${o}`,"x-grpc-web":"1"},body:new Uint8Array(0),signal:h.signal});if(clearTimeout(l),r.ok||r.status>=300&&r.status<400){const t=r.headers.get("grpc-status"),e=r.headers.get("grpc-message");if(null!=t||null!=e)return void(this._isReady=!0)}throw new e(s.Unavailable,t?.[this._address]?.toString())}catch(r){if(clearTimeout(l),r instanceof Error&&"AbortError"===r.name)throw new e(s.Timeout,t?.[this._address]?.toString());if(r instanceof e)throw r;throw new e(s.Unavailable,t?.[this._address]?.toString())}}close(){}_createUnaryClient(n){return async(c,d,u)=>{const p=new Date,m=this._grpcDeadline;p.setMilliseconds(p.getMilliseconds()+m);try{await this._waitForReady(p);const m=this._buildUrl(this._address),f=await fetch(`${m}/proto.${n}/${c.name}`,{method:"POST",headers:{"content-type":"application/grpc-web+proto","x-user-agent":`${a}/${o}`,"x-grpc-web":"1"},body:h(d)});if(!f.ok){return void u(new r(i._fromValue(f.status)),null)}const _=f.headers.get("grpc-status"),g=f.headers.get("grpc-message");if(null!=_&&null!=g){const r=new e(s._fromValue(parseInt(_)),t?.[this._address]?.toString());return r.message=g,void u(r,null)}const w=await f.arrayBuffer();u(null,l(w))}catch(r){if(r instanceof e)return void u(r,null);u(new e(s._fromValue(18),t?.[this._address]?.toString()),null)}}}}export{c as default};
|
|
2
2
|
//# sourceMappingURL=WebChannel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebChannel.js","sources":["../../src/channel/WebChannel.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { ALL_WEB_NETWORK_NODES } from \"../constants/ClientConstants.js\";\nimport GrpcServiceError from \"../grpc/GrpcServiceError.js\";\nimport GrpcStatus from \"../grpc/GrpcStatus.js\";\nimport HttpError from \"../http/HttpError.js\";\nimport HttpStatus from \"../http/HttpStatus.js\";\nimport { SDK_NAME, SDK_VERSION } from \"../version.js\";\nimport Channel, { encodeRequest, decodeUnaryResponse } from \"./Channel.js\";\n\nexport default class WebChannel extends Channel {\n /**\n * @param {string} address\n */\n constructor(address) {\n super();\n\n /**\n * @type {string}\n * @private\n */\n this._address = address;\n }\n\n /**\n * @override\n * @returns {void}\n */\n close() {\n // do nothing\n }\n\n /**\n * @override\n * @protected\n * @param {string} serviceName\n * @returns {import(\"protobufjs\").RPCImpl}\n */\n _createUnaryClient(serviceName) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return async (method, requestData, callback) => {\n try {\n // Check if address already contains a scheme\n const hasScheme =\n this._address.startsWith(\"http://\") ||\n this._address.startsWith(\"https://\");\n\n let address;\n if (hasScheme) {\n // Use the address as-is if it already has a scheme\n address = this._address;\n } else {\n // Only prepend scheme if none exists\n const shouldUseHttps = !(\n this._address.includes(\"localhost\") ||\n this._address.includes(\"127.0.0.1\")\n );\n\n address = shouldUseHttps\n ? `https://${this._address}`\n : `http://${this._address}`;\n }\n // this will be executed in a browser environment so eslint is\n // disabled for the fetch call\n //eslint-disable-next-line n/no-unsupported-features/node-builtins\n const response = await fetch(\n `${address}/proto.${serviceName}/${method.name}`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/grpc-web+proto\",\n \"x-user-agent\": `${SDK_NAME}/${SDK_VERSION}`,\n \"x-grpc-web\": \"1\",\n },\n body: encodeRequest(requestData),\n },\n );\n\n if (!response.ok) {\n const error = new HttpError(\n HttpStatus._fromValue(response.status),\n );\n callback(error, null);\n }\n\n // Check headers for gRPC errors\n const grpcStatus = response.headers.get(\"grpc-status\");\n const grpcMessage = response.headers.get(\"grpc-message\");\n\n if (grpcStatus != null && grpcMessage != null) {\n const error = new GrpcServiceError(\n GrpcStatus._fromValue(parseInt(grpcStatus)),\n ALL_WEB_NETWORK_NODES?.[this._address]?.toString(),\n );\n error.message = grpcMessage;\n callback(error, null);\n }\n\n const responseBuffer = await response.arrayBuffer();\n const unaryResponse = decodeUnaryResponse(responseBuffer);\n\n callback(null, unaryResponse);\n } catch (error) {\n const err = new GrpcServiceError(\n // retry on grpc web errors\n GrpcStatus._fromValue(18),\n ALL_WEB_NETWORK_NODES?.[this._address]?.toString(),\n );\n callback(err, null);\n }\n };\n }\n}\n"],"names":["WebChannel","Channel","constructor","address","super","this","_address","close","_createUnaryClient","serviceName","async","method","requestData","callback","startsWith","includes","response","fetch","name","headers","SDK_NAME","SDK_VERSION","body","encodeRequest","ok","HttpError","HttpStatus","_fromValue","status","grpcStatus","get","grpcMessage","error","GrpcServiceError","GrpcStatus","parseInt","ALL_WEB_NETWORK_NODES","toString","message","responseBuffer","arrayBuffer","decodeUnaryResponse"],"mappings":"oWASe,MAAMA,UAAmBC,EAIpC,WAAAC,CAAYC,GACRC,QAMAC,KAAKC,SAAWH,CACxB,CAMI,KAAAI,GAEJ,CAQI,kBAAAC,CAAmBC,GAEf,OAAOC,MAAOC,EAAQC,EAAaC,KAC/B,IAMI,IAAIV,EACJ,GAJIE,KAAKC,SAASQ,WAAW,YACzBT,KAAKC,SAASQ,WAAW,YAKzBX,EAAUE,KAAKC,aACZ,CAOHH,IAJIE,KAAKC,SAASS,SAAS,cACvBV,KAAKC,SAASS,SAAS,cAIrB,WAAWV,KAAKC,WAChB,UAAUD,KAAKC,UACzC,CAIgB,MAAMU,QAAiBC,MACnB,GAAGd,WAAiBM,KAAeE,EAAOO,OAC1C,CACIP,OAAQ,OACRQ,QAAS,CACL,eAAgB,6BAChB,eAAgB,GAAGC,KAAYC,IAC/B,aAAc,KAElBC,KAAMC,EAAcX,KAI5B,IAAKI,EAASQ,GAAI,CAIdX,EAHc,IAAIY,EACdC,EAAWC,WAAWX,EAASY,SAEnB,KACpC,CAGgB,MAAMC,EAAab,EAASG,QAAQW,IAAI,eAClCC,EAAcf,EAASG,QAAQW,IAAI,gBAEzC,GAAkB,MAAdD,GAAqC,MAAfE,EAAqB,CAC3C,MAAMC,EAAQ,IAAIC,EACdC,EAAWP,WAAWQ,SAASN,IAC/BO,IAAwB/B,KAAKC,WAAW+B,YAE5CL,EAAMM,QAAUP,EAChBlB,EAASmB,EAAO,KACpC,CAEgB,MAAMO,QAAuBvB,EAASwB,cAGtC3B,EAAS,KAFa4B,EAAoBF,GAG7C,CAAC,MAAOP,GAMLnB,EALY,IAAIoB,EAEZC,EAAWP,WAAW,IACtBS,IAAwB/B,KAAKC,WAAW+B,YAE9B,KAC9B,EAEA"}
|
|
1
|
+
{"version":3,"file":"WebChannel.js","sources":["../../src/channel/WebChannel.js"],"sourcesContent":["// SPDX-License-Identifier: Apache-2.0\nimport { ALL_WEB_NETWORK_NODES } from \"../constants/ClientConstants.js\";\nimport GrpcServiceError from \"../grpc/GrpcServiceError.js\";\nimport GrpcStatus from \"../grpc/GrpcStatus.js\";\nimport HttpError from \"../http/HttpError.js\";\nimport HttpStatus from \"../http/HttpStatus.js\";\nimport { SDK_NAME, SDK_VERSION } from \"../version.js\";\nimport Channel, { encodeRequest, decodeUnaryResponse } from \"./Channel.js\";\n\nexport default class WebChannel extends Channel {\n /**\n * @param {string} address\n * @param {number=} grpcDeadline\n */\n constructor(address, grpcDeadline) {\n super(grpcDeadline);\n\n /**\n * @type {string}\n * @private\n */\n this._address = address;\n\n // Set the gRPC deadline using the base class method\n\n /**\n * Flag indicating if the connection is ready (health check has passed)\n * Set to true after the first successful health check\n *\n * @type {boolean}\n * @private\n */\n this._isReady = false;\n\n /**\n * Promise that resolves when the health check is complete\n * Used to prevent multiple concurrent health checks\n *\n * @type {Promise<void>|null}\n * @private\n */\n this._healthCheckPromise = null;\n }\n\n /**\n * Determines whether to use HTTPS based on the address\n * @param {string} address - The address to check\n * @returns {boolean} - True if HTTPS should be used, false for HTTP\n * @private\n */\n _shouldUseHttps(address) {\n return !(\n address.includes(\"localhost\") || address.includes(\"127.0.0.1\")\n );\n }\n\n /**\n * Builds the full URL with appropriate scheme (http/https)\n * @param {string} address - The base address\n * @returns {string} - The full URL with scheme\n * @private\n */\n _buildUrl(address) {\n // Check if address already contains a scheme\n const hasScheme =\n address.startsWith(\"http://\") || address.startsWith(\"https://\");\n\n if (hasScheme) {\n // Use the address as-is if it already has a scheme\n return address;\n } else {\n // Only prepend scheme if none exists\n const shouldUseHttps = this._shouldUseHttps(address);\n return shouldUseHttps ? `https://${address}` : `http://${address}`;\n }\n }\n\n /**\n * Check if the gRPC-Web proxy is reachable and healthy\n * Performs a POST request and verifies the response has gRPC-Web headers,\n * which indicates the proxy is running and processing gRPC requests.\n * Results are cached per address for the entire lifecycle.\n * Uses promise-based synchronization to prevent multiple concurrent health checks.\n *\n * @param {Date} deadline - Deadline for the health check\n * @returns {Promise<void>}\n * @private\n */\n async _waitForReady(deadline) {\n // Check if we've already validated this address\n if (this._isReady) {\n return; // Health check already passed for this address\n }\n\n // If a health check is already in progress, wait for it to complete\n if (this._healthCheckPromise) {\n return this._healthCheckPromise;\n }\n\n // Start a new health check and store the promise\n this._healthCheckPromise = this._performHealthCheck(deadline);\n\n try {\n await this._healthCheckPromise;\n } finally {\n // Clear the promise when done (success or failure)\n this._healthCheckPromise = null;\n }\n }\n\n /**\n * Performs the actual health check request\n * @param {Date} deadline - Deadline for the health check\n * @returns {Promise<void>}\n * @private\n */\n async _performHealthCheck(deadline) {\n const address = this._buildUrl(this._address);\n\n // Calculate remaining time until deadline\n const timeoutMs = deadline.getTime() - Date.now();\n if (timeoutMs <= 0) {\n throw new GrpcServiceError(\n GrpcStatus.Timeout,\n ALL_WEB_NETWORK_NODES?.[this._address]?.toString(),\n );\n }\n\n const abortController = new AbortController();\n const timeoutId = setTimeout(() => abortController.abort(), timeoutMs);\n\n try {\n // Make a POST request to verify the gRPC-Web proxy is running\n // We use a minimal gRPC-Web compatible request\n //eslint-disable-next-line n/no-unsupported-features/node-builtins\n const response = await fetch(address, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/grpc-web+proto\",\n \"x-user-agent\": `${SDK_NAME}/${SDK_VERSION}`,\n \"x-grpc-web\": \"1\",\n },\n body: new Uint8Array(0), // Empty body for health check\n signal: abortController.signal,\n });\n\n clearTimeout(timeoutId);\n\n // Check if response is successful (200) or indicates a redirect (3xx)\n // 3xx status codes indicate the resource has moved, which is valid for proxies\n if (\n response.ok ||\n (response.status >= 300 && response.status < 400)\n ) {\n const grpcStatus = response.headers.get(\"grpc-status\");\n const grpcMessage = response.headers.get(\"grpc-message\");\n\n // If gRPC headers exist, the proxy is running and processing requests\n if (grpcStatus != null || grpcMessage != null) {\n // Mark this connection as ready\n this._isReady = true;\n return; // Healthy - gRPC-Web proxy is responding\n }\n }\n\n // If we get here, either status isn't 200/3xx or no gRPC headers present\n // This means the proxy might not be configured correctly or not running\n throw new GrpcServiceError(\n GrpcStatus.Unavailable,\n ALL_WEB_NETWORK_NODES?.[this._address]?.toString(),\n );\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof Error && error.name === \"AbortError\") {\n throw new GrpcServiceError(\n GrpcStatus.Timeout,\n ALL_WEB_NETWORK_NODES?.[this._address]?.toString(),\n );\n }\n\n if (error instanceof GrpcServiceError) {\n throw error;\n }\n\n // Network error - server is not reachable\n throw new GrpcServiceError(\n GrpcStatus.Unavailable,\n ALL_WEB_NETWORK_NODES?.[this._address]?.toString(),\n );\n }\n }\n\n /**\n * @override\n * @returns {void}\n */\n close() {\n // do nothing\n }\n\n /**\n * @override\n * @protected\n * @param {string} serviceName\n * @returns {import(\"protobufjs\").RPCImpl}\n */\n _createUnaryClient(serviceName) {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return async (method, requestData, callback) => {\n // Calculate deadline for connection check\n const deadline = new Date();\n const milliseconds = this._grpcDeadline;\n\n deadline.setMilliseconds(deadline.getMilliseconds() + milliseconds);\n\n try {\n // Wait for connection to be ready (similar to gRPC waitForReady)\n await this._waitForReady(deadline);\n\n // Build the full URL with appropriate scheme\n const address = this._buildUrl(this._address);\n // this will be executed in a browser environment so eslint is\n // disabled for the fetch call\n //eslint-disable-next-line n/no-unsupported-features/node-builtins\n const response = await fetch(\n `${address}/proto.${serviceName}/${method.name}`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/grpc-web+proto\",\n \"x-user-agent\": `${SDK_NAME}/${SDK_VERSION}`,\n \"x-grpc-web\": \"1\",\n },\n body: encodeRequest(requestData),\n },\n );\n\n if (!response.ok) {\n const error = new HttpError(\n HttpStatus._fromValue(response.status),\n );\n callback(error, null);\n return;\n }\n\n // Check headers for gRPC errors\n const grpcStatus = response.headers.get(\"grpc-status\");\n const grpcMessage = response.headers.get(\"grpc-message\");\n\n if (grpcStatus != null && grpcMessage != null) {\n const error = new GrpcServiceError(\n GrpcStatus._fromValue(parseInt(grpcStatus)),\n ALL_WEB_NETWORK_NODES?.[this._address]?.toString(),\n );\n error.message = grpcMessage;\n callback(error, null);\n return;\n }\n\n const responseBuffer = await response.arrayBuffer();\n const unaryResponse = decodeUnaryResponse(responseBuffer);\n\n callback(null, unaryResponse);\n } catch (error) {\n if (error instanceof GrpcServiceError) {\n callback(error, null);\n return;\n }\n\n const err = new GrpcServiceError(\n // retry on grpc web errors\n GrpcStatus._fromValue(18),\n ALL_WEB_NETWORK_NODES?.[this._address]?.toString(),\n );\n callback(err, null);\n }\n };\n }\n}\n"],"names":["WebChannel","Channel","constructor","address","grpcDeadline","super","this","_address","_isReady","_healthCheckPromise","_shouldUseHttps","includes","_buildUrl","startsWith","_waitForReady","deadline","_performHealthCheck","timeoutMs","getTime","Date","now","GrpcServiceError","GrpcStatus","Timeout","ALL_WEB_NETWORK_NODES","toString","abortController","AbortController","timeoutId","setTimeout","abort","response","fetch","method","headers","SDK_NAME","SDK_VERSION","body","Uint8Array","signal","clearTimeout","ok","status","grpcStatus","get","grpcMessage","Unavailable","error","Error","name","close","_createUnaryClient","serviceName","async","requestData","callback","milliseconds","_grpcDeadline","setMilliseconds","getMilliseconds","encodeRequest","HttpError","HttpStatus","_fromValue","parseInt","message","responseBuffer","arrayBuffer","decodeUnaryResponse"],"mappings":"oWASe,MAAMA,UAAmBC,EAKpC,WAAAC,CAAYC,EAASC,GACjBC,MAAMD,GAMNE,KAAKC,SAAWJ,EAWhBG,KAAKE,UAAW,EAShBF,KAAKG,oBAAsB,IACnC,CAQI,eAAAC,CAAgBP,GACZ,QACIA,EAAQQ,SAAS,cAAgBR,EAAQQ,SAAS,aAE9D,CAQI,SAAAC,CAAUT,GAKN,GAFIA,EAAQU,WAAW,YAAcV,EAAQU,WAAW,YAIpD,OAAOV,EAIP,OADuBG,KAAKI,gBAAgBP,GACpB,WAAWA,IAAY,UAAUA,GAErE,CAaI,mBAAMW,CAAcC,GAEhB,IAAIT,KAAKE,SAAT,CAKA,GAAIF,KAAKG,oBACL,OAAOH,KAAKG,oBAIhBH,KAAKG,oBAAsBH,KAAKU,oBAAoBD,GAEpD,UACUT,KAAKG,mBACvB,CAAkB,QAENH,KAAKG,oBAAsB,IACvC,CAfA,CAgBA,CAQI,yBAAMO,CAAoBD,GACtB,MAAMZ,EAAUG,KAAKM,UAAUN,KAAKC,UAG9BU,EAAYF,EAASG,UAAYC,KAAKC,MAC5C,GAAIH,GAAa,EACb,MAAM,IAAII,EACNC,EAAWC,QACXC,IAAwBlB,KAAKC,WAAWkB,YAIhD,MAAMC,EAAkB,IAAIC,gBACtBC,EAAYC,WAAW,IAAMH,EAAgBI,QAASb,GAE5D,IAII,MAAMc,QAAiBC,MAAM7B,EAAS,CAClC8B,OAAQ,OACRC,QAAS,CACL,eAAgB,6BAChB,eAAgB,GAAGC,KAAYC,IAC/B,aAAc,KAElBC,KAAM,IAAIC,WAAW,GACrBC,OAAQb,EAAgBa,SAO5B,GAJAC,aAAaZ,GAKTG,EAASU,IACRV,EAASW,QAAU,KAAOX,EAASW,OAAS,IAC/C,CACE,MAAMC,EAAaZ,EAASG,QAAQU,IAAI,eAClCC,EAAcd,EAASG,QAAQU,IAAI,gBAGzC,GAAkB,MAAdD,GAAqC,MAAfE,EAGtB,YADAvC,KAAKE,UAAW,EAGpC,CAIY,MAAM,IAAIa,EACNC,EAAWwB,YACXtB,IAAwBlB,KAAKC,WAAWkB,WAE/C,CAAC,MAAOsB,GAGL,GAFAP,aAAaZ,GAETmB,aAAiBC,OAAwB,eAAfD,EAAME,KAChC,MAAM,IAAI5B,EACNC,EAAWC,QACXC,IAAwBlB,KAAKC,WAAWkB,YAIhD,GAAIsB,aAAiB1B,EACjB,MAAM0B,EAIV,MAAM,IAAI1B,EACNC,EAAWwB,YACXtB,IAAwBlB,KAAKC,WAAWkB,WAExD,CACA,CAMI,KAAAyB,GAEJ,CAQI,kBAAAC,CAAmBC,GAEf,OAAOC,MAAOpB,EAAQqB,EAAaC,KAE/B,MAAMxC,EAAW,IAAII,KACfqC,EAAelD,KAAKmD,cAE1B1C,EAAS2C,gBAAgB3C,EAAS4C,kBAAoBH,GAEtD,UAEUlD,KAAKQ,cAAcC,GAGzB,MAAMZ,EAAUG,KAAKM,UAAUN,KAAKC,UAI9BwB,QAAiBC,MACnB,GAAG7B,WAAiBiD,KAAenB,EAAOgB,OAC1C,CACIhB,OAAQ,OACRC,QAAS,CACL,eAAgB,6BAChB,eAAgB,GAAGC,KAAYC,IAC/B,aAAc,KAElBC,KAAMuB,EAAcN,KAI5B,IAAKvB,EAASU,GAAI,CAKd,YADAc,EAHc,IAAIM,EACdC,EAAWC,WAAWhC,EAASW,SAEnB,KAEpC,CAGgB,MAAMC,EAAaZ,EAASG,QAAQU,IAAI,eAClCC,EAAcd,EAASG,QAAQU,IAAI,gBAEzC,GAAkB,MAAdD,GAAqC,MAAfE,EAAqB,CAC3C,MAAME,EAAQ,IAAI1B,EACdC,EAAWyC,WAAWC,SAASrB,IAC/BnB,IAAwBlB,KAAKC,WAAWkB,YAI5C,OAFAsB,EAAMkB,QAAUpB,OAChBU,EAASR,EAAO,KAEpC,CAEgB,MAAMmB,QAAuBnC,EAASoC,cAGtCZ,EAAS,KAFaa,EAAoBF,GAG7C,CAAC,MAAOnB,GACL,GAAIA,aAAiB1B,EAEjB,YADAkC,EAASR,EAAO,MASpBQ,EALY,IAAIlC,EAEZC,EAAWyC,WAAW,IACtBvC,IAAwBlB,KAAKC,WAAWkB,YAE9B,KAC9B,EAEA"}
|
package/lib/client/Client.cjs
CHANGED
|
@@ -16,6 +16,7 @@ var _FileId = _interopRequireDefault(require("../file/FileId.cjs"));
|
|
|
16
16
|
var _Logger = _interopRequireDefault(require("../logger/Logger.cjs"));
|
|
17
17
|
var _util = require("../util.cjs");
|
|
18
18
|
var _AddressBookQuery = _interopRequireDefault(require("../network/AddressBookQuery.cjs"));
|
|
19
|
+
var _ClientConstants = require("../constants/ClientConstants.cjs");
|
|
19
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
21
|
// SPDX-License-Identifier: Apache-2.0
|
|
21
22
|
|
|
@@ -48,6 +49,8 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
48
49
|
* @property {boolean} [scheduleNetworkUpdate]
|
|
49
50
|
* @property {number} [shard]
|
|
50
51
|
* @property {number} [realm]
|
|
52
|
+
* @property {number} [grpcDeadline]
|
|
53
|
+
* @property {number} [requestTimeout]
|
|
51
54
|
*/
|
|
52
55
|
|
|
53
56
|
/**
|
|
@@ -129,7 +132,10 @@ class Client {
|
|
|
129
132
|
this._defaultRegenerateTransactionId = true;
|
|
130
133
|
|
|
131
134
|
/** @private */
|
|
132
|
-
this._requestTimeout =
|
|
135
|
+
this._requestTimeout = _ClientConstants.DEFAULT_REQUEST_TIMEOUT;
|
|
136
|
+
|
|
137
|
+
/** @private */
|
|
138
|
+
this._grpcDeadline = _ClientConstants.DEFAULT_GRPC_DEADLINE;
|
|
133
139
|
|
|
134
140
|
/**
|
|
135
141
|
* @type {boolean}
|
|
@@ -152,6 +158,17 @@ class Client {
|
|
|
152
158
|
if (props != null && props.realm != null) {
|
|
153
159
|
this._realm = props.realm;
|
|
154
160
|
}
|
|
161
|
+
if (props != null && props.grpcDeadline != null) {
|
|
162
|
+
this.setGrpcDeadline(props.grpcDeadline);
|
|
163
|
+
}
|
|
164
|
+
if (props != null && props.requestTimeout != null) {
|
|
165
|
+
this.setRequestTimeout(props.requestTimeout);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Validate that requestTimeout is larger than grpcDeadline after both are set
|
|
169
|
+
if (this._requestTimeout <= this._grpcDeadline) {
|
|
170
|
+
console.warn(`DEPRECATION WARNING: requestTimeout (${this._requestTimeout}ms) should be larger than grpcDeadline (${this._grpcDeadline}ms). ` + `This configuration may cause operations to fail unexpectedly. ` + `This will throw an error in the next major version. Please adjust your timeout values.`);
|
|
171
|
+
}
|
|
155
172
|
|
|
156
173
|
/** @internal */
|
|
157
174
|
/** @type {NodeJS.Timeout} */
|
|
@@ -649,21 +666,57 @@ class Client {
|
|
|
649
666
|
}
|
|
650
667
|
|
|
651
668
|
/**
|
|
652
|
-
*
|
|
669
|
+
* Set the total request timeout for complete operations.
|
|
670
|
+
*
|
|
671
|
+
* @param {number} requestTimeout - Maximum time in milliseconds for complete Transaction/Query operations
|
|
653
672
|
* @returns {this}
|
|
654
673
|
*/
|
|
655
674
|
setRequestTimeout(requestTimeout) {
|
|
675
|
+
if (requestTimeout <= 0) {
|
|
676
|
+
throw new Error("requestTimeout must be a positive number");
|
|
677
|
+
}
|
|
678
|
+
if (requestTimeout <= this._grpcDeadline) {
|
|
679
|
+
console.warn(`DEPRECATION WARNING: requestTimeout (${requestTimeout}ms) should be larger than grpcDeadline (${this._grpcDeadline}ms). ` + `This configuration may cause operations to fail unexpectedly. ` + `This will throw an error in the next major version. Please adjust your timeout values.`);
|
|
680
|
+
}
|
|
656
681
|
this._requestTimeout = requestTimeout;
|
|
657
682
|
return this;
|
|
658
683
|
}
|
|
659
684
|
|
|
660
685
|
/**
|
|
661
|
-
*
|
|
686
|
+
* Get the total request timeout for complete operations.
|
|
687
|
+
*
|
|
688
|
+
* @returns {number} Maximum time in milliseconds for complete Transaction/Query operations
|
|
662
689
|
*/
|
|
663
690
|
get requestTimeout() {
|
|
664
691
|
return this._requestTimeout;
|
|
665
692
|
}
|
|
666
693
|
|
|
694
|
+
/**
|
|
695
|
+
* Set the global gRPC deadline for all requests.
|
|
696
|
+
*
|
|
697
|
+
* @param {number} grpcDeadline - Maximum time in milliseconds for a single gRPC request
|
|
698
|
+
* @returns {this}
|
|
699
|
+
*/
|
|
700
|
+
setGrpcDeadline(grpcDeadline) {
|
|
701
|
+
if (grpcDeadline <= 0) {
|
|
702
|
+
throw new Error("grpcDeadline must be a positive number");
|
|
703
|
+
}
|
|
704
|
+
if (grpcDeadline >= this._requestTimeout) {
|
|
705
|
+
console.warn(`DEPRECATION WARNING: grpcDeadline (${grpcDeadline}ms) should be smaller than requestTimeout (${this._requestTimeout}ms). ` + `This configuration may cause operations to fail unexpectedly. ` + `This will throw an error in the next major version. Please adjust your timeout values.`);
|
|
706
|
+
}
|
|
707
|
+
this._grpcDeadline = grpcDeadline;
|
|
708
|
+
return this;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Get the global gRPC deadline for all requests.
|
|
713
|
+
*
|
|
714
|
+
* @returns {number} Maximum time in milliseconds for a single gRPC request
|
|
715
|
+
*/
|
|
716
|
+
get grpcDeadline() {
|
|
717
|
+
return this._grpcDeadline;
|
|
718
|
+
}
|
|
719
|
+
|
|
667
720
|
/**
|
|
668
721
|
* @returns {number}
|
|
669
722
|
*/
|
|
@@ -752,7 +805,9 @@ class Client {
|
|
|
752
805
|
* @returns {(address: string) => ChannelT}
|
|
753
806
|
*/
|
|
754
807
|
_createNetworkChannel() {
|
|
755
|
-
|
|
808
|
+
return () => {
|
|
809
|
+
throw new Error("not implemented");
|
|
810
|
+
};
|
|
756
811
|
}
|
|
757
812
|
|
|
758
813
|
/**
|
|
@@ -760,7 +815,9 @@ class Client {
|
|
|
760
815
|
* @returns {(address: string) => MirrorChannelT}
|
|
761
816
|
*/
|
|
762
817
|
_createMirrorNetworkChannel() {
|
|
763
|
-
|
|
818
|
+
return () => {
|
|
819
|
+
throw new Error("not implemented");
|
|
820
|
+
};
|
|
764
821
|
}
|
|
765
822
|
|
|
766
823
|
/**
|
package/lib/client/Client.d.ts
CHANGED
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
* @property {boolean} [scheduleNetworkUpdate]
|
|
23
23
|
* @property {number} [shard]
|
|
24
24
|
* @property {number} [realm]
|
|
25
|
+
* @property {number} [grpcDeadline]
|
|
26
|
+
* @property {number} [requestTimeout]
|
|
25
27
|
*/
|
|
26
28
|
/**
|
|
27
29
|
* @typedef {"mainnet" | "testnet" | "previewnet"} NetworkName
|
|
@@ -108,6 +110,8 @@ export default class Client<ChannelT extends Channel, MirrorChannelT extends Mir
|
|
|
108
110
|
private _defaultRegenerateTransactionId;
|
|
109
111
|
/** @private */
|
|
110
112
|
private _requestTimeout;
|
|
113
|
+
/** @private */
|
|
114
|
+
private _grpcDeadline;
|
|
111
115
|
/**
|
|
112
116
|
* @type {boolean}
|
|
113
117
|
*/
|
|
@@ -405,14 +409,31 @@ export default class Client<ChannelT extends Channel, MirrorChannelT extends Mir
|
|
|
405
409
|
*/
|
|
406
410
|
get nodeMaxReadmitPeriod(): number;
|
|
407
411
|
/**
|
|
408
|
-
*
|
|
412
|
+
* Set the total request timeout for complete operations.
|
|
413
|
+
*
|
|
414
|
+
* @param {number} requestTimeout - Maximum time in milliseconds for complete Transaction/Query operations
|
|
409
415
|
* @returns {this}
|
|
410
416
|
*/
|
|
411
417
|
setRequestTimeout(requestTimeout: number): this;
|
|
412
418
|
/**
|
|
413
|
-
*
|
|
419
|
+
* Get the total request timeout for complete operations.
|
|
420
|
+
*
|
|
421
|
+
* @returns {number} Maximum time in milliseconds for complete Transaction/Query operations
|
|
422
|
+
*/
|
|
423
|
+
get requestTimeout(): number;
|
|
424
|
+
/**
|
|
425
|
+
* Set the global gRPC deadline for all requests.
|
|
426
|
+
*
|
|
427
|
+
* @param {number} grpcDeadline - Maximum time in milliseconds for a single gRPC request
|
|
428
|
+
* @returns {this}
|
|
429
|
+
*/
|
|
430
|
+
setGrpcDeadline(grpcDeadline: number): this;
|
|
431
|
+
/**
|
|
432
|
+
* Get the global gRPC deadline for all requests.
|
|
433
|
+
*
|
|
434
|
+
* @returns {number} Maximum time in milliseconds for a single gRPC request
|
|
414
435
|
*/
|
|
415
|
-
get
|
|
436
|
+
get grpcDeadline(): number;
|
|
416
437
|
/**
|
|
417
438
|
* @returns {number}
|
|
418
439
|
*/
|
|
@@ -489,6 +510,8 @@ export type ClientConfiguration = {
|
|
|
489
510
|
scheduleNetworkUpdate?: boolean | undefined;
|
|
490
511
|
shard?: number | undefined;
|
|
491
512
|
realm?: number | undefined;
|
|
513
|
+
grpcDeadline?: number | undefined;
|
|
514
|
+
requestTimeout?: number | undefined;
|
|
492
515
|
};
|
|
493
516
|
export type NetworkName = "mainnet" | "testnet" | "previewnet";
|
|
494
517
|
import MirrorNetwork from "./MirrorNetwork.js";
|
package/lib/client/Client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"../account/AccountId.js";import t from"../account/AccountBalanceQuery.js";import r from"../Hbar.js";import s from"./Network.js";import i from"./MirrorNetwork.js";import n from"../PublicKey.js";import o from"../PrivateKey.js";import a from"../LedgerId.js";import u from"../file/FileId.js";import"pino";import"../logger/LogLevel.js";import{convertToNumber as h}from"../util.js";import l from"../network/AddressBookQuery.js";import{DEFAULT_REQUEST_TIMEOUT as d,DEFAULT_GRPC_DEADLINE as m}from"../constants/ClientConstants.js";class c{constructor(e){this._mirrorNetwork=new i(this._createMirrorNetworkChannel()),this._network=new s(this._createNetworkChannel()),this._operator=null,this._defaultMaxTransactionFee=null,this._defaultMaxQueryPayment=new r(1),null!=e&&null!=e.operator&&this.setOperator(e.operator.accountId,e.operator.privateKey),this._maxAttempts=null,this._signOnDemand=!1,this._autoValidateChecksums=!1,this._minBackoff=250,this._maxBackoff=8e3,this._defaultRegenerateTransactionId=!0,this._requestTimeout=d,this._grpcDeadline=m,this._isUpdatingNetwork=!1,this._networkUpdatePeriod=864e5,this._isShutdown=!1,this._shard=0,this._realm=0,null!=e&&!1!==e.scheduleNetworkUpdate&&this._scheduleNetworkUpdate(),null!=e&&null!=e.shard&&(this._shard=e.shard),null!=e&&null!=e.realm&&(this._realm=e.realm),null!=e&&null!=e.grpcDeadline&&this.setGrpcDeadline(e.grpcDeadline),null!=e&&null!=e.requestTimeout&&this.setRequestTimeout(e.requestTimeout),this._requestTimeout<=this._grpcDeadline&&console.warn(`DEPRECATION WARNING: requestTimeout (${this._requestTimeout}ms) should be larger than grpcDeadline (${this._grpcDeadline}ms). This configuration may cause operations to fail unexpectedly. This will throw an error in the next major version. Please adjust your timeout values.`),this._timer,this._logger=null}setNetworkName(e){return console.warn("Deprecated: Use `setLedgerId` instead"),this.setLedgerId(e)}get networkName(){return console.warn("Deprecated: Use `ledgerId` instead"),null!=this.ledgerId?this.ledgerId.toString():null}setLedgerId(e){return this._network.setLedgerId("string"==typeof e?a.fromString(e):e),this}get ledgerId(){return null!=this._network._ledgerId?this._network.ledgerId:null}setNetwork(e){throw new Error("not implemented")}setNetworkFromAddressBook(e){return this._network.setNetworkFromAddressBook(e),this}get network(){return this._network.network}get shard(){return this._shard}get realm(){return this._realm}setMirrorNetwork(e){throw new Error("not implemented")}get mirrorNetwork(){return this._mirrorNetwork.network}get mirrorRestApiBaseUrl(){return this._mirrorNetwork.mirrorRestApiBaseUrl}get signOnDemand(){return this._signOnDemand}setSignOnDemand(e){this._signOnDemand=e}isTransportSecurity(){return this._network.isTransportSecurity()}setTransportSecurity(e){return this._network.setTransportSecurity(e),this}setOperator(e,t){const r="string"==typeof t?o.fromStringDer(t):t;return this.setOperatorWith(e,r.publicKey,e=>Promise.resolve(r.sign(e)))}getOperator(){return this._operator}setOperatorWith(t,r,s){const i=t instanceof e?t:e.fromString(t);return null!=this._network._ledgerId&&i.validateChecksum(this),this._operator={transactionSigner:s,accountId:i,publicKey:r instanceof n?r:n.fromString(r)},this}setAutoValidateChecksums(e){return this._autoValidateChecksums=e,this}isAutoValidateChecksumsEnabled(){return this._autoValidateChecksums}get operatorAccountId(){return null!=this._operator?this._operator.accountId:null}get operatorPublicKey(){return null!=this._operator?this._operator.publicKey:null}get defaultMaxTransactionFee(){return this._defaultMaxTransactionFee}get maxTransactionFee(){return this.defaultMaxTransactionFee}setDefaultMaxTransactionFee(e){if(e.toTinybars().toInt()<0)throw new Error("defaultMaxTransactionFee must be non-negative");return this._defaultMaxTransactionFee=e,this}setMaxTransactionFee(e){return this.setDefaultMaxTransactionFee(e)}get defaultRegenerateTransactionId(){return this._defaultRegenerateTransactionId}setDefaultRegenerateTransactionId(e){return this._defaultRegenerateTransactionId=e,this}get defaultMaxQueryPayment(){return this._defaultMaxQueryPayment}get maxQueryPayment(){return this.defaultMaxQueryPayment}setDefaultMaxQueryPayment(e){if(h(e.toTinybars())<0)throw new Error("defaultMaxQueryPayment must be non-negative");return this._defaultMaxQueryPayment=e,this}setMaxQueryPayment(e){return this.setDefaultMaxQueryPayment(e)}get maxAttempts(){return null!=this._maxAttempts?this._maxAttempts:10}setMaxAttempts(e){return this._maxAttempts=e,this}get maxNodeAttempts(){return this._network.maxNodeAttempts}setMaxNodeAttempts(e){return this._network.setMaxNodeAttempts(e),this}get nodeWaitTime(){return this._network.minBackoff}setNodeWaitTime(e){return this._network.setMinBackoff(e),this}get maxNodesPerTransaction(){return this._network.maxNodesPerTransaction}setMaxNodesPerTransaction(e){return this._network.setMaxNodesPerTransaction(e),this}setMinBackoff(e){if(null==e)throw new Error("minBackoff cannot be null.");if(e>this._maxBackoff)throw new Error("minBackoff cannot be larger than maxBackoff.");return this._minBackoff=e,this}get minBackoff(){return this._minBackoff}setMaxBackoff(e){if(null==e)throw new Error("maxBackoff cannot be null.");if(e<this._minBackoff)throw new Error("maxBackoff cannot be smaller than minBackoff.");return this._maxBackoff=e,this}get maxBackoff(){return this._maxBackoff}setNodeMinBackoff(e){return this._network.setMinBackoff(e),this}get nodeMinBackoff(){return this._network.minBackoff}setNodeMaxBackoff(e){return this._network.setMaxBackoff(e),this}get nodeMaxBackoff(){return this._network.maxBackoff}setNodeMinReadmitPeriod(e){return this._network.setNodeMinReadmitPeriod(e),this}get nodeMinReadmitPeriod(){return this._network.nodeMinReadmitPeriod}setNodeMaxReadmitPeriod(e){return this._network.setNodeMaxReadmitPeriod(e),this}get nodeMaxReadmitPeriod(){return this._network.nodeMaxReadmitPeriod}setRequestTimeout(e){if(e<=0)throw new Error("requestTimeout must be a positive number");return e<=this._grpcDeadline&&console.warn(`DEPRECATION WARNING: requestTimeout (${e}ms) should be larger than grpcDeadline (${this._grpcDeadline}ms). This configuration may cause operations to fail unexpectedly. This will throw an error in the next major version. Please adjust your timeout values.`),this._requestTimeout=e,this}get requestTimeout(){return this._requestTimeout}setGrpcDeadline(e){if(e<=0)throw new Error("grpcDeadline must be a positive number");return e>=this._requestTimeout&&console.warn(`DEPRECATION WARNING: grpcDeadline (${e}ms) should be smaller than requestTimeout (${this._requestTimeout}ms). This configuration may cause operations to fail unexpectedly. This will throw an error in the next major version. Please adjust your timeout values.`),this._grpcDeadline=e,this}get grpcDeadline(){return this._grpcDeadline}get networkUpdatePeriod(){return this._networkUpdatePeriod}setNetworkUpdatePeriod(e){return clearTimeout(this._timer),this._networkUpdatePeriod=e,this._scheduleNetworkUpdate(),this}setLogger(e){return this._logger=e,this}get logger(){return this._logger}async ping(r){await new t({accountId:r}).setNodeAccountIds([r instanceof e?r:e.fromString(r)]).execute(this)}async pingAll(){for(const e of Object.values(this._network.network))await this.ping(e)}async updateNetwork(){if(this._isUpdatingNetwork)return this;this._isUpdatingNetwork=!0;try{const e=await(new l).setFileId(u.getAddressBookFileIdFor(this._shard,this._realm)).execute(this);this.setNetworkFromAddressBook(e)}catch(e){this._logger&&this._logger.trace(`failed to update client address book: ${e.toString()}`)}finally{this._isUpdatingNetwork=!1}return this}close(){this._network.close(),this._mirrorNetwork.close(),this._isShutdown=!0,clearTimeout(this._timer)}_createNetworkChannel(){return()=>{throw new Error("not implemented")}}_createMirrorNetworkChannel(){return()=>{throw new Error("not implemented")}}_scheduleNetworkUpdate(){this._timer=setTimeout(async()=>{await this.updateNetwork(),this._isShutdown||this._scheduleNetworkUpdate()},this._networkUpdatePeriod)}get isClientShutDown(){return this._isShutdown}static _validateNetworkConsistency(e){if(0===Object.keys(e).length)return;const[,t]=Object.entries(e)[0],r=t.toString(),[s,i]=r.split(".").map(Number),n=Object.values(e).every(e=>{const t=e.toString(),[r,n]=t.split(".").map(Number);return r===s&&n===i});if(!n)throw new Error("Network is not valid, all nodes must be in the same shard and realm")}static _extractShardRealm(e){const t=Object.entries(e);if(0===t.length)return{shard:0,realm:0};const[,r]=t[0],s=r.toString(),[i,n]=s.split(".").map(Number);return{shard:i,realm:n}}}export{c as default};
|
|
2
2
|
//# sourceMappingURL=Client.js.map
|