@aws-sdk/core 3.975.2 → 3.976.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.
Files changed (74) hide show
  1. package/dist-cjs/submodules/httpAuthSchemes/index.js +1 -1
  2. package/dist-cjs/submodules/protocols/index.js +8 -8
  3. package/dist-es/submodules/httpAuthSchemes/utils/getDateHeader.js +1 -1
  4. package/dist-es/submodules/protocols/json/JsonShapeDeserializer.js +1 -1
  5. package/dist-es/submodules/protocols/json/JsonShapeSerializer.js +1 -1
  6. package/dist-es/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.js +182 -0
  7. package/dist-es/submodules/protocols/json/experimental/ByteJsonShapeSerializer.js +473 -0
  8. package/dist-es/submodules/protocols/xml/XmlShapeDeserializer.js +2 -2
  9. package/dist-es/submodules/protocols/xml/XmlShapeSerializer.js +4 -4
  10. package/dist-types/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.d.ts +29 -0
  11. package/dist-types/submodules/protocols/json/experimental/ByteJsonShapeSerializer.d.ts +59 -0
  12. package/dist-types/ts3.4/index.d.ts +1 -5
  13. package/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.d.ts +2 -4
  14. package/dist-types/ts3.4/submodules/account-id-endpoint/AccountIdEndpointModeConstants.d.ts +1 -3
  15. package/dist-types/ts3.4/submodules/account-id-endpoint/NodeAccountIdEndpointModeConfigOptions.d.ts +2 -4
  16. package/dist-types/ts3.4/submodules/client/index.browser.d.ts +3 -12
  17. package/dist-types/ts3.4/submodules/client/index.d.ts +4 -16
  18. package/dist-types/ts3.4/submodules/client/index.native.d.ts +3 -12
  19. package/dist-types/ts3.4/submodules/client/longPollMiddleware.d.ts +2 -4
  20. package/dist-types/ts3.4/submodules/client/middleware-host-header/hostHeaderMiddleware.d.ts +5 -9
  21. package/dist-types/ts3.4/submodules/client/middleware-logger/loggerMiddleware.d.ts +3 -6
  22. package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/configuration.d.ts +1 -2
  23. package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.browser.d.ts +1 -3
  24. package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/getRecursionDetectionPlugin.d.ts +1 -3
  25. package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.browser.d.ts +1 -4
  26. package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.d.ts +1 -4
  27. package/dist-types/ts3.4/submodules/client/middleware-recursion-detection/recursionDetectionMiddleware.native.d.ts +1 -4
  28. package/dist-types/ts3.4/submodules/client/middleware-user-agent/check-features.d.ts +2 -6
  29. package/dist-types/ts3.4/submodules/client/middleware-user-agent/configurations.d.ts +1 -1
  30. package/dist-types/ts3.4/submodules/client/middleware-user-agent/user-agent-middleware.d.ts +4 -7
  31. package/dist-types/ts3.4/submodules/client/region-config-resolver/extensions.d.ts +2 -2
  32. package/dist-types/ts3.4/submodules/client/region-config-resolver/stsRegionDefaultResolver.d.ts +1 -1
  33. package/dist-types/ts3.4/submodules/client/setCredentialFeature.d.ts +3 -8
  34. package/dist-types/ts3.4/submodules/client/setFeature.d.ts +1 -1
  35. package/dist-types/ts3.4/submodules/client/setTokenFeature.d.ts +1 -1
  36. package/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/isVirtualHostableS3Bucket.d.ts +1 -1
  37. package/dist-types/ts3.4/submodules/client/util-endpoints/lib/aws/partition.d.ts +1 -1
  38. package/dist-types/ts3.4/submodules/client/util-endpoints/resolveDefaultAwsRegionalEndpointsConfig.d.ts +3 -9
  39. package/dist-types/ts3.4/submodules/client/util-endpoints/types/RuleSetObject.d.ts +1 -5
  40. package/dist-types/ts3.4/submodules/client/util-user-agent-browser/createUserAgentStringParsingProvider.d.ts +1 -3
  41. package/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.d.ts +2 -6
  42. package/dist-types/ts3.4/submodules/client/util-user-agent-browser/defaultUserAgent.native.d.ts +2 -6
  43. package/dist-types/ts3.4/submodules/client/util-user-agent-node/defaultUserAgent.d.ts +2 -6
  44. package/dist-types/ts3.4/submodules/client/util-user-agent-node/nodeAppIdConfigOptions.d.ts +1 -3
  45. package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.d.ts +2 -5
  46. package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.d.ts +4 -6
  47. package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/NODE_AUTH_SCHEME_PREFERENCE_OPTIONS.d.ts +1 -3
  48. package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/index.d.ts +2 -8
  49. package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4AConfig.d.ts +3 -8
  50. package/dist-types/ts3.4/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.d.ts +8 -17
  51. package/dist-types/ts3.4/submodules/httpAuthSchemes/utils/getUpdatedSystemClockOffset.d.ts +1 -1
  52. package/dist-types/ts3.4/submodules/httpAuthSchemes/utils/isClockSkewed.d.ts +1 -4
  53. package/dist-types/ts3.4/submodules/protocols/ProtocolLib.d.ts +6 -19
  54. package/dist-types/ts3.4/submodules/protocols/cbor/AwsSmithyRpcV2CborProtocol.d.ts +2 -2
  55. package/dist-types/ts3.4/submodules/protocols/common.d.ts +1 -1
  56. package/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -5
  57. package/dist-types/ts3.4/submodules/protocols/json/AwsJsonRpcProtocol.d.ts +2 -2
  58. package/dist-types/ts3.4/submodules/protocols/json/AwsRestJsonProtocol.d.ts +3 -3
  59. package/dist-types/ts3.4/submodules/protocols/json/JsonCodec.d.ts +1 -4
  60. package/dist-types/ts3.4/submodules/protocols/json/JsonShapeSerializer.d.ts +1 -5
  61. package/dist-types/ts3.4/submodules/protocols/json/awsExpectUnion.d.ts +1 -3
  62. package/dist-types/ts3.4/submodules/protocols/json/experimental/BufferJsonShapeDeserializer.d.ts +14 -0
  63. package/dist-types/ts3.4/submodules/protocols/json/experimental/ByteJsonShapeSerializer.d.ts +30 -0
  64. package/dist-types/ts3.4/submodules/protocols/json/jsonReviver.d.ts +1 -1
  65. package/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +4 -13
  66. package/dist-types/ts3.4/submodules/protocols/query/AwsQueryProtocol.d.ts +4 -7
  67. package/dist-types/ts3.4/submodules/protocols/query/QueryShapeSerializer.d.ts +1 -1
  68. package/dist-types/ts3.4/submodules/protocols/xml/AwsRestXmlProtocol.d.ts +3 -3
  69. package/dist-types/ts3.4/submodules/protocols/xml/parseXmlBody.d.ts +3 -12
  70. package/dist-types/ts3.4/submodules/util/util-format-url/format-url.d.ts +1 -1
  71. package/package.json +65 -64
  72. package/dist-es/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.js +0 -135
  73. package/dist-types/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.d.ts +0 -27
  74. package/dist-types/ts3.4/submodules/protocols/json/experimental/SinglePassJsonShapeSerializer.d.ts +0 -17
