@azure/core-client 1.4.0-alpha.20211206.10 → 1.4.0
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 +2 -4
- package/dist/index.js +49 -33
- package/dist/index.js.map +1 -1
- package/dist-esm/src/authorizeRequestOnClaimChallenge.js +1 -1
- package/dist-esm/src/authorizeRequestOnClaimChallenge.js.map +1 -1
- package/dist-esm/src/deserializationPolicy.js +10 -9
- package/dist-esm/src/deserializationPolicy.js.map +1 -1
- package/dist-esm/src/index.js +3 -3
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/interfaces.js.map +1 -1
- package/dist-esm/src/operationHelpers.js +1 -1
- package/dist-esm/src/operationHelpers.js.map +1 -1
- package/dist-esm/src/pipeline.js +3 -3
- package/dist-esm/src/pipeline.js.map +1 -1
- package/dist-esm/src/serializationPolicy.js +7 -7
- package/dist-esm/src/serializationPolicy.js.map +1 -1
- package/dist-esm/src/serializer.js +29 -14
- package/dist-esm/src/serializer.js.map +1 -1
- package/dist-esm/src/serviceClient.js +2 -2
- package/dist-esm/src/serviceClient.js.map +1 -1
- package/dist-esm/src/urlHelpers.js +2 -2
- package/dist-esm/src/urlHelpers.js.map +1 -1
- package/dist-esm/src/utils.js +1 -1
- package/dist-esm/src/utils.js.map +1 -1
- package/package.json +7 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
-
## 1.4.0 (
|
|
3
|
+
## 1.4.0 (2022-01-06)
|
|
4
4
|
|
|
5
5
|
### Features Added
|
|
6
6
|
|
|
7
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
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
9
|
|
|
10
|
-
### Breaking Changes
|
|
11
|
-
|
|
12
10
|
### Bugs Fixed
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
- Fixed a serializer issue with nested polymorphics. [PR #19455](https://github.com/Azure/azure-sdk-for-js/pull/19455)
|
|
15
13
|
|
|
16
14
|
## 1.3.3 (2021-12-02)
|
|
17
15
|
|
package/dist/index.js
CHANGED
|
@@ -117,7 +117,7 @@ function flattenResponse(fullResponse, responseSpec) {
|
|
|
117
117
|
body: fullResponse.parsedBody,
|
|
118
118
|
headers: parsedHeaders,
|
|
119
119
|
hasNullableType: isNullable,
|
|
120
|
-
shouldWrapBody: isPrimitiveBody(fullResponse.parsedBody, expectedBodyTypeName)
|
|
120
|
+
shouldWrapBody: isPrimitiveBody(fullResponse.parsedBody, expectedBodyTypeName),
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -172,7 +172,7 @@ class SerializerImpl {
|
|
|
172
172
|
throw new Error(`"${objectName}" with value "${value}" should satisfy the constraint "${constraintName}": ${constraintValue}.`);
|
|
173
173
|
};
|
|
174
174
|
if (mapper.constraints && value !== undefined && value !== null) {
|
|
175
|
-
const { ExclusiveMaximum, ExclusiveMinimum, InclusiveMaximum, InclusiveMinimum, MaxItems, MaxLength, MinItems, MinLength, MultipleOf, Pattern, UniqueItems } = mapper.constraints;
|
|
175
|
+
const { ExclusiveMaximum, ExclusiveMinimum, InclusiveMaximum, InclusiveMinimum, MaxItems, MaxLength, MinItems, MinLength, MultipleOf, Pattern, UniqueItems, } = mapper.constraints;
|
|
176
176
|
if (ExclusiveMaximum !== undefined && value >= ExclusiveMaximum) {
|
|
177
177
|
failValidation("ExclusiveMaximum", ExclusiveMaximum);
|
|
178
178
|
}
|
|
@@ -231,8 +231,8 @@ class SerializerImpl {
|
|
|
231
231
|
xml: {
|
|
232
232
|
rootName: (_a = options.xml.rootName) !== null && _a !== void 0 ? _a : "",
|
|
233
233
|
includeRoot: (_b = options.xml.includeRoot) !== null && _b !== void 0 ? _b : false,
|
|
234
|
-
xmlCharKey: (_c = options.xml.xmlCharKey) !== null && _c !== void 0 ? _c : XML_CHARKEY
|
|
235
|
-
}
|
|
234
|
+
xmlCharKey: (_c = options.xml.xmlCharKey) !== null && _c !== void 0 ? _c : XML_CHARKEY,
|
|
235
|
+
},
|
|
236
236
|
};
|
|
237
237
|
let payload = {};
|
|
238
238
|
const mapperType = mapper.type.name;
|
|
@@ -320,8 +320,8 @@ class SerializerImpl {
|
|
|
320
320
|
xml: {
|
|
321
321
|
rootName: (_a = options.xml.rootName) !== null && _a !== void 0 ? _a : "",
|
|
322
322
|
includeRoot: (_b = options.xml.includeRoot) !== null && _b !== void 0 ? _b : false,
|
|
323
|
-
xmlCharKey: (_c = options.xml.xmlCharKey) !== null && _c !== void 0 ? _c : XML_CHARKEY
|
|
324
|
-
}
|
|
323
|
+
xmlCharKey: (_c = options.xml.xmlCharKey) !== null && _c !== void 0 ? _c : XML_CHARKEY,
|
|
324
|
+
},
|
|
325
325
|
};
|
|
326
326
|
if (responseBody === undefined || responseBody === null) {
|
|
327
327
|
if (this.isXML && mapper.type.name === "Sequence" && !mapper.xmlIsWrapped) {
|
|
@@ -426,9 +426,7 @@ function bufferToBase64Url(buffer) {
|
|
|
426
426
|
// Uint8Array to Base64.
|
|
427
427
|
const str = encodeByteArray(buffer);
|
|
428
428
|
// Base64 to Base64Url.
|
|
429
|
-
return trimEnd(str, "=")
|
|
430
|
-
.replace(/\+/g, "-")
|
|
431
|
-
.replace(/\//g, "_");
|
|
429
|
+
return trimEnd(str, "=").replace(/\+/g, "-").replace(/\//g, "_");
|
|
432
430
|
}
|
|
433
431
|
function base64UrlToByteArray(str) {
|
|
434
432
|
if (!str) {
|
|
@@ -587,14 +585,21 @@ function serializeDateTypes(typeName, value, objectName) {
|
|
|
587
585
|
return value;
|
|
588
586
|
}
|
|
589
587
|
function serializeSequenceType(serializer, mapper, object, objectName, isXml, options) {
|
|
588
|
+
var _a;
|
|
590
589
|
if (!Array.isArray(object)) {
|
|
591
590
|
throw new Error(`${objectName} must be of type Array.`);
|
|
592
591
|
}
|
|
593
|
-
|
|
592
|
+
let elementType = mapper.type.element;
|
|
594
593
|
if (!elementType || typeof elementType !== "object") {
|
|
595
594
|
throw new Error(`element" metadata for an Array must be defined in the ` +
|
|
596
595
|
`mapper and it must of type "object" in ${objectName}.`);
|
|
597
596
|
}
|
|
597
|
+
// Quirk: Composite mappers referenced by `element` might
|
|
598
|
+
// not have *all* properties declared (like uberParent),
|
|
599
|
+
// so let's try to look up the full definition by name.
|
|
600
|
+
if (elementType.type.name === "Composite" && elementType.type.className) {
|
|
601
|
+
elementType = (_a = serializer.modelMappers[elementType.type.className]) !== null && _a !== void 0 ? _a : elementType;
|
|
602
|
+
}
|
|
598
603
|
const tempArray = [];
|
|
599
604
|
for (let i = 0; i < object.length; i++) {
|
|
600
605
|
const serializedValue = serializer.serialize(elementType, object[i], objectName, options);
|
|
@@ -950,8 +955,8 @@ function deserializeDictionaryType(serializer, mapper, responseBody, objectName,
|
|
|
950
955
|
return responseBody;
|
|
951
956
|
}
|
|
952
957
|
function deserializeSequenceType(serializer, mapper, responseBody, objectName, options) {
|
|
953
|
-
|
|
954
|
-
|
|
958
|
+
var _a;
|
|
959
|
+
let element = mapper.type.element;
|
|
955
960
|
if (!element || typeof element !== "object") {
|
|
956
961
|
throw new Error(`element" metadata for an Array must be defined in the ` +
|
|
957
962
|
`mapper and it must of type "object" in ${objectName}`);
|
|
@@ -961,6 +966,12 @@ function deserializeSequenceType(serializer, mapper, responseBody, objectName, o
|
|
|
961
966
|
// xml2js will interpret a single element array as just the element, so force it to be an array
|
|
962
967
|
responseBody = [responseBody];
|
|
963
968
|
}
|
|
969
|
+
// Quirk: Composite mappers referenced by `element` might
|
|
970
|
+
// not have *all* properties declared (like uberParent),
|
|
971
|
+
// so let's try to look up the full definition by name.
|
|
972
|
+
if (element.type.name === "Composite" && element.type.className) {
|
|
973
|
+
element = (_a = serializer.modelMappers[element.type.className]) !== null && _a !== void 0 ? _a : element;
|
|
974
|
+
}
|
|
964
975
|
const tempArray = [];
|
|
965
976
|
for (let i = 0; i < responseBody.length; i++) {
|
|
966
977
|
tempArray[i] = serializer.deserialize(element, responseBody[i], `${objectName}[${i}]`, options);
|
|
@@ -972,8 +983,12 @@ function deserializeSequenceType(serializer, mapper, responseBody, objectName, o
|
|
|
972
983
|
function getPolymorphicMapper(serializer, mapper, object, polymorphicPropertyName) {
|
|
973
984
|
const polymorphicDiscriminator = getPolymorphicDiscriminatorRecursively(serializer, mapper);
|
|
974
985
|
if (polymorphicDiscriminator) {
|
|
975
|
-
|
|
986
|
+
let discriminatorName = polymorphicDiscriminator[polymorphicPropertyName];
|
|
976
987
|
if (discriminatorName) {
|
|
988
|
+
// The serializedName might have \\, which we just want to ignore
|
|
989
|
+
if (polymorphicPropertyName === "serializedName") {
|
|
990
|
+
discriminatorName = discriminatorName.replace(/\\/gi, "");
|
|
991
|
+
}
|
|
977
992
|
const discriminatorValue = object[discriminatorName];
|
|
978
993
|
if (discriminatorValue !== undefined && discriminatorValue !== null) {
|
|
979
994
|
const typeName = mapper.type.uberParent || mapper.type.className;
|
|
@@ -1018,7 +1033,7 @@ const MapperTypeNames = {
|
|
|
1018
1033
|
String: "String",
|
|
1019
1034
|
Stream: "Stream",
|
|
1020
1035
|
TimeSpan: "TimeSpan",
|
|
1021
|
-
UnixTime: "UnixTime"
|
|
1036
|
+
UnixTime: "UnixTime",
|
|
1022
1037
|
};
|
|
1023
1038
|
|
|
1024
1039
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -1104,7 +1119,7 @@ function getOperationArgumentValueFromParameter(operationArguments, parameter, f
|
|
|
1104
1119
|
const propertyPath = parameterPath[propertyName];
|
|
1105
1120
|
const propertyValue = getOperationArgumentValueFromParameter(operationArguments, {
|
|
1106
1121
|
parameterPath: propertyPath,
|
|
1107
|
-
mapper: propertyMapper
|
|
1122
|
+
mapper: propertyMapper,
|
|
1108
1123
|
}, fallbackObject);
|
|
1109
1124
|
if (propertyValue !== undefined) {
|
|
1110
1125
|
if (!value) {
|
|
@@ -1150,7 +1165,7 @@ const CollectionFormatToDelimiterMap = {
|
|
|
1150
1165
|
SSV: " ",
|
|
1151
1166
|
Multi: "Multi",
|
|
1152
1167
|
TSV: "\t",
|
|
1153
|
-
Pipes: "|"
|
|
1168
|
+
Pipes: "|",
|
|
1154
1169
|
};
|
|
1155
1170
|
function getRequestUrl(baseUri, operationSpec, operationArguments, fallbackObject) {
|
|
1156
1171
|
const urlReplacements = calculateUrlReplacements(operationSpec, operationArguments, fallbackObject);
|
|
@@ -1285,7 +1300,7 @@ function calculateQueryParameters(operationSpec, operationArguments, fallbackObj
|
|
|
1285
1300
|
}
|
|
1286
1301
|
return {
|
|
1287
1302
|
queryParams: result,
|
|
1288
|
-
sequenceParams
|
|
1303
|
+
sequenceParams,
|
|
1289
1304
|
};
|
|
1290
1305
|
}
|
|
1291
1306
|
function simpleParseQueryParams(queryString) {
|
|
@@ -1399,15 +1414,15 @@ function deserializationPolicy(options = {}) {
|
|
|
1399
1414
|
xml: {
|
|
1400
1415
|
rootName: (_e = serializerOptions === null || serializerOptions === void 0 ? void 0 : serializerOptions.xml.rootName) !== null && _e !== void 0 ? _e : "",
|
|
1401
1416
|
includeRoot: (_f = serializerOptions === null || serializerOptions === void 0 ? void 0 : serializerOptions.xml.includeRoot) !== null && _f !== void 0 ? _f : false,
|
|
1402
|
-
xmlCharKey: (_g = serializerOptions === null || serializerOptions === void 0 ? void 0 : serializerOptions.xml.xmlCharKey) !== null && _g !== void 0 ? _g : XML_CHARKEY
|
|
1403
|
-
}
|
|
1417
|
+
xmlCharKey: (_g = serializerOptions === null || serializerOptions === void 0 ? void 0 : serializerOptions.xml.xmlCharKey) !== null && _g !== void 0 ? _g : XML_CHARKEY,
|
|
1418
|
+
},
|
|
1404
1419
|
};
|
|
1405
1420
|
return {
|
|
1406
1421
|
name: deserializationPolicyName,
|
|
1407
1422
|
async sendRequest(request, next) {
|
|
1408
1423
|
const response = await next(request);
|
|
1409
1424
|
return deserializeResponseBody(jsonContentTypes, xmlContentTypes, response, updatedOptions, parseXML);
|
|
1410
|
-
}
|
|
1425
|
+
},
|
|
1411
1426
|
};
|
|
1412
1427
|
}
|
|
1413
1428
|
function getOperationResponseMap(parsedResponse) {
|
|
@@ -1477,7 +1492,7 @@ async function deserializeResponseBody(jsonContentTypes, xmlContentTypes, respon
|
|
|
1477
1492
|
const restError = new coreRestPipeline.RestError(`Error ${deserializeError} occurred in deserializing the responseBody - ${parsedResponse.bodyAsText}`, {
|
|
1478
1493
|
statusCode: parsedResponse.status,
|
|
1479
1494
|
request: parsedResponse.request,
|
|
1480
|
-
response: parsedResponse
|
|
1495
|
+
response: parsedResponse,
|
|
1481
1496
|
});
|
|
1482
1497
|
throw restError;
|
|
1483
1498
|
}
|
|
@@ -1520,7 +1535,7 @@ function handleErrorResponse(parsedResponse, operationSpec, responseSpec) {
|
|
|
1520
1535
|
const error = new coreRestPipeline.RestError(initialErrorMessage, {
|
|
1521
1536
|
statusCode: parsedResponse.status,
|
|
1522
1537
|
request: parsedResponse.request,
|
|
1523
|
-
response: parsedResponse
|
|
1538
|
+
response: parsedResponse,
|
|
1524
1539
|
});
|
|
1525
1540
|
// If the item failed but there's no error spec or default spec to deserialize the error,
|
|
1526
1541
|
// we should fail so we just throw the parsed response
|
|
@@ -1557,7 +1572,8 @@ function handleErrorResponse(parsedResponse, operationSpec, responseSpec) {
|
|
|
1557
1572
|
}
|
|
1558
1573
|
// If error response has headers, try to deserialize it using default header mapper
|
|
1559
1574
|
if (parsedResponse.headers && defaultHeadersMapper) {
|
|
1560
|
-
error.response.parsedHeaders =
|
|
1575
|
+
error.response.parsedHeaders =
|
|
1576
|
+
operationSpec.serializer.deserialize(defaultHeadersMapper, parsedResponse.headers.toJSON(), "operationRes.parsedHeaders");
|
|
1561
1577
|
}
|
|
1562
1578
|
}
|
|
1563
1579
|
catch (defaultError) {
|
|
@@ -1596,7 +1612,7 @@ async function parse(jsonContentTypes, xmlContentTypes, operationResponse, opts,
|
|
|
1596
1612
|
code: errCode,
|
|
1597
1613
|
statusCode: operationResponse.status,
|
|
1598
1614
|
request: operationResponse.request,
|
|
1599
|
-
response: operationResponse
|
|
1615
|
+
response: operationResponse,
|
|
1600
1616
|
});
|
|
1601
1617
|
throw e;
|
|
1602
1618
|
}
|
|
@@ -1626,7 +1642,7 @@ function serializationPolicy(options = {}) {
|
|
|
1626
1642
|
serializeRequestBody(request, operationArguments, operationSpec, stringifyXML);
|
|
1627
1643
|
}
|
|
1628
1644
|
return next(request);
|
|
1629
|
-
}
|
|
1645
|
+
},
|
|
1630
1646
|
};
|
|
1631
1647
|
}
|
|
1632
1648
|
/**
|
|
@@ -1671,14 +1687,14 @@ function serializeRequestBody(request, operationArguments, operationSpec, string
|
|
|
1671
1687
|
xml: {
|
|
1672
1688
|
rootName: (_b = serializerOptions === null || serializerOptions === void 0 ? void 0 : serializerOptions.xml.rootName) !== null && _b !== void 0 ? _b : "",
|
|
1673
1689
|
includeRoot: (_c = serializerOptions === null || serializerOptions === void 0 ? void 0 : serializerOptions.xml.includeRoot) !== null && _c !== void 0 ? _c : false,
|
|
1674
|
-
xmlCharKey: (_d = serializerOptions === null || serializerOptions === void 0 ? void 0 : serializerOptions.xml.xmlCharKey) !== null && _d !== void 0 ? _d : XML_CHARKEY
|
|
1675
|
-
}
|
|
1690
|
+
xmlCharKey: (_d = serializerOptions === null || serializerOptions === void 0 ? void 0 : serializerOptions.xml.xmlCharKey) !== null && _d !== void 0 ? _d : XML_CHARKEY,
|
|
1691
|
+
},
|
|
1676
1692
|
};
|
|
1677
1693
|
const xmlCharKey = updatedOptions.xml.xmlCharKey;
|
|
1678
1694
|
if (operationSpec.requestBody && operationSpec.requestBody.mapper) {
|
|
1679
1695
|
request.body = getOperationArgumentValueFromParameter(operationArguments, operationSpec.requestBody);
|
|
1680
1696
|
const bodyMapper = operationSpec.requestBody.mapper;
|
|
1681
|
-
const { required, serializedName, xmlName, xmlElementName, xmlNamespace, xmlNamespacePrefix, nullable } = bodyMapper;
|
|
1697
|
+
const { required, serializedName, xmlName, xmlElementName, xmlNamespace, xmlNamespacePrefix, nullable, } = bodyMapper;
|
|
1682
1698
|
const typeName = bodyMapper.type.name;
|
|
1683
1699
|
try {
|
|
1684
1700
|
if ((request.body !== undefined && request.body !== null) ||
|
|
@@ -1696,7 +1712,7 @@ function serializeRequestBody(request, operationArguments, operationSpec, string
|
|
|
1696
1712
|
else if (!isStream) {
|
|
1697
1713
|
request.body = stringifyXML(value, {
|
|
1698
1714
|
rootName: xmlName || serializedName,
|
|
1699
|
-
xmlCharKey
|
|
1715
|
+
xmlCharKey,
|
|
1700
1716
|
});
|
|
1701
1717
|
}
|
|
1702
1718
|
}
|
|
@@ -1764,12 +1780,12 @@ function createClientPipeline(options = {}) {
|
|
|
1764
1780
|
if (options.credentialOptions) {
|
|
1765
1781
|
pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
|
|
1766
1782
|
credential: options.credentialOptions.credential,
|
|
1767
|
-
scopes: options.credentialOptions.credentialScopes
|
|
1783
|
+
scopes: options.credentialOptions.credentialScopes,
|
|
1768
1784
|
}));
|
|
1769
1785
|
}
|
|
1770
1786
|
pipeline.addPolicy(serializationPolicy(options.serializationOptions), { phase: "Serialize" });
|
|
1771
1787
|
pipeline.addPolicy(deserializationPolicy(options.deserializationOptions), {
|
|
1772
|
-
phase: "Deserialize"
|
|
1788
|
+
phase: "Deserialize",
|
|
1773
1789
|
});
|
|
1774
1790
|
return pipeline;
|
|
1775
1791
|
}
|
|
@@ -1813,7 +1829,7 @@ class ServiceClient {
|
|
|
1813
1829
|
// not part of OperationArguments
|
|
1814
1830
|
const url = getRequestUrl(baseUri, operationSpec, operationArguments, this);
|
|
1815
1831
|
const request = coreRestPipeline.createPipelineRequest({
|
|
1816
|
-
url
|
|
1832
|
+
url,
|
|
1817
1833
|
});
|
|
1818
1834
|
request.method = operationSpec.httpMethod;
|
|
1819
1835
|
const operationInfo = getOperationRequestInfo(request);
|
|
@@ -1953,7 +1969,7 @@ async function authorizeRequestOnClaimChallenge(onChallengeOptions) {
|
|
|
1953
1969
|
return false;
|
|
1954
1970
|
}
|
|
1955
1971
|
const accessToken = await onChallengeOptions.getAccessToken(parsedChallenge.scope ? [parsedChallenge.scope] : scopes, {
|
|
1956
|
-
claims: decodeStringToString(parsedChallenge.claims)
|
|
1972
|
+
claims: decodeStringToString(parsedChallenge.claims),
|
|
1957
1973
|
});
|
|
1958
1974
|
if (!accessToken) {
|
|
1959
1975
|
return false;
|