@cdk8s/awscdk-resolver 0.0.613 → 0.0.615

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 (192) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js +3710 -15
  4. package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.browser.d.ts +1 -1
  5. package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.d.ts +1 -1
  6. package/node_modules/@aws-sdk/client-cloudformation/dist-types/runtimeConfig.native.d.ts +1 -1
  7. package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.browser.d.ts +7 -1
  8. package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.d.ts +7 -1
  9. package/node_modules/@aws-sdk/client-cloudformation/dist-types/ts3.4/runtimeConfig.native.d.ts +7 -1
  10. package/node_modules/@aws-sdk/client-cloudformation/package.json +8 -8
  11. package/node_modules/@aws-sdk/core/account-id-endpoint.d.ts +1 -3
  12. package/node_modules/@aws-sdk/core/client.d.ts +1 -3
  13. package/node_modules/@aws-sdk/core/httpAuthSchemes.d.ts +1 -3
  14. package/node_modules/@aws-sdk/core/package.json +8 -14
  15. package/node_modules/@aws-sdk/core/protocols.d.ts +1 -3
  16. package/node_modules/@aws-sdk/core/util.d.ts +1 -3
  17. package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
  18. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/index.js +172 -1
  19. package/node_modules/@aws-sdk/credential-provider-http/package.json +8 -10
  20. package/node_modules/@aws-sdk/credential-provider-ini/package.json +13 -13
  21. package/node_modules/@aws-sdk/credential-provider-login/package.json +6 -6
  22. package/node_modules/@aws-sdk/credential-provider-node/package.json +11 -11
  23. package/node_modules/@aws-sdk/credential-provider-process/package.json +5 -5
  24. package/node_modules/@aws-sdk/credential-provider-sso/package.json +7 -7
  25. package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/index.js +58 -3
  26. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +7 -8
  27. package/node_modules/@aws-sdk/nested-clients/cognito-identity.d.ts +1 -3
  28. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  29. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  30. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  31. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  32. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  33. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.browser.d.ts +1 -1
  34. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.d.ts +1 -1
  35. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/cognito-identity/runtimeConfig.native.d.ts +1 -1
  36. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.browser.d.ts +1 -1
  37. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.d.ts +1 -1
  38. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/runtimeConfig.native.d.ts +1 -1
  39. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.browser.d.ts +1 -1
  40. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.d.ts +1 -1
  41. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso/runtimeConfig.native.d.ts +1 -1
  42. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.browser.d.ts +1 -1
  43. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.d.ts +1 -1
  44. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sso-oidc/runtimeConfig.native.d.ts +1 -1
  45. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.browser.d.ts +1 -1
  46. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.d.ts +1 -1
  47. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/sts/runtimeConfig.native.d.ts +1 -1
  48. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.browser.d.ts +7 -1
  49. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.d.ts +7 -1
  50. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/cognito-identity/runtimeConfig.native.d.ts +7 -1
  51. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.browser.d.ts +7 -1
  52. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.d.ts +7 -1
  53. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/runtimeConfig.native.d.ts +7 -1
  54. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.browser.d.ts +7 -1
  55. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.d.ts +7 -1
  56. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso/runtimeConfig.native.d.ts +7 -1
  57. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.browser.d.ts +7 -1
  58. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.d.ts +7 -1
  59. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sso-oidc/runtimeConfig.native.d.ts +7 -1
  60. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.browser.d.ts +7 -1
  61. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.d.ts +7 -1
  62. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/sts/runtimeConfig.native.d.ts +7 -1
  63. package/node_modules/@aws-sdk/nested-clients/package.json +8 -8
  64. package/node_modules/@aws-sdk/nested-clients/signin.d.ts +1 -3
  65. package/node_modules/@aws-sdk/nested-clients/sso-oidc.d.ts +1 -3
  66. package/node_modules/@aws-sdk/nested-clients/sso.d.ts +1 -3
  67. package/node_modules/@aws-sdk/nested-clients/sts.d.ts +1 -3
  68. package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +4 -4
  69. package/node_modules/@aws-sdk/token-providers/package.json +6 -6
  70. package/node_modules/@aws-sdk/types/package.json +2 -2
  71. package/node_modules/@aws-sdk/xml-builder/dist-cjs/index.js +236 -3
  72. package/node_modules/@aws-sdk/xml-builder/package.json +3 -4
  73. package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.browser.js +358 -145
  74. package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.js +462 -142
  75. package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.native.js +358 -145
  76. package/node_modules/@smithy/core/dist-cjs/submodules/config/index.js +108 -63
  77. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.browser.js +11 -8
  78. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +11 -8
  79. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +5 -2
  80. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.browser.js +30 -36
  81. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +54 -110
  82. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.native.js +30 -36
  83. package/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Js.js +30 -0
  84. package/node_modules/@smithy/core/dist-es/submodules/checksum/crc32/Crc32Node.js +24 -0
  85. package/node_modules/@smithy/core/dist-es/submodules/checksum/index.browser.js +7 -1
  86. package/node_modules/@smithy/core/dist-es/submodules/checksum/index.js +7 -1
  87. package/node_modules/@smithy/core/dist-es/submodules/checksum/index.native.js +7 -1
  88. package/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Js.js +92 -0
  89. package/node_modules/@smithy/core/dist-es/submodules/checksum/md5/Md5Node.js +29 -0
  90. package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Js.js +179 -0
  91. package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256Node.js +59 -0
  92. package/node_modules/@smithy/core/dist-es/submodules/checksum/sha256/Sha256WebCrypto.js +71 -0
  93. package/node_modules/@smithy/core/dist-es/submodules/config/config-resolver/regionConfig/config.js +6 -1
  94. package/node_modules/@smithy/core/dist-es/submodules/config/config-resolver/regionConfig/getInstanceMetadataRegion.js +92 -0
  95. package/node_modules/@smithy/core/dist-es/submodules/config/defaults-mode/constants.js +3 -0
  96. package/node_modules/@smithy/core/dist-es/submodules/config/defaults-mode/resolveDefaultsModeConfig.js +3 -56
  97. package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/EventStreamCodec.js +5 -3
  98. package/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/splitMessage.js +7 -6
  99. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +4 -1
  100. package/node_modules/@smithy/core/dist-es/submodules/serde/concatBytes.js +15 -0
  101. package/node_modules/@smithy/core/dist-es/submodules/serde/index.browser.js +2 -0
  102. package/node_modules/@smithy/core/dist-es/submodules/serde/index.js +2 -0
  103. package/node_modules/@smithy/core/dist-es/submodules/serde/index.native.js +2 -0
  104. package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/checksum/ChecksumStream.js +4 -0
  105. package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/headStream.js +2 -1
  106. package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/stream-collector.browser.js +12 -38
  107. package/node_modules/@smithy/core/dist-es/submodules/serde/util-stream/stream-collector.js +18 -33
  108. package/node_modules/@smithy/core/dist-es/submodules/serde/util-utf8/toUint8Array.browser.js +3 -0
  109. package/node_modules/@smithy/core/dist-es/submodules/serde/util-utf8/toUint8Array.js +3 -0
  110. package/node_modules/@smithy/core/dist-types/submodules/checksum/crc32/Crc32Js.d.ts +18 -0
  111. package/node_modules/@smithy/core/dist-types/submodules/checksum/crc32/Crc32Node.d.ts +18 -0
  112. package/node_modules/@smithy/core/dist-types/submodules/checksum/index.browser.d.ts +7 -1
  113. package/node_modules/@smithy/core/dist-types/submodules/checksum/index.d.ts +7 -1
  114. package/node_modules/@smithy/core/dist-types/submodules/checksum/index.native.d.ts +7 -1
  115. package/node_modules/@smithy/core/dist-types/submodules/checksum/md5/Md5Js.d.ts +19 -0
  116. package/node_modules/@smithy/core/dist-types/submodules/checksum/md5/Md5Node.d.ts +17 -0
  117. package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256Js.d.ts +28 -0
  118. package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256Node.d.ts +13 -0
  119. package/node_modules/@smithy/core/dist-types/submodules/checksum/sha256/Sha256WebCrypto.d.ts +22 -0
  120. package/node_modules/@smithy/core/dist-types/submodules/config/config-resolver/regionConfig/getInstanceMetadataRegion.d.ts +7 -0
  121. package/node_modules/@smithy/core/dist-types/submodules/config/defaults-mode/constants.d.ts +12 -0
  122. package/node_modules/@smithy/core/dist-types/submodules/serde/concatBytes.d.ts +6 -0
  123. package/node_modules/@smithy/core/dist-types/submodules/serde/index.browser.d.ts +2 -0
  124. package/node_modules/@smithy/core/dist-types/submodules/serde/index.d.ts +2 -0
  125. package/node_modules/@smithy/core/dist-types/submodules/serde/index.native.d.ts +2 -0
  126. package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/checksum/ChecksumStream.d.ts +9 -0
  127. package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/stream-collector.browser.d.ts +8 -2
  128. package/node_modules/@smithy/core/dist-types/submodules/serde/util-stream/stream-collector.d.ts +4 -1
  129. package/node_modules/@smithy/core/package.json +4 -4
  130. package/node_modules/@smithy/credential-provider-imds/package.json +2 -2
  131. package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +2 -55
  132. package/node_modules/@smithy/fetch-http-handler/dist-es/index.js +2 -2
  133. package/node_modules/@smithy/fetch-http-handler/dist-types/index.d.ts +2 -2
  134. package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
  135. package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +3 -51
  136. package/node_modules/@smithy/node-http-handler/dist-es/index.js +3 -3
  137. package/node_modules/@smithy/node-http-handler/dist-types/index.d.ts +3 -3
  138. package/node_modules/@smithy/node-http-handler/package.json +2 -2
  139. package/node_modules/@smithy/signature-v4/package.json +2 -3
  140. package/package.json +5 -5
  141. package/node_modules/@aws-crypto/crc32/CHANGELOG.md +0 -100
  142. package/node_modules/@aws-crypto/crc32/LICENSE +0 -201
  143. package/node_modules/@aws-crypto/crc32/README.md +0 -16
  144. package/node_modules/@aws-crypto/crc32/build/main/aws_crc32.d.ts +0 -7
  145. package/node_modules/@aws-crypto/crc32/build/main/aws_crc32.js +0 -31
  146. package/node_modules/@aws-crypto/crc32/build/main/aws_crc32.js.map +0 -1
  147. package/node_modules/@aws-crypto/crc32/build/main/index.d.ts +0 -7
  148. package/node_modules/@aws-crypto/crc32/build/main/index.js +0 -108
  149. package/node_modules/@aws-crypto/crc32/build/main/index.js.map +0 -1
  150. package/node_modules/@aws-crypto/crc32/build/module/aws_crc32.d.ts +0 -7
  151. package/node_modules/@aws-crypto/crc32/build/module/aws_crc32.js +0 -28
  152. package/node_modules/@aws-crypto/crc32/build/module/aws_crc32.js.map +0 -1
  153. package/node_modules/@aws-crypto/crc32/build/module/index.d.ts +0 -7
  154. package/node_modules/@aws-crypto/crc32/build/module/index.js +0 -103
  155. package/node_modules/@aws-crypto/crc32/build/module/index.js.map +0 -1
  156. package/node_modules/@aws-crypto/crc32/package.json +0 -32
  157. package/node_modules/@aws-crypto/crc32/src/aws_crc32.ts +0 -24
  158. package/node_modules/@aws-crypto/crc32/src/index.ts +0 -92
  159. package/node_modules/@aws-crypto/crc32/tsconfig.json +0 -9
  160. package/node_modules/@aws-crypto/crc32/tsconfig.module.json +0 -7
  161. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/auth/httpAuthSchemeProvider.js +0 -40
  162. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/endpoint/bdd.js +0 -49
  163. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/endpoint/endpointResolver.js +0 -14
  164. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/models/CloudFormationServiceException.js +0 -8
  165. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/models/errors.js +0 -407
  166. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.browser.js +0 -32
  167. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.js +0 -45
  168. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.native.js +0 -12
  169. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/runtimeConfig.shared.js +0 -39
  170. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/schemas/schemas_0.js +0 -3022
  171. package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.browser.js +0 -869
  172. package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.native.js +0 -862
  173. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/checkUrl.js +0 -42
  174. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.browser.js +0 -27
  175. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.js +0 -71
  176. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/requestHelpers.js +0 -49
  177. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/retry-wrapper.js +0 -13
  178. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/index.browser.js +0 -2
  179. package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/fromTokenFile.js +0 -29
  180. package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/fromWebToken.js +0 -25
  181. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.browser.js +0 -57
  182. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.js +0 -234
  183. package/node_modules/@smithy/core/dist-es/submodules/checksum/md5-js/constants.js +0 -3
  184. package/node_modules/@smithy/core/dist-es/submodules/checksum/md5-js/md5.js +0 -168
  185. package/node_modules/@smithy/core/dist-types/submodules/checksum/md5-js/constants.d.ts +0 -12
  186. package/node_modules/@smithy/core/dist-types/submodules/checksum/md5-js/md5.d.ts +0 -16
  187. package/node_modules/@smithy/fetch-http-handler/dist-es/stream-collector.js +0 -53
  188. package/node_modules/@smithy/fetch-http-handler/dist-types/stream-collector.d.ts +0 -2
  189. package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/collector.js +0 -8
  190. package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/index.js +0 -41
  191. package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/collector.d.ts +0 -5
  192. package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/index.d.ts +0 -7