@@ -4,7 +4,7 @@ const { ProviderError } = require("@smithy/core/config");
4
4
  const { setCredentialFeature } = require("@aws-sdk/core/client");
5
5
  const { SignatureV4 } = require("@smithy/signature-v4");
6
6
 
7
- const getDateHeader = (response) => HttpResponse.isInstance(response) ? response.headers?.date ?? response.headers?.Date : undefined;
7
+ const getDateHeader = (response) => HttpResponse.isInstance(response) ? (response.headers?.date ?? response.headers?.Date) : undefined;
8
8
 
9
9
  const getSkewCorrectedDate = (systemClockOffset) => new Date(Date.now() + systemClockOffset);
10
10
 
@@ -414,7 +414,7 @@ class JsonShapeDeserializer extends SerdeContextConfig {
414
414
  else if (typeof record.__type === "string") {
415
415
  for (const k in record) {
416
416
  const v = record[k];
417
- const t = jsonName ? nameMap[k] ?? k : k;
417
+ const t = jsonName ? (nameMap[k] ?? k) : k;
418
418
  if (!(t in out)) {
419
419
  out[t] = v;
420
420
  }
@@ -623,7 +623,7 @@ class JsonShapeSerializer extends SerdeContextConfig {
623
623
  else if (typeof record.__type === "string") {
624
624
  for (const k in record) {
625
625
  const v = record[k];
626
- const targetKey = jsonName ? nameMap[k] ?? k : k;
626
+ const targetKey = jsonName ? (nameMap[k] ?? k) : k;
627
627
  if (!(targetKey in out)) {
628
628
  out[targetKey] = this._write(15, v);
629
629
  }
@@ -1050,8 +1050,8 @@ class XmlShapeDeserializer extends SerdeContextConfig {
1050
1050
  for (const [memberName, memberSchema] of ns.structIterator()) {
1051
1051
  const memberTraits = memberSchema.getMergedTraits();
1052
1052
  const xmlObjectKey = !memberTraits.httpPayload
1053
- ? memberSchema.getMemberTraits().xmlName ?? memberName
1054
- : memberTraits.xmlName ?? memberSchema.getName();
1053
+ ? (memberSchema.getMemberTraits().xmlName ?? memberName)
1054
+ : (memberTraits.xmlName ?? memberSchema.getName());
1055
1055
  if (union) {
1056
1056
  unionSerde.mark(xmlObjectKey);
1057
1057
  }
@@ -1533,8 +1533,8 @@ class XmlShapeSerializer extends SerdeContextConfig {
1533
1533
  writeStruct(ns, value, parentXmlns) {
1534
1534
  const traits = ns.getMergedTraits();
1535
1535
  const name = ns.isMemberSchema() && !traits.httpPayload
1536
- ? ns.getMemberTraits().xmlName ?? ns.getMemberName()
1537
- : traits.xmlName ?? ns.getName();
1536
+ ? (ns.getMemberTraits().xmlName ?? ns.getMemberName())
1537
+ : (traits.xmlName ?? ns.getName());
1538
1538
  if (!name || !ns.isStructSchema()) {
1539
1539
  throw new Error(`@aws-sdk/core/protocols - xml serializer, cannot write struct with empty name or non-struct, schema=${ns.getName(true)}.`);
1540
1540
  }
@@ -1603,10 +1603,10 @@ class XmlShapeSerializer extends SerdeContextConfig {
1603
1603
  }
1604
1604
  else if (listValueSchema.isStructSchema()) {
1605
1605
  const struct = this.writeStruct(listValueSchema, value, xmlns);
1606
- container.addChildNode(struct.withName(flat ? listTraits.xmlName ?? listMember.getMemberName() : listValueTraits.xmlName ?? "member"));
1606
+ container.addChildNode(struct.withName(flat ? (listTraits.xmlName ?? listMember.getMemberName()) : (listValueTraits.xmlName ?? "member")));
1607
1607
  }
1608
1608
  else {
1609
- const listItemNode = XmlNode.of(flat ? listTraits.xmlName ?? listMember.getMemberName() : listValueTraits.xmlName ?? "member");
1609
+ const listItemNode = XmlNode.of(flat ? (listTraits.xmlName ?? listMember.getMemberName()) : (listValueTraits.xmlName ?? "member"));
1610
1610
  this.writeSimpleInto(listValueSchema, value, listItemNode, xmlns);
1611
1611
  container.addChildNode(listItemNode);
1612
1612
  }
@@ -1,2 +1,2 @@
1
1
  import { HttpResponse } from "@smithy/core/protocols";
2
- export const getDateHeader = (response) => HttpResponse.isInstance(response) ? response.headers?.date ?? response.headers?.Date : undefined;
2
+ export const getDateHeader = (response) => HttpResponse.isInstance(response) ? (response.headers?.date ?? response.headers?.Date) : undefined;
@@ -54,7 +54,7 @@ export class JsonShapeDeserializer extends SerdeContextConfig {
54
54
  else if (typeof record.__type === "string") {
55
55
  for (const k in record) {
56
56
  const v = record[k];
57
- const t = jsonName ? nameMap[k] ?? k : k;
57
+ const t = jsonName ? (nameMap[k] ?? k) : k;
58
58
  if (!(t in out)) {
59
59
  out[t] = v;
60
60
  }
@@ -70,7 +70,7 @@ export class JsonShapeSerializer extends SerdeContextConfig {
70
70
  else if (typeof record.__type === "string") {
71
71
  for (const k in record) {
72
72
  const v = record[k];
73
- const targetKey = jsonName ? nameMap[k] ?? k : k;
73
+ const targetKey = jsonName ? (nameMap[k] ?? k) : k;
74
74
  if (!(targetKey in out)) {
75
75
  out[targetKey] = this._write(15, v);
76
76
  }
@@ -0,0 +1,182 @@
1
+ import { determineTimestampFormat } from "@smithy/core/protocols";
2
+ import { NormalizedSchema } from "@smithy/core/schema";
3
+ import { LazyJsonString, NumericValue, parseEpochTimestamp, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, } from "@smithy/core/serde";
4
+ import { fromBase64 } from "@smithy/core/serde";
5
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
6
+ import { UnionSerde } from "../../UnionSerde";
7
+ import { jsonReviver } from "../jsonReviver";
8
+ import { parseJsonBody } from "../parseJsonBody";
9
+ let canParseBuffer;
10
+ function detectBufferParsing() {
11
+ if (canParseBuffer === undefined) {
12
+ try {
13
+ const result = JSON.parse(new Uint8Array([0x7b, 0x7d]));
14
+ canParseBuffer = result !== null && typeof result === "object";
15
+ }
16
+ catch {
17
+ canParseBuffer = false;
18
+ }
19
+ }
20
+ return canParseBuffer;
21
+ }
22
+ export class BufferJsonShapeDeserializer extends SerdeContextConfig {
23
+ settings;
24
+ constructor(settings) {
25
+ super();
26
+ this.settings = settings;
27
+ }
28
+ async read(schema, data) {
29
+ let parsed;
30
+ if (typeof data === "string") {
31
+ parsed = JSON.parse(data, jsonReviver);
32
+ }
33
+ else if (data instanceof Uint8Array && detectBufferParsing()) {
34
+ parsed = JSON.parse(data, jsonReviver);
35
+ }
36
+ else {
37
+ parsed = await parseJsonBody(data, this.serdeContext);
38
+ }
39
+ return this._read(schema, parsed);
40
+ }
41
+ readObject(schema, data) {
42
+ return this._read(schema, data);
43
+ }
44
+ _read(schema, value) {
45
+ const isObject = value !== null && typeof value === "object";
46
+ const ns = NormalizedSchema.of(schema);
47
+ if (isObject) {
48
+ if (ns.isStructSchema()) {
49
+ return this._readStruct(ns, value);
50
+ }
51
+ if (Array.isArray(value) && ns.isListSchema()) {
52
+ const listMember = ns.getValueSchema();
53
+ for (let i = 0; i < value.length; ++i) {
54
+ value[i] = this._read(listMember, value[i]);
55
+ }
56
+ return value;
57
+ }
58
+ if (ns.isMapSchema()) {
59
+ const mapMember = ns.getValueSchema();
60
+ const map = value;
61
+ for (const k in map) {
62
+ map[k] = this._read(mapMember, map[k]);
63
+ }
64
+ return map;
65
+ }
66
+ }
67
+ if (ns.isBlobSchema() && typeof value === "string") {
68
+ return fromBase64(value);
69
+ }
70
+ const mediaType = ns.getMergedTraits().mediaType;
71
+ if (ns.isStringSchema() && typeof value === "string" && mediaType) {
72
+ const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
73
+ if (isJson) {
74
+ return LazyJsonString.from(value);
75
+ }
76
+ return value;
77
+ }
78
+ if (ns.isTimestampSchema() && value != null) {
79
+ const format = determineTimestampFormat(ns, this.settings);
80
+ switch (format) {
81
+ case 5:
82
+ return parseRfc3339DateTimeWithOffset(value);
83
+ case 6:
84
+ return parseRfc7231DateTime(value);
85
+ case 7:
86
+ return parseEpochTimestamp(value);
87
+ default:
88
+ console.warn("Missing timestamp format, parsing value with Date constructor:", value);
89
+ return new Date(value);
90
+ }
91
+ }
92
+ if (ns.isBigIntegerSchema() && (typeof value === "number" || typeof value === "string")) {
93
+ return BigInt(value);
94
+ }
95
+ if (ns.isBigDecimalSchema() && value != undefined) {
96
+ if (value instanceof NumericValue) {
97
+ return value;
98
+ }
99
+ const untyped = value;
100
+ if (untyped.type === "bigDecimal" && "string" in untyped) {
101
+ return new NumericValue(untyped.string, untyped.type);
102
+ }
103
+ return new NumericValue(String(value), "bigDecimal");
104
+ }
105
+ if (ns.isNumericSchema() && typeof value === "string") {
106
+ switch (value) {
107
+ case "Infinity":
108
+ return Infinity;
109
+ case "-Infinity":
110
+ return -Infinity;
111
+ case "NaN":
112
+ return NaN;
113
+ }
114
+ return value;
115
+ }
116
+ if (ns.isDocumentSchema()) {
117
+ if (isObject) {
118
+ if (Array.isArray(value)) {
119
+ for (let i = 0; i < value.length; ++i) {
120
+ const v = value[i];
121
+ if (!(v instanceof NumericValue)) {
122
+ value[i] = this._read(ns, v);
123
+ }
124
+ }
125
+ }
126
+ else {
127
+ const doc = value;
128
+ for (const k in doc) {
129
+ const v = doc[k];
130
+ if (!(v instanceof NumericValue)) {
131
+ doc[k] = this._read(ns, v);
132
+ }
133
+ }
134
+ }
135
+ return value;
136
+ }
137
+ else {
138
+ return value;
139
+ }
140
+ }
141
+ return value;
142
+ }
143
+ _readStruct(ns, record) {
144
+ const union = ns.isUnionSchema();
145
+ const out = {};
146
+ let nameMap = void 0;
147
+ const { jsonName } = this.settings;
148
+ if (jsonName) {
149
+ nameMap = {};
150
+ }
151
+ let unionSerde;
152
+ if (union) {
153
+ unionSerde = new UnionSerde(record, out);
154
+ }
155
+ for (const [memberName, memberSchema] of ns.structIterator()) {
156
+ let fromKey = memberName;
157
+ if (jsonName) {
158
+ fromKey = memberSchema.getMergedTraits().jsonName ?? fromKey;
159
+ nameMap[fromKey] = memberName;
160
+ }
161
+ if (union) {
162
+ unionSerde.mark(fromKey);
163
+ }
164
+ if (record[fromKey] != null) {
165
+ out[memberName] = this._read(memberSchema, record[fromKey]);
166
+ }
167
+ }
168
+ if (union) {
169
+ unionSerde.writeUnknown();
170
+ }
171
+ else if (typeof record.__type === "string") {
172
+ for (const k in record) {
173
+ const v = record[k];
174
+ const t = jsonName ? (nameMap[k] ?? k) : k;
175
+ if (!(t in out)) {
176
+ out[t] = v;
177
+ }
178
+ }
179
+ }
180
+ return out;
181
+ }
182
+ }