@azure/core-client 1.5.1-alpha.20220406.3 → 1.6.0-alpha.20220421.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -6
- package/dist/index.js +21 -14
- package/dist/index.js.map +1 -1
- package/dist-esm/src/authorizeRequestOnClaimChallenge.js +2 -3
- package/dist-esm/src/authorizeRequestOnClaimChallenge.js.map +1 -1
- package/dist-esm/src/deserializationPolicy.js.map +1 -1
- package/dist-esm/src/index.js +0 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/log.js +5 -0
- package/dist-esm/src/log.js.map +1 -0
- package/dist-esm/src/serializationPolicy.js.map +1 -1
- package/dist-esm/src/serviceClient.js +15 -8
- package/dist-esm/src/serviceClient.js.map +1 -1
- package/package.json +5 -6
- package/types/3.1/core-client.d.ts +8 -1
- package/types/latest/core-client.d.ts +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.6.0 (unreleased)
|
|
4
4
|
|
|
5
5
|
### Features Added
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bugs Fixed
|
|
10
|
-
|
|
11
|
-
### Other Changes
|
|
7
|
+
- Added a new property endpoint in ServiceClientOptions and mark the baseUri as deprecated to encourage people to use endpoint. See issue link [here](https://github.com/Azure/autorest.typescript/issues/1337)
|
|
8
|
+
- Upgraded our `@azure/core-tracing` dependency to version 1.0
|
|
12
9
|
|
|
13
10
|
## 1.5.0 (2022-02-03)
|
|
14
11
|
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
6
|
-
var logger = require('@azure/logger');
|
|
7
|
-
require('@azure/core-asynciterator-polyfill');
|
|
6
|
+
var logger$1 = require('@azure/logger');
|
|
8
7
|
|
|
9
8
|
// Copyright (c) Microsoft Corporation.
|
|
10
9
|
/**
|
|
@@ -1797,6 +1796,9 @@ function appendQueryParams(url, queryParams, sequenceParams, noOverwrite = false
|
|
|
1797
1796
|
return parsedUrl.toString();
|
|
1798
1797
|
}
|
|
1799
1798
|
|
|
1799
|
+
// Copyright (c) Microsoft Corporation.
|
|
1800
|
+
const logger = logger$1.createClientLogger("core-client");
|
|
1801
|
+
|
|
1800
1802
|
// Copyright (c) Microsoft Corporation.
|
|
1801
1803
|
/**
|
|
1802
1804
|
* Initializes a new instance of the ServiceClient.
|
|
@@ -1808,13 +1810,16 @@ class ServiceClient {
|
|
|
1808
1810
|
* @param options - The service client options that govern the behavior of the client.
|
|
1809
1811
|
*/
|
|
1810
1812
|
constructor(options = {}) {
|
|
1811
|
-
var _a;
|
|
1813
|
+
var _a, _b;
|
|
1812
1814
|
this._requestContentType = options.requestContentType;
|
|
1813
|
-
this.
|
|
1815
|
+
this._endpoint = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri;
|
|
1816
|
+
if (options.baseUri) {
|
|
1817
|
+
logger.warning("The baseUri option for SDK Clients has been deprecated, please use endpoint instead.");
|
|
1818
|
+
}
|
|
1814
1819
|
this._allowInsecureConnection = options.allowInsecureConnection;
|
|
1815
1820
|
this._httpClient = options.httpClient || getCachedDefaultHttpClient();
|
|
1816
1821
|
this.pipeline = options.pipeline || createDefaultPipeline(options);
|
|
1817
|
-
if ((
|
|
1822
|
+
if ((_b = options.additionalPolicies) === null || _b === void 0 ? void 0 : _b.length) {
|
|
1818
1823
|
for (const { policy, position } of options.additionalPolicies) {
|
|
1819
1824
|
// Sign happens after Retry and is commonly needed to occur
|
|
1820
1825
|
// before policies that intercept post-retry.
|
|
@@ -1838,14 +1843,14 @@ class ServiceClient {
|
|
|
1838
1843
|
* @param operationSpec - The OperationSpec to use to populate the httpRequest.
|
|
1839
1844
|
*/
|
|
1840
1845
|
async sendOperationRequest(operationArguments, operationSpec) {
|
|
1841
|
-
const
|
|
1842
|
-
if (!
|
|
1843
|
-
throw new Error("If operationSpec.baseUrl is not specified, then the ServiceClient must have a
|
|
1846
|
+
const endpoint = operationSpec.baseUrl || this._endpoint;
|
|
1847
|
+
if (!endpoint) {
|
|
1848
|
+
throw new Error("If operationSpec.baseUrl is not specified, then the ServiceClient must have a endpoint string property that contains the base URL to use.");
|
|
1844
1849
|
}
|
|
1845
1850
|
// Templatized URLs sometimes reference properties on the ServiceClient child class,
|
|
1846
1851
|
// so we have to pass `this` below in order to search these properties if they're
|
|
1847
1852
|
// not part of OperationArguments
|
|
1848
|
-
const url = getRequestUrl(
|
|
1853
|
+
const url = getRequestUrl(endpoint, operationSpec, operationArguments, this);
|
|
1849
1854
|
const request = coreRestPipeline.createPipelineRequest({
|
|
1850
1855
|
url,
|
|
1851
1856
|
});
|
|
@@ -1925,17 +1930,19 @@ function getCredentialScopes(options) {
|
|
|
1925
1930
|
? scopes.map((scope) => new URL(scope).toString())
|
|
1926
1931
|
: new URL(scopes).toString();
|
|
1927
1932
|
}
|
|
1933
|
+
if (options.endpoint) {
|
|
1934
|
+
return `${options.endpoint}/.default`;
|
|
1935
|
+
}
|
|
1928
1936
|
if (options.baseUri) {
|
|
1929
1937
|
return `${options.baseUri}/.default`;
|
|
1930
1938
|
}
|
|
1931
1939
|
if (options.credential && !options.credentialScopes) {
|
|
1932
|
-
throw new Error(`When using credentials, the ServiceClientOptions must contain either a
|
|
1940
|
+
throw new Error(`When using credentials, the ServiceClientOptions must contain either a endpoint or a credentialScopes. Unable to create a bearerTokenAuthenticationPolicy`);
|
|
1933
1941
|
}
|
|
1934
1942
|
return undefined;
|
|
1935
1943
|
}
|
|
1936
1944
|
|
|
1937
1945
|
// Copyright (c) Microsoft Corporation.
|
|
1938
|
-
const defaultLogger = logger.createClientLogger("authorizeRequestOnClaimChallenge");
|
|
1939
1946
|
/**
|
|
1940
1947
|
* Converts: `Bearer a="b", c="d", Bearer d="e", f="g"`.
|
|
1941
1948
|
* Into: `[ { a: 'b', c: 'd' }, { d: 'e', f: 'g' } ]`.
|
|
@@ -1979,16 +1986,16 @@ function parseCAEChallenge(challenges) {
|
|
|
1979
1986
|
*/
|
|
1980
1987
|
async function authorizeRequestOnClaimChallenge(onChallengeOptions) {
|
|
1981
1988
|
const { scopes, response } = onChallengeOptions;
|
|
1982
|
-
const logger = onChallengeOptions.logger ||
|
|
1989
|
+
const logger$1 = onChallengeOptions.logger || logger;
|
|
1983
1990
|
const challenge = response.headers.get("WWW-Authenticate");
|
|
1984
1991
|
if (!challenge) {
|
|
1985
|
-
logger.info(`The WWW-Authenticate header was missing. Failed to perform the Continuous Access Evaluation authentication flow.`);
|
|
1992
|
+
logger$1.info(`The WWW-Authenticate header was missing. Failed to perform the Continuous Access Evaluation authentication flow.`);
|
|
1986
1993
|
return false;
|
|
1987
1994
|
}
|
|
1988
1995
|
const challenges = parseCAEChallenge(challenge) || [];
|
|
1989
1996
|
const parsedChallenge = challenges.find((x) => x.claims);
|
|
1990
1997
|
if (!parsedChallenge) {
|
|
1991
|
-
logger.info(`The WWW-Authenticate header was missing the necessary "claims" to perform the Continuous Access Evaluation authentication flow.`);
|
|
1998
|
+
logger$1.info(`The WWW-Authenticate header was missing the necessary "claims" to perform the Continuous Access Evaluation authentication flow.`);
|
|
1992
1999
|
return false;
|
|
1993
2000
|
}
|
|
1994
2001
|
const accessToken = await onChallengeOptions.getAccessToken(parsedChallenge.scope ? [parsedChallenge.scope] : scopes, {
|