@@ -0,0 +1,92 @@
1
+ import { ENV_IMDS_DISABLED, IMDS_REGION_PATH, IMDS_TOKEN_PATH, X_AWS_EC2_METADATA_TOKEN, X_AWS_EC2_METADATA_TOKEN_TTL, } from "../../defaults-mode/constants";
2
+ const TIMEOUT_MS = 1000;
3
+ const NEG_CACHE_TTL_MS = 60_000;
4
+ let negativeCacheUntil = 0;
5
+ export const getInstanceMetadataRegion = async () => {
6
+ if (process.env[ENV_IMDS_DISABLED]) {
7
+ return undefined;
8
+ }
9
+ if (Date.now() < negativeCacheUntil) {
10
+ return undefined;
11
+ }
12
+ try {
13
+ const endpoint = resolveImdsEndpoint();
14
+ const token = (await imdsRequest({
15
+ ...endpoint,
16
+ path: IMDS_TOKEN_PATH,
17
+ method: "PUT",
18
+ headers: {
19
+ [X_AWS_EC2_METADATA_TOKEN_TTL]: "21600",
20
+ },
21
+ })).toString();
22
+ const region = (await imdsRequest({
23
+ ...endpoint,
24
+ path: IMDS_REGION_PATH,
25
+ method: "GET",
26
+ headers: {
27
+ [X_AWS_EC2_METADATA_TOKEN]: token,
28
+ },
29
+ }))
30
+ .toString()
31
+ .trim();
32
+ return region || cacheNegativeAndReturnUndefined();
33
+ }
34
+ catch {
35
+ return cacheNegativeAndReturnUndefined();
36
+ }
37
+ };
38
+ const cacheNegativeAndReturnUndefined = () => {
39
+ negativeCacheUntil = Date.now() + NEG_CACHE_TTL_MS;
40
+ return undefined;
41
+ };
42
+ const resolveImdsEndpoint = () => {
43
+ const envEndpoint = process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT;
44
+ if (envEndpoint) {
45
+ const url = new URL(envEndpoint);
46
+ return {
47
+ hostname: url.hostname.replace(/^\[(.+)]$/, "$1"),
48
+ port: url.port ? Number(url.port) : undefined,
49
+ };
50
+ }
51
+ if (process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE === "IPv6") {
52
+ return { hostname: "fd00:ec2::254" };
53
+ }
54
+ return { hostname: "169.254.169.254" };
55
+ };
56
+ const imdsRequest = async (options) => {
57
+ const { request } = await import("node:http");
58
+ return new Promise((resolve, reject) => {
59
+ const req = request({
60
+ hostname: options.hostname,
61
+ port: options.port,
62
+ path: options.path,
63
+ method: options.method,
64
+ headers: options.headers,
65
+ timeout: TIMEOUT_MS,
66
+ signal: AbortSignal.timeout(TIMEOUT_MS),
67
+ });
68
+ req.on("error", (err) => {
69
+ reject(err);
70
+ req.destroy();
71
+ });
72
+ req.on("timeout", () => {
73
+ reject(new Error("TimeoutError from instance metadata service"));
74
+ req.destroy();
75
+ });
76
+ req.on("response", (res) => {
77
+ const { statusCode = 400 } = res;
78
+ if (statusCode < 200 || statusCode >= 300) {
79
+ reject(Object.assign(new Error("Error response received from instance metadata service"), { statusCode }));
80
+ req.destroy();
81
+ return;
82
+ }
83
+ const chunks = [];
84
+ res.on("data", (chunk) => chunks.push(chunk));
85
+ res.on("end", () => {
86
+ resolve(Buffer.concat(chunks));
87
+ req.destroy();
88
+ });
89
+ });
90
+ req.end();
91
+ });
92
+ };
@@ -4,3 +4,6 @@ export const AWS_DEFAULT_REGION_ENV = "AWS_DEFAULT_REGION";
4
4
  export const ENV_IMDS_DISABLED = "AWS_EC2_METADATA_DISABLED";
5
5
  export const DEFAULTS_MODE_OPTIONS = ["in-region", "cross-region", "mobile", "standard", "legacy"];
6
6
  export const IMDS_REGION_PATH = "/latest/meta-data/placement/region";
7
+ export const IMDS_TOKEN_PATH = "/latest/api/token";
8
+ export const X_AWS_EC2_METADATA_TOKEN = "x-aws-ec2-metadata-token";
9
+ export const X_AWS_EC2_METADATA_TOKEN_TTL = "x-aws-ec2-metadata-token-ttl-seconds";
@@ -1,7 +1,8 @@
1
1
  import { NODE_REGION_CONFIG_OPTIONS } from "../config-resolver/regionConfig/config";
2
+ import { getInstanceMetadataRegion } from "../config-resolver/regionConfig/getInstanceMetadataRegion";
2
3
  import { loadConfig } from "../node-config-provider/configLoader";
3
4
  import { memoize } from "../property-provider/memoize";
4
- import { AWS_DEFAULT_REGION_ENV, AWS_EXECUTION_ENV, AWS_REGION_ENV, DEFAULTS_MODE_OPTIONS, ENV_IMDS_DISABLED, IMDS_REGION_PATH, } from "./constants";
5
+ import { AWS_DEFAULT_REGION_ENV, AWS_EXECUTION_ENV, AWS_REGION_ENV, DEFAULTS_MODE_OPTIONS } from "./constants";
5
6
  import { NODE_DEFAULTS_MODE_CONFIG_OPTIONS } from "./defaultsModeConfig";
