import packageInfo from "../package.json" ; import { NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS , NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS , } from "@aws-sdk/config-resolver" ; import { Hash } from "@aws-sdk/hash-node" ; import { DEFAULT_RETRY_MODE , NODE_MAX_ATTEMPT_CONFIG_OPTIONS , NODE_RETRY_MODE_CONFIG_OPTIONS , } from "@aws-sdk/middleware-retry" ; import { loadConfig as loadNodeConfig } from "@aws-sdk/node-config-provider" ; import { NodeHttpHandler as RequestHandler , streamCollector } from "@aws-sdk/node-http-handler" ; import { fromBase64 , toBase64 } from "@aws-sdk/util-base64-node" ; import { calculateBodyLength } from "@aws-sdk/util-body-length-node" ; import { defaultUserAgent } from "@aws-sdk/util-user-agent-node" ; import { fromUtf8 , toUtf8 } from "@aws-sdk/util-utf8-node" ; import { RestXmlProtocolClientConfig } from "./RestXmlProtocolClient" ; import { getRuntimeConfig as getSharedRuntimeConfig } from "./runtimeConfig.shared" ; import { loadConfigsForDefaultMode } from "@aws-sdk/smithy-client" ; import { resolveDefaultsModeConfig } from "@aws-sdk/util-defaults-mode-node" ; internal export const getRuntimeConfig = ( config ) => { const defaultsMode = resolveDefaultsModeConfig ( config ) ; const defaultConfigProvider = ( ) => defaultsMode ( ) . then ( loadConfigsForDefaultMode ) ; const clientSharedValues = getSharedRuntimeConfig ( config ) ; return { ... clientSharedValues , ... config , runtime : "node" , defaultsMode , base64Decoder : config ?. base64Decoder ?? fromBase64 , base64Encoder : config ?. base64Encoder ?? toBase64 , bodyLengthChecker : config ?. bodyLengthChecker ?? calculateBodyLength , defaultUserAgentProvider : config ?. defaultUserAgentProvider ?? defaultUserAgent ( { serviceId : clientSharedValues . serviceId , clientVersion : packageInfo . version } ) , maxAttempts : config ?. maxAttempts ?? loadNodeConfig ( NODE_MAX_ATTEMPT_CONFIG_OPTIONS ) , requestHandler : config ?. requestHandler ?? new RequestHandler ( defaultConfigProvider ) , retryMode : config ?. retryMode ?? loadNodeConfig ( { ... NODE_RETRY_MODE_CONFIG_OPTIONS , default : async ( ) => ( await defaultConfigProvider ( ) ) . retryMode || DEFAULT_RETRY_MODE , } ) , sha256 : config ?. sha256 ?? Hash . bind ( null , "sha256" ) , streamCollector : config ?. streamCollector ?? streamCollector , useDualstackEndpoint : config ?. useDualstackEndpoint ?? loadNodeConfig ( NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS ) , useFipsEndpoint : config ?. useFipsEndpoint ?? loadNodeConfig ( NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS ) , utf8Decoder : config ?. utf8Decoder ?? fromUtf8 , utf8Encoder : config ?. utf8Encoder ?? toUtf8 , } ; } ;