mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-07-18 12:38:24 +02:00
feat: add @actions/cache
This commit is contained in:
parent
b15fb7d098
commit
16e8c96a41
1932 changed files with 261172 additions and 10 deletions
262
node_modules/@azure/core-http/CHANGELOG.md
generated
vendored
Normal file
262
node_modules/@azure/core-http/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
# Release History
|
||||
|
||||
## 2.2.5 (2022-05-05)
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
- Fix an issue where React-Native is loading the wrong file. Adding a `react-native` mapping to point to the ESM entrypoint file. [PR #21118](https://github.com/Azure/azure-sdk-for-js/pull/21118)
|
||||
- delay creating XML parser/builder objects so that packages not requiring XML functionality but running on platforms lacking XML support can still load this package. [PR #21118](https://github.com/Azure/azure-sdk-for-js/pull/21118)
|
||||
- Add a `react-native` mapping to use `xml2js` as it is already in our dependency list. Customer can get it to work after installing `stream` and `timers` packages in their React-Native project.
|
||||
- Fix a run-time error in user agent policy when running in React-Native.
|
||||
|
||||
## 2.2.4 (2022-02-03)
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
- Updated the HTTP tracing span names to conform to the [OpenTelemetry Specification](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/http.md#name). [#19838](https://github.com/Azure/azure-sdk-for-js/pull/19838)
|
||||
- New HTTP spans will use the `HTTP <VERB>` convention instead of using the URL path.
|
||||
|
||||
## 2.2.3 (2022-01-06)
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
- Fix `HttpHeaders.rawHeaders()` to preserve header name case. As a result HttpClient now sends requests with their original header names. `HttpHeaders.toJson()` now has an option to preserve header key casing.
|
||||
|
||||
### Other Changes
|
||||
|
||||
- Update dependency `node-fetch` version to `2.6.6` to address advisory [CVE-2020-15168](https://github.com/advisories/GHSA-w7rc-rwvf-8q5r)
|
||||
|
||||
## 2.2.2 (2021-11-03)
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
- Fix the issue of `HttpHeaders.clone()` not preserving raw header names' casing [PR #18348](https://github.com/Azure/azure-sdk-for-js/pull/18348)
|
||||
- Fix the issue of network connection not being closed when download stream is closed [PR #14015](https://github.com/Azure/azure-sdk-for-js/pull/14015)
|
||||
|
||||
## 2.2.1 (2021-09-30)
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
- Fix incorrect caching of proxy agents [PR #17546](https://github.com/Azure/azure-sdk-for-js/pull/17546)
|
||||
|
||||
## 2.2.0 (2021-09-02)
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
- `tracingPolicy` will no longer propagate tracing errors to the caller, and such errors will be logged instead and the operation does not get interrupted. [PR #16916](https://github.com/Azure/azure-sdk-for-js/pull/16916)
|
||||
|
||||
## 2.1.0 (2021-07-22)
|
||||
|
||||
### Features Added
|
||||
|
||||
- `tracingPolicy` will no longer inject invalid traceparent headers if an incorrect tracer implementation is used.
|
||||
- `proxyPolicy` now allows passing in a list of no-proxy patterns to override global ones loaded from NO_PROXY environment variable [PR #16414](https://github.com/Azure/azure-sdk-for-js/pull/16414)
|
||||
|
||||
## 2.0.0 (2021-06-30)
|
||||
|
||||
### Features Added
|
||||
|
||||
- Changed TS compilation target to ES2017 in order to produce smaller bundles and use more native platform features.
|
||||
- Added support for the `Retry-After` header on responses with status code 503, Service Unavailable.
|
||||
- Added support for multiple retries on the `ThrottlingRetryPolicy` (up to 3 by default).
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- Updated @azure/core-tracing to version `1.0.0-preview.12`. See [@azure/core-tracing CHANGELOG](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-tracing/CHANGELOG.md) for details about breaking changes with tracing.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed an issue where `proxySettings` does not work when there is username but no password [Issue 15720](https://github.com/Azure/azure-sdk-for-js/issues/15720)
|
||||
- Throttling retry policy respects abort signal [#15796](https://github.com/Azure/azure-sdk-for-js/issues/15796)
|
||||
|
||||
## 1.2.6 (2021-06-14)
|
||||
|
||||
### Key Bugs Fixed
|
||||
|
||||
- Fixed an issue of lost properties when flattening array in deserialization [issue 15653](https://github.com/azure/azure-sdk-for-js/issues/15653)
|
||||
- Fixed an issue of incorrect minimum version of tslib [issue 15697](https://github.com/Azure/azure-sdk-for-js/issues/15697)
|
||||
|
||||
## 1.2.5 (2021-06-03)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Delay loading of NO_PROXY environment variable until when request pipeline is being created. This fixes [issue 14873](https://github.com/Azure/azure-sdk-for-js/issues/14873)
|
||||
- Fixed an issue where tracing spans were not setting a status correctly (on success or error) which results in the span status being `UNSET`. In addition, we will now capture the HTTP status code when a request fails in the tracing span. [PR 15061](https://github.com/Azure/azure-sdk-for-js/pull/15061)
|
||||
- Fix packaging issue [PR 15286](https://github.com/Azure/azure-sdk-for-js/pull/15286)
|
||||
- Improve the sanitizer to handle recursive objects [PR 15426](https://github.com/Azure/azure-sdk-for-js/pull/15426)
|
||||
|
||||
## 1.2.4 (2021-03-30)
|
||||
|
||||
- Rewrote `bearerTokenAuthenticationPolicy` to use a new backend that refreshes tokens only when they're about to expire and not multiple times before. This fixes the issue: [13369](https://github.com/Azure/azure-sdk-for-js/issues/13369).
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- Updated @azure/core-tracing to version `1.0.0-preview.11`. See [@azure/core-tracing CHANGELOG](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-tracing/CHANGELOG.md) for details about breaking changes with tracing.
|
||||
|
||||
## 1.2.3 (2021-02-04)
|
||||
|
||||
- Don't set a default content-type when there is no request body. [PR 13233](https://github.com/Azure/azure-sdk-for-js/pull/13233)
|
||||
- Clean up abort event handler properly for streaming operations. Fixed [issue 12029](https://github.com/Azure/azure-sdk-for-js/issues/12029)
|
||||
- Reduce memory usage of the cache in proxy policy. Fixed [issue 13277](https://github.com/Azure/azure-sdk-for-js/issues/13277)
|
||||
- Fix an issue where non-streaming response body was treated as stream [PR 13192](https://github.com/Azure/azure-sdk-for-js/pull/13192)
|
||||
- Browser XML parser now lazily load parser error namespace into cache. Fixed [issue 13268](https://github.com/Azure/azure-sdk-for-js/issues/13268)
|
||||
- Add ms-cv header used as correlation vector (used for distributed tracing) to list of non-redacted headers so that clients can share this header for debugging purposes. [PR 13541](https://github.com/Azure/azure-sdk-for-js/pull/13541)
|
||||
|
||||
## 1.2.2 (2021-01-07)
|
||||
|
||||
- Cache the default `HttpClient` used when one isn't passed in to `ServiceClient`. This means that for most packages we will only create a single `HttpClient`, which will improve platform resource usage by reducing overhead. [PR 12966](https://github.com/Azure/azure-sdk-for-js/pull/12966)
|
||||
|
||||
## 1.2.1 (2020-12-09)
|
||||
|
||||
- Support custom auth scopes. Scope is a mechanism in OAuth 2.0 to limit an application's access to a user's account [PR 12752](https://github.com/Azure/azure-sdk-for-js/pull/12752)
|
||||
- Add helper function `createSpan` to help in the creation of tracing spans in Track2 libraries [PR 12525](https://github.com/Azure/azure-sdk-for-js/pull/12525)
|
||||
|
||||
## 1.2.0 (2020-11-05)
|
||||
|
||||
- Explicitly set `manual` redirect handling for node fetch. And fixing redirectPipeline [PR 11863](https://github.com/Azure/azure-sdk-for-js/pull/11863)
|
||||
- Add support for multiple error response codes. [PR 11841](https://github.com/Azure/azure-sdk-for-js/)
|
||||
- Allow customizing serializer behavior via optional `SerialzierOptions` parameters. Particularly allow using a different `XML_CHARKEY` than the default `_` when parsing XML [PR 12065](https://github.com/Azure/azure-sdk-for-js/pull/12065)
|
||||
- Unexpected status code is now handled as an error if a mapper is not provided for it [PR 12153](https://github.com/Azure/azure-sdk-for-js/pull/12153)
|
||||
- Empty collection is now serialized correctly for `multi` format query parameters [PR 12090](https://github.com/Azure/azure-sdk-for-js/pull/12090)
|
||||
- De-serialize error from parsed object before trying to use its `code` and `message` properties [PR 12150](https://github.com/Azure/azure-sdk-for-js/pull/12150)
|
||||
- Fix an error thrown on older versions of Safari [PR 11759](https://github.com/Azure/azure-sdk-for-js/pull/11759)
|
||||
|
||||
## 1.1.9 (2020-09-30)
|
||||
|
||||
- Add support for XML namespaces in deserialization [PR 11201](https://github.com/Azure/azure-sdk-for-js/pull/11201)
|
||||
|
||||
- Add support for NDJSON format [PR 11325](https://github.com/Azure/azure-sdk-for-js/pull/11325)
|
||||
|
||||
- Add support for `NO_PROXY` and `ALL_PROXY` environment variables [PR 7069](https://github.com/Azure/azure-sdk-for-js/pull/7069)
|
||||
|
||||
- Serializer now resolves `additionalProperties` correctly from referenced mapper [PR 11473](https://github.com/Azure/azure-sdk-for-js/pull/11473)
|
||||
|
||||
- Empty wrapped XML element lists are no properly de-serialized. This fixes [issue 11071](https://github.com/Azure/azure-sdk-for-js/issues/11071)
|
||||
|
||||
## 1.1.8 (2020-09-08)
|
||||
|
||||
- `URLQuery` parsing now accepts `=` in query parameter values and no longer drops such query parameter name/value pairs. This fixes [issue 11014](https://github.com/Azure/azure-sdk-for-js/issues/11014)
|
||||
|
||||
## 1.1.7 (2020-09-02)
|
||||
|
||||
- `BearerTokenAuthenticationPolicy` now starts trying to refresh the token 30 seconds before the token expires. It will only try to refresh said token on each request when refreshing is not in progress. In the mean time, requests will use the existing token. This fixes [issue 10084](https://github.com/Azure/azure-sdk-for-js/issues/10084).
|
||||
- Un-export the `{...}Policy` classes that were meant to be internal to `@azure/core-http`. [PR 10738](https://github.com/Azure/azure-sdk-for-js/pull/10738)
|
||||
|
||||
## 1.1.6 (2020-08-04)
|
||||
|
||||
- Update dependencies `@azure/core-tracing` to version 1.0.0-preview.9 and `@opentelemetry/api` to version 0.10.2 [PR 10393](https://github.com/Azure/azure-sdk-for-js/pull/10393)
|
||||
|
||||
## 1.1.5 (2020-08-04)
|
||||
|
||||
- The global `fetch()` is no longer overridden by node-fetch. This fixed an issue impacting Electron render process. [PR #9880](https://github.com/Azure/azure-sdk-for-js/pull/9880)
|
||||
|
||||
## 1.1.4 (2020-07-02)
|
||||
|
||||
- Fix issue with flattened model serialization, where constant properties are being dropped [PR #8658](https://github.com/Azure/azure-sdk-for-js/pull/8658)
|
||||
- Switch to use `x-ms-useragent` header key for passing user agent info in browsers [PR #9490](https://github.com/Azure/azure-sdk-for-js/pull/9490)
|
||||
- Refactor `ExponentialRetryPolicy` and `SystemErrorRetryPolicy` to share common code [PR #9667](https://github.com/Azure/azure-sdk-for-js/pull/9490)
|
||||
|
||||
## 1.1.3 (2020-06-03)
|
||||
|
||||
- Fix issue of `SystemErrorRetryPolicy` didn't retry on errors [PR #8803](https://github.com/Azure/azure-sdk-for-js/pull/8803)
|
||||
- Add support for serialization of text media type. [PR #8977](https://github.com/Azure/azure-sdk-for-js/pull/8977)
|
||||
- Fix issue with URLBuilder incorrectly handling full URL in path. [PR #9245](https://github.com/Azure/azure-sdk-for-js/pull/9245)
|
||||
|
||||
## 1.1.2 (2020-05-07)
|
||||
|
||||
- Fix issue with null/undefined values in array and tabs/space delimiter arrays during sendOperationRequest. [PR #8604](https://github.com/Azure/azure-sdk-for-js/pull/8604)
|
||||
|
||||
## 1.1.1 (2020-04-28)
|
||||
|
||||
- Add support for `text/plain` endpoints. [PR #7963](https://github.com/Azure/azure-sdk-for-js/pull/7963)
|
||||
- Updated to use OpenTelemetry 0.6.1 via `@azure/core-tracing`.
|
||||
|
||||
## 1.1.0 (2020-03-31)
|
||||
|
||||
- A new interface `WebResourceLike` was introduced to avoid a direct dependency on the class `WebResource` in public interfaces. `HttpHeadersLike` was also added to replace references to `HttpHeaders`. This should improve cross-version compatibility for core-http. [PR #7873](https://github.com/Azure/azure-sdk-for-js/pull/7873)
|
||||
|
||||
- Add support to disable response decompression in `node-fetch` Http client. [PR #7878](https://github.com/Azure/azure-sdk-for-js/pull/7878)
|
||||
|
||||
## 1.0.4 (2020-03-03)
|
||||
|
||||
- When an operation times out based on the `timeout` configured in the `OperationRequestOptions`, it gets terminated with an error. In this update, the error that is thrown in browser for such cases is updated to match what is thrown in node i.e an `AbortError` is thrown instead of the previous `RestError`. [PR #7159](https://github.com/Azure/azure-sdk-for-js/pull/7159)
|
||||
- Support for username and password in the proxy url [PR #7211](https://github.com/Azure/azure-sdk-for-js/pull/7211)
|
||||
- Removed dependency on `lib.dom.d.ts` so TypeScript users no longer need `lib: ["dom"]` in their tsconfig.json file to use this library. [PR #7500](https://github.com/Azure/azure-sdk-for-js/pull/7500)
|
||||
|
||||
## 1.0.3 (2020-01-02)
|
||||
|
||||
- Added `x-ms-useragent` to the list of allowed headers in request logs.
|
||||
- Fix issue of data being pushed twice when reporting progress ([PR #6427](https://github.com/Azure/azure-sdk-for-js/issues/6427))
|
||||
- Move `getDefaultProxySettings()` calls into `proxyPolicy` so that libraries that don't use the PipelineOptions or createDefaultRequestPolicyFactories from core-http can use this behavior without duplicating code. ([PR #6478](https://github.com/Azure/azure-sdk-for-js/issues/6478))
|
||||
- Fix tracingPolicy() to set standard span attributes ([PR #6565](https://github.com/Azure/azure-sdk-for-js/pull/6565)). Now the following are set correctly for the spans
|
||||
- `http.method`
|
||||
- `http.url`
|
||||
- `http.user_agent`
|
||||
- `http.status_code`
|
||||
- `requestId`
|
||||
- `serviceRequestId`
|
||||
- `kind` = Client
|
||||
- span name: URI path
|
||||
|
||||
## 1.0.2 (2019-12-02)
|
||||
|
||||
- Updated to use OpenTelemetry 0.2 via `@azure/core-tracing`
|
||||
|
||||
## 1.0.0 (2019-10-29)
|
||||
|
||||
- This release marks the general availability of the `@azure/core-http` package.
|
||||
- Removed the browser bundle. A browser-compatible library can still be created through the use of a bundler such as Rollup, Webpack, or Parcel.
|
||||
([#5860](https://github.com/Azure/azure-sdk-for-js/pull/5860))
|
||||
|
||||
## 1.0.0-preview.6 (2019-10-22)
|
||||
|
||||
- Introduced a HTTP pipeline configuration type, `PipelineOptions`, which makes it easier to configure common settings for API requests. This is now the options type used in the `@azure/keyvault-*` data plane libraries.
|
||||
- Support for HTTP request logging has been redesigned to use `@azure/logger`; use`AZURE_LOG_LEVEL="info"` to see full request/response logs when running in Node.js. In the browser, you can import `setLogLevel` from `@azure/logger` to change the log level; logs will then be written to the browser console.
|
||||
- Removed error type `ResponseBodyNotFoundError` that was introduced in the previous preview. Use cases for it were removed.
|
||||
- Fixed an issue where error response details were not being deserialized correctly when the default mapper is used.
|
||||
- In Node.js, HTTP agents configured for proxy or keepAlive are now reused across requests. This resolves a memory leak reported in [#4964](https://github.com/Azure/azure-sdk-for-js/issues/4964).
|
||||
- Fixes a memory leak issue resulting from event listeners not being removed from abortSignals.
|
||||
- Cancelling an operation using an `abortSignal` will now throw an `AbortError`.
|
||||
The `name` property on the error will match "AbortError".
|
||||
|
||||
## 1.0.0-preview.4 (2019-10-07)
|
||||
|
||||
- No longer re-exports `@azure/core-tracing`. To enable tracing, call `setTracer` from `@azure/core-tracing` directly.
|
||||
([PR #5389](https://github.com/Azure/azure-sdk-for-js/pull/5389))
|
||||
- Report upload/download progress only after the first data chunk is received
|
||||
([PR #5298](https://github.com/Azure/azure-sdk-for-js/pull/5298))
|
||||
- Added new error type `ResponseBodyNotFoundError` for cases when the response body is unexpectedly empty.
|
||||
([PR #5369](https://github.com/Azure/azure-sdk-for-js/pull/5369))
|
||||
- Temporary fix for a memory leak issue resulting from creating new agents every time WebResource is cloned.
|
||||
([PR #5396](https://github.com/Azure/azure-sdk-for-js/pull/5396))
|
||||
|
||||
## 1.0.0-preview.3 (2019-09-09)
|
||||
|
||||
- Syncs changes from `@azure/ms-rest-js` to `@azure/core-http`.
|
||||
([PR #4756](https://github.com/Azure/azure-sdk-for-js/pull/4756)).
|
||||
- Updates HTTP clients to `fetch` and `node-fetch` for the browser and node.js respectively.
|
||||
- Reintroduces `ServiceClientCredentials` type to `credentials` parameter of `ServiceClient`
|
||||
([PR #4773](https://github.com/Azure/azure-sdk-for-js/pull/4773)).
|
||||
- Updates types for better compatibility with TypeScript 3.6.x.
|
||||
([PR #4928](https://github.com/Azure/azure-sdk-for-js/pull/4928)).
|
||||
- Adds `TracingPolicy` to support setting `traceparent` and `tracestate` headers
|
||||
when setting spans in operation as per the [trace context HTTP headers format](https://www.w3.org/TR/trace-context/#trace-context-http-headers-format).
|
||||
([PR #4712](https://github.com/Azure/azure-sdk-for-js/pull/4712)).
|
||||
- Adds `text/plain` as an accepted MIME type for JSON output.
|
||||
([PR #4975](https://github.com/Azure/azure-sdk-for-js/pull/4975)).
|
||||
- Exposes `ProxySettings` type. ([PR #5043](https://github.com/Azure/azure-sdk-for-js/pull/5043)).
|
||||
- Fixes bug where `WebResource.clone` would not copy `proxySettings` or `keepAlive` settings.
|
||||
([PR #5047](https://github.com/Azure/azure-sdk-for-js/pull/5047)).
|
||||
|
||||
## 1.0.0-preview.2 (2019-08-05)
|
||||
|
||||
- Removed `ServiceClientCredentials` type from `credentials` parameter of `ServiceClient` ([PR #4367](https://github.com/Azure/azure-sdk-for-js/pull/4367)). Credential implementations are now standardized on `@azure/core-auth`'s `TokenCredential` interface and provided by `@azure/identity`.
|
||||
- Added an `AccessTokenCache` so that access tokens can be cached across pipeline instances ([PR #4174](https://github.com/Azure/azure-sdk-for-js/pull/4174)).
|
||||
- Fixed the issue preventing `ServiceClient` from correctly setting the scope's resource URI when creating a `BearerTokenAuthenticationPolicy` ([PR #4335](https://github.com/Azure/azure-sdk-for-js/pull/4335)).
|
||||
- Migrated over `AxiosHttpClient` fixes from `@azure/ms-rest-js` ([PR #4106](https://github.com/Azure/azure-sdk-for-js/pull/4106)).
|
||||
|
||||
## 1.0.0-preview.1 (2019-06-25)
|
||||
|
||||
- Forked `@azure/ms-rest-js` to `@azure/core-http` to form the base HTTP pipeline of the Azure SDK TypeScript/JavaScript libraries.
|
||||
- Added `TokenCredential` to define a simple interface for credentials that provided bearer tokens
|
||||
- Added `BearerTokenAuthenticationPolicy` which can use a `TokenCredential` implementation to perform bearer token authentication against Azure services
|
21
node_modules/@azure/core-http/LICENSE
generated
vendored
Normal file
21
node_modules/@azure/core-http/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2020 Microsoft
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
72
node_modules/@azure/core-http/README.md
generated
vendored
Normal file
72
node_modules/@azure/core-http/README.md
generated
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
# Azure Core HTTP client library for JavaScript
|
||||
|
||||
This is the core HTTP pipeline for Azure SDK JavaScript libraries which work in the browser and Node.js. This library is primarily intended to be used in code generated by [AutoRest](https://github.com/Azure/Autorest) and [`autorest.typescript`](https://github.com/Azure/autorest.typescript).
|
||||
|
||||
## Getting started
|
||||
|
||||
### Currently supported environments
|
||||
|
||||
- [LTS versions of Node.js](https://nodejs.org/about/releases/)
|
||||
- Latest versions of Safari, Chrome, Edge, and Firefox.
|
||||
|
||||
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
|
||||
|
||||
### Installation
|
||||
|
||||
This package is primarily used in generated code and not meant to be consumed directly by end users.
|
||||
|
||||
## Key concepts
|
||||
|
||||
You can find an explanation of how this repository's code works by going to our [architecture overview](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-http/docs/architectureOverview.md).
|
||||
|
||||
## Examples
|
||||
|
||||
Examples can be found in the `samples` folder.
|
||||
|
||||
## Next steps
|
||||
|
||||
- Build this library (`core-http`). For more information on how to build project in this repo, please refer to the [Contributing Guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md).
|
||||
|
||||
- The code in `samples\node-sample.ts` shows how to create a `ServiceClient` instance with a test `TokenCredential` implementation and use the client instance to perform a `GET` operation from the Azure management service endpoint for subscriptions. To run the code, first obtain an access token to the Azure management service.
|
||||
|
||||
One easy way to get an access token is using [Azure CLI](https://docs.microsoft.com/cli/azure/?view=azure-cli-latest)
|
||||
|
||||
1. Sign in
|
||||
```shell
|
||||
az login
|
||||
```
|
||||
2. Select the subscription to use
|
||||
```shell
|
||||
az account set -s <subscription id>
|
||||
```
|
||||
3. Obtain an access token
|
||||
```shell
|
||||
az account get-access-token --resource=https://management.azure.com
|
||||
```
|
||||
|
||||
### NodeJS
|
||||
|
||||
- Set values of `subscriptionId` and `token` variable in `samples/node-sample.ts`
|
||||
|
||||
- Change directory to samples folder, compile the TypeScript code, then run the sample
|
||||
|
||||
```
|
||||
cd samples
|
||||
tsc node-sample.ts
|
||||
node node-sample.js
|
||||
```
|
||||
|
||||
### Browser
|
||||
|
||||
- Set values of `subscriptionId` and `token` variable in `samples/index.js`
|
||||
- Follow the instructions of [JavaScript Bundling Guide using Parcel](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/Bundling.md#using-parcel) to build and run the code in the browser.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If you run into issues while using this library, please feel free to [file an issue](https://github.com/Azure/azure-sdk-for-js/issues/new).
|
||||
|
||||
## Contributing
|
||||
|
||||
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
|
||||
|
||||

|
44
node_modules/@azure/core-http/dist-esm/src/coreHttp.js
generated
vendored
Normal file
44
node_modules/@azure/core-http/dist-esm/src/coreHttp.js
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/* eslint-disable-next-line @typescript-eslint/triple-slash-reference */
|
||||
/// <reference path="../dom-shim.d.ts" />
|
||||
export { WebResource, } from "./webResource";
|
||||
export { DefaultHttpClient } from "./defaultHttpClient";
|
||||
export { HttpHeaders } from "./httpHeaders";
|
||||
export { HttpPipelineLogLevel } from "./httpPipelineLogLevel";
|
||||
export { RestError } from "./restError";
|
||||
export { operationOptionsToRequestOptionsBase, } from "./operationOptions";
|
||||
export { ServiceClient, flattenResponse, createPipelineFromOptions, } from "./serviceClient";
|
||||
export { QueryCollectionFormat } from "./queryCollectionFormat";
|
||||
export { Constants } from "./util/constants";
|
||||
export { bearerTokenAuthenticationPolicy } from "./policies/bearerTokenAuthenticationPolicy";
|
||||
export { logPolicy } from "./policies/logPolicy";
|
||||
export { BaseRequestPolicy, RequestPolicyOptions, } from "./policies/requestPolicy";
|
||||
export { generateClientRequestIdPolicy } from "./policies/generateClientRequestIdPolicy";
|
||||
export { exponentialRetryPolicy, RetryMode } from "./policies/exponentialRetryPolicy";
|
||||
export { systemErrorRetryPolicy } from "./policies/systemErrorRetryPolicy";
|
||||
export { throttlingRetryPolicy } from "./policies/throttlingRetryPolicy";
|
||||
export { getDefaultProxySettings, proxyPolicy } from "./policies/proxyPolicy";
|
||||
export { redirectPolicy } from "./policies/redirectPolicy";
|
||||
export { keepAlivePolicy } from "./policies/keepAlivePolicy";
|
||||
export { disableResponseDecompressionPolicy } from "./policies/disableResponseDecompressionPolicy";
|
||||
export { signingPolicy } from "./policies/signingPolicy";
|
||||
export { userAgentPolicy, getDefaultUserAgentValue, } from "./policies/userAgentPolicy";
|
||||
export { deserializationPolicy, deserializeResponseBody, } from "./policies/deserializationPolicy";
|
||||
export { tracingPolicy } from "./policies/tracingPolicy";
|
||||
export { MapperType, Serializer, serializeObject, } from "./serializer";
|
||||
export { stripRequest, stripResponse, executePromisesSequentially, generateUuid, encodeUri, promiseToCallback, promiseToServiceCallback, isValidUuid, applyMixins, isNode, isDuration, } from "./util/utils";
|
||||
export { URLBuilder, URLQuery } from "./url";
|
||||
export { delay } from "./util/delay";
|
||||
// legacy exports. Use core-tracing instead (and remove on next major version update of core-http).
|
||||
export { createSpanFunction } from "./createSpanLegacy";
|
||||
// Credentials
|
||||
export { isTokenCredential } from "@azure/core-auth";
|
||||
export { ExpiringAccessTokenCache } from "./credentials/accessTokenCache";
|
||||
export { AccessTokenRefresher } from "./credentials/accessTokenRefresher";
|
||||
export { BasicAuthenticationCredentials } from "./credentials/basicAuthenticationCredentials";
|
||||
export { ApiKeyCredentials } from "./credentials/apiKeyCredentials";
|
||||
export { TopicCredentials } from "./credentials/topicCredentials";
|
||||
export { parseXML, stringifyXML } from "./util/xml";
|
||||
export { XML_ATTRKEY, XML_CHARKEY } from "./util/serializer.common";
|
||||
//# sourceMappingURL=coreHttp.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/coreHttp.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/coreHttp.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
19
node_modules/@azure/core-http/dist-esm/src/createSpanLegacy.js
generated
vendored
Normal file
19
node_modules/@azure/core-http/dist-esm/src/createSpanLegacy.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
// NOTE: we've moved this code into core-tracing but these functions
|
||||
// were a part of the GA'd library and can't be removed until the next major
|
||||
// release. They currently get called always, even if tracing is not enabled.
|
||||
import { createSpanFunction as coreTracingCreateSpanFunction } from "@azure/core-tracing";
|
||||
/**
|
||||
* This function is only here for compatibility. Use createSpanFunction in core-tracing.
|
||||
*
|
||||
* @deprecated This function is only here for compatibility. Use createSpanFunction in core-tracing.
|
||||
* @hidden
|
||||
|
||||
* @param spanConfig - The name of the operation being performed.
|
||||
* @param tracingOptions - The options for the underlying http request.
|
||||
*/
|
||||
export function createSpanFunction(args) {
|
||||
return coreTracingCreateSpanFunction(args);
|
||||
}
|
||||
//# sourceMappingURL=createSpanLegacy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/createSpanLegacy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/createSpanLegacy.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"createSpanLegacy.js","sourceRoot":"","sources":["../../src/createSpanLegacy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,oEAAoE;AACpE,4EAA4E;AAC5E,6EAA6E;AAE7E,OAAO,EAAQ,kBAAkB,IAAI,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAoBhG;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAgB;IAKhB,OAAO,6BAA6B,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// NOTE: we've moved this code into core-tracing but these functions\n// were a part of the GA'd library and can't be removed until the next major\n// release. They currently get called always, even if tracing is not enabled.\n\nimport { Span, createSpanFunction as coreTracingCreateSpanFunction } from \"@azure/core-tracing\";\nimport { OperationOptions } from \"./operationOptions\";\n\n/**\n * This function is only here for compatibility. Use createSpanFunction in core-tracing.\n *\n * @deprecated This function is only here for compatibility. Use core-tracing instead.\n * @hidden\n */\nexport interface SpanConfig {\n /**\n * Package name prefix\n */\n packagePrefix: string;\n /**\n * Service namespace\n */\n namespace: string;\n}\n\n/**\n * This function is only here for compatibility. Use createSpanFunction in core-tracing.\n *\n * @deprecated This function is only here for compatibility. Use createSpanFunction in core-tracing.\n * @hidden\n\n * @param spanConfig - The name of the operation being performed.\n * @param tracingOptions - The options for the underlying http request.\n */\nexport function createSpanFunction(\n args: SpanConfig\n): <T extends OperationOptions>(\n operationName: string,\n operationOptions: T\n) => { span: Span; updatedOptions: T } {\n return coreTracingCreateSpanFunction(args);\n}\n"]}
|
41
node_modules/@azure/core-http/dist-esm/src/credentials/accessTokenCache.js
generated
vendored
Normal file
41
node_modules/@azure/core-http/dist-esm/src/credentials/accessTokenCache.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/**
|
||||
* Defines the default token refresh buffer duration.
|
||||
*/
|
||||
export const TokenRefreshBufferMs = 2 * 60 * 1000; // 2 Minutes
|
||||
/**
|
||||
* Provides an {@link AccessTokenCache} implementation which clears
|
||||
* the cached {@link AccessToken}'s after the expiresOnTimestamp has
|
||||
* passed.
|
||||
*
|
||||
* @deprecated No longer used in the bearer authorization policy.
|
||||
*/
|
||||
export class ExpiringAccessTokenCache {
|
||||
/**
|
||||
* Constructs an instance of {@link ExpiringAccessTokenCache} with
|
||||
* an optional expiration buffer time.
|
||||
*/
|
||||
constructor(tokenRefreshBufferMs = TokenRefreshBufferMs) {
|
||||
this.cachedToken = undefined;
|
||||
this.tokenRefreshBufferMs = tokenRefreshBufferMs;
|
||||
}
|
||||
/**
|
||||
* Saves an access token into the internal in-memory cache.
|
||||
* @param accessToken - Access token or undefined to clear the cache.
|
||||
*/
|
||||
setCachedToken(accessToken) {
|
||||
this.cachedToken = accessToken;
|
||||
}
|
||||
/**
|
||||
* Returns the cached access token, or `undefined` if one is not cached or the cached one is expiring soon.
|
||||
*/
|
||||
getCachedToken() {
|
||||
if (this.cachedToken &&
|
||||
Date.now() + this.tokenRefreshBufferMs >= this.cachedToken.expiresOnTimestamp) {
|
||||
this.cachedToken = undefined;
|
||||
}
|
||||
return this.cachedToken;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=accessTokenCache.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/credentials/accessTokenCache.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/credentials/accessTokenCache.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"accessTokenCache.js","sourceRoot":"","sources":["../../../src/credentials/accessTokenCache.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AAqB/D;;;;;;GAMG;AACH,MAAM,OAAO,wBAAwB;IAInC;;;OAGG;IACH,YAAY,uBAA+B,oBAAoB;QANvD,gBAAW,GAAiB,SAAS,CAAC;QAO5C,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,WAAoC;QACjD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,IACE,IAAI,CAAC,WAAW;YAChB,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAC7E;YACA,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;SAC9B;QAED,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AccessToken } from \"@azure/core-auth\";\n\n/**\n * Defines the default token refresh buffer duration.\n */\nexport const TokenRefreshBufferMs = 2 * 60 * 1000; // 2 Minutes\n\n/**\n * Provides a cache for an AccessToken that was that\n * was returned from a TokenCredential.\n */\nexport interface AccessTokenCache {\n /**\n * Sets the cached token.\n *\n * @param accessToken - The {@link AccessToken} to be cached or null to\n * clear the cached token.\n */\n setCachedToken(accessToken: AccessToken | undefined): void;\n\n /**\n * Returns the cached {@link AccessToken} or undefined if nothing is cached.\n */\n getCachedToken(): AccessToken | undefined;\n}\n\n/**\n * Provides an {@link AccessTokenCache} implementation which clears\n * the cached {@link AccessToken}'s after the expiresOnTimestamp has\n * passed.\n *\n * @deprecated No longer used in the bearer authorization policy.\n */\nexport class ExpiringAccessTokenCache implements AccessTokenCache {\n private tokenRefreshBufferMs: number;\n private cachedToken?: AccessToken = undefined;\n\n /**\n * Constructs an instance of {@link ExpiringAccessTokenCache} with\n * an optional expiration buffer time.\n */\n constructor(tokenRefreshBufferMs: number = TokenRefreshBufferMs) {\n this.tokenRefreshBufferMs = tokenRefreshBufferMs;\n }\n\n /**\n * Saves an access token into the internal in-memory cache.\n * @param accessToken - Access token or undefined to clear the cache.\n */\n setCachedToken(accessToken: AccessToken | undefined): void {\n this.cachedToken = accessToken;\n }\n\n /**\n * Returns the cached access token, or `undefined` if one is not cached or the cached one is expiring soon.\n */\n getCachedToken(): AccessToken | undefined {\n if (\n this.cachedToken &&\n Date.now() + this.tokenRefreshBufferMs >= this.cachedToken.expiresOnTimestamp\n ) {\n this.cachedToken = undefined;\n }\n\n return this.cachedToken;\n }\n}\n"]}
|
46
node_modules/@azure/core-http/dist-esm/src/credentials/accessTokenRefresher.js
generated
vendored
Normal file
46
node_modules/@azure/core-http/dist-esm/src/credentials/accessTokenRefresher.js
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/**
|
||||
* Helps the core-http token authentication policies with requesting a new token if we're not currently waiting for a new token.
|
||||
*
|
||||
* @deprecated No longer used in the bearer authorization policy.
|
||||
*/
|
||||
export class AccessTokenRefresher {
|
||||
constructor(credential, scopes, requiredMillisecondsBeforeNewRefresh = 30000) {
|
||||
this.credential = credential;
|
||||
this.scopes = scopes;
|
||||
this.requiredMillisecondsBeforeNewRefresh = requiredMillisecondsBeforeNewRefresh;
|
||||
this.lastCalled = 0;
|
||||
}
|
||||
/**
|
||||
* Returns true if the required milliseconds(defaulted to 30000) have been passed signifying
|
||||
* that we are ready for a new refresh.
|
||||
*/
|
||||
isReady() {
|
||||
// We're only ready for a new refresh if the required milliseconds have passed.
|
||||
return (!this.lastCalled || Date.now() - this.lastCalled > this.requiredMillisecondsBeforeNewRefresh);
|
||||
}
|
||||
/**
|
||||
* Stores the time in which it is called,
|
||||
* then requests a new token,
|
||||
* then sets this.promise to undefined,
|
||||
* then returns the token.
|
||||
*/
|
||||
async getToken(options) {
|
||||
this.lastCalled = Date.now();
|
||||
const token = await this.credential.getToken(this.scopes, options);
|
||||
this.promise = undefined;
|
||||
return token || undefined;
|
||||
}
|
||||
/**
|
||||
* Requests a new token if we're not currently waiting for a new token.
|
||||
* Returns null if the required time between each call hasn't been reached.
|
||||
*/
|
||||
refresh(options) {
|
||||
if (!this.promise) {
|
||||
this.promise = this.getToken(options);
|
||||
}
|
||||
return this.promise;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=accessTokenRefresher.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/credentials/accessTokenRefresher.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/credentials/accessTokenRefresher.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"accessTokenRefresher.js","sourceRoot":"","sources":["../../../src/credentials/accessTokenRefresher.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAI/B,YACU,UAA2B,EAC3B,MAAyB,EACzB,uCAA+C,KAAK;QAFpD,eAAU,GAAV,UAAU,CAAiB;QAC3B,WAAM,GAAN,MAAM,CAAmB;QACzB,yCAAoC,GAApC,oCAAoC,CAAgB;QALtD,eAAU,GAAG,CAAC,CAAC;IAMpB,CAAC;IAEJ;;;OAGG;IACI,OAAO;QACZ,+EAA+E;QAC/E,OAAO,CACL,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oCAAoC,CAC7F,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,QAAQ,CAAC,OAAwB;QAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnE,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,OAAO,KAAK,IAAI,SAAS,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,OAAwB;QACrC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;SACvC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AccessToken, GetTokenOptions, TokenCredential } from \"@azure/core-auth\";\n\n/**\n * Helps the core-http token authentication policies with requesting a new token if we're not currently waiting for a new token.\n *\n * @deprecated No longer used in the bearer authorization policy.\n */\nexport class AccessTokenRefresher {\n private promise: Promise<AccessToken | undefined> | undefined;\n private lastCalled = 0;\n\n constructor(\n private credential: TokenCredential,\n private scopes: string | string[],\n private requiredMillisecondsBeforeNewRefresh: number = 30000\n ) {}\n\n /**\n * Returns true if the required milliseconds(defaulted to 30000) have been passed signifying\n * that we are ready for a new refresh.\n */\n public isReady(): boolean {\n // We're only ready for a new refresh if the required milliseconds have passed.\n return (\n !this.lastCalled || Date.now() - this.lastCalled > this.requiredMillisecondsBeforeNewRefresh\n );\n }\n\n /**\n * Stores the time in which it is called,\n * then requests a new token,\n * then sets this.promise to undefined,\n * then returns the token.\n */\n private async getToken(options: GetTokenOptions): Promise<AccessToken | undefined> {\n this.lastCalled = Date.now();\n const token = await this.credential.getToken(this.scopes, options);\n this.promise = undefined;\n return token || undefined;\n }\n\n /**\n * Requests a new token if we're not currently waiting for a new token.\n * Returns null if the required time between each call hasn't been reached.\n */\n public refresh(options: GetTokenOptions): Promise<AccessToken | undefined> {\n if (!this.promise) {\n this.promise = this.getToken(options);\n }\n\n return this.promise;\n }\n}\n"]}
|
53
node_modules/@azure/core-http/dist-esm/src/credentials/apiKeyCredentials.js
generated
vendored
Normal file
53
node_modules/@azure/core-http/dist-esm/src/credentials/apiKeyCredentials.js
generated
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { HttpHeaders } from "../httpHeaders";
|
||||
/**
|
||||
* Authenticates to a service using an API key.
|
||||
*/
|
||||
export class ApiKeyCredentials {
|
||||
/**
|
||||
* @param options - Specifies the options to be provided for auth. Either header or query needs to be provided.
|
||||
*/
|
||||
constructor(options) {
|
||||
if (!options || (options && !options.inHeader && !options.inQuery)) {
|
||||
throw new Error(`options cannot be null or undefined. Either "inHeader" or "inQuery" property of the options object needs to be provided.`);
|
||||
}
|
||||
this.inHeader = options.inHeader;
|
||||
this.inQuery = options.inQuery;
|
||||
}
|
||||
/**
|
||||
* Signs a request with the values provided in the inHeader and inQuery parameter.
|
||||
*
|
||||
* @param webResource - The WebResourceLike to be signed.
|
||||
* @returns The signed request object.
|
||||
*/
|
||||
signRequest(webResource) {
|
||||
if (!webResource) {
|
||||
return Promise.reject(new Error(`webResource cannot be null or undefined and must be of type "object".`));
|
||||
}
|
||||
if (this.inHeader) {
|
||||
if (!webResource.headers) {
|
||||
webResource.headers = new HttpHeaders();
|
||||
}
|
||||
for (const headerName in this.inHeader) {
|
||||
webResource.headers.set(headerName, this.inHeader[headerName]);
|
||||
}
|
||||
}
|
||||
if (this.inQuery) {
|
||||
if (!webResource.url) {
|
||||
return Promise.reject(new Error(`url cannot be null in the request object.`));
|
||||
}
|
||||
if (webResource.url.indexOf("?") < 0) {
|
||||
webResource.url += "?";
|
||||
}
|
||||
for (const key in this.inQuery) {
|
||||
if (!webResource.url.endsWith("?")) {
|
||||
webResource.url += "&";
|
||||
}
|
||||
webResource.url += `${key}=${this.inQuery[key]}`;
|
||||
}
|
||||
}
|
||||
return Promise.resolve(webResource);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=apiKeyCredentials.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/credentials/apiKeyCredentials.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/credentials/apiKeyCredentials.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"apiKeyCredentials.js","sourceRoot":"","sources":["../../../src/credentials/apiKeyCredentials.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAkB7C;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAU5B;;OAEG;IACH,YAAY,OAAgC;QAC1C,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAClE,MAAM,IAAI,KAAK,CACb,0HAA0H,CAC3H,CAAC;SACH;QACD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,WAAW,CAAC,WAA4B;QACtC,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CAAC,uEAAuE,CAAC,CACnF,CAAC;SACH;QAED,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;gBACxB,WAAW,CAAC,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;aACzC;YACD,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACtC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;aAChE;SACF;QAED,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE;gBACpB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC,CAAC;aAC/E;YACD,IAAI,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBACpC,WAAW,CAAC,GAAG,IAAI,GAAG,CAAC;aACxB;YACD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE;gBAC9B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;oBAClC,WAAW,CAAC,GAAG,IAAI,GAAG,CAAC;iBACxB;gBACD,WAAW,CAAC,GAAG,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;aAClD;SACF;QAED,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { HttpHeaders } from \"../httpHeaders\";\nimport { ServiceClientCredentials } from \"./serviceClientCredentials\";\nimport { WebResourceLike } from \"../webResource\";\n\n/**\n * Describes the options to be provided while creating an instance of ApiKeyCredentials\n */\nexport interface ApiKeyCredentialOptions {\n /**\n * A key value pair of the header parameters that need to be applied to the request.\n */\n inHeader?: { [x: string]: any };\n /**\n * A key value pair of the query parameters that need to be applied to the request.\n */\n inQuery?: { [x: string]: any };\n}\n\n/**\n * Authenticates to a service using an API key.\n */\nexport class ApiKeyCredentials implements ServiceClientCredentials {\n /**\n * A key value pair of the header parameters that need to be applied to the request.\n */\n private readonly inHeader?: { [x: string]: any };\n /**\n * A key value pair of the query parameters that need to be applied to the request.\n */\n private readonly inQuery?: { [x: string]: any };\n\n /**\n * @param options - Specifies the options to be provided for auth. Either header or query needs to be provided.\n */\n constructor(options: ApiKeyCredentialOptions) {\n if (!options || (options && !options.inHeader && !options.inQuery)) {\n throw new Error(\n `options cannot be null or undefined. Either \"inHeader\" or \"inQuery\" property of the options object needs to be provided.`\n );\n }\n this.inHeader = options.inHeader;\n this.inQuery = options.inQuery;\n }\n\n /**\n * Signs a request with the values provided in the inHeader and inQuery parameter.\n *\n * @param webResource - The WebResourceLike to be signed.\n * @returns The signed request object.\n */\n signRequest(webResource: WebResourceLike): Promise<WebResourceLike> {\n if (!webResource) {\n return Promise.reject(\n new Error(`webResource cannot be null or undefined and must be of type \"object\".`)\n );\n }\n\n if (this.inHeader) {\n if (!webResource.headers) {\n webResource.headers = new HttpHeaders();\n }\n for (const headerName in this.inHeader) {\n webResource.headers.set(headerName, this.inHeader[headerName]);\n }\n }\n\n if (this.inQuery) {\n if (!webResource.url) {\n return Promise.reject(new Error(`url cannot be null in the request object.`));\n }\n if (webResource.url.indexOf(\"?\") < 0) {\n webResource.url += \"?\";\n }\n for (const key in this.inQuery) {\n if (!webResource.url.endsWith(\"?\")) {\n webResource.url += \"&\";\n }\n webResource.url += `${key}=${this.inQuery[key]}`;\n }\n }\n\n return Promise.resolve(webResource);\n }\n}\n"]}
|
50
node_modules/@azure/core-http/dist-esm/src/credentials/basicAuthenticationCredentials.js
generated
vendored
Normal file
50
node_modules/@azure/core-http/dist-esm/src/credentials/basicAuthenticationCredentials.js
generated
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import * as base64 from "../util/base64";
|
||||
import { Constants } from "../util/constants";
|
||||
import { HttpHeaders } from "../httpHeaders";
|
||||
const HeaderConstants = Constants.HeaderConstants;
|
||||
const DEFAULT_AUTHORIZATION_SCHEME = "Basic";
|
||||
/**
|
||||
* A simple {@link ServiceClientCredential} that authenticates with a username and a password.
|
||||
*/
|
||||
export class BasicAuthenticationCredentials {
|
||||
/**
|
||||
* Creates a new BasicAuthenticationCredentials object.
|
||||
*
|
||||
* @param userName - User name.
|
||||
* @param password - Password.
|
||||
* @param authorizationScheme - The authorization scheme.
|
||||
*/
|
||||
constructor(userName, password, authorizationScheme = DEFAULT_AUTHORIZATION_SCHEME) {
|
||||
/**
|
||||
* Authorization scheme. Defaults to "Basic".
|
||||
* More information about authorization schemes is available here: https://developer.mozilla.org/docs/Web/HTTP/Authentication#authentication_schemes
|
||||
*/
|
||||
this.authorizationScheme = DEFAULT_AUTHORIZATION_SCHEME;
|
||||
if (userName === null || userName === undefined || typeof userName.valueOf() !== "string") {
|
||||
throw new Error("userName cannot be null or undefined and must be of type string.");
|
||||
}
|
||||
if (password === null || password === undefined || typeof password.valueOf() !== "string") {
|
||||
throw new Error("password cannot be null or undefined and must be of type string.");
|
||||
}
|
||||
this.userName = userName;
|
||||
this.password = password;
|
||||
this.authorizationScheme = authorizationScheme;
|
||||
}
|
||||
/**
|
||||
* Signs a request with the Authentication header.
|
||||
*
|
||||
* @param webResource - The WebResourceLike to be signed.
|
||||
* @returns The signed request object.
|
||||
*/
|
||||
signRequest(webResource) {
|
||||
const credentials = `${this.userName}:${this.password}`;
|
||||
const encodedCredentials = `${this.authorizationScheme} ${base64.encodeString(credentials)}`;
|
||||
if (!webResource.headers)
|
||||
webResource.headers = new HttpHeaders();
|
||||
webResource.headers.set(HeaderConstants.AUTHORIZATION, encodedCredentials);
|
||||
return Promise.resolve(webResource);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=basicAuthenticationCredentials.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/credentials/basicAuthenticationCredentials.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/credentials/basicAuthenticationCredentials.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"basicAuthenticationCredentials.js","sourceRoot":"","sources":["../../../src/credentials/basicAuthenticationCredentials.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI7C,MAAM,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC;AAClD,MAAM,4BAA4B,GAAG,OAAO,CAAC;AAE7C;;GAEG;AACH,MAAM,OAAO,8BAA8B;IAiBzC;;;;;;OAMG;IACH,YACE,QAAgB,EAChB,QAAgB,EAChB,sBAA8B,4BAA4B;QAhB5D;;;WAGG;QACH,wBAAmB,GAAW,4BAA4B,CAAC;QAczD,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,OAAO,EAAE,KAAK,QAAQ,EAAE;YACzF,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;SACrF;QACD,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,OAAO,EAAE,KAAK,QAAQ,EAAE;YACzF,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;SACrF;QACD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACH,WAAW,CAAC,WAA4B;QACtC,MAAM,WAAW,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QACxD,MAAM,kBAAkB,GAAG,GAAG,IAAI,CAAC,mBAAmB,IAAI,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7F,IAAI,CAAC,WAAW,CAAC,OAAO;YAAE,WAAW,CAAC,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClE,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;QAC3E,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as base64 from \"../util/base64\";\nimport { Constants } from \"../util/constants\";\nimport { HttpHeaders } from \"../httpHeaders\";\nimport { ServiceClientCredentials } from \"./serviceClientCredentials\";\nimport { WebResourceLike } from \"../webResource\";\n\nconst HeaderConstants = Constants.HeaderConstants;\nconst DEFAULT_AUTHORIZATION_SCHEME = \"Basic\";\n\n/**\n * A simple {@link ServiceClientCredential} that authenticates with a username and a password.\n */\nexport class BasicAuthenticationCredentials implements ServiceClientCredentials {\n /**\n * Username\n */\n userName: string;\n\n /**\n * Password\n */\n password: string;\n\n /**\n * Authorization scheme. Defaults to \"Basic\".\n * More information about authorization schemes is available here: https://developer.mozilla.org/docs/Web/HTTP/Authentication#authentication_schemes\n */\n authorizationScheme: string = DEFAULT_AUTHORIZATION_SCHEME;\n\n /**\n * Creates a new BasicAuthenticationCredentials object.\n *\n * @param userName - User name.\n * @param password - Password.\n * @param authorizationScheme - The authorization scheme.\n */\n constructor(\n userName: string,\n password: string,\n authorizationScheme: string = DEFAULT_AUTHORIZATION_SCHEME\n ) {\n if (userName === null || userName === undefined || typeof userName.valueOf() !== \"string\") {\n throw new Error(\"userName cannot be null or undefined and must be of type string.\");\n }\n if (password === null || password === undefined || typeof password.valueOf() !== \"string\") {\n throw new Error(\"password cannot be null or undefined and must be of type string.\");\n }\n this.userName = userName;\n this.password = password;\n this.authorizationScheme = authorizationScheme;\n }\n\n /**\n * Signs a request with the Authentication header.\n *\n * @param webResource - The WebResourceLike to be signed.\n * @returns The signed request object.\n */\n signRequest(webResource: WebResourceLike): Promise<WebResourceLike> {\n const credentials = `${this.userName}:${this.password}`;\n const encodedCredentials = `${this.authorizationScheme} ${base64.encodeString(credentials)}`;\n if (!webResource.headers) webResource.headers = new HttpHeaders();\n webResource.headers.set(HeaderConstants.AUTHORIZATION, encodedCredentials);\n return Promise.resolve(webResource);\n }\n}\n"]}
|
4
node_modules/@azure/core-http/dist-esm/src/credentials/credentials.js
generated
vendored
Normal file
4
node_modules/@azure/core-http/dist-esm/src/credentials/credentials.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=credentials.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/credentials/credentials.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/credentials/credentials.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../src/credentials/credentials.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * A function that receives a challenge and resolves a promise with a string token.\n * @deprecated The Authenticator type is not currently in use.\n */\nexport type Authenticator = (challenge: unknown) => Promise<string>;\n"]}
|
4
node_modules/@azure/core-http/dist-esm/src/credentials/serviceClientCredentials.js
generated
vendored
Normal file
4
node_modules/@azure/core-http/dist-esm/src/credentials/serviceClientCredentials.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=serviceClientCredentials.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/credentials/serviceClientCredentials.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/credentials/serviceClientCredentials.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"serviceClientCredentials.js","sourceRoot":"","sources":["../../../src/credentials/serviceClientCredentials.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { WebResourceLike } from \"../webResource\";\n\n/**\n * Represents an object or class with a `signRequest` method which will sign outgoing requests (for example, by setting the `Authorization` header).\n */\nexport interface ServiceClientCredentials {\n /**\n * Signs a request with the Authentication header.\n *\n * @param webResource - The WebResourceLike/request to be signed.\n * @returns The signed request object;\n */\n signRequest(webResource: WebResourceLike): Promise<WebResourceLike>;\n}\n"]}
|
25
node_modules/@azure/core-http/dist-esm/src/credentials/topicCredentials.js
generated
vendored
Normal file
25
node_modules/@azure/core-http/dist-esm/src/credentials/topicCredentials.js
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { ApiKeyCredentials } from "./apiKeyCredentials";
|
||||
/**
|
||||
* A {@link TopicCredentials} object used for Azure Event Grid.
|
||||
*/
|
||||
export class TopicCredentials extends ApiKeyCredentials {
|
||||
/**
|
||||
* Creates a new EventGrid TopicCredentials object.
|
||||
*
|
||||
* @param topicKey - The EventGrid topic key
|
||||
*/
|
||||
constructor(topicKey) {
|
||||
if (!topicKey || (topicKey && typeof topicKey !== "string")) {
|
||||
throw new Error("topicKey cannot be null or undefined and must be of type string.");
|
||||
}
|
||||
const options = {
|
||||
inHeader: {
|
||||
"aeg-sas-key": topicKey,
|
||||
},
|
||||
};
|
||||
super(options);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=topicCredentials.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/credentials/topicCredentials.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/credentials/topicCredentials.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"topicCredentials.js","sourceRoot":"","sources":["../../../src/credentials/topicCredentials.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAA2B,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEjF;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IACrD;;;;OAIG;IACH,YAAY,QAAgB;QAC1B,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,CAAC,EAAE;YAC3D,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;SACrF;QACD,MAAM,OAAO,GAA4B;YACvC,QAAQ,EAAE;gBACR,aAAa,EAAE,QAAQ;aACxB;SACF,CAAC;QACF,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ApiKeyCredentialOptions, ApiKeyCredentials } from \"./apiKeyCredentials\";\n\n/**\n * A {@link TopicCredentials} object used for Azure Event Grid.\n */\nexport class TopicCredentials extends ApiKeyCredentials {\n /**\n * Creates a new EventGrid TopicCredentials object.\n *\n * @param topicKey - The EventGrid topic key\n */\n constructor(topicKey: string) {\n if (!topicKey || (topicKey && typeof topicKey !== \"string\")) {\n throw new Error(\"topicKey cannot be null or undefined and must be of type string.\");\n }\n const options: ApiKeyCredentialOptions = {\n inHeader: {\n \"aeg-sas-key\": topicKey,\n },\n };\n super(options);\n }\n}\n"]}
|
4
node_modules/@azure/core-http/dist-esm/src/defaultHttpClient.browser.js
generated
vendored
Normal file
4
node_modules/@azure/core-http/dist-esm/src/defaultHttpClient.browser.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export { XhrHttpClient as DefaultHttpClient } from "./xhrHttpClient";
|
||||
//# sourceMappingURL=defaultHttpClient.browser.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/defaultHttpClient.browser.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/defaultHttpClient.browser.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"defaultHttpClient.browser.js","sourceRoot":"","sources":["../../src/defaultHttpClient.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport { XhrHttpClient as DefaultHttpClient } from \"./xhrHttpClient\";\n"]}
|
4
node_modules/@azure/core-http/dist-esm/src/defaultHttpClient.js
generated
vendored
Normal file
4
node_modules/@azure/core-http/dist-esm/src/defaultHttpClient.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export { NodeFetchHttpClient as DefaultHttpClient } from "./nodeFetchHttpClient";
|
||||
//# sourceMappingURL=defaultHttpClient.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/defaultHttpClient.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/defaultHttpClient.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"defaultHttpClient.js","sourceRoot":"","sources":["../../src/defaultHttpClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport { NodeFetchHttpClient as DefaultHttpClient } from \"./nodeFetchHttpClient\";\n"]}
|
4
node_modules/@azure/core-http/dist-esm/src/httpClient.js
generated
vendored
Normal file
4
node_modules/@azure/core-http/dist-esm/src/httpClient.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=httpClient.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/httpClient.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/httpClient.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"httpClient.js","sourceRoot":"","sources":["../../src/httpClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RequestPolicy } from \"./policies/requestPolicy\";\n\n/**\n * An interface that can send HttpRequests and receive promised HttpResponses.\n */\nexport interface HttpClient extends RequestPolicy {}\n"]}
|
11
node_modules/@azure/core-http/dist-esm/src/httpClientCache.js
generated
vendored
Normal file
11
node_modules/@azure/core-http/dist-esm/src/httpClientCache.js
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { DefaultHttpClient } from "./defaultHttpClient";
|
||||
let cachedHttpClient;
|
||||
export function getCachedDefaultHttpClient() {
|
||||
if (!cachedHttpClient) {
|
||||
cachedHttpClient = new DefaultHttpClient();
|
||||
}
|
||||
return cachedHttpClient;
|
||||
}
|
||||
//# sourceMappingURL=httpClientCache.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/httpClientCache.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/httpClientCache.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"httpClientCache.js","sourceRoot":"","sources":["../../src/httpClientCache.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,IAAI,gBAAwC,CAAC;AAE7C,MAAM,UAAU,0BAA0B;IACxC,IAAI,CAAC,gBAAgB,EAAE;QACrB,gBAAgB,GAAG,IAAI,iBAAiB,EAAE,CAAC;KAC5C;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { DefaultHttpClient } from \"./defaultHttpClient\";\nimport { HttpClient } from \"./httpClient\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\nexport function getCachedDefaultHttpClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = new DefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n"]}
|
151
node_modules/@azure/core-http/dist-esm/src/httpHeaders.js
generated
vendored
Normal file
151
node_modules/@azure/core-http/dist-esm/src/httpHeaders.js
generated
vendored
Normal file
|
@ -0,0 +1,151 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/**
|
||||
* A collection of HttpHeaders that can be sent with a HTTP request.
|
||||
*/
|
||||
function getHeaderKey(headerName) {
|
||||
return headerName.toLowerCase();
|
||||
}
|
||||
export function isHttpHeadersLike(object) {
|
||||
if (object && typeof object === "object") {
|
||||
const castObject = object;
|
||||
if (typeof castObject.rawHeaders === "function" &&
|
||||
typeof castObject.clone === "function" &&
|
||||
typeof castObject.get === "function" &&
|
||||
typeof castObject.set === "function" &&
|
||||
typeof castObject.contains === "function" &&
|
||||
typeof castObject.remove === "function" &&
|
||||
typeof castObject.headersArray === "function" &&
|
||||
typeof castObject.headerValues === "function" &&
|
||||
typeof castObject.headerNames === "function" &&
|
||||
typeof castObject.toJson === "function") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* A collection of HTTP header key/value pairs.
|
||||
*/
|
||||
export class HttpHeaders {
|
||||
constructor(rawHeaders) {
|
||||
this._headersMap = {};
|
||||
if (rawHeaders) {
|
||||
for (const headerName in rawHeaders) {
|
||||
this.set(headerName, rawHeaders[headerName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set a header in this collection with the provided name and value. The name is
|
||||
* case-insensitive.
|
||||
* @param headerName - The name of the header to set. This value is case-insensitive.
|
||||
* @param headerValue - The value of the header to set.
|
||||
*/
|
||||
set(headerName, headerValue) {
|
||||
this._headersMap[getHeaderKey(headerName)] = {
|
||||
name: headerName,
|
||||
value: headerValue.toString(),
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Get the header value for the provided header name, or undefined if no header exists in this
|
||||
* collection with the provided name.
|
||||
* @param headerName - The name of the header.
|
||||
*/
|
||||
get(headerName) {
|
||||
const header = this._headersMap[getHeaderKey(headerName)];
|
||||
return !header ? undefined : header.value;
|
||||
}
|
||||
/**
|
||||
* Get whether or not this header collection contains a header entry for the provided header name.
|
||||
*/
|
||||
contains(headerName) {
|
||||
return !!this._headersMap[getHeaderKey(headerName)];
|
||||
}
|
||||
/**
|
||||
* Remove the header with the provided headerName. Return whether or not the header existed and
|
||||
* was removed.
|
||||
* @param headerName - The name of the header to remove.
|
||||
*/
|
||||
remove(headerName) {
|
||||
const result = this.contains(headerName);
|
||||
delete this._headersMap[getHeaderKey(headerName)];
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Get the headers that are contained this collection as an object.
|
||||
*/
|
||||
rawHeaders() {
|
||||
return this.toJson({ preserveCase: true });
|
||||
}
|
||||
/**
|
||||
* Get the headers that are contained in this collection as an array.
|
||||
*/
|
||||
headersArray() {
|
||||
const headers = [];
|
||||
for (const headerKey in this._headersMap) {
|
||||
headers.push(this._headersMap[headerKey]);
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
/**
|
||||
* Get the header names that are contained in this collection.
|
||||
*/
|
||||
headerNames() {
|
||||
const headerNames = [];
|
||||
const headers = this.headersArray();
|
||||
for (let i = 0; i < headers.length; ++i) {
|
||||
headerNames.push(headers[i].name);
|
||||
}
|
||||
return headerNames;
|
||||
}
|
||||
/**
|
||||
* Get the header values that are contained in this collection.
|
||||
*/
|
||||
headerValues() {
|
||||
const headerValues = [];
|
||||
const headers = this.headersArray();
|
||||
for (let i = 0; i < headers.length; ++i) {
|
||||
headerValues.push(headers[i].value);
|
||||
}
|
||||
return headerValues;
|
||||
}
|
||||
/**
|
||||
* Get the JSON object representation of this HTTP header collection.
|
||||
*/
|
||||
toJson(options = {}) {
|
||||
const result = {};
|
||||
if (options.preserveCase) {
|
||||
for (const headerKey in this._headersMap) {
|
||||
const header = this._headersMap[headerKey];
|
||||
result[header.name] = header.value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (const headerKey in this._headersMap) {
|
||||
const header = this._headersMap[headerKey];
|
||||
result[getHeaderKey(header.name)] = header.value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Get the string representation of this HTTP header collection.
|
||||
*/
|
||||
toString() {
|
||||
return JSON.stringify(this.toJson({ preserveCase: true }));
|
||||
}
|
||||
/**
|
||||
* Create a deep clone/copy of this HttpHeaders collection.
|
||||
*/
|
||||
clone() {
|
||||
const resultPreservingCasing = {};
|
||||
for (const headerKey in this._headersMap) {
|
||||
const header = this._headersMap[headerKey];
|
||||
resultPreservingCasing[header.name] = header.value;
|
||||
}
|
||||
return new HttpHeaders(resultPreservingCasing);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=httpHeaders.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/httpHeaders.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/httpHeaders.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/@azure/core-http/dist-esm/src/httpOperationResponse.js
generated
vendored
Normal file
4
node_modules/@azure/core-http/dist-esm/src/httpOperationResponse.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=httpOperationResponse.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/httpOperationResponse.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/httpOperationResponse.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"httpOperationResponse.js","sourceRoot":"","sources":["../../src/httpOperationResponse.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { HttpHeadersLike } from \"./httpHeaders\";\nimport { WebResourceLike } from \"./webResource\";\n\n/**\n * The properties on an HTTP response which will always be present.\n */\nexport interface HttpResponse {\n /**\n * The raw request\n */\n request: WebResourceLike;\n\n /**\n * The HTTP response status (e.g. 200)\n */\n status: number;\n\n /**\n * The HTTP response headers.\n */\n headers: HttpHeadersLike;\n}\n\ndeclare global {\n /**\n * Stub declaration of the browser-only Blob type.\n * Full type information can be obtained by including \"lib\": [\"dom\"] in tsconfig.json.\n */\n interface Blob {}\n}\n\n/**\n * Wrapper object for http request and response. Deserialized object is stored in\n * the `parsedBody` property when the response body is received in JSON or XML.\n */\nexport interface HttpOperationResponse extends HttpResponse {\n /**\n * The parsed HTTP response headers.\n */\n parsedHeaders?: { [key: string]: any };\n\n /**\n * The response body as text (string format)\n */\n bodyAsText?: string | null;\n\n /**\n * The response body as parsed JSON or XML\n */\n parsedBody?: any;\n\n /**\n * BROWSER ONLY\n *\n * The response body as a browser Blob.\n * Always undefined in node.js.\n */\n blobBody?: Promise<Blob>;\n\n /**\n * NODEJS ONLY\n *\n * The response body as a node.js Readable stream.\n * Always undefined in the browser.\n */\n readableStreamBody?: NodeJS.ReadableStream;\n}\n\n/**\n * The flattened response to a REST call.\n * Contains the underlying {@link HttpOperationResponse} as well as\n * the merged properties of the `parsedBody`, `parsedHeaders`, etc.\n */\nexport interface RestResponse {\n /**\n * The underlying HTTP response containing both raw and deserialized response data.\n */\n _response: HttpOperationResponse;\n\n /**\n * The flattened properties described by the `OperationSpec`, deserialized from headers and the HTTP body.\n */\n [key: string]: any;\n}\n"]}
|
25
node_modules/@azure/core-http/dist-esm/src/httpPipelineLogLevel.js
generated
vendored
Normal file
25
node_modules/@azure/core-http/dist-esm/src/httpPipelineLogLevel.js
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/**
|
||||
* The different levels of logs that can be used with the HttpPipelineLogger.
|
||||
*/
|
||||
export var HttpPipelineLogLevel;
|
||||
(function (HttpPipelineLogLevel) {
|
||||
/**
|
||||
* A log level that indicates that no logs will be logged.
|
||||
*/
|
||||
HttpPipelineLogLevel[HttpPipelineLogLevel["OFF"] = 0] = "OFF";
|
||||
/**
|
||||
* An error log.
|
||||
*/
|
||||
HttpPipelineLogLevel[HttpPipelineLogLevel["ERROR"] = 1] = "ERROR";
|
||||
/**
|
||||
* A warning log.
|
||||
*/
|
||||
HttpPipelineLogLevel[HttpPipelineLogLevel["WARNING"] = 2] = "WARNING";
|
||||
/**
|
||||
* An information log.
|
||||
*/
|
||||
HttpPipelineLogLevel[HttpPipelineLogLevel["INFO"] = 3] = "INFO";
|
||||
})(HttpPipelineLogLevel || (HttpPipelineLogLevel = {}));
|
||||
//# sourceMappingURL=httpPipelineLogLevel.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/httpPipelineLogLevel.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/httpPipelineLogLevel.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"httpPipelineLogLevel.js","sourceRoot":"","sources":["../../src/httpPipelineLogLevel.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAN,IAAY,oBAoBX;AApBD,WAAY,oBAAoB;IAC9B;;OAEG;IACH,6DAAG,CAAA;IAEH;;OAEG;IACH,iEAAK,CAAA;IAEL;;OAEG;IACH,qEAAO,CAAA;IAEP;;OAEG;IACH,+DAAI,CAAA;AACN,CAAC,EApBW,oBAAoB,KAApB,oBAAoB,QAoB/B","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * The different levels of logs that can be used with the HttpPipelineLogger.\n */\nexport enum HttpPipelineLogLevel {\n /**\n * A log level that indicates that no logs will be logged.\n */\n OFF,\n\n /**\n * An error log.\n */\n ERROR,\n\n /**\n * A warning log.\n */\n WARNING,\n\n /**\n * An information log.\n */\n INFO,\n}\n"]}
|
35
node_modules/@azure/core-http/dist-esm/src/httpPipelineLogger.js
generated
vendored
Normal file
35
node_modules/@azure/core-http/dist-esm/src/httpPipelineLogger.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { HttpPipelineLogLevel } from "./httpPipelineLogLevel";
|
||||
/**
|
||||
* A HttpPipelineLogger that will send its logs to the console.
|
||||
*/
|
||||
export class ConsoleHttpPipelineLogger {
|
||||
/**
|
||||
* Create a new ConsoleHttpPipelineLogger.
|
||||
* @param minimumLogLevel - The log level threshold for what logs will be logged.
|
||||
*/
|
||||
constructor(minimumLogLevel) {
|
||||
this.minimumLogLevel = minimumLogLevel;
|
||||
}
|
||||
/**
|
||||
* Log the provided message.
|
||||
* @param logLevel - The HttpLogDetailLevel associated with this message.
|
||||
* @param message - The message to log.
|
||||
*/
|
||||
log(logLevel, message) {
|
||||
const logMessage = `${HttpPipelineLogLevel[logLevel]}: ${message}`;
|
||||
switch (logLevel) {
|
||||
case HttpPipelineLogLevel.ERROR:
|
||||
console.error(logMessage);
|
||||
break;
|
||||
case HttpPipelineLogLevel.WARNING:
|
||||
console.warn(logMessage);
|
||||
break;
|
||||
case HttpPipelineLogLevel.INFO:
|
||||
console.log(logMessage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=httpPipelineLogger.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/httpPipelineLogger.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/httpPipelineLogger.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"httpPipelineLogger.js","sourceRoot":"","sources":["../../src/httpPipelineLogger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAoB9D;;GAEG;AACH,MAAM,OAAO,yBAAyB;IACpC;;;OAGG;IACH,YAAmB,eAAqC;QAArC,oBAAe,GAAf,eAAe,CAAsB;IAAG,CAAC;IAE5D;;;;OAIG;IACH,GAAG,CAAC,QAA8B,EAAE,OAAe;QACjD,MAAM,UAAU,GAAG,GAAG,oBAAoB,CAAC,QAAQ,CAAC,KAAK,OAAO,EAAE,CAAC;QACnE,QAAQ,QAAQ,EAAE;YAChB,KAAK,oBAAoB,CAAC,KAAK;gBAC7B,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBAC1B,MAAM;YAER,KAAK,oBAAoB,CAAC,OAAO;gBAC/B,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACzB,MAAM;YAER,KAAK,oBAAoB,CAAC,IAAI;gBAC5B,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBACxB,MAAM;SACT;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { HttpPipelineLogLevel } from \"./httpPipelineLogLevel\";\n\n/**\n * A Logger that can be added to a HttpPipeline. This enables each RequestPolicy to log messages\n * that can be used for debugging purposes.\n */\nexport interface HttpPipelineLogger {\n /**\n * The log level threshold for what logs will be logged.\n */\n minimumLogLevel: HttpPipelineLogLevel;\n\n /**\n * Log the provided message.\n * @param logLevel - The HttpLogDetailLevel associated with this message.\n * @param message - The message to log.\n */\n log(logLevel: HttpPipelineLogLevel, message: string): void;\n}\n\n/**\n * A HttpPipelineLogger that will send its logs to the console.\n */\nexport class ConsoleHttpPipelineLogger implements HttpPipelineLogger {\n /**\n * Create a new ConsoleHttpPipelineLogger.\n * @param minimumLogLevel - The log level threshold for what logs will be logged.\n */\n constructor(public minimumLogLevel: HttpPipelineLogLevel) {}\n\n /**\n * Log the provided message.\n * @param logLevel - The HttpLogDetailLevel associated with this message.\n * @param message - The message to log.\n */\n log(logLevel: HttpPipelineLogLevel, message: string): void {\n const logMessage = `${HttpPipelineLogLevel[logLevel]}: ${message}`;\n switch (logLevel) {\n case HttpPipelineLogLevel.ERROR:\n console.error(logMessage);\n break;\n\n case HttpPipelineLogLevel.WARNING:\n console.warn(logMessage);\n break;\n\n case HttpPipelineLogLevel.INFO:\n console.log(logMessage);\n break;\n }\n }\n}\n"]}
|
5
node_modules/@azure/core-http/dist-esm/src/log.js
generated
vendored
Normal file
5
node_modules/@azure/core-http/dist-esm/src/log.js
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { createClientLogger } from "@azure/logger";
|
||||
export const logger = createClientLogger("core-http");
|
||||
//# sourceMappingURL=log.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/log.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/log.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/log.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"core-http\");\n"]}
|
313
node_modules/@azure/core-http/dist-esm/src/nodeFetchHttpClient.js
generated
vendored
Normal file
313
node_modules/@azure/core-http/dist-esm/src/nodeFetchHttpClient.js
generated
vendored
Normal file
|
@ -0,0 +1,313 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import * as http from "http";
|
||||
import * as https from "https";
|
||||
import * as tough from "tough-cookie";
|
||||
import { AbortController, AbortError } from "@azure/abort-controller";
|
||||
import { HttpHeaders } from "./httpHeaders";
|
||||
import { createProxyAgent, isUrlHttps } from "./proxyAgent";
|
||||
import { Transform } from "stream";
|
||||
import FormData from "form-data";
|
||||
import { RestError } from "./restError";
|
||||
import { logger } from "./log";
|
||||
import node_fetch from "node-fetch";
|
||||
function getCachedAgent(isHttps, agentCache) {
|
||||
return isHttps ? agentCache.httpsAgent : agentCache.httpAgent;
|
||||
}
|
||||
export class ReportTransform extends Transform {
|
||||
constructor(progressCallback) {
|
||||
super();
|
||||
this.progressCallback = progressCallback;
|
||||
this.loadedBytes = 0;
|
||||
}
|
||||
_transform(chunk, _encoding, callback) {
|
||||
this.push(chunk);
|
||||
this.loadedBytes += chunk.length;
|
||||
this.progressCallback({ loadedBytes: this.loadedBytes });
|
||||
callback(undefined);
|
||||
}
|
||||
}
|
||||
function isReadableStream(body) {
|
||||
return body && typeof body.pipe === "function";
|
||||
}
|
||||
function isStreamComplete(stream, aborter) {
|
||||
return new Promise((resolve) => {
|
||||
stream.once("close", () => {
|
||||
aborter === null || aborter === void 0 ? void 0 : aborter.abort();
|
||||
resolve();
|
||||
});
|
||||
stream.once("end", resolve);
|
||||
stream.once("error", resolve);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Transforms a set of headers into the key/value pair defined by {@link HttpHeadersLike}
|
||||
*/
|
||||
export function parseHeaders(headers) {
|
||||
const httpHeaders = new HttpHeaders();
|
||||
headers.forEach((value, key) => {
|
||||
httpHeaders.set(key, value);
|
||||
});
|
||||
return httpHeaders;
|
||||
}
|
||||
/**
|
||||
* An HTTP client that uses `node-fetch`.
|
||||
*/
|
||||
export class NodeFetchHttpClient {
|
||||
constructor() {
|
||||
// a mapping of proxy settings string `${host}:${port}:${username}:${password}` to agent
|
||||
this.proxyAgentMap = new Map();
|
||||
this.keepAliveAgents = {};
|
||||
this.cookieJar = new tough.CookieJar(undefined, { looseMode: true });
|
||||
}
|
||||
/**
|
||||
* Provides minimum viable error handling and the logic that executes the abstract methods.
|
||||
* @param httpRequest - Object representing the outgoing HTTP request.
|
||||
* @returns An object representing the incoming HTTP response.
|
||||
*/
|
||||
async sendRequest(httpRequest) {
|
||||
var _a;
|
||||
if (!httpRequest && typeof httpRequest !== "object") {
|
||||
throw new Error("'httpRequest' (WebResourceLike) cannot be null or undefined and must be of type object.");
|
||||
}
|
||||
const abortController = new AbortController();
|
||||
let abortListener;
|
||||
if (httpRequest.abortSignal) {
|
||||
if (httpRequest.abortSignal.aborted) {
|
||||
throw new AbortError("The operation was aborted.");
|
||||
}
|
||||
abortListener = (event) => {
|
||||
if (event.type === "abort") {
|
||||
abortController.abort();
|
||||
}
|
||||
};
|
||||
httpRequest.abortSignal.addEventListener("abort", abortListener);
|
||||
}
|
||||
if (httpRequest.timeout) {
|
||||
setTimeout(() => {
|
||||
abortController.abort();
|
||||
}, httpRequest.timeout);
|
||||
}
|
||||
if (httpRequest.formData) {
|
||||
const formData = httpRequest.formData;
|
||||
const requestForm = new FormData();
|
||||
const appendFormValue = (key, value) => {
|
||||
// value function probably returns a stream so we can provide a fresh stream on each retry
|
||||
if (typeof value === "function") {
|
||||
value = value();
|
||||
}
|
||||
if (value &&
|
||||
Object.prototype.hasOwnProperty.call(value, "value") &&
|
||||
Object.prototype.hasOwnProperty.call(value, "options")) {
|
||||
requestForm.append(key, value.value, value.options);
|
||||
}
|
||||
else {
|
||||
requestForm.append(key, value);
|
||||
}
|
||||
};
|
||||
for (const formKey of Object.keys(formData)) {
|
||||
const formValue = formData[formKey];
|
||||
if (Array.isArray(formValue)) {
|
||||
for (let j = 0; j < formValue.length; j++) {
|
||||
appendFormValue(formKey, formValue[j]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
appendFormValue(formKey, formValue);
|
||||
}
|
||||
}
|
||||
httpRequest.body = requestForm;
|
||||
httpRequest.formData = undefined;
|
||||
const contentType = httpRequest.headers.get("Content-Type");
|
||||
if (contentType && contentType.indexOf("multipart/form-data") !== -1) {
|
||||
if (typeof requestForm.getBoundary === "function") {
|
||||
httpRequest.headers.set("Content-Type", `multipart/form-data; boundary=${requestForm.getBoundary()}`);
|
||||
}
|
||||
else {
|
||||
// browser will automatically apply a suitable content-type header
|
||||
httpRequest.headers.remove("Content-Type");
|
||||
}
|
||||
}
|
||||
}
|
||||
let body = httpRequest.body
|
||||
? typeof httpRequest.body === "function"
|
||||
? httpRequest.body()
|
||||
: httpRequest.body
|
||||
: undefined;
|
||||
if (httpRequest.onUploadProgress && httpRequest.body) {
|
||||
const onUploadProgress = httpRequest.onUploadProgress;
|
||||
const uploadReportStream = new ReportTransform(onUploadProgress);
|
||||
if (isReadableStream(body)) {
|
||||
body.pipe(uploadReportStream);
|
||||
}
|
||||
else {
|
||||
uploadReportStream.end(body);
|
||||
}
|
||||
body = uploadReportStream;
|
||||
}
|
||||
const platformSpecificRequestInit = await this.prepareRequest(httpRequest);
|
||||
const requestInit = Object.assign({ body: body, headers: httpRequest.headers.rawHeaders(), method: httpRequest.method, signal: abortController.signal, redirect: "manual" }, platformSpecificRequestInit);
|
||||
let operationResponse;
|
||||
try {
|
||||
const response = await this.fetch(httpRequest.url, requestInit);
|
||||
const headers = parseHeaders(response.headers);
|
||||
const streaming = ((_a = httpRequest.streamResponseStatusCodes) === null || _a === void 0 ? void 0 : _a.has(response.status)) ||
|
||||
httpRequest.streamResponseBody;
|
||||
operationResponse = {
|
||||
headers: headers,
|
||||
request: httpRequest,
|
||||
status: response.status,
|
||||
readableStreamBody: streaming
|
||||
? response.body
|
||||
: undefined,
|
||||
bodyAsText: !streaming ? await response.text() : undefined,
|
||||
};
|
||||
const onDownloadProgress = httpRequest.onDownloadProgress;
|
||||
if (onDownloadProgress) {
|
||||
const responseBody = response.body || undefined;
|
||||
if (isReadableStream(responseBody)) {
|
||||
const downloadReportStream = new ReportTransform(onDownloadProgress);
|
||||
responseBody.pipe(downloadReportStream);
|
||||
operationResponse.readableStreamBody = downloadReportStream;
|
||||
}
|
||||
else {
|
||||
const length = parseInt(headers.get("Content-Length")) || undefined;
|
||||
if (length) {
|
||||
// Calling callback for non-stream response for consistency with browser
|
||||
onDownloadProgress({ loadedBytes: length });
|
||||
}
|
||||
}
|
||||
}
|
||||
await this.processRequest(operationResponse);
|
||||
return operationResponse;
|
||||
}
|
||||
catch (error) {
|
||||
const fetchError = error;
|
||||
if (fetchError.code === "ENOTFOUND") {
|
||||
throw new RestError(fetchError.message, RestError.REQUEST_SEND_ERROR, undefined, httpRequest);
|
||||
}
|
||||
else if (fetchError.type === "aborted") {
|
||||
throw new AbortError("The operation was aborted.");
|
||||
}
|
||||
throw fetchError;
|
||||
}
|
||||
finally {
|
||||
// clean up event listener
|
||||
if (httpRequest.abortSignal && abortListener) {
|
||||
let uploadStreamDone = Promise.resolve();
|
||||
if (isReadableStream(body)) {
|
||||
uploadStreamDone = isStreamComplete(body);
|
||||
}
|
||||
let downloadStreamDone = Promise.resolve();
|
||||
if (isReadableStream(operationResponse === null || operationResponse === void 0 ? void 0 : operationResponse.readableStreamBody)) {
|
||||
downloadStreamDone = isStreamComplete(operationResponse.readableStreamBody, abortController);
|
||||
}
|
||||
Promise.all([uploadStreamDone, downloadStreamDone])
|
||||
.then(() => {
|
||||
var _a;
|
||||
(_a = httpRequest.abortSignal) === null || _a === void 0 ? void 0 : _a.removeEventListener("abort", abortListener);
|
||||
return;
|
||||
})
|
||||
.catch((e) => {
|
||||
logger.warning("Error when cleaning up abortListener on httpRequest", e);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
getOrCreateAgent(httpRequest) {
|
||||
var _a;
|
||||
const isHttps = isUrlHttps(httpRequest.url);
|
||||
// At the moment, proxy settings and keepAlive are mutually
|
||||
// exclusive because the 'tunnel' library currently lacks the
|
||||
// ability to create a proxy with keepAlive turned on.
|
||||
if (httpRequest.proxySettings) {
|
||||
const { host, port, username, password } = httpRequest.proxySettings;
|
||||
const key = `${host}:${port}:${username}:${password}`;
|
||||
const proxyAgents = (_a = this.proxyAgentMap.get(key)) !== null && _a !== void 0 ? _a : {};
|
||||
let agent = getCachedAgent(isHttps, proxyAgents);
|
||||
if (agent) {
|
||||
return agent;
|
||||
}
|
||||
const tunnel = createProxyAgent(httpRequest.url, httpRequest.proxySettings, httpRequest.headers);
|
||||
agent = tunnel.agent;
|
||||
if (tunnel.isHttps) {
|
||||
proxyAgents.httpsAgent = tunnel.agent;
|
||||
}
|
||||
else {
|
||||
proxyAgents.httpAgent = tunnel.agent;
|
||||
}
|
||||
this.proxyAgentMap.set(key, proxyAgents);
|
||||
return agent;
|
||||
}
|
||||
else if (httpRequest.keepAlive) {
|
||||
let agent = getCachedAgent(isHttps, this.keepAliveAgents);
|
||||
if (agent) {
|
||||
return agent;
|
||||
}
|
||||
const agentOptions = {
|
||||
keepAlive: httpRequest.keepAlive,
|
||||
};
|
||||
if (isHttps) {
|
||||
agent = this.keepAliveAgents.httpsAgent = new https.Agent(agentOptions);
|
||||
}
|
||||
else {
|
||||
agent = this.keepAliveAgents.httpAgent = new http.Agent(agentOptions);
|
||||
}
|
||||
return agent;
|
||||
}
|
||||
else {
|
||||
return isHttps ? https.globalAgent : http.globalAgent;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Uses `node-fetch` to perform the request.
|
||||
*/
|
||||
// eslint-disable-next-line @azure/azure-sdk/ts-apisurface-standardized-verbs
|
||||
async fetch(input, init) {
|
||||
return node_fetch(input, init);
|
||||
}
|
||||
/**
|
||||
* Prepares a request based on the provided web resource.
|
||||
*/
|
||||
async prepareRequest(httpRequest) {
|
||||
const requestInit = {};
|
||||
if (this.cookieJar && !httpRequest.headers.get("Cookie")) {
|
||||
const cookieString = await new Promise((resolve, reject) => {
|
||||
this.cookieJar.getCookieString(httpRequest.url, (err, cookie) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
resolve(cookie);
|
||||
}
|
||||
});
|
||||
});
|
||||
httpRequest.headers.set("Cookie", cookieString);
|
||||
}
|
||||
// Set the http(s) agent
|
||||
requestInit.agent = this.getOrCreateAgent(httpRequest);
|
||||
requestInit.compress = httpRequest.decompressResponse;
|
||||
return requestInit;
|
||||
}
|
||||
/**
|
||||
* Process an HTTP response. Handles persisting a cookie for subsequent requests if the response has a "Set-Cookie" header.
|
||||
*/
|
||||
async processRequest(operationResponse) {
|
||||
if (this.cookieJar) {
|
||||
const setCookieHeader = operationResponse.headers.get("Set-Cookie");
|
||||
if (setCookieHeader !== undefined) {
|
||||
await new Promise((resolve, reject) => {
|
||||
this.cookieJar.setCookie(setCookieHeader, operationResponse.request.url, { ignoreError: true }, (err) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=nodeFetchHttpClient.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/nodeFetchHttpClient.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/nodeFetchHttpClient.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/@azure/core-http/dist-esm/src/operationArguments.js
generated
vendored
Normal file
4
node_modules/@azure/core-http/dist-esm/src/operationArguments.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=operationArguments.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/operationArguments.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/operationArguments.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"operationArguments.js","sourceRoot":"","sources":["../../src/operationArguments.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RequestOptionsBase } from \"./webResource\";\n\n/**\n * A collection of properties that apply to a single invocation of an operation.\n */\nexport interface OperationArguments {\n /**\n * The parameters that were passed to the operation method.\n */\n [parameterName: string]: any;\n\n /**\n * The optional arugments that are provided to an operation.\n */\n options?: RequestOptionsBase;\n}\n"]}
|
22
node_modules/@azure/core-http/dist-esm/src/operationOptions.js
generated
vendored
Normal file
22
node_modules/@azure/core-http/dist-esm/src/operationOptions.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { __rest } from "tslib";
|
||||
/**
|
||||
* Converts an OperationOptions to a RequestOptionsBase
|
||||
*
|
||||
* @param opts - OperationOptions object to convert to RequestOptionsBase
|
||||
*/
|
||||
export function operationOptionsToRequestOptionsBase(opts) {
|
||||
const { requestOptions, tracingOptions } = opts, additionalOptions = __rest(opts, ["requestOptions", "tracingOptions"]);
|
||||
let result = additionalOptions;
|
||||
if (requestOptions) {
|
||||
result = Object.assign(Object.assign({}, result), requestOptions);
|
||||
}
|
||||
if (tracingOptions) {
|
||||
result.tracingContext = tracingOptions.tracingContext;
|
||||
// By passing spanOptions if they exist at runtime, we're backwards compatible with @azure/core-tracing@preview.13 and earlier.
|
||||
result.spanOptions = tracingOptions === null || tracingOptions === void 0 ? void 0 : tracingOptions.spanOptions;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//# sourceMappingURL=operationOptions.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/operationOptions.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/operationOptions.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"operationOptions.js","sourceRoot":"","sources":["../../src/operationOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAuDlC;;;;GAIG;AACH,MAAM,UAAU,oCAAoC,CAClD,IAAO;IAEP,MAAM,EAAE,cAAc,EAAE,cAAc,KAA2B,IAAI,EAA1B,iBAAiB,UAAK,IAAI,EAA/D,oCAAwD,CAAO,CAAC;IAEtE,IAAI,MAAM,GAAuB,iBAAiB,CAAC;IAEnD,IAAI,cAAc,EAAE;QAClB,MAAM,mCAAQ,MAAM,GAAK,cAAc,CAAE,CAAC;KAC3C;IAED,IAAI,cAAc,EAAE;QAClB,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC;QACtD,+HAA+H;QAC/H,MAAM,CAAC,WAAW,GAAI,cAAsB,aAAtB,cAAc,uBAAd,cAAc,CAAU,WAAW,CAAC;KAC3D;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { RequestOptionsBase, TransferProgressEvent } from \"./webResource\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { HttpOperationResponse } from \"./httpOperationResponse\";\nimport { OperationTracingOptions } from \"@azure/core-tracing\";\n\n/**\n * The base options type for all operations.\n */\nexport interface OperationOptions {\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n /**\n * Options used when creating and sending HTTP requests for this operation.\n */\n requestOptions?: OperationRequestOptions;\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n}\n\n/**\n * Options that allow configuring the handling of HTTP requests made by an SDK operation.\n */\nexport interface OperationRequestOptions {\n /**\n * User defined custom request headers that will be applied before the request is sent.\n */\n customHeaders?: { [key: string]: string };\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n /**\n * Whether or not the HttpOperationResponse should be deserialized. If this is undefined, then the\n * HttpOperationResponse should be deserialized.\n */\n shouldDeserialize?: boolean | ((response: HttpOperationResponse) => boolean);\n}\n\n/**\n * Converts an OperationOptions to a RequestOptionsBase\n *\n * @param opts - OperationOptions object to convert to RequestOptionsBase\n */\nexport function operationOptionsToRequestOptionsBase<T extends OperationOptions>(\n opts: T\n): RequestOptionsBase {\n const { requestOptions, tracingOptions, ...additionalOptions } = opts;\n\n let result: RequestOptionsBase = additionalOptions;\n\n if (requestOptions) {\n result = { ...result, ...requestOptions };\n }\n\n if (tracingOptions) {\n result.tracingContext = tracingOptions.tracingContext;\n // By passing spanOptions if they exist at runtime, we're backwards compatible with @azure/core-tracing@preview.13 and earlier.\n result.spanOptions = (tracingOptions as any)?.spanOptions;\n }\n\n return result;\n}\n"]}
|
24
node_modules/@azure/core-http/dist-esm/src/operationParameter.js
generated
vendored
Normal file
24
node_modules/@azure/core-http/dist-esm/src/operationParameter.js
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/**
|
||||
* Get the path to this parameter's value as a dotted string (a.b.c).
|
||||
* @param parameter - The parameter to get the path string for.
|
||||
* @returns The path to this parameter's value as a dotted string.
|
||||
*/
|
||||
export function getPathStringFromParameter(parameter) {
|
||||
return getPathStringFromParameterPath(parameter.parameterPath, parameter.mapper);
|
||||
}
|
||||
export function getPathStringFromParameterPath(parameterPath, mapper) {
|
||||
let result;
|
||||
if (typeof parameterPath === "string") {
|
||||
result = parameterPath;
|
||||
}
|
||||
else if (Array.isArray(parameterPath)) {
|
||||
result = parameterPath.join(".");
|
||||
}
|
||||
else {
|
||||
result = mapper.serializedName;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//# sourceMappingURL=operationParameter.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/operationParameter.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/operationParameter.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"operationParameter.js","sourceRoot":"","sources":["../../src/operationParameter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAqDlC;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,SAA6B;IACtE,OAAO,8BAA8B,CAAC,SAAS,CAAC,aAAa,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;AACnF,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC5C,aAA4B,EAC5B,MAAc;IAEd,IAAI,MAAc,CAAC;IACnB,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;QACrC,MAAM,GAAG,aAAa,CAAC;KACxB;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACvC,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAClC;SAAM;QACL,MAAM,GAAG,MAAM,CAAC,cAAe,CAAC;KACjC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Mapper } from \"./serializer\";\nimport { QueryCollectionFormat } from \"./queryCollectionFormat\";\n\n/**\n * A path which describes how to access a particular property in a given object data source. May be a single property name, an array that denotes nested property names, or a set of multiple named properties with paths in the case of complex object values.\n */\nexport type ParameterPath = string | string[] | { [propertyName: string]: ParameterPath };\n\n/**\n * A common interface that all Operation parameter's extend.\n */\nexport interface OperationParameter {\n /**\n * The path to this parameter's value in OperationArguments or the object that contains paths for\n * each property's value in OperationArguments.\n */\n parameterPath: ParameterPath;\n\n /**\n * The mapper that defines how to validate and serialize this parameter's value.\n */\n mapper: Mapper;\n}\n\n/**\n * A parameter for an operation that will be substituted into the operation's request URL.\n */\nexport interface OperationURLParameter extends OperationParameter {\n /**\n * Whether or not to skip encoding the URL parameter's value before adding it to the URL.\n */\n skipEncoding?: boolean;\n}\n\n/**\n * A parameter for an operation that will be added as a query parameter to the operation's HTTP\n * request.\n */\nexport interface OperationQueryParameter extends OperationParameter {\n /**\n * Whether or not to skip encoding the query parameter's value before adding it to the URL.\n */\n skipEncoding?: boolean;\n\n /**\n * If this query parameter's value is a collection, what type of format should the value be\n * converted to.\n */\n collectionFormat?: QueryCollectionFormat;\n}\n\n/**\n * Get the path to this parameter's value as a dotted string (a.b.c).\n * @param parameter - The parameter to get the path string for.\n * @returns The path to this parameter's value as a dotted string.\n */\nexport function getPathStringFromParameter(parameter: OperationParameter): string {\n return getPathStringFromParameterPath(parameter.parameterPath, parameter.mapper);\n}\n\nexport function getPathStringFromParameterPath(\n parameterPath: ParameterPath,\n mapper: Mapper\n): string {\n let result: string;\n if (typeof parameterPath === \"string\") {\n result = parameterPath;\n } else if (Array.isArray(parameterPath)) {\n result = parameterPath.join(\".\");\n } else {\n result = mapper.serializedName!;\n }\n return result;\n}\n"]}
|
4
node_modules/@azure/core-http/dist-esm/src/operationResponse.js
generated
vendored
Normal file
4
node_modules/@azure/core-http/dist-esm/src/operationResponse.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=operationResponse.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/operationResponse.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/operationResponse.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"operationResponse.js","sourceRoot":"","sources":["../../src/operationResponse.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Mapper } from \"./serializer\";\n\n/**\n * An OperationResponse that can be returned from an operation request for a single status code.\n */\nexport interface OperationResponse {\n /**\n * The mapper that will be used to deserialize the response headers.\n */\n headersMapper?: Mapper;\n\n /**\n * The mapper that will be used to deserialize the response body.\n */\n bodyMapper?: Mapper;\n\n /**\n * Indicates if this is an error response\n */\n isError?: boolean;\n}\n"]}
|
19
node_modules/@azure/core-http/dist-esm/src/operationSpec.js
generated
vendored
Normal file
19
node_modules/@azure/core-http/dist-esm/src/operationSpec.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { MapperType } from "./serializer";
|
||||
/**
|
||||
* Gets the list of status codes for streaming responses.
|
||||
* @internal
|
||||
*/
|
||||
export function getStreamResponseStatusCodes(operationSpec) {
|
||||
const result = new Set();
|
||||
for (const statusCode in operationSpec.responses) {
|
||||
const operationResponse = operationSpec.responses[statusCode];
|
||||
if (operationResponse.bodyMapper &&
|
||||
operationResponse.bodyMapper.type.name === MapperType.Stream) {
|
||||
result.add(Number(statusCode));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//# sourceMappingURL=operationSpec.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/operationSpec.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/operationSpec.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"operationSpec.js","sourceRoot":"","sources":["../../src/operationSpec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAc,MAAM,cAAc,CAAC;AA8FtD;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,aAA4B;IACvE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,KAAK,MAAM,UAAU,IAAI,aAAa,CAAC,SAAS,EAAE;QAChD,MAAM,iBAAiB,GAAG,aAAa,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC9D,IACE,iBAAiB,CAAC,UAAU;YAC5B,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,MAAM,EAC5D;YACA,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;SAChC;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { MapperType, Serializer } from \"./serializer\";\nimport {\n OperationParameter,\n OperationQueryParameter,\n OperationURLParameter,\n} from \"./operationParameter\";\nimport { HttpMethods } from \"./webResource\";\nimport { OperationResponse } from \"./operationResponse\";\n\n/**\n * A specification that defines how to perform a particular service operation over HTTP, including how to properly serialize request information into and deserialize response information into an object payload returnable by the {@link ServiceClient}.\n */\nexport interface OperationSpec {\n /**\n * The serializer to use in this operation.\n */\n readonly serializer: Serializer;\n\n /**\n * The HTTP method that should be used by requests for this operation.\n */\n readonly httpMethod: HttpMethods;\n\n /**\n * The URL that was provided in the service's specification. This will still have all of the URL\n * template variables in it. If this is not provided when the OperationSpec is created, then it\n * will be populated by a \"baseUri\" property on the ServiceClient.\n */\n readonly baseUrl?: string;\n\n /**\n * The fixed path for this operation's URL. This will still have all of the URL template variables\n * in it.\n */\n readonly path?: string;\n\n /**\n * The content type of the request body. This value will be used as the \"Content-Type\" header if\n * it is provided.\n */\n readonly contentType?: string;\n\n /**\n * The media type of the request body.\n * This value can be used to aide in serialization if it is provided.\n */\n readonly mediaType?:\n | \"json\"\n | \"xml\"\n | \"form\"\n | \"binary\"\n | \"multipart\"\n | \"text\"\n | \"unknown\"\n | string;\n /**\n * The parameter that will be used to construct the HTTP request's body.\n */\n readonly requestBody?: OperationParameter;\n\n /**\n * Whether or not this operation uses XML request and response bodies.\n */\n readonly isXML?: boolean;\n\n /**\n * The parameters to the operation method that will be substituted into the constructed URL.\n */\n readonly urlParameters?: ReadonlyArray<OperationURLParameter>;\n\n /**\n * The parameters to the operation method that will be added to the constructed URL's query.\n */\n readonly queryParameters?: ReadonlyArray<OperationQueryParameter>;\n\n /**\n * The parameters to the operation method that will be converted to headers on the operation's\n * HTTP request.\n */\n readonly headerParameters?: ReadonlyArray<OperationParameter>;\n\n /**\n * The parameters to the operation method that will be used to create a formdata body for the\n * operation's HTTP request.\n */\n readonly formDataParameters?: ReadonlyArray<OperationParameter>;\n\n /**\n * The different types of responses that this operation can return based on what status code is\n * returned.\n */\n readonly responses: { [responseCode: string]: OperationResponse };\n}\n\n/**\n * Gets the list of status codes for streaming responses.\n * @internal\n */\nexport function getStreamResponseStatusCodes(operationSpec: OperationSpec): Set<number> {\n const result = new Set<number>();\n for (const statusCode in operationSpec.responses) {\n const operationResponse = operationSpec.responses[statusCode];\n if (\n operationResponse.bodyMapper &&\n operationResponse.bodyMapper.type.name === MapperType.Stream\n ) {\n result.add(Number(statusCode));\n }\n }\n return result;\n}\n"]}
|
4
node_modules/@azure/core-http/dist-esm/src/pipelineOptions.js
generated
vendored
Normal file
4
node_modules/@azure/core-http/dist-esm/src/pipelineOptions.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export {};
|
||||
//# sourceMappingURL=pipelineOptions.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/pipelineOptions.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/pipelineOptions.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"pipelineOptions.js","sourceRoot":"","sources":["../../src/pipelineOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { DeserializationOptions } from \"./policies/deserializationPolicy\";\nimport { HttpClient } from \"./httpClient\";\nimport { KeepAliveOptions } from \"./policies/keepAlivePolicy\";\nimport { LogPolicyOptions } from \"./policies/logPolicy\";\nimport { ProxyOptions } from \"./serviceClient\";\nimport { RedirectOptions } from \"./policies/redirectPolicy\";\nimport { RetryOptions } from \"./policies/exponentialRetryPolicy\";\nimport { UserAgentOptions } from \"./policies/userAgentPolicy\";\n\n/**\n * Defines options that are used to configure the HTTP pipeline for\n * an SDK client.\n */\nexport interface PipelineOptions {\n /**\n * The HttpClient implementation to use for outgoing HTTP requests. Defaults\n * to DefaultHttpClient.\n */\n httpClient?: HttpClient;\n\n /**\n * Options that control how to retry failed requests.\n */\n retryOptions?: RetryOptions;\n\n /**\n * Options to configure a proxy for outgoing requests.\n */\n proxyOptions?: ProxyOptions;\n\n /**\n * Options for how HTTP connections should be maintained for future\n * requests.\n */\n keepAliveOptions?: KeepAliveOptions;\n\n /**\n * Options for how redirect responses are handled.\n */\n redirectOptions?: RedirectOptions;\n\n /**\n * Options for adding user agent details to outgoing requests.\n */\n userAgentOptions?: UserAgentOptions;\n}\n\n/**\n * Defines options that are used to configure internal options of\n * the HTTP pipeline for an SDK client.\n */\nexport interface InternalPipelineOptions extends PipelineOptions {\n /**\n * Options to configure API response deserialization.\n */\n deserializationOptions?: DeserializationOptions;\n\n /**\n * Options to configure request/response logging.\n */\n loggingOptions?: LogPolicyOptions;\n\n /**\n * Configure whether to decompress response according to Accept-Encoding header (node-fetch only)\n */\n decompressResponse?: boolean;\n\n /**\n * Send JSON Array payloads as NDJSON.\n */\n sendStreamingJson?: boolean;\n}\n"]}
|
183
node_modules/@azure/core-http/dist-esm/src/policies/bearerTokenAuthenticationPolicy.js
generated
vendored
Normal file
183
node_modules/@azure/core-http/dist-esm/src/policies/bearerTokenAuthenticationPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,183 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "../policies/requestPolicy";
|
||||
import { Constants } from "../util/constants";
|
||||
import { delay } from "../util/delay";
|
||||
// Default options for the cycler if none are provided
|
||||
export const DEFAULT_CYCLER_OPTIONS = {
|
||||
forcedRefreshWindowInMs: 1000,
|
||||
retryIntervalInMs: 3000,
|
||||
refreshWindowInMs: 1000 * 60 * 2, // Start refreshing 2m before expiry
|
||||
};
|
||||
/**
|
||||
* Converts an an unreliable access token getter (which may resolve with null)
|
||||
* into an AccessTokenGetter by retrying the unreliable getter in a regular
|
||||
* interval.
|
||||
*
|
||||
* @param getAccessToken - a function that produces a promise of an access
|
||||
* token that may fail by returning null
|
||||
* @param retryIntervalInMs - the time (in milliseconds) to wait between retry
|
||||
* attempts
|
||||
* @param timeoutInMs - the timestamp after which the refresh attempt will fail,
|
||||
* throwing an exception
|
||||
* @returns - a promise that, if it resolves, will resolve with an access token
|
||||
*/
|
||||
async function beginRefresh(getAccessToken, retryIntervalInMs, timeoutInMs) {
|
||||
// This wrapper handles exceptions gracefully as long as we haven't exceeded
|
||||
// the timeout.
|
||||
async function tryGetAccessToken() {
|
||||
if (Date.now() < timeoutInMs) {
|
||||
try {
|
||||
return await getAccessToken();
|
||||
}
|
||||
catch (_a) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const finalToken = await getAccessToken();
|
||||
// Timeout is up, so throw if it's still null
|
||||
if (finalToken === null) {
|
||||
throw new Error("Failed to refresh access token.");
|
||||
}
|
||||
return finalToken;
|
||||
}
|
||||
}
|
||||
let token = await tryGetAccessToken();
|
||||
while (token === null) {
|
||||
await delay(retryIntervalInMs);
|
||||
token = await tryGetAccessToken();
|
||||
}
|
||||
return token;
|
||||
}
|
||||
/**
|
||||
* Creates a token cycler from a credential, scopes, and optional settings.
|
||||
*
|
||||
* A token cycler represents a way to reliably retrieve a valid access token
|
||||
* from a TokenCredential. It will handle initializing the token, refreshing it
|
||||
* when it nears expiration, and synchronizes refresh attempts to avoid
|
||||
* concurrency hazards.
|
||||
*
|
||||
* @param credential - the underlying TokenCredential that provides the access
|
||||
* token
|
||||
* @param scopes - the scopes to request authorization for
|
||||
* @param tokenCyclerOptions - optionally override default settings for the cycler
|
||||
*
|
||||
* @returns - a function that reliably produces a valid access token
|
||||
*/
|
||||
function createTokenCycler(credential, scopes, tokenCyclerOptions) {
|
||||
let refreshWorker = null;
|
||||
let token = null;
|
||||
const options = Object.assign(Object.assign({}, DEFAULT_CYCLER_OPTIONS), tokenCyclerOptions);
|
||||
/**
|
||||
* This little holder defines several predicates that we use to construct
|
||||
* the rules of refreshing the token.
|
||||
*/
|
||||
const cycler = {
|
||||
/**
|
||||
* Produces true if a refresh job is currently in progress.
|
||||
*/
|
||||
get isRefreshing() {
|
||||
return refreshWorker !== null;
|
||||
},
|
||||
/**
|
||||
* Produces true if the cycler SHOULD refresh (we are within the refresh
|
||||
* window and not already refreshing)
|
||||
*/
|
||||
get shouldRefresh() {
|
||||
var _a;
|
||||
return (!cycler.isRefreshing &&
|
||||
((_a = token === null || token === void 0 ? void 0 : token.expiresOnTimestamp) !== null && _a !== void 0 ? _a : 0) - options.refreshWindowInMs < Date.now());
|
||||
},
|
||||
/**
|
||||
* Produces true if the cycler MUST refresh (null or nearly-expired
|
||||
* token).
|
||||
*/
|
||||
get mustRefresh() {
|
||||
return (token === null || token.expiresOnTimestamp - options.forcedRefreshWindowInMs < Date.now());
|
||||
},
|
||||
};
|
||||
/**
|
||||
* Starts a refresh job or returns the existing job if one is already
|
||||
* running.
|
||||
*/
|
||||
function refresh(getTokenOptions) {
|
||||
var _a;
|
||||
if (!cycler.isRefreshing) {
|
||||
// We bind `scopes` here to avoid passing it around a lot
|
||||
const tryGetAccessToken = () => credential.getToken(scopes, getTokenOptions);
|
||||
// Take advantage of promise chaining to insert an assignment to `token`
|
||||
// before the refresh can be considered done.
|
||||
refreshWorker = beginRefresh(tryGetAccessToken, options.retryIntervalInMs,
|
||||
// If we don't have a token, then we should timeout immediately
|
||||
(_a = token === null || token === void 0 ? void 0 : token.expiresOnTimestamp) !== null && _a !== void 0 ? _a : Date.now())
|
||||
.then((_token) => {
|
||||
refreshWorker = null;
|
||||
token = _token;
|
||||
return token;
|
||||
})
|
||||
.catch((reason) => {
|
||||
// We also should reset the refresher if we enter a failed state. All
|
||||
// existing awaiters will throw, but subsequent requests will start a
|
||||
// new retry chain.
|
||||
refreshWorker = null;
|
||||
token = null;
|
||||
throw reason;
|
||||
});
|
||||
}
|
||||
return refreshWorker;
|
||||
}
|
||||
return async (tokenOptions) => {
|
||||
//
|
||||
// Simple rules:
|
||||
// - If we MUST refresh, then return the refresh task, blocking
|
||||
// the pipeline until a token is available.
|
||||
// - If we SHOULD refresh, then run refresh but don't return it
|
||||
// (we can still use the cached token).
|
||||
// - Return the token, since it's fine if we didn't return in
|
||||
// step 1.
|
||||
//
|
||||
if (cycler.mustRefresh)
|
||||
return refresh(tokenOptions);
|
||||
if (cycler.shouldRefresh) {
|
||||
refresh(tokenOptions);
|
||||
}
|
||||
return token;
|
||||
};
|
||||
}
|
||||
// #endregion
|
||||
/**
|
||||
* Creates a new factory for a RequestPolicy that applies a bearer token to
|
||||
* the requests' `Authorization` headers.
|
||||
*
|
||||
* @param credential - The TokenCredential implementation that can supply the bearer token.
|
||||
* @param scopes - The scopes for which the bearer token applies.
|
||||
*/
|
||||
export function bearerTokenAuthenticationPolicy(credential, scopes) {
|
||||
// This simple function encapsulates the entire process of reliably retrieving the token
|
||||
const getToken = createTokenCycler(credential, scopes /* , options */);
|
||||
class BearerTokenAuthenticationPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, options) {
|
||||
super(nextPolicy, options);
|
||||
}
|
||||
async sendRequest(webResource) {
|
||||
if (!webResource.url.toLowerCase().startsWith("https://")) {
|
||||
throw new Error("Bearer token authentication is not permitted for non-TLS protected (non-https) URLs.");
|
||||
}
|
||||
const { token } = await getToken({
|
||||
abortSignal: webResource.abortSignal,
|
||||
tracingOptions: {
|
||||
tracingContext: webResource.tracingContext,
|
||||
},
|
||||
});
|
||||
webResource.headers.set(Constants.HeaderConstants.AUTHORIZATION, `Bearer ${token}`);
|
||||
return this._nextPolicy.sendRequest(webResource);
|
||||
}
|
||||
}
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new BearerTokenAuthenticationPolicy(nextPolicy, options);
|
||||
},
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=bearerTokenAuthenticationPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/bearerTokenAuthenticationPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/bearerTokenAuthenticationPolicy.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
239
node_modules/@azure/core-http/dist-esm/src/policies/deserializationPolicy.js
generated
vendored
Normal file
239
node_modules/@azure/core-http/dist-esm/src/policies/deserializationPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,239 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
import { XML_CHARKEY } from "../util/serializer.common";
|
||||
import { MapperType } from "../serializer";
|
||||
import { RestError } from "../restError";
|
||||
import { parseXML } from "../util/xml";
|
||||
/**
|
||||
* Create a new serialization RequestPolicyCreator that will serialized HTTP request bodies as they
|
||||
* pass through the HTTP pipeline.
|
||||
*/
|
||||
export function deserializationPolicy(deserializationContentTypes, parsingOptions) {
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new DeserializationPolicy(nextPolicy, options, deserializationContentTypes, parsingOptions);
|
||||
},
|
||||
};
|
||||
}
|
||||
export const defaultJsonContentTypes = ["application/json", "text/json"];
|
||||
export const defaultXmlContentTypes = ["application/xml", "application/atom+xml"];
|
||||
export const DefaultDeserializationOptions = {
|
||||
expectedContentTypes: {
|
||||
json: defaultJsonContentTypes,
|
||||
xml: defaultXmlContentTypes,
|
||||
},
|
||||
};
|
||||
/**
|
||||
* A RequestPolicy that will deserialize HTTP response bodies and headers as they pass through the
|
||||
* HTTP pipeline.
|
||||
*/
|
||||
export class DeserializationPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, requestPolicyOptions, deserializationContentTypes, parsingOptions = {}) {
|
||||
var _a;
|
||||
super(nextPolicy, requestPolicyOptions);
|
||||
this.jsonContentTypes =
|
||||
(deserializationContentTypes && deserializationContentTypes.json) || defaultJsonContentTypes;
|
||||
this.xmlContentTypes =
|
||||
(deserializationContentTypes && deserializationContentTypes.xml) || defaultXmlContentTypes;
|
||||
this.xmlCharKey = (_a = parsingOptions.xmlCharKey) !== null && _a !== void 0 ? _a : XML_CHARKEY;
|
||||
}
|
||||
async sendRequest(request) {
|
||||
return this._nextPolicy.sendRequest(request).then((response) => deserializeResponseBody(this.jsonContentTypes, this.xmlContentTypes, response, {
|
||||
xmlCharKey: this.xmlCharKey,
|
||||
}));
|
||||
}
|
||||
}
|
||||
function getOperationResponse(parsedResponse) {
|
||||
let result;
|
||||
const request = parsedResponse.request;
|
||||
const operationSpec = request.operationSpec;
|
||||
if (operationSpec) {
|
||||
const operationResponseGetter = request.operationResponseGetter;
|
||||
if (!operationResponseGetter) {
|
||||
result = operationSpec.responses[parsedResponse.status];
|
||||
}
|
||||
else {
|
||||
result = operationResponseGetter(operationSpec, parsedResponse);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function shouldDeserializeResponse(parsedResponse) {
|
||||
const shouldDeserialize = parsedResponse.request.shouldDeserialize;
|
||||
let result;
|
||||
if (shouldDeserialize === undefined) {
|
||||
result = true;
|
||||
}
|
||||
else if (typeof shouldDeserialize === "boolean") {
|
||||
result = shouldDeserialize;
|
||||
}
|
||||
else {
|
||||
result = shouldDeserialize(parsedResponse);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Given a particular set of content types to parse as either JSON or XML, consumes the HTTP response to produce the result object defined by the request's {@link OperationSpec}.
|
||||
* @param jsonContentTypes - Response content types to parse the body as JSON.
|
||||
* @param xmlContentTypes - Response content types to parse the body as XML.
|
||||
* @param response - HTTP Response from the pipeline.
|
||||
* @param options - Options to the serializer, mostly for configuring the XML parser if needed.
|
||||
* @returns A parsed {@link HttpOperationResponse} object that can be returned by the {@link ServiceClient}.
|
||||
*/
|
||||
export function deserializeResponseBody(jsonContentTypes, xmlContentTypes, response, options = {}) {
|
||||
var _a, _b, _c;
|
||||
const updatedOptions = {
|
||||
rootName: (_a = options.rootName) !== null && _a !== void 0 ? _a : "",
|
||||
includeRoot: (_b = options.includeRoot) !== null && _b !== void 0 ? _b : false,
|
||||
xmlCharKey: (_c = options.xmlCharKey) !== null && _c !== void 0 ? _c : XML_CHARKEY,
|
||||
};
|
||||
return parse(jsonContentTypes, xmlContentTypes, response, updatedOptions).then((parsedResponse) => {
|
||||
if (!shouldDeserializeResponse(parsedResponse)) {
|
||||
return parsedResponse;
|
||||
}
|
||||
const operationSpec = parsedResponse.request.operationSpec;
|
||||
if (!operationSpec || !operationSpec.responses) {
|
||||
return parsedResponse;
|
||||
}
|
||||
const responseSpec = getOperationResponse(parsedResponse);
|
||||
const { error, shouldReturnResponse } = handleErrorResponse(parsedResponse, operationSpec, responseSpec);
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
else if (shouldReturnResponse) {
|
||||
return parsedResponse;
|
||||
}
|
||||
// An operation response spec does exist for current status code, so
|
||||
// use it to deserialize the response.
|
||||
if (responseSpec) {
|
||||
if (responseSpec.bodyMapper) {
|
||||
let valueToDeserialize = parsedResponse.parsedBody;
|
||||
if (operationSpec.isXML && responseSpec.bodyMapper.type.name === MapperType.Sequence) {
|
||||
valueToDeserialize =
|
||||
typeof valueToDeserialize === "object"
|
||||
? valueToDeserialize[responseSpec.bodyMapper.xmlElementName]
|
||||
: [];
|
||||
}
|
||||
try {
|
||||
parsedResponse.parsedBody = operationSpec.serializer.deserialize(responseSpec.bodyMapper, valueToDeserialize, "operationRes.parsedBody", options);
|
||||
}
|
||||
catch (innerError) {
|
||||
const restError = new RestError(`Error ${innerError} occurred in deserializing the responseBody - ${parsedResponse.bodyAsText}`, undefined, parsedResponse.status, parsedResponse.request, parsedResponse);
|
||||
throw restError;
|
||||
}
|
||||
}
|
||||
else if (operationSpec.httpMethod === "HEAD") {
|
||||
// head methods never have a body, but we return a boolean to indicate presence/absence of the resource
|
||||
parsedResponse.parsedBody = response.status >= 200 && response.status < 300;
|
||||
}
|
||||
if (responseSpec.headersMapper) {
|
||||
parsedResponse.parsedHeaders = operationSpec.serializer.deserialize(responseSpec.headersMapper, parsedResponse.headers.rawHeaders(), "operationRes.parsedHeaders", options);
|
||||
}
|
||||
}
|
||||
return parsedResponse;
|
||||
});
|
||||
}
|
||||
function isOperationSpecEmpty(operationSpec) {
|
||||
const expectedStatusCodes = Object.keys(operationSpec.responses);
|
||||
return (expectedStatusCodes.length === 0 ||
|
||||
(expectedStatusCodes.length === 1 && expectedStatusCodes[0] === "default"));
|
||||
}
|
||||
function handleErrorResponse(parsedResponse, operationSpec, responseSpec) {
|
||||
var _a;
|
||||
const isSuccessByStatus = 200 <= parsedResponse.status && parsedResponse.status < 300;
|
||||
const isExpectedStatusCode = isOperationSpecEmpty(operationSpec)
|
||||
? isSuccessByStatus
|
||||
: !!responseSpec;
|
||||
if (isExpectedStatusCode) {
|
||||
if (responseSpec) {
|
||||
if (!responseSpec.isError) {
|
||||
return { error: null, shouldReturnResponse: false };
|
||||
}
|
||||
}
|
||||
else {
|
||||
return { error: null, shouldReturnResponse: false };
|
||||
}
|
||||
}
|
||||
const errorResponseSpec = responseSpec !== null && responseSpec !== void 0 ? responseSpec : operationSpec.responses.default;
|
||||
const streaming = ((_a = parsedResponse.request.streamResponseStatusCodes) === null || _a === void 0 ? void 0 : _a.has(parsedResponse.status)) ||
|
||||
parsedResponse.request.streamResponseBody;
|
||||
const initialErrorMessage = streaming
|
||||
? `Unexpected status code: ${parsedResponse.status}`
|
||||
: parsedResponse.bodyAsText;
|
||||
const error = new RestError(initialErrorMessage, undefined, parsedResponse.status, parsedResponse.request, parsedResponse);
|
||||
// If the item failed but there's no error spec or default spec to deserialize the error,
|
||||
// we should fail so we just throw the parsed response
|
||||
if (!errorResponseSpec) {
|
||||
throw error;
|
||||
}
|
||||
const defaultBodyMapper = errorResponseSpec.bodyMapper;
|
||||
const defaultHeadersMapper = errorResponseSpec.headersMapper;
|
||||
try {
|
||||
// If error response has a body, try to deserialize it using default body mapper.
|
||||
// Then try to extract error code & message from it
|
||||
if (parsedResponse.parsedBody) {
|
||||
const parsedBody = parsedResponse.parsedBody;
|
||||
let parsedError;
|
||||
if (defaultBodyMapper) {
|
||||
let valueToDeserialize = parsedBody;
|
||||
if (operationSpec.isXML && defaultBodyMapper.type.name === MapperType.Sequence) {
|
||||
valueToDeserialize =
|
||||
typeof parsedBody === "object" ? parsedBody[defaultBodyMapper.xmlElementName] : [];
|
||||
}
|
||||
parsedError = operationSpec.serializer.deserialize(defaultBodyMapper, valueToDeserialize, "error.response.parsedBody");
|
||||
}
|
||||
const internalError = parsedBody.error || parsedError || parsedBody;
|
||||
error.code = internalError.code;
|
||||
if (internalError.message) {
|
||||
error.message = internalError.message;
|
||||
}
|
||||
if (defaultBodyMapper) {
|
||||
error.response.parsedBody = parsedError;
|
||||
}
|
||||
}
|
||||
// If error response has headers, try to deserialize it using default header mapper
|
||||
if (parsedResponse.headers && defaultHeadersMapper) {
|
||||
error.response.parsedHeaders = operationSpec.serializer.deserialize(defaultHeadersMapper, parsedResponse.headers.rawHeaders(), "operationRes.parsedHeaders");
|
||||
}
|
||||
}
|
||||
catch (defaultError) {
|
||||
error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody - "${parsedResponse.bodyAsText}" for the default response.`;
|
||||
}
|
||||
return { error, shouldReturnResponse: false };
|
||||
}
|
||||
function parse(jsonContentTypes, xmlContentTypes, operationResponse, opts) {
|
||||
var _a;
|
||||
const errorHandler = (err) => {
|
||||
const msg = `Error "${err}" occurred while parsing the response body - ${operationResponse.bodyAsText}.`;
|
||||
const errCode = err.code || RestError.PARSE_ERROR;
|
||||
const e = new RestError(msg, errCode, operationResponse.status, operationResponse.request, operationResponse);
|
||||
return Promise.reject(e);
|
||||
};
|
||||
const streaming = ((_a = operationResponse.request.streamResponseStatusCodes) === null || _a === void 0 ? void 0 : _a.has(operationResponse.status)) ||
|
||||
operationResponse.request.streamResponseBody;
|
||||
if (!streaming && operationResponse.bodyAsText) {
|
||||
const text = operationResponse.bodyAsText;
|
||||
const contentType = operationResponse.headers.get("Content-Type") || "";
|
||||
const contentComponents = !contentType
|
||||
? []
|
||||
: contentType.split(";").map((component) => component.toLowerCase());
|
||||
if (contentComponents.length === 0 ||
|
||||
contentComponents.some((component) => jsonContentTypes.indexOf(component) !== -1)) {
|
||||
return new Promise((resolve) => {
|
||||
operationResponse.parsedBody = JSON.parse(text);
|
||||
resolve(operationResponse);
|
||||
}).catch(errorHandler);
|
||||
}
|
||||
else if (contentComponents.some((component) => xmlContentTypes.indexOf(component) !== -1)) {
|
||||
return parseXML(text, opts)
|
||||
.then((body) => {
|
||||
operationResponse.parsedBody = body;
|
||||
return operationResponse;
|
||||
})
|
||||
.catch(errorHandler);
|
||||
}
|
||||
}
|
||||
return Promise.resolve(operationResponse);
|
||||
}
|
||||
//# sourceMappingURL=deserializationPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/deserializationPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/deserializationPolicy.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
28
node_modules/@azure/core-http/dist-esm/src/policies/disableResponseDecompressionPolicy.browser.js
generated
vendored
Normal file
28
node_modules/@azure/core-http/dist-esm/src/policies/disableResponseDecompressionPolicy.browser.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/*
|
||||
* NOTE: When moving this file, please update "browser" section in package.json
|
||||
*/
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
const DisbleResponseDecompressionNotSupportedInBrowser = new Error("DisableResponseDecompressionPolicy is not supported in browser environment");
|
||||
/**
|
||||
* {@link DisableResponseDecompressionPolicy} is not supported in browser and attempting
|
||||
* to use it will results in error being thrown.
|
||||
*/
|
||||
export function disableResponseDecompressionPolicy() {
|
||||
return {
|
||||
create: (_nextPolicy, _options) => {
|
||||
throw DisbleResponseDecompressionNotSupportedInBrowser;
|
||||
},
|
||||
};
|
||||
}
|
||||
export class DisableResponseDecompressionPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, options) {
|
||||
super(nextPolicy, options);
|
||||
throw DisbleResponseDecompressionNotSupportedInBrowser;
|
||||
}
|
||||
async sendRequest(_request) {
|
||||
throw DisbleResponseDecompressionNotSupportedInBrowser;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=disableResponseDecompressionPolicy.browser.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/disableResponseDecompressionPolicy.browser.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/disableResponseDecompressionPolicy.browser.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"disableResponseDecompressionPolicy.browser.js","sourceRoot":"","sources":["../../../src/policies/disableResponseDecompressionPolicy.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,OAAO,EACL,iBAAiB,GAIlB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,gDAAgD,GAAG,IAAI,KAAK,CAChE,4EAA4E,CAC7E,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,kCAAkC;IAChD,OAAO;QACL,MAAM,EAAE,CAAC,WAA0B,EAAE,QAA8B,EAAE,EAAE;YACrE,MAAM,gDAAgD,CAAC;QACzD,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,kCAAmC,SAAQ,iBAAiB;IACvE,YAAY,UAAyB,EAAE,OAA6B;QAClE,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC3B,MAAM,gDAAgD,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,QAAqB;QAC5C,MAAM,gDAAgD,CAAC;IACzD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/*\n * NOTE: When moving this file, please update \"browser\" section in package.json\n */\nimport {\n BaseRequestPolicy,\n RequestPolicy,\n RequestPolicyFactory,\n RequestPolicyOptions,\n} from \"./requestPolicy\";\nimport { HttpOperationResponse } from \"../httpOperationResponse\";\nimport { WebResource } from \"../webResource\";\n\nconst DisbleResponseDecompressionNotSupportedInBrowser = new Error(\n \"DisableResponseDecompressionPolicy is not supported in browser environment\"\n);\n\n/**\n * {@link DisableResponseDecompressionPolicy} is not supported in browser and attempting\n * to use it will results in error being thrown.\n */\nexport function disableResponseDecompressionPolicy(): RequestPolicyFactory {\n return {\n create: (_nextPolicy: RequestPolicy, _options: RequestPolicyOptions) => {\n throw DisbleResponseDecompressionNotSupportedInBrowser;\n },\n };\n}\n\nexport class DisableResponseDecompressionPolicy extends BaseRequestPolicy {\n constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions) {\n super(nextPolicy, options);\n throw DisbleResponseDecompressionNotSupportedInBrowser;\n }\n\n public async sendRequest(_request: WebResource): Promise<HttpOperationResponse> {\n throw DisbleResponseDecompressionNotSupportedInBrowser;\n }\n}\n"]}
|
42
node_modules/@azure/core-http/dist-esm/src/policies/disableResponseDecompressionPolicy.js
generated
vendored
Normal file
42
node_modules/@azure/core-http/dist-esm/src/policies/disableResponseDecompressionPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
/**
|
||||
* Returns a request policy factory that can be used to create an instance of
|
||||
* {@link DisableResponseDecompressionPolicy}.
|
||||
*/
|
||||
export function disableResponseDecompressionPolicy() {
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new DisableResponseDecompressionPolicy(nextPolicy, options);
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A policy to disable response decompression according to Accept-Encoding header
|
||||
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding
|
||||
*/
|
||||
export class DisableResponseDecompressionPolicy extends BaseRequestPolicy {
|
||||
/**
|
||||
* Creates an instance of DisableResponseDecompressionPolicy.
|
||||
*
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
*/
|
||||
// The parent constructor is protected.
|
||||
/* eslint-disable-next-line @typescript-eslint/no-useless-constructor */
|
||||
constructor(nextPolicy, options) {
|
||||
super(nextPolicy, options);
|
||||
}
|
||||
/**
|
||||
* Sends out request.
|
||||
*
|
||||
* @param request -
|
||||
* @returns
|
||||
*/
|
||||
async sendRequest(request) {
|
||||
request.decompressResponse = false;
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=disableResponseDecompressionPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/disableResponseDecompressionPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/disableResponseDecompressionPolicy.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"disableResponseDecompressionPolicy.js","sourceRoot":"","sources":["../../../src/policies/disableResponseDecompressionPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,iBAAiB,GAIlB,MAAM,iBAAiB,CAAC;AAIzB;;;GAGG;AACH,MAAM,UAAU,kCAAkC;IAChD,OAAO;QACL,MAAM,EAAE,CAAC,UAAyB,EAAE,OAA6B,EAAE,EAAE;YACnE,OAAO,IAAI,kCAAkC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACrE,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,kCAAmC,SAAQ,iBAAiB;IACvE;;;;;OAKG;IACH,uCAAuC;IACvC,wEAAwE;IACxE,YAAY,UAAyB,EAAE,OAA6B;QAClE,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,WAAW,CAAC,OAAoB;QAC3C,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC;QACnC,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n BaseRequestPolicy,\n RequestPolicy,\n RequestPolicyFactory,\n RequestPolicyOptions,\n} from \"./requestPolicy\";\nimport { HttpOperationResponse } from \"../httpOperationResponse\";\nimport { WebResource } from \"../webResource\";\n\n/**\n * Returns a request policy factory that can be used to create an instance of\n * {@link DisableResponseDecompressionPolicy}.\n */\nexport function disableResponseDecompressionPolicy(): RequestPolicyFactory {\n return {\n create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => {\n return new DisableResponseDecompressionPolicy(nextPolicy, options);\n },\n };\n}\n\n/**\n * A policy to disable response decompression according to Accept-Encoding header\n * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding\n */\nexport class DisableResponseDecompressionPolicy extends BaseRequestPolicy {\n /**\n * Creates an instance of DisableResponseDecompressionPolicy.\n *\n * @param nextPolicy -\n * @param options -\n */\n // The parent constructor is protected.\n /* eslint-disable-next-line @typescript-eslint/no-useless-constructor */\n constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions) {\n super(nextPolicy, options);\n }\n\n /**\n * Sends out request.\n *\n * @param request -\n * @returns\n */\n public async sendRequest(request: WebResource): Promise<HttpOperationResponse> {\n request.decompressResponse = false;\n return this._nextPolicy.sendRequest(request);\n }\n}\n"]}
|
106
node_modules/@azure/core-http/dist-esm/src/policies/exponentialRetryPolicy.js
generated
vendored
Normal file
106
node_modules/@azure/core-http/dist-esm/src/policies/exponentialRetryPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,106 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
import { DEFAULT_CLIENT_MAX_RETRY_INTERVAL, DEFAULT_CLIENT_RETRY_COUNT, DEFAULT_CLIENT_RETRY_INTERVAL, isNumber, shouldRetry, updateRetryData, } from "../util/exponentialBackoffStrategy";
|
||||
import { Constants } from "../util/constants";
|
||||
import { RestError } from "../restError";
|
||||
import { delay } from "../util/delay";
|
||||
import { logger } from "../log";
|
||||
/**
|
||||
* Policy that retries the request as many times as configured for as long as the max retry time interval specified, each retry waiting longer to begin than the last time.
|
||||
* @param retryCount - Maximum number of retries.
|
||||
* @param retryInterval - Base time between retries.
|
||||
* @param maxRetryInterval - Maximum time to wait between retries.
|
||||
*/
|
||||
export function exponentialRetryPolicy(retryCount, retryInterval, maxRetryInterval) {
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new ExponentialRetryPolicy(nextPolicy, options, retryCount, retryInterval, maxRetryInterval);
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Describes the Retry Mode type. Currently supporting only Exponential.
|
||||
*/
|
||||
export var RetryMode;
|
||||
(function (RetryMode) {
|
||||
/**
|
||||
* Currently supported retry mode.
|
||||
* Each time a retry happens, it will take exponentially more time than the last time.
|
||||
*/
|
||||
RetryMode[RetryMode["Exponential"] = 0] = "Exponential";
|
||||
})(RetryMode || (RetryMode = {}));
|
||||
export const DefaultRetryOptions = {
|
||||
maxRetries: DEFAULT_CLIENT_RETRY_COUNT,
|
||||
retryDelayInMs: DEFAULT_CLIENT_RETRY_INTERVAL,
|
||||
maxRetryDelayInMs: DEFAULT_CLIENT_MAX_RETRY_INTERVAL,
|
||||
};
|
||||
/**
|
||||
* Instantiates a new "ExponentialRetryPolicyFilter" instance.
|
||||
*/
|
||||
export class ExponentialRetryPolicy extends BaseRequestPolicy {
|
||||
/**
|
||||
* @param nextPolicy - The next RequestPolicy in the pipeline chain.
|
||||
* @param options - The options for this RequestPolicy.
|
||||
* @param retryCount - The client retry count.
|
||||
* @param retryInterval - The client retry interval, in milliseconds.
|
||||
* @param minRetryInterval - The minimum retry interval, in milliseconds.
|
||||
* @param maxRetryInterval - The maximum retry interval, in milliseconds.
|
||||
*/
|
||||
constructor(nextPolicy, options, retryCount, retryInterval, maxRetryInterval) {
|
||||
super(nextPolicy, options);
|
||||
this.retryCount = isNumber(retryCount) ? retryCount : DEFAULT_CLIENT_RETRY_COUNT;
|
||||
this.retryInterval = isNumber(retryInterval) ? retryInterval : DEFAULT_CLIENT_RETRY_INTERVAL;
|
||||
this.maxRetryInterval = isNumber(maxRetryInterval)
|
||||
? maxRetryInterval
|
||||
: DEFAULT_CLIENT_MAX_RETRY_INTERVAL;
|
||||
}
|
||||
sendRequest(request) {
|
||||
return this._nextPolicy
|
||||
.sendRequest(request.clone())
|
||||
.then((response) => retry(this, request, response))
|
||||
.catch((error) => retry(this, request, error.response, undefined, error));
|
||||
}
|
||||
}
|
||||
async function retry(policy, request, response, retryData, requestError) {
|
||||
function shouldPolicyRetry(responseParam) {
|
||||
const statusCode = responseParam === null || responseParam === void 0 ? void 0 : responseParam.status;
|
||||
if (statusCode === 503 && (response === null || response === void 0 ? void 0 : response.headers.get(Constants.HeaderConstants.RETRY_AFTER))) {
|
||||
return false;
|
||||
}
|
||||
if (statusCode === undefined ||
|
||||
(statusCode < 500 && statusCode !== 408) ||
|
||||
statusCode === 501 ||
|
||||
statusCode === 505) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
retryData = updateRetryData({
|
||||
retryInterval: policy.retryInterval,
|
||||
minRetryInterval: 0,
|
||||
maxRetryInterval: policy.maxRetryInterval,
|
||||
}, retryData, requestError);
|
||||
const isAborted = request.abortSignal && request.abortSignal.aborted;
|
||||
if (!isAborted && shouldRetry(policy.retryCount, shouldPolicyRetry, retryData, response)) {
|
||||
logger.info(`Retrying request in ${retryData.retryInterval}`);
|
||||
try {
|
||||
await delay(retryData.retryInterval);
|
||||
const res = await policy._nextPolicy.sendRequest(request.clone());
|
||||
return retry(policy, request, res, retryData);
|
||||
}
|
||||
catch (err) {
|
||||
return retry(policy, request, response, retryData, err);
|
||||
}
|
||||
}
|
||||
else if (isAborted || requestError || !response) {
|
||||
// If the operation failed in the end, return all errors instead of just the last one
|
||||
const err = retryData.error ||
|
||||
new RestError("Failed to send the request.", RestError.REQUEST_SEND_ERROR, response && response.status, response && response.request, response);
|
||||
throw err;
|
||||
}
|
||||
else {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=exponentialRetryPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/exponentialRetryPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/exponentialRetryPolicy.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
27
node_modules/@azure/core-http/dist-esm/src/policies/generateClientRequestIdPolicy.js
generated
vendored
Normal file
27
node_modules/@azure/core-http/dist-esm/src/policies/generateClientRequestIdPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
/**
|
||||
* Creates a policy that assigns a unique request id to outgoing requests.
|
||||
* @param requestIdHeaderName - The name of the header to use when assigning the unique id to the request.
|
||||
*/
|
||||
export function generateClientRequestIdPolicy(requestIdHeaderName = "x-ms-client-request-id") {
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new GenerateClientRequestIdPolicy(nextPolicy, options, requestIdHeaderName);
|
||||
},
|
||||
};
|
||||
}
|
||||
export class GenerateClientRequestIdPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, options, _requestIdHeaderName) {
|
||||
super(nextPolicy, options);
|
||||
this._requestIdHeaderName = _requestIdHeaderName;
|
||||
}
|
||||
sendRequest(request) {
|
||||
if (!request.headers.contains(this._requestIdHeaderName)) {
|
||||
request.headers.set(this._requestIdHeaderName, request.requestId);
|
||||
}
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=generateClientRequestIdPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/generateClientRequestIdPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/generateClientRequestIdPolicy.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"generateClientRequestIdPolicy.js","sourceRoot":"","sources":["../../../src/policies/generateClientRequestIdPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,iBAAiB,GAIlB,MAAM,iBAAiB,CAAC;AAIzB;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAC3C,mBAAmB,GAAG,wBAAwB;IAE9C,OAAO;QACL,MAAM,EAAE,CAAC,UAAyB,EAAE,OAA6B,EAAE,EAAE;YACnE,OAAO,IAAI,6BAA6B,CAAC,UAAU,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC;QACrF,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,6BAA8B,SAAQ,iBAAiB;IAClE,YACE,UAAyB,EACzB,OAA6B,EACrB,oBAA4B;QAEpC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAFnB,yBAAoB,GAApB,oBAAoB,CAAQ;IAGtC,CAAC;IAEM,WAAW,CAAC,OAAwB;QACzC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE;YACxD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;SACnE;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n BaseRequestPolicy,\n RequestPolicy,\n RequestPolicyFactory,\n RequestPolicyOptions,\n} from \"./requestPolicy\";\nimport { HttpOperationResponse } from \"../httpOperationResponse\";\nimport { WebResourceLike } from \"../webResource\";\n\n/**\n * Creates a policy that assigns a unique request id to outgoing requests.\n * @param requestIdHeaderName - The name of the header to use when assigning the unique id to the request.\n */\nexport function generateClientRequestIdPolicy(\n requestIdHeaderName = \"x-ms-client-request-id\"\n): RequestPolicyFactory {\n return {\n create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => {\n return new GenerateClientRequestIdPolicy(nextPolicy, options, requestIdHeaderName);\n },\n };\n}\n\nexport class GenerateClientRequestIdPolicy extends BaseRequestPolicy {\n constructor(\n nextPolicy: RequestPolicy,\n options: RequestPolicyOptions,\n private _requestIdHeaderName: string\n ) {\n super(nextPolicy, options);\n }\n\n public sendRequest(request: WebResourceLike): Promise<HttpOperationResponse> {\n if (!request.headers.contains(this._requestIdHeaderName)) {\n request.headers.set(this._requestIdHeaderName, request.requestId);\n }\n return this._nextPolicy.sendRequest(request);\n }\n}\n"]}
|
48
node_modules/@azure/core-http/dist-esm/src/policies/keepAlivePolicy.js
generated
vendored
Normal file
48
node_modules/@azure/core-http/dist-esm/src/policies/keepAlivePolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
/**
|
||||
* By default, HTTP connections are maintained for future requests.
|
||||
*/
|
||||
export const DefaultKeepAliveOptions = {
|
||||
enable: true,
|
||||
};
|
||||
/**
|
||||
* Creates a policy that controls whether HTTP connections are maintained on future requests.
|
||||
* @param keepAliveOptions - Keep alive options. By default, HTTP connections are maintained for future requests.
|
||||
* @returns An instance of the {@link KeepAlivePolicy}
|
||||
*/
|
||||
export function keepAlivePolicy(keepAliveOptions) {
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new KeepAlivePolicy(nextPolicy, options, keepAliveOptions || DefaultKeepAliveOptions);
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* KeepAlivePolicy is a policy used to control keep alive settings for every request.
|
||||
*/
|
||||
export class KeepAlivePolicy extends BaseRequestPolicy {
|
||||
/**
|
||||
* Creates an instance of KeepAlivePolicy.
|
||||
*
|
||||
* @param nextPolicy -
|
||||
* @param options -
|
||||
* @param keepAliveOptions -
|
||||
*/
|
||||
constructor(nextPolicy, options, keepAliveOptions) {
|
||||
super(nextPolicy, options);
|
||||
this.keepAliveOptions = keepAliveOptions;
|
||||
}
|
||||
/**
|
||||
* Sends out request.
|
||||
*
|
||||
* @param request -
|
||||
* @returns
|
||||
*/
|
||||
async sendRequest(request) {
|
||||
request.keepAlive = this.keepAliveOptions.enable;
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=keepAlivePolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/keepAlivePolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/keepAlivePolicy.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"keepAlivePolicy.js","sourceRoot":"","sources":["../../../src/policies/keepAlivePolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,iBAAiB,GAIlB,MAAM,iBAAiB,CAAC;AAgBzB;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAqB;IACvD,MAAM,EAAE,IAAI;CACb,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,gBAAmC;IACjE,OAAO;QACL,MAAM,EAAE,CAAC,UAAyB,EAAE,OAA6B,EAAE,EAAE;YACnE,OAAO,IAAI,eAAe,CAAC,UAAU,EAAE,OAAO,EAAE,gBAAgB,IAAI,uBAAuB,CAAC,CAAC;QAC/F,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,iBAAiB;IACpD;;;;;;OAMG;IACH,YACE,UAAyB,EACzB,OAA6B,EACZ,gBAAkC;QAEnD,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAFV,qBAAgB,GAAhB,gBAAgB,CAAkB;IAGrD,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,WAAW,CAAC,OAAwB;QAC/C,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC;QACjD,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n BaseRequestPolicy,\n RequestPolicy,\n RequestPolicyFactory,\n RequestPolicyOptions,\n} from \"./requestPolicy\";\nimport { HttpOperationResponse } from \"../httpOperationResponse\";\nimport { WebResourceLike } from \"../webResource\";\n\n/**\n * Options for how HTTP connections should be maintained for future\n * requests.\n */\nexport interface KeepAliveOptions {\n /**\n * When true, connections will be kept alive for multiple requests.\n * Defaults to true.\n */\n enable: boolean;\n}\n\n/**\n * By default, HTTP connections are maintained for future requests.\n */\nexport const DefaultKeepAliveOptions: KeepAliveOptions = {\n enable: true,\n};\n\n/**\n * Creates a policy that controls whether HTTP connections are maintained on future requests.\n * @param keepAliveOptions - Keep alive options. By default, HTTP connections are maintained for future requests.\n * @returns An instance of the {@link KeepAlivePolicy}\n */\nexport function keepAlivePolicy(keepAliveOptions?: KeepAliveOptions): RequestPolicyFactory {\n return {\n create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => {\n return new KeepAlivePolicy(nextPolicy, options, keepAliveOptions || DefaultKeepAliveOptions);\n },\n };\n}\n\n/**\n * KeepAlivePolicy is a policy used to control keep alive settings for every request.\n */\nexport class KeepAlivePolicy extends BaseRequestPolicy {\n /**\n * Creates an instance of KeepAlivePolicy.\n *\n * @param nextPolicy -\n * @param options -\n * @param keepAliveOptions -\n */\n constructor(\n nextPolicy: RequestPolicy,\n options: RequestPolicyOptions,\n private readonly keepAliveOptions: KeepAliveOptions\n ) {\n super(nextPolicy, options);\n }\n\n /**\n * Sends out request.\n *\n * @param request -\n * @returns\n */\n public async sendRequest(request: WebResourceLike): Promise<HttpOperationResponse> {\n request.keepAlive = this.keepAliveOptions.enable;\n return this._nextPolicy.sendRequest(request);\n }\n}\n"]}
|
78
node_modules/@azure/core-http/dist-esm/src/policies/logPolicy.js
generated
vendored
Normal file
78
node_modules/@azure/core-http/dist-esm/src/policies/logPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
import { Sanitizer } from "../util/sanitizer";
|
||||
import { logger as coreLogger } from "../log";
|
||||
/**
|
||||
* Creates a policy that logs information about the outgoing request and the incoming responses.
|
||||
* @param loggingOptions - Logging options.
|
||||
* @returns An instance of the {@link LogPolicy}
|
||||
*/
|
||||
export function logPolicy(loggingOptions = {}) {
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new LogPolicy(nextPolicy, options, loggingOptions);
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A policy that logs information about the outgoing request and the incoming responses.
|
||||
*/
|
||||
export class LogPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, options, { logger = coreLogger.info, allowedHeaderNames = [], allowedQueryParameters = [], } = {}) {
|
||||
super(nextPolicy, options);
|
||||
this.logger = logger;
|
||||
this.sanitizer = new Sanitizer({ allowedHeaderNames, allowedQueryParameters });
|
||||
}
|
||||
/**
|
||||
* Header names whose values will be logged when logging is enabled. Defaults to
|
||||
* Date, traceparent, x-ms-client-request-id, and x-ms-request id. Any headers
|
||||
* specified in this field will be added to that list. Any other values will
|
||||
* be written to logs as "REDACTED".
|
||||
* @deprecated Pass these into the constructor instead.
|
||||
*/
|
||||
get allowedHeaderNames() {
|
||||
return this.sanitizer.allowedHeaderNames;
|
||||
}
|
||||
/**
|
||||
* Header names whose values will be logged when logging is enabled. Defaults to
|
||||
* Date, traceparent, x-ms-client-request-id, and x-ms-request id. Any headers
|
||||
* specified in this field will be added to that list. Any other values will
|
||||
* be written to logs as "REDACTED".
|
||||
* @deprecated Pass these into the constructor instead.
|
||||
*/
|
||||
set allowedHeaderNames(allowedHeaderNames) {
|
||||
this.sanitizer.allowedHeaderNames = allowedHeaderNames;
|
||||
}
|
||||
/**
|
||||
* Query string names whose values will be logged when logging is enabled. By default no
|
||||
* query string values are logged.
|
||||
* @deprecated Pass these into the constructor instead.
|
||||
*/
|
||||
get allowedQueryParameters() {
|
||||
return this.sanitizer.allowedQueryParameters;
|
||||
}
|
||||
/**
|
||||
* Query string names whose values will be logged when logging is enabled. By default no
|
||||
* query string values are logged.
|
||||
* @deprecated Pass these into the constructor instead.
|
||||
*/
|
||||
set allowedQueryParameters(allowedQueryParameters) {
|
||||
this.sanitizer.allowedQueryParameters = allowedQueryParameters;
|
||||
}
|
||||
sendRequest(request) {
|
||||
if (!this.logger.enabled)
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
this.logRequest(request);
|
||||
return this._nextPolicy.sendRequest(request).then((response) => this.logResponse(response));
|
||||
}
|
||||
logRequest(request) {
|
||||
this.logger(`Request: ${this.sanitizer.sanitize(request)}`);
|
||||
}
|
||||
logResponse(response) {
|
||||
this.logger(`Response status code: ${response.status}`);
|
||||
this.logger(`Headers: ${this.sanitizer.sanitize(response.headers)}`);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=logPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/logPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/logPolicy.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
14
node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.browser.js
generated
vendored
Normal file
14
node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.browser.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
export function getDefaultUserAgentKey() {
|
||||
return "x-ms-useragent";
|
||||
}
|
||||
export function getPlatformSpecificData() {
|
||||
const navigator = self.navigator;
|
||||
const osInfo = {
|
||||
key: "OS",
|
||||
value: (navigator.oscpu || navigator.platform).replace(" ", ""),
|
||||
};
|
||||
return [osInfo];
|
||||
}
|
||||
//# sourceMappingURL=msRestUserAgentPolicy.browser.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.browser.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.browser.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"msRestUserAgentPolicy.browser.js","sourceRoot":"","sources":["../../../src/policies/msRestUserAgentPolicy.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAalC,MAAM,UAAU,sBAAsB;IACpC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAwB,CAAC;IAChD,MAAM,MAAM,GAAG;QACb,GAAG,EAAE,IAAI;QACT,KAAK,EAAE,CAAC,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;KAChE,CAAC;IAEF,OAAO,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/*\n * NOTE: When moving this file, please update \"browser\" section in package.json.\n */\n\nimport { TelemetryInfo } from \"./userAgentPolicy\";\n\ninterface NavigatorEx extends Navigator {\n // oscpu is not yet standards-compliant, but can not be undefined in TypeScript 3.6.2\n readonly oscpu: string;\n}\n\nexport function getDefaultUserAgentKey(): string {\n return \"x-ms-useragent\";\n}\n\nexport function getPlatformSpecificData(): TelemetryInfo[] {\n const navigator = self.navigator as NavigatorEx;\n const osInfo = {\n key: \"OS\",\n value: (navigator.oscpu || navigator.platform).replace(\" \", \"\"),\n };\n\n return [osInfo];\n}\n"]}
|
19
node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.js
generated
vendored
Normal file
19
node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import * as os from "os";
|
||||
import { Constants } from "../util/constants";
|
||||
export function getDefaultUserAgentKey() {
|
||||
return Constants.HeaderConstants.USER_AGENT;
|
||||
}
|
||||
export function getPlatformSpecificData() {
|
||||
const runtimeInfo = {
|
||||
key: "Node",
|
||||
value: process.version,
|
||||
};
|
||||
const osInfo = {
|
||||
key: "OS",
|
||||
value: `(${os.arch()}-${os.type()}-${os.release()})`,
|
||||
};
|
||||
return [runtimeInfo, osInfo];
|
||||
}
|
||||
//# sourceMappingURL=msRestUserAgentPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"msRestUserAgentPolicy.js","sourceRoot":"","sources":["../../../src/policies/msRestUserAgentPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,MAAM,UAAU,sBAAsB;IACpC,OAAO,SAAS,CAAC,eAAe,CAAC,UAAU,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,MAAM,WAAW,GAAG;QAClB,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,OAAO,CAAC,OAAO;KACvB,CAAC;IAEF,MAAM,MAAM,GAAG;QACb,GAAG,EAAE,IAAI;QACT,KAAK,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG;KACrD,CAAC;IAEF,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as os from \"os\";\nimport { Constants } from \"../util/constants\";\nimport { TelemetryInfo } from \"./userAgentPolicy\";\n\nexport function getDefaultUserAgentKey(): string {\n return Constants.HeaderConstants.USER_AGENT;\n}\n\nexport function getPlatformSpecificData(): TelemetryInfo[] {\n const runtimeInfo = {\n key: \"Node\",\n value: process.version,\n };\n\n const osInfo = {\n key: \"OS\",\n value: `(${os.arch()}-${os.type()}-${os.release()})`,\n };\n\n return [runtimeInfo, osInfo];\n}\n"]}
|
19
node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.native.js
generated
vendored
Normal file
19
node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.native.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
const { Platform } = require("react-native"); // eslint-disable-line import/no-extraneous-dependencies, @typescript-eslint/no-require-imports
|
||||
export function getDefaultUserAgentKey() {
|
||||
return "x-ms-useragent";
|
||||
}
|
||||
export function getPlatformSpecificData() {
|
||||
const { major, minor, patch } = Platform.constants.reactNativeVersion;
|
||||
const runtimeInfo = {
|
||||
key: "react-native",
|
||||
value: `${major}.${minor}.${patch}`,
|
||||
};
|
||||
const osInfo = {
|
||||
key: "OS",
|
||||
value: `${Platform.OS}-${Platform.Version}`,
|
||||
};
|
||||
return [runtimeInfo, osInfo];
|
||||
}
|
||||
//# sourceMappingURL=msRestUserAgentPolicy.native.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.native.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.native.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"msRestUserAgentPolicy.native.js","sourceRoot":"","sources":["../../../src/policies/msRestUserAgentPolicy.native.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,+FAA+F;AAE7I,MAAM,UAAU,sBAAsB;IACpC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,kBAAkB,CAAC;IACtE,MAAM,WAAW,GAAG;QAClB,GAAG,EAAE,cAAc;QACnB,KAAK,EAAE,GAAG,KAAK,IAAI,KAAK,IAAI,KAAK,EAAE;KACpC,CAAC;IAEF,MAAM,MAAM,GAAG;QACb,GAAG,EAAE,IAAI;QACT,KAAK,EAAE,GAAG,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,OAAO,EAAE;KAC5C,CAAC;IAEF,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/*\n * NOTE: When moving this file, please update \"react-native\" section in package.json.\n */\n\nimport { TelemetryInfo } from \"./userAgentPolicy\";\nconst { Platform } = require(\"react-native\"); // eslint-disable-line import/no-extraneous-dependencies, @typescript-eslint/no-require-imports\n\nexport function getDefaultUserAgentKey(): string {\n return \"x-ms-useragent\";\n}\n\nexport function getPlatformSpecificData(): TelemetryInfo[] {\n const { major, minor, patch } = Platform.constants.reactNativeVersion;\n const runtimeInfo = {\n key: \"react-native\",\n value: `${major}.${minor}.${patch}`,\n };\n\n const osInfo = {\n key: \"OS\",\n value: `${Platform.OS}-${Platform.Version}`,\n };\n\n return [runtimeInfo, osInfo];\n}\n"]}
|
37
node_modules/@azure/core-http/dist-esm/src/policies/ndJsonPolicy.js
generated
vendored
Normal file
37
node_modules/@azure/core-http/dist-esm/src/policies/ndJsonPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
// BaseRequestPolicy has a protected constructor.
|
||||
/* eslint-disable @typescript-eslint/no-useless-constructor */
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
export function ndJsonPolicy() {
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new NdJsonPolicy(nextPolicy, options);
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* NdJsonPolicy that formats a JSON array as newline-delimited JSON
|
||||
*/
|
||||
class NdJsonPolicy extends BaseRequestPolicy {
|
||||
/**
|
||||
* Creates an instance of KeepAlivePolicy.
|
||||
*/
|
||||
constructor(nextPolicy, options) {
|
||||
super(nextPolicy, options);
|
||||
}
|
||||
/**
|
||||
* Sends a request.
|
||||
*/
|
||||
async sendRequest(request) {
|
||||
// There currently isn't a good way to bypass the serializer
|
||||
if (typeof request.body === "string" && request.body.startsWith("[")) {
|
||||
const body = JSON.parse(request.body);
|
||||
if (Array.isArray(body)) {
|
||||
request.body = body.map((item) => JSON.stringify(item) + "\n").join("");
|
||||
}
|
||||
}
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ndJsonPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/ndJsonPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/ndJsonPolicy.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"ndJsonPolicy.js","sourceRoot":"","sources":["../../../src/policies/ndJsonPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,iDAAiD;AACjD,8DAA8D;AAE9D,OAAO,EACL,iBAAiB,GAIlB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,UAAU,YAAY;IAC1B,OAAO;QACL,MAAM,EAAE,CAAC,UAAyB,EAAE,OAA6B,EAAE,EAAE;YACnE,OAAO,IAAI,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,YAAa,SAAQ,iBAAiB;IAC1C;;OAEG;IACH,YAAY,UAAyB,EAAE,OAA6B;QAClE,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,WAAW,CAAC,OAAwB;QAC/C,4DAA4D;QAC5D,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACpE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACvB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;aACzE;SACF;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// BaseRequestPolicy has a protected constructor.\n/* eslint-disable @typescript-eslint/no-useless-constructor */\n\nimport {\n BaseRequestPolicy,\n RequestPolicy,\n RequestPolicyFactory,\n RequestPolicyOptions,\n} from \"./requestPolicy\";\nimport { HttpOperationResponse } from \"../httpOperationResponse\";\nimport { WebResourceLike } from \"../webResource\";\n\nexport function ndJsonPolicy(): RequestPolicyFactory {\n return {\n create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => {\n return new NdJsonPolicy(nextPolicy, options);\n },\n };\n}\n\n/**\n * NdJsonPolicy that formats a JSON array as newline-delimited JSON\n */\nclass NdJsonPolicy extends BaseRequestPolicy {\n /**\n * Creates an instance of KeepAlivePolicy.\n */\n constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions) {\n super(nextPolicy, options);\n }\n\n /**\n * Sends a request.\n */\n public async sendRequest(request: WebResourceLike): Promise<HttpOperationResponse> {\n // There currently isn't a good way to bypass the serializer\n if (typeof request.body === \"string\" && request.body.startsWith(\"[\")) {\n const body = JSON.parse(request.body);\n if (Array.isArray(body)) {\n request.body = body.map((item) => JSON.stringify(item) + \"\\n\").join(\"\");\n }\n }\n return this._nextPolicy.sendRequest(request);\n }\n}\n"]}
|
24
node_modules/@azure/core-http/dist-esm/src/policies/proxyPolicy.browser.js
generated
vendored
Normal file
24
node_modules/@azure/core-http/dist-esm/src/policies/proxyPolicy.browser.js
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
const proxyNotSupportedInBrowser = new Error("ProxyPolicy is not supported in browser environment");
|
||||
export function getDefaultProxySettings(_proxyUrl) {
|
||||
return undefined;
|
||||
}
|
||||
export function proxyPolicy(_proxySettings) {
|
||||
return {
|
||||
create: (_nextPolicy, _options) => {
|
||||
throw proxyNotSupportedInBrowser;
|
||||
},
|
||||
};
|
||||
}
|
||||
export class ProxyPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, options) {
|
||||
super(nextPolicy, options);
|
||||
throw proxyNotSupportedInBrowser;
|
||||
}
|
||||
sendRequest(_request) {
|
||||
throw proxyNotSupportedInBrowser;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=proxyPolicy.browser.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/proxyPolicy.browser.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/proxyPolicy.browser.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"proxyPolicy.browser.js","sourceRoot":"","sources":["../../../src/policies/proxyPolicy.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,iBAAiB,GAIlB,MAAM,iBAAiB,CAAC;AAKzB,MAAM,0BAA0B,GAAG,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;AAEpG,MAAM,UAAU,uBAAuB,CAAC,SAAkB;IACxD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,cAA8B;IACxD,OAAO;QACL,MAAM,EAAE,CAAC,WAA0B,EAAE,QAA8B,EAAE,EAAE;YACrE,MAAM,0BAA0B,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IAChD,YAAY,UAAyB,EAAE,OAA6B;QAClE,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC3B,MAAM,0BAA0B,CAAC;IACnC,CAAC;IAEM,WAAW,CAAC,QAAyB;QAC1C,MAAM,0BAA0B,CAAC;IACnC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n BaseRequestPolicy,\n RequestPolicy,\n RequestPolicyFactory,\n RequestPolicyOptions,\n} from \"./requestPolicy\";\nimport { HttpOperationResponse } from \"../httpOperationResponse\";\nimport { ProxySettings } from \"../serviceClient\";\nimport { WebResourceLike } from \"../webResource\";\n\nconst proxyNotSupportedInBrowser = new Error(\"ProxyPolicy is not supported in browser environment\");\n\nexport function getDefaultProxySettings(_proxyUrl?: string): ProxySettings | undefined {\n return undefined;\n}\n\nexport function proxyPolicy(_proxySettings?: ProxySettings): RequestPolicyFactory {\n return {\n create: (_nextPolicy: RequestPolicy, _options: RequestPolicyOptions) => {\n throw proxyNotSupportedInBrowser;\n },\n };\n}\n\nexport class ProxyPolicy extends BaseRequestPolicy {\n constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions) {\n super(nextPolicy, options);\n throw proxyNotSupportedInBrowser;\n }\n\n public sendRequest(_request: WebResourceLike): Promise<HttpOperationResponse> {\n throw proxyNotSupportedInBrowser;\n }\n}\n"]}
|
150
node_modules/@azure/core-http/dist-esm/src/policies/proxyPolicy.js
generated
vendored
Normal file
150
node_modules/@azure/core-http/dist-esm/src/policies/proxyPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,150 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
import { Constants } from "../util/constants";
|
||||
import { URLBuilder } from "../url";
|
||||
import { getEnvironmentValue } from "../util/utils";
|
||||
/**
|
||||
* Stores the patterns specified in NO_PROXY environment variable.
|
||||
* @internal
|
||||
*/
|
||||
export const globalNoProxyList = [];
|
||||
let noProxyListLoaded = false;
|
||||
/** A cache of whether a host should bypass the proxy. */
|
||||
const globalBypassedMap = new Map();
|
||||
function loadEnvironmentProxyValue() {
|
||||
if (!process) {
|
||||
return undefined;
|
||||
}
|
||||
const httpsProxy = getEnvironmentValue(Constants.HTTPS_PROXY);
|
||||
const allProxy = getEnvironmentValue(Constants.ALL_PROXY);
|
||||
const httpProxy = getEnvironmentValue(Constants.HTTP_PROXY);
|
||||
return httpsProxy || allProxy || httpProxy;
|
||||
}
|
||||
/**
|
||||
* Check whether the host of a given `uri` matches any pattern in the no proxy list.
|
||||
* If there's a match, any request sent to the same host shouldn't have the proxy settings set.
|
||||
* 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
|
||||
*/
|
||||
function isBypassed(uri, noProxyList, bypassedMap) {
|
||||
if (noProxyList.length === 0) {
|
||||
return false;
|
||||
}
|
||||
const host = URLBuilder.parse(uri).getHost();
|
||||
if (bypassedMap === null || bypassedMap === void 0 ? void 0 : bypassedMap.has(host)) {
|
||||
return bypassedMap.get(host);
|
||||
}
|
||||
let isBypassedFlag = false;
|
||||
for (const pattern of noProxyList) {
|
||||
if (pattern[0] === ".") {
|
||||
// This should match either domain it self or any subdomain or host
|
||||
// .foo.com will match foo.com it self or *.foo.com
|
||||
if (host.endsWith(pattern)) {
|
||||
isBypassedFlag = true;
|
||||
}
|
||||
else {
|
||||
if (host.length === pattern.length - 1 && host === pattern.slice(1)) {
|
||||
isBypassedFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (host === pattern) {
|
||||
isBypassedFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
bypassedMap === null || bypassedMap === void 0 ? void 0 : bypassedMap.set(host, isBypassedFlag);
|
||||
return isBypassedFlag;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export function loadNoProxy() {
|
||||
const noProxy = getEnvironmentValue(Constants.NO_PROXY);
|
||||
noProxyListLoaded = true;
|
||||
if (noProxy) {
|
||||
return noProxy
|
||||
.split(",")
|
||||
.map((item) => item.trim())
|
||||
.filter((item) => item.length);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
/**
|
||||
* Converts a given URL of a proxy server into `ProxySettings` or attempts to retrieve `ProxySettings` from the current environment if one is not passed.
|
||||
* @param proxyUrl - URL of the proxy
|
||||
* @returns The default proxy settings, or undefined.
|
||||
*/
|
||||
export function getDefaultProxySettings(proxyUrl) {
|
||||
if (!proxyUrl) {
|
||||
proxyUrl = loadEnvironmentProxyValue();
|
||||
if (!proxyUrl) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
const { username, password, urlWithoutAuth } = extractAuthFromUrl(proxyUrl);
|
||||
const parsedUrl = URLBuilder.parse(urlWithoutAuth);
|
||||
const schema = parsedUrl.getScheme() ? parsedUrl.getScheme() + "://" : "";
|
||||
return {
|
||||
host: schema + parsedUrl.getHost(),
|
||||
port: Number.parseInt(parsedUrl.getPort() || "80"),
|
||||
username,
|
||||
password,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A policy that allows one to apply proxy settings to all requests.
|
||||
* If not passed static settings, they will be retrieved from the HTTPS_PROXY
|
||||
* or HTTP_PROXY environment variables.
|
||||
* @param proxySettings - ProxySettings to use on each request.
|
||||
* @param options - additional settings, for example, custom NO_PROXY patterns
|
||||
*/
|
||||
export function proxyPolicy(proxySettings, options) {
|
||||
if (!proxySettings) {
|
||||
proxySettings = getDefaultProxySettings();
|
||||
}
|
||||
if (!noProxyListLoaded) {
|
||||
globalNoProxyList.push(...loadNoProxy());
|
||||
}
|
||||
return {
|
||||
create: (nextPolicy, requestPolicyOptions) => {
|
||||
return new ProxyPolicy(nextPolicy, requestPolicyOptions, proxySettings, options === null || options === void 0 ? void 0 : options.customNoProxyList);
|
||||
},
|
||||
};
|
||||
}
|
||||
function extractAuthFromUrl(url) {
|
||||
const atIndex = url.indexOf("@");
|
||||
if (atIndex === -1) {
|
||||
return { urlWithoutAuth: url };
|
||||
}
|
||||
const schemeIndex = url.indexOf("://");
|
||||
const authStart = schemeIndex !== -1 ? schemeIndex + 3 : 0;
|
||||
const auth = url.substring(authStart, atIndex);
|
||||
const colonIndex = auth.indexOf(":");
|
||||
const hasPassword = colonIndex !== -1;
|
||||
const username = hasPassword ? auth.substring(0, colonIndex) : auth;
|
||||
const password = hasPassword ? auth.substring(colonIndex + 1) : undefined;
|
||||
const urlWithoutAuth = url.substring(0, authStart) + url.substring(atIndex + 1);
|
||||
return {
|
||||
username,
|
||||
password,
|
||||
urlWithoutAuth,
|
||||
};
|
||||
}
|
||||
export class ProxyPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, options, proxySettings, customNoProxyList) {
|
||||
super(nextPolicy, options);
|
||||
this.proxySettings = proxySettings;
|
||||
this.customNoProxyList = customNoProxyList;
|
||||
}
|
||||
sendRequest(request) {
|
||||
var _a;
|
||||
if (!request.proxySettings &&
|
||||
!isBypassed(request.url, (_a = this.customNoProxyList) !== null && _a !== void 0 ? _a : globalNoProxyList, this.customNoProxyList ? undefined : globalBypassedMap)) {
|
||||
request.proxySettings = this.proxySettings;
|
||||
}
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=proxyPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/proxyPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/proxyPolicy.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
64
node_modules/@azure/core-http/dist-esm/src/policies/redirectPolicy.js
generated
vendored
Normal file
64
node_modules/@azure/core-http/dist-esm/src/policies/redirectPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
import { URLBuilder } from "../url";
|
||||
/**
|
||||
* Methods that are allowed to follow redirects 301 and 302
|
||||
*/
|
||||
const allowedRedirect = ["GET", "HEAD"];
|
||||
export const DefaultRedirectOptions = {
|
||||
handleRedirects: true,
|
||||
maxRetries: 20,
|
||||
};
|
||||
/**
|
||||
* Creates a redirect policy, which sends a repeats the request to a new destination if a response arrives with a "location" header, and a status code between 300 and 307.
|
||||
* @param maximumRetries - Maximum number of redirects to follow.
|
||||
* @returns An instance of the {@link RedirectPolicy}
|
||||
*/
|
||||
export function redirectPolicy(maximumRetries = 20) {
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new RedirectPolicy(nextPolicy, options, maximumRetries);
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Resends the request to a new destination if a response arrives with a "location" header, and a status code between 300 and 307.
|
||||
*/
|
||||
export class RedirectPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, options, maxRetries = 20) {
|
||||
super(nextPolicy, options);
|
||||
this.maxRetries = maxRetries;
|
||||
}
|
||||
sendRequest(request) {
|
||||
return this._nextPolicy
|
||||
.sendRequest(request)
|
||||
.then((response) => handleRedirect(this, response, 0));
|
||||
}
|
||||
}
|
||||
function handleRedirect(policy, response, currentRetries) {
|
||||
const { request, status } = response;
|
||||
const locationHeader = response.headers.get("location");
|
||||
if (locationHeader &&
|
||||
(status === 300 ||
|
||||
(status === 301 && allowedRedirect.includes(request.method)) ||
|
||||
(status === 302 && allowedRedirect.includes(request.method)) ||
|
||||
(status === 303 && request.method === "POST") ||
|
||||
status === 307) &&
|
||||
(!policy.maxRetries || currentRetries < policy.maxRetries)) {
|
||||
const builder = URLBuilder.parse(request.url);
|
||||
builder.setPath(locationHeader);
|
||||
request.url = builder.toString();
|
||||
// POST request with Status code 303 should be converted into a
|
||||
// redirected GET request if the redirect url is present in the location header
|
||||
if (status === 303) {
|
||||
request.method = "GET";
|
||||
delete request.body;
|
||||
}
|
||||
return policy._nextPolicy
|
||||
.sendRequest(request)
|
||||
.then((res) => handleRedirect(policy, res, currentRetries + 1));
|
||||
}
|
||||
return Promise.resolve(response);
|
||||
}
|
||||
//# sourceMappingURL=redirectPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/redirectPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/redirectPolicy.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
70
node_modules/@azure/core-http/dist-esm/src/policies/requestPolicy.js
generated
vendored
Normal file
70
node_modules/@azure/core-http/dist-esm/src/policies/requestPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { HttpPipelineLogLevel } from "../httpPipelineLogLevel";
|
||||
/**
|
||||
* The base class from which all request policies derive.
|
||||
*/
|
||||
export class BaseRequestPolicy {
|
||||
/**
|
||||
* The main method to implement that manipulates a request/response.
|
||||
*/
|
||||
constructor(
|
||||
/**
|
||||
* The next policy in the pipeline. Each policy is responsible for executing the next one if the request is to continue through the pipeline.
|
||||
*/
|
||||
_nextPolicy,
|
||||
/**
|
||||
* The options that can be passed to a given request policy.
|
||||
*/
|
||||
_options) {
|
||||
this._nextPolicy = _nextPolicy;
|
||||
this._options = _options;
|
||||
}
|
||||
/**
|
||||
* Get whether or not a log with the provided log level should be logged.
|
||||
* @param logLevel - The log level of the log that will be logged.
|
||||
* @returns Whether or not a log with the provided log level should be logged.
|
||||
*/
|
||||
shouldLog(logLevel) {
|
||||
return this._options.shouldLog(logLevel);
|
||||
}
|
||||
/**
|
||||
* Attempt to log the provided message to the provided logger. If no logger was provided or if
|
||||
* the log level does not meat the logger's threshold, then nothing will be logged.
|
||||
* @param logLevel - The log level of this log.
|
||||
* @param message - The message of this log.
|
||||
*/
|
||||
log(logLevel, message) {
|
||||
this._options.log(logLevel, message);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Optional properties that can be used when creating a RequestPolicy.
|
||||
*/
|
||||
export class RequestPolicyOptions {
|
||||
constructor(_logger) {
|
||||
this._logger = _logger;
|
||||
}
|
||||
/**
|
||||
* Get whether or not a log with the provided log level should be logged.
|
||||
* @param logLevel - The log level of the log that will be logged.
|
||||
* @returns Whether or not a log with the provided log level should be logged.
|
||||
*/
|
||||
shouldLog(logLevel) {
|
||||
return (!!this._logger &&
|
||||
logLevel !== HttpPipelineLogLevel.OFF &&
|
||||
logLevel <= this._logger.minimumLogLevel);
|
||||
}
|
||||
/**
|
||||
* Attempt to log the provided message to the provided logger. If no logger was provided or if
|
||||
* the log level does not meet the logger's threshold, then nothing will be logged.
|
||||
* @param logLevel - The log level of this log.
|
||||
* @param message - The message of this log.
|
||||
*/
|
||||
log(logLevel, message) {
|
||||
if (this._logger && this.shouldLog(logLevel)) {
|
||||
this._logger.log(logLevel, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=requestPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/requestPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/requestPolicy.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
153
node_modules/@azure/core-http/dist-esm/src/policies/rpRegistrationPolicy.js
generated
vendored
Normal file
153
node_modules/@azure/core-http/dist-esm/src/policies/rpRegistrationPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import * as utils from "../util/utils";
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
import { delay } from "../util/delay";
|
||||
export function rpRegistrationPolicy(retryTimeout = 30) {
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new RPRegistrationPolicy(nextPolicy, options, retryTimeout);
|
||||
},
|
||||
};
|
||||
}
|
||||
export class RPRegistrationPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, options, _retryTimeout = 30) {
|
||||
super(nextPolicy, options);
|
||||
this._retryTimeout = _retryTimeout;
|
||||
}
|
||||
sendRequest(request) {
|
||||
return this._nextPolicy
|
||||
.sendRequest(request.clone())
|
||||
.then((response) => registerIfNeeded(this, request, response));
|
||||
}
|
||||
}
|
||||
function registerIfNeeded(policy, request, response) {
|
||||
if (response.status === 409) {
|
||||
const rpName = checkRPNotRegisteredError(response.bodyAsText);
|
||||
if (rpName) {
|
||||
const urlPrefix = extractSubscriptionUrl(request.url);
|
||||
return (registerRP(policy, urlPrefix, rpName, request)
|
||||
// Autoregistration of ${provider} failed for some reason. We will not return this error
|
||||
// instead will return the initial response with 409 status code back to the user.
|
||||
// do nothing here as we are returning the original response at the end of this method.
|
||||
.catch(() => false)
|
||||
.then((registrationStatus) => {
|
||||
if (registrationStatus) {
|
||||
// Retry the original request. We have to change the x-ms-client-request-id
|
||||
// otherwise Azure endpoint will return the initial 409 (cached) response.
|
||||
request.headers.set("x-ms-client-request-id", utils.generateUuid());
|
||||
return policy._nextPolicy.sendRequest(request.clone());
|
||||
}
|
||||
return response;
|
||||
}));
|
||||
}
|
||||
}
|
||||
return Promise.resolve(response);
|
||||
}
|
||||
/**
|
||||
* Reuses the headers of the original request and url (if specified).
|
||||
* @param originalRequest - The original request
|
||||
* @param reuseUrlToo - Should the url from the original request be reused as well. Default false.
|
||||
* @returns A new request object with desired headers.
|
||||
*/
|
||||
function getRequestEssentials(originalRequest, reuseUrlToo = false) {
|
||||
const reqOptions = originalRequest.clone();
|
||||
if (reuseUrlToo) {
|
||||
reqOptions.url = originalRequest.url;
|
||||
}
|
||||
// We have to change the x-ms-client-request-id otherwise Azure endpoint
|
||||
// will return the initial 409 (cached) response.
|
||||
reqOptions.headers.set("x-ms-client-request-id", utils.generateUuid());
|
||||
// Set content-type to application/json
|
||||
reqOptions.headers.set("Content-Type", "application/json; charset=utf-8");
|
||||
return reqOptions;
|
||||
}
|
||||
/**
|
||||
* Validates the error code and message associated with 409 response status code. If it matches to that of
|
||||
* RP not registered then it returns the name of the RP else returns undefined.
|
||||
* @param body - The response body received after making the original request.
|
||||
* @returns The name of the RP if condition is satisfied else undefined.
|
||||
*/
|
||||
function checkRPNotRegisteredError(body) {
|
||||
let result, responseBody;
|
||||
if (body) {
|
||||
try {
|
||||
responseBody = JSON.parse(body);
|
||||
}
|
||||
catch (err) {
|
||||
// do nothing;
|
||||
}
|
||||
if (responseBody &&
|
||||
responseBody.error &&
|
||||
responseBody.error.message &&
|
||||
responseBody.error.code &&
|
||||
responseBody.error.code === "MissingSubscriptionRegistration") {
|
||||
const matchRes = responseBody.error.message.match(/.*'(.*)'/i);
|
||||
if (matchRes) {
|
||||
result = matchRes.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Extracts the first part of the URL, just after subscription:
|
||||
* https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/
|
||||
* @param url - The original request url
|
||||
* @returns The url prefix as explained above.
|
||||
*/
|
||||
function extractSubscriptionUrl(url) {
|
||||
let result;
|
||||
const matchRes = url.match(/.*\/subscriptions\/[a-f0-9-]+\//gi);
|
||||
if (matchRes && matchRes[0]) {
|
||||
result = matchRes[0];
|
||||
}
|
||||
else {
|
||||
throw new Error(`Unable to extract subscriptionId from the given url - ${url}.`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Registers the given provider.
|
||||
* @param policy - The RPRegistrationPolicy this function is being called against.
|
||||
* @param urlPrefix - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/
|
||||
* @param provider - The provider name to be registered.
|
||||
* @param originalRequest - The original request sent by the user that returned a 409 response
|
||||
* with a message that the provider is not registered.
|
||||
*/
|
||||
async function registerRP(policy, urlPrefix, provider, originalRequest) {
|
||||
const postUrl = `${urlPrefix}providers/${provider}/register?api-version=2016-02-01`;
|
||||
const getUrl = `${urlPrefix}providers/${provider}?api-version=2016-02-01`;
|
||||
const reqOptions = getRequestEssentials(originalRequest);
|
||||
reqOptions.method = "POST";
|
||||
reqOptions.url = postUrl;
|
||||
const response = await policy._nextPolicy.sendRequest(reqOptions);
|
||||
if (response.status !== 200) {
|
||||
throw new Error(`Autoregistration of ${provider} failed. Please try registering manually.`);
|
||||
}
|
||||
return getRegistrationStatus(policy, getUrl, originalRequest);
|
||||
}
|
||||
/**
|
||||
* Polls the registration status of the provider that was registered. Polling happens at an interval of 30 seconds.
|
||||
* Polling will happen till the registrationState property of the response body is "Registered".
|
||||
* @param policy - The RPRegistrationPolicy this function is being called against.
|
||||
* @param url - The request url for polling
|
||||
* @param originalRequest - The original request sent by the user that returned a 409 response
|
||||
* with a message that the provider is not registered.
|
||||
* @returns True if RP Registration is successful.
|
||||
*/
|
||||
async function getRegistrationStatus(policy, url, originalRequest) {
|
||||
const reqOptions = getRequestEssentials(originalRequest);
|
||||
reqOptions.url = url;
|
||||
reqOptions.method = "GET";
|
||||
const res = await policy._nextPolicy.sendRequest(reqOptions);
|
||||
const obj = res.parsedBody;
|
||||
if (res.parsedBody && obj.registrationState && obj.registrationState === "Registered") {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
await delay(policy._retryTimeout * 1000);
|
||||
return getRegistrationStatus(policy, url, originalRequest);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=rpRegistrationPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/rpRegistrationPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/rpRegistrationPolicy.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
31
node_modules/@azure/core-http/dist-esm/src/policies/signingPolicy.js
generated
vendored
Normal file
31
node_modules/@azure/core-http/dist-esm/src/policies/signingPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
/**
|
||||
* Creates a policy that signs outgoing requests by calling to the provided `authenticationProvider`'s `signRequest` method.
|
||||
* @param authenticationProvider - The authentication provider.
|
||||
* @returns An instance of the {@link SigningPolicy}.
|
||||
*/
|
||||
export function signingPolicy(authenticationProvider) {
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new SigningPolicy(nextPolicy, options, authenticationProvider);
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A policy that signs outgoing requests by calling to the provided `authenticationProvider`'s `signRequest` method.
|
||||
*/
|
||||
export class SigningPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, options, authenticationProvider) {
|
||||
super(nextPolicy, options);
|
||||
this.authenticationProvider = authenticationProvider;
|
||||
}
|
||||
signRequest(request) {
|
||||
return this.authenticationProvider.signRequest(request);
|
||||
}
|
||||
sendRequest(request) {
|
||||
return this.signRequest(request).then((nextRequest) => this._nextPolicy.sendRequest(nextRequest));
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=signingPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/signingPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/signingPolicy.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"signingPolicy.js","sourceRoot":"","sources":["../../../src/policies/signingPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,iBAAiB,GAIlB,MAAM,iBAAiB,CAAC;AAKzB;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,sBAAgD;IAEhD,OAAO;QACL,MAAM,EAAE,CAAC,UAAyB,EAAE,OAA6B,EAAE,EAAE;YACnE,OAAO,IAAI,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,sBAAsB,CAAC,CAAC;QACxE,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAClD,YACE,UAAyB,EACzB,OAA6B,EACtB,sBAAgD;QAEvD,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAFpB,2BAAsB,GAAtB,sBAAsB,CAA0B;IAGzD,CAAC;IAED,WAAW,CAAC,OAAwB;QAClC,OAAO,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAEM,WAAW,CAAC,OAAwB;QACzC,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CACpD,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAC1C,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n BaseRequestPolicy,\n RequestPolicy,\n RequestPolicyFactory,\n RequestPolicyOptions,\n} from \"./requestPolicy\";\nimport { HttpOperationResponse } from \"../httpOperationResponse\";\nimport { ServiceClientCredentials } from \"../credentials/serviceClientCredentials\";\nimport { WebResourceLike } from \"../webResource\";\n\n/**\n * Creates a policy that signs outgoing requests by calling to the provided `authenticationProvider`'s `signRequest` method.\n * @param authenticationProvider - The authentication provider.\n * @returns An instance of the {@link SigningPolicy}.\n */\nexport function signingPolicy(\n authenticationProvider: ServiceClientCredentials\n): RequestPolicyFactory {\n return {\n create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => {\n return new SigningPolicy(nextPolicy, options, authenticationProvider);\n },\n };\n}\n\n/**\n * A policy that signs outgoing requests by calling to the provided `authenticationProvider`'s `signRequest` method.\n */\nexport class SigningPolicy extends BaseRequestPolicy {\n constructor(\n nextPolicy: RequestPolicy,\n options: RequestPolicyOptions,\n public authenticationProvider: ServiceClientCredentials\n ) {\n super(nextPolicy, options);\n }\n\n signRequest(request: WebResourceLike): Promise<WebResourceLike> {\n return this.authenticationProvider.signRequest(request);\n }\n\n public sendRequest(request: WebResourceLike): Promise<HttpOperationResponse> {\n return this.signRequest(request).then((nextRequest) =>\n this._nextPolicy.sendRequest(nextRequest)\n );\n }\n}\n"]}
|
78
node_modules/@azure/core-http/dist-esm/src/policies/systemErrorRetryPolicy.js
generated
vendored
Normal file
78
node_modules/@azure/core-http/dist-esm/src/policies/systemErrorRetryPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
import { DEFAULT_CLIENT_MAX_RETRY_INTERVAL, DEFAULT_CLIENT_MIN_RETRY_INTERVAL, DEFAULT_CLIENT_RETRY_COUNT, DEFAULT_CLIENT_RETRY_INTERVAL, isNumber, shouldRetry, updateRetryData, } from "../util/exponentialBackoffStrategy";
|
||||
import { delay } from "../util/delay";
|
||||
/**
|
||||
* A policy that retries when there's a system error, identified by the codes "ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNREFUSED", "ECONNRESET" or "ENOENT".
|
||||
* @param retryCount - Maximum number of retries.
|
||||
* @param retryInterval - The client retry interval, in milliseconds.
|
||||
* @param minRetryInterval - The minimum retry interval, in milliseconds.
|
||||
* @param maxRetryInterval - The maximum retry interval, in milliseconds.
|
||||
* @returns An instance of the {@link SystemErrorRetryPolicy}
|
||||
*/
|
||||
export function systemErrorRetryPolicy(retryCount, retryInterval, minRetryInterval, maxRetryInterval) {
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new SystemErrorRetryPolicy(nextPolicy, options, retryCount, retryInterval, minRetryInterval, maxRetryInterval);
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A policy that retries when there's a system error, identified by the codes "ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNREFUSED", "ECONNRESET" or "ENOENT".
|
||||
* @param retryCount - The client retry count.
|
||||
* @param retryInterval - The client retry interval, in milliseconds.
|
||||
* @param minRetryInterval - The minimum retry interval, in milliseconds.
|
||||
* @param maxRetryInterval - The maximum retry interval, in milliseconds.
|
||||
*/
|
||||
export class SystemErrorRetryPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, options, retryCount, retryInterval, minRetryInterval, maxRetryInterval) {
|
||||
super(nextPolicy, options);
|
||||
this.retryCount = isNumber(retryCount) ? retryCount : DEFAULT_CLIENT_RETRY_COUNT;
|
||||
this.retryInterval = isNumber(retryInterval) ? retryInterval : DEFAULT_CLIENT_RETRY_INTERVAL;
|
||||
this.minRetryInterval = isNumber(minRetryInterval)
|
||||
? minRetryInterval
|
||||
: DEFAULT_CLIENT_MIN_RETRY_INTERVAL;
|
||||
this.maxRetryInterval = isNumber(maxRetryInterval)
|
||||
? maxRetryInterval
|
||||
: DEFAULT_CLIENT_MAX_RETRY_INTERVAL;
|
||||
}
|
||||
sendRequest(request) {
|
||||
return this._nextPolicy
|
||||
.sendRequest(request.clone())
|
||||
.catch((error) => retry(this, request, error.response, error));
|
||||
}
|
||||
}
|
||||
async function retry(policy, request, operationResponse, err, retryData) {
|
||||
retryData = updateRetryData(policy, retryData, err);
|
||||
function shouldPolicyRetry(_response, error) {
|
||||
if (error &&
|
||||
error.code &&
|
||||
(error.code === "ETIMEDOUT" ||
|
||||
error.code === "ESOCKETTIMEDOUT" ||
|
||||
error.code === "ECONNREFUSED" ||
|
||||
error.code === "ECONNRESET" ||
|
||||
error.code === "ENOENT")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (shouldRetry(policy.retryCount, shouldPolicyRetry, retryData, operationResponse, err)) {
|
||||
// If previous operation ended with an error and the policy allows a retry, do that
|
||||
try {
|
||||
await delay(retryData.retryInterval);
|
||||
return policy._nextPolicy.sendRequest(request.clone());
|
||||
}
|
||||
catch (nestedErr) {
|
||||
return retry(policy, request, operationResponse, nestedErr, retryData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (err) {
|
||||
// If the operation failed in the end, return all errors instead of just the last one
|
||||
return Promise.reject(retryData.error);
|
||||
}
|
||||
return operationResponse;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=systemErrorRetryPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/systemErrorRetryPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/systemErrorRetryPolicy.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
97
node_modules/@azure/core-http/dist-esm/src/policies/throttlingRetryPolicy.js
generated
vendored
Normal file
97
node_modules/@azure/core-http/dist-esm/src/policies/throttlingRetryPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,97 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
import { AbortError } from "@azure/abort-controller";
|
||||
import { Constants } from "../util/constants";
|
||||
import { DEFAULT_CLIENT_MAX_RETRY_COUNT } from "../util/throttlingRetryStrategy";
|
||||
import { delay } from "../util/delay";
|
||||
const StatusCodes = Constants.HttpConstants.StatusCodes;
|
||||
/**
|
||||
* Creates a policy that re-sends the request if the response indicates the request failed because of throttling reasons.
|
||||
* For example, if the response contains a `Retry-After` header, it will retry sending the request based on the value of that header.
|
||||
*
|
||||
* To learn more, please refer to
|
||||
* https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits,
|
||||
* https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits and
|
||||
* https://docs.microsoft.com/en-us/azure/virtual-machines/troubleshooting/troubleshooting-throttling-errors
|
||||
* @returns
|
||||
*/
|
||||
export function throttlingRetryPolicy() {
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new ThrottlingRetryPolicy(nextPolicy, options);
|
||||
},
|
||||
};
|
||||
}
|
||||
const StandardAbortMessage = "The operation was aborted.";
|
||||
/**
|
||||
* Creates a policy that re-sends the request if the response indicates the request failed because of throttling reasons.
|
||||
* For example, if the response contains a `Retry-After` header, it will retry sending the request based on the value of that header.
|
||||
*
|
||||
* To learn more, please refer to
|
||||
* https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits,
|
||||
* https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits and
|
||||
* https://docs.microsoft.com/en-us/azure/virtual-machines/troubleshooting/troubleshooting-throttling-errors
|
||||
*/
|
||||
export class ThrottlingRetryPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, options, _handleResponse) {
|
||||
super(nextPolicy, options);
|
||||
this.numberOfRetries = 0;
|
||||
this._handleResponse = _handleResponse || this._defaultResponseHandler;
|
||||
}
|
||||
async sendRequest(httpRequest) {
|
||||
const response = await this._nextPolicy.sendRequest(httpRequest.clone());
|
||||
if (response.status !== StatusCodes.TooManyRequests &&
|
||||
response.status !== StatusCodes.ServiceUnavailable) {
|
||||
return response;
|
||||
}
|
||||
else {
|
||||
return this._handleResponse(httpRequest, response);
|
||||
}
|
||||
}
|
||||
async _defaultResponseHandler(httpRequest, httpResponse) {
|
||||
var _a;
|
||||
const retryAfterHeader = httpResponse.headers.get(Constants.HeaderConstants.RETRY_AFTER);
|
||||
if (retryAfterHeader) {
|
||||
const delayInMs = ThrottlingRetryPolicy.parseRetryAfterHeader(retryAfterHeader);
|
||||
if (delayInMs) {
|
||||
this.numberOfRetries += 1;
|
||||
await delay(delayInMs, undefined, {
|
||||
abortSignal: httpRequest.abortSignal,
|
||||
abortErrorMsg: StandardAbortMessage,
|
||||
});
|
||||
if ((_a = httpRequest.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
|
||||
throw new AbortError(StandardAbortMessage);
|
||||
}
|
||||
if (this.numberOfRetries < DEFAULT_CLIENT_MAX_RETRY_COUNT) {
|
||||
return this.sendRequest(httpRequest);
|
||||
}
|
||||
else {
|
||||
return this._nextPolicy.sendRequest(httpRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
return httpResponse;
|
||||
}
|
||||
static parseRetryAfterHeader(headerValue) {
|
||||
const retryAfterInSeconds = Number(headerValue);
|
||||
if (Number.isNaN(retryAfterInSeconds)) {
|
||||
return ThrottlingRetryPolicy.parseDateRetryAfterHeader(headerValue);
|
||||
}
|
||||
else {
|
||||
return retryAfterInSeconds * 1000;
|
||||
}
|
||||
}
|
||||
static parseDateRetryAfterHeader(headerValue) {
|
||||
try {
|
||||
const now = Date.now();
|
||||
const date = Date.parse(headerValue);
|
||||
const diff = date - now;
|
||||
return Number.isNaN(diff) ? undefined : diff;
|
||||
}
|
||||
catch (error) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=throttlingRetryPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/throttlingRetryPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/throttlingRetryPolicy.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
126
node_modules/@azure/core-http/dist-esm/src/policies/tracingPolicy.js
generated
vendored
Normal file
126
node_modules/@azure/core-http/dist-esm/src/policies/tracingPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,126 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
import { SpanKind, SpanStatusCode, createSpanFunction, getTraceParentHeader, isSpanContextValid, } from "@azure/core-tracing";
|
||||
import { logger } from "../log";
|
||||
const createSpan = createSpanFunction({
|
||||
packagePrefix: "",
|
||||
namespace: "",
|
||||
});
|
||||
/**
|
||||
* Creates a policy that wraps outgoing requests with a tracing span.
|
||||
* @param tracingOptions - Tracing options.
|
||||
* @returns An instance of the {@link TracingPolicy} class.
|
||||
*/
|
||||
export function tracingPolicy(tracingOptions = {}) {
|
||||
return {
|
||||
create(nextPolicy, options) {
|
||||
return new TracingPolicy(nextPolicy, options, tracingOptions);
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A policy that wraps outgoing requests with a tracing span.
|
||||
*/
|
||||
export class TracingPolicy extends BaseRequestPolicy {
|
||||
constructor(nextPolicy, options, tracingOptions) {
|
||||
super(nextPolicy, options);
|
||||
this.userAgent = tracingOptions.userAgent;
|
||||
}
|
||||
async sendRequest(request) {
|
||||
if (!request.tracingContext) {
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
}
|
||||
const span = this.tryCreateSpan(request);
|
||||
if (!span) {
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
}
|
||||
try {
|
||||
const response = await this._nextPolicy.sendRequest(request);
|
||||
this.tryProcessResponse(span, response);
|
||||
return response;
|
||||
}
|
||||
catch (err) {
|
||||
this.tryProcessError(span, err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
tryCreateSpan(request) {
|
||||
var _a;
|
||||
try {
|
||||
// Passing spanOptions as part of tracingOptions to maintain compatibility @azure/core-tracing@preview.13 and earlier.
|
||||
// We can pass this as a separate parameter once we upgrade to the latest core-tracing.
|
||||
const { span } = createSpan(`HTTP ${request.method}`, {
|
||||
tracingOptions: {
|
||||
spanOptions: Object.assign(Object.assign({}, request.spanOptions), { kind: SpanKind.CLIENT }),
|
||||
tracingContext: request.tracingContext,
|
||||
},
|
||||
});
|
||||
// If the span is not recording, don't do any more work.
|
||||
if (!span.isRecording()) {
|
||||
span.end();
|
||||
return undefined;
|
||||
}
|
||||
const namespaceFromContext = (_a = request.tracingContext) === null || _a === void 0 ? void 0 : _a.getValue(Symbol.for("az.namespace"));
|
||||
if (typeof namespaceFromContext === "string") {
|
||||
span.setAttribute("az.namespace", namespaceFromContext);
|
||||
}
|
||||
span.setAttributes({
|
||||
"http.method": request.method,
|
||||
"http.url": request.url,
|
||||
requestId: request.requestId,
|
||||
});
|
||||
if (this.userAgent) {
|
||||
span.setAttribute("http.user_agent", this.userAgent);
|
||||
}
|
||||
// set headers
|
||||
const spanContext = span.spanContext();
|
||||
const traceParentHeader = getTraceParentHeader(spanContext);
|
||||
if (traceParentHeader && isSpanContextValid(spanContext)) {
|
||||
request.headers.set("traceparent", traceParentHeader);
|
||||
const traceState = spanContext.traceState && spanContext.traceState.serialize();
|
||||
// if tracestate is set, traceparent MUST be set, so only set tracestate after traceparent
|
||||
if (traceState) {
|
||||
request.headers.set("tracestate", traceState);
|
||||
}
|
||||
}
|
||||
return span;
|
||||
}
|
||||
catch (error) {
|
||||
logger.warning(`Skipping creating a tracing span due to an error: ${error.message}`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
tryProcessError(span, err) {
|
||||
try {
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.ERROR,
|
||||
message: err.message,
|
||||
});
|
||||
if (err.statusCode) {
|
||||
span.setAttribute("http.status_code", err.statusCode);
|
||||
}
|
||||
span.end();
|
||||
}
|
||||
catch (error) {
|
||||
logger.warning(`Skipping tracing span processing due to an error: ${error.message}`);
|
||||
}
|
||||
}
|
||||
tryProcessResponse(span, response) {
|
||||
try {
|
||||
span.setAttribute("http.status_code", response.status);
|
||||
const serviceRequestId = response.headers.get("x-ms-request-id");
|
||||
if (serviceRequestId) {
|
||||
span.setAttribute("serviceRequestId", serviceRequestId);
|
||||
}
|
||||
span.setStatus({
|
||||
code: SpanStatusCode.OK,
|
||||
});
|
||||
span.end();
|
||||
}
|
||||
catch (error) {
|
||||
logger.warning(`Skipping tracing span processing due to an error: ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=tracingPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/tracingPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/tracingPolicy.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
78
node_modules/@azure/core-http/dist-esm/src/policies/userAgentPolicy.js
generated
vendored
Normal file
78
node_modules/@azure/core-http/dist-esm/src/policies/userAgentPolicy.js
generated
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import { BaseRequestPolicy, } from "./requestPolicy";
|
||||
import { getDefaultUserAgentKey, getPlatformSpecificData } from "./msRestUserAgentPolicy";
|
||||
import { Constants } from "../util/constants";
|
||||
import { HttpHeaders } from "../httpHeaders";
|
||||
function getRuntimeInfo() {
|
||||
const msRestRuntime = {
|
||||
key: "core-http",
|
||||
value: Constants.coreHttpVersion,
|
||||
};
|
||||
return [msRestRuntime];
|
||||
}
|
||||
function getUserAgentString(telemetryInfo, keySeparator = " ", valueSeparator = "/") {
|
||||
return telemetryInfo
|
||||
.map((info) => {
|
||||
const value = info.value ? `${valueSeparator}${info.value}` : "";
|
||||
return `${info.key}${value}`;
|
||||
})
|
||||
.join(keySeparator);
|
||||
}
|
||||
export const getDefaultUserAgentHeaderName = getDefaultUserAgentKey;
|
||||
/**
|
||||
* The default approach to generate user agents.
|
||||
* Uses static information from this package, plus system information available from the runtime.
|
||||
*/
|
||||
export function getDefaultUserAgentValue() {
|
||||
const runtimeInfo = getRuntimeInfo();
|
||||
const platformSpecificData = getPlatformSpecificData();
|
||||
const userAgent = getUserAgentString(runtimeInfo.concat(platformSpecificData));
|
||||
return userAgent;
|
||||
}
|
||||
/**
|
||||
* Returns a policy that adds the user agent header to outgoing requests based on the given {@link TelemetryInfo}.
|
||||
* @param userAgentData - Telemetry information.
|
||||
* @returns A new {@link UserAgentPolicy}.
|
||||
*/
|
||||
export function userAgentPolicy(userAgentData) {
|
||||
const key = !userAgentData || userAgentData.key === undefined || userAgentData.key === null
|
||||
? getDefaultUserAgentKey()
|
||||
: userAgentData.key;
|
||||
const value = !userAgentData || userAgentData.value === undefined || userAgentData.value === null
|
||||
? getDefaultUserAgentValue()
|
||||
: userAgentData.value;
|
||||
return {
|
||||
create: (nextPolicy, options) => {
|
||||
return new UserAgentPolicy(nextPolicy, options, key, value);
|
||||
},
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A policy that adds the user agent header to outgoing requests based on the given {@link TelemetryInfo}.
|
||||
*/
|
||||
export class UserAgentPolicy extends BaseRequestPolicy {
|
||||
constructor(_nextPolicy, _options, headerKey, headerValue) {
|
||||
super(_nextPolicy, _options);
|
||||
this._nextPolicy = _nextPolicy;
|
||||
this._options = _options;
|
||||
this.headerKey = headerKey;
|
||||
this.headerValue = headerValue;
|
||||
}
|
||||
sendRequest(request) {
|
||||
this.addUserAgentHeader(request);
|
||||
return this._nextPolicy.sendRequest(request);
|
||||
}
|
||||
/**
|
||||
* Adds the user agent header to the outgoing request.
|
||||
*/
|
||||
addUserAgentHeader(request) {
|
||||
if (!request.headers) {
|
||||
request.headers = new HttpHeaders();
|
||||
}
|
||||
if (!request.headers.get(this.headerKey) && this.headerValue) {
|
||||
request.headers.set(this.headerKey, this.headerValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=userAgentPolicy.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/policies/userAgentPolicy.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/policies/userAgentPolicy.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
57
node_modules/@azure/core-http/dist-esm/src/proxyAgent.js
generated
vendored
Normal file
57
node_modules/@azure/core-http/dist-esm/src/proxyAgent.js
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import * as tunnel from "tunnel";
|
||||
import { URLBuilder } from "./url";
|
||||
export function createProxyAgent(requestUrl, proxySettings, headers) {
|
||||
const host = URLBuilder.parse(proxySettings.host).getHost();
|
||||
if (!host) {
|
||||
throw new Error("Expecting a non-empty host in proxy settings.");
|
||||
}
|
||||
if (!isValidPort(proxySettings.port)) {
|
||||
throw new Error("Expecting a valid port number in the range of [0, 65535] in proxy settings.");
|
||||
}
|
||||
const tunnelOptions = {
|
||||
proxy: {
|
||||
host: host,
|
||||
port: proxySettings.port,
|
||||
headers: (headers && headers.rawHeaders()) || {},
|
||||
},
|
||||
};
|
||||
if (proxySettings.username && proxySettings.password) {
|
||||
tunnelOptions.proxy.proxyAuth = `${proxySettings.username}:${proxySettings.password}`;
|
||||
}
|
||||
else if (proxySettings.username) {
|
||||
tunnelOptions.proxy.proxyAuth = `${proxySettings.username}`;
|
||||
}
|
||||
const isRequestHttps = isUrlHttps(requestUrl);
|
||||
const isProxyHttps = isUrlHttps(proxySettings.host);
|
||||
const proxyAgent = {
|
||||
isHttps: isRequestHttps,
|
||||
agent: createTunnel(isRequestHttps, isProxyHttps, tunnelOptions),
|
||||
};
|
||||
return proxyAgent;
|
||||
}
|
||||
export function isUrlHttps(url) {
|
||||
const urlScheme = URLBuilder.parse(url).getScheme() || "";
|
||||
return urlScheme.toLowerCase() === "https";
|
||||
}
|
||||
export function createTunnel(isRequestHttps, isProxyHttps, tunnelOptions) {
|
||||
if (isRequestHttps && isProxyHttps) {
|
||||
return tunnel.httpsOverHttps(tunnelOptions);
|
||||
}
|
||||
else if (isRequestHttps && !isProxyHttps) {
|
||||
return tunnel.httpsOverHttp(tunnelOptions);
|
||||
}
|
||||
else if (!isRequestHttps && isProxyHttps) {
|
||||
return tunnel.httpOverHttps(tunnelOptions);
|
||||
}
|
||||
else {
|
||||
return tunnel.httpOverHttp(tunnelOptions);
|
||||
}
|
||||
}
|
||||
function isValidPort(port) {
|
||||
// any port in 0-65535 range is valid (RFC 793) even though almost all implementations
|
||||
// will reserve 0 for a specific purpose, and a range of numbers for ephemeral ports
|
||||
return 0 <= port && port <= 65535;
|
||||
}
|
||||
//# sourceMappingURL=proxyAgent.js.map
|
1
node_modules/@azure/core-http/dist-esm/src/proxyAgent.js.map
generated
vendored
Normal file
1
node_modules/@azure/core-http/dist-esm/src/proxyAgent.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"proxyAgent.js","sourceRoot":"","sources":["../../src/proxyAgent.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnC,MAAM,UAAU,gBAAgB,CAC9B,UAAkB,EAClB,aAA4B,EAC5B,OAAyB;IAEzB,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAY,CAAC;IACtE,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAClE;IACD,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE;QACpC,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;KAChG;IACD,MAAM,aAAa,GAAiC;QAClD,KAAK,EAAE;YACL,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,OAAO,EAAE,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE;SACjD;KACF,CAAC;IAEF,IAAI,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,QAAQ,EAAE;QACpD,aAAa,CAAC,KAAM,CAAC,SAAS,GAAG,GAAG,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,QAAQ,EAAE,CAAC;KACxF;SAAM,IAAI,aAAa,CAAC,QAAQ,EAAE;QACjC,aAAa,CAAC,KAAM,CAAC,SAAS,GAAG,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC;KAC9D;IAED,MAAM,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,YAAY,GAAG,UAAU,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAEpD,MAAM,UAAU,GAAG;QACjB,OAAO,EAAE,cAAc;QACvB,KAAK,EAAE,YAAY,CAAC,cAAc,EAAE,YAAY,EAAE,aAAa,CAAC;KACjE,CAAC;IAEF,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC;IAC1D,OAAO,SAAS,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,cAAuB,EACvB,YAAqB,EACrB,aAA2C;IAE3C,IAAI,cAAc,IAAI,YAAY,EAAE;QAClC,OAAO,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;KAC7C;SAAM,IAAI,cAAc,IAAI,CAAC,YAAY,EAAE;QAC1C,OAAO,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;KAC5C;SAAM,IAAI,CAAC,cAAc,IAAI,YAAY,EAAE;QAC1C,OAAO,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;KAC5C;SAAM;QACL,OAAO,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;KAC3C;AACH,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,sFAAsF;IACtF,oFAAoF;IACpF,OAAO,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,CAAC;AACpC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as http from \"http\";\nimport * as https from \"https\";\nimport * as tunnel from \"tunnel\";\nimport { HttpHeadersLike } from \"./httpHeaders\";\nimport { ProxySettings } from \"./serviceClient\";\nimport { URLBuilder } from \"./url\";\n\nexport type ProxyAgent = { isHttps: boolean; agent: http.Agent | https.Agent };\nexport function createProxyAgent(\n requestUrl: string,\n proxySettings: ProxySettings,\n headers?: HttpHeadersLike\n): ProxyAgent {\n const host = URLBuilder.parse(proxySettings.host).getHost() as string;\n if (!host) {\n throw new Error(\"Expecting a non-empty host in proxy settings.\");\n }\n if (!isValidPort(proxySettings.port)) {\n throw new Error(\"Expecting a valid port number in the range of [0, 65535] in proxy settings.\");\n }\n const tunnelOptions: tunnel.HttpsOverHttpsOptions = {\n proxy: {\n host: host,\n port: proxySettings.port,\n headers: (headers && headers.rawHeaders()) || {},\n },\n };\n\n if (proxySettings.username && proxySettings.password) {\n tunnelOptions.proxy!.proxyAuth = `${proxySettings.username}:${proxySettings.password}`;\n } else if (proxySettings.username) {\n tunnelOptions.proxy!.proxyAuth = `${proxySettings.username}`;\n }\n\n const isRequestHttps = isUrlHttps(requestUrl);\n const isProxyHttps = isUrlHttps(proxySettings.host);\n\n const proxyAgent = {\n isHttps: isRequestHttps,\n agent: createTunnel(isRequestHttps, isProxyHttps, tunnelOptions),\n };\n\n return proxyAgent;\n}\n\nexport function isUrlHttps(url: string): boolean {\n const urlScheme = URLBuilder.parse(url).getScheme() || \"\";\n return urlScheme.toLowerCase() === \"https\";\n}\n\nexport function createTunnel(\n isRequestHttps: boolean,\n isProxyHttps: boolean,\n tunnelOptions: tunnel.HttpsOverHttpsOptions\n): http.Agent | https.Agent {\n if (isRequestHttps && isProxyHttps) {\n return tunnel.httpsOverHttps(tunnelOptions);\n } else if (isRequestHttps && !isProxyHttps) {\n return tunnel.httpsOverHttp(tunnelOptions);\n } else if (!isRequestHttps && isProxyHttps) {\n return tunnel.httpOverHttps(tunnelOptions);\n } else {\n return tunnel.httpOverHttp(tunnelOptions);\n }\n}\n\nfunction isValidPort(port: number): boolean {\n // any port in 0-65535 range is valid (RFC 793) even though almost all implementations\n // will reserve 0 for a specific purpose, and a range of numbers for ephemeral ports\n return 0 <= port && port <= 65535;\n}\n"]}
|
29
node_modules/@azure/core-http/dist-esm/src/queryCollectionFormat.js
generated
vendored
Normal file
29
node_modules/@azure/core-http/dist-esm/src/queryCollectionFormat.js
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
/**
|
||||
* The format that will be used to join an array of values together for a query parameter value.
|
||||
*/
|
||||
export var QueryCollectionFormat;
|
||||
(function (QueryCollectionFormat) {
|
||||
/**
|
||||
* CSV: Each pair of segments joined by a single comma.
|
||||
*/
|
||||
QueryCollectionFormat["Csv"] = ",";
|
||||
/**
|
||||
* SSV: Each pair of segments joined by a single space character.
|
||||
*/
|
||||
QueryCollectionFormat["Ssv"] = " ";
|
||||
/**
|
||||
* TSV: Each pair of segments joined by a single tab character.
|
||||
*/
|
||||
QueryCollectionFormat["Tsv"] = "\t";
|
||||
/**
|
||||
* Pipes: Each pair of segments joined by a single pipe character.
|
||||
*/
|
||||
QueryCollectionFormat["Pipes"] = "|";
|
||||
/**
|
||||
* Denotes this is an array of values that should be passed to the server in multiple key/value pairs, e.g. `?queryParam=value1&queryParam=value2`
|
||||
*/
|
||||
QueryCollectionFormat["Multi"] = "Multi";
|
||||
})(QueryCollectionFormat || (QueryCollectionFormat = {}));
|
||||
//# sourceMappingURL=queryCollectionFormat.js.map
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue