@smithy/core 3.37.0 → 3.38.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 (76) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist-cjs/index.js +4 -2
  3. package/dist-cjs/submodules/cbor/index.js +32 -16
  4. package/dist-cjs/submodules/client/index.js +26 -13
  5. package/dist-cjs/submodules/config/index.browser.js +8 -4
  6. package/dist-cjs/submodules/config/index.js +16 -8
  7. package/dist-cjs/submodules/config/index.native.js +8 -4
  8. package/dist-cjs/submodules/endpoints/index.browser.js +2 -1
  9. package/dist-cjs/submodules/endpoints/index.js +10 -5
  10. package/dist-cjs/submodules/event-streams/index.browser.js +18 -9
  11. package/dist-cjs/submodules/event-streams/index.js +18 -9
  12. package/dist-cjs/submodules/protocols/index.js +42 -24
  13. package/dist-cjs/submodules/retry/index.browser.js +20 -10
  14. package/dist-cjs/submodules/retry/index.js +24 -12
  15. package/dist-cjs/submodules/serde/index.browser.js +13 -4
  16. package/dist-cjs/submodules/serde/index.js +7 -1
  17. package/dist-cjs/submodules/serde/index.native.js +13 -4
  18. package/dist-cjs/submodules/transport/index.js +6 -3
  19. package/dist-es/legacy-root-exports/util-identity-and-auth/DefaultIdentityProviderConfig.js +2 -1
  20. package/dist-es/normalizeProvider.js +2 -1
  21. package/dist-es/submodules/cbor/codec-v1/CborShapeDeserializer.js +8 -4
  22. package/dist-es/submodules/cbor/codec-v1/CborShapeSerializer.js +6 -3
  23. package/dist-es/submodules/cbor/codec-v2/CborShapeDeserializer2.js +12 -6
  24. package/dist-es/submodules/cbor/codec-v2/CborShapeSerializer2.js +4 -2
  25. package/dist-es/submodules/cbor/parseCborBody.js +2 -1
  26. package/dist-es/submodules/client/middleware-stack/MiddlewareStack.js +10 -5
  27. package/dist-es/submodules/client/smithy-client/create-aggregated-client.js +2 -1
  28. package/dist-es/submodules/client/smithy-client/exceptions.js +4 -2
  29. package/dist-es/submodules/client/smithy-client/extensions/checksum.js +2 -1
  30. package/dist-es/submodules/client/smithy-client/get-value-from-text-node.js +2 -1
  31. package/dist-es/submodules/client/smithy-client/object-mapping.js +4 -2
  32. package/dist-es/submodules/client/smithy-client/serde-json.js +2 -1
  33. package/dist-es/submodules/config/shared-ini-file-loader/getHomeDir.js +8 -4
  34. package/dist-es/submodules/config/util-config-provider/booleanSelector.js +6 -3
  35. package/dist-es/submodules/config/util-config-provider/numberSelector.js +2 -1
  36. package/dist-es/submodules/endpoints/middleware-endpoint/adaptors/getEndpointUrlConfig.js +8 -4
  37. package/dist-es/submodules/endpoints/util-endpoints/resolveEndpoint.js +2 -1
  38. package/dist-es/submodules/event-streams/EventStreamSerde.js +6 -3
  39. package/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js +2 -1
  40. package/dist-es/submodules/event-streams/eventstream-codec/Int64.js +2 -1
  41. package/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageDecoderStream.js +2 -1
  42. package/dist-es/submodules/event-streams/eventstream-serde/utils.js +2 -1
  43. package/dist-es/submodules/event-streams/eventstream-serde-universal/getUnmarshalledStream.js +4 -2
  44. package/dist-es/submodules/protocols/HttpBindingProtocol.js +8 -4
  45. package/dist-es/submodules/protocols/HttpProtocol.js +4 -2
  46. package/dist-es/submodules/protocols/RpcProtocol.js +2 -1
  47. package/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js +7 -5
  48. package/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js +7 -5
  49. package/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js +7 -5
  50. package/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js +6 -3
  51. package/dist-es/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.js +3 -0
  52. package/dist-es/submodules/retry/middleware-retry/configurations.js +4 -2
  53. package/dist-es/submodules/retry/middleware-retry/parseRetryAfterHeader.js +2 -1
  54. package/dist-es/submodules/retry/middleware-retry/retry-pre-sra-deprecated/StandardRetryStrategy.js +6 -3
  55. package/dist-es/submodules/retry/middleware-retry/retryMiddleware.js +6 -3
  56. package/dist-es/submodules/retry/middleware-retry/util.js +6 -3
  57. package/dist-es/submodules/serde/index.browser.js +1 -0
  58. package/dist-es/submodules/serde/index.js +1 -0
  59. package/dist-es/submodules/serde/index.native.js +1 -0
  60. package/dist-es/submodules/serde/parse-utils.js +2 -1
  61. package/dist-es/submodules/serde/util-body-length/calculateBodyLength.browser.js +6 -3
  62. package/dist-es/submodules/transport/httpResponse.js +2 -1
  63. package/dist-es/submodules/transport/normalizeProvider.js +2 -1
  64. package/dist-es/submodules/transport/toEndpointV1.js +2 -1
  65. package/dist-types/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.d.ts +1 -0
  66. package/dist-types/submodules/serde/index.browser.d.ts +1 -0
  67. package/dist-types/submodules/serde/index.d.ts +1 -0
  68. package/dist-types/submodules/serde/index.native.d.ts +1 -0
  69. package/dist-types/ts3.4/submodules/protocols/protocol-http/extensions/httpExtensionConfiguration.d.ts +1 -0
  70. package/dist-types/ts3.4/submodules/serde/index.browser.d.ts +1 -0
  71. package/dist-types/ts3.4/submodules/serde/index.d.ts +1 -0
  72. package/dist-types/ts3.4/submodules/serde/index.native.d.ts +1 -0
  73. package/package.json +1 -1
  74. /package/dist-es/submodules/{protocols → serde}/writeKey.js +0 -0
  75. /package/dist-types/submodules/{protocols → serde}/writeKey.d.ts +0 -0
  76. /package/dist-types/ts3.4/submodules/{protocols → serde}/writeKey.d.ts +0 -0
