@typespec/ts-http-runtime 1.0.0-alpha.20240214.1 → 1.0.0-alpha.20240223.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/abort-controller/AbortError.d.ts +22 -0
- package/dist/browser/abort-controller/AbortError.d.ts.map +1 -0
- package/dist/browser/abort-controller/AbortSignalLike.d.ts +19 -0
- package/dist/browser/abort-controller/AbortSignalLike.d.ts.map +1 -0
- package/dist/browser/accessTokenCache.d.ts +40 -0
- package/dist/browser/accessTokenCache.d.ts.map +1 -0
- package/dist/browser/accessTokenCache.js +34 -0
- package/dist/browser/accessTokenCache.js.map +1 -0
- package/dist/browser/auth/keyCredential.d.ts +10 -0
- package/dist/browser/auth/keyCredential.d.ts.map +1 -0
- package/dist/browser/auth/tokenCredential.d.ts +77 -0
- package/dist/browser/auth/tokenCredential.d.ts.map +1 -0
- package/dist/browser/auth/tokenCredential.js.map +1 -0
- package/dist/browser/client/apiVersionPolicy.d.ts +10 -0
- package/dist/browser/client/apiVersionPolicy.d.ts.map +1 -0
- package/dist/browser/client/apiVersionPolicy.js.map +1 -0
- package/dist/browser/client/clientHelpers.d.ts +28 -0
- package/dist/browser/client/clientHelpers.d.ts.map +1 -0
- package/dist/browser/client/clientHelpers.js +51 -0
- package/dist/browser/client/clientHelpers.js.map +1 -0
- package/dist/browser/client/common.d.ts +358 -0
- package/dist/browser/client/common.d.ts.map +1 -0
- package/dist/browser/client/common.js.map +1 -0
- package/dist/browser/client/getClient.d.ts +17 -0
- package/dist/browser/client/getClient.d.ts.map +1 -0
- package/dist/browser/client/getClient.js +84 -0
- package/dist/browser/client/getClient.js.map +1 -0
- package/dist/browser/client/helpers/getBinaryBody.d.ts +5 -0
- package/dist/browser/client/helpers/getBinaryBody.d.ts.map +1 -0
- package/dist/browser/client/keyCredentialAuthenticationPolicy.d.ts +8 -0
- package/dist/browser/client/keyCredentialAuthenticationPolicy.d.ts.map +1 -0
- package/dist/browser/client/keyCredentialAuthenticationPolicy.js.map +1 -0
- package/dist/browser/client/operationOptionHelpers.d.ts +8 -0
- package/dist/browser/client/operationOptionHelpers.d.ts.map +1 -0
- package/dist/browser/client/operationOptionHelpers.js +21 -0
- package/dist/browser/client/operationOptionHelpers.js.map +1 -0
- package/dist/browser/client/restError.d.ts +11 -0
- package/dist/browser/client/restError.d.ts.map +1 -0
- package/dist/browser/client/restError.js +29 -0
- package/dist/browser/client/restError.js.map +1 -0
- package/dist/browser/client/sendRequest.d.ts +30 -0
- package/dist/browser/client/sendRequest.d.ts.map +1 -0
- package/dist/browser/client/sendRequest.js +195 -0
- package/dist/browser/client/sendRequest.js.map +1 -0
- package/dist/browser/client/urlHelpers.d.ts +20 -0
- package/dist/browser/client/urlHelpers.d.ts.map +1 -0
- package/dist/browser/client/urlHelpers.js +99 -0
- package/dist/browser/client/urlHelpers.js.map +1 -0
- package/dist/browser/constants.d.ts +3 -0
- package/dist/browser/constants.d.ts.map +1 -0
- package/dist/browser/createPipelineFromOptions.d.ts +59 -0
- package/dist/browser/createPipelineFromOptions.d.ts.map +1 -0
- package/dist/browser/createPipelineFromOptions.js +44 -0
- package/dist/browser/createPipelineFromOptions.js.map +1 -0
- package/dist/browser/defaultHttpClient-browser.d.mts.map +1 -0
- package/dist/browser/defaultHttpClient-browser.mjs.map +1 -0
- package/dist/browser/defaultHttpClient.d.ts +6 -0
- package/dist/browser/defaultHttpClient.js +10 -0
- package/dist/browser/fetchHttpClient.d.ts +7 -0
- package/dist/browser/fetchHttpClient.d.ts.map +1 -0
- package/dist/browser/fetchHttpClient.js +262 -0
- package/dist/browser/fetchHttpClient.js.map +1 -0
- package/dist/browser/httpHeaders.d.ts +7 -0
- package/dist/browser/httpHeaders.d.ts.map +1 -0
- package/dist/browser/httpHeaders.js +89 -0
- package/dist/browser/httpHeaders.js.map +1 -0
- package/dist/browser/index.d.ts +56 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +43 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/interfaces.d.ts +447 -0
- package/dist/browser/interfaces.d.ts.map +1 -0
- package/dist/browser/interfaces.js.map +1 -0
- package/dist/browser/log.d.ts +2 -0
- package/dist/browser/log.d.ts.map +1 -0
- package/dist/browser/log.js +5 -0
- package/dist/browser/log.js.map +1 -0
- package/dist/browser/logger/debug.d.ts +63 -0
- package/dist/browser/logger/debug.d.ts.map +1 -0
- package/dist/browser/logger/debug.js +93 -0
- package/dist/browser/logger/debug.js.map +1 -0
- package/dist/browser/logger/log-browser.d.mts.map +1 -0
- package/dist/browser/logger/log-browser.mjs.map +1 -0
- package/dist/browser/logger/log.d.ts +2 -0
- package/dist/browser/logger/log.js +23 -0
- package/dist/browser/logger/logger.d.ts +68 -0
- package/dist/browser/logger/logger.d.ts.map +1 -0
- package/dist/browser/logger/logger.js +99 -0
- package/dist/browser/logger/logger.js.map +1 -0
- package/dist/browser/nodeHttpClient.d.ts +9 -0
- package/dist/browser/nodeHttpClient.d.ts.map +1 -0
- package/dist/browser/nodeHttpClient.js +330 -0
- package/dist/browser/nodeHttpClient.js.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/pipeline.d.ts +93 -0
- package/dist/browser/pipeline.d.ts.map +1 -0
- package/dist/browser/pipeline.js +262 -0
- package/dist/browser/pipeline.js.map +1 -0
- package/dist/browser/pipelineRequest.d.ts +93 -0
- package/dist/browser/pipelineRequest.d.ts.map +1 -0
- package/dist/browser/pipelineRequest.js +53 -0
- package/dist/browser/pipelineRequest.js.map +1 -0
- package/dist/browser/policies/bearerTokenAuthenticationPolicy.d.ts +99 -0
- package/dist/browser/policies/bearerTokenAuthenticationPolicy.d.ts.map +1 -0
- package/dist/browser/policies/bearerTokenAuthenticationPolicy.js +112 -0
- package/dist/browser/policies/bearerTokenAuthenticationPolicy.js.map +1 -0
- package/dist/browser/policies/decompressResponsePolicy-browser.d.mts.map +1 -0
- package/dist/browser/policies/decompressResponsePolicy-browser.mjs.map +1 -0
- package/dist/browser/policies/decompressResponsePolicy.d.ts +7 -0
- package/dist/browser/policies/decompressResponsePolicy.js +14 -0
- package/dist/browser/policies/defaultRetryPolicy.d.ts +19 -0
- package/dist/browser/policies/defaultRetryPolicy.d.ts.map +1 -0
- package/dist/browser/policies/defaultRetryPolicy.js +25 -0
- package/dist/browser/policies/defaultRetryPolicy.js.map +1 -0
- package/dist/browser/policies/exponentialRetryPolicy.d.ts +31 -0
- package/dist/browser/policies/exponentialRetryPolicy.d.ts.map +1 -0
- package/dist/browser/policies/exponentialRetryPolicy.js +24 -0
- package/dist/browser/policies/exponentialRetryPolicy.js.map +1 -0
- package/dist/browser/policies/formDataPolicy.d.ts +10 -0
- package/dist/browser/policies/formDataPolicy.d.ts.map +1 -0
- package/dist/browser/policies/formDataPolicy.js +81 -0
- package/dist/browser/policies/formDataPolicy.js.map +1 -0
- package/dist/browser/policies/logPolicy.d.ts +35 -0
- package/dist/browser/policies/logPolicy.d.ts.map +1 -0
- package/dist/browser/policies/logPolicy.js +33 -0
- package/dist/browser/policies/logPolicy.js.map +1 -0
- package/dist/browser/policies/multipartPolicy.d.ts +10 -0
- package/dist/browser/policies/multipartPolicy.d.ts.map +1 -0
- package/dist/browser/policies/multipartPolicy.js +111 -0
- package/dist/browser/policies/multipartPolicy.js.map +1 -0
- package/dist/browser/policies/proxyPolicy-browser.d.mts.map +1 -0
- package/dist/browser/policies/proxyPolicy-browser.mjs.map +1 -0
- package/dist/browser/policies/proxyPolicy.d.ts +15 -0
- package/dist/browser/policies/proxyPolicy.js +27 -0
- package/dist/browser/policies/redirectPolicy.d.ts +23 -0
- package/dist/browser/policies/redirectPolicy.d.ts.map +1 -0
- package/dist/browser/policies/redirectPolicy.js.map +1 -0
- package/dist/browser/policies/retryPolicy.d.ts +21 -0
- package/dist/browser/policies/retryPolicy.d.ts.map +1 -0
- package/dist/browser/policies/retryPolicy.js +105 -0
- package/dist/browser/policies/retryPolicy.js.map +1 -0
- package/dist/browser/policies/systemErrorRetryPolicy.d.ts +33 -0
- package/dist/browser/policies/systemErrorRetryPolicy.d.ts.map +1 -0
- package/dist/browser/policies/systemErrorRetryPolicy.js +29 -0
- package/dist/browser/policies/systemErrorRetryPolicy.js.map +1 -0
- package/dist/browser/policies/throttlingRetryPolicy.d.ts +26 -0
- package/dist/browser/policies/throttlingRetryPolicy.d.ts.map +1 -0
- package/dist/browser/policies/throttlingRetryPolicy.js +28 -0
- package/dist/browser/policies/throttlingRetryPolicy.js.map +1 -0
- package/dist/browser/policies/tlsPolicy.d.ts +11 -0
- package/dist/browser/policies/tlsPolicy.d.ts.map +1 -0
- package/dist/browser/policies/tlsPolicy.js.map +1 -0
- package/dist/browser/policies/tracingPolicy.d.ts +24 -0
- package/dist/browser/policies/tracingPolicy.d.ts.map +1 -0
- package/dist/browser/policies/tracingPolicy.js +119 -0
- package/dist/browser/policies/tracingPolicy.js.map +1 -0
- package/dist/browser/policies/userAgentPolicy.d.ts +22 -0
- package/dist/browser/policies/userAgentPolicy.d.ts.map +1 -0
- package/dist/browser/policies/userAgentPolicy.js +26 -0
- package/dist/browser/policies/userAgentPolicy.js.map +1 -0
- package/dist/browser/restError.d.ts +65 -0
- package/dist/browser/restError.d.ts.map +1 -0
- package/dist/browser/restError.js +68 -0
- package/dist/browser/restError.js.map +1 -0
- package/dist/browser/retryStrategies/exponentialRetryStrategy.d.ts +40 -0
- package/dist/browser/retryStrategies/exponentialRetryStrategy.d.ts.map +1 -0
- package/dist/browser/retryStrategies/exponentialRetryStrategy.js +69 -0
- package/dist/browser/retryStrategies/exponentialRetryStrategy.js.map +1 -0
- package/dist/browser/retryStrategies/retryStrategy.d.ts +61 -0
- package/dist/browser/retryStrategies/retryStrategy.d.ts.map +1 -0
- package/dist/browser/retryStrategies/retryStrategy.js.map +1 -0
- package/dist/browser/retryStrategies/throttlingRetryStrategy.d.ts +9 -0
- package/dist/browser/retryStrategies/throttlingRetryStrategy.d.ts.map +1 -0
- package/dist/browser/retryStrategies/throttlingRetryStrategy.js +74 -0
- package/dist/browser/retryStrategies/throttlingRetryStrategy.js.map +1 -0
- package/dist/browser/tracing/instrumenter.d.ts +16 -0
- package/dist/browser/tracing/instrumenter.d.ts.map +1 -0
- package/dist/browser/tracing/instrumenter.js +61 -0
- package/dist/browser/tracing/instrumenter.js.map +1 -0
- package/dist/browser/tracing/interfaces.d.ts +254 -0
- package/dist/browser/tracing/interfaces.d.ts.map +1 -0
- package/dist/browser/tracing/tracingClient.d.ts +9 -0
- package/dist/browser/tracing/tracingClient.d.ts.map +1 -0
- package/dist/browser/tracing/tracingClient.js +78 -0
- package/dist/browser/tracing/tracingClient.js.map +1 -0
- package/dist/browser/tracing/tracingContext.d.ts +34 -0
- package/dist/browser/tracing/tracingContext.d.ts.map +1 -0
- package/dist/browser/tracing/tracingContext.js +48 -0
- package/dist/browser/tracing/tracingContext.js.map +1 -0
- package/dist/browser/util/aborterUtils.d.ts +27 -0
- package/dist/browser/util/aborterUtils.d.ts.map +1 -0
- package/dist/browser/util/aborterUtils.js +20 -0
- package/dist/browser/util/aborterUtils.js.map +1 -0
- package/dist/browser/util/bytesEncoding-browser.d.mts.map +1 -0
- package/dist/browser/util/bytesEncoding-browser.mjs.map +1 -0
- package/dist/browser/util/bytesEncoding.d.ts +61 -0
- package/dist/browser/util/bytesEncoding.js +110 -0
- package/dist/browser/util/checkEnvironment.d.ts +37 -0
- package/dist/browser/util/checkEnvironment.d.ts.map +1 -0
- package/dist/browser/util/checkEnvironment.js +40 -0
- package/dist/browser/util/checkEnvironment.js.map +1 -0
- package/dist/browser/util/createAbortablePromise.d.ts +16 -0
- package/dist/browser/util/createAbortablePromise.d.ts.map +1 -0
- package/dist/browser/util/createAbortablePromise.js +42 -0
- package/dist/browser/util/createAbortablePromise.js.map +1 -0
- package/dist/browser/util/delay.d.ts +14 -0
- package/dist/browser/util/delay.d.ts.map +1 -0
- package/dist/browser/util/delay.js +22 -0
- package/dist/browser/util/delay.js.map +1 -0
- package/dist/browser/util/error.d.ts +13 -0
- package/dist/browser/util/error.d.ts.map +1 -0
- package/dist/browser/util/error.js +42 -0
- package/dist/browser/util/error.js.map +1 -0
- package/dist/browser/util/file.d.ts +62 -0
- package/dist/browser/util/file.d.ts.map +1 -0
- package/dist/browser/util/file.js +66 -0
- package/dist/browser/util/file.js.map +1 -0
- package/dist/browser/util/helpers.d.ts +21 -0
- package/dist/browser/util/helpers.d.ts.map +1 -0
- package/dist/browser/util/helpers.js +58 -0
- package/dist/browser/util/helpers.js.map +1 -0
- package/dist/browser/util/inspect-browser.d.mts.map +1 -0
- package/dist/browser/util/inspect-browser.mjs.map +1 -0
- package/dist/browser/util/inspect.d.ts +2 -0
- package/dist/browser/util/inspect.js +4 -0
- package/dist/browser/util/object.d.ts +12 -0
- package/dist/browser/util/object.d.ts.map +1 -0
- package/dist/browser/util/random.d.ts +10 -0
- package/dist/browser/util/random.d.ts.map +1 -0
- package/dist/browser/util/sanitizer.d.ts +30 -0
- package/dist/browser/util/sanitizer.d.ts.map +1 -0
- package/dist/browser/util/sanitizer.js +145 -0
- package/dist/browser/util/sanitizer.js.map +1 -0
- package/dist/browser/util/sha256-browser.d.mts.map +1 -0
- package/dist/browser/util/sha256-browser.mjs.map +1 -0
- package/dist/browser/util/sha256.d.ts +14 -0
- package/dist/browser/util/sha256.js +49 -0
- package/dist/browser/util/stream-browser.d.mts.map +1 -0
- package/dist/browser/util/stream-browser.mjs.map +1 -0
- package/dist/browser/util/stream.d.ts +5 -0
- package/dist/browser/util/stream.js +62 -0
- package/dist/browser/util/tokenCycler.d.ts +45 -0
- package/dist/browser/util/tokenCycler.d.ts.map +1 -0
- package/dist/browser/util/tokenCycler.js +150 -0
- package/dist/browser/util/tokenCycler.js.map +1 -0
- package/dist/browser/util/typeGuards.d.ts +23 -0
- package/dist/browser/util/typeGuards.d.ts.map +1 -0
- package/dist/browser/util/userAgent.d.ts +9 -0
- package/dist/browser/util/userAgent.d.ts.map +1 -0
- package/dist/browser/util/userAgent.js +30 -0
- package/dist/browser/util/userAgent.js.map +1 -0
- package/dist/browser/util/userAgentPlatform-browser.d.mts.map +1 -0
- package/dist/browser/util/userAgentPlatform-browser.mjs.map +1 -0
- package/dist/browser/util/userAgentPlatform.d.ts +9 -0
- package/dist/browser/util/userAgentPlatform.js +19 -0
- package/dist/browser/util/uuidUtils-browser.d.mts.map +1 -0
- package/dist/browser/util/uuidUtils-browser.mjs.map +1 -0
- package/dist/browser/util/uuidUtils.common.d.ts +13 -0
- package/dist/browser/util/uuidUtils.common.d.ts.map +1 -0
- package/dist/browser/util/uuidUtils.common.js +43 -0
- package/dist/browser/util/uuidUtils.common.js.map +1 -0
- package/dist/browser/util/uuidUtils.d.ts +7 -0
- package/dist/browser/util/uuidUtils.js +16 -0
- package/dist/browser/xhrHttpClient.d.ts +7 -0
- package/dist/browser/xhrHttpClient.d.ts.map +1 -0
- package/dist/browser/xhrHttpClient.js +165 -0
- package/dist/browser/xhrHttpClient.js.map +1 -0
- package/dist/commonjs/abort-controller/AbortError.d.ts +22 -0
- package/dist/commonjs/abort-controller/AbortError.d.ts.map +1 -0
- package/dist/commonjs/abort-controller/AbortError.js +31 -0
- package/dist/commonjs/abort-controller/AbortError.js.map +1 -0
- package/dist/commonjs/abort-controller/AbortSignalLike.d.ts +19 -0
- package/dist/commonjs/abort-controller/AbortSignalLike.d.ts.map +1 -0
- package/dist/commonjs/abort-controller/AbortSignalLike.js +5 -0
- package/dist/commonjs/abort-controller/AbortSignalLike.js.map +1 -0
- package/dist/commonjs/accessTokenCache.d.ts +40 -0
- package/dist/commonjs/accessTokenCache.d.ts.map +1 -0
- package/dist/commonjs/accessTokenCache.js +38 -0
- package/dist/commonjs/accessTokenCache.js.map +1 -0
- package/dist/commonjs/auth/keyCredential.d.ts +10 -0
- package/dist/commonjs/auth/keyCredential.d.ts.map +1 -0
- package/dist/commonjs/auth/keyCredential.js +5 -0
- package/dist/commonjs/auth/keyCredential.js.map +1 -0
- package/dist/commonjs/auth/tokenCredential.d.ts +77 -0
- package/dist/commonjs/auth/tokenCredential.d.ts.map +1 -0
- package/dist/commonjs/auth/tokenCredential.js +23 -0
- package/dist/commonjs/auth/tokenCredential.js.map +1 -0
- package/dist/commonjs/client/apiVersionPolicy.d.ts +10 -0
- package/dist/commonjs/client/apiVersionPolicy.d.ts.map +1 -0
- package/dist/commonjs/client/apiVersionPolicy.js +27 -0
- package/dist/commonjs/client/apiVersionPolicy.js.map +1 -0
- package/dist/commonjs/client/clientHelpers.d.ts +28 -0
- package/dist/commonjs/client/clientHelpers.d.ts.map +1 -0
- package/dist/commonjs/client/clientHelpers.js +57 -0
- package/dist/commonjs/client/clientHelpers.js.map +1 -0
- package/dist/commonjs/client/common.d.ts +358 -0
- package/dist/commonjs/client/common.d.ts.map +1 -0
- package/dist/commonjs/client/common.js +5 -0
- package/dist/commonjs/client/common.js.map +1 -0
- package/dist/commonjs/client/getClient.d.ts +17 -0
- package/dist/commonjs/client/getClient.d.ts.map +1 -0
- package/dist/commonjs/client/getClient.js +88 -0
- package/dist/commonjs/client/getClient.js.map +1 -0
- package/dist/commonjs/client/helpers/getBinaryBody.d.ts +5 -0
- package/dist/commonjs/client/helpers/getBinaryBody.d.ts.map +1 -0
- package/dist/commonjs/client/helpers/getBinaryBody.js +17 -0
- package/dist/commonjs/client/helpers/getBinaryBody.js.map +1 -0
- package/dist/commonjs/client/keyCredentialAuthenticationPolicy.d.ts +8 -0
- package/dist/commonjs/client/keyCredentialAuthenticationPolicy.d.ts.map +1 -0
- package/dist/commonjs/client/keyCredentialAuthenticationPolicy.js +20 -0
- package/dist/commonjs/client/keyCredentialAuthenticationPolicy.js.map +1 -0
- package/dist/commonjs/client/operationOptionHelpers.d.ts +8 -0
- package/dist/commonjs/client/operationOptionHelpers.d.ts.map +1 -0
- package/dist/commonjs/client/operationOptionHelpers.js +25 -0
- package/dist/commonjs/client/operationOptionHelpers.js.map +1 -0
- package/dist/commonjs/client/restError.d.ts +11 -0
- package/dist/commonjs/client/restError.d.ts.map +1 -0
- package/dist/commonjs/client/restError.js +33 -0
- package/dist/commonjs/client/restError.js.map +1 -0
- package/dist/commonjs/client/sendRequest.d.ts +30 -0
- package/dist/commonjs/client/sendRequest.d.ts.map +1 -0
- package/dist/commonjs/client/sendRequest.js +200 -0
- package/dist/commonjs/client/sendRequest.js.map +1 -0
- package/dist/commonjs/client/urlHelpers.d.ts +20 -0
- package/dist/commonjs/client/urlHelpers.d.ts.map +1 -0
- package/dist/commonjs/client/urlHelpers.js +105 -0
- package/dist/commonjs/client/urlHelpers.js.map +1 -0
- package/dist/commonjs/constants.d.ts +3 -0
- package/dist/commonjs/constants.d.ts.map +1 -0
- package/dist/commonjs/constants.js +8 -0
- package/dist/commonjs/constants.js.map +1 -0
- package/dist/commonjs/createPipelineFromOptions.d.ts +59 -0
- package/dist/commonjs/createPipelineFromOptions.d.ts.map +1 -0
- package/dist/commonjs/createPipelineFromOptions.js +48 -0
- package/dist/commonjs/createPipelineFromOptions.js.map +1 -0
- package/dist/commonjs/defaultHttpClient.d.ts +6 -0
- package/dist/commonjs/defaultHttpClient.d.ts.map +1 -0
- package/dist/commonjs/defaultHttpClient.js +14 -0
- package/dist/commonjs/defaultHttpClient.js.map +1 -0
- package/dist/commonjs/fetchHttpClient.d.ts +7 -0
- package/dist/commonjs/fetchHttpClient.d.ts.map +1 -0
- package/dist/commonjs/fetchHttpClient.js +266 -0
- package/dist/commonjs/fetchHttpClient.js.map +1 -0
- package/dist/commonjs/httpHeaders.d.ts +7 -0
- package/dist/commonjs/httpHeaders.d.ts.map +1 -0
- package/dist/commonjs/httpHeaders.js +93 -0
- package/dist/commonjs/httpHeaders.js.map +1 -0
- package/dist/commonjs/index.d.ts +56 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +107 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/interfaces.d.ts +447 -0
- package/dist/commonjs/interfaces.d.ts.map +1 -0
- package/dist/commonjs/interfaces.js +5 -0
- package/dist/commonjs/interfaces.js.map +1 -0
- package/dist/commonjs/log.d.ts +2 -0
- package/dist/commonjs/log.d.ts.map +1 -0
- package/dist/commonjs/log.js +8 -0
- package/dist/commonjs/log.js.map +1 -0
- package/dist/commonjs/logger/debug.d.ts +63 -0
- package/dist/commonjs/logger/debug.d.ts.map +1 -0
- package/dist/commonjs/logger/debug.js +95 -0
- package/dist/commonjs/logger/debug.js.map +1 -0
- package/dist/commonjs/logger/log.d.ts +2 -0
- package/dist/commonjs/logger/log.d.ts.map +1 -0
- package/dist/commonjs/logger/log.js +14 -0
- package/dist/commonjs/logger/log.js.map +1 -0
- package/dist/commonjs/logger/logger.d.ts +68 -0
- package/dist/commonjs/logger/logger.d.ts.map +1 -0
- package/dist/commonjs/logger/logger.js +106 -0
- package/dist/commonjs/logger/logger.js.map +1 -0
- package/dist/commonjs/nodeHttpClient.d.ts +9 -0
- package/dist/commonjs/nodeHttpClient.d.ts.map +1 -0
- package/dist/commonjs/nodeHttpClient.js +336 -0
- package/dist/commonjs/nodeHttpClient.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/pipeline.d.ts +93 -0
- package/dist/commonjs/pipeline.d.ts.map +1 -0
- package/dist/commonjs/pipeline.js +266 -0
- package/dist/commonjs/pipeline.js.map +1 -0
- package/dist/commonjs/pipelineRequest.d.ts +93 -0
- package/dist/commonjs/pipelineRequest.d.ts.map +1 -0
- package/dist/commonjs/pipelineRequest.js +57 -0
- package/dist/commonjs/pipelineRequest.js.map +1 -0
- package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.d.ts +99 -0
- package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.js +116 -0
- package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.js.map +1 -0
- package/dist/commonjs/policies/decompressResponsePolicy.d.ts +11 -0
- package/dist/commonjs/policies/decompressResponsePolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/decompressResponsePolicy.js +27 -0
- package/dist/commonjs/policies/decompressResponsePolicy.js.map +1 -0
- package/dist/commonjs/policies/defaultRetryPolicy.d.ts +19 -0
- package/dist/commonjs/policies/defaultRetryPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/defaultRetryPolicy.js +29 -0
- package/dist/commonjs/policies/defaultRetryPolicy.js.map +1 -0
- package/dist/commonjs/policies/exponentialRetryPolicy.d.ts +31 -0
- package/dist/commonjs/policies/exponentialRetryPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/exponentialRetryPolicy.js +28 -0
- package/dist/commonjs/policies/exponentialRetryPolicy.js.map +1 -0
- package/dist/commonjs/policies/formDataPolicy.d.ts +10 -0
- package/dist/commonjs/policies/formDataPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/formDataPolicy.js +85 -0
- package/dist/commonjs/policies/formDataPolicy.js.map +1 -0
- package/dist/commonjs/policies/logPolicy.d.ts +35 -0
- package/dist/commonjs/policies/logPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/logPolicy.js +37 -0
- package/dist/commonjs/policies/logPolicy.js.map +1 -0
- package/dist/commonjs/policies/multipartPolicy.d.ts +10 -0
- package/dist/commonjs/policies/multipartPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/multipartPolicy.js +115 -0
- package/dist/commonjs/policies/multipartPolicy.js.map +1 -0
- package/dist/commonjs/policies/proxyPolicy.d.ts +31 -0
- package/dist/commonjs/policies/proxyPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/proxyPolicy.js +176 -0
- package/dist/commonjs/policies/proxyPolicy.js.map +1 -0
- package/dist/commonjs/policies/redirectPolicy.d.ts +23 -0
- package/dist/commonjs/policies/redirectPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/redirectPolicy.js +56 -0
- package/dist/commonjs/policies/redirectPolicy.js.map +1 -0
- package/dist/commonjs/policies/retryPolicy.d.ts +21 -0
- package/dist/commonjs/policies/retryPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/retryPolicy.js +109 -0
- package/dist/commonjs/policies/retryPolicy.js.map +1 -0
- package/dist/commonjs/policies/systemErrorRetryPolicy.d.ts +33 -0
- package/dist/commonjs/policies/systemErrorRetryPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/systemErrorRetryPolicy.js +33 -0
- package/dist/commonjs/policies/systemErrorRetryPolicy.js.map +1 -0
- package/dist/commonjs/policies/throttlingRetryPolicy.d.ts +26 -0
- package/dist/commonjs/policies/throttlingRetryPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/throttlingRetryPolicy.js +32 -0
- package/dist/commonjs/policies/throttlingRetryPolicy.js.map +1 -0
- package/dist/commonjs/policies/tlsPolicy.d.ts +11 -0
- package/dist/commonjs/policies/tlsPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/tlsPolicy.js +26 -0
- package/dist/commonjs/policies/tlsPolicy.js.map +1 -0
- package/dist/commonjs/policies/tracingPolicy.d.ts +24 -0
- package/dist/commonjs/policies/tracingPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/tracingPolicy.js +123 -0
- package/dist/commonjs/policies/tracingPolicy.js.map +1 -0
- package/dist/commonjs/policies/userAgentPolicy.d.ts +22 -0
- package/dist/commonjs/policies/userAgentPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/userAgentPolicy.js +30 -0
- package/dist/commonjs/policies/userAgentPolicy.js.map +1 -0
- package/dist/commonjs/restError.d.ts +65 -0
- package/dist/commonjs/restError.d.ts.map +1 -0
- package/dist/commonjs/restError.js +73 -0
- package/dist/commonjs/restError.js.map +1 -0
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.d.ts +40 -0
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.d.ts.map +1 -0
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js +75 -0
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js.map +1 -0
- package/dist/commonjs/retryStrategies/retryStrategy.d.ts +61 -0
- package/dist/commonjs/retryStrategies/retryStrategy.d.ts.map +1 -0
- package/dist/commonjs/retryStrategies/retryStrategy.js +5 -0
- package/dist/commonjs/retryStrategies/retryStrategy.js.map +1 -0
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.d.ts +9 -0
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.d.ts.map +1 -0
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js +79 -0
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js.map +1 -0
- package/dist/commonjs/tracing/instrumenter.d.ts +16 -0
- package/dist/commonjs/tracing/instrumenter.d.ts.map +1 -0
- package/dist/commonjs/tracing/instrumenter.js +68 -0
- package/dist/commonjs/tracing/instrumenter.js.map +1 -0
- package/dist/commonjs/tracing/interfaces.d.ts +254 -0
- package/dist/commonjs/tracing/interfaces.d.ts.map +1 -0
- package/dist/commonjs/tracing/interfaces.js +5 -0
- package/dist/commonjs/tracing/interfaces.js.map +1 -0
- package/dist/commonjs/tracing/tracingClient.d.ts +9 -0
- package/dist/commonjs/tracing/tracingClient.d.ts.map +1 -0
- package/dist/commonjs/tracing/tracingClient.js +82 -0
- package/dist/commonjs/tracing/tracingClient.js.map +1 -0
- package/dist/commonjs/tracing/tracingContext.d.ts +34 -0
- package/dist/commonjs/tracing/tracingContext.d.ts.map +1 -0
- package/dist/commonjs/tracing/tracingContext.js +53 -0
- package/dist/commonjs/tracing/tracingContext.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/commonjs/util/aborterUtils.d.ts +27 -0
- package/dist/commonjs/util/aborterUtils.d.ts.map +1 -0
- package/dist/commonjs/util/aborterUtils.js +24 -0
- package/dist/commonjs/util/aborterUtils.js.map +1 -0
- package/dist/commonjs/util/bytesEncoding.d.ts +17 -0
- package/dist/commonjs/util/bytesEncoding.d.ts.map +1 -0
- package/dist/commonjs/util/bytesEncoding.js +26 -0
- package/dist/commonjs/util/bytesEncoding.js.map +1 -0
- package/dist/commonjs/util/checkEnvironment.d.ts +37 -0
- package/dist/commonjs/util/checkEnvironment.d.ts.map +1 -0
- package/dist/commonjs/util/checkEnvironment.js +43 -0
- package/dist/commonjs/util/checkEnvironment.js.map +1 -0
- package/dist/commonjs/util/createAbortablePromise.d.ts +16 -0
- package/dist/commonjs/util/createAbortablePromise.d.ts.map +1 -0
- package/dist/commonjs/util/createAbortablePromise.js +46 -0
- package/dist/commonjs/util/createAbortablePromise.js.map +1 -0
- package/dist/commonjs/util/delay.d.ts +14 -0
- package/dist/commonjs/util/delay.d.ts.map +1 -0
- package/dist/commonjs/util/delay.js +26 -0
- package/dist/commonjs/util/delay.js.map +1 -0
- package/dist/commonjs/util/error.d.ts +13 -0
- package/dist/commonjs/util/error.d.ts.map +1 -0
- package/dist/commonjs/util/error.js +47 -0
- package/dist/commonjs/util/error.js.map +1 -0
- package/dist/commonjs/util/file.d.ts +62 -0
- package/dist/commonjs/util/file.d.ts.map +1 -0
- package/dist/commonjs/util/file.js +71 -0
- package/dist/commonjs/util/file.js.map +1 -0
- package/dist/commonjs/util/helpers.d.ts +21 -0
- package/dist/commonjs/util/helpers.d.ts.map +1 -0
- package/dist/commonjs/util/helpers.js +63 -0
- package/dist/commonjs/util/helpers.js.map +1 -0
- package/dist/commonjs/util/inspect.d.ts +2 -0
- package/dist/commonjs/util/inspect.d.ts.map +1 -0
- package/dist/commonjs/util/inspect.js +8 -0
- package/dist/commonjs/util/inspect.js.map +1 -0
- package/dist/commonjs/util/object.d.ts +12 -0
- package/dist/commonjs/util/object.d.ts.map +1 -0
- package/dist/commonjs/util/object.js +18 -0
- package/dist/commonjs/util/object.js.map +1 -0
- package/dist/commonjs/util/random.d.ts +10 -0
- package/dist/commonjs/util/random.d.ts.map +1 -0
- package/dist/commonjs/util/random.js +25 -0
- package/dist/commonjs/util/random.js.map +1 -0
- package/dist/commonjs/util/sanitizer.d.ts +30 -0
- package/dist/commonjs/util/sanitizer.d.ts.map +1 -0
- package/dist/commonjs/util/sanitizer.js +149 -0
- package/dist/commonjs/util/sanitizer.js.map +1 -0
- package/dist/commonjs/util/sha256.d.ts +14 -0
- package/dist/commonjs/util/sha256.d.ts.map +1 -0
- package/dist/commonjs/util/sha256.js +27 -0
- package/dist/commonjs/util/sha256.js.map +1 -0
- package/dist/commonjs/util/stream.d.ts +5 -0
- package/dist/commonjs/util/stream.d.ts.map +1 -0
- package/dist/commonjs/util/stream.js +69 -0
- package/dist/commonjs/util/stream.js.map +1 -0
- package/dist/commonjs/util/tokenCycler.d.ts +45 -0
- package/dist/commonjs/util/tokenCycler.d.ts.map +1 -0
- package/dist/commonjs/util/tokenCycler.js +154 -0
- package/dist/commonjs/util/tokenCycler.js.map +1 -0
- package/dist/commonjs/util/typeGuards.d.ts +23 -0
- package/dist/commonjs/util/typeGuards.d.ts.map +1 -0
- package/dist/commonjs/util/typeGuards.js +58 -0
- package/dist/commonjs/util/typeGuards.js.map +1 -0
- package/dist/commonjs/util/userAgent.d.ts +9 -0
- package/dist/commonjs/util/userAgent.d.ts.map +1 -0
- package/dist/commonjs/util/userAgent.js +35 -0
- package/dist/commonjs/util/userAgent.js.map +1 -0
- package/dist/commonjs/util/userAgentPlatform.d.ts +9 -0
- package/dist/commonjs/util/userAgentPlatform.d.ts.map +1 -0
- package/dist/commonjs/util/userAgentPlatform.js +33 -0
- package/dist/commonjs/util/userAgentPlatform.js.map +1 -0
- package/dist/commonjs/util/uuidUtils.common.d.ts +13 -0
- package/dist/commonjs/util/uuidUtils.common.d.ts.map +1 -0
- package/dist/commonjs/util/uuidUtils.common.js +48 -0
- package/dist/commonjs/util/uuidUtils.common.js.map +1 -0
- package/dist/commonjs/util/uuidUtils.d.ts +7 -0
- package/dist/commonjs/util/uuidUtils.d.ts.map +1 -0
- package/dist/commonjs/util/uuidUtils.js +25 -0
- package/dist/commonjs/util/uuidUtils.js.map +1 -0
- package/dist/commonjs/xhrHttpClient.d.ts +7 -0
- package/dist/commonjs/xhrHttpClient.d.ts.map +1 -0
- package/dist/commonjs/xhrHttpClient.js +169 -0
- package/dist/commonjs/xhrHttpClient.js.map +1 -0
- package/dist/esm/abort-controller/AbortError.d.ts +22 -0
- package/dist/esm/abort-controller/AbortError.d.ts.map +1 -0
- package/dist/esm/abort-controller/AbortError.js +27 -0
- package/dist/esm/abort-controller/AbortError.js.map +1 -0
- package/dist/esm/abort-controller/AbortSignalLike.d.ts +19 -0
- package/dist/esm/abort-controller/AbortSignalLike.d.ts.map +1 -0
- package/dist/esm/abort-controller/AbortSignalLike.js +4 -0
- package/dist/esm/abort-controller/AbortSignalLike.js.map +1 -0
- package/dist/esm/accessTokenCache.d.ts +40 -0
- package/dist/esm/accessTokenCache.d.ts.map +1 -0
- package/dist/esm/accessTokenCache.js +34 -0
- package/dist/esm/accessTokenCache.js.map +1 -0
- package/dist/esm/auth/keyCredential.d.ts +10 -0
- package/dist/esm/auth/keyCredential.d.ts.map +1 -0
- package/dist/esm/auth/keyCredential.js +4 -0
- package/dist/esm/auth/keyCredential.js.map +1 -0
- package/dist/esm/auth/tokenCredential.d.ts +77 -0
- package/dist/esm/auth/tokenCredential.d.ts.map +1 -0
- package/dist/esm/auth/tokenCredential.js +19 -0
- package/dist/esm/auth/tokenCredential.js.map +1 -0
- package/dist/esm/client/apiVersionPolicy.d.ts +10 -0
- package/dist/esm/client/apiVersionPolicy.d.ts.map +1 -0
- package/dist/esm/client/apiVersionPolicy.js +23 -0
- package/dist/esm/client/apiVersionPolicy.js.map +1 -0
- package/dist/esm/client/clientHelpers.d.ts +28 -0
- package/dist/esm/client/clientHelpers.d.ts.map +1 -0
- package/dist/esm/client/clientHelpers.js +51 -0
- package/dist/esm/client/clientHelpers.js.map +1 -0
- package/dist/esm/client/common.d.ts +358 -0
- package/dist/esm/client/common.d.ts.map +1 -0
- package/dist/esm/client/common.js +4 -0
- package/dist/esm/client/common.js.map +1 -0
- package/dist/esm/client/getClient.d.ts +17 -0
- package/dist/esm/client/getClient.d.ts.map +1 -0
- package/dist/esm/client/getClient.js +84 -0
- package/dist/esm/client/getClient.js.map +1 -0
- package/dist/esm/client/helpers/getBinaryBody.d.ts +5 -0
- package/dist/esm/client/helpers/getBinaryBody.d.ts.map +1 -0
- package/dist/esm/client/helpers/getBinaryBody.js +13 -0
- package/dist/esm/client/helpers/getBinaryBody.js.map +1 -0
- package/dist/esm/client/keyCredentialAuthenticationPolicy.d.ts +8 -0
- package/dist/esm/client/keyCredentialAuthenticationPolicy.d.ts.map +1 -0
- package/dist/esm/client/keyCredentialAuthenticationPolicy.js +16 -0
- package/dist/esm/client/keyCredentialAuthenticationPolicy.js.map +1 -0
- package/dist/esm/client/operationOptionHelpers.d.ts +8 -0
- package/dist/esm/client/operationOptionHelpers.d.ts.map +1 -0
- package/dist/esm/client/operationOptionHelpers.js +21 -0
- package/dist/esm/client/operationOptionHelpers.js.map +1 -0
- package/dist/esm/client/restError.d.ts +11 -0
- package/dist/esm/client/restError.d.ts.map +1 -0
- package/dist/esm/client/restError.js +29 -0
- package/dist/esm/client/restError.js.map +1 -0
- package/dist/esm/client/sendRequest.d.ts +30 -0
- package/dist/esm/client/sendRequest.d.ts.map +1 -0
- package/dist/esm/client/sendRequest.js +195 -0
- package/dist/esm/client/sendRequest.js.map +1 -0
- package/dist/esm/client/urlHelpers.d.ts +20 -0
- package/dist/esm/client/urlHelpers.d.ts.map +1 -0
- package/dist/esm/client/urlHelpers.js +99 -0
- package/dist/esm/client/urlHelpers.js.map +1 -0
- package/dist/esm/constants.d.ts +3 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +5 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/createPipelineFromOptions.d.ts +59 -0
- package/dist/esm/createPipelineFromOptions.d.ts.map +1 -0
- package/dist/esm/createPipelineFromOptions.js +44 -0
- package/dist/esm/createPipelineFromOptions.js.map +1 -0
- package/dist/esm/defaultHttpClient.d.ts +6 -0
- package/dist/esm/defaultHttpClient.d.ts.map +1 -0
- package/dist/esm/defaultHttpClient.js +10 -0
- package/dist/esm/defaultHttpClient.js.map +1 -0
- package/dist/esm/fetchHttpClient.d.ts +7 -0
- package/dist/esm/fetchHttpClient.d.ts.map +1 -0
- package/dist/esm/fetchHttpClient.js +262 -0
- package/dist/esm/fetchHttpClient.js.map +1 -0
- package/dist/esm/httpHeaders.d.ts +7 -0
- package/dist/esm/httpHeaders.d.ts.map +1 -0
- package/dist/esm/httpHeaders.js +89 -0
- package/dist/esm/httpHeaders.js.map +1 -0
- package/dist/esm/index.d.ts +56 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +43 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interfaces.d.ts +447 -0
- package/dist/esm/interfaces.d.ts.map +1 -0
- package/dist/esm/interfaces.js +4 -0
- package/dist/esm/interfaces.js.map +1 -0
- package/dist/esm/log.d.ts +2 -0
- package/dist/esm/log.d.ts.map +1 -0
- package/dist/esm/log.js +5 -0
- package/dist/esm/log.js.map +1 -0
- package/dist/esm/logger/debug.d.ts +63 -0
- package/dist/esm/logger/debug.d.ts.map +1 -0
- package/dist/esm/logger/debug.js +93 -0
- package/dist/esm/logger/debug.js.map +1 -0
- package/dist/esm/logger/log.d.ts +2 -0
- package/dist/esm/logger/log.d.ts.map +1 -0
- package/dist/esm/logger/log.js +9 -0
- package/dist/esm/logger/log.js.map +1 -0
- package/dist/esm/logger/logger.d.ts +68 -0
- package/dist/esm/logger/logger.d.ts.map +1 -0
- package/dist/esm/logger/logger.js +99 -0
- package/dist/esm/logger/logger.js.map +1 -0
- package/dist/esm/nodeHttpClient.d.ts +9 -0
- package/dist/esm/nodeHttpClient.d.ts.map +1 -0
- package/dist/esm/nodeHttpClient.js +330 -0
- package/dist/esm/nodeHttpClient.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/pipeline.d.ts +93 -0
- package/dist/esm/pipeline.d.ts.map +1 -0
- package/dist/esm/pipeline.js +262 -0
- package/dist/esm/pipeline.js.map +1 -0
- package/dist/esm/pipelineRequest.d.ts +93 -0
- package/dist/esm/pipelineRequest.d.ts.map +1 -0
- package/dist/esm/pipelineRequest.js +53 -0
- package/dist/esm/pipelineRequest.js.map +1 -0
- package/dist/esm/policies/bearerTokenAuthenticationPolicy.d.ts +99 -0
- package/dist/esm/policies/bearerTokenAuthenticationPolicy.d.ts.map +1 -0
- package/dist/esm/policies/bearerTokenAuthenticationPolicy.js +112 -0
- package/dist/esm/policies/bearerTokenAuthenticationPolicy.js.map +1 -0
- package/dist/esm/policies/decompressResponsePolicy.d.ts +11 -0
- package/dist/esm/policies/decompressResponsePolicy.d.ts.map +1 -0
- package/dist/esm/policies/decompressResponsePolicy.js.map +1 -0
- package/dist/esm/policies/defaultRetryPolicy.d.ts +19 -0
- package/dist/esm/policies/defaultRetryPolicy.d.ts.map +1 -0
- package/dist/esm/policies/defaultRetryPolicy.js +25 -0
- package/dist/esm/policies/defaultRetryPolicy.js.map +1 -0
- package/dist/esm/policies/exponentialRetryPolicy.d.ts +31 -0
- package/dist/esm/policies/exponentialRetryPolicy.d.ts.map +1 -0
- package/dist/esm/policies/exponentialRetryPolicy.js +24 -0
- package/dist/esm/policies/exponentialRetryPolicy.js.map +1 -0
- package/dist/esm/policies/formDataPolicy.d.ts +10 -0
- package/dist/esm/policies/formDataPolicy.d.ts.map +1 -0
- package/dist/esm/policies/formDataPolicy.js +81 -0
- package/dist/esm/policies/formDataPolicy.js.map +1 -0
- package/dist/esm/policies/logPolicy.d.ts +35 -0
- package/dist/esm/policies/logPolicy.d.ts.map +1 -0
- package/dist/esm/policies/logPolicy.js +33 -0
- package/dist/esm/policies/logPolicy.js.map +1 -0
- package/dist/esm/policies/multipartPolicy.d.ts +10 -0
- package/dist/esm/policies/multipartPolicy.d.ts.map +1 -0
- package/dist/esm/policies/multipartPolicy.js +111 -0
- package/dist/esm/policies/multipartPolicy.js.map +1 -0
- package/dist/esm/policies/proxyPolicy.d.ts +31 -0
- package/dist/esm/policies/proxyPolicy.d.ts.map +1 -0
- package/dist/esm/policies/proxyPolicy.js +170 -0
- package/dist/esm/policies/proxyPolicy.js.map +1 -0
- package/dist/esm/policies/redirectPolicy.d.ts +23 -0
- package/dist/esm/policies/redirectPolicy.d.ts.map +1 -0
- package/dist/esm/policies/redirectPolicy.js +52 -0
- package/dist/esm/policies/redirectPolicy.js.map +1 -0
- package/dist/esm/policies/retryPolicy.d.ts +21 -0
- package/dist/esm/policies/retryPolicy.d.ts.map +1 -0
- package/dist/esm/policies/retryPolicy.js +105 -0
- package/dist/esm/policies/retryPolicy.js.map +1 -0
- package/dist/esm/policies/systemErrorRetryPolicy.d.ts +33 -0
- package/dist/esm/policies/systemErrorRetryPolicy.d.ts.map +1 -0
- package/dist/esm/policies/systemErrorRetryPolicy.js +29 -0
- package/dist/esm/policies/systemErrorRetryPolicy.js.map +1 -0
- package/dist/esm/policies/throttlingRetryPolicy.d.ts +26 -0
- package/dist/esm/policies/throttlingRetryPolicy.d.ts.map +1 -0
- package/dist/esm/policies/throttlingRetryPolicy.js +28 -0
- package/dist/esm/policies/throttlingRetryPolicy.js.map +1 -0
- package/dist/esm/policies/tlsPolicy.d.ts +11 -0
- package/dist/esm/policies/tlsPolicy.d.ts.map +1 -0
- package/dist/esm/policies/tlsPolicy.js +22 -0
- package/dist/esm/policies/tlsPolicy.js.map +1 -0
- package/dist/esm/policies/tracingPolicy.d.ts +24 -0
- package/dist/esm/policies/tracingPolicy.d.ts.map +1 -0
- package/dist/esm/policies/tracingPolicy.js +119 -0
- package/dist/esm/policies/tracingPolicy.js.map +1 -0
- package/dist/esm/policies/userAgentPolicy.d.ts +22 -0
- package/dist/esm/policies/userAgentPolicy.d.ts.map +1 -0
- package/dist/esm/policies/userAgentPolicy.js +26 -0
- package/dist/esm/policies/userAgentPolicy.js.map +1 -0
- package/dist/esm/restError.d.ts +65 -0
- package/dist/esm/restError.d.ts.map +1 -0
- package/dist/esm/restError.js +68 -0
- package/dist/esm/restError.js.map +1 -0
- package/dist/esm/retryStrategies/exponentialRetryStrategy.d.ts +40 -0
- package/dist/esm/retryStrategies/exponentialRetryStrategy.d.ts.map +1 -0
- package/dist/esm/retryStrategies/exponentialRetryStrategy.js +69 -0
- package/dist/esm/retryStrategies/exponentialRetryStrategy.js.map +1 -0
- package/dist/esm/retryStrategies/retryStrategy.d.ts +61 -0
- package/dist/esm/retryStrategies/retryStrategy.d.ts.map +1 -0
- package/dist/esm/retryStrategies/retryStrategy.js +4 -0
- package/dist/esm/retryStrategies/retryStrategy.js.map +1 -0
- package/dist/esm/retryStrategies/throttlingRetryStrategy.d.ts +9 -0
- package/dist/esm/retryStrategies/throttlingRetryStrategy.d.ts.map +1 -0
- package/dist/esm/retryStrategies/throttlingRetryStrategy.js +74 -0
- package/dist/esm/retryStrategies/throttlingRetryStrategy.js.map +1 -0
- package/dist/esm/tracing/instrumenter.d.ts +16 -0
- package/dist/esm/tracing/instrumenter.d.ts.map +1 -0
- package/dist/esm/tracing/instrumenter.js +61 -0
- package/dist/esm/tracing/instrumenter.js.map +1 -0
- package/dist/esm/tracing/interfaces.d.ts +254 -0
- package/dist/esm/tracing/interfaces.d.ts.map +1 -0
- package/dist/esm/tracing/interfaces.js +4 -0
- package/dist/esm/tracing/interfaces.js.map +1 -0
- package/dist/esm/tracing/tracingClient.d.ts +9 -0
- package/dist/esm/tracing/tracingClient.d.ts.map +1 -0
- package/dist/esm/tracing/tracingClient.js +78 -0
- package/dist/esm/tracing/tracingClient.js.map +1 -0
- package/dist/esm/tracing/tracingContext.d.ts +34 -0
- package/dist/esm/tracing/tracingContext.d.ts.map +1 -0
- package/dist/esm/tracing/tracingContext.js +48 -0
- package/dist/esm/tracing/tracingContext.js.map +1 -0
- package/dist/esm/util/aborterUtils.d.ts +27 -0
- package/dist/esm/util/aborterUtils.d.ts.map +1 -0
- package/dist/esm/util/aborterUtils.js +20 -0
- package/dist/esm/util/aborterUtils.js.map +1 -0
- package/dist/esm/util/bytesEncoding.d.ts +17 -0
- package/dist/esm/util/bytesEncoding.d.ts.map +1 -0
- package/dist/esm/util/checkEnvironment.d.ts +37 -0
- package/dist/esm/util/checkEnvironment.d.ts.map +1 -0
- package/dist/esm/util/checkEnvironment.js +40 -0
- package/dist/esm/util/checkEnvironment.js.map +1 -0
- package/dist/esm/util/createAbortablePromise.d.ts +16 -0
- package/dist/esm/util/createAbortablePromise.d.ts.map +1 -0
- package/dist/esm/util/createAbortablePromise.js +42 -0
- package/dist/esm/util/createAbortablePromise.js.map +1 -0
- package/dist/esm/util/delay.d.ts +14 -0
- package/dist/esm/util/delay.d.ts.map +1 -0
- package/dist/esm/util/delay.js +22 -0
- package/dist/esm/util/delay.js.map +1 -0
- package/dist/esm/util/error.d.ts +13 -0
- package/dist/esm/util/error.d.ts.map +1 -0
- package/dist/esm/util/error.js +42 -0
- package/dist/esm/util/error.js.map +1 -0
- package/dist/esm/util/file.d.ts +62 -0
- package/dist/esm/util/file.d.ts.map +1 -0
- package/dist/esm/util/file.js +66 -0
- package/dist/esm/util/file.js.map +1 -0
- package/dist/esm/util/helpers.d.ts +21 -0
- package/dist/esm/util/helpers.d.ts.map +1 -0
- package/dist/esm/util/helpers.js +58 -0
- package/dist/esm/util/helpers.js.map +1 -0
- package/dist/esm/util/inspect.d.ts +2 -0
- package/dist/esm/util/inspect.d.ts.map +1 -0
- package/dist/esm/util/inspect.js +5 -0
- package/dist/esm/util/inspect.js.map +1 -0
- package/dist/esm/util/object.d.ts +12 -0
- package/dist/esm/util/object.d.ts.map +1 -0
- package/dist/esm/util/object.js +14 -0
- package/dist/esm/util/object.js.map +1 -0
- package/dist/esm/util/random.d.ts +10 -0
- package/dist/esm/util/random.d.ts.map +1 -0
- package/dist/esm/util/random.js +21 -0
- package/dist/esm/util/random.js.map +1 -0
- package/dist/esm/util/sanitizer.d.ts +30 -0
- package/dist/esm/util/sanitizer.d.ts.map +1 -0
- package/dist/esm/util/sanitizer.js +145 -0
- package/dist/esm/util/sanitizer.js.map +1 -0
- package/dist/esm/util/sha256.d.ts +14 -0
- package/dist/esm/util/sha256.d.ts.map +1 -0
- package/dist/esm/util/sha256.js +22 -0
- package/dist/esm/util/sha256.js.map +1 -0
- package/dist/esm/util/stream.d.ts +5 -0
- package/dist/esm/util/stream.d.ts.map +1 -0
- package/dist/esm/util/stream.js +63 -0
- package/dist/esm/util/stream.js.map +1 -0
- package/dist/esm/util/tokenCycler.d.ts +45 -0
- package/dist/esm/util/tokenCycler.d.ts.map +1 -0
- package/dist/esm/util/tokenCycler.js +150 -0
- package/dist/esm/util/tokenCycler.js.map +1 -0
- package/dist/esm/util/typeGuards.d.ts +23 -0
- package/dist/esm/util/typeGuards.d.ts.map +1 -0
- package/dist/esm/util/typeGuards.js +48 -0
- package/dist/esm/util/typeGuards.js.map +1 -0
- package/dist/esm/util/userAgent.d.ts +9 -0
- package/dist/esm/util/userAgent.d.ts.map +1 -0
- package/dist/esm/util/userAgent.js +30 -0
- package/dist/esm/util/userAgent.js.map +1 -0
- package/dist/esm/util/userAgentPlatform.d.ts +9 -0
- package/dist/esm/util/userAgentPlatform.d.ts.map +1 -0
- package/dist/esm/util/userAgentPlatform.js +27 -0
- package/dist/esm/util/userAgentPlatform.js.map +1 -0
- package/dist/esm/util/uuidUtils.common.d.ts +13 -0
- package/dist/esm/util/uuidUtils.common.d.ts.map +1 -0
- package/dist/esm/util/uuidUtils.common.js +43 -0
- package/dist/esm/util/uuidUtils.common.js.map +1 -0
- package/dist/esm/util/uuidUtils.d.ts +7 -0
- package/dist/esm/util/uuidUtils.d.ts.map +1 -0
- package/dist/esm/util/uuidUtils.js +21 -0
- package/dist/esm/util/uuidUtils.js.map +1 -0
- package/dist/esm/xhrHttpClient.d.ts +7 -0
- package/dist/esm/xhrHttpClient.d.ts.map +1 -0
- package/dist/esm/xhrHttpClient.js +165 -0
- package/dist/esm/xhrHttpClient.js.map +1 -0
- package/dist/react-native/abort-controller/AbortError.d.ts +22 -0
- package/dist/react-native/abort-controller/AbortError.d.ts.map +1 -0
- package/dist/react-native/abort-controller/AbortError.js +27 -0
- package/dist/react-native/abort-controller/AbortError.js.map +1 -0
- package/dist/react-native/abort-controller/AbortSignalLike.d.ts +19 -0
- package/dist/react-native/abort-controller/AbortSignalLike.d.ts.map +1 -0
- package/dist/react-native/abort-controller/AbortSignalLike.js +4 -0
- package/dist/react-native/abort-controller/AbortSignalLike.js.map +1 -0
- package/dist/react-native/accessTokenCache.d.ts +40 -0
- package/dist/react-native/accessTokenCache.d.ts.map +1 -0
- package/dist/react-native/accessTokenCache.js +34 -0
- package/dist/react-native/accessTokenCache.js.map +1 -0
- package/dist/react-native/auth/keyCredential.d.ts +10 -0
- package/dist/react-native/auth/keyCredential.d.ts.map +1 -0
- package/dist/react-native/auth/keyCredential.js +4 -0
- package/dist/react-native/auth/keyCredential.js.map +1 -0
- package/dist/react-native/auth/tokenCredential.d.ts +77 -0
- package/dist/react-native/auth/tokenCredential.d.ts.map +1 -0
- package/dist/react-native/auth/tokenCredential.js +19 -0
- package/dist/react-native/auth/tokenCredential.js.map +1 -0
- package/dist/react-native/client/apiVersionPolicy.d.ts +10 -0
- package/dist/react-native/client/apiVersionPolicy.d.ts.map +1 -0
- package/dist/react-native/client/apiVersionPolicy.js +23 -0
- package/dist/react-native/client/apiVersionPolicy.js.map +1 -0
- package/dist/react-native/client/clientHelpers.d.ts +28 -0
- package/dist/react-native/client/clientHelpers.d.ts.map +1 -0
- package/dist/react-native/client/clientHelpers.js +51 -0
- package/dist/react-native/client/clientHelpers.js.map +1 -0
- package/dist/react-native/client/common.d.ts +358 -0
- package/dist/react-native/client/common.d.ts.map +1 -0
- package/dist/react-native/client/common.js +4 -0
- package/dist/react-native/client/common.js.map +1 -0
- package/dist/react-native/client/getClient.d.ts +17 -0
- package/dist/react-native/client/getClient.d.ts.map +1 -0
- package/dist/react-native/client/getClient.js +84 -0
- package/dist/react-native/client/getClient.js.map +1 -0
- package/dist/react-native/client/helpers/getBinaryBody.d.ts +5 -0
- package/dist/react-native/client/helpers/getBinaryBody.d.ts.map +1 -0
- package/dist/react-native/client/helpers/getBinaryBody.js +13 -0
- package/dist/react-native/client/helpers/getBinaryBody.js.map +1 -0
- package/dist/react-native/client/keyCredentialAuthenticationPolicy.d.ts +8 -0
- package/dist/react-native/client/keyCredentialAuthenticationPolicy.d.ts.map +1 -0
- package/dist/react-native/client/keyCredentialAuthenticationPolicy.js +16 -0
- package/dist/react-native/client/keyCredentialAuthenticationPolicy.js.map +1 -0
- package/dist/react-native/client/operationOptionHelpers.d.ts +8 -0
- package/dist/react-native/client/operationOptionHelpers.d.ts.map +1 -0
- package/dist/react-native/client/operationOptionHelpers.js +21 -0
- package/dist/react-native/client/operationOptionHelpers.js.map +1 -0
- package/dist/react-native/client/restError.d.ts +11 -0
- package/dist/react-native/client/restError.d.ts.map +1 -0
- package/dist/react-native/client/restError.js +29 -0
- package/dist/react-native/client/restError.js.map +1 -0
- package/dist/react-native/client/sendRequest.d.ts +30 -0
- package/dist/react-native/client/sendRequest.d.ts.map +1 -0
- package/dist/react-native/client/sendRequest.js +195 -0
- package/dist/react-native/client/sendRequest.js.map +1 -0
- package/dist/react-native/client/urlHelpers.d.ts +20 -0
- package/dist/react-native/client/urlHelpers.d.ts.map +1 -0
- package/dist/react-native/client/urlHelpers.js +99 -0
- package/dist/react-native/client/urlHelpers.js.map +1 -0
- package/dist/react-native/constants.d.ts +3 -0
- package/dist/react-native/constants.d.ts.map +1 -0
- package/dist/react-native/constants.js +5 -0
- package/dist/react-native/constants.js.map +1 -0
- package/dist/react-native/createPipelineFromOptions.d.ts +59 -0
- package/dist/react-native/createPipelineFromOptions.d.ts.map +1 -0
- package/dist/react-native/createPipelineFromOptions.js +44 -0
- package/dist/react-native/createPipelineFromOptions.js.map +1 -0
- package/dist/react-native/defaultHttpClient-react-native.d.mts.map +1 -0
- package/dist/react-native/defaultHttpClient-react-native.mjs.map +1 -0
- package/dist/react-native/defaultHttpClient.d.ts +6 -0
- package/dist/react-native/defaultHttpClient.js +10 -0
- package/dist/react-native/fetchHttpClient.d.ts +7 -0
- package/dist/react-native/fetchHttpClient.d.ts.map +1 -0
- package/dist/react-native/fetchHttpClient.js +262 -0
- package/dist/react-native/fetchHttpClient.js.map +1 -0
- package/dist/react-native/httpHeaders.d.ts +7 -0
- package/dist/react-native/httpHeaders.d.ts.map +1 -0
- package/dist/react-native/httpHeaders.js +89 -0
- package/dist/react-native/httpHeaders.js.map +1 -0
- package/dist/react-native/index.d.ts +56 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +43 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/interfaces.d.ts +447 -0
- package/dist/react-native/interfaces.d.ts.map +1 -0
- package/dist/react-native/interfaces.js +4 -0
- package/dist/react-native/interfaces.js.map +1 -0
- package/dist/react-native/log.d.ts +2 -0
- package/dist/react-native/log.d.ts.map +1 -0
- package/dist/react-native/log.js +5 -0
- package/dist/react-native/log.js.map +1 -0
- package/dist/react-native/logger/debug.d.ts +63 -0
- package/dist/react-native/logger/debug.d.ts.map +1 -0
- package/dist/react-native/logger/debug.js +93 -0
- package/dist/react-native/logger/debug.js.map +1 -0
- package/dist/react-native/logger/log.d.ts +2 -0
- package/dist/react-native/logger/log.d.ts.map +1 -0
- package/dist/react-native/logger/log.js +9 -0
- package/dist/react-native/logger/log.js.map +1 -0
- package/dist/react-native/logger/logger.d.ts +68 -0
- package/dist/react-native/logger/logger.d.ts.map +1 -0
- package/dist/react-native/logger/logger.js +99 -0
- package/dist/react-native/logger/logger.js.map +1 -0
- package/dist/react-native/nodeHttpClient.d.ts +9 -0
- package/dist/react-native/nodeHttpClient.d.ts.map +1 -0
- package/dist/react-native/nodeHttpClient.js +330 -0
- package/dist/react-native/nodeHttpClient.js.map +1 -0
- package/dist/react-native/package.json +3 -0
- package/dist/react-native/pipeline.d.ts +93 -0
- package/dist/react-native/pipeline.d.ts.map +1 -0
- package/dist/react-native/pipeline.js +262 -0
- package/dist/react-native/pipeline.js.map +1 -0
- package/dist/react-native/pipelineRequest.d.ts +93 -0
- package/dist/react-native/pipelineRequest.d.ts.map +1 -0
- package/dist/react-native/pipelineRequest.js +53 -0
- package/dist/react-native/pipelineRequest.js.map +1 -0
- package/dist/react-native/policies/bearerTokenAuthenticationPolicy.d.ts +99 -0
- package/dist/react-native/policies/bearerTokenAuthenticationPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/bearerTokenAuthenticationPolicy.js +112 -0
- package/dist/react-native/policies/bearerTokenAuthenticationPolicy.js.map +1 -0
- package/dist/react-native/policies/decompressResponsePolicy.d.ts +11 -0
- package/dist/react-native/policies/decompressResponsePolicy.d.ts.map +1 -0
- package/dist/react-native/policies/decompressResponsePolicy.js +23 -0
- package/dist/react-native/policies/decompressResponsePolicy.js.map +1 -0
- package/dist/react-native/policies/defaultRetryPolicy.d.ts +19 -0
- package/dist/react-native/policies/defaultRetryPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/defaultRetryPolicy.js +25 -0
- package/dist/react-native/policies/defaultRetryPolicy.js.map +1 -0
- package/dist/react-native/policies/exponentialRetryPolicy.d.ts +31 -0
- package/dist/react-native/policies/exponentialRetryPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/exponentialRetryPolicy.js +24 -0
- package/dist/react-native/policies/exponentialRetryPolicy.js.map +1 -0
- package/dist/react-native/policies/formDataPolicy.d.ts +10 -0
- package/dist/react-native/policies/formDataPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/formDataPolicy.js +81 -0
- package/dist/react-native/policies/formDataPolicy.js.map +1 -0
- package/dist/react-native/policies/logPolicy.d.ts +35 -0
- package/dist/react-native/policies/logPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/logPolicy.js +33 -0
- package/dist/react-native/policies/logPolicy.js.map +1 -0
- package/dist/react-native/policies/multipartPolicy.d.ts +10 -0
- package/dist/react-native/policies/multipartPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/multipartPolicy.js +111 -0
- package/dist/react-native/policies/multipartPolicy.js.map +1 -0
- package/dist/react-native/policies/proxyPolicy.d.ts +31 -0
- package/dist/react-native/policies/proxyPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/proxyPolicy.js +170 -0
- package/dist/react-native/policies/proxyPolicy.js.map +1 -0
- package/dist/react-native/policies/redirectPolicy.d.ts +23 -0
- package/dist/react-native/policies/redirectPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/redirectPolicy.js +52 -0
- package/dist/react-native/policies/redirectPolicy.js.map +1 -0
- package/dist/react-native/policies/retryPolicy.d.ts +21 -0
- package/dist/react-native/policies/retryPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/retryPolicy.js +105 -0
- package/dist/react-native/policies/retryPolicy.js.map +1 -0
- package/dist/react-native/policies/systemErrorRetryPolicy.d.ts +33 -0
- package/dist/react-native/policies/systemErrorRetryPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/systemErrorRetryPolicy.js +29 -0
- package/dist/react-native/policies/systemErrorRetryPolicy.js.map +1 -0
- package/dist/react-native/policies/throttlingRetryPolicy.d.ts +26 -0
- package/dist/react-native/policies/throttlingRetryPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/throttlingRetryPolicy.js +28 -0
- package/dist/react-native/policies/throttlingRetryPolicy.js.map +1 -0
- package/dist/react-native/policies/tlsPolicy.d.ts +11 -0
- package/dist/react-native/policies/tlsPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/tlsPolicy.js +22 -0
- package/dist/react-native/policies/tlsPolicy.js.map +1 -0
- package/dist/react-native/policies/tracingPolicy.d.ts +24 -0
- package/dist/react-native/policies/tracingPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/tracingPolicy.js +119 -0
- package/dist/react-native/policies/tracingPolicy.js.map +1 -0
- package/dist/react-native/policies/userAgentPolicy.d.ts +22 -0
- package/dist/react-native/policies/userAgentPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/userAgentPolicy.js +26 -0
- package/dist/react-native/policies/userAgentPolicy.js.map +1 -0
- package/dist/react-native/restError.d.ts +65 -0
- package/dist/react-native/restError.d.ts.map +1 -0
- package/dist/react-native/restError.js +68 -0
- package/dist/react-native/restError.js.map +1 -0
- package/dist/react-native/retryStrategies/exponentialRetryStrategy.d.ts +40 -0
- package/dist/react-native/retryStrategies/exponentialRetryStrategy.d.ts.map +1 -0
- package/dist/react-native/retryStrategies/exponentialRetryStrategy.js +69 -0
- package/dist/react-native/retryStrategies/exponentialRetryStrategy.js.map +1 -0
- package/dist/react-native/retryStrategies/retryStrategy.d.ts +61 -0
- package/dist/react-native/retryStrategies/retryStrategy.d.ts.map +1 -0
- package/dist/react-native/retryStrategies/retryStrategy.js +4 -0
- package/dist/react-native/retryStrategies/retryStrategy.js.map +1 -0
- package/dist/react-native/retryStrategies/throttlingRetryStrategy.d.ts +9 -0
- package/dist/react-native/retryStrategies/throttlingRetryStrategy.d.ts.map +1 -0
- package/dist/react-native/retryStrategies/throttlingRetryStrategy.js +74 -0
- package/dist/react-native/retryStrategies/throttlingRetryStrategy.js.map +1 -0
- package/dist/react-native/tracing/instrumenter.d.ts +16 -0
- package/dist/react-native/tracing/instrumenter.d.ts.map +1 -0
- package/dist/react-native/tracing/instrumenter.js +61 -0
- package/dist/react-native/tracing/instrumenter.js.map +1 -0
- package/dist/react-native/tracing/interfaces.d.ts +254 -0
- package/dist/react-native/tracing/interfaces.d.ts.map +1 -0
- package/dist/react-native/tracing/interfaces.js +4 -0
- package/dist/react-native/tracing/interfaces.js.map +1 -0
- package/dist/react-native/tracing/tracingClient.d.ts +9 -0
- package/dist/react-native/tracing/tracingClient.d.ts.map +1 -0
- package/dist/react-native/tracing/tracingClient.js +78 -0
- package/dist/react-native/tracing/tracingClient.js.map +1 -0
- package/dist/react-native/tracing/tracingContext.d.ts +34 -0
- package/dist/react-native/tracing/tracingContext.d.ts.map +1 -0
- package/dist/react-native/tracing/tracingContext.js +48 -0
- package/dist/react-native/tracing/tracingContext.js.map +1 -0
- package/dist/react-native/util/aborterUtils.d.ts +27 -0
- package/dist/react-native/util/aborterUtils.d.ts.map +1 -0
- package/dist/react-native/util/aborterUtils.js +20 -0
- package/dist/react-native/util/aborterUtils.js.map +1 -0
- package/dist/react-native/util/bytesEncoding.d.ts +17 -0
- package/dist/react-native/util/bytesEncoding.d.ts.map +1 -0
- package/dist/react-native/util/bytesEncoding.js +21 -0
- package/dist/react-native/util/bytesEncoding.js.map +1 -0
- package/dist/react-native/util/checkEnvironment.d.ts +37 -0
- package/dist/react-native/util/checkEnvironment.d.ts.map +1 -0
- package/dist/react-native/util/checkEnvironment.js +40 -0
- package/dist/react-native/util/checkEnvironment.js.map +1 -0
- package/dist/react-native/util/createAbortablePromise.d.ts +16 -0
- package/dist/react-native/util/createAbortablePromise.d.ts.map +1 -0
- package/dist/react-native/util/createAbortablePromise.js +42 -0
- package/dist/react-native/util/createAbortablePromise.js.map +1 -0
- package/dist/react-native/util/delay.d.ts +14 -0
- package/dist/react-native/util/delay.d.ts.map +1 -0
- package/dist/react-native/util/delay.js +22 -0
- package/dist/react-native/util/delay.js.map +1 -0
- package/dist/react-native/util/error.d.ts +13 -0
- package/dist/react-native/util/error.d.ts.map +1 -0
- package/dist/react-native/util/error.js +42 -0
- package/dist/react-native/util/error.js.map +1 -0
- package/dist/react-native/util/file.d.ts +62 -0
- package/dist/react-native/util/file.d.ts.map +1 -0
- package/dist/react-native/util/file.js +66 -0
- package/dist/react-native/util/file.js.map +1 -0
- package/dist/react-native/util/helpers.d.ts +21 -0
- package/dist/react-native/util/helpers.d.ts.map +1 -0
- package/dist/react-native/util/helpers.js +58 -0
- package/dist/react-native/util/helpers.js.map +1 -0
- package/dist/react-native/util/inspect.d.ts +2 -0
- package/dist/react-native/util/inspect.d.ts.map +1 -0
- package/dist/react-native/util/inspect.js +5 -0
- package/dist/react-native/util/inspect.js.map +1 -0
- package/dist/react-native/util/object.d.ts +12 -0
- package/dist/react-native/util/object.d.ts.map +1 -0
- package/dist/react-native/util/object.js +14 -0
- package/dist/react-native/util/object.js.map +1 -0
- package/dist/react-native/util/random.d.ts +10 -0
- package/dist/react-native/util/random.d.ts.map +1 -0
- package/dist/react-native/util/random.js +21 -0
- package/dist/react-native/util/random.js.map +1 -0
- package/dist/react-native/util/sanitizer.d.ts +30 -0
- package/dist/react-native/util/sanitizer.d.ts.map +1 -0
- package/dist/react-native/util/sanitizer.js +145 -0
- package/dist/react-native/util/sanitizer.js.map +1 -0
- package/dist/react-native/util/sha256.d.ts +14 -0
- package/dist/react-native/util/sha256.d.ts.map +1 -0
- package/dist/react-native/util/sha256.js +22 -0
- package/dist/react-native/util/sha256.js.map +1 -0
- package/dist/react-native/util/stream.d.ts +5 -0
- package/dist/react-native/util/stream.d.ts.map +1 -0
- package/dist/react-native/util/stream.js +63 -0
- package/dist/react-native/util/stream.js.map +1 -0
- package/dist/react-native/util/tokenCycler.d.ts +45 -0
- package/dist/react-native/util/tokenCycler.d.ts.map +1 -0
- package/dist/react-native/util/tokenCycler.js +150 -0
- package/dist/react-native/util/tokenCycler.js.map +1 -0
- package/dist/react-native/util/typeGuards.d.ts +23 -0
- package/dist/react-native/util/typeGuards.d.ts.map +1 -0
- package/dist/react-native/util/typeGuards.js +48 -0
- package/dist/react-native/util/typeGuards.js.map +1 -0
- package/dist/react-native/util/userAgent.d.ts +9 -0
- package/dist/react-native/util/userAgent.d.ts.map +1 -0
- package/dist/react-native/util/userAgent.js +30 -0
- package/dist/react-native/util/userAgent.js.map +1 -0
- package/dist/react-native/util/userAgentPlatform-react-native.d.mts.map +1 -0
- package/dist/react-native/util/userAgentPlatform-react-native.mjs.map +1 -0
- package/dist/react-native/util/userAgentPlatform.d.ts +9 -0
- package/dist/react-native/util/userAgentPlatform.js +24 -0
- package/dist/react-native/util/uuidUtils-react-native.d.mts.map +1 -0
- package/dist/react-native/util/uuidUtils-react-native.mjs.map +1 -0
- package/dist/react-native/util/uuidUtils.common.d.ts +13 -0
- package/dist/react-native/util/uuidUtils.common.d.ts.map +1 -0
- package/dist/react-native/util/uuidUtils.common.js +43 -0
- package/dist/react-native/util/uuidUtils.common.js.map +1 -0
- package/dist/react-native/util/uuidUtils.d.ts +2 -0
- package/dist/react-native/util/uuidUtils.js +4 -0
- package/dist/react-native/xhrHttpClient.d.ts +7 -0
- package/dist/react-native/xhrHttpClient.d.ts.map +1 -0
- package/dist/react-native/xhrHttpClient.js +165 -0
- package/dist/react-native/xhrHttpClient.js.map +1 -0
- package/package.json +72 -75
- package/dist/index.js +0 -3694
- package/dist/index.js.map +0 -1
- package/dist-esm/src/accessTokenCache.js +0 -32
- package/dist-esm/src/accessTokenCache.js.map +0 -1
- package/dist-esm/src/auth/tokenCredential.js.map +0 -1
- package/dist-esm/src/client/apiVersionPolicy.js.map +0 -1
- package/dist-esm/src/client/clientHelpers.js +0 -52
- package/dist-esm/src/client/clientHelpers.js.map +0 -1
- package/dist-esm/src/client/common.js.map +0 -1
- package/dist-esm/src/client/getClient.js +0 -86
- package/dist-esm/src/client/getClient.js.map +0 -1
- package/dist-esm/src/client/keyCredentialAuthenticationPolicy.js.map +0 -1
- package/dist-esm/src/client/operationOptionHelpers.js +0 -22
- package/dist-esm/src/client/operationOptionHelpers.js.map +0 -1
- package/dist-esm/src/client/restError.js +0 -31
- package/dist-esm/src/client/restError.js.map +0 -1
- package/dist-esm/src/client/sendRequest.js +0 -195
- package/dist-esm/src/client/sendRequest.js.map +0 -1
- package/dist-esm/src/client/urlHelpers.js +0 -100
- package/dist-esm/src/client/urlHelpers.js.map +0 -1
- package/dist-esm/src/createPipelineFromOptions.js +0 -44
- package/dist-esm/src/createPipelineFromOptions.js.map +0 -1
- package/dist-esm/src/defaultHttpClient.browser.js +0 -10
- package/dist-esm/src/defaultHttpClient.browser.js.map +0 -1
- package/dist-esm/src/defaultHttpClient.js +0 -10
- package/dist-esm/src/defaultHttpClient.js.map +0 -1
- package/dist-esm/src/defaultHttpClient.native.js +0 -10
- package/dist-esm/src/defaultHttpClient.native.js.map +0 -1
- package/dist-esm/src/fetchHttpClient.js +0 -255
- package/dist-esm/src/fetchHttpClient.js.map +0 -1
- package/dist-esm/src/httpHeaders.js +0 -89
- package/dist-esm/src/httpHeaders.js.map +0 -1
- package/dist-esm/src/index.js +0 -43
- package/dist-esm/src/index.js.map +0 -1
- package/dist-esm/src/interfaces.js.map +0 -1
- package/dist-esm/src/log.js +0 -5
- package/dist-esm/src/log.js.map +0 -1
- package/dist-esm/src/logger/debug.js +0 -93
- package/dist-esm/src/logger/debug.js.map +0 -1
- package/dist-esm/src/logger/log.browser.js +0 -23
- package/dist-esm/src/logger/log.browser.js.map +0 -1
- package/dist-esm/src/logger/log.js +0 -8
- package/dist-esm/src/logger/log.js.map +0 -1
- package/dist-esm/src/logger/logger.js +0 -99
- package/dist-esm/src/logger/logger.js.map +0 -1
- package/dist-esm/src/nodeHttpClient.js +0 -332
- package/dist-esm/src/nodeHttpClient.js.map +0 -1
- package/dist-esm/src/pipeline.js +0 -262
- package/dist-esm/src/pipeline.js.map +0 -1
- package/dist-esm/src/pipelineRequest.js +0 -36
- package/dist-esm/src/pipelineRequest.js.map +0 -1
- package/dist-esm/src/policies/bearerTokenAuthenticationPolicy.js +0 -108
- package/dist-esm/src/policies/bearerTokenAuthenticationPolicy.js.map +0 -1
- package/dist-esm/src/policies/decompressResponsePolicy.browser.js +0 -14
- package/dist-esm/src/policies/decompressResponsePolicy.browser.js.map +0 -1
- package/dist-esm/src/policies/decompressResponsePolicy.js.map +0 -1
- package/dist-esm/src/policies/defaultRetryPolicy.js +0 -26
- package/dist-esm/src/policies/defaultRetryPolicy.js.map +0 -1
- package/dist-esm/src/policies/exponentialRetryPolicy.js +0 -22
- package/dist-esm/src/policies/exponentialRetryPolicy.js.map +0 -1
- package/dist-esm/src/policies/formDataPolicy.js +0 -81
- package/dist-esm/src/policies/formDataPolicy.js.map +0 -1
- package/dist-esm/src/policies/logPolicy.js +0 -34
- package/dist-esm/src/policies/logPolicy.js.map +0 -1
- package/dist-esm/src/policies/multipartPolicy.js +0 -112
- package/dist-esm/src/policies/multipartPolicy.js.map +0 -1
- package/dist-esm/src/policies/proxyPolicy.browser.js +0 -27
- package/dist-esm/src/policies/proxyPolicy.browser.js.map +0 -1
- package/dist-esm/src/policies/proxyPolicy.js +0 -171
- package/dist-esm/src/policies/proxyPolicy.js.map +0 -1
- package/dist-esm/src/policies/redirectPolicy.js.map +0 -1
- package/dist-esm/src/policies/retryPolicy.js +0 -106
- package/dist-esm/src/policies/retryPolicy.js.map +0 -1
- package/dist-esm/src/policies/systemErrorRetryPolicy.js +0 -27
- package/dist-esm/src/policies/systemErrorRetryPolicy.js.map +0 -1
- package/dist-esm/src/policies/throttlingRetryPolicy.js +0 -29
- package/dist-esm/src/policies/throttlingRetryPolicy.js.map +0 -1
- package/dist-esm/src/policies/tlsPolicy.js.map +0 -1
- package/dist-esm/src/policies/tracingPolicy.js +0 -120
- package/dist-esm/src/policies/tracingPolicy.js.map +0 -1
- package/dist-esm/src/policies/userAgentPolicy.js +0 -26
- package/dist-esm/src/policies/userAgentPolicy.js.map +0 -1
- package/dist-esm/src/restError.js +0 -48
- package/dist-esm/src/restError.js.map +0 -1
- package/dist-esm/src/retryStrategies/exponentialRetryStrategy.js +0 -70
- package/dist-esm/src/retryStrategies/exponentialRetryStrategy.js.map +0 -1
- package/dist-esm/src/retryStrategies/retryStrategy.js.map +0 -1
- package/dist-esm/src/retryStrategies/throttlingRetryStrategy.js +0 -74
- package/dist-esm/src/retryStrategies/throttlingRetryStrategy.js.map +0 -1
- package/dist-esm/src/tracing/instrumenter.js +0 -61
- package/dist-esm/src/tracing/instrumenter.js.map +0 -1
- package/dist-esm/src/tracing/tracingClient.js +0 -74
- package/dist-esm/src/tracing/tracingClient.js.map +0 -1
- package/dist-esm/src/tracing/tracingContext.js +0 -47
- package/dist-esm/src/tracing/tracingContext.js.map +0 -1
- package/dist-esm/src/util/aborterUtils.js +0 -21
- package/dist-esm/src/util/aborterUtils.js.map +0 -1
- package/dist-esm/src/util/bytesEncoding.browser.js +0 -110
- package/dist-esm/src/util/bytesEncoding.browser.js.map +0 -1
- package/dist-esm/src/util/checkEnvironment.js +0 -41
- package/dist-esm/src/util/checkEnvironment.js.map +0 -1
- package/dist-esm/src/util/createAbortablePromise.js +0 -42
- package/dist-esm/src/util/createAbortablePromise.js.map +0 -1
- package/dist-esm/src/util/delay.js +0 -22
- package/dist-esm/src/util/delay.js.map +0 -1
- package/dist-esm/src/util/error.js +0 -42
- package/dist-esm/src/util/error.js.map +0 -1
- package/dist-esm/src/util/file.js +0 -51
- package/dist-esm/src/util/file.js.map +0 -1
- package/dist-esm/src/util/helpers.js +0 -58
- package/dist-esm/src/util/helpers.js.map +0 -1
- package/dist-esm/src/util/inspect.browser.js +0 -4
- package/dist-esm/src/util/inspect.browser.js.map +0 -1
- package/dist-esm/src/util/inspect.js +0 -5
- package/dist-esm/src/util/inspect.js.map +0 -1
- package/dist-esm/src/util/sanitizer.js +0 -139
- package/dist-esm/src/util/sanitizer.js.map +0 -1
- package/dist-esm/src/util/sha256.browser.js +0 -49
- package/dist-esm/src/util/sha256.browser.js.map +0 -1
- package/dist-esm/src/util/sha256.js +0 -22
- package/dist-esm/src/util/sha256.js.map +0 -1
- package/dist-esm/src/util/stream.browser.js +0 -64
- package/dist-esm/src/util/stream.browser.js.map +0 -1
- package/dist-esm/src/util/stream.js +0 -81
- package/dist-esm/src/util/stream.js.map +0 -1
- package/dist-esm/src/util/tokenCycler.js +0 -149
- package/dist-esm/src/util/tokenCycler.js.map +0 -1
- package/dist-esm/src/util/userAgent.js +0 -30
- package/dist-esm/src/util/userAgent.js.map +0 -1
- package/dist-esm/src/util/userAgentPlatform.browser.js +0 -20
- package/dist-esm/src/util/userAgentPlatform.browser.js.map +0 -1
- package/dist-esm/src/util/userAgentPlatform.js +0 -17
- package/dist-esm/src/util/userAgentPlatform.js.map +0 -1
- package/dist-esm/src/util/userAgentPlatform.native.js +0 -24
- package/dist-esm/src/util/userAgentPlatform.native.js.map +0 -1
- package/dist-esm/src/util/uuidUtils.browser.js +0 -17
- package/dist-esm/src/util/uuidUtils.browser.js.map +0 -1
- package/dist-esm/src/util/uuidUtils.js +0 -22
- package/dist-esm/src/util/uuidUtils.js.map +0 -1
- package/dist-esm/src/util/uuidUtils.native.js +0 -43
- package/dist-esm/src/util/uuidUtils.native.js.map +0 -1
- package/dist-esm/src/xhrHttpClient.js +0 -167
- package/dist-esm/src/xhrHttpClient.js.map +0 -1
- package/ts-http-runtime.shims.d.ts +0 -12
- /package/{dist-esm/src → dist/browser}/abort-controller/AbortError.js +0 -0
- /package/{dist-esm/src → dist/browser}/abort-controller/AbortError.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/abort-controller/AbortSignalLike.js +0 -0
- /package/{dist-esm/src → dist/browser}/abort-controller/AbortSignalLike.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/auth/keyCredential.js +0 -0
- /package/{dist-esm/src → dist/browser}/auth/keyCredential.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/auth/tokenCredential.js +0 -0
- /package/{dist-esm/src → dist/browser}/client/apiVersionPolicy.js +0 -0
- /package/{dist-esm/src → dist/browser}/client/common.js +0 -0
- /package/{dist-esm/src → dist/browser}/client/helpers/getBinaryBody.js +0 -0
- /package/{dist-esm/src → dist/browser}/client/helpers/getBinaryBody.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/client/keyCredentialAuthenticationPolicy.js +0 -0
- /package/{dist-esm/src → dist/browser}/constants.js +0 -0
- /package/{dist-esm/src → dist/browser}/constants.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/interfaces.js +0 -0
- /package/{dist-esm/src → dist/browser}/policies/redirectPolicy.js +0 -0
- /package/{dist-esm/src → dist/browser}/policies/tlsPolicy.js +0 -0
- /package/{dist-esm/src → dist/browser}/retryStrategies/retryStrategy.js +0 -0
- /package/{dist-esm/src → dist/browser}/tracing/interfaces.js +0 -0
- /package/{dist-esm/src → dist/browser}/tracing/interfaces.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/util/object.js +0 -0
- /package/{dist-esm/src → dist/browser}/util/object.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/util/random.js +0 -0
- /package/{dist-esm/src → dist/browser}/util/random.js.map +0 -0
- /package/{dist-esm/src → dist/browser}/util/typeGuards.js +0 -0
- /package/{dist-esm/src → dist/browser}/util/typeGuards.js.map +0 -0
- /package/{dist-esm/src → dist/esm}/policies/decompressResponsePolicy.js +0 -0
- /package/{dist-esm/src → dist/esm}/util/bytesEncoding.js +0 -0
- /package/{dist-esm/src → dist/esm}/util/bytesEncoding.js.map +0 -0
- /package/{types → dist}/ts-http-runtime.d.ts +0 -0
package/dist/index.js
DELETED
|
@@ -1,3694 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var os = require('os');
|
|
6
|
-
var util = require('util');
|
|
7
|
-
var tslib = require('tslib');
|
|
8
|
-
var stream = require('stream');
|
|
9
|
-
var crypto = require('crypto');
|
|
10
|
-
var httpsProxyAgent = require('https-proxy-agent');
|
|
11
|
-
var httpProxyAgent = require('http-proxy-agent');
|
|
12
|
-
var http = require('http');
|
|
13
|
-
var https = require('https');
|
|
14
|
-
var zlib = require('zlib');
|
|
15
|
-
|
|
16
|
-
function _interopNamespaceDefault(e) {
|
|
17
|
-
var n = Object.create(null);
|
|
18
|
-
if (e) {
|
|
19
|
-
Object.keys(e).forEach(function (k) {
|
|
20
|
-
if (k !== 'default') {
|
|
21
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () { return e[k]; }
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
n.default = e;
|
|
30
|
-
return Object.freeze(n);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os);
|
|
34
|
-
var http__namespace = /*#__PURE__*/_interopNamespaceDefault(http);
|
|
35
|
-
var https__namespace = /*#__PURE__*/_interopNamespaceDefault(https);
|
|
36
|
-
var zlib__namespace = /*#__PURE__*/_interopNamespaceDefault(zlib);
|
|
37
|
-
|
|
38
|
-
// Copyright (c) Microsoft Corporation.
|
|
39
|
-
// Licensed under the MIT license.
|
|
40
|
-
const ValidPhaseNames = new Set(["Deserialize", "Serialize", "Retry", "Sign"]);
|
|
41
|
-
/**
|
|
42
|
-
* A private implementation of Pipeline.
|
|
43
|
-
* Do not export this class from the package.
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
class HttpPipeline {
|
|
47
|
-
constructor(policies) {
|
|
48
|
-
var _a;
|
|
49
|
-
this._policies = [];
|
|
50
|
-
this._policies = (_a = policies === null || policies === void 0 ? void 0 : policies.slice(0)) !== null && _a !== void 0 ? _a : [];
|
|
51
|
-
this._orderedPolicies = undefined;
|
|
52
|
-
}
|
|
53
|
-
addPolicy(policy, options = {}) {
|
|
54
|
-
if (options.phase && options.afterPhase) {
|
|
55
|
-
throw new Error("Policies inside a phase cannot specify afterPhase.");
|
|
56
|
-
}
|
|
57
|
-
if (options.phase && !ValidPhaseNames.has(options.phase)) {
|
|
58
|
-
throw new Error(`Invalid phase name: ${options.phase}`);
|
|
59
|
-
}
|
|
60
|
-
if (options.afterPhase && !ValidPhaseNames.has(options.afterPhase)) {
|
|
61
|
-
throw new Error(`Invalid afterPhase name: ${options.afterPhase}`);
|
|
62
|
-
}
|
|
63
|
-
this._policies.push({
|
|
64
|
-
policy,
|
|
65
|
-
options,
|
|
66
|
-
});
|
|
67
|
-
this._orderedPolicies = undefined;
|
|
68
|
-
}
|
|
69
|
-
removePolicy(options) {
|
|
70
|
-
const removedPolicies = [];
|
|
71
|
-
this._policies = this._policies.filter((policyDescriptor) => {
|
|
72
|
-
if ((options.name && policyDescriptor.policy.name === options.name) ||
|
|
73
|
-
(options.phase && policyDescriptor.options.phase === options.phase)) {
|
|
74
|
-
removedPolicies.push(policyDescriptor.policy);
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
this._orderedPolicies = undefined;
|
|
82
|
-
return removedPolicies;
|
|
83
|
-
}
|
|
84
|
-
sendRequest(httpClient, request) {
|
|
85
|
-
const policies = this.getOrderedPolicies();
|
|
86
|
-
const pipeline = policies.reduceRight((next, policy) => {
|
|
87
|
-
return (req) => {
|
|
88
|
-
return policy.sendRequest(req, next);
|
|
89
|
-
};
|
|
90
|
-
}, (req) => httpClient.sendRequest(req));
|
|
91
|
-
return pipeline(request);
|
|
92
|
-
}
|
|
93
|
-
getOrderedPolicies() {
|
|
94
|
-
if (!this._orderedPolicies) {
|
|
95
|
-
this._orderedPolicies = this.orderPolicies();
|
|
96
|
-
}
|
|
97
|
-
return this._orderedPolicies;
|
|
98
|
-
}
|
|
99
|
-
clone() {
|
|
100
|
-
return new HttpPipeline(this._policies);
|
|
101
|
-
}
|
|
102
|
-
static create() {
|
|
103
|
-
return new HttpPipeline();
|
|
104
|
-
}
|
|
105
|
-
orderPolicies() {
|
|
106
|
-
/**
|
|
107
|
-
* The goal of this method is to reliably order pipeline policies
|
|
108
|
-
* based on their declared requirements when they were added.
|
|
109
|
-
*
|
|
110
|
-
* Order is first determined by phase:
|
|
111
|
-
*
|
|
112
|
-
* 1. Serialize Phase
|
|
113
|
-
* 2. Policies not in a phase
|
|
114
|
-
* 3. Deserialize Phase
|
|
115
|
-
* 4. Retry Phase
|
|
116
|
-
* 5. Sign Phase
|
|
117
|
-
*
|
|
118
|
-
* Within each phase, policies are executed in the order
|
|
119
|
-
* they were added unless they were specified to execute
|
|
120
|
-
* before/after other policies or after a particular phase.
|
|
121
|
-
*
|
|
122
|
-
* To determine the final order, we will walk the policy list
|
|
123
|
-
* in phase order multiple times until all dependencies are
|
|
124
|
-
* satisfied.
|
|
125
|
-
*
|
|
126
|
-
* `afterPolicies` are the set of policies that must be
|
|
127
|
-
* executed before a given policy. This requirement is
|
|
128
|
-
* considered satisfied when each of the listed policies
|
|
129
|
-
* have been scheduled.
|
|
130
|
-
*
|
|
131
|
-
* `beforePolicies` are the set of policies that must be
|
|
132
|
-
* executed after a given policy. Since this dependency
|
|
133
|
-
* can be expressed by converting it into a equivalent
|
|
134
|
-
* `afterPolicies` declarations, they are normalized
|
|
135
|
-
* into that form for simplicity.
|
|
136
|
-
*
|
|
137
|
-
* An `afterPhase` dependency is considered satisfied when all
|
|
138
|
-
* policies in that phase have scheduled.
|
|
139
|
-
*
|
|
140
|
-
*/
|
|
141
|
-
const result = [];
|
|
142
|
-
// Track all policies we know about.
|
|
143
|
-
const policyMap = new Map();
|
|
144
|
-
function createPhase(name) {
|
|
145
|
-
return {
|
|
146
|
-
name,
|
|
147
|
-
policies: new Set(),
|
|
148
|
-
hasRun: false,
|
|
149
|
-
hasAfterPolicies: false,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
// Track policies for each phase.
|
|
153
|
-
const serializePhase = createPhase("Serialize");
|
|
154
|
-
const noPhase = createPhase("None");
|
|
155
|
-
const deserializePhase = createPhase("Deserialize");
|
|
156
|
-
const retryPhase = createPhase("Retry");
|
|
157
|
-
const signPhase = createPhase("Sign");
|
|
158
|
-
// a list of phases in order
|
|
159
|
-
const orderedPhases = [serializePhase, noPhase, deserializePhase, retryPhase, signPhase];
|
|
160
|
-
// Small helper function to map phase name to each Phase
|
|
161
|
-
function getPhase(phase) {
|
|
162
|
-
if (phase === "Retry") {
|
|
163
|
-
return retryPhase;
|
|
164
|
-
}
|
|
165
|
-
else if (phase === "Serialize") {
|
|
166
|
-
return serializePhase;
|
|
167
|
-
}
|
|
168
|
-
else if (phase === "Deserialize") {
|
|
169
|
-
return deserializePhase;
|
|
170
|
-
}
|
|
171
|
-
else if (phase === "Sign") {
|
|
172
|
-
return signPhase;
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
return noPhase;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
// First walk each policy and create a node to track metadata.
|
|
179
|
-
for (const descriptor of this._policies) {
|
|
180
|
-
const policy = descriptor.policy;
|
|
181
|
-
const options = descriptor.options;
|
|
182
|
-
const policyName = policy.name;
|
|
183
|
-
if (policyMap.has(policyName)) {
|
|
184
|
-
throw new Error("Duplicate policy names not allowed in pipeline");
|
|
185
|
-
}
|
|
186
|
-
const node = {
|
|
187
|
-
policy,
|
|
188
|
-
dependsOn: new Set(),
|
|
189
|
-
dependants: new Set(),
|
|
190
|
-
};
|
|
191
|
-
if (options.afterPhase) {
|
|
192
|
-
node.afterPhase = getPhase(options.afterPhase);
|
|
193
|
-
node.afterPhase.hasAfterPolicies = true;
|
|
194
|
-
}
|
|
195
|
-
policyMap.set(policyName, node);
|
|
196
|
-
const phase = getPhase(options.phase);
|
|
197
|
-
phase.policies.add(node);
|
|
198
|
-
}
|
|
199
|
-
// Now that each policy has a node, connect dependency references.
|
|
200
|
-
for (const descriptor of this._policies) {
|
|
201
|
-
const { policy, options } = descriptor;
|
|
202
|
-
const policyName = policy.name;
|
|
203
|
-
const node = policyMap.get(policyName);
|
|
204
|
-
if (!node) {
|
|
205
|
-
throw new Error(`Missing node for policy ${policyName}`);
|
|
206
|
-
}
|
|
207
|
-
if (options.afterPolicies) {
|
|
208
|
-
for (const afterPolicyName of options.afterPolicies) {
|
|
209
|
-
const afterNode = policyMap.get(afterPolicyName);
|
|
210
|
-
if (afterNode) {
|
|
211
|
-
// Linking in both directions helps later
|
|
212
|
-
// when we want to notify dependants.
|
|
213
|
-
node.dependsOn.add(afterNode);
|
|
214
|
-
afterNode.dependants.add(node);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (options.beforePolicies) {
|
|
219
|
-
for (const beforePolicyName of options.beforePolicies) {
|
|
220
|
-
const beforeNode = policyMap.get(beforePolicyName);
|
|
221
|
-
if (beforeNode) {
|
|
222
|
-
// To execute before another node, make it
|
|
223
|
-
// depend on the current node.
|
|
224
|
-
beforeNode.dependsOn.add(node);
|
|
225
|
-
node.dependants.add(beforeNode);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
function walkPhase(phase) {
|
|
231
|
-
phase.hasRun = true;
|
|
232
|
-
// Sets iterate in insertion order
|
|
233
|
-
for (const node of phase.policies) {
|
|
234
|
-
if (node.afterPhase && (!node.afterPhase.hasRun || node.afterPhase.policies.size)) {
|
|
235
|
-
// If this node is waiting on a phase to complete,
|
|
236
|
-
// we need to skip it for now.
|
|
237
|
-
// Even if the phase is empty, we should wait for it
|
|
238
|
-
// to be walked to avoid re-ordering policies.
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
if (node.dependsOn.size === 0) {
|
|
242
|
-
// If there's nothing else we're waiting for, we can
|
|
243
|
-
// add this policy to the result list.
|
|
244
|
-
result.push(node.policy);
|
|
245
|
-
// Notify anything that depends on this policy that
|
|
246
|
-
// the policy has been scheduled.
|
|
247
|
-
for (const dependant of node.dependants) {
|
|
248
|
-
dependant.dependsOn.delete(node);
|
|
249
|
-
}
|
|
250
|
-
policyMap.delete(node.policy.name);
|
|
251
|
-
phase.policies.delete(node);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
function walkPhases() {
|
|
256
|
-
for (const phase of orderedPhases) {
|
|
257
|
-
walkPhase(phase);
|
|
258
|
-
// if the phase isn't complete
|
|
259
|
-
if (phase.policies.size > 0 && phase !== noPhase) {
|
|
260
|
-
if (!noPhase.hasRun) {
|
|
261
|
-
// Try running noPhase to see if that unblocks this phase next tick.
|
|
262
|
-
// This can happen if a phase that happens before noPhase
|
|
263
|
-
// is waiting on a noPhase policy to complete.
|
|
264
|
-
walkPhase(noPhase);
|
|
265
|
-
}
|
|
266
|
-
// Don't proceed to the next phase until this phase finishes.
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
if (phase.hasAfterPolicies) {
|
|
270
|
-
// Run any policies unblocked by this phase
|
|
271
|
-
walkPhase(noPhase);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
// Iterate until we've put every node in the result list.
|
|
276
|
-
let iteration = 0;
|
|
277
|
-
while (policyMap.size > 0) {
|
|
278
|
-
iteration++;
|
|
279
|
-
const initialResultLength = result.length;
|
|
280
|
-
// Keep walking each phase in order until we can order every node.
|
|
281
|
-
walkPhases();
|
|
282
|
-
// The result list *should* get at least one larger each time
|
|
283
|
-
// after the first full pass.
|
|
284
|
-
// Otherwise, we're going to loop forever.
|
|
285
|
-
if (result.length <= initialResultLength && iteration > 1) {
|
|
286
|
-
throw new Error("Cannot satisfy policy dependencies due to requirements cycle.");
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return result;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Creates a totally empty pipeline.
|
|
294
|
-
* Useful for testing or creating a custom one.
|
|
295
|
-
*/
|
|
296
|
-
function createEmptyPipeline() {
|
|
297
|
-
return HttpPipeline.create();
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// Copyright (c) Microsoft Corporation.
|
|
301
|
-
// Licensed under the MIT license.
|
|
302
|
-
function log(message, ...args) {
|
|
303
|
-
process.stderr.write(`${util.format(message, ...args)}${os.EOL}`);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Copyright (c) Microsoft Corporation.
|
|
307
|
-
// Licensed under the MIT license.
|
|
308
|
-
const debugEnvVariable = (typeof process !== "undefined" && process.env && process.env.DEBUG) || undefined;
|
|
309
|
-
let enabledString;
|
|
310
|
-
let enabledNamespaces = [];
|
|
311
|
-
let skippedNamespaces = [];
|
|
312
|
-
const debuggers = [];
|
|
313
|
-
if (debugEnvVariable) {
|
|
314
|
-
enable(debugEnvVariable);
|
|
315
|
-
}
|
|
316
|
-
const debugObj = Object.assign((namespace) => {
|
|
317
|
-
return createDebugger(namespace);
|
|
318
|
-
}, {
|
|
319
|
-
enable,
|
|
320
|
-
enabled,
|
|
321
|
-
disable,
|
|
322
|
-
log,
|
|
323
|
-
});
|
|
324
|
-
function enable(namespaces) {
|
|
325
|
-
enabledString = namespaces;
|
|
326
|
-
enabledNamespaces = [];
|
|
327
|
-
skippedNamespaces = [];
|
|
328
|
-
const wildcard = /\*/g;
|
|
329
|
-
const namespaceList = namespaces.split(",").map((ns) => ns.trim().replace(wildcard, ".*?"));
|
|
330
|
-
for (const ns of namespaceList) {
|
|
331
|
-
if (ns.startsWith("-")) {
|
|
332
|
-
skippedNamespaces.push(new RegExp(`^${ns.substr(1)}$`));
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
enabledNamespaces.push(new RegExp(`^${ns}$`));
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
for (const instance of debuggers) {
|
|
339
|
-
instance.enabled = enabled(instance.namespace);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
function enabled(namespace) {
|
|
343
|
-
if (namespace.endsWith("*")) {
|
|
344
|
-
return true;
|
|
345
|
-
}
|
|
346
|
-
for (const skipped of skippedNamespaces) {
|
|
347
|
-
if (skipped.test(namespace)) {
|
|
348
|
-
return false;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
for (const enabledNamespace of enabledNamespaces) {
|
|
352
|
-
if (enabledNamespace.test(namespace)) {
|
|
353
|
-
return true;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return false;
|
|
357
|
-
}
|
|
358
|
-
function disable() {
|
|
359
|
-
const result = enabledString || "";
|
|
360
|
-
enable("");
|
|
361
|
-
return result;
|
|
362
|
-
}
|
|
363
|
-
function createDebugger(namespace) {
|
|
364
|
-
const newDebugger = Object.assign(debug, {
|
|
365
|
-
enabled: enabled(namespace),
|
|
366
|
-
destroy,
|
|
367
|
-
log: debugObj.log,
|
|
368
|
-
namespace,
|
|
369
|
-
extend,
|
|
370
|
-
});
|
|
371
|
-
function debug(...args) {
|
|
372
|
-
if (!newDebugger.enabled) {
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
if (args.length > 0) {
|
|
376
|
-
args[0] = `${namespace} ${args[0]}`;
|
|
377
|
-
}
|
|
378
|
-
newDebugger.log(...args);
|
|
379
|
-
}
|
|
380
|
-
debuggers.push(newDebugger);
|
|
381
|
-
return newDebugger;
|
|
382
|
-
}
|
|
383
|
-
function destroy() {
|
|
384
|
-
const index = debuggers.indexOf(this);
|
|
385
|
-
if (index >= 0) {
|
|
386
|
-
debuggers.splice(index, 1);
|
|
387
|
-
return true;
|
|
388
|
-
}
|
|
389
|
-
return false;
|
|
390
|
-
}
|
|
391
|
-
function extend(namespace) {
|
|
392
|
-
const newDebugger = createDebugger(`${this.namespace}:${namespace}`);
|
|
393
|
-
newDebugger.log = this.log;
|
|
394
|
-
return newDebugger;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// Copyright (c) Microsoft Corporation.
|
|
398
|
-
// Licensed under the MIT license.
|
|
399
|
-
const registeredLoggers = new Set();
|
|
400
|
-
const logLevelFromEnv = (typeof process !== "undefined" && process.env && process.env.TYPESPEC_RUNTIME_LOG_LEVEL) ||
|
|
401
|
-
undefined;
|
|
402
|
-
let typeSpecRuntimeLogLevel;
|
|
403
|
-
/**
|
|
404
|
-
* The TypeSpecRuntimeLogger provides a mechanism for overriding where logs are output to.
|
|
405
|
-
* By default, logs are sent to stderr.
|
|
406
|
-
* Override the `log` method to redirect logs to another location.
|
|
407
|
-
*/
|
|
408
|
-
const TypeSpecRuntimeLogger = debugObj("typeSpecRuntime");
|
|
409
|
-
TypeSpecRuntimeLogger.log = (...args) => {
|
|
410
|
-
debugObj.log(...args);
|
|
411
|
-
};
|
|
412
|
-
const TYPESPEC_RUNTIME_LOG_LEVELS = ["verbose", "info", "warning", "error"];
|
|
413
|
-
if (logLevelFromEnv) {
|
|
414
|
-
// avoid calling setLogLevel because we don't want a mis-set environment variable to crash
|
|
415
|
-
if (isTypeSpecRuntimeLogLevel(logLevelFromEnv)) {
|
|
416
|
-
setLogLevel(logLevelFromEnv);
|
|
417
|
-
}
|
|
418
|
-
else {
|
|
419
|
-
console.error(`TYPESPEC_RUNTIME_LOG_LEVEL set to unknown log level '${logLevelFromEnv}'; logging is not enabled. Acceptable values: ${TYPESPEC_RUNTIME_LOG_LEVELS.join(", ")}.`);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Immediately enables logging at the specified log level. If no level is specified, logging is disabled.
|
|
424
|
-
* @param level - The log level to enable for logging.
|
|
425
|
-
* Options from most verbose to least verbose are:
|
|
426
|
-
* - verbose
|
|
427
|
-
* - info
|
|
428
|
-
* - warning
|
|
429
|
-
* - error
|
|
430
|
-
*/
|
|
431
|
-
function setLogLevel(level) {
|
|
432
|
-
if (level && !isTypeSpecRuntimeLogLevel(level)) {
|
|
433
|
-
throw new Error(`Unknown log level '${level}'. Acceptable values: ${TYPESPEC_RUNTIME_LOG_LEVELS.join(",")}`);
|
|
434
|
-
}
|
|
435
|
-
typeSpecRuntimeLogLevel = level;
|
|
436
|
-
const enabledNamespaces = [];
|
|
437
|
-
for (const logger of registeredLoggers) {
|
|
438
|
-
if (shouldEnable(logger)) {
|
|
439
|
-
enabledNamespaces.push(logger.namespace);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
debugObj.enable(enabledNamespaces.join(","));
|
|
443
|
-
}
|
|
444
|
-
const levelMap = {
|
|
445
|
-
verbose: 400,
|
|
446
|
-
info: 300,
|
|
447
|
-
warning: 200,
|
|
448
|
-
error: 100,
|
|
449
|
-
};
|
|
450
|
-
/**
|
|
451
|
-
* Creates a logger for use by the SDKs that inherits from `TypeSpecRuntimeLogger`.
|
|
452
|
-
* @param namespace - The name of the SDK package.
|
|
453
|
-
* @hidden
|
|
454
|
-
*/
|
|
455
|
-
function createClientLogger(namespace) {
|
|
456
|
-
const clientRootLogger = TypeSpecRuntimeLogger.extend(namespace);
|
|
457
|
-
patchLogMethod(TypeSpecRuntimeLogger, clientRootLogger);
|
|
458
|
-
return {
|
|
459
|
-
error: createLogger(clientRootLogger, "error"),
|
|
460
|
-
warning: createLogger(clientRootLogger, "warning"),
|
|
461
|
-
info: createLogger(clientRootLogger, "info"),
|
|
462
|
-
verbose: createLogger(clientRootLogger, "verbose"),
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
function patchLogMethod(parent, child) {
|
|
466
|
-
child.log = (...args) => {
|
|
467
|
-
parent.log(...args);
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
function createLogger(parent, level) {
|
|
471
|
-
const logger = Object.assign(parent.extend(level), {
|
|
472
|
-
level,
|
|
473
|
-
});
|
|
474
|
-
patchLogMethod(parent, logger);
|
|
475
|
-
if (shouldEnable(logger)) {
|
|
476
|
-
const enabledNamespaces = debugObj.disable();
|
|
477
|
-
debugObj.enable(enabledNamespaces + "," + logger.namespace);
|
|
478
|
-
}
|
|
479
|
-
registeredLoggers.add(logger);
|
|
480
|
-
return logger;
|
|
481
|
-
}
|
|
482
|
-
function shouldEnable(logger) {
|
|
483
|
-
return Boolean(typeSpecRuntimeLogLevel && levelMap[logger.level] <= levelMap[typeSpecRuntimeLogLevel]);
|
|
484
|
-
}
|
|
485
|
-
function isTypeSpecRuntimeLogLevel(logLevel) {
|
|
486
|
-
return TYPESPEC_RUNTIME_LOG_LEVELS.includes(logLevel);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// Copyright (c) Microsoft Corporation.
|
|
490
|
-
// Licensed under the MIT license.
|
|
491
|
-
const logger = createClientLogger("ts-http-runtime");
|
|
492
|
-
|
|
493
|
-
// Copyright (c) Microsoft Corporation.
|
|
494
|
-
// Licensed under the MIT license.
|
|
495
|
-
/**
|
|
496
|
-
* Helper to determine when an input is a generic JS object.
|
|
497
|
-
* @returns true when input is an object type that is not null, Array, RegExp, or Date.
|
|
498
|
-
*/
|
|
499
|
-
function isObject(input) {
|
|
500
|
-
return (typeof input === "object" &&
|
|
501
|
-
input !== null &&
|
|
502
|
-
!Array.isArray(input) &&
|
|
503
|
-
!(input instanceof RegExp) &&
|
|
504
|
-
!(input instanceof Date));
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
// Copyright (c) Microsoft Corporation.
|
|
508
|
-
// Licensed under the MIT license.
|
|
509
|
-
const RedactedString = "REDACTED";
|
|
510
|
-
// Make sure this list is up-to-date with the one under core/logger/Readme#Keyconcepts
|
|
511
|
-
const defaultAllowedHeaderNames = [
|
|
512
|
-
"x-ms-client-request-id",
|
|
513
|
-
"x-ms-return-client-request-id",
|
|
514
|
-
"x-ms-useragent",
|
|
515
|
-
"x-ms-correlation-request-id",
|
|
516
|
-
"x-ms-request-id",
|
|
517
|
-
"client-request-id",
|
|
518
|
-
"ms-cv",
|
|
519
|
-
"return-client-request-id",
|
|
520
|
-
"traceparent",
|
|
521
|
-
"Access-Control-Allow-Credentials",
|
|
522
|
-
"Access-Control-Allow-Headers",
|
|
523
|
-
"Access-Control-Allow-Methods",
|
|
524
|
-
"Access-Control-Allow-Origin",
|
|
525
|
-
"Access-Control-Expose-Headers",
|
|
526
|
-
"Access-Control-Max-Age",
|
|
527
|
-
"Access-Control-Request-Headers",
|
|
528
|
-
"Access-Control-Request-Method",
|
|
529
|
-
"Origin",
|
|
530
|
-
"Accept",
|
|
531
|
-
"Accept-Encoding",
|
|
532
|
-
"Cache-Control",
|
|
533
|
-
"Connection",
|
|
534
|
-
"Content-Length",
|
|
535
|
-
"Content-Type",
|
|
536
|
-
"Date",
|
|
537
|
-
"ETag",
|
|
538
|
-
"Expires",
|
|
539
|
-
"If-Match",
|
|
540
|
-
"If-Modified-Since",
|
|
541
|
-
"If-None-Match",
|
|
542
|
-
"If-Unmodified-Since",
|
|
543
|
-
"Last-Modified",
|
|
544
|
-
"Pragma",
|
|
545
|
-
"Request-Id",
|
|
546
|
-
"Retry-After",
|
|
547
|
-
"Server",
|
|
548
|
-
"Transfer-Encoding",
|
|
549
|
-
"User-Agent",
|
|
550
|
-
"WWW-Authenticate",
|
|
551
|
-
];
|
|
552
|
-
const defaultAllowedQueryParameters = ["api-version"];
|
|
553
|
-
/**
|
|
554
|
-
* @internal
|
|
555
|
-
*/
|
|
556
|
-
class Sanitizer {
|
|
557
|
-
constructor({ additionalAllowedHeaderNames: allowedHeaderNames = [], additionalAllowedQueryParameters: allowedQueryParameters = [], } = {}) {
|
|
558
|
-
allowedHeaderNames = defaultAllowedHeaderNames.concat(allowedHeaderNames);
|
|
559
|
-
allowedQueryParameters = defaultAllowedQueryParameters.concat(allowedQueryParameters);
|
|
560
|
-
this.allowedHeaderNames = new Set(allowedHeaderNames.map((n) => n.toLowerCase()));
|
|
561
|
-
this.allowedQueryParameters = new Set(allowedQueryParameters.map((p) => p.toLowerCase()));
|
|
562
|
-
}
|
|
563
|
-
sanitize(obj) {
|
|
564
|
-
const seen = new Set();
|
|
565
|
-
return JSON.stringify(obj, (key, value) => {
|
|
566
|
-
// Ensure Errors include their interesting non-enumerable members
|
|
567
|
-
if (value instanceof Error) {
|
|
568
|
-
return Object.assign(Object.assign({}, value), { name: value.name, message: value.message });
|
|
569
|
-
}
|
|
570
|
-
if (key === "headers") {
|
|
571
|
-
return this.sanitizeHeaders(value);
|
|
572
|
-
}
|
|
573
|
-
else if (key === "url") {
|
|
574
|
-
return this.sanitizeUrl(value);
|
|
575
|
-
}
|
|
576
|
-
else if (key === "query") {
|
|
577
|
-
return this.sanitizeQuery(value);
|
|
578
|
-
}
|
|
579
|
-
else if (key === "body") {
|
|
580
|
-
// Don't log the request body
|
|
581
|
-
return undefined;
|
|
582
|
-
}
|
|
583
|
-
else if (key === "response") {
|
|
584
|
-
// Don't log response again
|
|
585
|
-
return undefined;
|
|
586
|
-
}
|
|
587
|
-
else if (key === "operationSpec") {
|
|
588
|
-
// When using sendOperationRequest, the request carries a massive
|
|
589
|
-
// field with the autorest spec. No need to log it.
|
|
590
|
-
return undefined;
|
|
591
|
-
}
|
|
592
|
-
else if (Array.isArray(value) || isObject(value)) {
|
|
593
|
-
if (seen.has(value)) {
|
|
594
|
-
return "[Circular]";
|
|
595
|
-
}
|
|
596
|
-
seen.add(value);
|
|
597
|
-
}
|
|
598
|
-
return value;
|
|
599
|
-
}, 2);
|
|
600
|
-
}
|
|
601
|
-
sanitizeHeaders(obj) {
|
|
602
|
-
const sanitized = {};
|
|
603
|
-
for (const key of Object.keys(obj)) {
|
|
604
|
-
if (this.allowedHeaderNames.has(key.toLowerCase())) {
|
|
605
|
-
sanitized[key] = obj[key];
|
|
606
|
-
}
|
|
607
|
-
else {
|
|
608
|
-
sanitized[key] = RedactedString;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
return sanitized;
|
|
612
|
-
}
|
|
613
|
-
sanitizeQuery(value) {
|
|
614
|
-
if (typeof value !== "object" || value === null) {
|
|
615
|
-
return value;
|
|
616
|
-
}
|
|
617
|
-
const sanitized = {};
|
|
618
|
-
for (const k of Object.keys(value)) {
|
|
619
|
-
if (this.allowedQueryParameters.has(k.toLowerCase())) {
|
|
620
|
-
sanitized[k] = value[k];
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
sanitized[k] = RedactedString;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
return sanitized;
|
|
627
|
-
}
|
|
628
|
-
sanitizeUrl(value) {
|
|
629
|
-
if (typeof value !== "string" || value === null) {
|
|
630
|
-
return value;
|
|
631
|
-
}
|
|
632
|
-
const url = new URL(value);
|
|
633
|
-
if (!url.search) {
|
|
634
|
-
return value;
|
|
635
|
-
}
|
|
636
|
-
for (const [key] of url.searchParams) {
|
|
637
|
-
if (!this.allowedQueryParameters.has(key.toLowerCase())) {
|
|
638
|
-
url.searchParams.set(key, RedactedString);
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
return url.toString();
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
// Copyright (c) Microsoft Corporation.
|
|
646
|
-
// Licensed under the MIT license.
|
|
647
|
-
/**
|
|
648
|
-
* The programmatic identifier of the logPolicy.
|
|
649
|
-
*/
|
|
650
|
-
const logPolicyName = "logPolicy";
|
|
651
|
-
/**
|
|
652
|
-
* A policy that logs all requests and responses.
|
|
653
|
-
* @param options - Options to configure logPolicy.
|
|
654
|
-
*/
|
|
655
|
-
function logPolicy(options = {}) {
|
|
656
|
-
var _a;
|
|
657
|
-
const logger$1 = (_a = options.logger) !== null && _a !== void 0 ? _a : logger.info;
|
|
658
|
-
const sanitizer = new Sanitizer({
|
|
659
|
-
additionalAllowedHeaderNames: options.additionalAllowedHeaderNames,
|
|
660
|
-
additionalAllowedQueryParameters: options.additionalAllowedQueryParameters,
|
|
661
|
-
});
|
|
662
|
-
return {
|
|
663
|
-
name: logPolicyName,
|
|
664
|
-
async sendRequest(request, next) {
|
|
665
|
-
if (!logger$1.enabled) {
|
|
666
|
-
return next(request);
|
|
667
|
-
}
|
|
668
|
-
logger$1(`Request: ${sanitizer.sanitize(request)}`);
|
|
669
|
-
const response = await next(request);
|
|
670
|
-
logger$1(`Response status code: ${response.status}`);
|
|
671
|
-
logger$1(`Headers: ${sanitizer.sanitize(response.headers)}`);
|
|
672
|
-
return response;
|
|
673
|
-
},
|
|
674
|
-
};
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
// Copyright (c) Microsoft Corporation.
|
|
678
|
-
// Licensed under the MIT license.
|
|
679
|
-
/**
|
|
680
|
-
* The programmatic identifier of the redirectPolicy.
|
|
681
|
-
*/
|
|
682
|
-
const redirectPolicyName = "redirectPolicy";
|
|
683
|
-
/**
|
|
684
|
-
* Methods that are allowed to follow redirects 301 and 302
|
|
685
|
-
*/
|
|
686
|
-
const allowedRedirect = ["GET", "HEAD"];
|
|
687
|
-
/**
|
|
688
|
-
* A policy to follow Location headers from the server in order
|
|
689
|
-
* to support server-side redirection.
|
|
690
|
-
* In the browser, this policy is not used.
|
|
691
|
-
* @param options - Options to control policy behavior.
|
|
692
|
-
*/
|
|
693
|
-
function redirectPolicy(options = {}) {
|
|
694
|
-
const { maxRetries = 20 } = options;
|
|
695
|
-
return {
|
|
696
|
-
name: redirectPolicyName,
|
|
697
|
-
async sendRequest(request, next) {
|
|
698
|
-
const response = await next(request);
|
|
699
|
-
return handleRedirect(next, response, maxRetries);
|
|
700
|
-
},
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
async function handleRedirect(next, response, maxRetries, currentRetries = 0) {
|
|
704
|
-
const { request, status, headers } = response;
|
|
705
|
-
const locationHeader = headers.get("location");
|
|
706
|
-
if (locationHeader &&
|
|
707
|
-
(status === 300 ||
|
|
708
|
-
(status === 301 && allowedRedirect.includes(request.method)) ||
|
|
709
|
-
(status === 302 && allowedRedirect.includes(request.method)) ||
|
|
710
|
-
(status === 303 && request.method === "POST") ||
|
|
711
|
-
status === 307) &&
|
|
712
|
-
currentRetries < maxRetries) {
|
|
713
|
-
const url = new URL(locationHeader, request.url);
|
|
714
|
-
request.url = url.toString();
|
|
715
|
-
// POST request with Status code 303 should be converted into a
|
|
716
|
-
// redirected GET request if the redirect url is present in the location header
|
|
717
|
-
if (status === 303) {
|
|
718
|
-
request.method = "GET";
|
|
719
|
-
request.headers.delete("Content-Length");
|
|
720
|
-
delete request.body;
|
|
721
|
-
}
|
|
722
|
-
request.headers.delete("Authorization");
|
|
723
|
-
const res = await next(request);
|
|
724
|
-
return handleRedirect(next, res, maxRetries, currentRetries + 1);
|
|
725
|
-
}
|
|
726
|
-
return response;
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
// Copyright (c) Microsoft Corporation.
|
|
730
|
-
// Licensed under the MIT license.
|
|
731
|
-
/**
|
|
732
|
-
* @internal
|
|
733
|
-
*/
|
|
734
|
-
function getHeaderName() {
|
|
735
|
-
return "User-Agent";
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* @internal
|
|
739
|
-
*/
|
|
740
|
-
function setPlatformSpecificData(map) {
|
|
741
|
-
map.set("Node", process.version);
|
|
742
|
-
map.set("OS", `(${os__namespace.arch()}-${os__namespace.type()}-${os__namespace.release()})`);
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
// Copyright (c) Microsoft Corporation.
|
|
746
|
-
// Licensed under the MIT license.
|
|
747
|
-
const SDK_VERSION = "1.0.0-beta.1";
|
|
748
|
-
const DEFAULT_RETRY_POLICY_COUNT = 3;
|
|
749
|
-
|
|
750
|
-
// Copyright (c) Microsoft Corporation.
|
|
751
|
-
// Licensed under the MIT license.
|
|
752
|
-
function getUserAgentString(telemetryInfo) {
|
|
753
|
-
const parts = [];
|
|
754
|
-
for (const [key, value] of telemetryInfo) {
|
|
755
|
-
const token = value ? `${key}/${value}` : key;
|
|
756
|
-
parts.push(token);
|
|
757
|
-
}
|
|
758
|
-
return parts.join(" ");
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* @internal
|
|
762
|
-
*/
|
|
763
|
-
function getUserAgentHeaderName() {
|
|
764
|
-
return getHeaderName();
|
|
765
|
-
}
|
|
766
|
-
/**
|
|
767
|
-
* @internal
|
|
768
|
-
*/
|
|
769
|
-
function getUserAgentValue(prefix) {
|
|
770
|
-
const runtimeInfo = new Map();
|
|
771
|
-
runtimeInfo.set("ts-http-runtime", SDK_VERSION);
|
|
772
|
-
setPlatformSpecificData(runtimeInfo);
|
|
773
|
-
const defaultAgent = getUserAgentString(runtimeInfo);
|
|
774
|
-
const userAgentValue = prefix ? `${prefix} ${defaultAgent}` : defaultAgent;
|
|
775
|
-
return userAgentValue;
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
// Copyright (c) Microsoft Corporation.
|
|
779
|
-
// Licensed under the MIT license.
|
|
780
|
-
const UserAgentHeaderName = getUserAgentHeaderName();
|
|
781
|
-
/**
|
|
782
|
-
* The programmatic identifier of the userAgentPolicy.
|
|
783
|
-
*/
|
|
784
|
-
const userAgentPolicyName = "userAgentPolicy";
|
|
785
|
-
/**
|
|
786
|
-
* A policy that sets the User-Agent header (or equivalent) to reflect
|
|
787
|
-
* the library version.
|
|
788
|
-
* @param options - Options to customize the user agent value.
|
|
789
|
-
*/
|
|
790
|
-
function userAgentPolicy(options = {}) {
|
|
791
|
-
const userAgentValue = getUserAgentValue(options.userAgentPrefix);
|
|
792
|
-
return {
|
|
793
|
-
name: userAgentPolicyName,
|
|
794
|
-
async sendRequest(request, next) {
|
|
795
|
-
if (!request.headers.has(UserAgentHeaderName)) {
|
|
796
|
-
request.headers.set(UserAgentHeaderName, userAgentValue);
|
|
797
|
-
}
|
|
798
|
-
return next(request);
|
|
799
|
-
},
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
// Copyright (c) Microsoft Corporation.
|
|
804
|
-
// Licensed under the MIT license.
|
|
805
|
-
/**
|
|
806
|
-
* The helper that transforms bytes with specific character encoding into string
|
|
807
|
-
* @param bytes - the uint8array bytes
|
|
808
|
-
* @param format - the format we use to encode the byte
|
|
809
|
-
* @returns a string of the encoded string
|
|
810
|
-
*/
|
|
811
|
-
function uint8ArrayToString(bytes, format) {
|
|
812
|
-
return Buffer.from(bytes).toString(format);
|
|
813
|
-
}
|
|
814
|
-
/**
|
|
815
|
-
* The helper that transforms string to specific character encoded bytes array.
|
|
816
|
-
* @param value - the string to be converted
|
|
817
|
-
* @param format - the format we use to decode the value
|
|
818
|
-
* @returns a uint8array
|
|
819
|
-
*/
|
|
820
|
-
function stringToUint8Array(value, format) {
|
|
821
|
-
return Buffer.from(value, format);
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
// Copyright (c) Microsoft Corporation.
|
|
825
|
-
// Licensed under the MIT license.
|
|
826
|
-
/**
|
|
827
|
-
* Helper TypeGuard that checks if something is defined or not.
|
|
828
|
-
* @param thing - Anything
|
|
829
|
-
*/
|
|
830
|
-
function isDefined(thing) {
|
|
831
|
-
return typeof thing !== "undefined" && thing !== null;
|
|
832
|
-
}
|
|
833
|
-
/**
|
|
834
|
-
* Helper TypeGuard that checks if the input is an object with the specified properties.
|
|
835
|
-
* @param thing - Anything.
|
|
836
|
-
* @param properties - The name of the properties that should appear in the object.
|
|
837
|
-
*/
|
|
838
|
-
function isObjectWithProperties(thing, properties) {
|
|
839
|
-
if (!isDefined(thing) || typeof thing !== "object") {
|
|
840
|
-
return false;
|
|
841
|
-
}
|
|
842
|
-
for (const property of properties) {
|
|
843
|
-
if (!objectHasProperty(thing, property)) {
|
|
844
|
-
return false;
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
return true;
|
|
848
|
-
}
|
|
849
|
-
/**
|
|
850
|
-
* Helper TypeGuard that checks if the input is an object with the specified property.
|
|
851
|
-
* @param thing - Any object.
|
|
852
|
-
* @param property - The name of the property that should appear in the object.
|
|
853
|
-
*/
|
|
854
|
-
function objectHasProperty(thing, property) {
|
|
855
|
-
return (isDefined(thing) && typeof thing === "object" && property in thing);
|
|
856
|
-
}
|
|
857
|
-
function isNodeReadableStream(x) {
|
|
858
|
-
return Boolean(x && typeof x["pipe"] === "function");
|
|
859
|
-
}
|
|
860
|
-
function isWebReadableStream(x) {
|
|
861
|
-
return Boolean(x &&
|
|
862
|
-
typeof x.getReader === "function" &&
|
|
863
|
-
typeof x.tee === "function");
|
|
864
|
-
}
|
|
865
|
-
function isReadableStream$1(x) {
|
|
866
|
-
return isNodeReadableStream(x) || isWebReadableStream(x);
|
|
867
|
-
}
|
|
868
|
-
function isBlob(x) {
|
|
869
|
-
return typeof x.stream === "function";
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
// Copyright (c) Microsoft Corporation.
|
|
873
|
-
// Licensed under the MIT license.
|
|
874
|
-
function streamAsyncIterator() {
|
|
875
|
-
return tslib.__asyncGenerator(this, arguments, function* streamAsyncIterator_1() {
|
|
876
|
-
const reader = this.getReader();
|
|
877
|
-
try {
|
|
878
|
-
while (true) {
|
|
879
|
-
const { done, value } = yield tslib.__await(reader.read());
|
|
880
|
-
if (done) {
|
|
881
|
-
return yield tslib.__await(void 0);
|
|
882
|
-
}
|
|
883
|
-
yield yield tslib.__await(value);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
finally {
|
|
887
|
-
reader.releaseLock();
|
|
888
|
-
}
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
function makeAsyncIterable(webStream) {
|
|
892
|
-
if (!webStream[Symbol.asyncIterator]) {
|
|
893
|
-
webStream[Symbol.asyncIterator] = streamAsyncIterator.bind(webStream);
|
|
894
|
-
}
|
|
895
|
-
if (!webStream.values) {
|
|
896
|
-
webStream.values = streamAsyncIterator.bind(webStream);
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
function nodeStreamFromWebStream(webStream) {
|
|
900
|
-
makeAsyncIterable(webStream);
|
|
901
|
-
return stream.Readable.fromWeb(webStream);
|
|
902
|
-
}
|
|
903
|
-
function toWebStream(stream$1) {
|
|
904
|
-
return isWebReadableStream(stream$1)
|
|
905
|
-
? stream$1
|
|
906
|
-
: stream.Readable.toWeb(stream.Readable.from(stream$1));
|
|
907
|
-
}
|
|
908
|
-
function toStream(source) {
|
|
909
|
-
if (source instanceof Uint8Array) {
|
|
910
|
-
return stream.Readable.from(Buffer.from(source));
|
|
911
|
-
}
|
|
912
|
-
else if (isBlob(source)) {
|
|
913
|
-
return nodeStreamFromWebStream(source.stream());
|
|
914
|
-
}
|
|
915
|
-
else if (isNodeReadableStream(source)) {
|
|
916
|
-
return source;
|
|
917
|
-
}
|
|
918
|
-
else {
|
|
919
|
-
return nodeStreamFromWebStream(source);
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
function concatenateStreams(sources) {
|
|
923
|
-
if (sources.some(isWebReadableStream)) {
|
|
924
|
-
throw new Error("Was not expecting a Web stream here");
|
|
925
|
-
}
|
|
926
|
-
return stream.Readable.from((function () {
|
|
927
|
-
return tslib.__asyncGenerator(this, arguments, function* () {
|
|
928
|
-
var _a, e_1, _b, _c;
|
|
929
|
-
for (const stream of sources) {
|
|
930
|
-
try {
|
|
931
|
-
for (var _d = true, stream_1 = (e_1 = void 0, tslib.__asyncValues(stream)), stream_1_1; stream_1_1 = yield tslib.__await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
|
|
932
|
-
_c = stream_1_1.value;
|
|
933
|
-
_d = false;
|
|
934
|
-
const chunk = _c;
|
|
935
|
-
yield yield tslib.__await(chunk);
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
939
|
-
finally {
|
|
940
|
-
try {
|
|
941
|
-
if (!_d && !_a && (_b = stream_1.return)) yield tslib.__await(_b.call(stream_1));
|
|
942
|
-
}
|
|
943
|
-
finally { if (e_1) throw e_1.error; }
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
});
|
|
947
|
-
})());
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
// Copyright (c) Microsoft Corporation.
|
|
951
|
-
// Licensed under the MIT license.
|
|
952
|
-
/*
|
|
953
|
-
* NOTE: When moving this file, please update "react-native" section in package.json.
|
|
954
|
-
*/
|
|
955
|
-
/**
|
|
956
|
-
* Generated Universally Unique Identifier
|
|
957
|
-
*
|
|
958
|
-
* @returns RFC4122 v4 UUID.
|
|
959
|
-
*/
|
|
960
|
-
function generateUUID() {
|
|
961
|
-
let uuid = "";
|
|
962
|
-
for (let i = 0; i < 32; i++) {
|
|
963
|
-
// Generate a random number between 0 and 15
|
|
964
|
-
const randomNumber = Math.floor(Math.random() * 16);
|
|
965
|
-
// Set the UUID version to 4 in the 13th position
|
|
966
|
-
if (i === 12) {
|
|
967
|
-
uuid += "4";
|
|
968
|
-
}
|
|
969
|
-
else if (i === 16) {
|
|
970
|
-
// Set the UUID variant to "10" in the 17th position
|
|
971
|
-
uuid += (randomNumber & 0x3) | 0x8;
|
|
972
|
-
}
|
|
973
|
-
else {
|
|
974
|
-
// Add a random hexadecimal digit to the UUID string
|
|
975
|
-
uuid += randomNumber.toString(16);
|
|
976
|
-
}
|
|
977
|
-
// Add hyphens to the UUID string at the appropriate positions
|
|
978
|
-
if (i === 7 || i === 11 || i === 15 || i === 19) {
|
|
979
|
-
uuid += "-";
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
return uuid;
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
// Copyright (c) Microsoft Corporation.
|
|
986
|
-
// Licensed under the MIT license.
|
|
987
|
-
var _a$1;
|
|
988
|
-
// NOTE: This is a workaround until we can use `globalThis.crypto.randomUUID` in Node.js 19+.
|
|
989
|
-
let uuidFunction = typeof ((_a$1 = globalThis === null || globalThis === void 0 ? void 0 : globalThis.crypto) === null || _a$1 === void 0 ? void 0 : _a$1.randomUUID) === "function"
|
|
990
|
-
? globalThis.crypto.randomUUID.bind(globalThis.crypto)
|
|
991
|
-
: crypto.randomUUID;
|
|
992
|
-
// Not defined in earlier versions of Node.js 14
|
|
993
|
-
if (!uuidFunction) {
|
|
994
|
-
uuidFunction = generateUUID;
|
|
995
|
-
}
|
|
996
|
-
/**
|
|
997
|
-
* Generated Universally Unique Identifier
|
|
998
|
-
*
|
|
999
|
-
* @returns RFC4122 v4 UUID.
|
|
1000
|
-
*/
|
|
1001
|
-
function randomUUID() {
|
|
1002
|
-
return uuidFunction();
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
// Copyright (c) Microsoft Corporation.
|
|
1006
|
-
// Licensed under the MIT license.
|
|
1007
|
-
function generateBoundary() {
|
|
1008
|
-
return `----AzSDKFormBoundary${randomUUID()}`;
|
|
1009
|
-
}
|
|
1010
|
-
function encodeHeaders(headers) {
|
|
1011
|
-
let result = "";
|
|
1012
|
-
for (const [key, value] of headers) {
|
|
1013
|
-
result += `${key}: ${value}\r\n`;
|
|
1014
|
-
}
|
|
1015
|
-
return result;
|
|
1016
|
-
}
|
|
1017
|
-
function getLength(source) {
|
|
1018
|
-
if (source instanceof Uint8Array) {
|
|
1019
|
-
return source.byteLength;
|
|
1020
|
-
}
|
|
1021
|
-
else if (isBlob(source)) {
|
|
1022
|
-
// if was created using createFile then -1 means we have an unknown size
|
|
1023
|
-
return source.size === -1 ? undefined : source.size;
|
|
1024
|
-
}
|
|
1025
|
-
else {
|
|
1026
|
-
return undefined;
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
function getTotalLength(sources) {
|
|
1030
|
-
let total = 0;
|
|
1031
|
-
for (const source of sources) {
|
|
1032
|
-
const partLength = getLength(source);
|
|
1033
|
-
if (partLength === undefined) {
|
|
1034
|
-
return undefined;
|
|
1035
|
-
}
|
|
1036
|
-
else {
|
|
1037
|
-
total += partLength;
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
return total;
|
|
1041
|
-
}
|
|
1042
|
-
function buildRequestBody(request, parts, boundary) {
|
|
1043
|
-
const sources = [
|
|
1044
|
-
stringToUint8Array(`--${boundary}`, "utf-8"),
|
|
1045
|
-
...parts.flatMap((part) => [
|
|
1046
|
-
stringToUint8Array("\r\n", "utf-8"),
|
|
1047
|
-
stringToUint8Array(encodeHeaders(part.headers), "utf-8"),
|
|
1048
|
-
stringToUint8Array("\r\n", "utf-8"),
|
|
1049
|
-
part.body,
|
|
1050
|
-
stringToUint8Array(`\r\n--${boundary}`, "utf-8"),
|
|
1051
|
-
]),
|
|
1052
|
-
stringToUint8Array("--\r\n\r\n", "utf-8"),
|
|
1053
|
-
];
|
|
1054
|
-
const contentLength = getTotalLength(sources);
|
|
1055
|
-
if (contentLength) {
|
|
1056
|
-
request.headers.set("Content-Length", contentLength);
|
|
1057
|
-
}
|
|
1058
|
-
request.body = (() => concatenateStreams(sources.map((source) => (typeof source === "function" ? source() : source)).map(toStream)));
|
|
1059
|
-
}
|
|
1060
|
-
/**
|
|
1061
|
-
* Name of multipart policy
|
|
1062
|
-
*/
|
|
1063
|
-
const multipartPolicyName = "multipartPolicy";
|
|
1064
|
-
const maxBoundaryLength = 70;
|
|
1065
|
-
const validBoundaryCharacters = new Set(`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'()+,-./:=?`);
|
|
1066
|
-
function assertValidBoundary(boundary) {
|
|
1067
|
-
if (boundary.length > maxBoundaryLength) {
|
|
1068
|
-
throw new Error(`Multipart boundary "${boundary}" exceeds maximum length of 70 characters`);
|
|
1069
|
-
}
|
|
1070
|
-
if (Array.from(boundary).some((x) => !validBoundaryCharacters.has(x))) {
|
|
1071
|
-
throw new Error(`Multipart boundary "${boundary}" contains invalid characters`);
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
/**
|
|
1075
|
-
* Pipeline policy for multipart requests
|
|
1076
|
-
*/
|
|
1077
|
-
function multipartPolicy() {
|
|
1078
|
-
return {
|
|
1079
|
-
name: multipartPolicyName,
|
|
1080
|
-
sendRequest(request, next) {
|
|
1081
|
-
var _a;
|
|
1082
|
-
if (!request.multipartBody) {
|
|
1083
|
-
return next(request);
|
|
1084
|
-
}
|
|
1085
|
-
if (request.body) {
|
|
1086
|
-
throw new Error("multipartBody and regular body cannot be set at the same time");
|
|
1087
|
-
}
|
|
1088
|
-
let boundary = request.multipartBody.boundary;
|
|
1089
|
-
const contentTypeHeader = (_a = request.headers.get("Content-Type")) !== null && _a !== void 0 ? _a : "multipart/mixed";
|
|
1090
|
-
const parsedHeader = contentTypeHeader.match(/^(multipart\/[^ ;]+)(?:; *boundary=(.+))?$/);
|
|
1091
|
-
if (!parsedHeader) {
|
|
1092
|
-
throw new Error(`Got multipart request body, but content-type header was not multipart: ${contentTypeHeader}`);
|
|
1093
|
-
}
|
|
1094
|
-
const [, contentType, parsedBoundary] = parsedHeader;
|
|
1095
|
-
if (parsedBoundary && boundary && parsedBoundary !== boundary) {
|
|
1096
|
-
throw new Error(`Multipart boundary was specified as ${parsedBoundary} in the header, but got ${boundary} in the request body`);
|
|
1097
|
-
}
|
|
1098
|
-
boundary !== null && boundary !== void 0 ? boundary : (boundary = parsedBoundary);
|
|
1099
|
-
if (boundary) {
|
|
1100
|
-
assertValidBoundary(boundary);
|
|
1101
|
-
}
|
|
1102
|
-
else {
|
|
1103
|
-
boundary = generateBoundary();
|
|
1104
|
-
}
|
|
1105
|
-
request.headers.set("Content-Type", `${contentType}; boundary=${boundary}`);
|
|
1106
|
-
buildRequestBody(request, request.multipartBody.parts, boundary);
|
|
1107
|
-
request.multipartBody = undefined;
|
|
1108
|
-
return next(request);
|
|
1109
|
-
},
|
|
1110
|
-
};
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
// Copyright (c) Microsoft Corporation.
|
|
1114
|
-
// Licensed under the MIT license.
|
|
1115
|
-
/**
|
|
1116
|
-
* The programmatic identifier of the decompressResponsePolicy.
|
|
1117
|
-
*/
|
|
1118
|
-
const decompressResponsePolicyName = "decompressResponsePolicy";
|
|
1119
|
-
/**
|
|
1120
|
-
* A policy to enable response decompression according to Accept-Encoding header
|
|
1121
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding
|
|
1122
|
-
*/
|
|
1123
|
-
function decompressResponsePolicy() {
|
|
1124
|
-
return {
|
|
1125
|
-
name: decompressResponsePolicyName,
|
|
1126
|
-
async sendRequest(request, next) {
|
|
1127
|
-
// HEAD requests have no body
|
|
1128
|
-
if (request.method !== "HEAD") {
|
|
1129
|
-
request.headers.set("Accept-Encoding", "gzip,deflate");
|
|
1130
|
-
}
|
|
1131
|
-
return next(request);
|
|
1132
|
-
},
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
// Copyright (c) Microsoft Corporation.
|
|
1137
|
-
// Licensed under the MIT license.
|
|
1138
|
-
/**
|
|
1139
|
-
* Returns a random integer value between a lower and upper bound,
|
|
1140
|
-
* inclusive of both bounds.
|
|
1141
|
-
* Note that this uses Math.random and isn't secure. If you need to use
|
|
1142
|
-
* this for any kind of security purpose, find a better source of random.
|
|
1143
|
-
* @param min - The smallest integer value allowed.
|
|
1144
|
-
* @param max - The largest integer value allowed.
|
|
1145
|
-
*/
|
|
1146
|
-
function getRandomIntegerInclusive(min, max) {
|
|
1147
|
-
// Make sure inputs are integers.
|
|
1148
|
-
min = Math.ceil(min);
|
|
1149
|
-
max = Math.floor(max);
|
|
1150
|
-
// Pick a random offset from zero to the size of the range.
|
|
1151
|
-
// Since Math.random() can never return 1, we have to make the range one larger
|
|
1152
|
-
// in order to be inclusive of the maximum value after we take the floor.
|
|
1153
|
-
const offset = Math.floor(Math.random() * (max - min + 1));
|
|
1154
|
-
return offset + min;
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
// Copyright (c) Microsoft Corporation.
|
|
1158
|
-
// Licensed under the MIT license.
|
|
1159
|
-
/**
|
|
1160
|
-
* This error is thrown when an asynchronous operation has been aborted.
|
|
1161
|
-
* Check for this error by testing the `name` that the name property of the
|
|
1162
|
-
* error matches `"AbortError"`.
|
|
1163
|
-
*
|
|
1164
|
-
* @example
|
|
1165
|
-
* ```ts
|
|
1166
|
-
* const controller = new AbortController();
|
|
1167
|
-
* controller.abort();
|
|
1168
|
-
* try {
|
|
1169
|
-
* doAsyncWork(controller.signal)
|
|
1170
|
-
* } catch (e) {
|
|
1171
|
-
* if (e.name === 'AbortError') {
|
|
1172
|
-
* // handle abort error here.
|
|
1173
|
-
* }
|
|
1174
|
-
* }
|
|
1175
|
-
* ```
|
|
1176
|
-
*/
|
|
1177
|
-
class AbortError extends Error {
|
|
1178
|
-
constructor(message) {
|
|
1179
|
-
super(message);
|
|
1180
|
-
this.name = "AbortError";
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
// Copyright (c) Microsoft Corporation.
|
|
1185
|
-
// Licensed under the MIT license.
|
|
1186
|
-
const StandardAbortMessage$1 = "The operation was aborted.";
|
|
1187
|
-
/**
|
|
1188
|
-
* A wrapper for setTimeout that resolves a promise after delayInMs milliseconds.
|
|
1189
|
-
* @param delayInMs - The number of milliseconds to be delayed.
|
|
1190
|
-
* @param value - The value to be resolved with after a timeout of t milliseconds.
|
|
1191
|
-
* @param options - The options for delay - currently abort options
|
|
1192
|
-
* - abortSignal - The abortSignal associated with containing operation.
|
|
1193
|
-
* - abortErrorMsg - The abort error message associated with containing operation.
|
|
1194
|
-
* @returns Resolved promise
|
|
1195
|
-
*/
|
|
1196
|
-
function delay$1(delayInMs, value, options) {
|
|
1197
|
-
return new Promise((resolve, reject) => {
|
|
1198
|
-
let timer = undefined;
|
|
1199
|
-
let onAborted = undefined;
|
|
1200
|
-
const rejectOnAbort = () => {
|
|
1201
|
-
return reject(new AbortError((options === null || options === void 0 ? void 0 : options.abortErrorMsg) ? options === null || options === void 0 ? void 0 : options.abortErrorMsg : StandardAbortMessage$1));
|
|
1202
|
-
};
|
|
1203
|
-
const removeListeners = () => {
|
|
1204
|
-
if ((options === null || options === void 0 ? void 0 : options.abortSignal) && onAborted) {
|
|
1205
|
-
options.abortSignal.removeEventListener("abort", onAborted);
|
|
1206
|
-
}
|
|
1207
|
-
};
|
|
1208
|
-
onAborted = () => {
|
|
1209
|
-
if (timer) {
|
|
1210
|
-
clearTimeout(timer);
|
|
1211
|
-
}
|
|
1212
|
-
removeListeners();
|
|
1213
|
-
return rejectOnAbort();
|
|
1214
|
-
};
|
|
1215
|
-
if ((options === null || options === void 0 ? void 0 : options.abortSignal) && options.abortSignal.aborted) {
|
|
1216
|
-
return rejectOnAbort();
|
|
1217
|
-
}
|
|
1218
|
-
timer = setTimeout(() => {
|
|
1219
|
-
removeListeners();
|
|
1220
|
-
resolve(value);
|
|
1221
|
-
}, delayInMs);
|
|
1222
|
-
if (options === null || options === void 0 ? void 0 : options.abortSignal) {
|
|
1223
|
-
options.abortSignal.addEventListener("abort", onAborted);
|
|
1224
|
-
}
|
|
1225
|
-
});
|
|
1226
|
-
}
|
|
1227
|
-
/**
|
|
1228
|
-
* @internal
|
|
1229
|
-
* @returns the parsed value or undefined if the parsed value is invalid.
|
|
1230
|
-
*/
|
|
1231
|
-
function parseHeaderValueAsNumber(response, headerName) {
|
|
1232
|
-
const value = response.headers.get(headerName);
|
|
1233
|
-
if (!value)
|
|
1234
|
-
return;
|
|
1235
|
-
const valueAsNum = Number(value);
|
|
1236
|
-
if (Number.isNaN(valueAsNum))
|
|
1237
|
-
return;
|
|
1238
|
-
return valueAsNum;
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
// Copyright (c) Microsoft Corporation.
|
|
1242
|
-
// Licensed under the MIT license.
|
|
1243
|
-
/**
|
|
1244
|
-
* The header that comes back from services representing
|
|
1245
|
-
* the amount of time (minimum) to wait to retry (in seconds or timestamp after which we can retry).
|
|
1246
|
-
*/
|
|
1247
|
-
const RetryAfterHeader = "Retry-After";
|
|
1248
|
-
/**
|
|
1249
|
-
* The headers that come back from services representing
|
|
1250
|
-
* the amount of time (minimum) to wait to retry.
|
|
1251
|
-
*
|
|
1252
|
-
* "retry-after-ms", "x-ms-retry-after-ms" : milliseconds
|
|
1253
|
-
* "Retry-After" : seconds or timestamp
|
|
1254
|
-
*/
|
|
1255
|
-
const AllRetryAfterHeaders = ["retry-after-ms", "x-ms-retry-after-ms", RetryAfterHeader];
|
|
1256
|
-
/**
|
|
1257
|
-
* A response is a throttling retry response if it has a throttling status code (429 or 503),
|
|
1258
|
-
* as long as one of the [ "Retry-After" or "retry-after-ms" or "x-ms-retry-after-ms" ] headers has a valid value.
|
|
1259
|
-
*
|
|
1260
|
-
* Returns the `retryAfterInMs` value if the response is a throttling retry response.
|
|
1261
|
-
* If not throttling retry response, returns `undefined`.
|
|
1262
|
-
*
|
|
1263
|
-
* @internal
|
|
1264
|
-
*/
|
|
1265
|
-
function getRetryAfterInMs(response) {
|
|
1266
|
-
if (!(response && [429, 503].includes(response.status)))
|
|
1267
|
-
return undefined;
|
|
1268
|
-
try {
|
|
1269
|
-
// Headers: "retry-after-ms", "x-ms-retry-after-ms", "Retry-After"
|
|
1270
|
-
for (const header of AllRetryAfterHeaders) {
|
|
1271
|
-
const retryAfterValue = parseHeaderValueAsNumber(response, header);
|
|
1272
|
-
if (retryAfterValue === 0 || retryAfterValue) {
|
|
1273
|
-
// "Retry-After" header ==> seconds
|
|
1274
|
-
// "retry-after-ms", "x-ms-retry-after-ms" headers ==> milli-seconds
|
|
1275
|
-
const multiplyingFactor = header === RetryAfterHeader ? 1000 : 1;
|
|
1276
|
-
return retryAfterValue * multiplyingFactor; // in milli-seconds
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
// RetryAfterHeader ("Retry-After") has a special case where it might be formatted as a date instead of a number of seconds
|
|
1280
|
-
const retryAfterHeader = response.headers.get(RetryAfterHeader);
|
|
1281
|
-
if (!retryAfterHeader)
|
|
1282
|
-
return;
|
|
1283
|
-
const date = Date.parse(retryAfterHeader);
|
|
1284
|
-
const diff = date - Date.now();
|
|
1285
|
-
// negative diff would mean a date in the past, so retry asap with 0 milliseconds
|
|
1286
|
-
return Number.isFinite(diff) ? Math.max(0, diff) : undefined;
|
|
1287
|
-
}
|
|
1288
|
-
catch (e) {
|
|
1289
|
-
return undefined;
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1292
|
-
/**
|
|
1293
|
-
* A response is a retry response if it has a throttling status code (429 or 503),
|
|
1294
|
-
* as long as one of the [ "Retry-After" or "retry-after-ms" or "x-ms-retry-after-ms" ] headers has a valid value.
|
|
1295
|
-
*/
|
|
1296
|
-
function isThrottlingRetryResponse(response) {
|
|
1297
|
-
return Number.isFinite(getRetryAfterInMs(response));
|
|
1298
|
-
}
|
|
1299
|
-
function throttlingRetryStrategy() {
|
|
1300
|
-
return {
|
|
1301
|
-
name: "throttlingRetryStrategy",
|
|
1302
|
-
retry({ response }) {
|
|
1303
|
-
const retryAfterInMs = getRetryAfterInMs(response);
|
|
1304
|
-
if (!Number.isFinite(retryAfterInMs)) {
|
|
1305
|
-
return { skipStrategy: true };
|
|
1306
|
-
}
|
|
1307
|
-
return {
|
|
1308
|
-
retryAfterInMs,
|
|
1309
|
-
};
|
|
1310
|
-
},
|
|
1311
|
-
};
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
// Copyright (c) Microsoft Corporation.
|
|
1315
|
-
// Licensed under the MIT license.
|
|
1316
|
-
// intervals are in milliseconds
|
|
1317
|
-
const DEFAULT_CLIENT_RETRY_INTERVAL = 1000;
|
|
1318
|
-
const DEFAULT_CLIENT_MAX_RETRY_INTERVAL = 1000 * 64;
|
|
1319
|
-
/**
|
|
1320
|
-
* A retry strategy that retries with an exponentially increasing delay in these two cases:
|
|
1321
|
-
* - When there are errors in the underlying transport layer (e.g. DNS lookup failures).
|
|
1322
|
-
* - Or otherwise if the outgoing request fails (408, greater or equal than 500, except for 501 and 505).
|
|
1323
|
-
*/
|
|
1324
|
-
function exponentialRetryStrategy(options = {}) {
|
|
1325
|
-
var _a, _b;
|
|
1326
|
-
const retryInterval = (_a = options.retryDelayInMs) !== null && _a !== void 0 ? _a : DEFAULT_CLIENT_RETRY_INTERVAL;
|
|
1327
|
-
const maxRetryInterval = (_b = options.maxRetryDelayInMs) !== null && _b !== void 0 ? _b : DEFAULT_CLIENT_MAX_RETRY_INTERVAL;
|
|
1328
|
-
let retryAfterInMs = retryInterval;
|
|
1329
|
-
return {
|
|
1330
|
-
name: "exponentialRetryStrategy",
|
|
1331
|
-
retry({ retryCount, response, responseError }) {
|
|
1332
|
-
const matchedSystemError = isSystemError(responseError);
|
|
1333
|
-
const ignoreSystemErrors = matchedSystemError && options.ignoreSystemErrors;
|
|
1334
|
-
const isExponential = isExponentialRetryResponse(response);
|
|
1335
|
-
const ignoreExponentialResponse = isExponential && options.ignoreHttpStatusCodes;
|
|
1336
|
-
const unknownResponse = response && (isThrottlingRetryResponse(response) || !isExponential);
|
|
1337
|
-
if (unknownResponse || ignoreExponentialResponse || ignoreSystemErrors) {
|
|
1338
|
-
return { skipStrategy: true };
|
|
1339
|
-
}
|
|
1340
|
-
if (responseError && !matchedSystemError && !isExponential) {
|
|
1341
|
-
return { errorToThrow: responseError };
|
|
1342
|
-
}
|
|
1343
|
-
// Exponentially increase the delay each time
|
|
1344
|
-
const exponentialDelay = retryAfterInMs * Math.pow(2, retryCount);
|
|
1345
|
-
// Don't let the delay exceed the maximum
|
|
1346
|
-
const clampedExponentialDelay = Math.min(maxRetryInterval, exponentialDelay);
|
|
1347
|
-
// Allow the final value to have some "jitter" (within 50% of the delay size) so
|
|
1348
|
-
// that retries across multiple clients don't occur simultaneously.
|
|
1349
|
-
retryAfterInMs =
|
|
1350
|
-
clampedExponentialDelay / 2 + getRandomIntegerInclusive(0, clampedExponentialDelay / 2);
|
|
1351
|
-
return { retryAfterInMs };
|
|
1352
|
-
},
|
|
1353
|
-
};
|
|
1354
|
-
}
|
|
1355
|
-
/**
|
|
1356
|
-
* A response is a retry response if it has status codes:
|
|
1357
|
-
* - 408, or
|
|
1358
|
-
* - Greater or equal than 500, except for 501 and 505.
|
|
1359
|
-
*/
|
|
1360
|
-
function isExponentialRetryResponse(response) {
|
|
1361
|
-
return Boolean(response &&
|
|
1362
|
-
response.status !== undefined &&
|
|
1363
|
-
(response.status >= 500 || response.status === 408) &&
|
|
1364
|
-
response.status !== 501 &&
|
|
1365
|
-
response.status !== 505);
|
|
1366
|
-
}
|
|
1367
|
-
/**
|
|
1368
|
-
* Determines whether an error from a pipeline response was triggered in the network layer.
|
|
1369
|
-
*/
|
|
1370
|
-
function isSystemError(err) {
|
|
1371
|
-
if (!err) {
|
|
1372
|
-
return false;
|
|
1373
|
-
}
|
|
1374
|
-
return (err.code === "ETIMEDOUT" ||
|
|
1375
|
-
err.code === "ESOCKETTIMEDOUT" ||
|
|
1376
|
-
err.code === "ECONNREFUSED" ||
|
|
1377
|
-
err.code === "ECONNRESET" ||
|
|
1378
|
-
err.code === "ENOENT" ||
|
|
1379
|
-
err.code === "ENOTFOUND");
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
// Copyright (c) Microsoft Corporation.
|
|
1383
|
-
// Licensed under the MIT license.
|
|
1384
|
-
const retryPolicyLogger = createClientLogger("core-rest-pipeline retryPolicy");
|
|
1385
|
-
/**
|
|
1386
|
-
* The programmatic identifier of the retryPolicy.
|
|
1387
|
-
*/
|
|
1388
|
-
const retryPolicyName = "retryPolicy";
|
|
1389
|
-
/**
|
|
1390
|
-
* retryPolicy is a generic policy to enable retrying requests when certain conditions are met
|
|
1391
|
-
*/
|
|
1392
|
-
function retryPolicy(strategies, options = { maxRetries: DEFAULT_RETRY_POLICY_COUNT }) {
|
|
1393
|
-
const logger = options.logger || retryPolicyLogger;
|
|
1394
|
-
return {
|
|
1395
|
-
name: retryPolicyName,
|
|
1396
|
-
async sendRequest(request, next) {
|
|
1397
|
-
var _a, _b;
|
|
1398
|
-
let response;
|
|
1399
|
-
let responseError;
|
|
1400
|
-
let retryCount = -1;
|
|
1401
|
-
// eslint-disable-next-line no-constant-condition
|
|
1402
|
-
retryRequest: while (true) {
|
|
1403
|
-
retryCount += 1;
|
|
1404
|
-
response = undefined;
|
|
1405
|
-
responseError = undefined;
|
|
1406
|
-
try {
|
|
1407
|
-
logger.info(`Retry ${retryCount}: Attempting to send request`, request.requestId);
|
|
1408
|
-
response = await next(request);
|
|
1409
|
-
logger.info(`Retry ${retryCount}: Received a response from request`, request.requestId);
|
|
1410
|
-
}
|
|
1411
|
-
catch (e) {
|
|
1412
|
-
logger.error(`Retry ${retryCount}: Received an error from request`, request.requestId);
|
|
1413
|
-
// RestErrors are valid targets for the retry strategies.
|
|
1414
|
-
// If none of the retry strategies can work with them, they will be thrown later in this policy.
|
|
1415
|
-
// If the received error is not a RestError, it is immediately thrown.
|
|
1416
|
-
responseError = e;
|
|
1417
|
-
if (!e || responseError.name !== "RestError") {
|
|
1418
|
-
throw e;
|
|
1419
|
-
}
|
|
1420
|
-
response = responseError.response;
|
|
1421
|
-
}
|
|
1422
|
-
if ((_a = request.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
1423
|
-
logger.error(`Retry ${retryCount}: Request aborted.`);
|
|
1424
|
-
const abortError = new AbortError();
|
|
1425
|
-
throw abortError;
|
|
1426
|
-
}
|
|
1427
|
-
if (retryCount >= ((_b = options.maxRetries) !== null && _b !== void 0 ? _b : DEFAULT_RETRY_POLICY_COUNT)) {
|
|
1428
|
-
logger.info(`Retry ${retryCount}: Maximum retries reached. Returning the last received response, or throwing the last received error.`);
|
|
1429
|
-
if (responseError) {
|
|
1430
|
-
throw responseError;
|
|
1431
|
-
}
|
|
1432
|
-
else if (response) {
|
|
1433
|
-
return response;
|
|
1434
|
-
}
|
|
1435
|
-
else {
|
|
1436
|
-
throw new Error("Maximum retries reached with no response or error to throw");
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
logger.info(`Retry ${retryCount}: Processing ${strategies.length} retry strategies.`);
|
|
1440
|
-
strategiesLoop: for (const strategy of strategies) {
|
|
1441
|
-
const strategyLogger = strategy.logger || retryPolicyLogger;
|
|
1442
|
-
strategyLogger.info(`Retry ${retryCount}: Processing retry strategy ${strategy.name}.`);
|
|
1443
|
-
const modifiers = strategy.retry({
|
|
1444
|
-
retryCount,
|
|
1445
|
-
response,
|
|
1446
|
-
responseError,
|
|
1447
|
-
});
|
|
1448
|
-
if (modifiers.skipStrategy) {
|
|
1449
|
-
strategyLogger.info(`Retry ${retryCount}: Skipped.`);
|
|
1450
|
-
continue strategiesLoop;
|
|
1451
|
-
}
|
|
1452
|
-
const { errorToThrow, retryAfterInMs, redirectTo } = modifiers;
|
|
1453
|
-
if (errorToThrow) {
|
|
1454
|
-
strategyLogger.error(`Retry ${retryCount}: Retry strategy ${strategy.name} throws error:`, errorToThrow);
|
|
1455
|
-
throw errorToThrow;
|
|
1456
|
-
}
|
|
1457
|
-
if (retryAfterInMs || retryAfterInMs === 0) {
|
|
1458
|
-
strategyLogger.info(`Retry ${retryCount}: Retry strategy ${strategy.name} retries after ${retryAfterInMs}`);
|
|
1459
|
-
await delay$1(retryAfterInMs, undefined, { abortSignal: request.abortSignal });
|
|
1460
|
-
continue retryRequest;
|
|
1461
|
-
}
|
|
1462
|
-
if (redirectTo) {
|
|
1463
|
-
strategyLogger.info(`Retry ${retryCount}: Retry strategy ${strategy.name} redirects to ${redirectTo}`);
|
|
1464
|
-
request.url = redirectTo;
|
|
1465
|
-
continue retryRequest;
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
if (responseError) {
|
|
1469
|
-
logger.info(`None of the retry strategies could work with the received error. Throwing it.`);
|
|
1470
|
-
throw responseError;
|
|
1471
|
-
}
|
|
1472
|
-
if (response) {
|
|
1473
|
-
logger.info(`None of the retry strategies could work with the received response. Returning it.`);
|
|
1474
|
-
return response;
|
|
1475
|
-
}
|
|
1476
|
-
// If all the retries skip and there's no response,
|
|
1477
|
-
// we're still in the retry loop, so a new request will be sent
|
|
1478
|
-
// until `maxRetries` is reached.
|
|
1479
|
-
}
|
|
1480
|
-
},
|
|
1481
|
-
};
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
// Copyright (c) Microsoft Corporation.
|
|
1485
|
-
// Licensed under the MIT license.
|
|
1486
|
-
/**
|
|
1487
|
-
* Name of the {@link defaultRetryPolicy}
|
|
1488
|
-
*/
|
|
1489
|
-
const defaultRetryPolicyName = "defaultRetryPolicy";
|
|
1490
|
-
/**
|
|
1491
|
-
* A policy that retries according to three strategies:
|
|
1492
|
-
* - When the server sends a 429 response with a Retry-After header.
|
|
1493
|
-
* - When there are errors in the underlying transport layer (e.g. DNS lookup failures).
|
|
1494
|
-
* - Or otherwise if the outgoing request fails, it will retry with an exponentially increasing delay.
|
|
1495
|
-
*/
|
|
1496
|
-
function defaultRetryPolicy(options = {}) {
|
|
1497
|
-
var _a;
|
|
1498
|
-
return {
|
|
1499
|
-
name: defaultRetryPolicyName,
|
|
1500
|
-
sendRequest: retryPolicy([throttlingRetryStrategy(), exponentialRetryStrategy(options)], {
|
|
1501
|
-
maxRetries: (_a = options.maxRetries) !== null && _a !== void 0 ? _a : DEFAULT_RETRY_POLICY_COUNT,
|
|
1502
|
-
}).sendRequest,
|
|
1503
|
-
};
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
// Copyright (c) Microsoft Corporation.
|
|
1507
|
-
// Licensed under the MIT license.
|
|
1508
|
-
function normalizeName(name) {
|
|
1509
|
-
return name.toLowerCase();
|
|
1510
|
-
}
|
|
1511
|
-
function* headerIterator(map) {
|
|
1512
|
-
for (const entry of map.values()) {
|
|
1513
|
-
yield [entry.name, entry.value];
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
class HttpHeadersImpl {
|
|
1517
|
-
constructor(rawHeaders) {
|
|
1518
|
-
this._headersMap = new Map();
|
|
1519
|
-
if (rawHeaders) {
|
|
1520
|
-
for (const headerName of Object.keys(rawHeaders)) {
|
|
1521
|
-
this.set(headerName, rawHeaders[headerName]);
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
/**
|
|
1526
|
-
* Set a header in this collection with the provided name and value. The name is
|
|
1527
|
-
* case-insensitive.
|
|
1528
|
-
* @param name - The name of the header to set. This value is case-insensitive.
|
|
1529
|
-
* @param value - The value of the header to set.
|
|
1530
|
-
*/
|
|
1531
|
-
set(name, value) {
|
|
1532
|
-
this._headersMap.set(normalizeName(name), { name, value: String(value).trim() });
|
|
1533
|
-
}
|
|
1534
|
-
/**
|
|
1535
|
-
* Get the header value for the provided header name, or undefined if no header exists in this
|
|
1536
|
-
* collection with the provided name.
|
|
1537
|
-
* @param name - The name of the header. This value is case-insensitive.
|
|
1538
|
-
*/
|
|
1539
|
-
get(name) {
|
|
1540
|
-
var _a;
|
|
1541
|
-
return (_a = this._headersMap.get(normalizeName(name))) === null || _a === void 0 ? void 0 : _a.value;
|
|
1542
|
-
}
|
|
1543
|
-
/**
|
|
1544
|
-
* Get whether or not this header collection contains a header entry for the provided header name.
|
|
1545
|
-
* @param name - The name of the header to set. This value is case-insensitive.
|
|
1546
|
-
*/
|
|
1547
|
-
has(name) {
|
|
1548
|
-
return this._headersMap.has(normalizeName(name));
|
|
1549
|
-
}
|
|
1550
|
-
/**
|
|
1551
|
-
* Remove the header with the provided headerName.
|
|
1552
|
-
* @param name - The name of the header to remove.
|
|
1553
|
-
*/
|
|
1554
|
-
delete(name) {
|
|
1555
|
-
this._headersMap.delete(normalizeName(name));
|
|
1556
|
-
}
|
|
1557
|
-
/**
|
|
1558
|
-
* Get the JSON object representation of this HTTP header collection.
|
|
1559
|
-
*/
|
|
1560
|
-
toJSON(options = {}) {
|
|
1561
|
-
const result = {};
|
|
1562
|
-
if (options.preserveCase) {
|
|
1563
|
-
for (const entry of this._headersMap.values()) {
|
|
1564
|
-
result[entry.name] = entry.value;
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
else {
|
|
1568
|
-
for (const [normalizedName, entry] of this._headersMap) {
|
|
1569
|
-
result[normalizedName] = entry.value;
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
return result;
|
|
1573
|
-
}
|
|
1574
|
-
/**
|
|
1575
|
-
* Get the string representation of this HTTP header collection.
|
|
1576
|
-
*/
|
|
1577
|
-
toString() {
|
|
1578
|
-
return JSON.stringify(this.toJSON({ preserveCase: true }));
|
|
1579
|
-
}
|
|
1580
|
-
/**
|
|
1581
|
-
* Iterate over tuples of header [name, value] pairs.
|
|
1582
|
-
*/
|
|
1583
|
-
[Symbol.iterator]() {
|
|
1584
|
-
return headerIterator(this._headersMap);
|
|
1585
|
-
}
|
|
1586
|
-
}
|
|
1587
|
-
/**
|
|
1588
|
-
* Creates an object that satisfies the `HttpHeaders` interface.
|
|
1589
|
-
* @param rawHeaders - A simple object representing initial headers
|
|
1590
|
-
*/
|
|
1591
|
-
function createHttpHeaders(rawHeaders) {
|
|
1592
|
-
return new HttpHeadersImpl(rawHeaders);
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
// Copyright (c) Microsoft Corporation.
|
|
1596
|
-
// Licensed under the MIT license.
|
|
1597
|
-
/**
|
|
1598
|
-
* The programmatic identifier of the formDataPolicy.
|
|
1599
|
-
*/
|
|
1600
|
-
const formDataPolicyName = "formDataPolicy";
|
|
1601
|
-
/**
|
|
1602
|
-
* A policy that encodes FormData on the request into the body.
|
|
1603
|
-
*/
|
|
1604
|
-
function formDataPolicy() {
|
|
1605
|
-
return {
|
|
1606
|
-
name: formDataPolicyName,
|
|
1607
|
-
async sendRequest(request, next) {
|
|
1608
|
-
if (request.formData) {
|
|
1609
|
-
const contentType = request.headers.get("Content-Type");
|
|
1610
|
-
if (contentType && contentType.indexOf("application/x-www-form-urlencoded") !== -1) {
|
|
1611
|
-
request.body = wwwFormUrlEncode(request.formData);
|
|
1612
|
-
}
|
|
1613
|
-
else {
|
|
1614
|
-
await prepareFormData(request.formData, request);
|
|
1615
|
-
}
|
|
1616
|
-
request.formData = undefined;
|
|
1617
|
-
}
|
|
1618
|
-
return next(request);
|
|
1619
|
-
},
|
|
1620
|
-
};
|
|
1621
|
-
}
|
|
1622
|
-
function wwwFormUrlEncode(formData) {
|
|
1623
|
-
const urlSearchParams = new URLSearchParams();
|
|
1624
|
-
for (const [key, value] of Object.entries(formData)) {
|
|
1625
|
-
if (Array.isArray(value)) {
|
|
1626
|
-
for (const subValue of value) {
|
|
1627
|
-
urlSearchParams.append(key, subValue.toString());
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
else {
|
|
1631
|
-
urlSearchParams.append(key, value.toString());
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
return urlSearchParams.toString();
|
|
1635
|
-
}
|
|
1636
|
-
async function prepareFormData(formData, request) {
|
|
1637
|
-
// validate content type (multipart/form-data)
|
|
1638
|
-
const contentType = request.headers.get("Content-Type");
|
|
1639
|
-
if (contentType && !contentType.startsWith("multipart/form-data")) {
|
|
1640
|
-
// content type is specified and is not multipart/form-data. Exit.
|
|
1641
|
-
return;
|
|
1642
|
-
}
|
|
1643
|
-
request.headers.set("Content-Type", contentType !== null && contentType !== void 0 ? contentType : "multipart/form-data");
|
|
1644
|
-
// set body to MultipartRequestBody using content from FormDataMap
|
|
1645
|
-
const parts = [];
|
|
1646
|
-
for (const [fieldName, values] of Object.entries(formData)) {
|
|
1647
|
-
for (const value of Array.isArray(values) ? values : [values]) {
|
|
1648
|
-
if (typeof value === "string") {
|
|
1649
|
-
parts.push({
|
|
1650
|
-
headers: createHttpHeaders({
|
|
1651
|
-
"Content-Disposition": `form-data; name="${fieldName}"`,
|
|
1652
|
-
}),
|
|
1653
|
-
body: stringToUint8Array(value, "utf-8"),
|
|
1654
|
-
});
|
|
1655
|
-
}
|
|
1656
|
-
else {
|
|
1657
|
-
// using || instead of ?? here since if value.name is empty we should create a file name
|
|
1658
|
-
const fileName = value.name || "blob";
|
|
1659
|
-
const headers = createHttpHeaders();
|
|
1660
|
-
headers.set("Content-Disposition", `form-data; name="${fieldName}"; filename="${fileName}"`);
|
|
1661
|
-
if (value.type) {
|
|
1662
|
-
headers.set("Content-Type", value.type);
|
|
1663
|
-
}
|
|
1664
|
-
parts.push({
|
|
1665
|
-
headers,
|
|
1666
|
-
body: value,
|
|
1667
|
-
});
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
request.multipartBody = { parts };
|
|
1672
|
-
}
|
|
1673
|
-
|
|
1674
|
-
// Copyright (c) Microsoft Corporation.
|
|
1675
|
-
// Licensed under the MIT license.
|
|
1676
|
-
var _a, _b, _c, _d;
|
|
1677
|
-
/**
|
|
1678
|
-
* A constant that indicates whether the environment the code is running is a Web Browser.
|
|
1679
|
-
*/
|
|
1680
|
-
// eslint-disable-next-line @azure/azure-sdk/ts-no-window
|
|
1681
|
-
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
1682
|
-
/**
|
|
1683
|
-
* A constant that indicates whether the environment the code is running is a Web Worker.
|
|
1684
|
-
*/
|
|
1685
|
-
const isWebWorker = typeof self === "object" &&
|
|
1686
|
-
typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
|
|
1687
|
-
(((_a = self.constructor) === null || _a === void 0 ? void 0 : _a.name) === "DedicatedWorkerGlobalScope" ||
|
|
1688
|
-
((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "ServiceWorkerGlobalScope" ||
|
|
1689
|
-
((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "SharedWorkerGlobalScope");
|
|
1690
|
-
/**
|
|
1691
|
-
* A constant that indicates whether the environment the code is running is Bun.sh.
|
|
1692
|
-
*/
|
|
1693
|
-
const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
|
|
1694
|
-
/**
|
|
1695
|
-
* A constant that indicates whether the environment the code is running is Deno.
|
|
1696
|
-
*/
|
|
1697
|
-
const isDeno = typeof Deno !== "undefined" &&
|
|
1698
|
-
typeof Deno.version !== "undefined" &&
|
|
1699
|
-
typeof Deno.version.deno !== "undefined";
|
|
1700
|
-
/**
|
|
1701
|
-
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
1702
|
-
*/
|
|
1703
|
-
const isNode = typeof process !== "undefined" &&
|
|
1704
|
-
Boolean(process.version) &&
|
|
1705
|
-
Boolean((_d = process.versions) === null || _d === void 0 ? void 0 : _d.node) &&
|
|
1706
|
-
// Deno thought it was a good idea to spoof process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
|
|
1707
|
-
!isDeno &&
|
|
1708
|
-
!isBun;
|
|
1709
|
-
/**
|
|
1710
|
-
* A constant that indicates whether the environment the code is running is in React-Native.
|
|
1711
|
-
*/
|
|
1712
|
-
// https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
|
|
1713
|
-
const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
|
|
1714
|
-
|
|
1715
|
-
// Copyright (c) Microsoft Corporation.
|
|
1716
|
-
// Licensed under the MIT license.
|
|
1717
|
-
const HTTPS_PROXY = "HTTPS_PROXY";
|
|
1718
|
-
const HTTP_PROXY = "HTTP_PROXY";
|
|
1719
|
-
const ALL_PROXY = "ALL_PROXY";
|
|
1720
|
-
const NO_PROXY = "NO_PROXY";
|
|
1721
|
-
/**
|
|
1722
|
-
* The programmatic identifier of the proxyPolicy.
|
|
1723
|
-
*/
|
|
1724
|
-
const proxyPolicyName = "proxyPolicy";
|
|
1725
|
-
/**
|
|
1726
|
-
* Stores the patterns specified in NO_PROXY environment variable.
|
|
1727
|
-
* @internal
|
|
1728
|
-
*/
|
|
1729
|
-
const globalNoProxyList = [];
|
|
1730
|
-
let noProxyListLoaded = false;
|
|
1731
|
-
/** A cache of whether a host should bypass the proxy. */
|
|
1732
|
-
const globalBypassedMap = new Map();
|
|
1733
|
-
function getEnvironmentValue(name) {
|
|
1734
|
-
if (process.env[name]) {
|
|
1735
|
-
return process.env[name];
|
|
1736
|
-
}
|
|
1737
|
-
else if (process.env[name.toLowerCase()]) {
|
|
1738
|
-
return process.env[name.toLowerCase()];
|
|
1739
|
-
}
|
|
1740
|
-
return undefined;
|
|
1741
|
-
}
|
|
1742
|
-
function loadEnvironmentProxyValue() {
|
|
1743
|
-
if (!process) {
|
|
1744
|
-
return undefined;
|
|
1745
|
-
}
|
|
1746
|
-
const httpsProxy = getEnvironmentValue(HTTPS_PROXY);
|
|
1747
|
-
const allProxy = getEnvironmentValue(ALL_PROXY);
|
|
1748
|
-
const httpProxy = getEnvironmentValue(HTTP_PROXY);
|
|
1749
|
-
return httpsProxy || allProxy || httpProxy;
|
|
1750
|
-
}
|
|
1751
|
-
/**
|
|
1752
|
-
* Check whether the host of a given `uri` matches any pattern in the no proxy list.
|
|
1753
|
-
* If there's a match, any request sent to the same host shouldn't have the proxy settings set.
|
|
1754
|
-
* This implementation is a port of https://github.com/Azure/azure-sdk-for-net/blob/8cca811371159e527159c7eb65602477898683e2/sdk/core/Azure.Core/src/Pipeline/Internal/HttpEnvironmentProxy.cs#L210
|
|
1755
|
-
*/
|
|
1756
|
-
function isBypassed(uri, noProxyList, bypassedMap) {
|
|
1757
|
-
if (noProxyList.length === 0) {
|
|
1758
|
-
return false;
|
|
1759
|
-
}
|
|
1760
|
-
const host = new URL(uri).hostname;
|
|
1761
|
-
if (bypassedMap === null || bypassedMap === void 0 ? void 0 : bypassedMap.has(host)) {
|
|
1762
|
-
return bypassedMap.get(host);
|
|
1763
|
-
}
|
|
1764
|
-
let isBypassedFlag = false;
|
|
1765
|
-
for (const pattern of noProxyList) {
|
|
1766
|
-
if (pattern[0] === ".") {
|
|
1767
|
-
// This should match either domain it self or any subdomain or host
|
|
1768
|
-
// .foo.com will match foo.com it self or *.foo.com
|
|
1769
|
-
if (host.endsWith(pattern)) {
|
|
1770
|
-
isBypassedFlag = true;
|
|
1771
|
-
}
|
|
1772
|
-
else {
|
|
1773
|
-
if (host.length === pattern.length - 1 && host === pattern.slice(1)) {
|
|
1774
|
-
isBypassedFlag = true;
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
else {
|
|
1779
|
-
if (host === pattern) {
|
|
1780
|
-
isBypassedFlag = true;
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
bypassedMap === null || bypassedMap === void 0 ? void 0 : bypassedMap.set(host, isBypassedFlag);
|
|
1785
|
-
return isBypassedFlag;
|
|
1786
|
-
}
|
|
1787
|
-
function loadNoProxy() {
|
|
1788
|
-
const noProxy = getEnvironmentValue(NO_PROXY);
|
|
1789
|
-
noProxyListLoaded = true;
|
|
1790
|
-
if (noProxy) {
|
|
1791
|
-
return noProxy
|
|
1792
|
-
.split(",")
|
|
1793
|
-
.map((item) => item.trim())
|
|
1794
|
-
.filter((item) => item.length);
|
|
1795
|
-
}
|
|
1796
|
-
return [];
|
|
1797
|
-
}
|
|
1798
|
-
/**
|
|
1799
|
-
* This method converts a proxy url into `ProxySettings` for use with ProxyPolicy.
|
|
1800
|
-
* If no argument is given, it attempts to parse a proxy URL from the environment
|
|
1801
|
-
* variables `HTTPS_PROXY` or `HTTP_PROXY`.
|
|
1802
|
-
* @param proxyUrl - The url of the proxy to use. May contain authentication information.
|
|
1803
|
-
*/
|
|
1804
|
-
function getDefaultProxySettings(proxyUrl) {
|
|
1805
|
-
if (!proxyUrl) {
|
|
1806
|
-
proxyUrl = loadEnvironmentProxyValue();
|
|
1807
|
-
if (!proxyUrl) {
|
|
1808
|
-
return undefined;
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
const parsedUrl = new URL(proxyUrl);
|
|
1812
|
-
const schema = parsedUrl.protocol ? parsedUrl.protocol + "//" : "";
|
|
1813
|
-
return {
|
|
1814
|
-
host: schema + parsedUrl.hostname,
|
|
1815
|
-
port: Number.parseInt(parsedUrl.port || "80"),
|
|
1816
|
-
username: parsedUrl.username,
|
|
1817
|
-
password: parsedUrl.password,
|
|
1818
|
-
};
|
|
1819
|
-
}
|
|
1820
|
-
function setProxyAgentOnRequest(request, cachedAgents) {
|
|
1821
|
-
// Custom Agent should take precedence so if one is present
|
|
1822
|
-
// we should skip to avoid overwriting it.
|
|
1823
|
-
if (request.agent) {
|
|
1824
|
-
return;
|
|
1825
|
-
}
|
|
1826
|
-
const url = new URL(request.url);
|
|
1827
|
-
const isInsecure = url.protocol !== "https:";
|
|
1828
|
-
const proxySettings = request.proxySettings;
|
|
1829
|
-
if (proxySettings) {
|
|
1830
|
-
let parsedProxyUrl;
|
|
1831
|
-
try {
|
|
1832
|
-
parsedProxyUrl = new URL(proxySettings.host);
|
|
1833
|
-
}
|
|
1834
|
-
catch (_error) {
|
|
1835
|
-
throw new Error(`Expecting a valid host string in proxy settings, but found "${proxySettings.host}".`);
|
|
1836
|
-
}
|
|
1837
|
-
if (request.tlsSettings) {
|
|
1838
|
-
logger.warning("TLS settings are not supported in combination with custom Proxy, certificates provided to the client will be ignored.");
|
|
1839
|
-
}
|
|
1840
|
-
const headers = request.headers.toJSON();
|
|
1841
|
-
if (isInsecure) {
|
|
1842
|
-
if (!cachedAgents.httpProxyAgent) {
|
|
1843
|
-
cachedAgents.httpProxyAgent = new httpProxyAgent.HttpProxyAgent(parsedProxyUrl, { headers });
|
|
1844
|
-
}
|
|
1845
|
-
request.agent = cachedAgents.httpProxyAgent;
|
|
1846
|
-
}
|
|
1847
|
-
else {
|
|
1848
|
-
if (!cachedAgents.httpsProxyAgent) {
|
|
1849
|
-
cachedAgents.httpsProxyAgent = new httpsProxyAgent.HttpsProxyAgent(parsedProxyUrl, { headers });
|
|
1850
|
-
}
|
|
1851
|
-
request.agent = cachedAgents.httpsProxyAgent;
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
/**
|
|
1856
|
-
* A policy that allows one to apply proxy settings to all requests.
|
|
1857
|
-
* If not passed static settings, they will be retrieved from the HTTPS_PROXY
|
|
1858
|
-
* or HTTP_PROXY environment variables.
|
|
1859
|
-
* @param proxySettings - ProxySettings to use on each request.
|
|
1860
|
-
* @param options - additional settings, for example, custom NO_PROXY patterns
|
|
1861
|
-
*/
|
|
1862
|
-
function proxyPolicy(proxySettings = getDefaultProxySettings(), options) {
|
|
1863
|
-
if (!noProxyListLoaded) {
|
|
1864
|
-
globalNoProxyList.push(...loadNoProxy());
|
|
1865
|
-
}
|
|
1866
|
-
const cachedAgents = {};
|
|
1867
|
-
return {
|
|
1868
|
-
name: proxyPolicyName,
|
|
1869
|
-
async sendRequest(request, next) {
|
|
1870
|
-
var _a;
|
|
1871
|
-
if (!request.proxySettings &&
|
|
1872
|
-
!isBypassed(request.url, (_a = options === null || options === void 0 ? void 0 : options.customNoProxyList) !== null && _a !== void 0 ? _a : globalNoProxyList, (options === null || options === void 0 ? void 0 : options.customNoProxyList) ? undefined : globalBypassedMap)) {
|
|
1873
|
-
request.proxySettings = proxySettings;
|
|
1874
|
-
}
|
|
1875
|
-
if (request.proxySettings) {
|
|
1876
|
-
setProxyAgentOnRequest(request, cachedAgents);
|
|
1877
|
-
}
|
|
1878
|
-
return next(request);
|
|
1879
|
-
},
|
|
1880
|
-
};
|
|
1881
|
-
}
|
|
1882
|
-
|
|
1883
|
-
// Copyright (c) Microsoft Corporation.
|
|
1884
|
-
// Licensed under the MIT license.
|
|
1885
|
-
/**
|
|
1886
|
-
* Name of the TLS Policy
|
|
1887
|
-
*/
|
|
1888
|
-
const tlsPolicyName = "tlsPolicy";
|
|
1889
|
-
/**
|
|
1890
|
-
* Gets a pipeline policy that adds the client certificate to the HttpClient agent for authentication.
|
|
1891
|
-
*/
|
|
1892
|
-
function tlsPolicy(tlsSettings) {
|
|
1893
|
-
return {
|
|
1894
|
-
name: tlsPolicyName,
|
|
1895
|
-
sendRequest: async (req, next) => {
|
|
1896
|
-
// Users may define a request tlsSettings, honor those over the client level one
|
|
1897
|
-
if (!req.tlsSettings) {
|
|
1898
|
-
req.tlsSettings = tlsSettings;
|
|
1899
|
-
}
|
|
1900
|
-
return next(req);
|
|
1901
|
-
},
|
|
1902
|
-
};
|
|
1903
|
-
}
|
|
1904
|
-
|
|
1905
|
-
// Copyright (c) Microsoft Corporation.
|
|
1906
|
-
// Licensed under the MIT license.
|
|
1907
|
-
/** @internal */
|
|
1908
|
-
const knownContextKeys = {
|
|
1909
|
-
span: Symbol.for("@typespec/ts-http-runtime span"),
|
|
1910
|
-
namespace: Symbol.for("@typespec/ts-http-runtime namespace"),
|
|
1911
|
-
};
|
|
1912
|
-
/**
|
|
1913
|
-
* Creates a new {@link TracingContext} with the given options.
|
|
1914
|
-
* @param options - A set of known keys that may be set on the context.
|
|
1915
|
-
* @returns A new {@link TracingContext} with the given options.
|
|
1916
|
-
*
|
|
1917
|
-
* @internal
|
|
1918
|
-
*/
|
|
1919
|
-
function createTracingContext(options = {}) {
|
|
1920
|
-
let context = new TracingContextImpl(options.parentContext);
|
|
1921
|
-
if (options.span) {
|
|
1922
|
-
context = context.setValue(knownContextKeys.span, options.span);
|
|
1923
|
-
}
|
|
1924
|
-
if (options.namespace) {
|
|
1925
|
-
context = context.setValue(knownContextKeys.namespace, options.namespace);
|
|
1926
|
-
}
|
|
1927
|
-
return context;
|
|
1928
|
-
}
|
|
1929
|
-
/** @internal */
|
|
1930
|
-
class TracingContextImpl {
|
|
1931
|
-
constructor(initialContext) {
|
|
1932
|
-
this._contextMap =
|
|
1933
|
-
initialContext instanceof TracingContextImpl
|
|
1934
|
-
? new Map(initialContext._contextMap)
|
|
1935
|
-
: new Map();
|
|
1936
|
-
}
|
|
1937
|
-
setValue(key, value) {
|
|
1938
|
-
const newContext = new TracingContextImpl(this);
|
|
1939
|
-
newContext._contextMap.set(key, value);
|
|
1940
|
-
return newContext;
|
|
1941
|
-
}
|
|
1942
|
-
getValue(key) {
|
|
1943
|
-
return this._contextMap.get(key);
|
|
1944
|
-
}
|
|
1945
|
-
deleteValue(key) {
|
|
1946
|
-
const newContext = new TracingContextImpl(this);
|
|
1947
|
-
newContext._contextMap.delete(key);
|
|
1948
|
-
return newContext;
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
|
|
1952
|
-
// Copyright (c) Microsoft Corporation.
|
|
1953
|
-
// Licensed under the MIT license.
|
|
1954
|
-
function createDefaultTracingSpan() {
|
|
1955
|
-
return {
|
|
1956
|
-
end: () => {
|
|
1957
|
-
// noop
|
|
1958
|
-
},
|
|
1959
|
-
isRecording: () => false,
|
|
1960
|
-
recordException: () => {
|
|
1961
|
-
// noop
|
|
1962
|
-
},
|
|
1963
|
-
setAttribute: () => {
|
|
1964
|
-
// noop
|
|
1965
|
-
},
|
|
1966
|
-
setStatus: () => {
|
|
1967
|
-
// noop
|
|
1968
|
-
},
|
|
1969
|
-
};
|
|
1970
|
-
}
|
|
1971
|
-
function createDefaultInstrumenter() {
|
|
1972
|
-
return {
|
|
1973
|
-
createRequestHeaders: () => {
|
|
1974
|
-
return {};
|
|
1975
|
-
},
|
|
1976
|
-
parseTraceparentHeader: () => {
|
|
1977
|
-
return undefined;
|
|
1978
|
-
},
|
|
1979
|
-
startSpan: (_name, spanOptions) => {
|
|
1980
|
-
return {
|
|
1981
|
-
span: createDefaultTracingSpan(),
|
|
1982
|
-
tracingContext: createTracingContext({ parentContext: spanOptions.tracingContext }),
|
|
1983
|
-
};
|
|
1984
|
-
},
|
|
1985
|
-
withContext(_context, callback, ...callbackArgs) {
|
|
1986
|
-
return callback(...callbackArgs);
|
|
1987
|
-
},
|
|
1988
|
-
};
|
|
1989
|
-
}
|
|
1990
|
-
/** @internal */
|
|
1991
|
-
let instrumenterImplementation;
|
|
1992
|
-
/**
|
|
1993
|
-
* Extends the SDK with support for a given instrumenter implementation.
|
|
1994
|
-
*
|
|
1995
|
-
* @param instrumenter - The instrumenter implementation to use.
|
|
1996
|
-
*/
|
|
1997
|
-
function useInstrumenter(instrumenter) {
|
|
1998
|
-
instrumenterImplementation = instrumenter;
|
|
1999
|
-
}
|
|
2000
|
-
/**
|
|
2001
|
-
* Gets the currently set instrumenter, a No-Op instrumenter by default.
|
|
2002
|
-
*
|
|
2003
|
-
* @returns The currently set instrumenter
|
|
2004
|
-
*/
|
|
2005
|
-
function getInstrumenter() {
|
|
2006
|
-
if (!instrumenterImplementation) {
|
|
2007
|
-
instrumenterImplementation = createDefaultInstrumenter();
|
|
2008
|
-
}
|
|
2009
|
-
return instrumenterImplementation;
|
|
2010
|
-
}
|
|
2011
|
-
|
|
2012
|
-
// Copyright (c) Microsoft Corporation.
|
|
2013
|
-
// Licensed under the MIT license.
|
|
2014
|
-
/**
|
|
2015
|
-
* Creates a new tracing client.
|
|
2016
|
-
*
|
|
2017
|
-
* @param options - Options used to configure the tracing client.
|
|
2018
|
-
* @returns - An instance of {@link TracingClient}.
|
|
2019
|
-
*/
|
|
2020
|
-
function createTracingClient(options) {
|
|
2021
|
-
const { namespace, packageName, packageVersion } = options;
|
|
2022
|
-
function startSpan(name, operationOptions, spanOptions) {
|
|
2023
|
-
var _a;
|
|
2024
|
-
const startSpanResult = getInstrumenter().startSpan(name, Object.assign(Object.assign({}, spanOptions), { packageName: packageName, packageVersion: packageVersion, tracingContext: (_a = operationOptions === null || operationOptions === void 0 ? void 0 : operationOptions.tracingOptions) === null || _a === void 0 ? void 0 : _a.tracingContext }));
|
|
2025
|
-
let tracingContext = startSpanResult.tracingContext;
|
|
2026
|
-
const span = startSpanResult.span;
|
|
2027
|
-
if (!tracingContext.getValue(knownContextKeys.namespace)) {
|
|
2028
|
-
tracingContext = tracingContext.setValue(knownContextKeys.namespace, namespace);
|
|
2029
|
-
}
|
|
2030
|
-
span.setAttribute("az.namespace", tracingContext.getValue(knownContextKeys.namespace));
|
|
2031
|
-
const updatedOptions = Object.assign({}, operationOptions, {
|
|
2032
|
-
tracingOptions: Object.assign(Object.assign({}, operationOptions === null || operationOptions === void 0 ? void 0 : operationOptions.tracingOptions), { tracingContext }),
|
|
2033
|
-
});
|
|
2034
|
-
return {
|
|
2035
|
-
span,
|
|
2036
|
-
updatedOptions,
|
|
2037
|
-
};
|
|
2038
|
-
}
|
|
2039
|
-
async function withSpan(name, operationOptions, callback, spanOptions) {
|
|
2040
|
-
const { span, updatedOptions } = startSpan(name, operationOptions, spanOptions);
|
|
2041
|
-
try {
|
|
2042
|
-
const result = await withContext(updatedOptions.tracingOptions.tracingContext, () => Promise.resolve(callback(updatedOptions, span)));
|
|
2043
|
-
span.setStatus({ status: "success" });
|
|
2044
|
-
return result;
|
|
2045
|
-
}
|
|
2046
|
-
catch (err) {
|
|
2047
|
-
span.setStatus({ status: "error", error: err });
|
|
2048
|
-
throw err;
|
|
2049
|
-
}
|
|
2050
|
-
finally {
|
|
2051
|
-
span.end();
|
|
2052
|
-
}
|
|
2053
|
-
}
|
|
2054
|
-
function withContext(context, callback, ...callbackArgs) {
|
|
2055
|
-
return getInstrumenter().withContext(context, callback, ...callbackArgs);
|
|
2056
|
-
}
|
|
2057
|
-
/**
|
|
2058
|
-
* Parses a traceparent header value into a span identifier.
|
|
2059
|
-
*
|
|
2060
|
-
* @param traceparentHeader - The traceparent header to parse.
|
|
2061
|
-
* @returns An implementation-specific identifier for the span.
|
|
2062
|
-
*/
|
|
2063
|
-
function parseTraceparentHeader(traceparentHeader) {
|
|
2064
|
-
return getInstrumenter().parseTraceparentHeader(traceparentHeader);
|
|
2065
|
-
}
|
|
2066
|
-
/**
|
|
2067
|
-
* Creates a set of request headers to propagate tracing information to a backend.
|
|
2068
|
-
*
|
|
2069
|
-
* @param tracingContext - The context containing the span to serialize.
|
|
2070
|
-
* @returns The set of headers to add to a request.
|
|
2071
|
-
*/
|
|
2072
|
-
function createRequestHeaders(tracingContext) {
|
|
2073
|
-
return getInstrumenter().createRequestHeaders(tracingContext);
|
|
2074
|
-
}
|
|
2075
|
-
return {
|
|
2076
|
-
startSpan,
|
|
2077
|
-
withSpan,
|
|
2078
|
-
withContext,
|
|
2079
|
-
parseTraceparentHeader,
|
|
2080
|
-
createRequestHeaders,
|
|
2081
|
-
};
|
|
2082
|
-
}
|
|
2083
|
-
|
|
2084
|
-
// Copyright (c) Microsoft Corporation.
|
|
2085
|
-
// Licensed under the MIT license.
|
|
2086
|
-
/**
|
|
2087
|
-
* Typeguard for an error object shape (has name and message)
|
|
2088
|
-
* @param e - Something caught by a catch clause.
|
|
2089
|
-
*/
|
|
2090
|
-
function isError(e) {
|
|
2091
|
-
if (isObject(e)) {
|
|
2092
|
-
const hasName = typeof e.name === "string";
|
|
2093
|
-
const hasMessage = typeof e.message === "string";
|
|
2094
|
-
return hasName && hasMessage;
|
|
2095
|
-
}
|
|
2096
|
-
return false;
|
|
2097
|
-
}
|
|
2098
|
-
/**
|
|
2099
|
-
* Given what is thought to be an error object, return the message if possible.
|
|
2100
|
-
* If the message is missing, returns a stringified version of the input.
|
|
2101
|
-
* @param e - Something thrown from a try block
|
|
2102
|
-
* @returns The error message or a string of the input
|
|
2103
|
-
*/
|
|
2104
|
-
function getErrorMessage(e) {
|
|
2105
|
-
if (isError(e)) {
|
|
2106
|
-
return e.message;
|
|
2107
|
-
}
|
|
2108
|
-
else {
|
|
2109
|
-
let stringified;
|
|
2110
|
-
try {
|
|
2111
|
-
if (typeof e === "object" && e) {
|
|
2112
|
-
stringified = JSON.stringify(e);
|
|
2113
|
-
}
|
|
2114
|
-
else {
|
|
2115
|
-
stringified = String(e);
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
|
-
catch (err) {
|
|
2119
|
-
stringified = "[unable to stringify input]";
|
|
2120
|
-
}
|
|
2121
|
-
return `Unknown error ${stringified}`;
|
|
2122
|
-
}
|
|
2123
|
-
}
|
|
2124
|
-
|
|
2125
|
-
// Copyright (c) Microsoft Corporation.
|
|
2126
|
-
// Licensed under the MIT license.
|
|
2127
|
-
const custom = util.inspect.custom;
|
|
2128
|
-
|
|
2129
|
-
// Copyright (c) Microsoft Corporation.
|
|
2130
|
-
// Licensed under the MIT license.
|
|
2131
|
-
const errorSanitizer = new Sanitizer();
|
|
2132
|
-
/**
|
|
2133
|
-
* A custom error type for failed pipeline requests.
|
|
2134
|
-
*/
|
|
2135
|
-
class RestError extends Error {
|
|
2136
|
-
constructor(message, options = {}) {
|
|
2137
|
-
super(message);
|
|
2138
|
-
this.name = "RestError";
|
|
2139
|
-
this.code = options.code;
|
|
2140
|
-
this.statusCode = options.statusCode;
|
|
2141
|
-
this.request = options.request;
|
|
2142
|
-
this.response = options.response;
|
|
2143
|
-
Object.setPrototypeOf(this, RestError.prototype);
|
|
2144
|
-
}
|
|
2145
|
-
/**
|
|
2146
|
-
* Logging method for util.inspect in Node
|
|
2147
|
-
*/
|
|
2148
|
-
[custom]() {
|
|
2149
|
-
return `RestError: ${this.message} \n ${errorSanitizer.sanitize(this)}`;
|
|
2150
|
-
}
|
|
2151
|
-
}
|
|
2152
|
-
/**
|
|
2153
|
-
* Something went wrong when making the request.
|
|
2154
|
-
* This means the actual request failed for some reason,
|
|
2155
|
-
* such as a DNS issue or the connection being lost.
|
|
2156
|
-
*/
|
|
2157
|
-
RestError.REQUEST_SEND_ERROR = "REQUEST_SEND_ERROR";
|
|
2158
|
-
/**
|
|
2159
|
-
* This means that parsing the response from the server failed.
|
|
2160
|
-
* It may have been malformed.
|
|
2161
|
-
*/
|
|
2162
|
-
RestError.PARSE_ERROR = "PARSE_ERROR";
|
|
2163
|
-
/**
|
|
2164
|
-
* Typeguard for RestError
|
|
2165
|
-
* @param e - Something caught by a catch clause.
|
|
2166
|
-
*/
|
|
2167
|
-
function isRestError(e) {
|
|
2168
|
-
if (e instanceof RestError) {
|
|
2169
|
-
return true;
|
|
2170
|
-
}
|
|
2171
|
-
return isError(e) && e.name === "RestError";
|
|
2172
|
-
}
|
|
2173
|
-
|
|
2174
|
-
// Copyright (c) Microsoft Corporation.
|
|
2175
|
-
// Licensed under the MIT license.
|
|
2176
|
-
/**
|
|
2177
|
-
* The programmatic identifier of the tracingPolicy.
|
|
2178
|
-
*/
|
|
2179
|
-
const tracingPolicyName = "tracingPolicy";
|
|
2180
|
-
/**
|
|
2181
|
-
* A simple policy to create OpenTelemetry Spans for each request made by the pipeline
|
|
2182
|
-
* that has SpanOptions with a parent.
|
|
2183
|
-
* Requests made without a parent Span will not be recorded.
|
|
2184
|
-
* @param options - Options to configure the telemetry logged by the tracing policy.
|
|
2185
|
-
*/
|
|
2186
|
-
function tracingPolicy(options = {}) {
|
|
2187
|
-
const userAgent = getUserAgentValue(options.userAgentPrefix);
|
|
2188
|
-
const tracingClient = tryCreateTracingClient();
|
|
2189
|
-
return {
|
|
2190
|
-
name: tracingPolicyName,
|
|
2191
|
-
async sendRequest(request, next) {
|
|
2192
|
-
var _a, _b;
|
|
2193
|
-
if (!tracingClient || !((_a = request.tracingOptions) === null || _a === void 0 ? void 0 : _a.tracingContext)) {
|
|
2194
|
-
return next(request);
|
|
2195
|
-
}
|
|
2196
|
-
const { span, tracingContext } = (_b = tryCreateSpan(tracingClient, request, userAgent)) !== null && _b !== void 0 ? _b : {};
|
|
2197
|
-
if (!span || !tracingContext) {
|
|
2198
|
-
return next(request);
|
|
2199
|
-
}
|
|
2200
|
-
try {
|
|
2201
|
-
const response = await tracingClient.withContext(tracingContext, next, request);
|
|
2202
|
-
tryProcessResponse(span, response);
|
|
2203
|
-
return response;
|
|
2204
|
-
}
|
|
2205
|
-
catch (err) {
|
|
2206
|
-
tryProcessError(span, err);
|
|
2207
|
-
throw err;
|
|
2208
|
-
}
|
|
2209
|
-
},
|
|
2210
|
-
};
|
|
2211
|
-
}
|
|
2212
|
-
function tryCreateTracingClient() {
|
|
2213
|
-
try {
|
|
2214
|
-
return createTracingClient({
|
|
2215
|
-
namespace: "",
|
|
2216
|
-
packageName: "@typespec/ts-http-runtime",
|
|
2217
|
-
packageVersion: SDK_VERSION,
|
|
2218
|
-
});
|
|
2219
|
-
}
|
|
2220
|
-
catch (e) {
|
|
2221
|
-
logger.warning(`Error when creating the TracingClient: ${getErrorMessage(e)}`);
|
|
2222
|
-
return undefined;
|
|
2223
|
-
}
|
|
2224
|
-
}
|
|
2225
|
-
function tryCreateSpan(tracingClient, request, userAgent) {
|
|
2226
|
-
try {
|
|
2227
|
-
// As per spec, we do not need to differentiate between HTTP and HTTPS in span name.
|
|
2228
|
-
const { span, updatedOptions } = tracingClient.startSpan(`HTTP ${request.method}`, { tracingOptions: request.tracingOptions }, {
|
|
2229
|
-
spanKind: "client",
|
|
2230
|
-
spanAttributes: {
|
|
2231
|
-
"http.method": request.method,
|
|
2232
|
-
"http.url": request.url,
|
|
2233
|
-
requestId: request.requestId,
|
|
2234
|
-
},
|
|
2235
|
-
});
|
|
2236
|
-
// If the span is not recording, don't do any more work.
|
|
2237
|
-
if (!span.isRecording()) {
|
|
2238
|
-
span.end();
|
|
2239
|
-
return undefined;
|
|
2240
|
-
}
|
|
2241
|
-
if (userAgent) {
|
|
2242
|
-
span.setAttribute("http.user_agent", userAgent);
|
|
2243
|
-
}
|
|
2244
|
-
// set headers
|
|
2245
|
-
const headers = tracingClient.createRequestHeaders(updatedOptions.tracingOptions.tracingContext);
|
|
2246
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
2247
|
-
request.headers.set(key, value);
|
|
2248
|
-
}
|
|
2249
|
-
return { span, tracingContext: updatedOptions.tracingOptions.tracingContext };
|
|
2250
|
-
}
|
|
2251
|
-
catch (e) {
|
|
2252
|
-
logger.warning(`Skipping creating a tracing span due to an error: ${getErrorMessage(e)}`);
|
|
2253
|
-
return undefined;
|
|
2254
|
-
}
|
|
2255
|
-
}
|
|
2256
|
-
function tryProcessError(span, error) {
|
|
2257
|
-
try {
|
|
2258
|
-
span.setStatus({
|
|
2259
|
-
status: "error",
|
|
2260
|
-
error: isError(error) ? error : undefined,
|
|
2261
|
-
});
|
|
2262
|
-
if (isRestError(error) && error.statusCode) {
|
|
2263
|
-
span.setAttribute("http.status_code", error.statusCode);
|
|
2264
|
-
}
|
|
2265
|
-
span.end();
|
|
2266
|
-
}
|
|
2267
|
-
catch (e) {
|
|
2268
|
-
logger.warning(`Skipping tracing span processing due to an error: ${getErrorMessage(e)}`);
|
|
2269
|
-
}
|
|
2270
|
-
}
|
|
2271
|
-
function tryProcessResponse(span, response) {
|
|
2272
|
-
try {
|
|
2273
|
-
span.setAttribute("http.status_code", response.status);
|
|
2274
|
-
const serviceRequestId = response.headers.get("x-ms-request-id");
|
|
2275
|
-
if (serviceRequestId) {
|
|
2276
|
-
span.setAttribute("serviceRequestId", serviceRequestId);
|
|
2277
|
-
}
|
|
2278
|
-
span.setStatus({
|
|
2279
|
-
status: "success",
|
|
2280
|
-
});
|
|
2281
|
-
span.end();
|
|
2282
|
-
}
|
|
2283
|
-
catch (e) {
|
|
2284
|
-
logger.warning(`Skipping tracing span processing due to an error: ${getErrorMessage(e)}`);
|
|
2285
|
-
}
|
|
2286
|
-
}
|
|
2287
|
-
|
|
2288
|
-
// Copyright (c) Microsoft Corporation.
|
|
2289
|
-
// Licensed under the MIT license.
|
|
2290
|
-
/**
|
|
2291
|
-
* Create a new pipeline with a default set of customizable policies.
|
|
2292
|
-
* @param options - Options to configure a custom pipeline.
|
|
2293
|
-
*/
|
|
2294
|
-
function createPipelineFromOptions(options) {
|
|
2295
|
-
const pipeline = createEmptyPipeline();
|
|
2296
|
-
if (isNode) {
|
|
2297
|
-
if (options.tlsOptions) {
|
|
2298
|
-
pipeline.addPolicy(tlsPolicy(options.tlsOptions));
|
|
2299
|
-
}
|
|
2300
|
-
pipeline.addPolicy(proxyPolicy(options.proxyOptions));
|
|
2301
|
-
pipeline.addPolicy(decompressResponsePolicy());
|
|
2302
|
-
}
|
|
2303
|
-
pipeline.addPolicy(formDataPolicy(), { beforePolicies: [multipartPolicyName] });
|
|
2304
|
-
pipeline.addPolicy(userAgentPolicy(options.userAgentOptions));
|
|
2305
|
-
// The multipart policy is added after policies with no phase, so that
|
|
2306
|
-
// policies can be added between it and formDataPolicy to modify
|
|
2307
|
-
// properties (e.g., making the boundary constant in recorded tests).
|
|
2308
|
-
pipeline.addPolicy(multipartPolicy(), { afterPhase: "Deserialize" });
|
|
2309
|
-
pipeline.addPolicy(defaultRetryPolicy(options.retryOptions), { phase: "Retry" });
|
|
2310
|
-
pipeline.addPolicy(tracingPolicy(options.userAgentOptions), { afterPhase: "Retry" });
|
|
2311
|
-
if (isNode) {
|
|
2312
|
-
// Both XHR and Fetch expect to handle redirects automatically,
|
|
2313
|
-
// so only include this policy when we're in Node.
|
|
2314
|
-
pipeline.addPolicy(redirectPolicy(options.redirectOptions), { afterPhase: "Retry" });
|
|
2315
|
-
}
|
|
2316
|
-
pipeline.addPolicy(logPolicy(options.loggingOptions), { afterPhase: "Sign" });
|
|
2317
|
-
return pipeline;
|
|
2318
|
-
}
|
|
2319
|
-
|
|
2320
|
-
// Copyright (c) Microsoft Corporation.
|
|
2321
|
-
// Licensed under the MIT license.
|
|
2322
|
-
const DEFAULT_TLS_SETTINGS = {};
|
|
2323
|
-
function isReadableStream(body) {
|
|
2324
|
-
return body && typeof body.pipe === "function";
|
|
2325
|
-
}
|
|
2326
|
-
function isStreamComplete(stream) {
|
|
2327
|
-
return new Promise((resolve) => {
|
|
2328
|
-
stream.on("close", resolve);
|
|
2329
|
-
stream.on("end", resolve);
|
|
2330
|
-
stream.on("error", resolve);
|
|
2331
|
-
});
|
|
2332
|
-
}
|
|
2333
|
-
function isArrayBuffer(body) {
|
|
2334
|
-
return body && typeof body.byteLength === "number";
|
|
2335
|
-
}
|
|
2336
|
-
class ReportTransform extends stream.Transform {
|
|
2337
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
2338
|
-
_transform(chunk, _encoding, callback) {
|
|
2339
|
-
this.push(chunk);
|
|
2340
|
-
this.loadedBytes += chunk.length;
|
|
2341
|
-
try {
|
|
2342
|
-
this.progressCallback({ loadedBytes: this.loadedBytes });
|
|
2343
|
-
callback();
|
|
2344
|
-
}
|
|
2345
|
-
catch (e) {
|
|
2346
|
-
callback(e);
|
|
2347
|
-
}
|
|
2348
|
-
}
|
|
2349
|
-
constructor(progressCallback) {
|
|
2350
|
-
super();
|
|
2351
|
-
this.loadedBytes = 0;
|
|
2352
|
-
this.progressCallback = progressCallback;
|
|
2353
|
-
}
|
|
2354
|
-
}
|
|
2355
|
-
/**
|
|
2356
|
-
* A HttpClient implementation that uses Node's "https" module to send HTTPS requests.
|
|
2357
|
-
* @internal
|
|
2358
|
-
*/
|
|
2359
|
-
class NodeHttpClient {
|
|
2360
|
-
constructor() {
|
|
2361
|
-
this.cachedHttpsAgents = new WeakMap();
|
|
2362
|
-
}
|
|
2363
|
-
/**
|
|
2364
|
-
* Makes a request over an underlying transport layer and returns the response.
|
|
2365
|
-
* @param request - The request to be made.
|
|
2366
|
-
*/
|
|
2367
|
-
async sendRequest(request) {
|
|
2368
|
-
var _a, _b, _c;
|
|
2369
|
-
const abortController = new AbortController();
|
|
2370
|
-
let abortListener;
|
|
2371
|
-
if (request.abortSignal) {
|
|
2372
|
-
if (request.abortSignal.aborted) {
|
|
2373
|
-
throw new AbortError("The operation was aborted.");
|
|
2374
|
-
}
|
|
2375
|
-
abortListener = (event) => {
|
|
2376
|
-
if (event.type === "abort") {
|
|
2377
|
-
abortController.abort();
|
|
2378
|
-
}
|
|
2379
|
-
};
|
|
2380
|
-
request.abortSignal.addEventListener("abort", abortListener);
|
|
2381
|
-
}
|
|
2382
|
-
if (request.timeout > 0) {
|
|
2383
|
-
setTimeout(() => {
|
|
2384
|
-
abortController.abort();
|
|
2385
|
-
}, request.timeout);
|
|
2386
|
-
}
|
|
2387
|
-
const acceptEncoding = request.headers.get("Accept-Encoding");
|
|
2388
|
-
const shouldDecompress = (acceptEncoding === null || acceptEncoding === void 0 ? void 0 : acceptEncoding.includes("gzip")) || (acceptEncoding === null || acceptEncoding === void 0 ? void 0 : acceptEncoding.includes("deflate"));
|
|
2389
|
-
let body = typeof request.body === "function" ? request.body() : request.body;
|
|
2390
|
-
if (body && !request.headers.has("Content-Length")) {
|
|
2391
|
-
const bodyLength = getBodyLength(body);
|
|
2392
|
-
if (bodyLength !== null) {
|
|
2393
|
-
request.headers.set("Content-Length", bodyLength);
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2396
|
-
let responseStream;
|
|
2397
|
-
try {
|
|
2398
|
-
if (body && request.onUploadProgress) {
|
|
2399
|
-
const onUploadProgress = request.onUploadProgress;
|
|
2400
|
-
const uploadReportStream = new ReportTransform(onUploadProgress);
|
|
2401
|
-
uploadReportStream.on("error", (e) => {
|
|
2402
|
-
logger.error("Error in upload progress", e);
|
|
2403
|
-
});
|
|
2404
|
-
if (isReadableStream(body)) {
|
|
2405
|
-
body.pipe(uploadReportStream);
|
|
2406
|
-
}
|
|
2407
|
-
else {
|
|
2408
|
-
uploadReportStream.end(body);
|
|
2409
|
-
}
|
|
2410
|
-
body = uploadReportStream;
|
|
2411
|
-
}
|
|
2412
|
-
const res = await this.makeRequest(request, abortController, body);
|
|
2413
|
-
const headers = getResponseHeaders(res);
|
|
2414
|
-
const status = (_a = res.statusCode) !== null && _a !== void 0 ? _a : 0;
|
|
2415
|
-
const response = {
|
|
2416
|
-
status,
|
|
2417
|
-
headers,
|
|
2418
|
-
request,
|
|
2419
|
-
};
|
|
2420
|
-
// Responses to HEAD must not have a body.
|
|
2421
|
-
// If they do return a body, that body must be ignored.
|
|
2422
|
-
if (request.method === "HEAD") {
|
|
2423
|
-
// call resume() and not destroy() to avoid closing the socket
|
|
2424
|
-
// and losing keep alive
|
|
2425
|
-
res.resume();
|
|
2426
|
-
return response;
|
|
2427
|
-
}
|
|
2428
|
-
responseStream = shouldDecompress ? getDecodedResponseStream(res, headers) : res;
|
|
2429
|
-
const onDownloadProgress = request.onDownloadProgress;
|
|
2430
|
-
if (onDownloadProgress) {
|
|
2431
|
-
const downloadReportStream = new ReportTransform(onDownloadProgress);
|
|
2432
|
-
downloadReportStream.on("error", (e) => {
|
|
2433
|
-
logger.error("Error in download progress", e);
|
|
2434
|
-
});
|
|
2435
|
-
responseStream.pipe(downloadReportStream);
|
|
2436
|
-
responseStream = downloadReportStream;
|
|
2437
|
-
}
|
|
2438
|
-
if (
|
|
2439
|
-
// Value of POSITIVE_INFINITY in streamResponseStatusCodes is considered as any status code
|
|
2440
|
-
((_b = request.streamResponseStatusCodes) === null || _b === void 0 ? void 0 : _b.has(Number.POSITIVE_INFINITY)) ||
|
|
2441
|
-
((_c = request.streamResponseStatusCodes) === null || _c === void 0 ? void 0 : _c.has(response.status))) {
|
|
2442
|
-
response.readableStreamBody = responseStream;
|
|
2443
|
-
}
|
|
2444
|
-
else {
|
|
2445
|
-
response.bodyAsText = await streamToText(responseStream);
|
|
2446
|
-
}
|
|
2447
|
-
return response;
|
|
2448
|
-
}
|
|
2449
|
-
finally {
|
|
2450
|
-
// clean up event listener
|
|
2451
|
-
if (request.abortSignal && abortListener) {
|
|
2452
|
-
let uploadStreamDone = Promise.resolve();
|
|
2453
|
-
if (isReadableStream(body)) {
|
|
2454
|
-
uploadStreamDone = isStreamComplete(body);
|
|
2455
|
-
}
|
|
2456
|
-
let downloadStreamDone = Promise.resolve();
|
|
2457
|
-
if (isReadableStream(responseStream)) {
|
|
2458
|
-
downloadStreamDone = isStreamComplete(responseStream);
|
|
2459
|
-
}
|
|
2460
|
-
Promise.all([uploadStreamDone, downloadStreamDone])
|
|
2461
|
-
.then(() => {
|
|
2462
|
-
var _a;
|
|
2463
|
-
// eslint-disable-next-line promise/always-return
|
|
2464
|
-
if (abortListener) {
|
|
2465
|
-
(_a = request.abortSignal) === null || _a === void 0 ? void 0 : _a.removeEventListener("abort", abortListener);
|
|
2466
|
-
}
|
|
2467
|
-
})
|
|
2468
|
-
.catch((e) => {
|
|
2469
|
-
logger.warning("Error when cleaning up abortListener on httpRequest", e);
|
|
2470
|
-
});
|
|
2471
|
-
}
|
|
2472
|
-
}
|
|
2473
|
-
}
|
|
2474
|
-
makeRequest(request, abortController, body) {
|
|
2475
|
-
var _a;
|
|
2476
|
-
const url = new URL(request.url);
|
|
2477
|
-
const isInsecure = url.protocol !== "https:";
|
|
2478
|
-
if (isInsecure && !request.allowInsecureConnection) {
|
|
2479
|
-
throw new Error(`Cannot connect to ${request.url} while allowInsecureConnection is false.`);
|
|
2480
|
-
}
|
|
2481
|
-
const agent = (_a = request.agent) !== null && _a !== void 0 ? _a : this.getOrCreateAgent(request, isInsecure);
|
|
2482
|
-
const options = {
|
|
2483
|
-
agent,
|
|
2484
|
-
hostname: url.hostname,
|
|
2485
|
-
path: `${url.pathname}${url.search}`,
|
|
2486
|
-
port: url.port,
|
|
2487
|
-
method: request.method,
|
|
2488
|
-
headers: request.headers.toJSON({ preserveCase: true }),
|
|
2489
|
-
};
|
|
2490
|
-
return new Promise((resolve, reject) => {
|
|
2491
|
-
const req = isInsecure ? http__namespace.request(options, resolve) : https__namespace.request(options, resolve);
|
|
2492
|
-
req.once("error", (err) => {
|
|
2493
|
-
var _a;
|
|
2494
|
-
reject(new RestError(err.message, { code: (_a = err.code) !== null && _a !== void 0 ? _a : RestError.REQUEST_SEND_ERROR, request }));
|
|
2495
|
-
});
|
|
2496
|
-
abortController.signal.addEventListener("abort", () => {
|
|
2497
|
-
const abortError = new AbortError("The operation was aborted.");
|
|
2498
|
-
req.destroy(abortError);
|
|
2499
|
-
reject(abortError);
|
|
2500
|
-
});
|
|
2501
|
-
if (body && isReadableStream(body)) {
|
|
2502
|
-
body.pipe(req);
|
|
2503
|
-
}
|
|
2504
|
-
else if (body) {
|
|
2505
|
-
if (typeof body === "string" || Buffer.isBuffer(body)) {
|
|
2506
|
-
req.end(body);
|
|
2507
|
-
}
|
|
2508
|
-
else if (isArrayBuffer(body)) {
|
|
2509
|
-
req.end(ArrayBuffer.isView(body) ? Buffer.from(body.buffer) : Buffer.from(body));
|
|
2510
|
-
}
|
|
2511
|
-
else {
|
|
2512
|
-
logger.error("Unrecognized body type", body);
|
|
2513
|
-
reject(new RestError("Unrecognized body type"));
|
|
2514
|
-
}
|
|
2515
|
-
}
|
|
2516
|
-
else {
|
|
2517
|
-
// streams don't like "undefined" being passed as data
|
|
2518
|
-
req.end();
|
|
2519
|
-
}
|
|
2520
|
-
});
|
|
2521
|
-
}
|
|
2522
|
-
getOrCreateAgent(request, isInsecure) {
|
|
2523
|
-
var _a;
|
|
2524
|
-
const disableKeepAlive = request.disableKeepAlive;
|
|
2525
|
-
// Handle Insecure requests first
|
|
2526
|
-
if (isInsecure) {
|
|
2527
|
-
if (disableKeepAlive) {
|
|
2528
|
-
// keepAlive:false is the default so we don't need a custom Agent
|
|
2529
|
-
return http__namespace.globalAgent;
|
|
2530
|
-
}
|
|
2531
|
-
if (!this.cachedHttpAgent) {
|
|
2532
|
-
// If there is no cached agent create a new one and cache it.
|
|
2533
|
-
this.cachedHttpAgent = new http__namespace.Agent({ keepAlive: true });
|
|
2534
|
-
}
|
|
2535
|
-
return this.cachedHttpAgent;
|
|
2536
|
-
}
|
|
2537
|
-
else {
|
|
2538
|
-
if (disableKeepAlive && !request.tlsSettings) {
|
|
2539
|
-
// When there are no tlsSettings and keepAlive is false
|
|
2540
|
-
// we don't need a custom agent
|
|
2541
|
-
return https__namespace.globalAgent;
|
|
2542
|
-
}
|
|
2543
|
-
// We use the tlsSettings to index cached clients
|
|
2544
|
-
const tlsSettings = (_a = request.tlsSettings) !== null && _a !== void 0 ? _a : DEFAULT_TLS_SETTINGS;
|
|
2545
|
-
// Get the cached agent or create a new one with the
|
|
2546
|
-
// provided values for keepAlive and tlsSettings
|
|
2547
|
-
let agent = this.cachedHttpsAgents.get(tlsSettings);
|
|
2548
|
-
if (agent && agent.options.keepAlive === !disableKeepAlive) {
|
|
2549
|
-
return agent;
|
|
2550
|
-
}
|
|
2551
|
-
logger.info("No cached TLS Agent exist, creating a new Agent");
|
|
2552
|
-
agent = new https__namespace.Agent(Object.assign({
|
|
2553
|
-
// keepAlive is true if disableKeepAlive is false.
|
|
2554
|
-
keepAlive: !disableKeepAlive }, tlsSettings));
|
|
2555
|
-
this.cachedHttpsAgents.set(tlsSettings, agent);
|
|
2556
|
-
return agent;
|
|
2557
|
-
}
|
|
2558
|
-
}
|
|
2559
|
-
}
|
|
2560
|
-
function getResponseHeaders(res) {
|
|
2561
|
-
const headers = createHttpHeaders();
|
|
2562
|
-
for (const header of Object.keys(res.headers)) {
|
|
2563
|
-
const value = res.headers[header];
|
|
2564
|
-
if (Array.isArray(value)) {
|
|
2565
|
-
if (value.length > 0) {
|
|
2566
|
-
headers.set(header, value[0]);
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
|
-
else if (value) {
|
|
2570
|
-
headers.set(header, value);
|
|
2571
|
-
}
|
|
2572
|
-
}
|
|
2573
|
-
return headers;
|
|
2574
|
-
}
|
|
2575
|
-
function getDecodedResponseStream(stream, headers) {
|
|
2576
|
-
const contentEncoding = headers.get("Content-Encoding");
|
|
2577
|
-
if (contentEncoding === "gzip") {
|
|
2578
|
-
const unzip = zlib__namespace.createGunzip();
|
|
2579
|
-
stream.pipe(unzip);
|
|
2580
|
-
return unzip;
|
|
2581
|
-
}
|
|
2582
|
-
else if (contentEncoding === "deflate") {
|
|
2583
|
-
const inflate = zlib__namespace.createInflate();
|
|
2584
|
-
stream.pipe(inflate);
|
|
2585
|
-
return inflate;
|
|
2586
|
-
}
|
|
2587
|
-
return stream;
|
|
2588
|
-
}
|
|
2589
|
-
function streamToText(stream) {
|
|
2590
|
-
return new Promise((resolve, reject) => {
|
|
2591
|
-
const buffer = [];
|
|
2592
|
-
stream.on("data", (chunk) => {
|
|
2593
|
-
if (Buffer.isBuffer(chunk)) {
|
|
2594
|
-
buffer.push(chunk);
|
|
2595
|
-
}
|
|
2596
|
-
else {
|
|
2597
|
-
buffer.push(Buffer.from(chunk));
|
|
2598
|
-
}
|
|
2599
|
-
});
|
|
2600
|
-
stream.on("end", () => {
|
|
2601
|
-
resolve(Buffer.concat(buffer).toString("utf8"));
|
|
2602
|
-
});
|
|
2603
|
-
stream.on("error", (e) => {
|
|
2604
|
-
if (e && (e === null || e === void 0 ? void 0 : e.name) === "AbortError") {
|
|
2605
|
-
reject(e);
|
|
2606
|
-
}
|
|
2607
|
-
else {
|
|
2608
|
-
reject(new RestError(`Error reading response as text: ${e.message}`, {
|
|
2609
|
-
code: RestError.PARSE_ERROR,
|
|
2610
|
-
}));
|
|
2611
|
-
}
|
|
2612
|
-
});
|
|
2613
|
-
});
|
|
2614
|
-
}
|
|
2615
|
-
/** @internal */
|
|
2616
|
-
function getBodyLength(body) {
|
|
2617
|
-
if (!body) {
|
|
2618
|
-
return 0;
|
|
2619
|
-
}
|
|
2620
|
-
else if (Buffer.isBuffer(body)) {
|
|
2621
|
-
return body.length;
|
|
2622
|
-
}
|
|
2623
|
-
else if (isReadableStream(body)) {
|
|
2624
|
-
return null;
|
|
2625
|
-
}
|
|
2626
|
-
else if (isArrayBuffer(body)) {
|
|
2627
|
-
return body.byteLength;
|
|
2628
|
-
}
|
|
2629
|
-
else if (typeof body === "string") {
|
|
2630
|
-
return Buffer.from(body).length;
|
|
2631
|
-
}
|
|
2632
|
-
else {
|
|
2633
|
-
return null;
|
|
2634
|
-
}
|
|
2635
|
-
}
|
|
2636
|
-
/**
|
|
2637
|
-
* Create a new HttpClient instance for the NodeJS environment.
|
|
2638
|
-
* @internal
|
|
2639
|
-
*/
|
|
2640
|
-
function createNodeHttpClient() {
|
|
2641
|
-
return new NodeHttpClient();
|
|
2642
|
-
}
|
|
2643
|
-
|
|
2644
|
-
// Copyright (c) Microsoft Corporation.
|
|
2645
|
-
// Licensed under the MIT license.
|
|
2646
|
-
/**
|
|
2647
|
-
* Create the correct HttpClient for the current environment.
|
|
2648
|
-
*/
|
|
2649
|
-
function createDefaultHttpClient() {
|
|
2650
|
-
return createNodeHttpClient();
|
|
2651
|
-
}
|
|
2652
|
-
|
|
2653
|
-
// Copyright (c) Microsoft Corporation.
|
|
2654
|
-
// Licensed under the MIT license.
|
|
2655
|
-
class PipelineRequestImpl {
|
|
2656
|
-
constructor(options) {
|
|
2657
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2658
|
-
this.url = options.url;
|
|
2659
|
-
this.body = options.body;
|
|
2660
|
-
this.headers = (_a = options.headers) !== null && _a !== void 0 ? _a : createHttpHeaders();
|
|
2661
|
-
this.method = (_b = options.method) !== null && _b !== void 0 ? _b : "GET";
|
|
2662
|
-
this.timeout = (_c = options.timeout) !== null && _c !== void 0 ? _c : 0;
|
|
2663
|
-
this.multipartBody = options.multipartBody;
|
|
2664
|
-
this.formData = options.formData;
|
|
2665
|
-
this.disableKeepAlive = (_d = options.disableKeepAlive) !== null && _d !== void 0 ? _d : false;
|
|
2666
|
-
this.proxySettings = options.proxySettings;
|
|
2667
|
-
this.streamResponseStatusCodes = options.streamResponseStatusCodes;
|
|
2668
|
-
this.withCredentials = (_e = options.withCredentials) !== null && _e !== void 0 ? _e : false;
|
|
2669
|
-
this.abortSignal = options.abortSignal;
|
|
2670
|
-
this.tracingOptions = options.tracingOptions;
|
|
2671
|
-
this.onUploadProgress = options.onUploadProgress;
|
|
2672
|
-
this.onDownloadProgress = options.onDownloadProgress;
|
|
2673
|
-
this.requestId = options.requestId || randomUUID();
|
|
2674
|
-
this.allowInsecureConnection = (_f = options.allowInsecureConnection) !== null && _f !== void 0 ? _f : false;
|
|
2675
|
-
this.enableBrowserStreams = (_g = options.enableBrowserStreams) !== null && _g !== void 0 ? _g : false;
|
|
2676
|
-
}
|
|
2677
|
-
}
|
|
2678
|
-
/**
|
|
2679
|
-
* Creates a new pipeline request with the given options.
|
|
2680
|
-
* This method is to allow for the easy setting of default values and not required.
|
|
2681
|
-
* @param options - The options to create the request with.
|
|
2682
|
-
*/
|
|
2683
|
-
function createPipelineRequest(options) {
|
|
2684
|
-
return new PipelineRequestImpl(options);
|
|
2685
|
-
}
|
|
2686
|
-
|
|
2687
|
-
// Copyright (c) Microsoft Corporation.
|
|
2688
|
-
// Licensed under the MIT license.
|
|
2689
|
-
// Default options for the cycler if none are provided
|
|
2690
|
-
const DEFAULT_CYCLER_OPTIONS = {
|
|
2691
|
-
forcedRefreshWindowInMs: 1000, // Force waiting for a refresh 1s before the token expires
|
|
2692
|
-
retryIntervalInMs: 3000, // Allow refresh attempts every 3s
|
|
2693
|
-
refreshWindowInMs: 1000 * 60 * 2, // Start refreshing 2m before expiry
|
|
2694
|
-
};
|
|
2695
|
-
/**
|
|
2696
|
-
* Converts an an unreliable access token getter (which may resolve with null)
|
|
2697
|
-
* into an AccessTokenGetter by retrying the unreliable getter in a regular
|
|
2698
|
-
* interval.
|
|
2699
|
-
*
|
|
2700
|
-
* @param getAccessToken - A function that produces a promise of an access token that may fail by returning null.
|
|
2701
|
-
* @param retryIntervalInMs - The time (in milliseconds) to wait between retry attempts.
|
|
2702
|
-
* @param refreshTimeout - The timestamp after which the refresh attempt will fail, throwing an exception.
|
|
2703
|
-
* @returns - A promise that, if it resolves, will resolve with an access token.
|
|
2704
|
-
*/
|
|
2705
|
-
async function beginRefresh(getAccessToken, retryIntervalInMs, refreshTimeout) {
|
|
2706
|
-
// This wrapper handles exceptions gracefully as long as we haven't exceeded
|
|
2707
|
-
// the timeout.
|
|
2708
|
-
async function tryGetAccessToken() {
|
|
2709
|
-
if (Date.now() < refreshTimeout) {
|
|
2710
|
-
try {
|
|
2711
|
-
return await getAccessToken();
|
|
2712
|
-
}
|
|
2713
|
-
catch (_a) {
|
|
2714
|
-
return null;
|
|
2715
|
-
}
|
|
2716
|
-
}
|
|
2717
|
-
else {
|
|
2718
|
-
const finalToken = await getAccessToken();
|
|
2719
|
-
// Timeout is up, so throw if it's still null
|
|
2720
|
-
if (finalToken === null) {
|
|
2721
|
-
throw new Error("Failed to refresh access token.");
|
|
2722
|
-
}
|
|
2723
|
-
return finalToken;
|
|
2724
|
-
}
|
|
2725
|
-
}
|
|
2726
|
-
let token = await tryGetAccessToken();
|
|
2727
|
-
while (token === null) {
|
|
2728
|
-
await delay$1(retryIntervalInMs);
|
|
2729
|
-
token = await tryGetAccessToken();
|
|
2730
|
-
}
|
|
2731
|
-
return token;
|
|
2732
|
-
}
|
|
2733
|
-
/**
|
|
2734
|
-
* Creates a token cycler from a credential, scopes, and optional settings.
|
|
2735
|
-
*
|
|
2736
|
-
* A token cycler represents a way to reliably retrieve a valid access token
|
|
2737
|
-
* from a TokenCredential. It will handle initializing the token, refreshing it
|
|
2738
|
-
* when it nears expiration, and synchronizes refresh attempts to avoid
|
|
2739
|
-
* concurrency hazards.
|
|
2740
|
-
*
|
|
2741
|
-
* @param credential - the underlying TokenCredential that provides the access
|
|
2742
|
-
* token
|
|
2743
|
-
* @param tokenCyclerOptions - optionally override default settings for the cycler
|
|
2744
|
-
*
|
|
2745
|
-
* @returns - a function that reliably produces a valid access token
|
|
2746
|
-
*/
|
|
2747
|
-
function createTokenCycler(credential, tokenCyclerOptions) {
|
|
2748
|
-
let refreshWorker = null;
|
|
2749
|
-
let token = null;
|
|
2750
|
-
let tenantId;
|
|
2751
|
-
const options = Object.assign(Object.assign({}, DEFAULT_CYCLER_OPTIONS), tokenCyclerOptions);
|
|
2752
|
-
/**
|
|
2753
|
-
* This little holder defines several predicates that we use to construct
|
|
2754
|
-
* the rules of refreshing the token.
|
|
2755
|
-
*/
|
|
2756
|
-
const cycler = {
|
|
2757
|
-
/**
|
|
2758
|
-
* Produces true if a refresh job is currently in progress.
|
|
2759
|
-
*/
|
|
2760
|
-
get isRefreshing() {
|
|
2761
|
-
return refreshWorker !== null;
|
|
2762
|
-
},
|
|
2763
|
-
/**
|
|
2764
|
-
* Produces true if the cycler SHOULD refresh (we are within the refresh
|
|
2765
|
-
* window and not already refreshing)
|
|
2766
|
-
*/
|
|
2767
|
-
get shouldRefresh() {
|
|
2768
|
-
var _a;
|
|
2769
|
-
return (!cycler.isRefreshing &&
|
|
2770
|
-
((_a = token === null || token === void 0 ? void 0 : token.expiresOnTimestamp) !== null && _a !== void 0 ? _a : 0) - options.refreshWindowInMs < Date.now());
|
|
2771
|
-
},
|
|
2772
|
-
/**
|
|
2773
|
-
* Produces true if the cycler MUST refresh (null or nearly-expired
|
|
2774
|
-
* token).
|
|
2775
|
-
*/
|
|
2776
|
-
get mustRefresh() {
|
|
2777
|
-
return (token === null || token.expiresOnTimestamp - options.forcedRefreshWindowInMs < Date.now());
|
|
2778
|
-
},
|
|
2779
|
-
};
|
|
2780
|
-
/**
|
|
2781
|
-
* Starts a refresh job or returns the existing job if one is already
|
|
2782
|
-
* running.
|
|
2783
|
-
*/
|
|
2784
|
-
function refresh(scopes, getTokenOptions) {
|
|
2785
|
-
var _a;
|
|
2786
|
-
if (!cycler.isRefreshing) {
|
|
2787
|
-
// We bind `scopes` here to avoid passing it around a lot
|
|
2788
|
-
const tryGetAccessToken = () => credential.getToken(scopes, getTokenOptions);
|
|
2789
|
-
// Take advantage of promise chaining to insert an assignment to `token`
|
|
2790
|
-
// before the refresh can be considered done.
|
|
2791
|
-
refreshWorker = beginRefresh(tryGetAccessToken, options.retryIntervalInMs,
|
|
2792
|
-
// If we don't have a token, then we should timeout immediately
|
|
2793
|
-
(_a = token === null || token === void 0 ? void 0 : token.expiresOnTimestamp) !== null && _a !== void 0 ? _a : Date.now())
|
|
2794
|
-
.then((_token) => {
|
|
2795
|
-
refreshWorker = null;
|
|
2796
|
-
token = _token;
|
|
2797
|
-
tenantId = getTokenOptions.tenantId;
|
|
2798
|
-
return token;
|
|
2799
|
-
})
|
|
2800
|
-
.catch((reason) => {
|
|
2801
|
-
// We also should reset the refresher if we enter a failed state. All
|
|
2802
|
-
// existing awaiters will throw, but subsequent requests will start a
|
|
2803
|
-
// new retry chain.
|
|
2804
|
-
refreshWorker = null;
|
|
2805
|
-
token = null;
|
|
2806
|
-
tenantId = undefined;
|
|
2807
|
-
throw reason;
|
|
2808
|
-
});
|
|
2809
|
-
}
|
|
2810
|
-
return refreshWorker;
|
|
2811
|
-
}
|
|
2812
|
-
return async (scopes, tokenOptions) => {
|
|
2813
|
-
//
|
|
2814
|
-
// Simple rules:
|
|
2815
|
-
// - If we MUST refresh, then return the refresh task, blocking
|
|
2816
|
-
// the pipeline until a token is available.
|
|
2817
|
-
// - If we SHOULD refresh, then run refresh but don't return it
|
|
2818
|
-
// (we can still use the cached token).
|
|
2819
|
-
// - Return the token, since it's fine if we didn't return in
|
|
2820
|
-
// step 1.
|
|
2821
|
-
//
|
|
2822
|
-
// If the tenantId passed in token options is different to the one we have
|
|
2823
|
-
// Or if we are in claim challenge and the token was rejected and a new access token need to be issued, we need to
|
|
2824
|
-
// refresh the token with the new tenantId or token.
|
|
2825
|
-
const mustRefresh = tenantId !== tokenOptions.tenantId || Boolean(tokenOptions.claims) || cycler.mustRefresh;
|
|
2826
|
-
if (mustRefresh)
|
|
2827
|
-
return refresh(scopes, tokenOptions);
|
|
2828
|
-
if (cycler.shouldRefresh) {
|
|
2829
|
-
refresh(scopes, tokenOptions);
|
|
2830
|
-
}
|
|
2831
|
-
return token;
|
|
2832
|
-
};
|
|
2833
|
-
}
|
|
2834
|
-
|
|
2835
|
-
// Copyright (c) Microsoft Corporation.
|
|
2836
|
-
// Licensed under the MIT license.
|
|
2837
|
-
/**
|
|
2838
|
-
* The programmatic identifier of the bearerTokenAuthenticationPolicy.
|
|
2839
|
-
*/
|
|
2840
|
-
const bearerTokenAuthenticationPolicyName = "bearerTokenAuthenticationPolicy";
|
|
2841
|
-
/**
|
|
2842
|
-
* Default authorize request handler
|
|
2843
|
-
*/
|
|
2844
|
-
async function defaultAuthorizeRequest(options) {
|
|
2845
|
-
const { scopes, getAccessToken, request } = options;
|
|
2846
|
-
const getTokenOptions = {
|
|
2847
|
-
abortSignal: request.abortSignal,
|
|
2848
|
-
tracingOptions: request.tracingOptions,
|
|
2849
|
-
};
|
|
2850
|
-
const accessToken = await getAccessToken(scopes, getTokenOptions);
|
|
2851
|
-
if (accessToken) {
|
|
2852
|
-
options.request.headers.set("Authorization", `Bearer ${accessToken.token}`);
|
|
2853
|
-
}
|
|
2854
|
-
}
|
|
2855
|
-
/**
|
|
2856
|
-
* We will retrieve the challenge only if the response status code was 401,
|
|
2857
|
-
* and if the response contained the header "WWW-Authenticate" with a non-empty value.
|
|
2858
|
-
*/
|
|
2859
|
-
function getChallenge(response) {
|
|
2860
|
-
const challenge = response.headers.get("WWW-Authenticate");
|
|
2861
|
-
if (response.status === 401 && challenge) {
|
|
2862
|
-
return challenge;
|
|
2863
|
-
}
|
|
2864
|
-
return;
|
|
2865
|
-
}
|
|
2866
|
-
/**
|
|
2867
|
-
* A policy that can request a token from a TokenCredential implementation and
|
|
2868
|
-
* then apply it to the Authorization header of a request as a Bearer token.
|
|
2869
|
-
*/
|
|
2870
|
-
function bearerTokenAuthenticationPolicy(options) {
|
|
2871
|
-
var _a;
|
|
2872
|
-
const { credential, scopes, challengeCallbacks } = options;
|
|
2873
|
-
const logger$1 = options.logger || logger;
|
|
2874
|
-
const callbacks = Object.assign({ authorizeRequest: (_a = challengeCallbacks === null || challengeCallbacks === void 0 ? void 0 : challengeCallbacks.authorizeRequest) !== null && _a !== void 0 ? _a : defaultAuthorizeRequest, authorizeRequestOnChallenge: challengeCallbacks === null || challengeCallbacks === void 0 ? void 0 : challengeCallbacks.authorizeRequestOnChallenge }, challengeCallbacks);
|
|
2875
|
-
// This function encapsulates the entire process of reliably retrieving the token
|
|
2876
|
-
// The options are left out of the public API until there's demand to configure this.
|
|
2877
|
-
// Remember to extend `BearerTokenAuthenticationPolicyOptions` with `TokenCyclerOptions`
|
|
2878
|
-
// in order to pass through the `options` object.
|
|
2879
|
-
const getAccessToken = credential
|
|
2880
|
-
? createTokenCycler(credential /* , options */)
|
|
2881
|
-
: () => Promise.resolve(null);
|
|
2882
|
-
return {
|
|
2883
|
-
name: bearerTokenAuthenticationPolicyName,
|
|
2884
|
-
/**
|
|
2885
|
-
* If there's no challenge parameter:
|
|
2886
|
-
* - It will try to retrieve the token using the cache, or the credential's getToken.
|
|
2887
|
-
* - Then it will try the next policy with or without the retrieved token.
|
|
2888
|
-
*
|
|
2889
|
-
* It uses the challenge parameters to:
|
|
2890
|
-
* - Skip a first attempt to get the token from the credential if there's no cached token,
|
|
2891
|
-
* since it expects the token to be retrievable only after the challenge.
|
|
2892
|
-
* - Prepare the outgoing request if the `prepareRequest` method has been provided.
|
|
2893
|
-
* - Send an initial request to receive the challenge if it fails.
|
|
2894
|
-
* - Process a challenge if the response contains it.
|
|
2895
|
-
* - Retrieve a token with the challenge information, then re-send the request.
|
|
2896
|
-
*/
|
|
2897
|
-
async sendRequest(request, next) {
|
|
2898
|
-
if (!request.url.toLowerCase().startsWith("https://")) {
|
|
2899
|
-
throw new Error("Bearer token authentication is not permitted for non-TLS protected (non-https) URLs.");
|
|
2900
|
-
}
|
|
2901
|
-
await callbacks.authorizeRequest({
|
|
2902
|
-
scopes: Array.isArray(scopes) ? scopes : [scopes],
|
|
2903
|
-
request,
|
|
2904
|
-
getAccessToken,
|
|
2905
|
-
logger: logger$1,
|
|
2906
|
-
});
|
|
2907
|
-
let response;
|
|
2908
|
-
let error;
|
|
2909
|
-
try {
|
|
2910
|
-
response = await next(request);
|
|
2911
|
-
}
|
|
2912
|
-
catch (err) {
|
|
2913
|
-
error = err;
|
|
2914
|
-
response = err.response;
|
|
2915
|
-
}
|
|
2916
|
-
if (callbacks.authorizeRequestOnChallenge &&
|
|
2917
|
-
(response === null || response === void 0 ? void 0 : response.status) === 401 &&
|
|
2918
|
-
getChallenge(response)) {
|
|
2919
|
-
// processes challenge
|
|
2920
|
-
const shouldSendRequest = await callbacks.authorizeRequestOnChallenge({
|
|
2921
|
-
scopes: Array.isArray(scopes) ? scopes : [scopes],
|
|
2922
|
-
request,
|
|
2923
|
-
response,
|
|
2924
|
-
getAccessToken,
|
|
2925
|
-
logger: logger$1,
|
|
2926
|
-
});
|
|
2927
|
-
if (shouldSendRequest) {
|
|
2928
|
-
return next(request);
|
|
2929
|
-
}
|
|
2930
|
-
}
|
|
2931
|
-
if (error) {
|
|
2932
|
-
throw error;
|
|
2933
|
-
}
|
|
2934
|
-
else {
|
|
2935
|
-
return response;
|
|
2936
|
-
}
|
|
2937
|
-
},
|
|
2938
|
-
};
|
|
2939
|
-
}
|
|
2940
|
-
|
|
2941
|
-
// Copyright (c) Microsoft Corporation.
|
|
2942
|
-
// Licensed under the MIT license.
|
|
2943
|
-
/**
|
|
2944
|
-
* Creates an abortable promise.
|
|
2945
|
-
* @param buildPromise - A function that takes the resolve and reject functions as parameters.
|
|
2946
|
-
* @param options - The options for the abortable promise.
|
|
2947
|
-
* @returns A promise that can be aborted.
|
|
2948
|
-
*/
|
|
2949
|
-
function createAbortablePromise(buildPromise, options) {
|
|
2950
|
-
const { cleanupBeforeAbort, abortSignal, abortErrorMsg } = options !== null && options !== void 0 ? options : {};
|
|
2951
|
-
return new Promise((resolve, reject) => {
|
|
2952
|
-
function rejectOnAbort() {
|
|
2953
|
-
reject(new AbortError(abortErrorMsg !== null && abortErrorMsg !== void 0 ? abortErrorMsg : "The operation was aborted."));
|
|
2954
|
-
}
|
|
2955
|
-
function removeListeners() {
|
|
2956
|
-
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener("abort", onAbort);
|
|
2957
|
-
}
|
|
2958
|
-
function onAbort() {
|
|
2959
|
-
cleanupBeforeAbort === null || cleanupBeforeAbort === void 0 ? void 0 : cleanupBeforeAbort();
|
|
2960
|
-
removeListeners();
|
|
2961
|
-
rejectOnAbort();
|
|
2962
|
-
}
|
|
2963
|
-
if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
|
|
2964
|
-
return rejectOnAbort();
|
|
2965
|
-
}
|
|
2966
|
-
try {
|
|
2967
|
-
buildPromise((x) => {
|
|
2968
|
-
removeListeners();
|
|
2969
|
-
resolve(x);
|
|
2970
|
-
}, (x) => {
|
|
2971
|
-
removeListeners();
|
|
2972
|
-
reject(x);
|
|
2973
|
-
});
|
|
2974
|
-
}
|
|
2975
|
-
catch (err) {
|
|
2976
|
-
reject(err);
|
|
2977
|
-
}
|
|
2978
|
-
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener("abort", onAbort);
|
|
2979
|
-
});
|
|
2980
|
-
}
|
|
2981
|
-
|
|
2982
|
-
// Copyright (c) Microsoft Corporation.
|
|
2983
|
-
// Licensed under the MIT license.
|
|
2984
|
-
const StandardAbortMessage = "The delay was aborted.";
|
|
2985
|
-
/**
|
|
2986
|
-
* A wrapper for setTimeout that resolves a promise after timeInMs milliseconds.
|
|
2987
|
-
* @param timeInMs - The number of milliseconds to be delayed.
|
|
2988
|
-
* @param options - The options for delay - currently abort options
|
|
2989
|
-
* @returns Promise that is resolved after timeInMs
|
|
2990
|
-
*/
|
|
2991
|
-
function delay(timeInMs, options) {
|
|
2992
|
-
let token;
|
|
2993
|
-
const { abortSignal, abortErrorMsg } = options !== null && options !== void 0 ? options : {};
|
|
2994
|
-
return createAbortablePromise((resolve) => {
|
|
2995
|
-
token = setTimeout(resolve, timeInMs);
|
|
2996
|
-
}, {
|
|
2997
|
-
cleanupBeforeAbort: () => clearTimeout(token),
|
|
2998
|
-
abortSignal,
|
|
2999
|
-
abortErrorMsg: abortErrorMsg !== null && abortErrorMsg !== void 0 ? abortErrorMsg : StandardAbortMessage,
|
|
3000
|
-
});
|
|
3001
|
-
}
|
|
3002
|
-
|
|
3003
|
-
// Copyright (c) Microsoft Corporation.
|
|
3004
|
-
// Licensed under the MIT license.
|
|
3005
|
-
/**
|
|
3006
|
-
* promise.race() wrapper that aborts rest of promises as soon as the first promise settles.
|
|
3007
|
-
*/
|
|
3008
|
-
async function cancelablePromiseRace(abortablePromiseBuilders, options) {
|
|
3009
|
-
var _a, _b;
|
|
3010
|
-
const aborter = new AbortController();
|
|
3011
|
-
function abortHandler() {
|
|
3012
|
-
aborter.abort();
|
|
3013
|
-
}
|
|
3014
|
-
(_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.addEventListener("abort", abortHandler);
|
|
3015
|
-
try {
|
|
3016
|
-
return await Promise.race(abortablePromiseBuilders.map((p) => p({ abortSignal: aborter.signal })));
|
|
3017
|
-
}
|
|
3018
|
-
finally {
|
|
3019
|
-
aborter.abort();
|
|
3020
|
-
(_b = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _b === void 0 ? void 0 : _b.removeEventListener("abort", abortHandler);
|
|
3021
|
-
}
|
|
3022
|
-
}
|
|
3023
|
-
|
|
3024
|
-
// Copyright (c) Microsoft Corporation.
|
|
3025
|
-
// Licensed under the MIT license.
|
|
3026
|
-
const unimplementedMethods = {
|
|
3027
|
-
arrayBuffer: () => {
|
|
3028
|
-
throw new Error("Not implemented");
|
|
3029
|
-
},
|
|
3030
|
-
slice: () => {
|
|
3031
|
-
throw new Error("Not implemented");
|
|
3032
|
-
},
|
|
3033
|
-
text: () => {
|
|
3034
|
-
throw new Error("Not implemented");
|
|
3035
|
-
},
|
|
3036
|
-
};
|
|
3037
|
-
/**
|
|
3038
|
-
* Create an object that implements the File interface. This object is intended to be
|
|
3039
|
-
* passed into RequestBodyType.formData, and is not guaranteed to work as expected in
|
|
3040
|
-
* other situations.
|
|
3041
|
-
*
|
|
3042
|
-
* Use this function to:
|
|
3043
|
-
* - Create a File object for use in RequestBodyType.formData in environments where the
|
|
3044
|
-
* global File object is unavailable.
|
|
3045
|
-
* - Create a File-like object from a readable stream without reading the stream into memory.
|
|
3046
|
-
*
|
|
3047
|
-
* @param stream - the content of the file as a callback returning a stream. When a File object made using createFile is
|
|
3048
|
-
* passed in a request's form data map, the stream will not be read into memory
|
|
3049
|
-
* and instead will be streamed when the request is made. In the event of a retry, the
|
|
3050
|
-
* stream needs to be read again, so this callback SHOULD return a fresh stream if possible.
|
|
3051
|
-
* @param name - the name of the file.
|
|
3052
|
-
* @param options - optional metadata about the file, e.g. file name, file size, MIME type.
|
|
3053
|
-
*/
|
|
3054
|
-
function createFileFromStream(stream, name, options = {}) {
|
|
3055
|
-
var _a, _b, _c, _d;
|
|
3056
|
-
return Object.assign(Object.assign({}, unimplementedMethods), { type: (_a = options.type) !== null && _a !== void 0 ? _a : "", lastModified: (_b = options.lastModified) !== null && _b !== void 0 ? _b : new Date().getTime(), webkitRelativePath: (_c = options.webkitRelativePath) !== null && _c !== void 0 ? _c : "", size: (_d = options.size) !== null && _d !== void 0 ? _d : -1, name, stream: () => toWebStream(stream()) });
|
|
3057
|
-
}
|
|
3058
|
-
/**
|
|
3059
|
-
* Create an object that implements the File interface. This object is intended to be
|
|
3060
|
-
* passed into RequestBodyType.formData, and is not guaranteed to work as expected in
|
|
3061
|
-
* other situations.
|
|
3062
|
-
*
|
|
3063
|
-
* Use this function create a File object for use in RequestBodyType.formData in environments where the global File object is unavailable.
|
|
3064
|
-
*
|
|
3065
|
-
* @param content - the content of the file as a Uint8Array in memory.
|
|
3066
|
-
* @param name - the name of the file.
|
|
3067
|
-
* @param options - optional metadata about the file, e.g. file name, file size, MIME type.
|
|
3068
|
-
*/
|
|
3069
|
-
function createFile(content, name, options = {}) {
|
|
3070
|
-
var _a, _b, _c;
|
|
3071
|
-
return Object.assign(Object.assign({}, unimplementedMethods), { type: (_a = options.type) !== null && _a !== void 0 ? _a : "", lastModified: (_b = options.lastModified) !== null && _b !== void 0 ? _b : new Date().getTime(), webkitRelativePath: (_c = options.webkitRelativePath) !== null && _c !== void 0 ? _c : "", size: content.byteLength, name, arrayBuffer: async () => content.buffer, stream: () => new Blob([content]).stream() });
|
|
3072
|
-
}
|
|
3073
|
-
|
|
3074
|
-
// Copyright (c) Microsoft Corporation.
|
|
3075
|
-
// Licensed under the MIT license.
|
|
3076
|
-
/**
|
|
3077
|
-
* Generates a SHA-256 HMAC signature.
|
|
3078
|
-
* @param key - The HMAC key represented as a base64 string, used to generate the cryptographic HMAC hash.
|
|
3079
|
-
* @param stringToSign - The data to be signed.
|
|
3080
|
-
* @param encoding - The textual encoding to use for the returned HMAC digest.
|
|
3081
|
-
*/
|
|
3082
|
-
async function computeSha256Hmac(key, stringToSign, encoding) {
|
|
3083
|
-
const decodedKey = Buffer.from(key, "base64");
|
|
3084
|
-
return crypto.createHmac("sha256", decodedKey).update(stringToSign).digest(encoding);
|
|
3085
|
-
}
|
|
3086
|
-
/**
|
|
3087
|
-
* Generates a SHA-256 hash.
|
|
3088
|
-
* @param content - The data to be included in the hash.
|
|
3089
|
-
* @param encoding - The textual encoding to use for the returned hash.
|
|
3090
|
-
*/
|
|
3091
|
-
async function computeSha256Hash(content, encoding) {
|
|
3092
|
-
return crypto.createHash("sha256").update(content).digest(encoding);
|
|
3093
|
-
}
|
|
3094
|
-
|
|
3095
|
-
// Copyright (c) Microsoft Corporation.
|
|
3096
|
-
// Licensed under the MIT license.
|
|
3097
|
-
function createRestError(messageOrResponse, response) {
|
|
3098
|
-
var _a;
|
|
3099
|
-
const resp = typeof messageOrResponse === "string" ? response : messageOrResponse;
|
|
3100
|
-
const internalError = resp.body.error || resp.body;
|
|
3101
|
-
const message = typeof messageOrResponse === "string"
|
|
3102
|
-
? messageOrResponse
|
|
3103
|
-
: (_a = internalError.message) !== null && _a !== void 0 ? _a : `Unexpected status code: ${resp.status}`;
|
|
3104
|
-
return new RestError(message, {
|
|
3105
|
-
statusCode: statusCodeToNumber(resp.status),
|
|
3106
|
-
code: internalError.code,
|
|
3107
|
-
request: resp.request,
|
|
3108
|
-
response: toPipelineResponse(resp),
|
|
3109
|
-
});
|
|
3110
|
-
}
|
|
3111
|
-
function toPipelineResponse(response) {
|
|
3112
|
-
var _a;
|
|
3113
|
-
return {
|
|
3114
|
-
headers: createHttpHeaders(response.headers),
|
|
3115
|
-
request: response.request,
|
|
3116
|
-
status: (_a = statusCodeToNumber(response.status)) !== null && _a !== void 0 ? _a : -1,
|
|
3117
|
-
};
|
|
3118
|
-
}
|
|
3119
|
-
function statusCodeToNumber(statusCode) {
|
|
3120
|
-
const status = Number.parseInt(statusCode);
|
|
3121
|
-
return Number.isNaN(status) ? undefined : status;
|
|
3122
|
-
}
|
|
3123
|
-
|
|
3124
|
-
// Copyright (c) Microsoft Corporation.
|
|
3125
|
-
// Licensed under the MIT license.
|
|
3126
|
-
/**
|
|
3127
|
-
* Tests an object to determine whether it implements TokenCredential.
|
|
3128
|
-
*
|
|
3129
|
-
* @param credential - The assumed TokenCredential to be tested.
|
|
3130
|
-
*/
|
|
3131
|
-
function isTokenCredential(credential) {
|
|
3132
|
-
// Check for an object with a 'getToken' function and possibly with
|
|
3133
|
-
// a 'signRequest' function. We do this check to make sure that
|
|
3134
|
-
// a ServiceClientCredentials implementor (like TokenClientCredentials
|
|
3135
|
-
// in ms-rest-nodeauth) doesn't get mistaken for a TokenCredential if
|
|
3136
|
-
// it doesn't actually implement TokenCredential also.
|
|
3137
|
-
const castCredential = credential;
|
|
3138
|
-
return (castCredential &&
|
|
3139
|
-
typeof castCredential.getToken === "function" &&
|
|
3140
|
-
(castCredential.signRequest === undefined || castCredential.getToken.length > 0));
|
|
3141
|
-
}
|
|
3142
|
-
|
|
3143
|
-
// Copyright (c) Microsoft Corporation.
|
|
3144
|
-
// Licensed under the MIT license.
|
|
3145
|
-
const apiVersionPolicyName = "ApiVersionPolicy";
|
|
3146
|
-
/**
|
|
3147
|
-
* Creates a policy that sets the apiVersion as a query parameter on every request
|
|
3148
|
-
* @param options - Client options
|
|
3149
|
-
* @returns Pipeline policy that sets the apiVersion as a query parameter on every request
|
|
3150
|
-
*/
|
|
3151
|
-
function apiVersionPolicy(options) {
|
|
3152
|
-
return {
|
|
3153
|
-
name: apiVersionPolicyName,
|
|
3154
|
-
sendRequest: (req, next) => {
|
|
3155
|
-
// Use the apiVesion defined in request url directly
|
|
3156
|
-
// Append one if there is no apiVesion and we have one at client options
|
|
3157
|
-
const url = new URL(req.url);
|
|
3158
|
-
if (!url.searchParams.get("api-version") && options.apiVersion) {
|
|
3159
|
-
req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${options.apiVersion}`;
|
|
3160
|
-
}
|
|
3161
|
-
return next(req);
|
|
3162
|
-
},
|
|
3163
|
-
};
|
|
3164
|
-
}
|
|
3165
|
-
|
|
3166
|
-
// Copyright (c) Microsoft Corporation.
|
|
3167
|
-
// Licensed under the MIT license.
|
|
3168
|
-
/**
|
|
3169
|
-
* The programmatic identifier of the bearerTokenAuthenticationPolicy.
|
|
3170
|
-
*/
|
|
3171
|
-
const keyCredentialAuthenticationPolicyName = "keyCredentialAuthenticationPolicy";
|
|
3172
|
-
function keyCredentialAuthenticationPolicy(credential, apiKeyHeaderName) {
|
|
3173
|
-
return {
|
|
3174
|
-
name: keyCredentialAuthenticationPolicyName,
|
|
3175
|
-
async sendRequest(request, next) {
|
|
3176
|
-
request.headers.set(apiKeyHeaderName, credential.key);
|
|
3177
|
-
return next(request);
|
|
3178
|
-
},
|
|
3179
|
-
};
|
|
3180
|
-
}
|
|
3181
|
-
|
|
3182
|
-
// Copyright (c) Microsoft Corporation.
|
|
3183
|
-
// Licensed under the MIT license.
|
|
3184
|
-
let cachedHttpClient;
|
|
3185
|
-
/**
|
|
3186
|
-
* Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
|
|
3187
|
-
*/
|
|
3188
|
-
function addCredentialPipelinePolicy(pipeline, baseUrl, options = {}) {
|
|
3189
|
-
var _a, _b, _c, _d;
|
|
3190
|
-
const { credential, clientOptions } = options;
|
|
3191
|
-
if (!credential) {
|
|
3192
|
-
return;
|
|
3193
|
-
}
|
|
3194
|
-
if (isTokenCredential(credential)) {
|
|
3195
|
-
const tokenPolicy = bearerTokenAuthenticationPolicy({
|
|
3196
|
-
credential,
|
|
3197
|
-
scopes: (_b = (_a = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.credentials) === null || _a === void 0 ? void 0 : _a.scopes) !== null && _b !== void 0 ? _b : `${baseUrl}/.default`,
|
|
3198
|
-
});
|
|
3199
|
-
pipeline.addPolicy(tokenPolicy);
|
|
3200
|
-
}
|
|
3201
|
-
else if (isKeyCredential(credential)) {
|
|
3202
|
-
if (!((_c = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.credentials) === null || _c === void 0 ? void 0 : _c.apiKeyHeaderName)) {
|
|
3203
|
-
throw new Error(`Missing API Key Header Name`);
|
|
3204
|
-
}
|
|
3205
|
-
const keyPolicy = keyCredentialAuthenticationPolicy(credential, (_d = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.credentials) === null || _d === void 0 ? void 0 : _d.apiKeyHeaderName);
|
|
3206
|
-
pipeline.addPolicy(keyPolicy);
|
|
3207
|
-
}
|
|
3208
|
-
}
|
|
3209
|
-
/**
|
|
3210
|
-
* Creates a default rest pipeline to re-use accross Rest Level Clients
|
|
3211
|
-
*/
|
|
3212
|
-
function createDefaultPipeline(baseUrl, credential, options = {}) {
|
|
3213
|
-
const pipeline = createPipelineFromOptions(options);
|
|
3214
|
-
pipeline.addPolicy(apiVersionPolicy(options));
|
|
3215
|
-
addCredentialPipelinePolicy(pipeline, baseUrl, { credential, clientOptions: options });
|
|
3216
|
-
return pipeline;
|
|
3217
|
-
}
|
|
3218
|
-
function isKeyCredential(credential) {
|
|
3219
|
-
return credential.key !== undefined;
|
|
3220
|
-
}
|
|
3221
|
-
function getCachedDefaultHttpsClient() {
|
|
3222
|
-
if (!cachedHttpClient) {
|
|
3223
|
-
cachedHttpClient = createDefaultHttpClient();
|
|
3224
|
-
}
|
|
3225
|
-
return cachedHttpClient;
|
|
3226
|
-
}
|
|
3227
|
-
|
|
3228
|
-
// Copyright (c) Microsoft Corporation.
|
|
3229
|
-
// Licensed under the MIT license.
|
|
3230
|
-
/**
|
|
3231
|
-
* Helper function to convert OperationOptions to RequestParameters
|
|
3232
|
-
* @param options - the options that are used by Modular layer to send the request
|
|
3233
|
-
* @returns the result of the conversion in RequestParameters of RLC layer
|
|
3234
|
-
*/
|
|
3235
|
-
function operationOptionsToRequestParameters(options) {
|
|
3236
|
-
var _a, _b, _c, _d, _e, _f;
|
|
3237
|
-
return {
|
|
3238
|
-
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
|
3239
|
-
timeout: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.timeout,
|
|
3240
|
-
skipUrlEncoding: (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.skipUrlEncoding,
|
|
3241
|
-
abortSignal: options.abortSignal,
|
|
3242
|
-
onUploadProgress: (_d = options.requestOptions) === null || _d === void 0 ? void 0 : _d.onUploadProgress,
|
|
3243
|
-
onDownloadProgress: (_e = options.requestOptions) === null || _e === void 0 ? void 0 : _e.onDownloadProgress,
|
|
3244
|
-
tracingOptions: options.tracingOptions,
|
|
3245
|
-
headers: Object.assign({}, (_f = options.requestOptions) === null || _f === void 0 ? void 0 : _f.headers),
|
|
3246
|
-
onResponse: options.onResponse,
|
|
3247
|
-
};
|
|
3248
|
-
}
|
|
3249
|
-
|
|
3250
|
-
// Copyright (c) Microsoft Corporation.
|
|
3251
|
-
// Licensed under the MIT license.
|
|
3252
|
-
/**
|
|
3253
|
-
* Converts binary content to its string representation
|
|
3254
|
-
*/
|
|
3255
|
-
function binaryArrayToString(content) {
|
|
3256
|
-
let decodedBody = "";
|
|
3257
|
-
for (const element of content) {
|
|
3258
|
-
decodedBody += String.fromCharCode(element);
|
|
3259
|
-
}
|
|
3260
|
-
return decodedBody;
|
|
3261
|
-
}
|
|
3262
|
-
|
|
3263
|
-
// Copyright (c) Microsoft Corporation.
|
|
3264
|
-
// Licensed under the MIT license.
|
|
3265
|
-
/**
|
|
3266
|
-
* Helper function to send request used by the client
|
|
3267
|
-
* @param method - method to use to send the request
|
|
3268
|
-
* @param url - url to send the request to
|
|
3269
|
-
* @param pipeline - pipeline with the policies to run when sending the request
|
|
3270
|
-
* @param options - request options
|
|
3271
|
-
* @param customHttpClient - a custom HttpClient to use when making the request
|
|
3272
|
-
* @returns returns and HttpResponse
|
|
3273
|
-
*/
|
|
3274
|
-
async function sendRequest(method, url, pipeline, options = {}, customHttpClient) {
|
|
3275
|
-
const httpClient = customHttpClient !== null && customHttpClient !== void 0 ? customHttpClient : getCachedDefaultHttpsClient();
|
|
3276
|
-
const request = buildPipelineRequest(method, url, options);
|
|
3277
|
-
const response = await pipeline.sendRequest(httpClient, request);
|
|
3278
|
-
const rawHeaders = response.headers.toJSON();
|
|
3279
|
-
const parsedBody = getResponseBody(response);
|
|
3280
|
-
if (options === null || options === void 0 ? void 0 : options.onResponse) {
|
|
3281
|
-
options.onResponse(Object.assign(Object.assign({}, response), { request, rawHeaders, parsedBody }));
|
|
3282
|
-
}
|
|
3283
|
-
return {
|
|
3284
|
-
request,
|
|
3285
|
-
headers: rawHeaders,
|
|
3286
|
-
status: `${response.status}`,
|
|
3287
|
-
body: parsedBody,
|
|
3288
|
-
};
|
|
3289
|
-
}
|
|
3290
|
-
/**
|
|
3291
|
-
* Helper function to send request used by the client
|
|
3292
|
-
* @param method - method to use to send the request
|
|
3293
|
-
* @param url - url to send the request to
|
|
3294
|
-
* @param pipeline - pipeline with the policies to run when sending the request
|
|
3295
|
-
* @param options - request options
|
|
3296
|
-
* @param customHttpClient - a custom HttpClient to use when making the request
|
|
3297
|
-
* @returns returns and HttpResponse
|
|
3298
|
-
*/
|
|
3299
|
-
async function sendRequestAsStream(method, url, pipeline, options = {}, customHttpClient) {
|
|
3300
|
-
var _a;
|
|
3301
|
-
const httpClient = customHttpClient !== null && customHttpClient !== void 0 ? customHttpClient : getCachedDefaultHttpsClient();
|
|
3302
|
-
const request = buildPipelineRequest(method, url, Object.assign(Object.assign({}, options), { responseAsStream: true }));
|
|
3303
|
-
const response = await pipeline.sendRequest(httpClient, request);
|
|
3304
|
-
const rawHeaders = response.headers.toJSON();
|
|
3305
|
-
const parsedBody = (_a = response.browserStreamBody) !== null && _a !== void 0 ? _a : response.readableStreamBody;
|
|
3306
|
-
return {
|
|
3307
|
-
request,
|
|
3308
|
-
headers: rawHeaders,
|
|
3309
|
-
status: `${response.status}`,
|
|
3310
|
-
body: parsedBody,
|
|
3311
|
-
};
|
|
3312
|
-
}
|
|
3313
|
-
/**
|
|
3314
|
-
* Function to determine the content-type of a body
|
|
3315
|
-
* this is used if an explicit content-type is not provided
|
|
3316
|
-
* @param body - body in the request
|
|
3317
|
-
* @returns returns the content-type
|
|
3318
|
-
*/
|
|
3319
|
-
function getContentType(body) {
|
|
3320
|
-
if (ArrayBuffer.isView(body)) {
|
|
3321
|
-
return "application/octet-stream";
|
|
3322
|
-
}
|
|
3323
|
-
// By default return json
|
|
3324
|
-
return "application/json; charset=UTF-8";
|
|
3325
|
-
}
|
|
3326
|
-
function buildPipelineRequest(method, url, options = {}) {
|
|
3327
|
-
var _a, _b;
|
|
3328
|
-
const { body, formData } = getRequestBody(options.body, options.contentType);
|
|
3329
|
-
const hasContent = body !== undefined || formData !== undefined;
|
|
3330
|
-
const headers = createHttpHeaders(Object.assign(Object.assign(Object.assign({}, (options.headers ? options.headers : {})), { accept: (_a = options.accept) !== null && _a !== void 0 ? _a : "application/json" }), (hasContent && {
|
|
3331
|
-
"content-type": (_b = options.contentType) !== null && _b !== void 0 ? _b : getContentType(options.body),
|
|
3332
|
-
})));
|
|
3333
|
-
return createPipelineRequest({
|
|
3334
|
-
url,
|
|
3335
|
-
method,
|
|
3336
|
-
body,
|
|
3337
|
-
formData,
|
|
3338
|
-
headers,
|
|
3339
|
-
allowInsecureConnection: options.allowInsecureConnection,
|
|
3340
|
-
tracingOptions: options.tracingOptions,
|
|
3341
|
-
abortSignal: options.abortSignal,
|
|
3342
|
-
onUploadProgress: options.onUploadProgress,
|
|
3343
|
-
onDownloadProgress: options.onDownloadProgress,
|
|
3344
|
-
timeout: options.timeout,
|
|
3345
|
-
enableBrowserStreams: true,
|
|
3346
|
-
streamResponseStatusCodes: options.responseAsStream
|
|
3347
|
-
? new Set([Number.POSITIVE_INFINITY])
|
|
3348
|
-
: undefined,
|
|
3349
|
-
});
|
|
3350
|
-
}
|
|
3351
|
-
/**
|
|
3352
|
-
* Prepares the body before sending the request
|
|
3353
|
-
*/
|
|
3354
|
-
function getRequestBody(body, contentType = "") {
|
|
3355
|
-
if (body === undefined) {
|
|
3356
|
-
return { body: undefined };
|
|
3357
|
-
}
|
|
3358
|
-
if (isReadableStream$1(body)) {
|
|
3359
|
-
return { body };
|
|
3360
|
-
}
|
|
3361
|
-
if (!contentType && typeof body === "string") {
|
|
3362
|
-
return { body };
|
|
3363
|
-
}
|
|
3364
|
-
const firstType = contentType.split(";")[0];
|
|
3365
|
-
if (firstType === "application/json") {
|
|
3366
|
-
return { body: JSON.stringify(body) };
|
|
3367
|
-
}
|
|
3368
|
-
if (ArrayBuffer.isView(body)) {
|
|
3369
|
-
if (body instanceof Uint8Array) {
|
|
3370
|
-
return { body: binaryArrayToString(body) };
|
|
3371
|
-
}
|
|
3372
|
-
else {
|
|
3373
|
-
return { body: JSON.stringify(body) };
|
|
3374
|
-
}
|
|
3375
|
-
}
|
|
3376
|
-
switch (firstType) {
|
|
3377
|
-
case "multipart/form-data":
|
|
3378
|
-
return isFormData(body)
|
|
3379
|
-
? { formData: processFormData(body) }
|
|
3380
|
-
: { body: JSON.stringify(body) };
|
|
3381
|
-
case "text/plain":
|
|
3382
|
-
return { body: String(body) };
|
|
3383
|
-
default:
|
|
3384
|
-
if (typeof body === "string") {
|
|
3385
|
-
return { body };
|
|
3386
|
-
}
|
|
3387
|
-
return { body: JSON.stringify(body) };
|
|
3388
|
-
}
|
|
3389
|
-
}
|
|
3390
|
-
function isFormData(body) {
|
|
3391
|
-
return body instanceof Object && Object.keys(body).length > 0;
|
|
3392
|
-
}
|
|
3393
|
-
/**
|
|
3394
|
-
* Checks if binary data is in Uint8Array format, if so decode it to a binary string
|
|
3395
|
-
* to send over the wire
|
|
3396
|
-
*/
|
|
3397
|
-
function processFormData(formData) {
|
|
3398
|
-
if (!formData) {
|
|
3399
|
-
return formData;
|
|
3400
|
-
}
|
|
3401
|
-
const processedFormData = {};
|
|
3402
|
-
for (const element in formData) {
|
|
3403
|
-
const item = formData[element];
|
|
3404
|
-
if (item instanceof Uint8Array) {
|
|
3405
|
-
processedFormData[element] = binaryArrayToString(item);
|
|
3406
|
-
}
|
|
3407
|
-
else {
|
|
3408
|
-
processedFormData[element] = item;
|
|
3409
|
-
}
|
|
3410
|
-
}
|
|
3411
|
-
return processedFormData;
|
|
3412
|
-
}
|
|
3413
|
-
/**
|
|
3414
|
-
* Prepares the response body
|
|
3415
|
-
*/
|
|
3416
|
-
function getResponseBody(response) {
|
|
3417
|
-
var _a, _b;
|
|
3418
|
-
// Set the default response type
|
|
3419
|
-
const contentType = (_a = response.headers.get("content-type")) !== null && _a !== void 0 ? _a : "";
|
|
3420
|
-
const firstType = contentType.split(";")[0];
|
|
3421
|
-
const bodyToParse = (_b = response.bodyAsText) !== null && _b !== void 0 ? _b : "";
|
|
3422
|
-
if (firstType === "text/plain") {
|
|
3423
|
-
return String(bodyToParse);
|
|
3424
|
-
}
|
|
3425
|
-
// Default to "application/json" and fallback to string;
|
|
3426
|
-
try {
|
|
3427
|
-
return bodyToParse ? JSON.parse(bodyToParse) : undefined;
|
|
3428
|
-
}
|
|
3429
|
-
catch (error) {
|
|
3430
|
-
// If we were supposed to get a JSON object and failed to
|
|
3431
|
-
// parse, throw a parse error
|
|
3432
|
-
if (firstType === "application/json") {
|
|
3433
|
-
throw createParseError(response, error);
|
|
3434
|
-
}
|
|
3435
|
-
// We are not sure how to handle the response so we return it as
|
|
3436
|
-
// plain text.
|
|
3437
|
-
return String(bodyToParse);
|
|
3438
|
-
}
|
|
3439
|
-
}
|
|
3440
|
-
function createParseError(response, err) {
|
|
3441
|
-
var _a;
|
|
3442
|
-
const msg = `Error "${err}" occurred while parsing the response body - ${response.bodyAsText}.`;
|
|
3443
|
-
const errCode = (_a = err.code) !== null && _a !== void 0 ? _a : RestError.PARSE_ERROR;
|
|
3444
|
-
return new RestError(msg, {
|
|
3445
|
-
code: errCode,
|
|
3446
|
-
statusCode: response.status,
|
|
3447
|
-
request: response.request,
|
|
3448
|
-
response: response,
|
|
3449
|
-
});
|
|
3450
|
-
}
|
|
3451
|
-
|
|
3452
|
-
// Copyright (c) Microsoft Corporation.
|
|
3453
|
-
// Licensed under the MIT license.
|
|
3454
|
-
/**
|
|
3455
|
-
* Builds the request url, filling in query and path parameters
|
|
3456
|
-
* @param baseUrl - base url which can be a template url
|
|
3457
|
-
* @param routePath - path to append to the baseUrl
|
|
3458
|
-
* @param pathParameters - values of the path parameters
|
|
3459
|
-
* @param options - request parameters including query parameters
|
|
3460
|
-
* @returns a full url with path and query parameters
|
|
3461
|
-
*/
|
|
3462
|
-
function buildRequestUrl(baseUrl, routePath, pathParameters, options = {}) {
|
|
3463
|
-
if (routePath.startsWith("https://") || routePath.startsWith("http://")) {
|
|
3464
|
-
return routePath;
|
|
3465
|
-
}
|
|
3466
|
-
baseUrl = buildBaseUrl(baseUrl, options);
|
|
3467
|
-
routePath = buildRoutePath(routePath, pathParameters, options);
|
|
3468
|
-
const requestUrl = appendQueryParams(`${baseUrl}/${routePath}`, options);
|
|
3469
|
-
const url = new URL(requestUrl);
|
|
3470
|
-
return (url
|
|
3471
|
-
.toString()
|
|
3472
|
-
// Remove double forward slashes
|
|
3473
|
-
.replace(/([^:]\/)\/+/g, "$1"));
|
|
3474
|
-
}
|
|
3475
|
-
function appendQueryParams(url, options = {}) {
|
|
3476
|
-
if (!options.queryParameters) {
|
|
3477
|
-
return url;
|
|
3478
|
-
}
|
|
3479
|
-
let parsedUrl = new URL(url);
|
|
3480
|
-
const queryParams = options.queryParameters;
|
|
3481
|
-
for (const key of Object.keys(queryParams)) {
|
|
3482
|
-
const param = queryParams[key];
|
|
3483
|
-
if (param === undefined || param === null) {
|
|
3484
|
-
continue;
|
|
3485
|
-
}
|
|
3486
|
-
if (!param.toString || typeof param.toString !== "function") {
|
|
3487
|
-
throw new Error(`Query parameters must be able to be represented as string, ${key} can't`);
|
|
3488
|
-
}
|
|
3489
|
-
const value = param.toISOString !== undefined ? param.toISOString() : param.toString();
|
|
3490
|
-
parsedUrl.searchParams.append(key, value);
|
|
3491
|
-
}
|
|
3492
|
-
if (options.skipUrlEncoding) {
|
|
3493
|
-
parsedUrl = skipQueryParameterEncoding(parsedUrl);
|
|
3494
|
-
}
|
|
3495
|
-
return parsedUrl.toString();
|
|
3496
|
-
}
|
|
3497
|
-
function skipQueryParameterEncoding(url) {
|
|
3498
|
-
if (!url) {
|
|
3499
|
-
return url;
|
|
3500
|
-
}
|
|
3501
|
-
const searchPieces = [];
|
|
3502
|
-
for (const [name, value] of url.searchParams) {
|
|
3503
|
-
// QUIRK: searchParams.get retrieves the values decoded
|
|
3504
|
-
searchPieces.push(`${name}=${value}`);
|
|
3505
|
-
}
|
|
3506
|
-
// QUIRK: we have to set search manually as searchParams will encode comma when it shouldn't.
|
|
3507
|
-
url.search = searchPieces.length ? `?${searchPieces.join("&")}` : "";
|
|
3508
|
-
return url;
|
|
3509
|
-
}
|
|
3510
|
-
function buildBaseUrl(baseUrl, options) {
|
|
3511
|
-
var _a;
|
|
3512
|
-
if (!options.pathParameters) {
|
|
3513
|
-
return baseUrl;
|
|
3514
|
-
}
|
|
3515
|
-
const pathParams = options.pathParameters;
|
|
3516
|
-
for (const [key, param] of Object.entries(pathParams)) {
|
|
3517
|
-
if (param === undefined || param === null) {
|
|
3518
|
-
throw new Error(`Path parameters ${key} must not be undefined or null`);
|
|
3519
|
-
}
|
|
3520
|
-
if (!param.toString || typeof param.toString !== "function") {
|
|
3521
|
-
throw new Error(`Path parameters must be able to be represented as string, ${key} can't`);
|
|
3522
|
-
}
|
|
3523
|
-
let value = param.toISOString !== undefined ? param.toISOString() : String(param);
|
|
3524
|
-
if (!options.skipUrlEncoding) {
|
|
3525
|
-
value = encodeURIComponent(param);
|
|
3526
|
-
}
|
|
3527
|
-
baseUrl = (_a = replaceAll(baseUrl, `{${key}}`, value)) !== null && _a !== void 0 ? _a : "";
|
|
3528
|
-
}
|
|
3529
|
-
return baseUrl;
|
|
3530
|
-
}
|
|
3531
|
-
function buildRoutePath(routePath, pathParameters, options = {}) {
|
|
3532
|
-
for (const pathParam of pathParameters) {
|
|
3533
|
-
let value = pathParam;
|
|
3534
|
-
if (!options.skipUrlEncoding) {
|
|
3535
|
-
value = encodeURIComponent(pathParam);
|
|
3536
|
-
}
|
|
3537
|
-
routePath = routePath.replace(/\{\w+\}/, value);
|
|
3538
|
-
}
|
|
3539
|
-
return routePath;
|
|
3540
|
-
}
|
|
3541
|
-
/**
|
|
3542
|
-
* Replace all of the instances of searchValue in value with the provided replaceValue.
|
|
3543
|
-
* @param value - The value to search and replace in.
|
|
3544
|
-
* @param searchValue - The value to search for in the value argument.
|
|
3545
|
-
* @param replaceValue - The value to replace searchValue with in the value argument.
|
|
3546
|
-
* @returns The value where each instance of searchValue was replaced with replacedValue.
|
|
3547
|
-
*/
|
|
3548
|
-
function replaceAll(value, searchValue, replaceValue) {
|
|
3549
|
-
return !value || !searchValue ? value : value.split(searchValue).join(replaceValue || "");
|
|
3550
|
-
}
|
|
3551
|
-
|
|
3552
|
-
// Copyright (c) Microsoft Corporation.
|
|
3553
|
-
// Licensed under the MIT license.
|
|
3554
|
-
function getClient(baseUrl, credentialsOrPipelineOptions, clientOptions = {}) {
|
|
3555
|
-
var _a;
|
|
3556
|
-
let credentials;
|
|
3557
|
-
if (credentialsOrPipelineOptions) {
|
|
3558
|
-
if (isCredential(credentialsOrPipelineOptions)) {
|
|
3559
|
-
credentials = credentialsOrPipelineOptions;
|
|
3560
|
-
}
|
|
3561
|
-
else {
|
|
3562
|
-
clientOptions = credentialsOrPipelineOptions !== null && credentialsOrPipelineOptions !== void 0 ? credentialsOrPipelineOptions : {};
|
|
3563
|
-
}
|
|
3564
|
-
}
|
|
3565
|
-
const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions);
|
|
3566
|
-
if ((_a = clientOptions.additionalPolicies) === null || _a === void 0 ? void 0 : _a.length) {
|
|
3567
|
-
for (const { policy, position } of clientOptions.additionalPolicies) {
|
|
3568
|
-
// Sign happens after Retry and is commonly needed to occur
|
|
3569
|
-
// before policies that intercept post-retry.
|
|
3570
|
-
const afterPhase = position === "perRetry" ? "Sign" : undefined;
|
|
3571
|
-
pipeline.addPolicy(policy, {
|
|
3572
|
-
afterPhase,
|
|
3573
|
-
});
|
|
3574
|
-
}
|
|
3575
|
-
}
|
|
3576
|
-
const { allowInsecureConnection, httpClient } = clientOptions;
|
|
3577
|
-
const client = (path, ...args) => {
|
|
3578
|
-
const getUrl = (requestOptions) => buildRequestUrl(baseUrl, path, args, Object.assign({ allowInsecureConnection }, requestOptions));
|
|
3579
|
-
return {
|
|
3580
|
-
get: (requestOptions = {}) => {
|
|
3581
|
-
return buildOperation("GET", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
|
|
3582
|
-
},
|
|
3583
|
-
post: (requestOptions = {}) => {
|
|
3584
|
-
return buildOperation("POST", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
|
|
3585
|
-
},
|
|
3586
|
-
put: (requestOptions = {}) => {
|
|
3587
|
-
return buildOperation("PUT", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
|
|
3588
|
-
},
|
|
3589
|
-
patch: (requestOptions = {}) => {
|
|
3590
|
-
return buildOperation("PATCH", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
|
|
3591
|
-
},
|
|
3592
|
-
delete: (requestOptions = {}) => {
|
|
3593
|
-
return buildOperation("DELETE", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
|
|
3594
|
-
},
|
|
3595
|
-
head: (requestOptions = {}) => {
|
|
3596
|
-
return buildOperation("HEAD", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
|
|
3597
|
-
},
|
|
3598
|
-
options: (requestOptions = {}) => {
|
|
3599
|
-
return buildOperation("OPTIONS", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
|
|
3600
|
-
},
|
|
3601
|
-
trace: (requestOptions = {}) => {
|
|
3602
|
-
return buildOperation("TRACE", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
|
|
3603
|
-
},
|
|
3604
|
-
};
|
|
3605
|
-
};
|
|
3606
|
-
return {
|
|
3607
|
-
path: client,
|
|
3608
|
-
pathUnchecked: client,
|
|
3609
|
-
pipeline,
|
|
3610
|
-
};
|
|
3611
|
-
}
|
|
3612
|
-
function buildOperation(method, url, pipeline, options, allowInsecureConnection, httpClient) {
|
|
3613
|
-
var _a;
|
|
3614
|
-
allowInsecureConnection = (_a = options.allowInsecureConnection) !== null && _a !== void 0 ? _a : allowInsecureConnection;
|
|
3615
|
-
return {
|
|
3616
|
-
then: function (onFulfilled, onrejected) {
|
|
3617
|
-
return sendRequest(method, url, pipeline, Object.assign(Object.assign({}, options), { allowInsecureConnection }), httpClient).then(onFulfilled, onrejected);
|
|
3618
|
-
},
|
|
3619
|
-
async asBrowserStream() {
|
|
3620
|
-
return sendRequestAsStream(method, url, pipeline, Object.assign(Object.assign({}, options), { allowInsecureConnection }), httpClient);
|
|
3621
|
-
},
|
|
3622
|
-
async asNodeStream() {
|
|
3623
|
-
return sendRequestAsStream(method, url, pipeline, Object.assign(Object.assign({}, options), { allowInsecureConnection }), httpClient);
|
|
3624
|
-
},
|
|
3625
|
-
};
|
|
3626
|
-
}
|
|
3627
|
-
function isCredential(param) {
|
|
3628
|
-
if (param.key !== undefined || isTokenCredential(param)) {
|
|
3629
|
-
return true;
|
|
3630
|
-
}
|
|
3631
|
-
return false;
|
|
3632
|
-
}
|
|
3633
|
-
|
|
3634
|
-
exports.AbortError = AbortError;
|
|
3635
|
-
exports.RestError = RestError;
|
|
3636
|
-
exports.TypeSpecRuntimeLogger = TypeSpecRuntimeLogger;
|
|
3637
|
-
exports.addCredentialPipelinePolicy = addCredentialPipelinePolicy;
|
|
3638
|
-
exports.bearerTokenAuthenticationPolicy = bearerTokenAuthenticationPolicy;
|
|
3639
|
-
exports.bearerTokenAuthenticationPolicyName = bearerTokenAuthenticationPolicyName;
|
|
3640
|
-
exports.cancelablePromiseRace = cancelablePromiseRace;
|
|
3641
|
-
exports.computeSha256Hash = computeSha256Hash;
|
|
3642
|
-
exports.computeSha256Hmac = computeSha256Hmac;
|
|
3643
|
-
exports.createAbortablePromise = createAbortablePromise;
|
|
3644
|
-
exports.createDefaultHttpClient = createDefaultHttpClient;
|
|
3645
|
-
exports.createEmptyPipeline = createEmptyPipeline;
|
|
3646
|
-
exports.createFile = createFile;
|
|
3647
|
-
exports.createFileFromStream = createFileFromStream;
|
|
3648
|
-
exports.createHttpHeaders = createHttpHeaders;
|
|
3649
|
-
exports.createPipelineFromOptions = createPipelineFromOptions;
|
|
3650
|
-
exports.createPipelineRequest = createPipelineRequest;
|
|
3651
|
-
exports.createRestError = createRestError;
|
|
3652
|
-
exports.createTracingClient = createTracingClient;
|
|
3653
|
-
exports.decompressResponsePolicy = decompressResponsePolicy;
|
|
3654
|
-
exports.decompressResponsePolicyName = decompressResponsePolicyName;
|
|
3655
|
-
exports.defaultRetryPolicy = defaultRetryPolicy;
|
|
3656
|
-
exports.delay = delay;
|
|
3657
|
-
exports.formDataPolicy = formDataPolicy;
|
|
3658
|
-
exports.formDataPolicyName = formDataPolicyName;
|
|
3659
|
-
exports.getClient = getClient;
|
|
3660
|
-
exports.getDefaultProxySettings = getDefaultProxySettings;
|
|
3661
|
-
exports.getErrorMessage = getErrorMessage;
|
|
3662
|
-
exports.getRandomIntegerInclusive = getRandomIntegerInclusive;
|
|
3663
|
-
exports.isBrowser = isBrowser;
|
|
3664
|
-
exports.isBun = isBun;
|
|
3665
|
-
exports.isDefined = isDefined;
|
|
3666
|
-
exports.isDeno = isDeno;
|
|
3667
|
-
exports.isError = isError;
|
|
3668
|
-
exports.isNode = isNode;
|
|
3669
|
-
exports.isObject = isObject;
|
|
3670
|
-
exports.isObjectWithProperties = isObjectWithProperties;
|
|
3671
|
-
exports.isReactNative = isReactNative;
|
|
3672
|
-
exports.isRestError = isRestError;
|
|
3673
|
-
exports.isWebWorker = isWebWorker;
|
|
3674
|
-
exports.logPolicy = logPolicy;
|
|
3675
|
-
exports.logPolicyName = logPolicyName;
|
|
3676
|
-
exports.multipartPolicy = multipartPolicy;
|
|
3677
|
-
exports.multipartPolicyName = multipartPolicyName;
|
|
3678
|
-
exports.objectHasProperty = objectHasProperty;
|
|
3679
|
-
exports.operationOptionsToRequestParameters = operationOptionsToRequestParameters;
|
|
3680
|
-
exports.proxyPolicy = proxyPolicy;
|
|
3681
|
-
exports.proxyPolicyName = proxyPolicyName;
|
|
3682
|
-
exports.randomUUID = randomUUID;
|
|
3683
|
-
exports.redirectPolicy = redirectPolicy;
|
|
3684
|
-
exports.redirectPolicyName = redirectPolicyName;
|
|
3685
|
-
exports.stringToUint8Array = stringToUint8Array;
|
|
3686
|
-
exports.tlsPolicy = tlsPolicy;
|
|
3687
|
-
exports.tlsPolicyName = tlsPolicyName;
|
|
3688
|
-
exports.tracingPolicy = tracingPolicy;
|
|
3689
|
-
exports.tracingPolicyName = tracingPolicyName;
|
|
3690
|
-
exports.uint8ArrayToString = uint8ArrayToString;
|
|
3691
|
-
exports.useInstrumenter = useInstrumenter;
|
|
3692
|
-
exports.userAgentPolicy = userAgentPolicy;
|
|
3693
|
-
exports.userAgentPolicyName = userAgentPolicyName;
|
|
3694
|
-
//# sourceMappingURL=index.js.map
|