@typespec/ts-http-runtime 0.3.1-alpha.20250711.2 → 0.3.1-alpha.20250722.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/client/getClient.js +8 -10
- package/dist/browser/client/getClient.js.map +1 -1
- package/dist/browser/client/multipart.js +2 -4
- package/dist/browser/client/multipart.js.map +1 -1
- package/dist/browser/client/operationOptionHelpers.js +6 -7
- package/dist/browser/client/operationOptionHelpers.js.map +1 -1
- package/dist/browser/client/restError.js +4 -6
- package/dist/browser/client/restError.js.map +1 -1
- package/dist/browser/client/sendRequest.js +20 -19
- package/dist/browser/client/sendRequest.js.map +1 -1
- package/dist/browser/client/urlHelpers.js +6 -9
- package/dist/browser/client/urlHelpers.js.map +1 -1
- package/dist/browser/fetchHttpClient.js +30 -21
- package/dist/browser/fetchHttpClient.js.map +1 -1
- package/dist/browser/httpHeaders.js +2 -2
- package/dist/browser/httpHeaders.js.map +1 -1
- package/dist/browser/nodeHttpClient.js +30 -24
- package/dist/browser/nodeHttpClient.js.map +1 -1
- package/dist/browser/pipeline.js +3 -3
- package/dist/browser/pipeline.js.map +1 -1
- package/dist/browser/pipelineRequest.js +26 -8
- package/dist/browser/pipelineRequest.js.map +1 -1
- package/dist/browser/policies/auth/apiKeyAuthenticationPolicy.js +1 -2
- package/dist/browser/policies/auth/apiKeyAuthenticationPolicy.js.map +1 -1
- package/dist/browser/policies/auth/basicAuthenticationPolicy.js +1 -2
- package/dist/browser/policies/auth/basicAuthenticationPolicy.js.map +1 -1
- package/dist/browser/policies/auth/bearerAuthenticationPolicy.js +1 -2
- package/dist/browser/policies/auth/bearerAuthenticationPolicy.js.map +1 -1
- package/dist/browser/policies/auth/checkInsecureConnection.js +1 -1
- package/dist/browser/policies/auth/checkInsecureConnection.js.map +1 -1
- package/dist/browser/policies/auth/oauth2AuthenticationPolicy.js +1 -2
- package/dist/browser/policies/auth/oauth2AuthenticationPolicy.js.map +1 -1
- package/dist/browser/policies/defaultRetryPolicy.js +1 -2
- package/dist/browser/policies/defaultRetryPolicy.js.map +1 -1
- package/dist/browser/policies/exponentialRetryPolicy.js +5 -3
- package/dist/browser/policies/exponentialRetryPolicy.js.map +1 -1
- package/dist/browser/policies/formDataPolicy.js +2 -3
- package/dist/browser/policies/formDataPolicy.js.map +1 -1
- package/dist/browser/policies/logPolicy.js +1 -2
- package/dist/browser/policies/logPolicy.js.map +1 -1
- package/dist/browser/policies/multipartPolicy.js +2 -3
- package/dist/browser/policies/multipartPolicy.js.map +1 -1
- package/dist/browser/policies/retryPolicy.js +2 -3
- package/dist/browser/policies/retryPolicy.js.map +1 -1
- package/dist/browser/policies/systemErrorRetryPolicy.js +5 -3
- package/dist/browser/policies/systemErrorRetryPolicy.js.map +1 -1
- package/dist/browser/policies/throttlingRetryPolicy.js +1 -2
- package/dist/browser/policies/throttlingRetryPolicy.js.map +1 -1
- package/dist/browser/restError.js +38 -12
- package/dist/browser/restError.js.map +1 -1
- package/dist/browser/retryStrategies/exponentialRetryStrategy.js +2 -3
- package/dist/browser/retryStrategies/exponentialRetryStrategy.js.map +1 -1
- package/dist/browser/retryStrategies/throttlingRetryStrategy.js +1 -1
- package/dist/browser/retryStrategies/throttlingRetryStrategy.js.map +1 -1
- package/dist/browser/util/checkEnvironment.js +6 -7
- package/dist/browser/util/checkEnvironment.js.map +1 -1
- package/dist/browser/util/helpers.js +4 -4
- package/dist/browser/util/helpers.js.map +1 -1
- package/dist/browser/util/sanitizer.js +7 -1
- package/dist/browser/util/sanitizer.js.map +1 -1
- package/dist/browser/util/userAgentPlatform-browser.mjs.map +1 -1
- package/dist/browser/util/userAgentPlatform.js +2 -2
- package/dist/browser/util/uuidUtils-browser.mjs.map +1 -1
- package/dist/browser/util/uuidUtils.js +1 -2
- package/dist/browser/xhrHttpClient.js +3 -5
- package/dist/browser/xhrHttpClient.js.map +1 -1
- package/dist/commonjs/client/getClient.js +8 -10
- package/dist/commonjs/client/getClient.js.map +1 -1
- package/dist/commonjs/client/multipart.js +2 -4
- package/dist/commonjs/client/multipart.js.map +1 -1
- package/dist/commonjs/client/operationOptionHelpers.js +6 -7
- package/dist/commonjs/client/operationOptionHelpers.js.map +1 -1
- package/dist/commonjs/client/restError.js +4 -6
- package/dist/commonjs/client/restError.js.map +1 -1
- package/dist/commonjs/client/sendRequest.js +20 -19
- package/dist/commonjs/client/sendRequest.js.map +1 -1
- package/dist/commonjs/client/urlHelpers.js +6 -9
- package/dist/commonjs/client/urlHelpers.js.map +1 -1
- package/dist/commonjs/fetchHttpClient.js +30 -21
- package/dist/commonjs/fetchHttpClient.js.map +1 -1
- package/dist/commonjs/httpHeaders.js +2 -2
- package/dist/commonjs/httpHeaders.js.map +1 -1
- package/dist/commonjs/logger/log.js +2 -2
- package/dist/commonjs/logger/log.js.map +1 -1
- package/dist/commonjs/nodeHttpClient.js +36 -30
- package/dist/commonjs/nodeHttpClient.js.map +1 -1
- package/dist/commonjs/pipeline.js +3 -3
- package/dist/commonjs/pipeline.js.map +1 -1
- package/dist/commonjs/pipelineRequest.js +26 -8
- package/dist/commonjs/pipelineRequest.js.map +1 -1
- package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js +1 -2
- package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js.map +1 -1
- package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js +1 -2
- package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js.map +1 -1
- package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js +1 -2
- package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js.map +1 -1
- package/dist/commonjs/policies/auth/checkInsecureConnection.js +1 -1
- package/dist/commonjs/policies/auth/checkInsecureConnection.js.map +1 -1
- package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js +1 -2
- package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js.map +1 -1
- package/dist/commonjs/policies/defaultRetryPolicy.js +1 -2
- package/dist/commonjs/policies/defaultRetryPolicy.js.map +1 -1
- package/dist/commonjs/policies/exponentialRetryPolicy.js +5 -3
- package/dist/commonjs/policies/exponentialRetryPolicy.js.map +1 -1
- package/dist/commonjs/policies/formDataPolicy.js +2 -3
- package/dist/commonjs/policies/formDataPolicy.js.map +1 -1
- package/dist/commonjs/policies/logPolicy.js +1 -2
- package/dist/commonjs/policies/logPolicy.js.map +1 -1
- package/dist/commonjs/policies/multipartPolicy.js +2 -3
- package/dist/commonjs/policies/multipartPolicy.js.map +1 -1
- package/dist/commonjs/policies/proxyPolicy.js +4 -5
- package/dist/commonjs/policies/proxyPolicy.js.map +1 -1
- package/dist/commonjs/policies/retryPolicy.js +2 -3
- package/dist/commonjs/policies/retryPolicy.js.map +1 -1
- package/dist/commonjs/policies/systemErrorRetryPolicy.js +5 -3
- package/dist/commonjs/policies/systemErrorRetryPolicy.js.map +1 -1
- package/dist/commonjs/policies/throttlingRetryPolicy.js +1 -2
- package/dist/commonjs/policies/throttlingRetryPolicy.js.map +1 -1
- package/dist/commonjs/restError.js +38 -12
- package/dist/commonjs/restError.js.map +1 -1
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js +2 -3
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js.map +1 -1
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js +1 -1
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/commonjs/util/checkEnvironment.js +6 -7
- package/dist/commonjs/util/checkEnvironment.js.map +1 -1
- package/dist/commonjs/util/concat.js +17 -35
- package/dist/commonjs/util/concat.js.map +1 -1
- package/dist/commonjs/util/helpers.js +4 -4
- package/dist/commonjs/util/helpers.js.map +1 -1
- package/dist/commonjs/util/sanitizer.js +7 -1
- package/dist/commonjs/util/sanitizer.js.map +1 -1
- package/dist/commonjs/util/userAgentPlatform.js +5 -5
- package/dist/commonjs/util/userAgentPlatform.js.map +1 -1
- package/dist/commonjs/util/uuidUtils.js +1 -2
- package/dist/commonjs/util/uuidUtils.js.map +1 -1
- package/dist/commonjs/xhrHttpClient.js +3 -5
- package/dist/commonjs/xhrHttpClient.js.map +1 -1
- package/dist/esm/client/getClient.js +8 -10
- package/dist/esm/client/getClient.js.map +1 -1
- package/dist/esm/client/multipart.js +2 -4
- package/dist/esm/client/multipart.js.map +1 -1
- package/dist/esm/client/operationOptionHelpers.js +6 -7
- package/dist/esm/client/operationOptionHelpers.js.map +1 -1
- package/dist/esm/client/restError.js +4 -6
- package/dist/esm/client/restError.js.map +1 -1
- package/dist/esm/client/sendRequest.js +20 -19
- package/dist/esm/client/sendRequest.js.map +1 -1
- package/dist/esm/client/urlHelpers.js +6 -9
- package/dist/esm/client/urlHelpers.js.map +1 -1
- package/dist/esm/fetchHttpClient.js +30 -21
- package/dist/esm/fetchHttpClient.js.map +1 -1
- package/dist/esm/httpHeaders.js +2 -2
- package/dist/esm/httpHeaders.js.map +1 -1
- package/dist/esm/logger/log.js +1 -1
- package/dist/esm/logger/log.js.map +1 -1
- package/dist/esm/nodeHttpClient.js +30 -24
- package/dist/esm/nodeHttpClient.js.map +1 -1
- package/dist/esm/pipeline.js +3 -3
- package/dist/esm/pipeline.js.map +1 -1
- package/dist/esm/pipelineRequest.js +26 -8
- package/dist/esm/pipelineRequest.js.map +1 -1
- package/dist/esm/policies/auth/apiKeyAuthenticationPolicy.js +1 -2
- package/dist/esm/policies/auth/apiKeyAuthenticationPolicy.js.map +1 -1
- package/dist/esm/policies/auth/basicAuthenticationPolicy.js +1 -2
- package/dist/esm/policies/auth/basicAuthenticationPolicy.js.map +1 -1
- package/dist/esm/policies/auth/bearerAuthenticationPolicy.js +1 -2
- package/dist/esm/policies/auth/bearerAuthenticationPolicy.js.map +1 -1
- package/dist/esm/policies/auth/checkInsecureConnection.js +1 -1
- package/dist/esm/policies/auth/checkInsecureConnection.js.map +1 -1
- package/dist/esm/policies/auth/oauth2AuthenticationPolicy.js +1 -2
- package/dist/esm/policies/auth/oauth2AuthenticationPolicy.js.map +1 -1
- package/dist/esm/policies/defaultRetryPolicy.js +1 -2
- package/dist/esm/policies/defaultRetryPolicy.js.map +1 -1
- package/dist/esm/policies/exponentialRetryPolicy.js +5 -3
- package/dist/esm/policies/exponentialRetryPolicy.js.map +1 -1
- package/dist/esm/policies/formDataPolicy.js +2 -3
- package/dist/esm/policies/formDataPolicy.js.map +1 -1
- package/dist/esm/policies/logPolicy.js +1 -2
- package/dist/esm/policies/logPolicy.js.map +1 -1
- package/dist/esm/policies/multipartPolicy.js +2 -3
- package/dist/esm/policies/multipartPolicy.js.map +1 -1
- package/dist/esm/policies/proxyPolicy.js +4 -5
- package/dist/esm/policies/proxyPolicy.js.map +1 -1
- package/dist/esm/policies/retryPolicy.js +2 -3
- package/dist/esm/policies/retryPolicy.js.map +1 -1
- package/dist/esm/policies/systemErrorRetryPolicy.js +5 -3
- package/dist/esm/policies/systemErrorRetryPolicy.js.map +1 -1
- package/dist/esm/policies/throttlingRetryPolicy.js +1 -2
- package/dist/esm/policies/throttlingRetryPolicy.js.map +1 -1
- package/dist/esm/restError.js +38 -12
- package/dist/esm/restError.js.map +1 -1
- package/dist/esm/retryStrategies/exponentialRetryStrategy.js +2 -3
- package/dist/esm/retryStrategies/exponentialRetryStrategy.js.map +1 -1
- package/dist/esm/retryStrategies/throttlingRetryStrategy.js +1 -1
- package/dist/esm/retryStrategies/throttlingRetryStrategy.js.map +1 -1
- package/dist/esm/util/checkEnvironment.js +6 -7
- package/dist/esm/util/checkEnvironment.js.map +1 -1
- package/dist/esm/util/concat.js +17 -35
- package/dist/esm/util/concat.js.map +1 -1
- package/dist/esm/util/helpers.js +4 -4
- package/dist/esm/util/helpers.js.map +1 -1
- package/dist/esm/util/sanitizer.js +7 -1
- package/dist/esm/util/sanitizer.js.map +1 -1
- package/dist/esm/util/userAgentPlatform.js +2 -2
- package/dist/esm/util/userAgentPlatform.js.map +1 -1
- package/dist/esm/util/uuidUtils.js +1 -2
- package/dist/esm/util/uuidUtils.js.map +1 -1
- package/dist/esm/xhrHttpClient.js +3 -5
- package/dist/esm/xhrHttpClient.js.map +1 -1
- package/dist/react-native/client/getClient.js +8 -10
- package/dist/react-native/client/getClient.js.map +1 -1
- package/dist/react-native/client/multipart.js +2 -4
- package/dist/react-native/client/multipart.js.map +1 -1
- package/dist/react-native/client/operationOptionHelpers.js +6 -7
- package/dist/react-native/client/operationOptionHelpers.js.map +1 -1
- package/dist/react-native/client/restError.js +4 -6
- package/dist/react-native/client/restError.js.map +1 -1
- package/dist/react-native/client/sendRequest.js +20 -19
- package/dist/react-native/client/sendRequest.js.map +1 -1
- package/dist/react-native/client/urlHelpers.js +6 -9
- package/dist/react-native/client/urlHelpers.js.map +1 -1
- package/dist/react-native/fetchHttpClient.js +30 -21
- package/dist/react-native/fetchHttpClient.js.map +1 -1
- package/dist/react-native/httpHeaders.js +2 -2
- package/dist/react-native/httpHeaders.js.map +1 -1
- package/dist/react-native/nodeHttpClient.js +30 -24
- package/dist/react-native/nodeHttpClient.js.map +1 -1
- package/dist/react-native/pipeline.js +3 -3
- package/dist/react-native/pipeline.js.map +1 -1
- package/dist/react-native/pipelineRequest.js +26 -8
- package/dist/react-native/pipelineRequest.js.map +1 -1
- package/dist/react-native/policies/auth/apiKeyAuthenticationPolicy.js +1 -2
- package/dist/react-native/policies/auth/apiKeyAuthenticationPolicy.js.map +1 -1
- package/dist/react-native/policies/auth/basicAuthenticationPolicy.js +1 -2
- package/dist/react-native/policies/auth/basicAuthenticationPolicy.js.map +1 -1
- package/dist/react-native/policies/auth/bearerAuthenticationPolicy.js +1 -2
- package/dist/react-native/policies/auth/bearerAuthenticationPolicy.js.map +1 -1
- package/dist/react-native/policies/auth/checkInsecureConnection.js +1 -1
- package/dist/react-native/policies/auth/checkInsecureConnection.js.map +1 -1
- package/dist/react-native/policies/auth/oauth2AuthenticationPolicy.js +1 -2
- package/dist/react-native/policies/auth/oauth2AuthenticationPolicy.js.map +1 -1
- package/dist/react-native/policies/defaultRetryPolicy.js +1 -2
- package/dist/react-native/policies/defaultRetryPolicy.js.map +1 -1
- package/dist/react-native/policies/exponentialRetryPolicy.js +5 -3
- package/dist/react-native/policies/exponentialRetryPolicy.js.map +1 -1
- package/dist/react-native/policies/formDataPolicy.js +2 -3
- package/dist/react-native/policies/formDataPolicy.js.map +1 -1
- package/dist/react-native/policies/logPolicy.js +1 -2
- package/dist/react-native/policies/logPolicy.js.map +1 -1
- package/dist/react-native/policies/multipartPolicy.js +2 -3
- package/dist/react-native/policies/multipartPolicy.js.map +1 -1
- package/dist/react-native/policies/retryPolicy.js +2 -3
- package/dist/react-native/policies/retryPolicy.js.map +1 -1
- package/dist/react-native/policies/systemErrorRetryPolicy.js +5 -3
- package/dist/react-native/policies/systemErrorRetryPolicy.js.map +1 -1
- package/dist/react-native/policies/throttlingRetryPolicy.js +1 -2
- package/dist/react-native/policies/throttlingRetryPolicy.js.map +1 -1
- package/dist/react-native/restError.js +38 -12
- package/dist/react-native/restError.js.map +1 -1
- package/dist/react-native/retryStrategies/exponentialRetryStrategy.js +2 -3
- package/dist/react-native/retryStrategies/exponentialRetryStrategy.js.map +1 -1
- package/dist/react-native/retryStrategies/throttlingRetryStrategy.js +1 -1
- package/dist/react-native/retryStrategies/throttlingRetryStrategy.js.map +1 -1
- package/dist/react-native/util/checkEnvironment.js +6 -7
- package/dist/react-native/util/checkEnvironment.js.map +1 -1
- package/dist/react-native/util/helpers.js +4 -4
- package/dist/react-native/util/helpers.js.map +1 -1
- package/dist/react-native/util/sanitizer.js +7 -1
- package/dist/react-native/util/sanitizer.js.map +1 -1
- package/dist/react-native/util/userAgentPlatform-react-native.mjs.map +1 -1
- package/dist/react-native/util/userAgentPlatform.js +1 -2
- package/dist/react-native/xhrHttpClient.js +3 -5
- package/dist/react-native/xhrHttpClient.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipelineRequest.js","sourceRoot":"","sources":["../../src/pipelineRequest.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,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,KAAK,CAAC;QAC1D,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,yBAAyB,GAAG,OAAO,CAAC,yBAAyB,CAAC;QACnE,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,KAAK,CAAC;QACxD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACjD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;QACrD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,UAAU,EAAE,CAAC;QACnD,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,IAAI,KAAK,CAAC;QACxE,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,IAAI,KAAK,CAAC;QAClE,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACjD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACzC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n FormDataMap,\n HttpHeaders,\n HttpMethods,\n MultipartRequestBody,\n PipelineRequest,\n ProxySettings,\n RequestBodyType,\n TransferProgressEvent,\n} from \"./interfaces.js\";\nimport { createHttpHeaders } from \"./httpHeaders.js\";\nimport { randomUUID } from \"./util/uuidUtils.js\";\nimport { AuthScheme } from \"./auth/schemes.js\";\n\n/**\n * Settings to initialize a request.\n * Almost equivalent to Partial<PipelineRequest>, but url is mandatory.\n */\nexport interface PipelineRequestOptions {\n /**\n * The URL to make the request to.\n */\n url: string;\n\n /**\n * The HTTP method to use when making the request.\n */\n method?: HttpMethods;\n\n /**\n * The HTTP headers to use when making the request.\n */\n headers?: HttpHeaders;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n * If the request is terminated, an `AbortError` is thrown.\n * Defaults to 0, which disables the timeout.\n */\n timeout?: number;\n\n /**\n * If credentials (cookies) should be sent along during an XHR.\n * Defaults to false.\n */\n withCredentials?: boolean;\n\n /**\n * A unique identifier for the request. Used for logging and tracing.\n */\n requestId?: string;\n\n /**\n * The HTTP body content (if any)\n */\n body?: RequestBodyType;\n\n /**\n * Body for a multipart request.\n */\n multipartBody?: MultipartRequestBody;\n\n /**\n * To simulate a browser form post\n */\n formData?: FormDataMap;\n\n /**\n * A list of response status codes whose corresponding PipelineResponse body should be treated as a stream.\n */\n streamResponseStatusCodes?: Set<number>;\n\n /**\n * BROWSER ONLY\n *\n * A browser only option to enable use of the Streams API. If this option is set and streaming is used\n * (see `streamResponseStatusCodes`), the response will have a property `browserStream` instead of\n * `blobBody` which will be undefined.\n *\n * Default value is false\n */\n enableBrowserStreams?: boolean;\n\n /**\n * Proxy configuration.\n */\n proxySettings?: ProxySettings;\n\n /**\n * If the connection should not be reused.\n */\n disableKeepAlive?: boolean;\n\n /**\n * Used to abort the request later.\n */\n abortSignal?: AbortSignal;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /** Callback which fires upon download progress. */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n\n /**\n * List of authentication schemes used for this specific request.\n * These schemes define how the request will be authenticated.\n *\n * If values are provided, these schemes override the client level authentication schemes.\n * If an empty array is provided, it explicitly specifies no authentication for the request.\n * If not provided at the request level, the client level authentication schemes will be used.\n */\n authSchemes?: AuthScheme[];\n\n /**\n * Additional options to set on the request. This provides a way to override\n * existing ones or provide request properties that are not declared.\n *\n * For possible valid properties, see\n * - NodeJS https.request options: https://nodejs.org/api/http.html#httprequestoptions-callback\n * - Browser RequestInit: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit\n *\n * WARNING: Options specified here will override any properties of same names when request is sent by {@link HttpClient}.\n */\n requestOverrides?: Record<string, unknown>;\n}\n\nclass PipelineRequestImpl implements PipelineRequest {\n public url: string;\n public method: HttpMethods;\n public headers: HttpHeaders;\n public timeout: number;\n public withCredentials: boolean;\n public body?: RequestBodyType;\n public multipartBody?: MultipartRequestBody;\n public formData?: FormDataMap;\n public streamResponseStatusCodes?: Set<number>;\n public enableBrowserStreams: boolean;\n\n public proxySettings?: ProxySettings;\n public disableKeepAlive: boolean;\n public abortSignal?: AbortSignal;\n public requestId: string;\n public allowInsecureConnection?: boolean;\n public onUploadProgress?: (progress: TransferProgressEvent) => void;\n public onDownloadProgress?: (progress: TransferProgressEvent) => void;\n public requestOverrides?: Record<string, unknown>;\n public authSchemes?: AuthScheme[];\n\n constructor(options: PipelineRequestOptions) {\n this.url = options.url;\n this.body = options.body;\n this.headers = options.headers ?? createHttpHeaders();\n this.method = options.method ?? \"GET\";\n this.timeout = options.timeout ?? 0;\n this.multipartBody = options.multipartBody;\n this.formData = options.formData;\n this.disableKeepAlive = options.disableKeepAlive ?? false;\n this.proxySettings = options.proxySettings;\n this.streamResponseStatusCodes = options.streamResponseStatusCodes;\n this.withCredentials = options.withCredentials ?? false;\n this.abortSignal = options.abortSignal;\n this.onUploadProgress = options.onUploadProgress;\n this.onDownloadProgress = options.onDownloadProgress;\n this.requestId = options.requestId || randomUUID();\n this.allowInsecureConnection = options.allowInsecureConnection ?? false;\n this.enableBrowserStreams = options.enableBrowserStreams ?? false;\n this.requestOverrides = options.requestOverrides;\n this.authSchemes = options.authSchemes;\n }\n}\n\n/**\n * Creates a new pipeline request with the given options.\n * This method is to allow for the easy setting of default values and not required.\n * @param options - The options to create the request with.\n */\nexport function createPipelineRequest(options: PipelineRequestOptions): PipelineRequest {\n return new PipelineRequestImpl(options);\n}\n"]}
|
|
@@ -12,10 +12,9 @@ export function apiKeyAuthenticationPolicy(options) {
|
|
|
12
12
|
return {
|
|
13
13
|
name: apiKeyAuthenticationPolicyName,
|
|
14
14
|
async sendRequest(request, next) {
|
|
15
|
-
var _a, _b;
|
|
16
15
|
// Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs
|
|
17
16
|
ensureSecureConnection(request, options);
|
|
18
|
-
const scheme = (
|
|
17
|
+
const scheme = (request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === "apiKey");
|
|
19
18
|
// Skip adding authentication header if no API key authentication scheme is found
|
|
20
19
|
if (!scheme) {
|
|
21
20
|
return next(request);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiKeyAuthenticationPolicy.js","sourceRoot":"","sources":["../../../../src/policies/auth/apiKeyAuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,4BAA4B,CAAC;AAqB3E;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA0C;IAE1C,OAAO;QACL,IAAI,EAAE,8BAA8B;QACpC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB
|
|
1
|
+
{"version":3,"file":"apiKeyAuthenticationPolicy.js","sourceRoot":"","sources":["../../../../src/policies/auth/apiKeyAuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,4BAA4B,CAAC;AAqB3E;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA0C;IAE1C,OAAO;QACL,IAAI,EAAE,8BAA8B;QACpC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,0FAA0F;YAC1F,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAEzC,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;YAE9F,iFAAiF;YACjF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YACD,IAAI,MAAM,CAAC,cAAc,KAAK,QAAQ,EAAE,CAAC;gBACvC,MAAM,IAAI,KAAK,CAAC,iCAAiC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;YAC5E,CAAC;YAED,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YACzD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ApiKeyCredential } from \"../../auth/credentials.js\";\nimport type { AuthScheme } from \"../../auth/schemes.js\";\nimport type { PipelineRequest, PipelineResponse, SendRequest } from \"../../interfaces.js\";\nimport type { PipelinePolicy } from \"../../pipeline.js\";\nimport { ensureSecureConnection } from \"./checkInsecureConnection.js\";\n\n/**\n * Name of the API Key Authentication Policy\n */\nexport const apiKeyAuthenticationPolicyName = \"apiKeyAuthenticationPolicy\";\n\n/**\n * Options for configuring the API key authentication policy\n */\nexport interface ApiKeyAuthenticationPolicyOptions {\n /**\n * The credential used to authenticate requests\n */\n credential: ApiKeyCredential;\n /**\n * Optional authentication schemes to use. If `authSchemes` is provided in both request and policy options, the request options will take precedence.\n */\n authSchemes?: AuthScheme[];\n /**\n * Allows for connecting to HTTP endpoints instead of enforcing HTTPS.\n * CAUTION: Never use this option in production.\n */\n allowInsecureConnection?: boolean;\n}\n\n/**\n * Gets a pipeline policy that adds API key authentication to requests\n */\nexport function apiKeyAuthenticationPolicy(\n options: ApiKeyAuthenticationPolicyOptions,\n): PipelinePolicy {\n return {\n name: apiKeyAuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs\n ensureSecureConnection(request, options);\n\n const scheme = (request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === \"apiKey\");\n\n // Skip adding authentication header if no API key authentication scheme is found\n if (!scheme) {\n return next(request);\n }\n if (scheme.apiKeyLocation !== \"header\") {\n throw new Error(`Unsupported API key location: ${scheme.apiKeyLocation}`);\n }\n\n request.headers.set(scheme.name, options.credential.key);\n return next(request);\n },\n };\n}\n"]}
|
|
@@ -13,10 +13,9 @@ export function basicAuthenticationPolicy(options) {
|
|
|
13
13
|
return {
|
|
14
14
|
name: basicAuthenticationPolicyName,
|
|
15
15
|
async sendRequest(request, next) {
|
|
16
|
-
var _a, _b;
|
|
17
16
|
// Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs
|
|
18
17
|
ensureSecureConnection(request, options);
|
|
19
|
-
const scheme = (
|
|
18
|
+
const scheme = (request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === "http" && x.scheme === "basic");
|
|
20
19
|
// Skip adding authentication header if no basic authentication scheme is found
|
|
21
20
|
if (!scheme) {
|
|
22
21
|
return next(request);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basicAuthenticationPolicy.js","sourceRoot":"","sources":["../../../../src/policies/auth/basicAuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,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AQ,IAAI,QAAQ,EAAE,EAAE,OAAO,CAAC,EACtD,QAAQ,CACT,CAAC;YACF,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,SAAS,WAAW,EAAE,CAAC,CAAC;YAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { BasicCredential } from \"../../auth/credentials.js\";\nimport type { AuthScheme } from \"../../auth/schemes.js\";\nimport type { PipelineRequest, PipelineResponse, SendRequest } from \"../../interfaces.js\";\nimport type { PipelinePolicy } from \"../../pipeline.js\";\nimport { stringToUint8Array, uint8ArrayToString } from \"../../util/bytesEncoding.js\";\nimport { ensureSecureConnection } from \"./checkInsecureConnection.js\";\n\n/**\n * Name of the Basic Authentication Policy\n */\nexport const basicAuthenticationPolicyName = \"bearerAuthenticationPolicy\";\n\n/**\n * Options for configuring the basic authentication policy\n */\nexport interface BasicAuthenticationPolicyOptions {\n /**\n * The credential used to authenticate requests\n */\n credential: BasicCredential;\n /**\n * Optional authentication schemes to use. If not provided, schemes from the request will be used.\n */\n authSchemes?: AuthScheme[];\n /**\n * Allows for connecting to HTTP endpoints instead of enforcing HTTPS.\n * CAUTION: Never use this option in production.\n */\n allowInsecureConnection?: boolean;\n}\n\n/**\n * Gets a pipeline policy that adds basic authentication to requests\n */\nexport function basicAuthenticationPolicy(\n options: BasicAuthenticationPolicyOptions,\n): PipelinePolicy {\n return {\n name: basicAuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs\n ensureSecureConnection(request, options);\n\n const scheme = (request.authSchemes ?? options.authSchemes)?.find(\n (x) => x.kind === \"http\" && x.scheme === \"basic\",\n );\n\n // Skip adding authentication header if no basic authentication scheme is found\n if (!scheme) {\n return next(request);\n }\n\n const { username, password } = options.credential;\n const headerValue = uint8ArrayToString(\n stringToUint8Array(`${username}:${password}`, \"utf-8\"),\n \"base64\",\n );\n request.headers.set(\"Authorization\", `Basic ${headerValue}`);\n return next(request);\n },\n };\n}\n"]}
|
|
@@ -12,10 +12,9 @@ export function bearerAuthenticationPolicy(options) {
|
|
|
12
12
|
return {
|
|
13
13
|
name: bearerAuthenticationPolicyName,
|
|
14
14
|
async sendRequest(request, next) {
|
|
15
|
-
var _a, _b;
|
|
16
15
|
// Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs
|
|
17
16
|
ensureSecureConnection(request, options);
|
|
18
|
-
const scheme = (
|
|
17
|
+
const scheme = (request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === "http" && x.scheme === "bearer");
|
|
19
18
|
// Skip adding authentication header if no bearer authentication scheme is found
|
|
20
19
|
if (!scheme) {
|
|
21
20
|
return next(request);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bearerAuthenticationPolicy.js","sourceRoot":"","sources":["../../../../src/policies/auth/bearerAuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,4BAA4B,CAAC;AAqB3E;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA0C;IAE1C,OAAO;QACL,IAAI,EAAE,8BAA8B;QACpC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB
|
|
1
|
+
{"version":3,"file":"bearerAuthenticationPolicy.js","sourceRoot":"","sources":["../../../../src/policies/auth/bearerAuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,4BAA4B,CAAC;AAqB3E;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA0C;IAE1C,OAAO;QACL,IAAI,EAAE,8BAA8B;QACpC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,0FAA0F;YAC1F,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAEzC,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAC/D,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,QAAQ,CAClD,CAAC;YAEF,gFAAgF;YAChF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YAED,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC;gBACpD,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAC;YACH,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC;YACxD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { BearerTokenCredential } from \"../../auth/credentials.js\";\nimport type { AuthScheme } from \"../../auth/schemes.js\";\nimport type { PipelineRequest, PipelineResponse, SendRequest } from \"../../interfaces.js\";\nimport type { PipelinePolicy } from \"../../pipeline.js\";\nimport { ensureSecureConnection } from \"./checkInsecureConnection.js\";\n\n/**\n * Name of the Bearer Authentication Policy\n */\nexport const bearerAuthenticationPolicyName = \"bearerAuthenticationPolicy\";\n\n/**\n * Options for configuring the bearer authentication policy\n */\nexport interface BearerAuthenticationPolicyOptions {\n /**\n * The BearerTokenCredential implementation that can supply the bearer token.\n */\n credential: BearerTokenCredential;\n /**\n * Optional authentication schemes to use. If not provided, schemes from the request will be used.\n */\n authSchemes?: AuthScheme[];\n /**\n * Allows for connecting to HTTP endpoints instead of enforcing HTTPS.\n * CAUTION: Never use this option in production.\n */\n allowInsecureConnection?: boolean;\n}\n\n/**\n * Gets a pipeline policy that adds bearer token authentication to requests\n */\nexport function bearerAuthenticationPolicy(\n options: BearerAuthenticationPolicyOptions,\n): PipelinePolicy {\n return {\n name: bearerAuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs\n ensureSecureConnection(request, options);\n\n const scheme = (request.authSchemes ?? options.authSchemes)?.find(\n (x) => x.kind === \"http\" && x.scheme === \"bearer\",\n );\n\n // Skip adding authentication header if no bearer authentication scheme is found\n if (!scheme) {\n return next(request);\n }\n\n const token = await options.credential.getBearerToken({\n abortSignal: request.abortSignal,\n });\n request.headers.set(\"Authorization\", `Bearer ${token}`);\n return next(request);\n },\n };\n}\n"]}
|
|
@@ -28,7 +28,7 @@ function allowInsecureConnection(request, options) {
|
|
|
28
28
|
function emitInsecureConnectionWarning() {
|
|
29
29
|
const warning = "Sending token over insecure transport. Assume any token issued is compromised.";
|
|
30
30
|
logger.warning(warning);
|
|
31
|
-
if (typeof
|
|
31
|
+
if (typeof process?.emitWarning === "function" && !insecureConnectionWarningEmmitted) {
|
|
32
32
|
insecureConnectionWarningEmmitted = true;
|
|
33
33
|
process.emitWarning(warning);
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkInsecureConnection.js","sourceRoot":"","sources":["../../../../src/policies/auth/checkInsecureConnection.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,2CAA2C;AAC3C,IAAI,iCAAiC,GAAG,KAAK,CAAC;AAE9C;;;;;;;GAOG;AACH,SAAS,uBAAuB,CAC9B,OAAwB,EACxB,OAA8C;IAE9C,IAAI,OAAO,CAAC,uBAAuB,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC;QACvE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;YACjE,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,6BAA6B;IACpC,MAAM,OAAO,GAAG,gFAAgF,CAAC;IAEjG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAExB,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"checkInsecureConnection.js","sourceRoot":"","sources":["../../../../src/policies/auth/checkInsecureConnection.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,2CAA2C;AAC3C,IAAI,iCAAiC,GAAG,KAAK,CAAC;AAE9C;;;;;;;GAOG;AACH,SAAS,uBAAuB,CAC9B,OAAwB,EACxB,OAA8C;IAE9C,IAAI,OAAO,CAAC,uBAAuB,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC;QACvE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,IAAI,GAAG,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;YACjE,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,SAAS,6BAA6B;IACpC,MAAM,OAAO,GAAG,gFAAgF,CAAC;IAEjG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAExB,IAAI,OAAO,OAAO,EAAE,WAAW,KAAK,UAAU,IAAI,CAAC,iCAAiC,EAAE,CAAC;QACrF,iCAAiC,GAAG,IAAI,CAAC;QACzC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAwB,EACxB,OAA8C;IAE9C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACtD,IAAI,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;YAC9C,6BAA6B,EAAE,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CACb,+GAA+G,CAChH,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRequest } from \"../../interfaces.js\";\nimport { logger } from \"../../log.js\";\n\n// Ensure the warining is only emitted once\nlet insecureConnectionWarningEmmitted = false;\n\n/**\n * Checks if the request is allowed to be sent over an insecure connection.\n *\n * A request is allowed to be sent over an insecure connection when:\n * - The `allowInsecureConnection` option is set to `true`.\n * - The request has the `allowInsecureConnection` property set to `true`.\n * - The request is being sent to `localhost` or `127.0.0.1`\n */\nfunction allowInsecureConnection(\n request: PipelineRequest,\n options: { allowInsecureConnection?: boolean },\n): boolean {\n if (options.allowInsecureConnection && request.allowInsecureConnection) {\n const url = new URL(request.url);\n if (url.hostname === \"localhost\" || url.hostname === \"127.0.0.1\") {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Logs a warning about sending a token over an insecure connection.\n *\n * This function will emit a node warning once, but log the warning every time.\n */\nfunction emitInsecureConnectionWarning(): void {\n const warning = \"Sending token over insecure transport. Assume any token issued is compromised.\";\n\n logger.warning(warning);\n\n if (typeof process?.emitWarning === \"function\" && !insecureConnectionWarningEmmitted) {\n insecureConnectionWarningEmmitted = true;\n process.emitWarning(warning);\n }\n}\n\n/**\n * Ensures that authentication is only allowed over HTTPS unless explicitly allowed.\n * Throws an error if the connection is not secure and not explicitly allowed.\n */\nexport function ensureSecureConnection(\n request: PipelineRequest,\n options: { allowInsecureConnection?: boolean },\n): void {\n if (!request.url.toLowerCase().startsWith(\"https://\")) {\n if (allowInsecureConnection(request, options)) {\n emitInsecureConnectionWarning();\n } else {\n throw new Error(\n \"Authentication is not permitted for non-TLS protected (non-https) URLs when allowInsecureConnection is false.\",\n );\n }\n }\n}\n"]}
|
|
@@ -12,10 +12,9 @@ export function oauth2AuthenticationPolicy(options) {
|
|
|
12
12
|
return {
|
|
13
13
|
name: oauth2AuthenticationPolicyName,
|
|
14
14
|
async sendRequest(request, next) {
|
|
15
|
-
var _a, _b;
|
|
16
15
|
// Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs
|
|
17
16
|
ensureSecureConnection(request, options);
|
|
18
|
-
const scheme = (
|
|
17
|
+
const scheme = (request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === "oauth2");
|
|
19
18
|
// Skip adding authentication header if no OAuth2 authentication scheme is found
|
|
20
19
|
if (!scheme) {
|
|
21
20
|
return next(request);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth2AuthenticationPolicy.js","sourceRoot":"","sources":["../../../../src/policies/auth/oauth2AuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,4BAA4B,CAAC;AAqB3E;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAAkD;IAElD,OAAO;QACL,IAAI,EAAE,8BAA8B;QACpC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB
|
|
1
|
+
{"version":3,"file":"oauth2AuthenticationPolicy.js","sourceRoot":"","sources":["../../../../src/policies/auth/oauth2AuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,4BAA4B,CAAC;AAqB3E;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAAkD;IAElD,OAAO;QACL,IAAI,EAAE,8BAA8B;QACpC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,0FAA0F;YAC1F,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAEzC,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;YAE9F,gFAAgF;YAChF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,MAAM,CAAC,KAAiB,EAAE;gBAC9E,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAC;YACH,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,KAAK,EAAE,CAAC,CAAC;YACxD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OAuth2Flow } from \"../../auth/oauth2Flows.js\";\nimport type { OAuth2TokenCredential } from \"../../auth/credentials.js\";\nimport type { AuthScheme } from \"../../auth/schemes.js\";\nimport type { PipelineRequest, PipelineResponse, SendRequest } from \"../../interfaces.js\";\nimport type { PipelinePolicy } from \"../../pipeline.js\";\nimport { ensureSecureConnection } from \"./checkInsecureConnection.js\";\n\n/**\n * Name of the OAuth2 Authentication Policy\n */\nexport const oauth2AuthenticationPolicyName = \"oauth2AuthenticationPolicy\";\n\n/**\n * Options for configuring the OAuth2 authentication policy\n */\nexport interface OAuth2AuthenticationPolicyOptions<TFlows extends OAuth2Flow> {\n /**\n * The OAuth2TokenCredential implementation that can supply the bearer token.\n */\n credential: OAuth2TokenCredential<TFlows>;\n /**\n * Optional authentication schemes to use. If not provided, schemes from the request will be used.\n */\n authSchemes?: AuthScheme[];\n /**\n * Allows for connecting to HTTP endpoints instead of enforcing HTTPS.\n * CAUTION: Never use this option in production.\n */\n allowInsecureConnection?: boolean;\n}\n\n/**\n * Gets a pipeline policy that adds authorization header from OAuth2 schemes\n */\nexport function oauth2AuthenticationPolicy<TFlows extends OAuth2Flow>(\n options: OAuth2AuthenticationPolicyOptions<TFlows>,\n): PipelinePolicy {\n return {\n name: oauth2AuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // Ensure allowInsecureConnection is explicitly set when sending request to non-https URLs\n ensureSecureConnection(request, options);\n\n const scheme = (request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === \"oauth2\");\n\n // Skip adding authentication header if no OAuth2 authentication scheme is found\n if (!scheme) {\n return next(request);\n }\n const token = await options.credential.getOAuth2Token(scheme.flows as TFlows[], {\n abortSignal: request.abortSignal,\n });\n request.headers.set(\"Authorization\", `Bearer ${token}`);\n return next(request);\n },\n };\n}\n"]}
|
|
@@ -15,11 +15,10 @@ export const defaultRetryPolicyName = "defaultRetryPolicy";
|
|
|
15
15
|
* - Or otherwise if the outgoing request fails, it will retry with an exponentially increasing delay.
|
|
16
16
|
*/
|
|
17
17
|
export function defaultRetryPolicy(options = {}) {
|
|
18
|
-
var _a;
|
|
19
18
|
return {
|
|
20
19
|
name: defaultRetryPolicyName,
|
|
21
20
|
sendRequest: retryPolicy([throttlingRetryStrategy(), exponentialRetryStrategy(options)], {
|
|
22
|
-
maxRetries:
|
|
21
|
+
maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT,
|
|
23
22
|
}).sendRequest,
|
|
24
23
|
};
|
|
25
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/defaultRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAO3D;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAqC,EAAE
|
|
1
|
+
{"version":3,"file":"defaultRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/defaultRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAO3D;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAqC,EAAE;IACxE,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,WAAW,CAAC,CAAC,uBAAuB,EAAE,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC,EAAE;YACvF,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,0BAA0B;SAC7D,CAAC,CAAC,WAAW;KACf,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRetryOptions } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { exponentialRetryStrategy } from \"../retryStrategies/exponentialRetryStrategy.js\";\nimport { throttlingRetryStrategy } from \"../retryStrategies/throttlingRetryStrategy.js\";\nimport { retryPolicy } from \"./retryPolicy.js\";\nimport { DEFAULT_RETRY_POLICY_COUNT } from \"../constants.js\";\n\n/**\n * Name of the {@link defaultRetryPolicy}\n */\nexport const defaultRetryPolicyName = \"defaultRetryPolicy\";\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface DefaultRetryPolicyOptions extends PipelineRetryOptions {}\n\n/**\n * A policy that retries according to three strategies:\n * - When the server sends a 429 response with a Retry-After header.\n * - When there are errors in the underlying transport layer (e.g. DNS lookup failures).\n * - Or otherwise if the outgoing request fails, it will retry with an exponentially increasing delay.\n */\nexport function defaultRetryPolicy(options: DefaultRetryPolicyOptions = {}): PipelinePolicy {\n return {\n name: defaultRetryPolicyName,\n sendRequest: retryPolicy([throttlingRetryStrategy(), exponentialRetryStrategy(options)], {\n maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT,\n }).sendRequest,\n };\n}\n"]}
|
|
@@ -12,11 +12,13 @@ export const exponentialRetryPolicyName = "exponentialRetryPolicy";
|
|
|
12
12
|
* @param options - Options that configure retry logic.
|
|
13
13
|
*/
|
|
14
14
|
export function exponentialRetryPolicy(options = {}) {
|
|
15
|
-
var _a;
|
|
16
15
|
return retryPolicy([
|
|
17
|
-
exponentialRetryStrategy(
|
|
16
|
+
exponentialRetryStrategy({
|
|
17
|
+
...options,
|
|
18
|
+
ignoreSystemErrors: true,
|
|
19
|
+
}),
|
|
18
20
|
], {
|
|
19
|
-
maxRetries:
|
|
21
|
+
maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT,
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
//# sourceMappingURL=exponentialRetryPolicy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exponentialRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/exponentialRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAyBnE;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAyC,EAAE
|
|
1
|
+
{"version":3,"file":"exponentialRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/exponentialRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAyBnE;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAyC,EAAE;IAE3C,OAAO,WAAW,CAChB;QACE,wBAAwB,CAAC;YACvB,GAAG,OAAO;YACV,kBAAkB,EAAE,IAAI;SACzB,CAAC;KACH,EACD;QACE,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,0BAA0B;KAC7D,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { exponentialRetryStrategy } from \"../retryStrategies/exponentialRetryStrategy.js\";\nimport { retryPolicy } from \"./retryPolicy.js\";\nimport { DEFAULT_RETRY_POLICY_COUNT } from \"../constants.js\";\n\n/**\n * The programmatic identifier of the exponentialRetryPolicy.\n */\nexport const exponentialRetryPolicyName = \"exponentialRetryPolicy\";\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface ExponentialRetryPolicyOptions {\n /**\n * The maximum number of retry attempts. Defaults to 3.\n */\n maxRetries?: number;\n\n /**\n * The amount of delay in milliseconds between retry attempts. Defaults to 1000\n * (1 second.) The delay increases exponentially with each retry up to a maximum\n * specified by maxRetryDelayInMs.\n */\n retryDelayInMs?: number;\n\n /**\n * The maximum delay in milliseconds allowed before retrying an operation. Defaults\n * to 64000 (64 seconds).\n */\n maxRetryDelayInMs?: number;\n}\n\n/**\n * A policy that attempts to retry requests while introducing an exponentially increasing delay.\n * @param options - Options that configure retry logic.\n */\nexport function exponentialRetryPolicy(\n options: ExponentialRetryPolicyOptions = {},\n): PipelinePolicy {\n return retryPolicy(\n [\n exponentialRetryStrategy({\n ...options,\n ignoreSystemErrors: true,\n }),\n ],\n {\n maxRetries: options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT,\n },\n );\n}\n"]}
|
|
@@ -8,10 +8,9 @@ import { createHttpHeaders } from "../httpHeaders.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export const formDataPolicyName = "formDataPolicy";
|
|
10
10
|
function formDataToFormDataMap(formData) {
|
|
11
|
-
var _a;
|
|
12
11
|
const formDataMap = {};
|
|
13
12
|
for (const [key, value] of formData.entries()) {
|
|
14
|
-
|
|
13
|
+
formDataMap[key] ??= [];
|
|
15
14
|
formDataMap[key].push(value);
|
|
16
15
|
}
|
|
17
16
|
return formDataMap;
|
|
@@ -62,7 +61,7 @@ async function prepareFormData(formData, request) {
|
|
|
62
61
|
// content type is specified and is not multipart/form-data. Exit.
|
|
63
62
|
return;
|
|
64
63
|
}
|
|
65
|
-
request.headers.set("Content-Type", contentType
|
|
64
|
+
request.headers.set("Content-Type", contentType ?? "multipart/form-data");
|
|
66
65
|
// set body to MultipartRequestBody using content from FormDataMap
|
|
67
66
|
const parts = [];
|
|
68
67
|
for (const [fieldName, values] of Object.entries(formData)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formDataPolicy.js","sourceRoot":"","sources":["../../../src/policies/formDataPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAWtD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAEnD,SAAS,qBAAqB,CAAC,QAAkB
|
|
1
|
+
{"version":3,"file":"formDataPolicy.js","sourceRoot":"","sources":["../../../src/policies/formDataPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAWtD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAEnD,SAAS,qBAAqB,CAAC,QAAkB;IAC/C,MAAM,WAAW,GAAgB,EAAE,CAAC;IACpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QAC9C,WAAW,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACvB,WAAW,CAAC,GAAG,CAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CA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,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9E,MAAM,IAAI,KAAK,CACb,4BAA4B,SAAS,KAAK,KAAK,+CAA+C,CAC/F,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,wFAAwF;gBACxF,MAAM,QAAQ,GAAI,KAAc,CAAC,IAAI,IAAI,MAAM,CAAC;gBAChD,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;gBACpC,OAAO,CAAC,GAAG,CACT,qBAAqB,EACrB,oBAAoB,SAAS,gBAAgB,QAAQ,GAAG,CACzD,CAAC;gBAEF,8EAA8E;gBAC9E,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,KAAK,CAAC,IAAI,IAAI,0BAA0B,CAAC,CAAC;gBAEtE,KAAK,CAAC,IAAI,CAAC;oBACT,OAAO;oBACP,IAAI,EAAE,KAAK;iBACZ,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,CAAC,aAAa,GAAG,EAAE,KAAK,EAAE,CAAC;AACpC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { stringToUint8Array } from \"../util/bytesEncoding.js\";\nimport { isNodeLike } from \"../util/checkEnvironment.js\";\nimport { createHttpHeaders } from \"../httpHeaders.js\";\nimport type {\n BodyPart,\n FormDataMap,\n FormDataValue,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\n/**\n * The programmatic identifier of the formDataPolicy.\n */\nexport const formDataPolicyName = \"formDataPolicy\";\n\nfunction formDataToFormDataMap(formData: FormData): FormDataMap {\n const formDataMap: FormDataMap = {};\n for (const [key, value] of formData.entries()) {\n formDataMap[key] ??= [];\n (formDataMap[key] as FormDataValue[]).push(value);\n }\n return formDataMap;\n}\n\n/**\n * A policy that encodes FormData on the request into the body.\n */\nexport function formDataPolicy(): PipelinePolicy {\n return {\n name: formDataPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (isNodeLike && typeof FormData !== \"undefined\" && request.body instanceof FormData) {\n request.formData = formDataToFormDataMap(request.body);\n request.body = undefined;\n }\n\n if (request.formData) {\n const contentType = request.headers.get(\"Content-Type\");\n if (contentType && contentType.indexOf(\"application/x-www-form-urlencoded\") !== -1) {\n request.body = wwwFormUrlEncode(request.formData);\n } else {\n await prepareFormData(request.formData, request);\n }\n\n request.formData = undefined;\n }\n return next(request);\n },\n };\n}\n\nfunction wwwFormUrlEncode(formData: FormDataMap): string {\n const urlSearchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(formData)) {\n if (Array.isArray(value)) {\n for (const subValue of value) {\n urlSearchParams.append(key, subValue.toString());\n }\n } else {\n urlSearchParams.append(key, value.toString());\n }\n }\n return urlSearchParams.toString();\n}\n\nasync function prepareFormData(formData: FormDataMap, request: PipelineRequest): Promise<void> {\n // validate content type (multipart/form-data)\n const contentType = request.headers.get(\"Content-Type\");\n if (contentType && !contentType.startsWith(\"multipart/form-data\")) {\n // content type is specified and is not multipart/form-data. Exit.\n return;\n }\n\n request.headers.set(\"Content-Type\", contentType ?? \"multipart/form-data\");\n\n // set body to MultipartRequestBody using content from FormDataMap\n const parts: BodyPart[] = [];\n\n for (const [fieldName, values] of Object.entries(formData)) {\n for (const value of Array.isArray(values) ? values : [values]) {\n if (typeof value === \"string\") {\n parts.push({\n headers: createHttpHeaders({\n \"Content-Disposition\": `form-data; name=\"${fieldName}\"`,\n }),\n body: stringToUint8Array(value, \"utf-8\"),\n });\n } else if (value === undefined || value === null || typeof value !== \"object\") {\n throw new Error(\n `Unexpected value for key ${fieldName}: ${value}. Value should be serialized to string first.`,\n );\n } else {\n // using || instead of ?? here since if value.name is empty we should create a file name\n const fileName = (value as File).name || \"blob\";\n const headers = createHttpHeaders();\n headers.set(\n \"Content-Disposition\",\n `form-data; name=\"${fieldName}\"; filename=\"${fileName}\"`,\n );\n\n // again, || is used since an empty value.type means the content type is unset\n headers.set(\"Content-Type\", value.type || \"application/octet-stream\");\n\n parts.push({\n headers,\n body: value,\n });\n }\n }\n }\n request.multipartBody = { parts };\n}\n"]}
|
|
@@ -11,8 +11,7 @@ export const logPolicyName = "logPolicy";
|
|
|
11
11
|
* @param options - Options to configure logPolicy.
|
|
12
12
|
*/
|
|
13
13
|
export function logPolicy(options = {}) {
|
|
14
|
-
|
|
15
|
-
const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : coreLogger.info;
|
|
14
|
+
const logger = options.logger ?? coreLogger.info;
|
|
16
15
|
const sanitizer = new Sanitizer({
|
|
17
16
|
additionalAllowedHeaderNames: options.additionalAllowedHeaderNames,
|
|
18
17
|
additionalAllowedQueryParameters: options.additionalAllowedQueryParameters,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logPolicy.js","sourceRoot":"","sources":["../../../src/policies/logPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AA4BzC;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,UAA4B,EAAE
|
|
1
|
+
{"version":3,"file":"logPolicy.js","sourceRoot":"","sources":["../../../src/policies/logPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;AA4BzC;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,UAA4B,EAAE;IACtD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC;QAC9B,4BAA4B,EAAE,OAAO,CAAC,4BAA4B;QAClE,gCAAgC,EAAE,OAAO,CAAC,gCAAgC;KAC3E,CAAC,CAAC;IACH,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YAED,MAAM,CAAC,YAAY,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAElD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;YAErC,MAAM,CAAC,yBAAyB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YACnD,MAAM,CAAC,YAAY,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAE3D,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Debugger } from \"../logger/logger.js\";\nimport type { PipelineRequest, PipelineResponse, SendRequest } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { logger as coreLogger } from \"../log.js\";\nimport { Sanitizer } from \"../util/sanitizer.js\";\n\n/**\n * The programmatic identifier of the logPolicy.\n */\nexport const logPolicyName = \"logPolicy\";\n\n/**\n * Options to configure the logPolicy.\n */\nexport interface LogPolicyOptions {\n /**\n * Header names whose values will be logged when logging is enabled.\n * Defaults include a list of well-known safe headers. Any headers\n * specified in this field will be added to that list. Any other values will\n * be written to logs as \"REDACTED\".\n */\n additionalAllowedHeaderNames?: string[];\n\n /**\n * Query string names whose values will be logged when logging is enabled. By default no\n * query string values are logged.\n */\n additionalAllowedQueryParameters?: string[];\n\n /**\n * The log function to use for writing pipeline logs.\n * Defaults to core-http's built-in logger.\n * Compatible with the `debug` library.\n */\n logger?: Debugger;\n}\n\n/**\n * A policy that logs all requests and responses.\n * @param options - Options to configure logPolicy.\n */\nexport function logPolicy(options: LogPolicyOptions = {}): PipelinePolicy {\n const logger = options.logger ?? coreLogger.info;\n const sanitizer = new Sanitizer({\n additionalAllowedHeaderNames: options.additionalAllowedHeaderNames,\n additionalAllowedQueryParameters: options.additionalAllowedQueryParameters,\n });\n return {\n name: logPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (!logger.enabled) {\n return next(request);\n }\n\n logger(`Request: ${sanitizer.sanitize(request)}`);\n\n const response = await next(request);\n\n logger(`Response status code: ${response.status}`);\n logger(`Headers: ${sanitizer.sanitize(response.headers)}`);\n\n return response;\n },\n };\n}\n"]}
|
|
@@ -78,7 +78,6 @@ export function multipartPolicy() {
|
|
|
78
78
|
return {
|
|
79
79
|
name: multipartPolicyName,
|
|
80
80
|
async sendRequest(request, next) {
|
|
81
|
-
var _a;
|
|
82
81
|
if (!request.multipartBody) {
|
|
83
82
|
return next(request);
|
|
84
83
|
}
|
|
@@ -86,7 +85,7 @@ export function multipartPolicy() {
|
|
|
86
85
|
throw new Error("multipartBody and regular body cannot be set at the same time");
|
|
87
86
|
}
|
|
88
87
|
let boundary = request.multipartBody.boundary;
|
|
89
|
-
const contentTypeHeader =
|
|
88
|
+
const contentTypeHeader = request.headers.get("Content-Type") ?? "multipart/mixed";
|
|
90
89
|
const parsedHeader = contentTypeHeader.match(/^(multipart\/[^ ;]+)(?:; *boundary=(.+))?$/);
|
|
91
90
|
if (!parsedHeader) {
|
|
92
91
|
throw new Error(`Got multipart request body, but content-type header was not multipart: ${contentTypeHeader}`);
|
|
@@ -95,7 +94,7 @@ export function multipartPolicy() {
|
|
|
95
94
|
if (parsedBoundary && boundary && parsedBoundary !== boundary) {
|
|
96
95
|
throw new Error(`Multipart boundary was specified as ${parsedBoundary} in the header, but got ${boundary} in the request body`);
|
|
97
96
|
}
|
|
98
|
-
boundary
|
|
97
|
+
boundary ??= parsedBoundary;
|
|
99
98
|
if (boundary) {
|
|
100
99
|
assertValidBoundary(boundary);
|
|
101
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multipartPolicy.js","sourceRoot":"","sources":["../../../src/policies/multipartPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,SAAS,gBAAgB;IACvB,OAAO,wBAAwB,UAAU,EAAE,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,aAAa,CAAC,OAAoB;IACzC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,GAAG,KAAK,KAAK,MAAM,CAAC;IACnC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,SAAS,CAChB,MAMyB;IAEzB,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,UAAU,CAAC;IAC3B,CAAC;SAAM,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,wEAAwE;QACxE,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,cAA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,CAAC;YAE9C,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,iBAAiB,CAAC;YACnF,MAAM,YAAY,GAAG,iBAAiB,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAC3F,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,MAAM,IAAI,KAAK,CACb,0EAA0E,iBAAiB,EAAE,CAC9F,CAAC;YACJ,CAAC;YAED,MAAM,CAAC,EAAE,WAAW,EAAE,cAAc,CAAC,GAAG,YAAY,CAAC;YACrD,IAAI,cAAc,IAAI,QAAQ,IAAI,cAAc,KAAK,QAAQ,EAAE,CAAC;gBAC9D,MAAM,IAAI,KAAK,CACb,uCAAuC,cAAc,2BAA2B,QAAQ,sBAAsB,CAC/G,CAAC;YACJ,CAAC;YAED,QAAQ,KAAK,cAAc,CAAC;YAC5B,IAAI,QAAQ,EAAE,CAAC;gBACb,mBAAmB,CAAC,QAAQ,CAAC,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACN,QAAQ,GAAG,gBAAgB,EAAE,CAAC;YAChC,CAAC;YACD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,WAAW,cAAc,QAAQ,EAAE,CAAC,CAAC;YAC5E,MAAM,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAEvE,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;YAElC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { BodyPart, HttpHeaders, PipelineRequest, PipelineResponse } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { stringToUint8Array } from \"../util/bytesEncoding.js\";\nimport { isBlob } from \"../util/typeGuards.js\";\nimport { randomUUID } from \"../util/uuidUtils.js\";\nimport { concat } from \"../util/concat.js\";\n\nfunction generateBoundary(): string {\n return `----AzSDKFormBoundary${randomUUID()}`;\n}\n\nfunction encodeHeaders(headers: HttpHeaders): string {\n let result = \"\";\n for (const [key, value] of headers) {\n result += `${key}: ${value}\\r\\n`;\n }\n return result;\n}\n\nfunction getLength(\n source:\n | (() => ReadableStream<Uint8Array>)\n | (() => NodeJS.ReadableStream)\n | Uint8Array\n | Blob\n | ReadableStream\n | NodeJS.ReadableStream,\n): number | undefined {\n if (source instanceof Uint8Array) {\n return source.byteLength;\n } else if (isBlob(source)) {\n // if was created using createFile then -1 means we have an unknown size\n return source.size === -1 ? undefined : source.size;\n } else {\n return undefined;\n }\n}\n\nfunction getTotalLength(\n sources: (\n | (() => ReadableStream<Uint8Array>)\n | (() => NodeJS.ReadableStream)\n | Uint8Array\n | Blob\n | ReadableStream\n | NodeJS.ReadableStream\n )[],\n): number | undefined {\n let total = 0;\n for (const source of sources) {\n const partLength = getLength(source);\n if (partLength === undefined) {\n return undefined;\n } else {\n total += partLength;\n }\n }\n return total;\n}\n\nasync function buildRequestBody(\n request: PipelineRequest,\n parts: BodyPart[],\n boundary: string,\n): Promise<void> {\n const sources = [\n stringToUint8Array(`--${boundary}`, \"utf-8\"),\n ...parts.flatMap((part) => [\n stringToUint8Array(\"\\r\\n\", \"utf-8\"),\n stringToUint8Array(encodeHeaders(part.headers), \"utf-8\"),\n stringToUint8Array(\"\\r\\n\", \"utf-8\"),\n part.body,\n stringToUint8Array(`\\r\\n--${boundary}`, \"utf-8\"),\n ]),\n stringToUint8Array(\"--\\r\\n\\r\\n\", \"utf-8\"),\n ];\n\n const contentLength = getTotalLength(sources);\n if (contentLength) {\n request.headers.set(\"Content-Length\", contentLength);\n }\n\n request.body = await concat(sources);\n}\n\n/**\n * Name of multipart policy\n */\nexport const multipartPolicyName = \"multipartPolicy\";\n\nconst maxBoundaryLength = 70;\nconst validBoundaryCharacters = new Set(\n `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'()+,-./:=?`,\n);\n\nfunction assertValidBoundary(boundary: string): void {\n if (boundary.length > maxBoundaryLength) {\n throw new Error(`Multipart boundary \"${boundary}\" exceeds maximum length of 70 characters`);\n }\n\n if (Array.from(boundary).some((x) => !validBoundaryCharacters.has(x))) {\n throw new Error(`Multipart boundary \"${boundary}\" contains invalid characters`);\n }\n}\n\n/**\n * Pipeline policy for multipart requests\n */\nexport function multipartPolicy(): PipelinePolicy {\n return {\n name: multipartPolicyName,\n async sendRequest(request, next): Promise<PipelineResponse> {\n if (!request.multipartBody) {\n return next(request);\n }\n\n if (request.body) {\n throw new Error(\"multipartBody and regular body cannot be set at the same time\");\n }\n\n let boundary = request.multipartBody.boundary;\n\n const contentTypeHeader = request.headers.get(\"Content-Type\") ?? \"multipart/mixed\";\n const parsedHeader = contentTypeHeader.match(/^(multipart\\/[^ ;]+)(?:; *boundary=(.+))?$/);\n if (!parsedHeader) {\n throw new Error(\n `Got multipart request body, but content-type header was not multipart: ${contentTypeHeader}`,\n );\n }\n\n const [, contentType, parsedBoundary] = parsedHeader;\n if (parsedBoundary && boundary && parsedBoundary !== boundary) {\n throw new Error(\n `Multipart boundary was specified as ${parsedBoundary} in the header, but got ${boundary} in the request body`,\n );\n }\n\n boundary ??= parsedBoundary;\n if (boundary) {\n assertValidBoundary(boundary);\n } else {\n boundary = generateBoundary();\n }\n request.headers.set(\"Content-Type\", `${contentType}; boundary=${boundary}`);\n await buildRequestBody(request, request.multipartBody.parts, boundary);\n\n request.multipartBody = undefined;\n\n return next(request);\n },\n };\n}\n"]}
|
|
@@ -47,7 +47,7 @@ function isBypassed(uri, noProxyList, bypassedMap) {
|
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
49
|
const host = new URL(uri).hostname;
|
|
50
|
-
if (bypassedMap
|
|
50
|
+
if (bypassedMap?.has(host)) {
|
|
51
51
|
return bypassedMap.get(host);
|
|
52
52
|
}
|
|
53
53
|
let isBypassedFlag = false;
|
|
@@ -70,7 +70,7 @@ function isBypassed(uri, noProxyList, bypassedMap) {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
bypassedMap
|
|
73
|
+
bypassedMap?.set(host, isBypassedFlag);
|
|
74
74
|
return isBypassedFlag;
|
|
75
75
|
}
|
|
76
76
|
export function loadNoProxy() {
|
|
@@ -120,7 +120,7 @@ function getUrlFromProxySettings(settings) {
|
|
|
120
120
|
try {
|
|
121
121
|
parsedProxyUrl = new URL(settings.host);
|
|
122
122
|
}
|
|
123
|
-
catch
|
|
123
|
+
catch {
|
|
124
124
|
throw new Error(`Expecting a valid host string in proxy settings, but found "${settings.host}".`);
|
|
125
125
|
}
|
|
126
126
|
parsedProxyUrl.port = String(settings.port);
|
|
@@ -175,10 +175,9 @@ export function proxyPolicy(proxySettings, options) {
|
|
|
175
175
|
return {
|
|
176
176
|
name: proxyPolicyName,
|
|
177
177
|
async sendRequest(request, next) {
|
|
178
|
-
var _a;
|
|
179
178
|
if (!request.proxySettings &&
|
|
180
179
|
defaultProxy &&
|
|
181
|
-
!isBypassed(request.url,
|
|
180
|
+
!isBypassed(request.url, options?.customNoProxyList ?? globalNoProxyList, options?.customNoProxyList ? undefined : globalBypassedMap)) {
|
|
182
181
|
setProxyAgentOnRequest(request, cachedAgents, defaultProxy);
|
|
183
182
|
}
|
|
184
183
|
else if (request.proxySettings) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxyPolicy.js","sourceRoot":"","sources":["../../../src/policies/proxyPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQlD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,MAAM,U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M,UAAU,WAAW,CACzB,aAA6B,EAC7B,OAGC;IAED,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,iBAAiB,CAAC,IAAI,CAAC,GAAG,WAAW,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,YAAY,GAAG,aAAa;QAChC,CAAC,CAAC,uBAAuB,CAAC,aAAa,CAAC;QACxC,CAAC,CAAC,+BAA+B,EAAE,CAAC;IAEtC,MAAM,YAAY,GAAiB,EAAE,CAAC;IAEtC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;;YAC3D,IACE,CAAC,OAAO,CAAC,aAAa;gBACtB,YAAY;gBACZ,CAAC,UAAU,CACT,OAAO,CAAC,GAAG,EACX,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,mCAAI,iBAAiB,EAC/C,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAC3D,EACD,CAAC;gBACD,sBAAsB,CAAC,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;YAC9D,CAAC;iBAAM,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;gBACjC,sBAAsB,CACpB,OAAO,EACP,YAAY,EACZ,uBAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAC/C,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type * as http from \"http\";\nimport type * as https from \"https\";\nimport { HttpsProxyAgent } from \"https-proxy-agent\";\nimport { HttpProxyAgent } from \"http-proxy-agent\";\nimport type {\n PipelineRequest,\n PipelineResponse,\n ProxySettings,\n SendRequest,\n} from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { logger } from \"../log.js\";\n\nconst HTTPS_PROXY = \"HTTPS_PROXY\";\nconst HTTP_PROXY = \"HTTP_PROXY\";\nconst ALL_PROXY = \"ALL_PROXY\";\nconst NO_PROXY = \"NO_PROXY\";\n\n/**\n * The programmatic identifier of the proxyPolicy.\n */\nexport const proxyPolicyName = \"proxyPolicy\";\n\n/**\n * Stores the patterns specified in NO_PROXY environment variable.\n * @internal\n */\nexport const globalNoProxyList: string[] = [];\nlet noProxyListLoaded: boolean = false;\n\n/** A cache of whether a host should bypass the proxy. */\nconst globalBypassedMap: Map<string, boolean> = new Map();\n\nfunction getEnvironmentValue(name: string): string | undefined {\n if (process.env[name]) {\n return process.env[name];\n } else if (process.env[name.toLowerCase()]) {\n return process.env[name.toLowerCase()];\n }\n return undefined;\n}\n\nfunction loadEnvironmentProxyValue(): string | undefined {\n if (!process) {\n return undefined;\n }\n\n const httpsProxy = getEnvironmentValue(HTTPS_PROXY);\n const allProxy = getEnvironmentValue(ALL_PROXY);\n const httpProxy = getEnvironmentValue(HTTP_PROXY);\n\n return httpsProxy || allProxy || httpProxy;\n}\n\n/**\n * Check whether the host of a given `uri` matches any pattern in the no proxy list.\n * If there's a match, any request sent to the same host shouldn't have the proxy settings set.\n * 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\n */\nfunction isBypassed(\n uri: string,\n noProxyList: string[],\n bypassedMap?: Map<string, boolean>,\n): boolean | undefined {\n if (noProxyList.length === 0) {\n return false;\n }\n const host = new URL(uri).hostname;\n if (bypassedMap?.has(host)) {\n return bypassedMap.get(host);\n }\n let isBypassedFlag = false;\n for (const pattern of noProxyList) {\n if (pattern[0] === \".\") {\n // This should match either domain it self or any subdomain or host\n // .foo.com will match foo.com it self or *.foo.com\n if (host.endsWith(pattern)) {\n isBypassedFlag = true;\n } else {\n if (host.length === pattern.length - 1 && host === pattern.slice(1)) {\n isBypassedFlag = true;\n }\n }\n } else {\n if (host === pattern) {\n isBypassedFlag = true;\n }\n }\n }\n bypassedMap?.set(host, isBypassedFlag);\n return isBypassedFlag;\n}\n\nexport function loadNoProxy(): string[] {\n const noProxy = getEnvironmentValue(NO_PROXY);\n noProxyListLoaded = true;\n if (noProxy) {\n return noProxy\n .split(\",\")\n .map((item) => item.trim())\n .filter((item) => item.length);\n }\n\n return [];\n}\n\n/**\n * This method converts a proxy url into `ProxySettings` for use with ProxyPolicy.\n * If no argument is given, it attempts to parse a proxy URL from the environment\n * variables `HTTPS_PROXY` or `HTTP_PROXY`.\n * @param proxyUrl - The url of the proxy to use. May contain authentication information.\n * @deprecated - Internally this method is no longer necessary when setting proxy information.\n */\nexport function getDefaultProxySettings(proxyUrl?: string): ProxySettings | undefined {\n if (!proxyUrl) {\n proxyUrl = loadEnvironmentProxyValue();\n if (!proxyUrl) {\n return undefined;\n }\n }\n\n const parsedUrl = new URL(proxyUrl);\n const schema = parsedUrl.protocol ? parsedUrl.protocol + \"//\" : \"\";\n return {\n host: schema + parsedUrl.hostname,\n port: Number.parseInt(parsedUrl.port || \"80\"),\n username: parsedUrl.username,\n password: parsedUrl.password,\n };\n}\n\n/**\n * This method attempts to parse a proxy URL from the environment\n * variables `HTTPS_PROXY` or `HTTP_PROXY`.\n */\nfunction getDefaultProxySettingsInternal(): URL | undefined {\n const envProxy = loadEnvironmentProxyValue();\n return envProxy ? new URL(envProxy) : undefined;\n}\n\nfunction getUrlFromProxySettings(settings: ProxySettings): URL {\n let parsedProxyUrl: URL;\n try {\n parsedProxyUrl = new URL(settings.host);\n } catch {\n throw new Error(\n `Expecting a valid host string in proxy settings, but found \"${settings.host}\".`,\n );\n }\n\n parsedProxyUrl.port = String(settings.port);\n if (settings.username) {\n parsedProxyUrl.username = settings.username;\n }\n if (settings.password) {\n parsedProxyUrl.password = settings.password;\n }\n\n return parsedProxyUrl;\n}\n\nfunction setProxyAgentOnRequest(\n request: PipelineRequest,\n cachedAgents: CachedAgents,\n proxyUrl: URL,\n): void {\n // Custom Agent should take precedence so if one is present\n // we should skip to avoid overwriting it.\n if (request.agent) {\n return;\n }\n\n const url = new URL(request.url);\n\n const isInsecure = url.protocol !== \"https:\";\n\n if (request.tlsSettings) {\n logger.warning(\n \"TLS settings are not supported in combination with custom Proxy, certificates provided to the client will be ignored.\",\n );\n }\n\n const headers = request.headers.toJSON();\n\n if (isInsecure) {\n if (!cachedAgents.httpProxyAgent) {\n cachedAgents.httpProxyAgent = new HttpProxyAgent(proxyUrl, { headers });\n }\n request.agent = cachedAgents.httpProxyAgent;\n } else {\n if (!cachedAgents.httpsProxyAgent) {\n cachedAgents.httpsProxyAgent = new HttpsProxyAgent(proxyUrl, { headers });\n }\n request.agent = cachedAgents.httpsProxyAgent;\n }\n}\n\ninterface CachedAgents {\n httpsProxyAgent?: https.Agent;\n httpProxyAgent?: http.Agent;\n}\n\n/**\n * A policy that allows one to apply proxy settings to all requests.\n * If not passed static settings, they will be retrieved from the HTTPS_PROXY\n * or HTTP_PROXY environment variables.\n * @param proxySettings - ProxySettings to use on each request.\n * @param options - additional settings, for example, custom NO_PROXY patterns\n */\nexport function proxyPolicy(\n proxySettings?: ProxySettings,\n options?: {\n /** a list of patterns to override those loaded from NO_PROXY environment variable. */\n customNoProxyList?: string[];\n },\n): PipelinePolicy {\n if (!noProxyListLoaded) {\n globalNoProxyList.push(...loadNoProxy());\n }\n\n const defaultProxy = proxySettings\n ? getUrlFromProxySettings(proxySettings)\n : getDefaultProxySettingsInternal();\n\n const cachedAgents: CachedAgents = {};\n\n return {\n name: proxyPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (\n !request.proxySettings &&\n defaultProxy &&\n !isBypassed(\n request.url,\n options?.customNoProxyList ?? globalNoProxyList,\n options?.customNoProxyList ? undefined : globalBypassedMap,\n )\n ) {\n setProxyAgentOnRequest(request, cachedAgents, defaultProxy);\n } else if (request.proxySettings) {\n setProxyAgentOnRequest(\n request,\n cachedAgents,\n getUrlFromProxySettings(request.proxySettings),\n );\n }\n return next(request);\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"proxyPolicy.js","sourceRoot":"","sources":["../../../src/policies/proxyPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAQlD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,MAAM,QAAQ,GAAG,UAAU,CAAC;AAE5B;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAa,EAAE,CAAC;AAC9C,IAAI,iBAAiB,GAAY,KAAK,CAAC;AAEvC,yDAAyD;AACzD,MAAM,iBAAiB,GAAyB,IAAI,GAAG,EAAE,CAAC;AAE1D,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;SAAM,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;QAC3C,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,yBAAyB;IAChC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,UAAU,GAAG,mBAAmB,CAA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C,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type * as http from \"http\";\nimport type * as https from \"https\";\nimport { HttpsProxyAgent } from \"https-proxy-agent\";\nimport { HttpProxyAgent } from \"http-proxy-agent\";\nimport type {\n PipelineRequest,\n PipelineResponse,\n ProxySettings,\n SendRequest,\n} from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { logger } from \"../log.js\";\n\nconst HTTPS_PROXY = \"HTTPS_PROXY\";\nconst HTTP_PROXY = \"HTTP_PROXY\";\nconst ALL_PROXY = \"ALL_PROXY\";\nconst NO_PROXY = \"NO_PROXY\";\n\n/**\n * The programmatic identifier of the proxyPolicy.\n */\nexport const proxyPolicyName = \"proxyPolicy\";\n\n/**\n * Stores the patterns specified in NO_PROXY environment variable.\n * @internal\n */\nexport const globalNoProxyList: string[] = [];\nlet noProxyListLoaded: boolean = false;\n\n/** A cache of whether a host should bypass the proxy. */\nconst globalBypassedMap: Map<string, boolean> = new Map();\n\nfunction getEnvironmentValue(name: string): string | undefined {\n if (process.env[name]) {\n return process.env[name];\n } else if (process.env[name.toLowerCase()]) {\n return process.env[name.toLowerCase()];\n }\n return undefined;\n}\n\nfunction loadEnvironmentProxyValue(): string | undefined {\n if (!process) {\n return undefined;\n }\n\n const httpsProxy = getEnvironmentValue(HTTPS_PROXY);\n const allProxy = getEnvironmentValue(ALL_PROXY);\n const httpProxy = getEnvironmentValue(HTTP_PROXY);\n\n return httpsProxy || allProxy || httpProxy;\n}\n\n/**\n * Check whether the host of a given `uri` matches any pattern in the no proxy list.\n * If there's a match, any request sent to the same host shouldn't have the proxy settings set.\n * 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\n */\nfunction isBypassed(\n uri: string,\n noProxyList: string[],\n bypassedMap?: Map<string, boolean>,\n): boolean | undefined {\n if (noProxyList.length === 0) {\n return false;\n }\n const host = new URL(uri).hostname;\n if (bypassedMap?.has(host)) {\n return bypassedMap.get(host);\n }\n let isBypassedFlag = false;\n for (const pattern of noProxyList) {\n if (pattern[0] === \".\") {\n // This should match either domain it self or any subdomain or host\n // .foo.com will match foo.com it self or *.foo.com\n if (host.endsWith(pattern)) {\n isBypassedFlag = true;\n } else {\n if (host.length === pattern.length - 1 && host === pattern.slice(1)) {\n isBypassedFlag = true;\n }\n }\n } else {\n if (host === pattern) {\n isBypassedFlag = true;\n }\n }\n }\n bypassedMap?.set(host, isBypassedFlag);\n return isBypassedFlag;\n}\n\nexport function loadNoProxy(): string[] {\n const noProxy = getEnvironmentValue(NO_PROXY);\n noProxyListLoaded = true;\n if (noProxy) {\n return noProxy\n .split(\",\")\n .map((item) => item.trim())\n .filter((item) => item.length);\n }\n\n return [];\n}\n\n/**\n * This method converts a proxy url into `ProxySettings` for use with ProxyPolicy.\n * If no argument is given, it attempts to parse a proxy URL from the environment\n * variables `HTTPS_PROXY` or `HTTP_PROXY`.\n * @param proxyUrl - The url of the proxy to use. May contain authentication information.\n * @deprecated - Internally this method is no longer necessary when setting proxy information.\n */\nexport function getDefaultProxySettings(proxyUrl?: string): ProxySettings | undefined {\n if (!proxyUrl) {\n proxyUrl = loadEnvironmentProxyValue();\n if (!proxyUrl) {\n return undefined;\n }\n }\n\n const parsedUrl = new URL(proxyUrl);\n const schema = parsedUrl.protocol ? parsedUrl.protocol + \"//\" : \"\";\n return {\n host: schema + parsedUrl.hostname,\n port: Number.parseInt(parsedUrl.port || \"80\"),\n username: parsedUrl.username,\n password: parsedUrl.password,\n };\n}\n\n/**\n * This method attempts to parse a proxy URL from the environment\n * variables `HTTPS_PROXY` or `HTTP_PROXY`.\n */\nfunction getDefaultProxySettingsInternal(): URL | undefined {\n const envProxy = loadEnvironmentProxyValue();\n return envProxy ? new URL(envProxy) : undefined;\n}\n\nfunction getUrlFromProxySettings(settings: ProxySettings): URL {\n let parsedProxyUrl: URL;\n try {\n parsedProxyUrl = new URL(settings.host);\n } catch {\n throw new Error(\n `Expecting a valid host string in proxy settings, but found \"${settings.host}\".`,\n );\n }\n\n parsedProxyUrl.port = String(settings.port);\n if (settings.username) {\n parsedProxyUrl.username = settings.username;\n }\n if (settings.password) {\n parsedProxyUrl.password = settings.password;\n }\n\n return parsedProxyUrl;\n}\n\nfunction setProxyAgentOnRequest(\n request: PipelineRequest,\n cachedAgents: CachedAgents,\n proxyUrl: URL,\n): void {\n // Custom Agent should take precedence so if one is present\n // we should skip to avoid overwriting it.\n if (request.agent) {\n return;\n }\n\n const url = new URL(request.url);\n\n const isInsecure = url.protocol !== \"https:\";\n\n if (request.tlsSettings) {\n logger.warning(\n \"TLS settings are not supported in combination with custom Proxy, certificates provided to the client will be ignored.\",\n );\n }\n\n const headers = request.headers.toJSON();\n\n if (isInsecure) {\n if (!cachedAgents.httpProxyAgent) {\n cachedAgents.httpProxyAgent = new HttpProxyAgent(proxyUrl, { headers });\n }\n request.agent = cachedAgents.httpProxyAgent;\n } else {\n if (!cachedAgents.httpsProxyAgent) {\n cachedAgents.httpsProxyAgent = new HttpsProxyAgent(proxyUrl, { headers });\n }\n request.agent = cachedAgents.httpsProxyAgent;\n }\n}\n\ninterface CachedAgents {\n httpsProxyAgent?: https.Agent;\n httpProxyAgent?: http.Agent;\n}\n\n/**\n * A policy that allows one to apply proxy settings to all requests.\n * If not passed static settings, they will be retrieved from the HTTPS_PROXY\n * or HTTP_PROXY environment variables.\n * @param proxySettings - ProxySettings to use on each request.\n * @param options - additional settings, for example, custom NO_PROXY patterns\n */\nexport function proxyPolicy(\n proxySettings?: ProxySettings,\n options?: {\n /** a list of patterns to override those loaded from NO_PROXY environment variable. */\n customNoProxyList?: string[];\n },\n): PipelinePolicy {\n if (!noProxyListLoaded) {\n globalNoProxyList.push(...loadNoProxy());\n }\n\n const defaultProxy = proxySettings\n ? getUrlFromProxySettings(proxySettings)\n : getDefaultProxySettingsInternal();\n\n const cachedAgents: CachedAgents = {};\n\n return {\n name: proxyPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (\n !request.proxySettings &&\n defaultProxy &&\n !isBypassed(\n request.url,\n options?.customNoProxyList ?? globalNoProxyList,\n options?.customNoProxyList ? undefined : globalBypassedMap,\n )\n ) {\n setProxyAgentOnRequest(request, cachedAgents, defaultProxy);\n } else if (request.proxySettings) {\n setProxyAgentOnRequest(\n request,\n cachedAgents,\n getUrlFromProxySettings(request.proxySettings),\n );\n }\n return next(request);\n },\n };\n}\n"]}
|
|
@@ -17,7 +17,6 @@ export function retryPolicy(strategies, options = { maxRetries: DEFAULT_RETRY_PO
|
|
|
17
17
|
return {
|
|
18
18
|
name: retryPolicyName,
|
|
19
19
|
async sendRequest(request, next) {
|
|
20
|
-
var _a, _b;
|
|
21
20
|
let response;
|
|
22
21
|
let responseError;
|
|
23
22
|
let retryCount = -1;
|
|
@@ -41,12 +40,12 @@ export function retryPolicy(strategies, options = { maxRetries: DEFAULT_RETRY_PO
|
|
|
41
40
|
}
|
|
42
41
|
response = responseError.response;
|
|
43
42
|
}
|
|
44
|
-
if (
|
|
43
|
+
if (request.abortSignal?.aborted) {
|
|
45
44
|
logger.error(`Retry ${retryCount}: Request aborted.`);
|
|
46
45
|
const abortError = new AbortError();
|
|
47
46
|
throw abortError;
|
|
48
47
|
}
|
|
49
|
-
if (retryCount >= (
|
|
48
|
+
if (retryCount >= (options.maxRetries ?? DEFAULT_RETRY_POLICY_COUNT)) {
|
|
50
49
|
logger.info(`Retry ${retryCount}: Maximum retries reached. Returning the last received response, or throwing the last received error.`);
|
|
51
50
|
if (responseError) {
|
|
52
51
|
throw responseError;
|