@@ -1,9 +1,8 @@
1
1
  import { determineTimestampFormat } from "../../serde/determineTimestampFormat";
2
2
  import { NormalizedSchema } from "@smithy/core/schema";
3
- import { dateToUtcString, generateIdempotencyToken, LazyJsonString, NumericValue, toBase64 } from "@smithy/core/serde";
3
+ import { dateToUtcString, generateIdempotencyToken, LazyJsonString, NumericValue, toBase64, writeKey, } from "@smithy/core/serde";
4
4
  import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
5
5
  import { JsonReplacer } from "../jsonReplacer";
6
- import { writeKey } from "../../writeKey";
7
6
  import { hasOwn } from "@smithy/core/transport";
8
7
  export class JsonShapeSerializer extends SerdeContextConfig {
9
8
  settings;
@@ -74,8 +73,9 @@ export class JsonShapeSerializer extends SerdeContextConfig {
74
73
  }
75
74
  else if (typeof record.__type === "string") {
76
75
  for (const k in record) {
77
- if (!hasOwn(record, k))
76
+ if (!hasOwn(record, k)) {
78
77
  continue;
78
+ }
79
79
  const v = record[k];
80
80
  const targetKey = jsonName ? (nameMap[k] ?? k) : k;
81
81
  if (!(targetKey in out)) {
@@ -101,8 +101,9 @@ export class JsonShapeSerializer extends SerdeContextConfig {
101
101
  const out = {};
102
102
  const sparse = !!ns.getMergedTraits().sparse;
103
103
  for (const _k in value) {
104
- if (!hasOwn(value, _k))
104
+ if (!hasOwn(value, _k)) {
105
105
  continue;
106
+ }
106
107
  const _v = value[_k];
107
108
  if (sparse || _v != null) {
108
109
  if (_k === "__proto__") {
@@ -175,8 +176,9 @@ export class JsonShapeSerializer extends SerdeContextConfig {
175
176
  }
176
177
  const out = Array.isArray(value) ? [] : {};
177
178
  for (const k in value) {
178
- if (!hasOwn(value, k))
179
+ if (!hasOwn(value, k)) {
179
180
  continue;
181
+ }
180
182
  const v = value[k];
181
183
  if (k === "__proto__") {
182
184
  writeKey(out);
@@ -1,13 +1,12 @@
1
1
  import { determineTimestampFormat } from "../../serde/determineTimestampFormat";
2
2
  import { NormalizedSchema } from "@smithy/core/schema";
3
- import { fromBase64, LazyJsonString, NumericValue, parseEpochTimestamp, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, } from "@smithy/core/serde";
3
+ import { fromBase64, LazyJsonString, NumericValue, parseEpochTimestamp, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, writeKey, } from "@smithy/core/serde";
4
4
  import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
5
5
  import { UnionSerde } from "../../UnionSerde";
6
6
  import { detectBufferParsing } from "../detectBufferParsing";
7
7
  import { jsonReviver } from "../jsonReviver";
8
8
  import { needsReviver } from "../needsReviver";
9
9
  import { parseJsonBody } from "../parseJsonBody";
10
- import { writeKey } from "../../writeKey";
11
10
  import { hasOwn } from "@smithy/core/transport";
12
11
  export class JsonShapeDeserializer2 extends SerdeContextConfig {
13
12
  settings;
@@ -60,8 +59,9 @@ export class JsonShapeDeserializer2 extends SerdeContextConfig {
60
59
  const map = value;
61
60
  if (this.needsTransform(mapMember)) {
62
61
  for (const k in map) {
63
- if (!hasOwn(map, k))
62
+ if (!hasOwn(map, k)) {
64
63
  continue;
64
+ }
65
65
  if (k === "__proto__") {
66
66
  writeKey(map);
67
67
  }
@@ -133,8 +133,9 @@ export class JsonShapeDeserializer2 extends SerdeContextConfig {
133
133
  else {
134
134
  const doc = value;
135
135
  for (const k in doc) {
136
- if (!hasOwn(doc, k))
136
+ if (!hasOwn(doc, k)) {
137
137
  continue;
138
+ }
138
139
  if (k === "__proto__") {
139
140
  writeKey(doc);
140
141
  }
@@ -181,8 +182,9 @@ export class JsonShapeDeserializer2 extends SerdeContextConfig {
181
182
  }
182
183
  else if (hasType) {
183
184
  for (const k in record) {
184
- if (!hasOwn(record, k))
185
+ if (!hasOwn(record, k)) {
185
186
  continue;
187
+ }
186
188
  const v = record[k];
187
189
  const t = jsonName ? (nameMap[k] ?? k) : k;
188
190
  if (!(t in out)) {
@@ -417,8 +417,9 @@ export class JsonShapeSerializer2 extends SerdeContextConfig {
417
417
  const out = [];
418
418
  for (let i = 0; i < value.length; ++i) {
419
419
  const v = value[i];
420
- if (v == null && !sparse)
420
+ if (v == null && !sparse) {
421
421
  continue;
422
+ }
422
423
  if (Number.isNaN(v) || v === Infinity || v === -Infinity) {
423
424
  out.push(String(v));
424
425
  }
@@ -458,8 +459,9 @@ export class JsonShapeSerializer2 extends SerdeContextConfig {
458
459
  if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) {
459
460
  let modifications;
460
461
  for (const k in value) {
461
- if (!hasOwn(value, k))
462
+ if (!hasOwn(value, k)) {
462
463
  continue;
464
+ }
463
465
  const v = value[k];
464
466
  if (Number.isNaN(v) || v === Infinity || v === -Infinity) {
465
467
  (modifications ??= {})[k] = v;
@@ -483,8 +485,9 @@ export class JsonShapeSerializer2 extends SerdeContextConfig {
483
485
  this.json[this.i++] = OPEN_BRACE;
484
486
  let first = true;
485
487
  for (const k in value) {
486
- if (!hasOwn(value, k))
488
+ if (!hasOwn(value, k)) {
487
489
  continue;
490
+ }
488
491
  const v = value[k];
489
492
  if (isDocument ? v === undefined : v == null && !sparse) {
490
493
  continue;
@@ -2,6 +2,9 @@ export const getHttpHandlerExtensionConfiguration = (runtimeConfig) => {
2
2
  if (runtimeConfig.logger && runtimeConfig.logger.constructor?.name !== "NoOpLogger") {
3
3
  runtimeConfig.requestHandler?.updateHttpClientConfig?.(Symbol.for("logger"), runtimeConfig.logger);
4
4
  }
5
+ if (runtimeConfig.defaultSocketTimeout) {
6
+ runtimeConfig.requestHandler?.updateHttpClientConfig?.(Symbol.for("@smithy/defaultSocketTimeout"), runtimeConfig.defaultSocketTimeout);
7
+ }
5
8
  return {
6
9
  setHttpHandler(handler) {
7
10
  runtimeConfig.requestHandler = handler;
@@ -8,8 +8,9 @@ export const CONFIG_MAX_ATTEMPTS = "max_attempts";
8
8
  export const NODE_MAX_ATTEMPT_CONFIG_OPTIONS = {
9
9
  environmentVariableSelector: (env) => {
10
10
  const value = env[ENV_MAX_ATTEMPTS];
11
- if (!value)
11
+ if (!value) {
12
12
  return undefined;
13
+ }
13
14
  const maxAttempt = parseInt(value);
14
15
  if (Number.isNaN(maxAttempt)) {
15
16
  throw new Error(`Environment variable ${ENV_MAX_ATTEMPTS} mast be a number, got "${value}"`);
@@ -18,8 +19,9 @@ export const NODE_MAX_ATTEMPT_CONFIG_OPTIONS = {
18
19
  },
19
20
  configFileSelector: (profile) => {
20
21
  const value = profile[CONFIG_MAX_ATTEMPTS];
21
- if (!value)
22
+ if (!value) {
22
23
  return undefined;
24
+ }
23
25
  const maxAttempt = parseInt(value);
24
26
  if (Number.isNaN(maxAttempt)) {
25
27
  throw new Error(`Shared config file entry ${CONFIG_MAX_ATTEMPTS} mast be a number, got "${value}"`);
@@ -6,8 +6,9 @@ export function parseRetryAfterHeader(response, logger) {
6
6
  return;
7
7
  }
8
8
  for (const header in response.headers) {
9
- if (!hasOwn(response.headers, header))
9
+ if (!hasOwn(response.headers, header)) {
10
10
  continue;
11
+ }
11
12
  const h = header.toLowerCase();
12
13
  if (h === "retry-after") {
13
14
  const retryAfter = response.headers[header];
@@ -81,15 +81,18 @@ export class StandardRetryStrategy {
81
81
  }
82
82
  }
83
83
  const getDelayFromRetryAfterHeader = (response) => {
84
- if (!HttpResponse.isInstance(response))
84
+ if (!HttpResponse.isInstance(response)) {
85
85
  return;
86
+ }
86
87
  const retryAfterHeaderName = Object.keys(response.headers).find((key) => key.toLowerCase() === "retry-after");
87
- if (!retryAfterHeaderName)
88
+ if (!retryAfterHeaderName) {
88
89
  return;
90
+ }
89
91
  const retryAfter = response.headers[retryAfterHeaderName];
90
92
  const retryAfterSeconds = Number(retryAfter);
91
- if (!Number.isNaN(retryAfterSeconds))
93
+ if (!Number.isNaN(retryAfterSeconds)) {
92
94
  return Math.min(retryAfterSeconds * 1000, 20_000);
95
+ }
93
96
  const retryAfterDate = new Date(retryAfter);
94
97
  return Math.min(retryAfterDate.getTime() - Date.now(), 20_000);
95
98
  };
@@ -83,12 +83,15 @@ const getRetryErrorInfo = (error, logger) => {
83
83
  return errorInfo;
84
84
  };
85
85
  const getRetryErrorType = (error) => {
86
- if (isThrottlingError(error))
86
+ if (isThrottlingError(error)) {
87
87
  return "THROTTLING";
88
- if (isTransientError(error))
88
+ }
89
+ if (isTransientError(error)) {
89
90
  return "TRANSIENT";
90
- if (isServerError(error))
91
+ }
92
+ if (isServerError(error)) {
91
93
  return "SERVER_ERROR";
94
+ }
92
95
  return "CLIENT_ERROR";
93
96
  };
94
97
  export const retryMiddlewareOptions = {
@@ -1,9 +1,12 @@
1
1
  export const asSdkError = (error) => {
2
- if (error instanceof Error)
2
+ if (error instanceof Error) {
3
3
  return error;
4
- if (error instanceof Object)
4
+ }
5
+ if (error instanceof Object) {
5
6
  return Object.assign(new Error(), error);
6
- if (typeof error === "string")
7
+ }
8
+ if (typeof error === "string") {
7
9
  return new Error(error);
10
+ }
8
11
  return new Error(`AWS SDK error wrapper for ${error}`);
9
12
  };
@@ -42,3 +42,4 @@ const _getRandomValues = (array) => crypto.getRandomValues(array);
42
42
  export const v4 = bindV4(_getRandomValues);
43
43
  export const generateIdempotencyToken = v4;
44
44
  export { hasOwn } from "@smithy/core/transport";
45
+ export { writeKey } from "./writeKey";
@@ -41,3 +41,4 @@ const _getRandomValues = getRandomValues;
41
41
  export const v4 = bindV4(_getRandomValues);
42
42
  export const generateIdempotencyToken = v4;
43
43
  export { hasOwn } from "@smithy/core/transport";
44
+ export { writeKey } from "./writeKey";
@@ -44,3 +44,4 @@ const _getRandomValues = (array) => crypto.getRandomValues(array);
44
44
  export const v4 = bindV4(_getRandomValues);
45
45
  export const generateIdempotencyToken = v4;
46
46
  export { hasOwn } from "@smithy/core/transport";
47
+ export { writeKey } from "./writeKey";
@@ -138,8 +138,9 @@ export const expectUnion = (value) => {
138
138
  const asObject = expectObject(value);
139
139
  const setKeys = [];
140
140
  for (const k in asObject) {
141
- if (!hasOwn(asObject, k))
141
+ if (!hasOwn(asObject, k)) {
142
142
  continue;
143
+ }
143
144
  if (asObject[k] != null) {
144
145
  setKeys.push(k);
145
146
  }
@@ -7,12 +7,15 @@ export const calculateBodyLength = (body) => {
7
7
  let len = body.length;
8
8
  for (let i = len - 1; i >= 0; i--) {
9
9
  const code = body.charCodeAt(i);
10
- if (code > 0x7f && code <= 0x7ff)
10
+ if (code > 0x7f && code <= 0x7ff) {
11
11
  len++;
12
- else if (code > 0x7ff && code <= 0xffff)
12
+ }
13
+ else if (code > 0x7ff && code <= 0xffff) {
13
14
  len += 2;
14
- if (code >= 0xdc00 && code <= 0xdfff)
15
+ }
16
+ if (code >= 0xdc00 && code <= 0xdfff) {
15
17
  i--;
18
+ }
16
19
  }
17
20
  return len;
18
21
  }
@@ -10,8 +10,9 @@ export class HttpResponse {
10
10
  this.body = options.body;
11
11
  }
12
12
  static isInstance(response) {
13
- if (!response)
13
+ if (!response) {
14
14
  return false;
15
+ }
15
16
  const resp = response;
16
17
  return typeof resp.statusCode === "number" && typeof resp.headers === "object";
17
18
  }
@@ -1,6 +1,7 @@
1
1
  export const normalizeProvider = (input) => {
2
- if (typeof input === "function")
2
+ if (typeof input === "function") {
3
3
  return input;
4
+ }
4
5
  const promisified = Promise.resolve(input);
5
6
  return () => promisified;
6
7
  };
@@ -7,8 +7,9 @@ export const toEndpointV1 = (endpoint) => {
7
7
  if (endpoint.headers) {
8
8
  v1Endpoint.headers = {};
9
9
  for (const name in endpoint.headers) {
10
- if (!hasOwn(endpoint.headers, name))
10
+ if (!hasOwn(endpoint.headers, name)) {
11
11
  continue;
12
+ }
12
13
  v1Endpoint.headers[name.toLowerCase()] = endpoint.headers[name].join(", ");
13
14
  }
14
15
  }
@@ -24,6 +24,7 @@ export declare const getHttpHandlerExtensionConfiguration: <HandlerConfig extend
24
24
  logger?: Logger;
25
25
  }>(runtimeConfig: HttpHandlerExtensionConfigType<HandlerConfig> & {
26
26
  logger?: Logger;
27
+ defaultSocketTimeout?: number;
27
28
  }) => {
28
29
  setHttpHandler(handler: HttpHandler<HandlerConfig>): void;
29
30
  httpHandler(): HttpHandler<HandlerConfig>;
@@ -40,3 +40,4 @@ export { streamCollector } from "./util-stream/stream-collector.browser";
40
40
  export declare const v4: () => string;
41
41
  export declare const generateIdempotencyToken: () => string;
42
42
  export { hasOwn } from "@smithy/core/transport";
43
+ export { writeKey } from "./writeKey";
@@ -38,3 +38,4 @@ export { streamCollector } from "./util-stream/stream-collector";
38
38
  export declare const v4: () => string;
39
39
  export declare const generateIdempotencyToken: () => string;
40
40
  export { hasOwn } from "@smithy/core/transport";
41
+ export { writeKey } from "./writeKey";
@@ -38,3 +38,4 @@ export { streamCollector } from "./util-stream/stream-collector.browser";
38
38
  export declare const v4: () => string;
39
39
  export declare const generateIdempotencyToken: () => string;
40
40
  export { hasOwn } from "@smithy/core/transport";
41
+ export { writeKey } from "./writeKey";
@@ -24,6 +24,7 @@ export declare const getHttpHandlerExtensionConfiguration: <HandlerConfig extend
24
24
  logger?: Logger;
25
25
  }>(runtimeConfig: HttpHandlerExtensionConfigType<HandlerConfig> & {
26
26
  logger?: Logger;
27
+ defaultSocketTimeout?: number;
27
28
  }) => {
28
29
  setHttpHandler(handler: HttpHandler<HandlerConfig>): void;
29
30
  httpHandler(): HttpHandler<HandlerConfig>;
@@ -40,3 +40,4 @@ export { streamCollector } from "./util-stream/stream-collector.browser";
40
40
  export declare const v4: () => string;
41
41
  export declare const generateIdempotencyToken: () => string;
42
42
  export { hasOwn } from "@smithy/core/transport";
43
+ export { writeKey } from "./writeKey";
@@ -38,3 +38,4 @@ export { streamCollector } from "./util-stream/stream-collector";
38
38
  export declare const v4: () => string;
39
39
  export declare const generateIdempotencyToken: () => string;
40
40
  export { hasOwn } from "@smithy/core/transport";
41
+ export { writeKey } from "./writeKey";
@@ -38,3 +38,4 @@ export { streamCollector } from "./util-stream/stream-collector.browser";
38
38
  export declare const v4: () => string;
39
39
  export declare const generateIdempotencyToken: () => string;
40
40
  export { hasOwn } from "@smithy/core/transport";
41
+ export { writeKey } from "./writeKey";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.37.0",
3
+ "version": "3.38.0",
4
4
  "homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/core",
5
5
  "license": "Apache-2.0",
6
6
  "author": {