@aws-sdk/core 3.974.8 → 3.974.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.js +65 -51
- package/dist-cjs/submodules/account-id-endpoint/index.js +2 -2
- package/dist-cjs/submodules/client/index.js +2 -2
- package/dist-cjs/submodules/httpAuthSchemes/index.js +7 -7
- package/dist-cjs/submodules/protocols/index.js +56 -41
- package/dist-cjs/submodules/util/index.js +59 -0
- package/dist-es/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.js +1 -1
- package/dist-es/submodules/client/setFeature.js +1 -1
- package/dist-es/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.js +1 -1
- package/dist-es/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js +1 -1
- package/dist-es/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4AConfig.js +1 -1
- package/dist-es/submodules/httpAuthSchemes/utils/getDateHeader.js +1 -1
- package/dist-es/submodules/protocols/ProtocolLib.js +1 -1
- package/dist-es/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.js +1 -1
- package/dist-es/submodules/protocols/common.js +2 -2
- package/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +7 -6
- package/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +1 -1
- package/dist-es/submodules/protocols/json/JsonShapeDeserializer.js +1 -1
- package/dist-es/submodules/protocols/json/JsonShapeSerializer.js +1 -2
- package/dist-es/submodules/protocols/json/awsExpectUnion.js +1 -1
- package/dist-es/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.js +1 -2
- package/dist-es/submodules/protocols/json/parseJsonBody.js +28 -13
- package/dist-es/submodules/protocols/query/AwsQueryProtocol.js +1 -1
- package/dist-es/submodules/protocols/query/QueryShapeSerializer.js +2 -3
- package/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +1 -1
- package/dist-es/submodules/protocols/xml/XmlShapeDeserializer.js +2 -2
- package/dist-es/submodules/protocols/xml/XmlShapeSerializer.js +2 -3
- package/dist-es/submodules/protocols/xml/parseXmlBody.js +1 -1
- package/dist-es/submodules/util/index.js +2 -0
- package/dist-es/submodules/util/util-arn-parser/arn.js +21 -0
- package/dist-es/submodules/util/util-format-url/format-url.js +29 -0
- package/dist-types/api-extractor-type-index.d.ts +1 -0
- package/dist-types/index.d.ts +1 -0
- package/dist-types/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.d.ts +1 -1
- package/dist-types/submodules/httpAuthSchemes/aws_sdk/NODE_AUTH_SCHEME_PREFERENCE_OPTIONS.d.ts +1 -1
- package/dist-types/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4AConfig.d.ts +1 -1
- package/dist-types/submodules/protocols/ProtocolLib.d.ts +1 -1
- package/dist-types/submodules/protocols/json/parseJsonBody.d.ts +4 -0
- package/dist-types/submodules/util/index.d.ts +2 -0
- package/dist-types/submodules/util/util-arn-parser/arn.d.ts +32 -0
- package/dist-types/submodules/util/util-format-url/format-url.d.ts +2 -0
- package/dist-types/ts3.4/api-extractor-type-index.d.ts +1 -0
- package/dist-types/ts3.4/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.d.ts +1 -1
- package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/NODE_AUTH_SCHEME_PREFERENCE_OPTIONS.d.ts +1 -1
- package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4AConfig.d.ts +1 -1
- package/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +1 -1
- package/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +6 -0
- package/dist-types/ts3.4/submodules/util/index.d.ts +2 -0
- package/dist-types/ts3.4/submodules/util/util-arn-parser/arn.d.ts +14 -0
- package/dist-types/ts3.4/submodules/util/util-format-url/format-url.d.ts +4 -0
- package/package.json +16 -13
- package/util.d.ts +7 -0
- package/util.js +5 -0
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var cbor = require('@smithy/core/cbor');
|
|
4
4
|
var schema = require('@smithy/core/schema');
|
|
5
|
-
var
|
|
5
|
+
var client = require('@smithy/core/client');
|
|
6
6
|
var protocols = require('@smithy/core/protocols');
|
|
7
7
|
var serde = require('@smithy/core/serde');
|
|
8
|
-
var utilBase64 = require('@smithy/util-base64');
|
|
9
|
-
var utilUtf8 = require('@smithy/util-utf8');
|
|
10
8
|
var xmlBuilder = require('@aws-sdk/xml-builder');
|
|
11
9
|
|
|
12
10
|
class ProtocolLib {
|
|
@@ -92,7 +90,7 @@ class ProtocolLib {
|
|
|
92
90
|
decorateServiceException(exception, additions = {}) {
|
|
93
91
|
if (this.queryCompat) {
|
|
94
92
|
const msg = exception.Message ?? additions.Message;
|
|
95
|
-
const error =
|
|
93
|
+
const error = client.decorateServiceException(exception, additions);
|
|
96
94
|
if (msg) {
|
|
97
95
|
error.message = msg;
|
|
98
96
|
}
|
|
@@ -107,7 +105,7 @@ class ProtocolLib {
|
|
|
107
105
|
}
|
|
108
106
|
return error;
|
|
109
107
|
}
|
|
110
|
-
return
|
|
108
|
+
return client.decorateServiceException(exception, additions);
|
|
111
109
|
}
|
|
112
110
|
setQueryCompatError(output, response) {
|
|
113
111
|
const queryErrorHeader = response.headers?.["x-amzn-query-error"];
|
|
@@ -180,7 +178,7 @@ class AwsSmithyRpcV2CborProtocol extends cbor.SmithyRpcV2CborProtocol {
|
|
|
180
178
|
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
181
179
|
const message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
|
182
180
|
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
|
183
|
-
const exception = new ErrorCtor(
|
|
181
|
+
const exception = new ErrorCtor({});
|
|
184
182
|
const output = {};
|
|
185
183
|
for (const [name, member] of ns.structIterator()) {
|
|
186
184
|
if (dataObject[name] != null) {
|
|
@@ -299,7 +297,7 @@ function jsonReviver(key, value, context) {
|
|
|
299
297
|
return value;
|
|
300
298
|
}
|
|
301
299
|
|
|
302
|
-
const collectBodyString = (streamBody, context) =>
|
|
300
|
+
const collectBodyString = (streamBody, context) => protocols.collectBody(streamBody, context).then((body) => (context?.utf8Encoder ?? serde.toUtf8)(body));
|
|
303
301
|
|
|
304
302
|
const parseJsonBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
|
|
305
303
|
if (encoded.length) {
|
|
@@ -323,7 +321,7 @@ const parseJsonErrorBody = async (errorBody, context) => {
|
|
|
323
321
|
return value;
|
|
324
322
|
};
|
|
325
323
|
const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
|
|
326
|
-
const sanitizeErrorCode = (rawValue) => {
|
|
324
|
+
const sanitizeErrorCode = (rawValue, removeNamespace = true) => {
|
|
327
325
|
let cleanValue = rawValue;
|
|
328
326
|
if (typeof cleanValue === "number") {
|
|
329
327
|
cleanValue = cleanValue.toString();
|
|
@@ -334,23 +332,38 @@ const sanitizeErrorCode = (rawValue) => {
|
|
|
334
332
|
if (cleanValue.indexOf(":") >= 0) {
|
|
335
333
|
cleanValue = cleanValue.split(":")[0];
|
|
336
334
|
}
|
|
337
|
-
if (cleanValue.indexOf("#") >= 0) {
|
|
335
|
+
if (removeNamespace && cleanValue.indexOf("#") >= 0) {
|
|
338
336
|
cleanValue = cleanValue.split("#")[1];
|
|
339
337
|
}
|
|
340
338
|
return cleanValue;
|
|
341
339
|
};
|
|
342
340
|
const loadRestJsonErrorCode = (output, data) => {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
341
|
+
return loadErrorCode(output, data, true, ["header", "code", "type"]);
|
|
342
|
+
};
|
|
343
|
+
const loadJsonRpcErrorCode = (output, data, removeNamespace, queryCompat = false) => {
|
|
344
|
+
return loadErrorCode(output, data, removeNamespace, queryCompat ? ["code", "header", "type"] : ["type", "code", "header"]);
|
|
345
|
+
};
|
|
346
|
+
const loadErrorCode = ({ headers }, data, removeNamespace, order) => {
|
|
347
|
+
while (order.length > 0) {
|
|
348
|
+
const location = order.shift();
|
|
349
|
+
switch (location) {
|
|
350
|
+
case "header":
|
|
351
|
+
const headerKey = findKey(headers ?? {}, "x-amzn-errortype");
|
|
352
|
+
if (headerKey !== undefined) {
|
|
353
|
+
return sanitizeErrorCode(headers[headerKey], removeNamespace);
|
|
354
|
+
}
|
|
355
|
+
break;
|
|
356
|
+
case "code":
|
|
357
|
+
const codeKey = findKey(data ?? {}, "code");
|
|
358
|
+
if (codeKey && data[codeKey] !== undefined) {
|
|
359
|
+
return sanitizeErrorCode(data[codeKey], removeNamespace);
|
|
360
|
+
}
|
|
361
|
+
break;
|
|
362
|
+
case "type":
|
|
363
|
+
if (data?.__type !== undefined) {
|
|
364
|
+
return sanitizeErrorCode(data.__type, removeNamespace);
|
|
365
|
+
}
|
|
366
|
+
break;
|
|
354
367
|
}
|
|
355
368
|
}
|
|
356
369
|
};
|
|
@@ -429,7 +442,7 @@ class JsonShapeDeserializer extends SerdeContextConfig {
|
|
|
429
442
|
}
|
|
430
443
|
}
|
|
431
444
|
if (ns.isBlobSchema() && typeof value === "string") {
|
|
432
|
-
return
|
|
445
|
+
return serde.fromBase64(value);
|
|
433
446
|
}
|
|
434
447
|
const mediaType = ns.getMergedTraits().mediaType;
|
|
435
448
|
if (ns.isStringSchema() && typeof value === "string" && mediaType) {
|
|
@@ -647,7 +660,7 @@ class JsonShapeSerializer extends SerdeContextConfig {
|
|
|
647
660
|
if (ns === this.rootSchema) {
|
|
648
661
|
return value;
|
|
649
662
|
}
|
|
650
|
-
return (this.serdeContext?.base64Encoder ??
|
|
663
|
+
return (this.serdeContext?.base64Encoder ?? serde.toBase64)(value);
|
|
651
664
|
}
|
|
652
665
|
if (value instanceof Date && (ns.isTimestampSchema() || ns.isDocumentSchema())) {
|
|
653
666
|
const format = protocols.determineTimestampFormat(ns, this.settings);
|
|
@@ -693,7 +706,7 @@ class JsonShapeSerializer extends SerdeContextConfig {
|
|
|
693
706
|
if (ns === this.rootSchema) {
|
|
694
707
|
return value;
|
|
695
708
|
}
|
|
696
|
-
return (this.serdeContext?.base64Encoder ??
|
|
709
|
+
return (this.serdeContext?.base64Encoder ?? serde.toBase64)(value);
|
|
697
710
|
}
|
|
698
711
|
if (typeof value === "bigint") {
|
|
699
712
|
this.useReplacer = true;
|
|
@@ -785,16 +798,17 @@ class AwsJsonRpcProtocol extends protocols.RpcProtocol {
|
|
|
785
798
|
return this.codec;
|
|
786
799
|
}
|
|
787
800
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
788
|
-
|
|
801
|
+
const { awsQueryCompatible } = this;
|
|
802
|
+
if (awsQueryCompatible) {
|
|
789
803
|
this.mixin.setQueryCompatError(dataObject, response);
|
|
790
804
|
}
|
|
791
|
-
const errorIdentifier =
|
|
805
|
+
const errorIdentifier = loadJsonRpcErrorCode(response, dataObject, this.getJsonRpcVersion() === "1.1", awsQueryCompatible) ?? "Unknown";
|
|
792
806
|
this.mixin.compose(this.compositeErrorRegistry, errorIdentifier, this.options.defaultNamespace);
|
|
793
|
-
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata,
|
|
807
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata, awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
|
|
794
808
|
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
795
809
|
const message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
|
796
810
|
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
|
797
|
-
const exception = new ErrorCtor(
|
|
811
|
+
const exception = new ErrorCtor({});
|
|
798
812
|
const output = {};
|
|
799
813
|
const errorDeserializer = this.codec.createDeserializer();
|
|
800
814
|
for (const [name, member] of ns.structIterator()) {
|
|
@@ -802,7 +816,7 @@ class AwsJsonRpcProtocol extends protocols.RpcProtocol {
|
|
|
802
816
|
output[name] = errorDeserializer.readObject(member, dataObject[name]);
|
|
803
817
|
}
|
|
804
818
|
}
|
|
805
|
-
if (
|
|
819
|
+
if (awsQueryCompatible) {
|
|
806
820
|
this.mixin.queryCompatOutput(dataObject, output);
|
|
807
821
|
}
|
|
808
822
|
throw this.mixin.decorateServiceException(Object.assign(exception, errorMetadata, {
|
|
@@ -917,7 +931,7 @@ class AwsRestJsonProtocol extends protocols.HttpBindingProtocol {
|
|
|
917
931
|
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
918
932
|
const message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
|
919
933
|
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
|
920
|
-
const exception = new ErrorCtor(
|
|
934
|
+
const exception = new ErrorCtor({});
|
|
921
935
|
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
922
936
|
const output = {};
|
|
923
937
|
const errorDeserializer = this.codec.createDeserializer();
|
|
@@ -942,7 +956,7 @@ const awsExpectUnion = (value) => {
|
|
|
942
956
|
if (typeof value === "object" && "__type" in value) {
|
|
943
957
|
delete value.__type;
|
|
944
958
|
}
|
|
945
|
-
return
|
|
959
|
+
return serde.expectUnion(value);
|
|
946
960
|
};
|
|
947
961
|
|
|
948
962
|
class XmlShapeDeserializer extends SerdeContextConfig {
|
|
@@ -977,7 +991,7 @@ class XmlShapeDeserializer extends SerdeContextConfig {
|
|
|
977
991
|
}
|
|
978
992
|
return output;
|
|
979
993
|
}
|
|
980
|
-
const xmlString = (this.serdeContext?.utf8Encoder ??
|
|
994
|
+
const xmlString = (this.serdeContext?.utf8Encoder ?? serde.toUtf8)(bytes);
|
|
981
995
|
const parsedObject = this.parseXml(xmlString);
|
|
982
996
|
return this.readSchema(schema$1, key ? parsedObject[key] : parsedObject);
|
|
983
997
|
}
|
|
@@ -1086,7 +1100,7 @@ class XmlShapeDeserializer extends SerdeContextConfig {
|
|
|
1086
1100
|
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
|
|
1087
1101
|
delete parsedObjToReturn[textNodeName];
|
|
1088
1102
|
}
|
|
1089
|
-
return
|
|
1103
|
+
return client.getValueFromTextNode(parsedObjToReturn);
|
|
1090
1104
|
}
|
|
1091
1105
|
return {};
|
|
1092
1106
|
}
|
|
@@ -1110,7 +1124,7 @@ class QueryShapeSerializer extends SerdeContextConfig {
|
|
|
1110
1124
|
if (ns.isBlobSchema()) {
|
|
1111
1125
|
if (typeof value === "string" || value instanceof Uint8Array) {
|
|
1112
1126
|
this.writeKey(prefix);
|
|
1113
|
-
this.writeValue((this.serdeContext?.base64Encoder ??
|
|
1127
|
+
this.writeValue((this.serdeContext?.base64Encoder ?? serde.toBase64)(value));
|
|
1114
1128
|
}
|
|
1115
1129
|
}
|
|
1116
1130
|
else if (ns.isBooleanSchema() || ns.isNumericSchema() || ns.isStringSchema()) {
|
|
@@ -1144,7 +1158,7 @@ class QueryShapeSerializer extends SerdeContextConfig {
|
|
|
1144
1158
|
this.writeValue(value.toISOString().replace(".000Z", "Z"));
|
|
1145
1159
|
break;
|
|
1146
1160
|
case 6:
|
|
1147
|
-
this.writeValue(
|
|
1161
|
+
this.writeValue(serde.dateToUtcString(value));
|
|
1148
1162
|
break;
|
|
1149
1163
|
case 7:
|
|
1150
1164
|
this.writeValue(String(value.getTime() / 1000));
|
|
@@ -1368,7 +1382,7 @@ class AwsQueryProtocol extends protocols.RpcProtocol {
|
|
|
1368
1382
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, this.mixin.findQueryCompatibleError);
|
|
1369
1383
|
const ns = schema.NormalizedSchema.of(errorSchema);
|
|
1370
1384
|
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
|
1371
|
-
const exception = new ErrorCtor(
|
|
1385
|
+
const exception = new ErrorCtor({});
|
|
1372
1386
|
const output = {
|
|
1373
1387
|
Type: errorData.Error.Type,
|
|
1374
1388
|
Code: errorData.Error.Code,
|
|
@@ -1447,7 +1461,7 @@ const parseXmlBody = (streamBody, context) => collectBodyString(streamBody, cont
|
|
|
1447
1461
|
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
|
|
1448
1462
|
delete parsedObjToReturn[textNodeName];
|
|
1449
1463
|
}
|
|
1450
|
-
return
|
|
1464
|
+
return client.getValueFromTextNode(parsedObjToReturn);
|
|
1451
1465
|
}
|
|
1452
1466
|
return {};
|
|
1453
1467
|
});
|
|
@@ -1488,7 +1502,7 @@ class XmlShapeSerializer extends SerdeContextConfig {
|
|
|
1488
1502
|
this.byteBuffer =
|
|
1489
1503
|
"byteLength" in value
|
|
1490
1504
|
? value
|
|
1491
|
-
: (this.serdeContext?.base64Decoder ??
|
|
1505
|
+
: (this.serdeContext?.base64Decoder ?? serde.fromBase64)(value);
|
|
1492
1506
|
}
|
|
1493
1507
|
else {
|
|
1494
1508
|
this.buffer = this.writeStruct(ns, value, undefined);
|
|
@@ -1692,7 +1706,7 @@ class XmlShapeSerializer extends SerdeContextConfig {
|
|
|
1692
1706
|
let nodeContents = null;
|
|
1693
1707
|
if (value && typeof value === "object") {
|
|
1694
1708
|
if (ns.isBlobSchema()) {
|
|
1695
|
-
nodeContents = (this.serdeContext?.base64Encoder ??
|
|
1709
|
+
nodeContents = (this.serdeContext?.base64Encoder ?? serde.toBase64)(value);
|
|
1696
1710
|
}
|
|
1697
1711
|
else if (ns.isTimestampSchema() && value instanceof Date) {
|
|
1698
1712
|
const format = protocols.determineTimestampFormat(ns, this.settings);
|
|
@@ -1701,14 +1715,14 @@ class XmlShapeSerializer extends SerdeContextConfig {
|
|
|
1701
1715
|
nodeContents = value.toISOString().replace(".000Z", "Z");
|
|
1702
1716
|
break;
|
|
1703
1717
|
case 6:
|
|
1704
|
-
nodeContents =
|
|
1718
|
+
nodeContents = serde.dateToUtcString(value);
|
|
1705
1719
|
break;
|
|
1706
1720
|
case 7:
|
|
1707
1721
|
nodeContents = String(value.getTime() / 1000);
|
|
1708
1722
|
break;
|
|
1709
1723
|
default:
|
|
1710
1724
|
console.warn("Missing timestamp format, using http date", value);
|
|
1711
|
-
nodeContents =
|
|
1725
|
+
nodeContents = serde.dateToUtcString(value);
|
|
1712
1726
|
break;
|
|
1713
1727
|
}
|
|
1714
1728
|
}
|
|
@@ -1847,7 +1861,7 @@ class AwsRestXmlProtocol extends protocols.HttpBindingProtocol {
|
|
|
1847
1861
|
dataObject.Message ??
|
|
1848
1862
|
"UnknownError";
|
|
1849
1863
|
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
|
1850
|
-
const exception = new ErrorCtor(
|
|
1864
|
+
const exception = new ErrorCtor({});
|
|
1851
1865
|
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
1852
1866
|
const output = {};
|
|
1853
1867
|
const errorDeserializer = this.codec.createDeserializer();
|
|
@@ -1893,6 +1907,7 @@ exports._toBool = _toBool;
|
|
|
1893
1907
|
exports._toNum = _toNum;
|
|
1894
1908
|
exports._toStr = _toStr;
|
|
1895
1909
|
exports.awsExpectUnion = awsExpectUnion;
|
|
1910
|
+
exports.loadJsonRpcErrorCode = loadJsonRpcErrorCode;
|
|
1896
1911
|
exports.loadRestJsonErrorCode = loadRestJsonErrorCode;
|
|
1897
1912
|
exports.loadRestXmlErrorCode = loadRestXmlErrorCode;
|
|
1898
1913
|
exports.parseJsonBody = parseJsonBody;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var protocols = require('@smithy/core/protocols');
|
|
4
|
+
|
|
5
|
+
const validate = (str) => typeof str === "string" && str.indexOf("arn:") === 0 && str.split(":").length >= 6;
|
|
6
|
+
const parse = (arn) => {
|
|
7
|
+
const segments = arn.split(":");
|
|
8
|
+
if (segments.length < 6 || segments[0] !== "arn")
|
|
9
|
+
throw new Error("Malformed ARN");
|
|
10
|
+
const [, partition, service, region, accountId, ...resource] = segments;
|
|
11
|
+
return {
|
|
12
|
+
partition,
|
|
13
|
+
service,
|
|
14
|
+
region,
|
|
15
|
+
accountId,
|
|
16
|
+
resource: resource.join(":"),
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const build = (arnObject) => {
|
|
20
|
+
const { partition = "aws", service, region, accountId, resource } = arnObject;
|
|
21
|
+
if ([service, region, accountId, resource].some((segment) => typeof segment !== "string")) {
|
|
22
|
+
throw new Error("Input ARN object is invalid");
|
|
23
|
+
}
|
|
24
|
+
return `arn:${partition}:${service}:${region}:${accountId}:${resource}`;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function formatUrl(request) {
|
|
28
|
+
const { port, query } = request;
|
|
29
|
+
let { protocol, path, hostname } = request;
|
|
30
|
+
if (protocol && protocol.slice(-1) !== ":") {
|
|
31
|
+
protocol += ":";
|
|
32
|
+
}
|
|
33
|
+
if (port) {
|
|
34
|
+
hostname += `:${port}`;
|
|
35
|
+
}
|
|
36
|
+
if (path && path.charAt(0) !== "/") {
|
|
37
|
+
path = `/${path}`;
|
|
38
|
+
}
|
|
39
|
+
let queryString = query ? protocols.buildQueryString(query) : "";
|
|
40
|
+
if (queryString && queryString[0] !== "?") {
|
|
41
|
+
queryString = `?${queryString}`;
|
|
42
|
+
}
|
|
43
|
+
let auth = "";
|
|
44
|
+
if (request.username != null || request.password != null) {
|
|
45
|
+
const username = request.username ?? "";
|
|
46
|
+
const password = request.password ?? "";
|
|
47
|
+
auth = `${username}:${password}@`;
|
|
48
|
+
}
|
|
49
|
+
let fragment = "";
|
|
50
|
+
if (request.fragment) {
|
|
51
|
+
fragment = `#${request.fragment}`;
|
|
52
|
+
}
|
|
53
|
+
return `${protocol}//${auth}${hostname}${path}${queryString}${fragment}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
exports.build = build;
|
|
57
|
+
exports.formatUrl = formatUrl;
|
|
58
|
+
exports.parse = parse;
|
|
59
|
+
exports.validate = validate;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeProvider } from "@smithy/
|
|
1
|
+
import { normalizeProvider } from "@smithy/core/client";
|
|
2
2
|
import { DEFAULT_ACCOUNT_ID_ENDPOINT_MODE, validateAccountIdEndpointMode } from "./AccountIdEndpointModeConstants";
|
|
3
3
|
export const resolveAccountIdEndpointModeConfig = (input) => {
|
|
4
4
|
const { accountIdEndpointMode } = input;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Retry } from "@smithy/
|
|
1
|
+
import { Retry } from "@smithy/core/retry";
|
|
2
2
|
Retry.v2026 ||= typeof process === "object" && process.env?.AWS_NEW_RETRIES_2026 === "true";
|
|
3
3
|
export function setFeature(context, feature, value) {
|
|
4
4
|
if (!context.__aws_sdk_context) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpRequest } from "@smithy/
|
|
1
|
+
import { HttpRequest } from "@smithy/core/protocols";
|
|
2
2
|
import { getSkewCorrectedDate } from "../utils";
|
|
3
3
|
import { AwsSdkSigV4Signer, validateSigningProperties } from "./AwsSdkSigV4Signer";
|
|
4
4
|
export class AwsSdkSigV4ASigner extends AwsSdkSigV4Signer {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpRequest } from "@smithy/
|
|
1
|
+
import { HttpRequest } from "@smithy/core/protocols";
|
|
2
2
|
import { getDateHeader, getSkewCorrectedDate, getUpdatedSystemClockOffset } from "../utils";
|
|
3
3
|
const throwSigningPropertyError = (name, property) => {
|
|
4
4
|
if (!property) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizeProvider } from "@smithy/core";
|
|
2
|
-
import { ProviderError } from "@smithy/
|
|
2
|
+
import { ProviderError } from "@smithy/core/config";
|
|
3
3
|
export const resolveAwsSdkSigV4AConfig = (config) => {
|
|
4
4
|
config.sigv4aSigningRegionSet = normalizeProvider(config.sigv4aSigningRegionSet);
|
|
5
5
|
return config;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { HttpResponse } from "@smithy/
|
|
1
|
+
import { HttpResponse } from "@smithy/core/protocols";
|
|
2
2
|
export const getDateHeader = (response) => HttpResponse.isInstance(response) ? response.headers?.date ?? response.headers?.Date : undefined;
|
|
@@ -32,7 +32,7 @@ export class AwsSmithyRpcV2CborProtocol extends SmithyRpcV2CborProtocol {
|
|
|
32
32
|
const ns = NormalizedSchema.of(errorSchema);
|
|
33
33
|
const message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
|
34
34
|
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
|
35
|
-
const exception = new ErrorCtor(
|
|
35
|
+
const exception = new ErrorCtor({});
|
|
36
36
|
const output = {};
|
|
37
37
|
for (const [name, member] of ns.structIterator()) {
|
|
38
38
|
if (dataObject[name] != null) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { collectBody } from "@smithy/
|
|
2
|
-
import { toUtf8 } from "@smithy/
|
|
1
|
+
import { collectBody } from "@smithy/core/protocols";
|
|
2
|
+
import { toUtf8 } from "@smithy/core/serde";
|
|
3
3
|
export const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => (context?.utf8Encoder ?? toUtf8)(body));
|
|
@@ -2,7 +2,7 @@ import { RpcProtocol } from "@smithy/core/protocols";
|
|
|
2
2
|
import { deref, NormalizedSchema } from "@smithy/core/schema";
|
|
3
3
|
import { ProtocolLib } from "../ProtocolLib";
|
|
4
4
|
import { JsonCodec } from "./JsonCodec";
|
|
5
|
-
import {
|
|
5
|
+
import { loadJsonRpcErrorCode } from "./parseJsonBody";
|
|
6
6
|
export class AwsJsonRpcProtocol extends RpcProtocol {
|
|
7
7
|
serializer;
|
|
8
8
|
deserializer;
|
|
@@ -49,16 +49,17 @@ export class AwsJsonRpcProtocol extends RpcProtocol {
|
|
|
49
49
|
return this.codec;
|
|
50
50
|
}
|
|
51
51
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
52
|
-
|
|
52
|
+
const { awsQueryCompatible } = this;
|
|
53
|
+
if (awsQueryCompatible) {
|
|
53
54
|
this.mixin.setQueryCompatError(dataObject, response);
|
|
54
55
|
}
|
|
55
|
-
const errorIdentifier =
|
|
56
|
+
const errorIdentifier = loadJsonRpcErrorCode(response, dataObject, this.getJsonRpcVersion() === "1.1", awsQueryCompatible) ?? "Unknown";
|
|
56
57
|
this.mixin.compose(this.compositeErrorRegistry, errorIdentifier, this.options.defaultNamespace);
|
|
57
|
-
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata,
|
|
58
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata, awsQueryCompatible ? this.mixin.findQueryCompatibleError : undefined);
|
|
58
59
|
const ns = NormalizedSchema.of(errorSchema);
|
|
59
60
|
const message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
|
60
61
|
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
|
61
|
-
const exception = new ErrorCtor(
|
|
62
|
+
const exception = new ErrorCtor({});
|
|
62
63
|
const output = {};
|
|
63
64
|
const errorDeserializer = this.codec.createDeserializer();
|
|
64
65
|
for (const [name, member] of ns.structIterator()) {
|
|
@@ -66,7 +67,7 @@ export class AwsJsonRpcProtocol extends RpcProtocol {
|
|
|
66
67
|
output[name] = errorDeserializer.readObject(member, dataObject[name]);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
if (
|
|
70
|
+
if (awsQueryCompatible) {
|
|
70
71
|
this.mixin.queryCompatOutput(dataObject, output);
|
|
71
72
|
}
|
|
72
73
|
throw this.mixin.decorateServiceException(Object.assign(exception, errorMetadata, {
|
|
@@ -66,7 +66,7 @@ export class AwsRestJsonProtocol extends HttpBindingProtocol {
|
|
|
66
66
|
const ns = NormalizedSchema.of(errorSchema);
|
|
67
67
|
const message = dataObject.message ?? dataObject.Message ?? "UnknownError";
|
|
68
68
|
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
|
69
|
-
const exception = new ErrorCtor(
|
|
69
|
+
const exception = new ErrorCtor({});
|
|
70
70
|
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
71
71
|
const output = {};
|
|
72
72
|
const errorDeserializer = this.codec.createDeserializer();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { determineTimestampFormat } from "@smithy/core/protocols";
|
|
2
2
|
import { NormalizedSchema } from "@smithy/core/schema";
|
|
3
3
|
import { LazyJsonString, NumericValue, parseEpochTimestamp, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, } from "@smithy/core/serde";
|
|
4
|
-
import { fromBase64 } from "@smithy/
|
|
4
|
+
import { fromBase64 } from "@smithy/core/serde";
|
|
5
5
|
import { SerdeContextConfig } from "../ConfigurableSerdeContext";
|
|
6
6
|
import { UnionSerde } from "../UnionSerde";
|
|
7
7
|
import { jsonReviver } from "./jsonReviver";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { determineTimestampFormat } from "@smithy/core/protocols";
|
|
2
2
|
import { NormalizedSchema } from "@smithy/core/schema";
|
|
3
|
-
import { dateToUtcString, generateIdempotencyToken, LazyJsonString, NumericValue } from "@smithy/core/serde";
|
|
4
|
-
import { toBase64 } from "@smithy/util-base64";
|
|
3
|
+
import { dateToUtcString, generateIdempotencyToken, LazyJsonString, NumericValue, toBase64 } from "@smithy/core/serde";
|
|
5
4
|
import { SerdeContextConfig } from "../ConfigurableSerdeContext";
|
|
6
5
|
import { JsonReplacer } from "./jsonReplacer";
|
|
7
6
|
export class JsonShapeSerializer extends SerdeContextConfig {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { determineTimestampFormat } from "@smithy/core/protocols";
|
|
2
2
|
import { NormalizedSchema } from "@smithy/core/schema";
|
|
3
|
-
import { dateToUtcString, generateIdempotencyToken, LazyJsonString, NumericValue } from "@smithy/core/serde";
|
|
4
|
-
import { toBase64 } from "@smithy/util-base64";
|
|
3
|
+
import { dateToUtcString, generateIdempotencyToken, LazyJsonString, NumericValue, toBase64 } from "@smithy/core/serde";
|
|
5
4
|
import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
|
|
6
5
|
export class SinglePassJsonShapeSerializer extends SerdeContextConfig {
|
|
7
6
|
settings;
|
|
@@ -21,7 +21,7 @@ export const parseJsonErrorBody = async (errorBody, context) => {
|
|
|
21
21
|
return value;
|
|
22
22
|
};
|
|
23
23
|
const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
|
|
24
|
-
const sanitizeErrorCode = (rawValue) => {
|
|
24
|
+
const sanitizeErrorCode = (rawValue, removeNamespace = true) => {
|
|
25
25
|
let cleanValue = rawValue;
|
|
26
26
|
if (typeof cleanValue === "number") {
|
|
27
27
|
cleanValue = cleanValue.toString();
|
|
@@ -32,23 +32,38 @@ const sanitizeErrorCode = (rawValue) => {
|
|
|
32
32
|
if (cleanValue.indexOf(":") >= 0) {
|
|
33
33
|
cleanValue = cleanValue.split(":")[0];
|
|
34
34
|
}
|
|
35
|
-
if (cleanValue.indexOf("#") >= 0) {
|
|
35
|
+
if (removeNamespace && cleanValue.indexOf("#") >= 0) {
|
|
36
36
|
cleanValue = cleanValue.split("#")[1];
|
|
37
37
|
}
|
|
38
38
|
return cleanValue;
|
|
39
39
|
};
|
|
40
40
|
export const loadRestJsonErrorCode = (output, data) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
return loadErrorCode(output, data, true, ["header", "code", "type"]);
|
|
42
|
+
};
|
|
43
|
+
export const loadJsonRpcErrorCode = (output, data, removeNamespace, queryCompat = false) => {
|
|
44
|
+
return loadErrorCode(output, data, removeNamespace, queryCompat ? ["code", "header", "type"] : ["type", "code", "header"]);
|
|
45
|
+
};
|
|
46
|
+
const loadErrorCode = ({ headers }, data, removeNamespace, order) => {
|
|
47
|
+
while (order.length > 0) {
|
|
48
|
+
const location = order.shift();
|
|
49
|
+
switch (location) {
|
|
50
|
+
case "header":
|
|
51
|
+
const headerKey = findKey(headers ?? {}, "x-amzn-errortype");
|
|
52
|
+
if (headerKey !== undefined) {
|
|
53
|
+
return sanitizeErrorCode(headers[headerKey], removeNamespace);
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
case "code":
|
|
57
|
+
const codeKey = findKey(data ?? {}, "code");
|
|
58
|
+
if (codeKey && data[codeKey] !== undefined) {
|
|
59
|
+
return sanitizeErrorCode(data[codeKey], removeNamespace);
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
case "type":
|
|
63
|
+
if (data?.__type !== undefined) {
|
|
64
|
+
return sanitizeErrorCode(data.__type, removeNamespace);
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
52
67
|
}
|
|
53
68
|
}
|
|
54
69
|
};
|
|
@@ -95,7 +95,7 @@ export class AwsQueryProtocol extends RpcProtocol {
|
|
|
95
95
|
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, errorData, metadata, this.mixin.findQueryCompatibleError);
|
|
96
96
|
const ns = NormalizedSchema.of(errorSchema);
|
|
97
97
|
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
|
98
|
-
const exception = new ErrorCtor(
|
|
98
|
+
const exception = new ErrorCtor({});
|
|
99
99
|
const output = {
|
|
100
100
|
Type: errorData.Error.Type,
|
|
101
101
|
Code: errorData.Error.Code,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { determineTimestampFormat, extendedEncodeURIComponent } from "@smithy/core/protocols";
|
|
2
2
|
import { NormalizedSchema } from "@smithy/core/schema";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { toBase64 } from "@smithy/util-base64";
|
|
3
|
+
import { dateToUtcString } from "@smithy/core/serde";
|
|
4
|
+
import { generateIdempotencyToken, NumericValue, toBase64 } from "@smithy/core/serde";
|
|
6
5
|
import { SerdeContextConfig } from "../ConfigurableSerdeContext";
|
|
7
6
|
export class QueryShapeSerializer extends SerdeContextConfig {
|
|
8
7
|
settings;
|
|
@@ -71,7 +71,7 @@ export class AwsRestXmlProtocol extends HttpBindingProtocol {
|
|
|
71
71
|
dataObject.Message ??
|
|
72
72
|
"UnknownError";
|
|
73
73
|
const ErrorCtor = this.compositeErrorRegistry.getErrorCtor(errorSchema) ?? Error;
|
|
74
|
-
const exception = new ErrorCtor(
|
|
74
|
+
const exception = new ErrorCtor({});
|
|
75
75
|
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
76
76
|
const output = {};
|
|
77
77
|
const errorDeserializer = this.codec.createDeserializer();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parseXML } from "@aws-sdk/xml-builder";
|
|
2
|
+
import { getValueFromTextNode } from "@smithy/core/client";
|
|
2
3
|
import { FromStringShapeDeserializer } from "@smithy/core/protocols";
|
|
3
4
|
import { NormalizedSchema } from "@smithy/core/schema";
|
|
4
|
-
import {
|
|
5
|
-
import { toUtf8 } from "@smithy/util-utf8";
|
|
5
|
+
import { toUtf8 } from "@smithy/core/serde";
|
|
6
6
|
import { SerdeContextConfig } from "../ConfigurableSerdeContext";
|
|
7
7
|
import { UnionSerde } from "../UnionSerde";
|
|
8
8
|
export class XmlShapeDeserializer extends SerdeContextConfig {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { XmlNode, XmlText } from "@aws-sdk/xml-builder";
|
|
2
2
|
import { determineTimestampFormat } from "@smithy/core/protocols";
|
|
3
3
|
import { NormalizedSchema } from "@smithy/core/schema";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { fromBase64, toBase64 } from "@smithy/util-base64";
|
|
4
|
+
import { dateToUtcString } from "@smithy/core/serde";
|
|
5
|
+
import { fromBase64, generateIdempotencyToken, NumericValue, toBase64 } from "@smithy/core/serde";
|
|
7
6
|
import { SerdeContextConfig } from "../ConfigurableSerdeContext";
|
|
8
7
|
export class XmlShapeSerializer extends SerdeContextConfig {
|
|
9
8
|
settings;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseXML } from "@aws-sdk/xml-builder";
|
|
2
|
-
import { getValueFromTextNode } from "@smithy/
|
|
2
|
+
import { getValueFromTextNode } from "@smithy/core/client";
|
|
3
3
|
import { collectBodyString } from "../common";
|
|
4
4
|
export const parseXmlBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
|
|
5
5
|
if (encoded.length) {
|