@azure/core-client 1.3.3-alpha.20211101.2 → 1.3.3

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 CHANGED
@@ -1,17 +1,10 @@
1
1
  # Release History
2
2
 
3
- ## 1.3.3 (Unreleased)
4
-
5
- ### Features Added
6
-
7
- - Added a new function `authorizeRequestOnClaimChallenge`, that can be used with the `@azure/core-rest-pipeline`'s `bearerTokenAuthenticationPolicy` to support [Continuous Access Evaluation (CAE) challenges](https://docs.microsoft.com/azure/active-directory/conditional-access/concept-continuous-access-evaluation).
8
- - Call the `bearerTokenAuthenticationPolicy` with the following options: `bearerTokenAuthenticationPolicy({ authorizeRequestOnChallenge: authorizeRequestOnClaimChallenge })`. Once provided, the `bearerTokenAuthenticationPolicy` policy will internally handle Continuous Access Evaluation (CAE) challenges. When it can't complete a challenge it will return the 401 (unauthorized) response from ARM.
9
-
10
- ### Breaking Changes
3
+ ## 1.3.3 (2021-12-02)
11
4
 
12
5
  ### Bugs Fixed
13
6
 
14
- ### Other Changes
7
+ - Added a check to handle undefined value during the parsing of query parameters. Please refer to [PR #18621](https://github.com/Azure/azure-sdk-for-js/pull/18621) for further details.
15
8
 
16
9
  ## 1.3.2 (2021-10-25)
17
10
 
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Azure Core Service client library for JavaScript (Experimental)
1
+ # Azure Core Service client library for JavaScript
2
2
 
3
3
  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).
4
4
 
package/dist/index.js CHANGED
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var coreRestPipeline = require('@azure/core-rest-pipeline');
6
- var logger$1 = require('@azure/logger');
7
6
  require('@azure/core-asynciterator-polyfill');
8
7
 
9
8
  // Copyright (c) Microsoft Corporation.
