@cdk8s/awscdk-resolver 0.0.612 → 0.0.614

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
@@ -863,6 +863,9 @@ const calculateBodyLength = (body) => {
863
863
  };
864
864
 
865
865
  const toUint8Array = (data) => {
866
+ if (data instanceof Uint8Array) {
867
+ return data;
868
+ }
866
869
  if (typeof data === "string") {
867
870
  return fromUtf8(data);
868
871
  }
@@ -872,6 +875,22 @@ const toUint8Array = (data) => {
872
875
  return new Uint8Array(data);
873
876
  };
874
877
 
878
+ function concatBytes(arrays, length) {
879
+ if (length === undefined) {
880
+ length = 0;
881
+ for (const bytes of arrays) {
882
+ length += bytes.byteLength;
883
+ }
884
+ }
885
+ const result = new Uint8Array(length);
886
+ let offset = 0;
887
+ for (const buf of arrays) {
888
+ result.set(buf, offset);
889
+ offset += buf.byteLength;
890
+ }
891
+ return result;
892
+ }
893
+
875
894
  const isArrayBuffer = (arg) => (typeof ArrayBuffer === "function" && arg instanceof ArrayBuffer) ||
876
895
  Object.prototype.toString.call(arg) === "[object ArrayBuffer]";
877
896
 
@@ -1201,56 +1220,29 @@ async function headStream(stream, bytes) {
1201
1220
  }
1202
1221
 
1203
1222
  const streamCollector = async (stream) => {
1204
- if ((typeof Blob === "function" && stream instanceof Blob) || stream.constructor?.name === "Blob") {
1205
- if (Blob.prototype.arrayBuffer !== undefined) {
1206
- return new Uint8Array(await stream.arrayBuffer());
1207
- }
1223
+ if (isBlob(stream)) {
1208
1224
  return collectBlob(stream);
1209
1225
  }
1210
- return collectStream(stream);
1226
+ return collectReadableStream(stream);
1211
1227
  };
1212
1228
  async function collectBlob(blob) {
1213
- const base64 = await readToBase64(blob);
1214
- const arrayBuffer = fromBase64(base64);
1215
- return new Uint8Array(arrayBuffer);
1229
+ return blob.arrayBuffer().then((ab) => new Uint8Array(ab));
1216
1230
  }
1217
- async function collectStream(stream) {
1231
+ async function collectReadableStream(stream) {
1218
1232
  const chunks = [];
1219
1233
  const reader = stream.getReader();
1220
- let isDone = false;
1221
1234
  let length = 0;
1222
- while (!isDone) {
1235
+ while (true) {
1223
1236
  const { done, value } = await reader.read();
1224
1237
  if (value) {
1225
1238
  chunks.push(value);
1226
1239
  length += value.length;
1227
1240
  }
1228
- isDone = done;
1229
- }
1230
- const collected = new Uint8Array(length);
1231
- let offset = 0;
1232
- for (const chunk of chunks) {
1233
- collected.set(chunk, offset);
1234
- offset += chunk.length;
1241
+ if (done) {
1242
+ break;
1243
+ }
1235
1244
  }
1236
- return collected;
1237
- }
1238
- function readToBase64(blob) {
1239
- return new Promise((resolve, reject) => {
1240
- const reader = new FileReader();
1241
- reader.onloadend = () => {
1242
- if (reader.readyState !== 2) {
1243
- return reject(new Error("Reader aborted too early"));
1244
- }
1245
- const result = (reader.result ?? "");
1246
- const commaIndex = result.indexOf(",");
1247
- const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
1248
- resolve(result.substring(dataOffset));
1249
- };
1250
- reader.onabort = () => reject(new Error("Read aborted"));
1251
- reader.onerror = () => reject(reader.error);
1252
- reader.readAsDataURL(blob);
1253
- });
1245
+ return concatBytes(chunks, length);
1254
1246
  }
1255
1247
 
1256
1248
  const ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED = "The stream has already been transformed.";
@@ -1340,6 +1332,7 @@ exports._parseEpochTimestamp = _parseEpochTimestamp;
1340
1332
  exports._parseRfc3339DateTimeWithOffset = _parseRfc3339DateTimeWithOffset;
1341
1333
  exports._parseRfc7231DateTime = _parseRfc7231DateTime;
1342
1334
  exports.calculateBodyLength = calculateBodyLength;
1335
+ exports.concatBytes = concatBytes;
1343
1336
  exports.copyDocumentWithTransform = copyDocumentWithTransform;
1344
1337
  exports.createBufferedReadable = createBufferedReadable;
1345
1338
  exports.createChecksumStream = createChecksumStream;
@@ -1388,6 +1381,7 @@ exports.serializerMiddlewareOption = serializerMiddlewareOption;
1388
1381
  exports.splitEvery = splitEvery;
1389
1382
  exports.splitHeader = splitHeader;
1390
1383
  exports.splitStream = splitStream;
1384
+ exports.streamCollector = streamCollector;
1391
1385
  exports.strictParseByte = strictParseByte;
1392
1386
  exports.strictParseDouble = strictParseDouble;
1393
1387
  exports.strictParseFloat = strictParseFloat;
@@ -0,0 +1,30 @@
1
+ const CRC32_TABLE = new Uint32Array(256);
2
+ for (let i = 0; i < 256; ++i) {
3
+ let c = i;
4
+ for (let j = 0; j < 8; ++j) {
5
+ c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
6
+ }
7
+ CRC32_TABLE[i] = c >>> 0;
8
+ }
9
+ const ONES = 0xffff_ffff;
10
+ export class Crc32Js {
11
+ digestLength = 4;
12
+ checksum = ONES;
13
+ update(data) {
14
+ for (let i = 0; i < data.length; ++i) {
15
+ this.checksum = (this.checksum >>> 8) ^ CRC32_TABLE[(this.checksum ^ data[i]) & 0xff];
16
+ }
17
+ }
18
+ digestSync() {
19
+ return (this.checksum ^ ONES) >>> 0;
20
+ }
21
+ async digest() {
22
+ const value = this.digestSync();
23
+ const out = new Uint8Array(4);
24
+ new DataView(out.buffer).setUint32(0, value, false);
25
+ return out;
26
+ }
27
+ reset() {
28
+ this.checksum = ONES;
29
+ }
30
+ }
@@ -0,0 +1,24 @@
1
+ import * as zlib from "node:zlib";
2
+ import { Crc32Js } from "./Crc32Js";
3
+ const zlibCrc32 = typeof zlib.crc32 === "function" ? zlib.crc32 : undefined;
4
+ export const Crc32Node = zlibCrc32 ? buildNativeClass(zlibCrc32) : Crc32Js;
5
+ function buildNativeClass(nativeCrc32) {
6
+ return class Crc32Node {
7
+ digestLength = 4;
8
+ value = 0;
9
+ update(data) {
10
+ this.value = nativeCrc32(data, this.value);
11
+ }
12
+ digestSync() {
13
+ return this.value >>> 0;
14
+ }
15
+ async digest() {
16
+ const out = new Uint8Array(4);
17
+ new DataView(out.buffer).setUint32(0, this.digestSync(), false);
18
+ return out;
19
+ }
20
+ reset() {
21
+ this.value = 0;
22
+ }
23
+ };
24
+ }
@@ -2,5 +2,11 @@ const no = Symbol.for("node-only");
2
2
  export { blobHasher } from "./hash-blob-browser/blobHasher";
3
3
  export const fileStreamHasher = no;
4
4
  export const readableStreamHasher = no;
5
- export { Md5 } from "./md5-js/md5";
5
+ export { Md5Js, Md5Js as Md5 } from "./md5/Md5Js";
6
+ export const Md5Node = no;
7
+ export { Crc32Js, Crc32Js as Crc32 } from "./crc32/Crc32Js";
8
+ export const Crc32Node = no;
9
+ export { Sha256Js } from "./sha256/Sha256Js";
10
+ export { Sha256WebCrypto, Sha256WebCrypto as Sha256 } from "./sha256/Sha256WebCrypto";
11
+ export const Sha256Node = no;
6
12
  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";
@@ -2,5 +2,11 @@ const no = Symbol.for("node-only");
2
2
  export { blobHasher } from "./hash-blob-browser/blobHasher";
3
3
  export const fileStreamHasher = no;
4
4
  export const readableStreamHasher = no;
5
- export { Md5 } from "./md5-js/md5";
5
+ export { Md5Js, Md5Js as Md5 } from "./md5/Md5Js";
6
+ export const Md5Node = no;
7
+ export { Crc32Js, Crc32Js as Crc32 } from "./crc32/Crc32Js";
8
+ export const Crc32Node = no;
9
+ export { Sha256Js } from "./sha256/Sha256Js";
10
+ export { Sha256WebCrypto, Sha256WebCrypto as Sha256 } from "./sha256/Sha256WebCrypto";
11
+ export const Sha256Node = no;
6
12
  export { blobReader } from "./chunked-blob-reader/chunked-blob-reader.native";
@@ -0,0 +1,92 @@
1
+ import { toUint8Array } from "@smithy/core/serde";
2
+ export class Md5Js {
3
+ digestLength = 16;
4
+ state = Uint32Array.from(INIT);
5
+ writeBuffer = new DataView(new ArrayBuffer(64));
6
+ bufferLength = 0;
7
+ bytesHashed = 0;
8
+ update(sourceData) {
9
+ const data = toUint8Array(sourceData);
10
+ let pos = 0;
11
+ let len = data.byteLength;
12
+ this.bytesHashed += len;
13
+ while (len > 0) {
14
+ this.writeBuffer.setUint8(this.bufferLength++, data[pos++]);
15
+ --len;
16
+ if (this.bufferLength === 64) {
17
+ compress(this.state, this.writeBuffer);
18
+ this.bufferLength = 0;
19
+ }
20
+ }
21
+ }
22
+ async digest() {
23
+ const state = Uint32Array.from(this.state);
24
+ const buf = new DataView(this.writeBuffer.buffer.slice(0));
25
+ let bufLen = this.bufferLength;
26
+ const bits = this.bytesHashed * 8;
27
+ buf.setUint8(bufLen++, 0x80);
28
+ if (this.bufferLength % 64 >= 56) {
29
+ for (let i = bufLen; i < 64; ++i) {
30
+ buf.setUint8(i, 0);
31
+ }
32
+ compress(state, buf);
33
+ bufLen = 0;
34
+ }
35
+ for (let i = bufLen; i < 56; ++i) {
36
+ buf.setUint8(i, 0);
37
+ }
38
+ buf.setUint32(56, bits >>> 0, true);
39
+ buf.setUint32(60, Math.floor(bits / 2 ** 32), true);
40
+ compress(state, buf);
41
+ const out = new Uint8Array(16);
42
+ const view = new DataView(out.buffer);
43
+ for (let i = 0; i < 4; ++i) {
44
+ view.setUint32(i * 4, state[i], true);
45
+ }
46
+ return out;
47
+ }
48
+ reset() {
49
+ this.state.set(INIT);
50
+ this.writeBuffer = new DataView(new ArrayBuffer(64));
51
+ this.bufferLength = 0;
52
+ this.bytesHashed = 0;
53
+ }
54
+ }
55
+ const INIT = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476];
56
+ const M = 0xffffffff;
57
+ const S = Uint8Array.of(7, 12, 17, 22, 5, 9, 14, 20, 4, 11, 16, 23, 6, 10, 15, 21);
58
+ const T = Array.from({ length: 64 }, (_, i) => (Math.abs(Math.sin(i + 1)) * 2 ** 32) >>> 0);
59
+ function compress(state, block) {
60
+ let a = state[0], b = state[1], c = state[2], d = state[3];
61
+ for (let i = 0; i < 64; ++i) {
62
+ let f, g;
63
+ if (i < 16) {
64
+ f = (b & c) | (~b & d);
65
+ g = i;
66
+ }
67
+ else if (i < 32) {
68
+ f = (d & b) | (c & ~d);
69
+ g = (5 * i + 1) % 16;
70
+ }
71
+ else if (i < 48) {
72
+ f = b ^ c ^ d;
73
+ g = (3 * i + 5) % 16;
74
+ }
75
+ else {
76
+ f = c ^ (b | ~d);
77
+ g = (7 * i) % 16;
78
+ }
79
+ const x = block.getUint32(g * 4, true);
80
+ const tmp = d;
81
+ d = c;
82
+ c = b;
83
+ const s = S[(i >> 4) * 4 + (i & 3)];
84
+ const sum = (((a + f) & M) + ((x + T[i]) & M)) & M;
85
+ b = (b + (((sum << s) | (sum >>> (32 - s))) >>> 0)) & M;
86
+ a = tmp;
87
+ }
88
+ state[0] = (state[0] + a) & M;
89
+ state[1] = (state[1] + b) & M;
90
+ state[2] = (state[2] + c) & M;
91
+ state[3] = (state[3] + d) & M;
92
+ }
@@ -0,0 +1,29 @@
1
+ import { createHash } from "node:crypto";
2
+ import { toUint8Array } from "@smithy/core/serde";
3
+ import { Md5Js } from "./Md5Js";
4
+ const hasNativeCrypto = (() => {
5
+ try {
6
+ createHash("md5");
7
+ return true;
8
+ }
9
+ catch {
10
+ return false;
11
+ }
12
+ })();
13
+ export const Md5Node = hasNativeCrypto ? buildNativeClass() : Md5Js;
14
+ function buildNativeClass() {
15
+ return class Md5Node {
16
+ digestLength = 16;
17
+ hash = createHash("md5");
18
+ update(data) {
19
+ this.hash.update(toUint8Array(data));
20
+ }
21
+ async digest() {
22
+ const buf = this.hash.copy().digest();
23
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
24
+ }
25
+ reset() {
26
+ this.hash = createHash("md5");
27
+ }
28
+ };
29
+ }
@@ -0,0 +1,179 @@
1
+ import { toUint8Array } from "@smithy/core/serde";
2
+ const BLOCK = 64;
3
+ const DIGEST_LENGTH = 32;
4
+ const MAX_HASHABLE_LENGTH = 2 ** 53 - 1;
5
+ export class Sha256Js {
6
+ digestLength = DIGEST_LENGTH;
7
+ state = Int32Array.from(INIT);
8
+ w;
9
+ buffer = new Uint8Array(64);
10
+ bufferLength = 0;
11
+ bytesHashed = 0;
12
+ finished = false;
13
+ inner;
14
+ outer;
15
+ constructor(secret) {
16
+ if (secret) {
17
+ const key = Sha256Js.normalizeKey(secret);
18
+ this.inner = new Sha256Js();
19
+ this.outer = new Sha256Js();
20
+ const { inner, outer } = this;
21
+ const pad = new Uint8Array(BLOCK * 2);
22
+ for (let i = 0; i < BLOCK; ++i) {
23
+ pad[i] = 0x36 ^ key[i];
24
+ pad[i + BLOCK] = 0x5c ^ key[i];
25
+ }
26
+ inner.update(pad.subarray(0, BLOCK));
27
+ outer.update(pad.subarray(BLOCK));
28
+ }
29
+ }
30
+ update(data) {
31
+ if (this.finished) {
32
+ throw new Error("Attempted to update an already finished HMAC.");
33
+ }
34
+ if (this.inner) {
35
+ this.inner.update(data);
36
+ return;
37
+ }
38
+ const chunk = toUint8Array(data);
39
+ let position = 0;
40
+ let { byteLength } = chunk;
41
+ this.bytesHashed += byteLength;
42
+ if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {
43
+ throw new Error("Cannot hash more than 2^53 - 1 bits");
44
+ }
45
+ while (byteLength > 0) {
46
+ this.buffer[this.bufferLength++] = chunk[position++];
47
+ byteLength--;
48
+ if (this.bufferLength === BLOCK) {
49
+ this.hashBuffer();
50
+ this.bufferLength = 0;
51
+ }
52
+ }
53
+ }
54
+ async digest() {
55
+ const { inner, outer } = this;
56
+ if (inner && outer) {
57
+ if (this.finished) {
58
+ throw new Error("Attempted to digest an already finished HMAC.");
59
+ }
60
+ this.finished = true;
61
+ const innerDigest = inner.digestSync();
62
+ outer.update(innerDigest);
63
+ return outer.digestSync();
64
+ }
65
+ return this.digestSync();
66
+ }
67
+ reset() {
68
+ this.state = Int32Array.from(INIT);
69
+ this.buffer = new Uint8Array(64);
70
+ this.bufferLength = 0;
71
+ this.bytesHashed = 0;
72
+ }
73
+ digestSync() {
74
+ const state = this.state.slice();
75
+ const buffer = this.buffer.slice();
76
+ let bufferLength = this.bufferLength;
77
+ const bitsHashed = this.bytesHashed * 8;
78
+ const bufferView = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
79
+ bufferView.setUint8(bufferLength++, 0x80);
80
+ if ((bufferLength - 1) % BLOCK >= BLOCK - 8) {
81
+ for (let i = bufferLength; i < BLOCK; ++i) {
82
+ bufferView.setUint8(i, 0);
83
+ }
84
+ this.hashBufferWith(state, buffer);
85
+ bufferLength = 0;
86
+ }
87
+ for (let i = bufferLength; i < BLOCK - 8; ++i) {
88
+ bufferView.setUint8(i, 0);
89
+ }
90
+ bufferView.setUint32(BLOCK - 8, Math.floor(bitsHashed / 0x100000000), false);
91
+ bufferView.setUint32(BLOCK - 4, bitsHashed, false);
92
+ this.hashBufferWith(state, buffer);
93
+ const out = new Uint8Array(DIGEST_LENGTH);
94
+ for (let i = 0; i < 8; ++i) {
95
+ out[i * 4] = (state[i] >>> 24) & 0xff;
96
+ out[i * 4 + 1] = (state[i] >>> 16) & 0xff;
97
+ out[i * 4 + 2] = (state[i] >>> 8) & 0xff;
98
+ out[i * 4 + 3] = (state[i] >>> 0) & 0xff;
99
+ }
100
+ return out;
101
+ }
102
+ static normalizeKey(secret) {
103
+ const key = toUint8Array(secret);
104
+ if (key.byteLength > BLOCK) {
105
+ const h = new Sha256Js();
106
+ h.update(key);
107
+ const out = h.digestSync();
108
+ const padded = new Uint8Array(BLOCK);
109
+ padded.set(out);
110
+ return padded;
111
+ }
112
+ if (key.byteLength < BLOCK) {
113
+ const padded = new Uint8Array(BLOCK);
114
+ padded.set(key);
115
+ return padded;
116
+ }
117
+ return key;
118
+ }
119
+ hashBuffer() {
120
+ this.hashBufferWith(this.state, this.buffer);
121
+ }
122
+ hashBufferWith(state, buffer) {
123
+ const w = (this.w ??= new Int32Array(64));
124
+ let s0 = state[0], s1 = state[1], s2 = state[2], s3 = state[3], s4 = state[4], s5 = state[5], s6 = state[6], s7 = state[7];
125
+ for (let i = 0; i < BLOCK; ++i) {
126
+ if (i < 16) {
127
+ w[i] =
128
+ ((buffer[i * 4] & 0xff) << 24) |
129
+ ((buffer[i * 4 + 1] & 0xff) << 16) |
130
+ ((buffer[i * 4 + 2] & 0xff) << 8) |
131
+ (buffer[i * 4 + 3] & 0xff);
132
+ }
133
+ else {
134
+ let u = w[i - 2];
135
+ const t1 = ((u >>> 17) | (u << 15)) ^ ((u >>> 19) | (u << 13)) ^ (u >>> 10);
136
+ u = w[i - 15];
137
+ const t2 = ((u >>> 7) | (u << 25)) ^ ((u >>> 18) | (u << 14)) ^ (u >>> 3);
138
+ w[i] = ((t1 + w[i - 7]) | 0) + ((t2 + w[i - 16]) | 0);
139
+ }
140
+ const t1 = ((((((s4 >>> 6) | (s4 << 26)) ^ ((s4 >>> 11) | (s4 << 21)) ^ ((s4 >>> 25) | (s4 << 7))) +
141
+ ((s4 & s5) ^ (~s4 & s6))) |
142
+ 0) +
143
+ ((s7 + ((K[i] + w[i]) | 0)) | 0)) |
144
+ 0;
145
+ const t2 = ((((s0 >>> 2) | (s0 << 30)) ^ ((s0 >>> 13) | (s0 << 19)) ^ ((s0 >>> 22) | (s0 << 10))) +
146
+ ((s0 & s1) ^ (s0 & s2) ^ (s1 & s2))) |
147
+ 0;
148
+ s7 = s6;
149
+ s6 = s5;
150
+ s5 = s4;
151
+ s4 = (s3 + t1) | 0;
152
+ s3 = s2;
153
+ s2 = s1;
154
+ s1 = s0;
155
+ s0 = (t1 + t2) | 0;
156
+ }
157
+ state[0] += s0;
158
+ state[1] += s1;
159
+ state[2] += s2;
160
+ state[3] += s3;
161
+ state[4] += s4;
162
+ state[5] += s5;
163
+ state[6] += s6;
164
+ state[7] += s7;
165
+ }
166
+ }
167
+ const INIT = new Int32Array([
168
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
169
+ ]);
170
+ const K = new Int32Array([
171
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
172
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
173
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
174
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
175
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
176
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
177
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
178
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
179
+ ]);
@@ -0,0 +1,59 @@
1
+ import { createHash, createHmac } from "node:crypto";
2
+ import { Sha256Js } from "./Sha256Js";
3
+ const hasNativeCrypto = (() => {
4
+ try {
5
+ createHash("sha256");
6
+ return true;
7
+ }
8
+ catch {
9
+ return false;
10
+ }
11
+ })();
12
+ export const Sha256Node = hasNativeCrypto ? buildNativeClass() : Sha256Js;
13
+ function buildNativeClass() {
14
+ return class Sha256Node {
15
+ digestLength = 32;
16
+ secret;
17
+ hash;
18
+ isHmac;
19
+ finished = false;
20
+ constructor(secret) {
21
+ this.secret = secret;
22
+ this.isHmac = !!secret;
23
+ this.hash = this.createHash();
24
+ }
25
+ update(data) {
26
+ if (this.finished) {
27
+ throw new Error("Attempted to update an already finished hash.");
28
+ }
29
+ this.hash.update(data);
30
+ }
31
+ async digest() {
32
+ let buf;
33
+ if (this.isHmac) {
34
+ this.finished = true;
35
+ buf = this.hash.digest();
36
+ }
37
+ else {
38
+ buf = this.hash.copy().digest();
39
+ }
40
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
41
+ }
42
+ reset() {
43
+ this.hash = this.createHash();
44
+ this.finished = false;
45
+ }
46
+ createHash() {
47
+ return this.secret ? createHmac("sha256", toBuffer(this.secret)) : createHash("sha256");
48
+ }
49
+ };
50
+ }
51
+ function toBuffer(data) {
52
+ if (typeof data === "string") {
53
+ return data;
54
+ }
55
+ if (ArrayBuffer.isView(data)) {
56
+ return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
57
+ }
58
+ return Buffer.from(data);
59
+ }
@@ -0,0 +1,71 @@
1
+ import { concatBytes, toUint8Array } from "@smithy/core/serde";
2
+ import { Sha256Js } from "./Sha256Js";
3
+ const { digest, sign, importKey } = globalThis?.crypto?.subtle ?? {};
4
+ const subtle = typeof digest === "function" && typeof sign === "function" && typeof importKey === "function"
5
+ ? globalThis.crypto.subtle
6
+ : undefined;
7
+ const MAX_PENDING_BYTES = 8 * 1024 * 1024;
8
+ export class Sha256WebCrypto {
9
+ digestLength = 32;
10
+ secret;
11
+ pending = [];
12
+ pendingBytes = 0;
13
+ fallback;
14
+ finished = false;
15
+ constructor(secret) {
16
+ if (secret) {
17
+ this.secret = toUint8Array(secret);
18
+ }
19
+ }
20
+ update(data) {
21
+ if (this.finished) {
22
+ throw new Error("Attempted to update an already finished HMAC.");
23
+ }
24
+ if (this.fallback) {
25
+ this.fallback.update(data);
26
+ return;
27
+ }
28
+ this.pending.push(data.slice());
29
+ this.pendingBytes += data.byteLength;
30
+ if (this.pendingBytes >= MAX_PENDING_BYTES) {
31
+ this.switchToFallback();
32
+ }
33
+ }
34
+ async digest() {
35
+ if (this.fallback) {
36
+ return this.fallback.digest();
37
+ }
38
+ if (this.secret && this.finished) {
39
+ throw new Error("Attempted to digest an already finished HMAC.");
40
+ }
41
+ const data = concatBytes(this.pending);
42
+ if (subtle) {
43
+ if (this.secret) {
44
+ this.finished = true;
45
+ const key = await subtle.importKey("raw", this.secret, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
46
+ const sig = await subtle.sign("HMAC", key, data);
47
+ return new Uint8Array(sig);
48
+ }
49
+ const hash = await subtle.digest("SHA-256", data);
50
+ return new Uint8Array(hash);
51
+ }
52
+ const sha256 = new Sha256Js(this.secret);
53
+ sha256.update(data);
54
+ return sha256.digest();
55
+ }
56
+ reset() {
57
+ this.pending = [];
58
+ this.pendingBytes = 0;
59
+ this.fallback = undefined;
60
+ this.finished = false;
61
+ }
62
+ switchToFallback() {
63
+ const sha256Js = new Sha256Js(this.secret);
64
+ for (const chunk of this.pending) {
65
+ sha256Js.update(chunk);
66
+ }
67
+ this.fallback = sha256Js;
68
+ this.pending = [];
69
+ this.pendingBytes = 0;
70
+ }
71
+ }
@@ -1,9 +1,14 @@
1
+ import { getInstanceMetadataRegion } from "./getInstanceMetadataRegion";
1
2
  export const REGION_ENV_NAME = "AWS_REGION";
2
3
  export const REGION_INI_NAME = "region";
3
4
  export const NODE_REGION_CONFIG_OPTIONS = {
4
5
  environmentVariableSelector: (env) => env[REGION_ENV_NAME],
5
6
  configFileSelector: (profile) => profile[REGION_INI_NAME],
6
- default: () => {
7
+ default: async () => {
8
+ const region = await getInstanceMetadataRegion();
9
+ if (region) {
10
+ return region;
11
+ }
7
12
  throw new Error("Region is missing");
8
13
  },
9
14
  };