6
7
  export const resolveDefaultsModeConfig = ({ region = loadConfig(NODE_REGION_CONFIG_OPTIONS), defaultsMode = loadConfig(NODE_DEFAULTS_MODE_CONFIG_OPTIONS), } = {}) => memoize(async () => {
7
8
  const mode = typeof defaultsMode === "function" ? await defaultsMode() : defaultsMode;
@@ -40,59 +41,5 @@ const inferPhysicalRegion = async () => {
40
41
  if (process.env[AWS_EXECUTION_ENV] && (process.env[AWS_REGION_ENV] || process.env[AWS_DEFAULT_REGION_ENV])) {
41
42
  return process.env[AWS_REGION_ENV] ?? process.env[AWS_DEFAULT_REGION_ENV];
42
43
  }
43
- if (!process.env[ENV_IMDS_DISABLED]) {
44
- try {
45
- const endpoint = await getImdsEndpoint();
46
- return (await imdsHttpGet({ hostname: endpoint.hostname, path: IMDS_REGION_PATH })).toString();
47
- }
48
- catch (e) {
49
- }
50
- }
51
- };
52
- const getImdsEndpoint = async () => {
53
- const envEndpoint = process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT;
54
- if (envEndpoint) {
55
- const url = new URL(envEndpoint);
56
- return { hostname: url.hostname, path: url.pathname };
57
- }
58
- const envMode = process.env.AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE;
59
- if (envMode === "IPv6") {
60
- return { hostname: "fd00:ec2::254", path: "/" };
61
- }
62
- return { hostname: "169.254.169.254", path: "/" };
63
- };
64
- const imdsHttpGet = async ({ hostname, path }) => {
65
- const { request } = await import("node:http");
66
- return new Promise((resolve, reject) => {
67
- const req = request({
68
- method: "GET",
69
- hostname: hostname.replace(/^\[(.+)]$/, "$1"),
70
- path,
71
- timeout: 1000,
72
- signal: AbortSignal.timeout(1000),
73
- });
74
- req.on("error", (err) => {
75
- reject(err);
76
- req.destroy();
77
- });
78
- req.on("timeout", () => {
79
- reject(new Error("TimeoutError from instance metadata service"));
80
- req.destroy();
81
- });
82
- req.on("response", (res) => {
83
- const { statusCode = 400 } = res;
84
- if (statusCode < 200 || 300 <= statusCode) {
85
- reject(Object.assign(new Error("Error response received from instance metadata service"), { statusCode }));
86
- req.destroy();
87
- return;
88
- }
89
- const chunks = [];
90
- res.on("data", (chunk) => chunks.push(chunk));
91
- res.on("end", () => {
92
- resolve(Buffer.concat(chunks));
93
- req.destroy();
94
- });
95
- });
96
- req.end();
97
- });
44
+ return getInstanceMetadataRegion();
98
45
  };
@@ -1,4 +1,4 @@
1
- import { Crc32 } from "@aws-crypto/crc32";
1
+ import { Crc32 } from "@smithy/core/checksum";
2
2
  import { HeaderMarshaller } from "./HeaderMarshaller";
3
3
  import { splitMessage } from "./splitMessage";
4
4
  export class EventStreamCodec {
@@ -49,10 +49,12 @@ export class EventStreamCodec {
49
49
  const checksum = new Crc32();
50
50
  view.setUint32(0, length, false);
51
51
  view.setUint32(4, headers.byteLength, false);
52
- view.setUint32(8, checksum.update(out.subarray(0, 8)).digest(), false);
52
+ checksum.update(out.subarray(0, 8));
53
+ view.setUint32(8, checksum.digestSync(), false);
53
54
  out.set(headers, 12);
54
55
  out.set(body, headers.byteLength + 12);
55
- view.setUint32(length - 4, checksum.update(out.subarray(8, length - 4)).digest(), false);
56
+ checksum.update(out.subarray(8, length - 4));
57
+ view.setUint32(length - 4, checksum.digestSync(), false);
56
58
  return out;
57
59
  }
58
60
  decode(message) {
@@ -1,4 +1,4 @@
1
- import { Crc32 } from "@aws-crypto/crc32";
1
+ import { Crc32 } from "@smithy/core/checksum";
2
2
  const PRELUDE_MEMBER_LENGTH = 4;
3
3
  const PRELUDE_LENGTH = PRELUDE_MEMBER_LENGTH * 2;
4
4
  const CHECKSUM_LENGTH = 4;
@@ -15,13 +15,14 @@ export function splitMessage({ byteLength, byteOffset, buffer }) {
15
15
  const headerLength = view.getUint32(PRELUDE_MEMBER_LENGTH, false);
16
16
  const expectedPreludeChecksum = view.getUint32(PRELUDE_LENGTH, false);
17
17
  const expectedMessageChecksum = view.getUint32(byteLength - CHECKSUM_LENGTH, false);
18
- const checksummer = new Crc32().update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));
19
- if (expectedPreludeChecksum !== checksummer.digest()) {
20
- throw new Error(`The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digest()})`);
18
+ const checksummer = new Crc32();
19
+ checksummer.update(new Uint8Array(buffer, byteOffset, PRELUDE_LENGTH));
20
+ if (expectedPreludeChecksum !== checksummer.digestSync()) {
21
+ throw new Error(`The prelude checksum specified in the message (${expectedPreludeChecksum}) does not match the calculated CRC32 checksum (${checksummer.digestSync()})`);
21
22
  }
22
23
  checksummer.update(new Uint8Array(buffer, byteOffset + PRELUDE_LENGTH, byteLength - (PRELUDE_LENGTH + CHECKSUM_LENGTH)));
23
- if (expectedMessageChecksum !== checksummer.digest()) {
24
- throw new Error(`The message checksum (${checksummer.digest()}) did not match the expected value of ${expectedMessageChecksum}`);
24
+ if (expectedMessageChecksum !== checksummer.digestSync()) {
25
+ throw new Error(`The message checksum (${checksummer.digestSync()}) did not match the expected value of ${expectedMessageChecksum}`);
25
26
  }
26
27
  return {
27
28
  headers: new DataView(buffer, byteOffset + PRELUDE_LENGTH + CHECKSUM_LENGTH, headerLength),
@@ -1,5 +1,5 @@
1
1
  import { NormalizedSchema, TypeRegistry, translateTraits } from "@smithy/core/schema";
2
- import { HttpRequest, HttpResponse } from "@smithy/core/transport";
2
+ import { HttpRequest, HttpResponse, isValidHostname } from "@smithy/core/transport";
3
3
  import { SerdeContext } from "./SerdeContext";
4
4
  export class HttpProtocol extends SerdeContext {
5
5
  options;
@@ -84,6 +84,9 @@ export class HttpProtocol extends SerdeContext {
84
84
  hostPrefix = hostPrefix.replace(`{${name}}`, replacement);
85
85
  }
86
86
  request.hostname = hostPrefix + request.hostname;
87
+ if (!isValidHostname(request.hostname)) {
88
+ throw new Error(`[${request.hostname}] is not a valid hostname.`);
89
+ }
87
90
  }
88
91
  }
89
92
  }
@@ -0,0 +1,15 @@
1
+ export function concatBytes(arrays, length) {
2
+ if (length === undefined) {
3
+ length = 0;
4
+ for (const bytes of arrays) {
5
+ length += bytes.byteLength;
6
+ }
7
+ }
8
+ const result = new Uint8Array(length);
9
+ let offset = 0;
10
+ for (const buf of arrays) {
11
+ result.set(buf, offset);
12
+ offset += buf.byteLength;
13
+ }
14
+ return result;
15
+ }
@@ -19,6 +19,7 @@ export { toBase64, fromBase64 };
19
19
  export { calculateBodyLength } from "./util-body-length/calculateBodyLength.browser";
20
20
  export { toUint8Array } from "./util-utf8/toUint8Array.browser";
21
21
  export { toUtf8, fromUtf8 };
22
+ export { concatBytes } from "./concatBytes";
22
23
  export const fromArrayBuffer = no;
23
24
  export const fromString = no;
24
25
  export { isArrayBuffer } from "./is-array-buffer/is-array-buffer";
@@ -36,6 +37,7 @@ export { headStream } from "./util-stream/headStream.browser";
36
37
  export { sdkStreamMixin } from "./util-stream/sdk-stream-mixin.browser";
37
38
  export { splitStream } from "./util-stream/splitStream.browser";
38
39
  export { isReadableStream, isBlob } from "./util-stream/stream-type-check";
40
+ export { streamCollector } from "./util-stream/stream-collector.browser";
39
41
  const _getRandomValues = (array) => crypto.getRandomValues(array);
40
42
  export const v4 = bindV4(_getRandomValues);
41
43
  export const generateIdempotencyToken = v4;
@@ -19,6 +19,7 @@ export { toBase64, fromBase64 };
19
19
  export { calculateBodyLength } from "./util-body-length/calculateBodyLength";
20
20
  export { toUint8Array } from "./util-utf8/toUint8Array";
21
21
  export { toUtf8, fromUtf8 };
22
+ export { concatBytes } from "./concatBytes";
22
23
  export { fromArrayBuffer, fromString } from "./util-buffer-from/buffer-from";
23
24
  export { isArrayBuffer } from "./is-array-buffer/is-array-buffer";
24
25
  export { deserializerMiddleware } from "./middleware-serde/deserializerMiddleware";
@@ -35,6 +36,7 @@ export { headStream } from "./util-stream/headStream";
35
36
  export { sdkStreamMixin } from "./util-stream/sdk-stream-mixin";
36
37
  export { splitStream } from "./util-stream/splitStream";
37
38
  export { isReadableStream, isBlob } from "./util-stream/stream-type-check";
39
+ export { streamCollector } from "./util-stream/stream-collector";
38
40
  const _getRandomValues = getRandomValues;
39
41
  export const v4 = bindV4(_getRandomValues);
40
42
  export const generateIdempotencyToken = v4;
@@ -21,6 +21,7 @@ export { calculateBodyLength } from "./util-body-length/calculateBodyLength.brow
21
21
  export { fromUtf8 } from "./util-utf8/fromUtf8.browser";
22
22
  export { toUint8Array } from "./util-utf8/toUint8Array.browser";
23
23
  export { toUtf8 } from "./util-utf8/toUtf8.browser";
24
+ export { concatBytes } from "./concatBytes";
24
25
  export const fromArrayBuffer = no;
25
26
  export const fromString = no;
26
27
  export { isArrayBuffer } from "./is-array-buffer/is-array-buffer";
@@ -38,6 +39,7 @@ export { headStream } from "./util-stream/headStream.browser";
38
39
  export { sdkStreamMixin } from "./util-stream/sdk-stream-mixin.browser";
39
40
  export { splitStream } from "./util-stream/splitStream.browser";
40
41
  export { isReadableStream, isBlob } from "./util-stream/stream-type-check";
42
+ export { streamCollector } from "./util-stream/stream-collector.browser";
41
43
  const _getRandomValues = (array) => crypto.getRandomValues(array);
42
44
  export const v4 = bindV4(_getRandomValues);
43
45
  export const generateIdempotencyToken = v4;
@@ -57,4 +57,8 @@ export class ChecksumStream extends Duplex {
57
57
  this.push(null);
58
58
  return callback();
59
59
  }
60
+ _destroy(error, callback) {
61
+ this.source?.destroy();
62
+ callback(error);
63
+ }
60
64
  }
@@ -1,4 +1,5 @@
1
1
  import { Writable } from "node:stream";
2
+ import { concatBytes } from "../concatBytes";
2
3
  import { headStream as headWebStream } from "./headStream.browser";
3
4
  import { isReadableStream } from "./stream-type-check";
4
5
  export const headStream = (stream, bytes) => {
@@ -15,7 +16,7 @@ export const headStream = (stream, bytes) => {
15
16
  });
16
17
  collector.on("error", reject);
17
18
  collector.on("finish", function () {
18
- const bytes = new Uint8Array(Buffer.concat(this.buffers));
19
+ const bytes = concatBytes(this.buffers);
19
20
  resolve(bytes);
20
21
  });
21
22
  });
@@ -1,53 +1,27 @@
1
- import { fromBase64 } from "../util-base64/fromBase64.browser";
1
+ import { concatBytes } from "../concatBytes";
2
+ import { isBlob } from "./stream-type-check";
2
3
  export const streamCollector = async (stream) => {
3
- if ((typeof Blob === "function" && stream instanceof Blob) || stream.constructor?.name === "Blob") {
4
- if (Blob.prototype.arrayBuffer !== undefined) {
5
- return new Uint8Array(await stream.arrayBuffer());
6
- }
4
+ if (isBlob(stream)) {
7
5
  return collectBlob(stream);
8
6
  }
9
- return collectStream(stream);
7
+ return collectReadableStream(stream);
10
8
  };
11
- async function collectBlob(blob) {
12
- const base64 = await readToBase64(blob);
13
- const arrayBuffer = fromBase64(base64);
14
- return new Uint8Array(arrayBuffer);
9
+ export async function collectBlob(blob) {
10
+ return blob.arrayBuffer().then((ab) => new Uint8Array(ab));
15
11
  }
16
- async function collectStream(stream) {
12
+ export async function collectReadableStream(stream) {
17
13
  const chunks = [];
18
14
  const reader = stream.getReader();
19
- let isDone = false;
20
15
  let length = 0;
21
- while (!isDone) {
16
+ while (true) {
22
17
  const { done, value } = await reader.read();
23
18
  if (value) {
24
19
  chunks.push(value);
25
20
  length += value.length;
26
21
  }
27
- isDone = done;
28
- }
29
- const collected = new Uint8Array(length);
30
- let offset = 0;
31
- for (const chunk of chunks) {
32
- collected.set(chunk, offset);
33
- offset += chunk.length;
22
+ if (done) {
23
+ break;
24
+ }
34
25
  }
35
- return collected;
36
- }
37
- function readToBase64(blob) {
38
- return new Promise((resolve, reject) => {
39
- const reader = new FileReader();
40
- reader.onloadend = () => {
41
- if (reader.readyState !== 2) {
42
- return reject(new Error("Reader aborted too early"));
43
- }
44
- const result = (reader.result ?? "");
45
- const commaIndex = result.indexOf(",");
46
- const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
47
- resolve(result.substring(dataOffset));
48
- };
49
- reader.onabort = () => reject(new Error("Read aborted"));
50
- reader.onerror = () => reject(reader.error);
51
- reader.readAsDataURL(blob);
52
- });
26
+ return concatBytes(chunks, length);
53
27
  }
@@ -1,48 +1,33 @@
1
1
  import { Writable } from "node:stream";
2
- class Collector extends Writable {
3
- bufferedBytes = [];
4
- _write(chunk, encoding, callback) {
5
- this.bufferedBytes.push(chunk);
6
- callback();
7
- }
8
- }
9
- const isReadableStreamInstance = (stream) => typeof ReadableStream === "function" && stream instanceof ReadableStream;
10
- async function collectReadableStream(stream) {
11
- const chunks = [];
12
- const reader = stream.getReader();
13
- let isDone = false;
14
- let length = 0;
15
- while (!isDone) {
16
- const { done, value } = await reader.read();
17
- if (value) {
18
- chunks.push(value);
19
- length += value.length;
20
- }
21
- isDone = done;
22
- }
23
- const collected = new Uint8Array(length);
24
- let offset = 0;
25
- for (const chunk of chunks) {
26
- collected.set(chunk, offset);
27
- offset += chunk.length;
28
- }
29
- return collected;
30
- }
2
+ import { concatBytes } from "../concatBytes";
3
+ import { collectBlob, collectReadableStream } from "./stream-collector.browser";
4
+ import { isBlob, isReadableStream } from "./stream-type-check";
31
5
  export const streamCollector = (stream) => {
32
- if (isReadableStreamInstance(stream)) {
6
+ if (isBlob(stream)) {
7
+ return collectBlob(stream);
8
+ }
9
+ if (isReadableStream(stream)) {
33
10
  return collectReadableStream(stream);
34
11
  }
35
12
  return new Promise((resolve, reject) => {
36
13
  const collector = new Collector();
37
- stream.pipe(collector);
38
- stream.on("error", (err) => {
14
+ const nodeStream = stream;
15
+ nodeStream.pipe(collector);
16
+ nodeStream.on("error", (err) => {
39
17
  collector.end();
40
18
  reject(err);
41
19
  });
42
20
  collector.on("error", reject);
43
21
  collector.on("finish", function () {
44
- const bytes = new Uint8Array(Buffer.concat(this.bufferedBytes));
22
+ const bytes = concatBytes(this.bufferedBytes);
45
23
  resolve(bytes);
46
24
  });
47
25
  });
48
26
  };
27
+ class Collector extends Writable {
28
+ bufferedBytes = [];
29
+ _write(chunk, encoding, callback) {
30
+ this.bufferedBytes.push(chunk);
31
+ callback();
32
+ }
33
+ }
@@ -1,5 +1,8 @@
1
1
  import { fromUtf8 } from "./fromUtf8.browser";
2
2
  export const toUint8Array = (data) => {
3
+ if (data instanceof Uint8Array) {
4
+ return data;
5
+ }
3
6
  if (typeof data === "string") {
4
7
  return fromUtf8(data);
5
8
  }
@@ -1,5 +1,8 @@
1
1
  import { fromUtf8 } from "./fromUtf8";
2
2
  export const toUint8Array = (data) => {
3
+ if (data instanceof Uint8Array) {
4
+ return data;
5
+ }
3
6
  if (typeof data === "string") {
4
7
  return fromUtf8(data);
5
8
  }
@@ -0,0 +1,18 @@
1
+ import type { Checksum } from "@smithy/types";
2
+ /**
3
+ * Pure JS CRC-32 implementation using the IEEE 802.3 polynomial.
4
+ * @see https://www.w3.org/TR/png/#D-CRCAppendix
5
+ * @public
6
+ */
7
+ export declare class Crc32Js implements Checksum {
8
+ readonly digestLength = 4;
9
+ private checksum;
10
+ update(data: Uint8Array): void;
11
+ /**
12
+ * Used by EventStreamCodec.
13
+ * @internal
14
+ */
15
+ digestSync(): number;
16
+ digest(): Promise<Uint8Array>;
17
+ reset(): void;
18
+ }
@@ -0,0 +1,18 @@
1
+ import type { Checksum } from "@smithy/types";
2
+ /**
3
+ * CRC-32 using Node.js zlib native implementation when available,
4
+ * falling back to the pure JS implementation.
5
+ * @public
6
+ */
7
+ export interface Crc32Node extends Checksum {
8
+ readonly digestLength: 4;
9
+ /**
10
+ * Used by EventStreamCodec.
11
+ * @internal
12
+ */
13
+ digestSync(): number;
14
+ }
15
+ /**
16
+ * @public
17
+ */
18
+ export declare const Crc32Node: new () => Crc32Node;
@@ -1,5 +1,11 @@
1
1
  export { blobHasher } from "./hash-blob-browser/blobHasher";
2
2
  export declare const fileStreamHasher: symbol;
3
3
  export declare const readableStreamHasher: symbol;
4
- export { Md5 } from "./md5-js/md5";
4
+ export { Md5Js, Md5Js as Md5 } from "./md5/Md5Js";
5
+ export declare const Md5Node: symbol;
6
+ export { Crc32Js, Crc32Js as Crc32 } from "./crc32/Crc32Js";
7
+ export declare const Crc32Node: symbol;
8
+ export { Sha256Js } from "./sha256/Sha256Js";
9
+ export { Sha256WebCrypto, Sha256WebCrypto as Sha256 } from "./sha256/Sha256WebCrypto";
10
+ export declare const Sha256Node: symbol;
5
11
  export { blobReader } from "./chunked-blob-reader/chunked-blob-reader";
@@ -1,5 +1,11 @@
1
1
  export { blobHasher } from "./hash-blob-browser/blobHasher";
2
2
  export { fileStreamHasher } from "./hash-stream-node/fileStreamHasher";
3
3
  export { readableStreamHasher } from "./hash-stream-node/readableStreamHasher";
4
- export { Md5 } from "./md5-js/md5";
4
+ export { Md5Js } from "./md5/Md5Js";
5
+ export { Md5Node, Md5Node as Md5 } from "./md5/Md5Node";
6
+ export { Crc32Js } from "./crc32/Crc32Js";
7
+ export { Crc32Node, Crc32Node as Crc32 } from "./crc32/Crc32Node";
8
+ export { Sha256Js } from "./sha256/Sha256Js";
9
+ export { Sha256Node, Sha256Node as Sha256 } from "./sha256/Sha256Node";
10
+ export { Sha256WebCrypto } from "./sha256/Sha256WebCrypto";
5
11
  export { blobReader } from "./chunked-blob-reader/chunked-blob-reader";
@@ -1,5 +1,11 @@
1
1
  export { blobHasher } from "./hash-blob-browser/blobHasher";
2
2
  export declare const fileStreamHasher: symbol;
3
3
  export declare const readableStreamHasher: symbol;
4
- export { Md5 } from "./md5-js/md5";
4
+ export { Md5Js, Md5Js as Md5 } from "./md5/Md5Js";
5
+ export declare const Md5Node: symbol;
6
+ export { Crc32Js, Crc32Js as Crc32 } from "./crc32/Crc32Js";
7
+ export declare const Crc32Node: symbol;
8
+ export { Sha256Js } from "./sha256/Sha256Js";
9
+ export { Sha256WebCrypto, Sha256WebCrypto as Sha256 } from "./sha256/Sha256WebCrypto";
10
+ export declare const Sha256Node: symbol;
5
11
  export { blobReader } from "./chunked-blob-reader/chunked-blob-reader.native";
@@ -0,0 +1,19 @@
1
+ import type { Checksum, SourceData } from "@smithy/types";
2
+ /**
3
+ * Pure-JS MD5 implementation. Used as fallback where node:crypto is unavailable.
4
+ *
5
+ * @public
6
+ */
7
+ export declare class Md5Js implements Checksum {
8
+ readonly digestLength = 16;
9
+ private state;
10
+ private writeBuffer;
11
+ private bufferLength;
12
+ private bytesHashed;
13
+ update(sourceData: SourceData): void;
14
+ /**
15
+ * Non-destructive: works on copies so update() may continue after digest().
16
+ */
17
+ digest(): Promise<Uint8Array>;
18
+ reset(): void;
19
+ }
@@ -0,0 +1,17 @@
1
+ import type { Checksum, SourceData } from "@smithy/types";
2
+ /**
3
+ * MD5 using Node.js crypto native implementation when available,
4
+ * falling back to the pure JS implementation.
5
+ * @public
6
+ */
7
+ export interface Md5Node extends Checksum {
8
+ readonly digestLength: 16;
9
+ /**
10
+ * @override
11
+ */
12
+ update(data: SourceData): void;
13
+ }
14
+ /**
15
+ * @public
16
+ */
17
+ export declare const Md5Node: new () => Md5Node;
@@ -0,0 +1,28 @@
1
+ import type { Checksum, SourceData } from "@smithy/types";
2
+ /**
3
+ * Pure JS SHA-256 implementation with HMAC support.
4
+ * @see https://csrc.nist.gov/pubs/fips/180-4/upd1/final
5
+ * @public
6
+ */
7
+ export declare class Sha256Js implements Checksum {
8
+ readonly digestLength = 32;
9
+ /** Eight 32-bit words representing the current hash state. */
10
+ private state;
11
+ /** Reused message schedule array (W), allocated on first use of hashBuffer. */
12
+ private w?;
13
+ /** Accumulates input bytes until a full 64-byte block is ready. */
14
+ private buffer;
15
+ private bufferLength;
16
+ private bytesHashed;
17
+ private finished;
18
+ private readonly inner?;
19
+ private readonly outer?;
20
+ constructor(secret?: SourceData);
21
+ update(data: SourceData): void;
22
+ digest(): Promise<Uint8Array>;
23
+ reset(): void;
24
+ private digestSync;
25
+ private static normalizeKey;
26
+ private hashBuffer;
27
+ private hashBufferWith;
28
+ }
@@ -0,0 +1,13 @@
1
+ import type { Checksum, SourceData } from "@smithy/types";
2
+ /**
3
+ * SHA-256 using Node.js crypto native implementation when available,
4
+ * falling back to the pure JS implementation.
5
+ * @public
6
+ */
7
+ export interface Sha256Node extends Checksum {
8
+ readonly digestLength: 32;
9
+ }
10
+ /**
11
+ * @public
12
+ */
13
+ export declare const Sha256Node: new (secret?: SourceData) => Sha256Node;