@@ -141,13 +140,6 @@ function encodeByteArray(value) {
141
140
  function decodeString(value) {
142
141
  return Buffer.from(value, "base64");
143
142
  }
144
- /**
145
- * Decodes a base64 string into a string.
146
- * @param value - the base64 string to decode
147
- */
148
- function decodeStringToString(value) {
149
- return Buffer.from(value, "base64").toString();
150
- }
151
143
 
152
144
  // Copyright (c) Microsoft Corporation.
153
145
  // Licensed under the MIT license.
@@ -1354,12 +1346,15 @@ function appendQueryParams(url, queryParams, sequenceParams, noOverwrite = false
1354
1346
  if (typeof value === "string") {
1355
1347
  searchPieces.push(`${name}=${value}`);
1356
1348
  }
1357
- else {
1349
+ else if (Array.isArray(value)) {
1358
1350
  // QUIRK: If we get an array of values, include multiple key/value pairs
1359
1351
  for (const subValue of value) {
1360
1352
  searchPieces.push(`${name}=${subValue}`);
1361
1353
  }
1362
1354
  }
1355
+ else {
1356
+ searchPieces.push(`${name}=${value}`);
1357
+ }
1363
1358
  }
1364
1359
  // QUIRK: we have to set search manually as searchParams will encode comma when it shouldn't.
1365
1360
  parsedUrl.search = searchPieces.length ? `?${searchPieces.join("&")}` : "";
@@ -1891,77 +1886,10 @@ function getCredentialScopes(options) {
1891
1886
  return undefined;
1892
1887
  }
1893
1888
 
1894
- // Copyright (c) Microsoft Corporation.
1895
- const logger = logger$1.createClientLogger("authorizeRequestOnClaimChallenge");
1896
- /**
1897
- * Converts: `Bearer a="b", c="d", Bearer d="e", f="g"`.
1898
- * Into: `[ { a: 'b', c: 'd' }, { d: 'e', f: 'g' } ]`.
1899
- *
1900
- * @internal
1901
- */
1902
- function parseCAEChallenge(challenges) {
1903
- const bearerChallenges = `, ${challenges.trim()}`.split(", Bearer ").filter((x) => x);
1904
- return bearerChallenges.map((challenge) => {
1905
- const challengeParts = `${challenge.trim()}, `.split('", ').filter((x) => x);
1906
- const keyValuePairs = challengeParts.map((keyValue) => (([key, value]) => ({ [key]: value }))(keyValue.trim().split('="')));
1907
- // Key-value pairs to plain object:
1908
- return keyValuePairs.reduce((a, b) => (Object.assign(Object.assign({}, a), b)), {});
1909
- });
1910
- }
1911
- /**
1912
- * This function can be used as a callback for the `bearerTokenAuthenticationPolicy` of `@azure/core-rest-pipeline`, to support CAE challenges:
1913
- * [Continuous Access Evaluation](https://docs.microsoft.com/azure/active-directory/conditional-access/concept-continuous-access-evaluation).
1914
- *
1915
- * Call the `bearerTokenAuthenticationPolicy` with the following options:
1916
- *
1917
- * ```ts
1918
- * import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
1919
- * import { authorizeRequestOnClaimChallenge } from "@azure/core-client";
1920
- *
1921
- * const bearerTokenAuthenticationPolicy = bearerTokenAuthenticationPolicy({
1922
- * authorizeRequestOnChallenge: authorizeRequestOnClaimChallenge
1923
- * });
1924
- * ```
1925
- *
1926
- * Once provided, the `bearerTokenAuthenticationPolicy` policy will internally handle Continuous Access Evaluation (CAE) challenges.
1927
- * When it can't complete a challenge it will return the 401 (unauthorized) response from ARM.
1928
- *
1929
- * Example challenge with claims:
1930
- *
1931
- * ```
1932
- * Bearer authorization_uri="https://login.windows-ppe.net/", error="invalid_token",
1933
- * error_description="User session has been revoked",
1934
- * claims="eyJhY2Nlc3NfdG9rZW4iOnsibmJmIjp7ImVzc2VudGlhbCI6dHJ1ZSwgInZhbHVlIjoiMTYwMzc0MjgwMCJ9fX0="
1935
- * ```
1936
- */
1937
- async function authorizeRequestOnClaimChallenge(onChallengeOptions) {
1938
- const { scopes, response } = onChallengeOptions;
1939
- const challenge = response.headers.get("WWW-Authenticate");
1940
- if (!challenge) {
1941
- logger.info(`The WWW-Authenticate header was missing. Failed to perform the Continuous Access Evaluation authentication flow.`);
1942
- return false;
1943
- }
1944
- const challenges = parseCAEChallenge(challenge) || [];
1945
- const parsedChallenge = challenges.find((x) => x.claims);
1946
- if (!parsedChallenge) {
1947
- logger.info(`The WWW-Authenticate header was missing the necessary "claims" to perform the Continuous Access Evaluation authentication flow.`);
1948
- return false;
1949
- }
1950
- const accessToken = await onChallengeOptions.getAccessToken(parsedChallenge.scope ? [parsedChallenge.scope] : scopes, {
1951
- claims: decodeStringToString(parsedChallenge.claims)
1952
- });
1953
- if (!accessToken) {
1954
- return false;
1955
- }
1956
- onChallengeOptions.request.headers.set("Authorization", `Bearer ${accessToken.token}`);
1957
- return true;
1958
- }
1959
-
1960
1889
  exports.MapperTypeNames = MapperTypeNames;
1961
1890
  exports.ServiceClient = ServiceClient;
1962
1891
  exports.XML_ATTRKEY = XML_ATTRKEY;
1963
1892
  exports.XML_CHARKEY = XML_CHARKEY;
1964
- exports.authorizeRequestOnClaimChallenge = authorizeRequestOnClaimChallenge;
1965
1893
  exports.createClientPipeline = createClientPipeline;
1966
1894
  exports.createSerializer = createSerializer;
1967
1895
  exports.deserializationPolicy = deserializationPolicy;