@cdk8s/awscdk-resolver 0.0.189 → 0.0.191

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 (144) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/package.json +7 -7
  4. package/node_modules/@aws-sdk/client-sso/package.json +4 -4
  5. package/node_modules/@aws-sdk/client-sso-oidc/package.json +6 -6
  6. package/node_modules/@aws-sdk/client-sts/package.json +6 -6
  7. package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js +9 -5
  8. package/node_modules/@aws-sdk/core/dist-es/submodules/client/emitWarningIfUnsupportedVersion.js +5 -3
  9. package/node_modules/@aws-sdk/core/dist-types/submodules/client/emitWarningIfUnsupportedVersion.d.ts +3 -0
  10. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/emitWarningIfUnsupportedVersion.d.ts +3 -0
  11. package/node_modules/@aws-sdk/core/package.json +3 -3
  12. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  13. package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
  14. package/node_modules/@aws-sdk/credential-provider-ini/package.json +8 -8
  15. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  16. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  17. package/node_modules/@aws-sdk/credential-provider-sso/package.json +3 -3
  18. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  19. package/node_modules/@aws-sdk/middleware-user-agent/package.json +2 -2
  20. package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
  21. package/node_modules/@smithy/abort-controller/package.json +2 -2
  22. package/node_modules/@smithy/config-resolver/package.json +4 -4
  23. package/node_modules/@smithy/core/dist-cjs/index.js +79 -158
  24. package/node_modules/@smithy/core/dist-cjs/setFeature.js +1 -0
  25. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +2 -2
  26. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +163 -0
  27. package/node_modules/@smithy/core/dist-es/index.js +4 -3
  28. package/node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/getHttpAuthSchemeEndpointRuleSetPlugin.js +1 -2
  29. package/node_modules/@smithy/core/dist-es/middleware-http-signing/getHttpSigningMiddleware.js +1 -2
  30. package/node_modules/@smithy/core/dist-es/protocols/requestBuilder.js +1 -67
  31. package/node_modules/@smithy/core/dist-es/setFeature.js +11 -0
  32. package/node_modules/@smithy/core/dist-es/submodules/cbor/parseCborBody.js +1 -1
  33. package/node_modules/@smithy/core/dist-es/submodules/protocols/collect-stream-body.js +11 -0
  34. package/node_modules/@smithy/core/dist-es/submodules/protocols/extended-encode-uri-component.js +5 -0
  35. package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +4 -0
  36. package/node_modules/@smithy/core/dist-es/submodules/protocols/requestBuilder.js +67 -0
  37. package/node_modules/@smithy/core/dist-es/submodules/protocols/resolve-path.js +19 -0
  38. package/node_modules/@smithy/core/dist-types/index.d.ts +4 -3
  39. package/node_modules/@smithy/core/dist-types/protocols/requestBuilder.d.ts +2 -48
  40. package/node_modules/@smithy/core/dist-types/setFeature.d.ts +12 -0
  41. package/node_modules/@smithy/core/dist-types/submodules/protocols/collect-stream-body.d.ts +10 -0
  42. package/node_modules/@smithy/core/dist-types/submodules/protocols/extended-encode-uri-component.d.ts +7 -0
  43. package/node_modules/@smithy/core/dist-types/submodules/protocols/index.d.ts +4 -0
  44. package/node_modules/@smithy/core/dist-types/submodules/protocols/requestBuilder.d.ts +51 -0
  45. package/node_modules/@smithy/core/dist-types/submodules/protocols/resolve-path.d.ts +4 -0
  46. package/node_modules/@smithy/core/dist-types/ts3.4/index.d.ts +4 -3
  47. package/node_modules/@smithy/core/dist-types/ts3.4/protocols/requestBuilder.d.ts +2 -48
  48. package/node_modules/@smithy/core/dist-types/ts3.4/setFeature.d.ts +12 -0
  49. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/collect-stream-body.d.ts +10 -0
  50. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/extended-encode-uri-component.d.ts +7 -0
  51. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/index.d.ts +4 -0
  52. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/requestBuilder.d.ts +51 -0
  53. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/resolve-path.d.ts +4 -0
  54. package/node_modules/@smithy/core/package.json +15 -8
  55. package/node_modules/@smithy/core/protocols.d.ts +7 -0
  56. package/node_modules/@smithy/core/protocols.js +6 -0
  57. package/node_modules/@smithy/credential-provider-imds/package.json +5 -5
  58. package/node_modules/@smithy/hash-node/package.json +2 -2
  59. package/node_modules/@smithy/invalid-dependency/package.json +2 -2
  60. package/node_modules/@smithy/middleware-content-length/package.json +3 -3
  61. package/node_modules/@smithy/middleware-endpoint/dist-cjs/index.js +4 -0
  62. package/node_modules/@smithy/middleware-endpoint/dist-es/endpointMiddleware.js +4 -0
  63. package/node_modules/@smithy/middleware-endpoint/package.json +8 -7
  64. package/node_modules/@smithy/middleware-retry/package.json +8 -8
  65. package/node_modules/@smithy/middleware-serde/package.json +2 -2
  66. package/node_modules/@smithy/middleware-stack/package.json +2 -2
  67. package/node_modules/@smithy/node-config-provider/package.json +4 -4
  68. package/node_modules/@smithy/node-http-handler/package.json +5 -5
  69. package/node_modules/@smithy/property-provider/package.json +2 -2
  70. package/node_modules/@smithy/protocol-http/package.json +2 -2
  71. package/node_modules/@smithy/querystring-builder/package.json +2 -2
  72. package/node_modules/@smithy/querystring-parser/package.json +2 -2
  73. package/node_modules/@smithy/service-error-classification/package.json +2 -2
  74. package/node_modules/@smithy/shared-ini-file-loader/package.json +2 -2
  75. package/node_modules/@smithy/signature-v4/package.json +4 -4
  76. package/node_modules/@smithy/smithy-client/dist-cjs/index.js +6 -35
  77. package/node_modules/@smithy/smithy-client/dist-es/collect-stream-body.js +1 -11
  78. package/node_modules/@smithy/smithy-client/dist-es/extended-encode-uri-component.js +1 -5
  79. package/node_modules/@smithy/smithy-client/dist-es/resolve-path.js +1 -19
  80. package/node_modules/@smithy/smithy-client/dist-types/collect-stream-body.d.ts +2 -7
  81. package/node_modules/@smithy/smithy-client/dist-types/extended-encode-uri-component.d.ts +2 -4
  82. package/node_modules/@smithy/smithy-client/dist-types/resolve-path.d.ts +2 -1
  83. package/node_modules/@smithy/smithy-client/dist-types/ts3.4/collect-stream-body.d.ts +2 -7
  84. package/node_modules/@smithy/smithy-client/dist-types/ts3.4/extended-encode-uri-component.d.ts +2 -4
  85. package/node_modules/@smithy/smithy-client/dist-types/ts3.4/resolve-path.d.ts +2 -1
  86. package/node_modules/@smithy/smithy-client/package.json +7 -6
  87. package/node_modules/@smithy/types/dist-cjs/feature-ids.js +1 -0
  88. package/node_modules/@smithy/types/dist-es/feature-ids.js +1 -0
  89. package/node_modules/@smithy/types/dist-es/index.js +1 -0
  90. package/node_modules/@smithy/types/dist-types/feature-ids.d.ts +16 -0
  91. package/node_modules/@smithy/types/dist-types/index.d.ts +1 -0
  92. package/node_modules/@smithy/types/dist-types/middleware.d.ts +30 -6
  93. package/node_modules/@smithy/types/dist-types/ts3.4/feature-ids.d.ts +16 -0
  94. package/node_modules/@smithy/types/dist-types/ts3.4/index.d.ts +1 -0
  95. package/node_modules/@smithy/types/dist-types/ts3.4/middleware.d.ts +26 -2
  96. package/node_modules/@smithy/types/package.json +1 -1
  97. package/node_modules/@smithy/url-parser/package.json +3 -3
  98. package/node_modules/@smithy/util-defaults-mode-browser/package.json +4 -4
  99. package/node_modules/@smithy/util-defaults-mode-node/package.json +7 -7
  100. package/node_modules/@smithy/util-endpoints/package.json +3 -3
  101. package/node_modules/@smithy/util-middleware/package.json +2 -2
  102. package/node_modules/@smithy/util-retry/package.json +3 -3
  103. package/node_modules/@smithy/util-stream/dist-cjs/checksum/ChecksumStream.browser.js +7 -0
  104. package/node_modules/@smithy/util-stream/dist-cjs/checksum/ChecksumStream.js +49 -0
  105. package/node_modules/@smithy/util-stream/dist-cjs/checksum/createChecksumStream.browser.js +40 -0
  106. package/node_modules/@smithy/util-stream/dist-cjs/checksum/createChecksumStream.js +13 -0
  107. package/node_modules/@smithy/util-stream/dist-cjs/index.js +5 -1
  108. package/node_modules/@smithy/util-stream/dist-es/checksum/ChecksumStream.browser.js +3 -0
  109. package/node_modules/@smithy/util-stream/dist-es/checksum/ChecksumStream.js +44 -0
  110. package/node_modules/@smithy/util-stream/dist-es/checksum/createChecksumStream.browser.js +35 -0
  111. package/node_modules/@smithy/util-stream/dist-es/checksum/createChecksumStream.js +9 -0
  112. package/node_modules/@smithy/util-stream/dist-es/index.js +2 -0
  113. package/node_modules/@smithy/util-stream/dist-types/checksum/ChecksumStream.browser.d.ts +37 -0
  114. package/node_modules/@smithy/util-stream/dist-types/checksum/ChecksumStream.d.ts +61 -0
  115. package/node_modules/@smithy/util-stream/dist-types/checksum/createChecksumStream.browser.d.ts +15 -0
  116. package/node_modules/@smithy/util-stream/dist-types/checksum/createChecksumStream.d.ts +12 -0
  117. package/node_modules/@smithy/util-stream/dist-types/index.d.ts +2 -0
  118. package/node_modules/@smithy/util-stream/dist-types/ts3.4/checksum/ChecksumStream.browser.d.ts +37 -0
  119. package/node_modules/@smithy/util-stream/dist-types/ts3.4/checksum/ChecksumStream.d.ts +60 -0
  120. package/node_modules/@smithy/util-stream/dist-types/ts3.4/checksum/createChecksumStream.browser.d.ts +15 -0
  121. package/node_modules/@smithy/util-stream/dist-types/ts3.4/checksum/createChecksumStream.d.ts +12 -0
  122. package/node_modules/@smithy/util-stream/dist-types/ts3.4/index.d.ts +2 -0
  123. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/LICENSE +201 -0
  124. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/README.md +11 -0
  125. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-cjs/fetch-http-handler.js +1 -0
  126. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +230 -0
  127. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-cjs/request-timeout.js +1 -0
  128. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-cjs/stream-collector.js +1 -0
  129. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js +138 -0
  130. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-es/index.js +2 -0
  131. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-es/request-timeout.js +11 -0
  132. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-es/stream-collector.js +27 -0
  133. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-types/fetch-http-handler.d.ts +33 -0
  134. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-types/index.d.ts +2 -0
  135. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-types/request-timeout.d.ts +1 -0
  136. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-types/stream-collector.d.ts +2 -0
  137. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-types/ts3.4/fetch-http-handler.d.ts +33 -0
  138. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-types/ts3.4/index.d.ts +2 -0
  139. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-types/ts3.4/request-timeout.d.ts +1 -0
  140. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/dist-types/ts3.4/stream-collector.d.ts +2 -0
  141. package/node_modules/@smithy/util-stream/node_modules/@smithy/fetch-http-handler/package.json +62 -0
  142. package/node_modules/@smithy/util-stream/package.json +10 -4
  143. package/node_modules/@smithy/util-waiter/package.json +3 -3
  144. package/package.json +5 -5
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/util-defaults-mode-node",
3
- "version": "3.0.23",
3
+ "version": "3.0.25",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
6
6
  "build:cjs": "node ../../scripts/inline util-defaults-mode-node",
@@ -22,12 +22,12 @@
22
22
  },
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@smithy/config-resolver": "^3.0.9",
26
- "@smithy/credential-provider-imds": "^3.2.4",
27
- "@smithy/node-config-provider": "^3.1.8",
28
- "@smithy/property-provider": "^3.1.7",
29
- "@smithy/smithy-client": "^3.4.0",
30
- "@smithy/types": "^3.5.0",
25
+ "@smithy/config-resolver": "^3.0.10",
26
+ "@smithy/credential-provider-imds": "^3.2.5",
27
+ "@smithy/node-config-provider": "^3.1.9",
28
+ "@smithy/property-provider": "^3.1.8",
29
+ "@smithy/smithy-client": "^3.4.2",
30
+ "@smithy/types": "^3.6.0",
31
31
  "tslib": "^2.6.2"
32
32
  },
33
33
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/util-endpoints",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "Utilities to help with endpoint resolution.",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -26,8 +26,8 @@
26
26
  },
27
27
  "license": "Apache-2.0",
28
28
  "dependencies": {
29
- "@smithy/node-config-provider": "^3.1.8",
30
- "@smithy/types": "^3.5.0",
29
+ "@smithy/node-config-provider": "^3.1.9",
30
+ "@smithy/types": "^3.6.0",
31
31
  "tslib": "^2.6.2"
32
32
  },
33
33
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/util-middleware",
3
- "version": "3.0.7",
3
+ "version": "3.0.8",
4
4
  "description": "Shared utilities for to be used in middleware packages.",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "license": "Apache-2.0",
28
28
  "dependencies": {
29
- "@smithy/types": "^3.5.0",
29
+ "@smithy/types": "^3.6.0",
30
30
  "tslib": "^2.6.2"
31
31
  },
32
32
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/util-retry",
3
- "version": "3.0.7",
3
+ "version": "3.0.8",
4
4
  "description": "Shared retry utilities to be used in middleware packages.",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "module": "./dist-es/index.js",
@@ -27,8 +27,8 @@
27
27
  },
28
28
  "license": "Apache-2.0",
29
29
  "dependencies": {
30
- "@smithy/service-error-classification": "^3.0.7",
31
- "@smithy/types": "^3.5.0",
30
+ "@smithy/service-error-classification": "^3.0.8",
31
+ "@smithy/types": "^3.6.0",
32
32
  "tslib": "^2.6.2"
33
33
  },
34
34
  "devDependencies": {
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChecksumStream = void 0;
4
+ const ReadableStreamRef = typeof ReadableStream === "function" ? ReadableStream : function () { };
5
+ class ChecksumStream extends ReadableStreamRef {
6
+ }
7
+ exports.ChecksumStream = ChecksumStream;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChecksumStream = void 0;
4
+ const util_base64_1 = require("@smithy/util-base64");
5
+ const stream_1 = require("stream");
6
+ class ChecksumStream extends stream_1.Duplex {
7
+ constructor({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder, }) {
8
+ var _a, _b;
9
+ super();
10
+ if (typeof source.pipe === "function") {
11
+ this.source = source;
12
+ }
13
+ else {
14
+ throw new Error(`@smithy/util-stream: unsupported source type ${(_b = (_a = source === null || source === void 0 ? void 0 : source.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : source} in ChecksumStream.`);
15
+ }
16
+ this.base64Encoder = base64Encoder !== null && base64Encoder !== void 0 ? base64Encoder : util_base64_1.toBase64;
17
+ this.expectedChecksum = expectedChecksum;
18
+ this.checksum = checksum;
19
+ this.checksumSourceLocation = checksumSourceLocation;
20
+ this.source.pipe(this);
21
+ }
22
+ _read(size) { }
23
+ _write(chunk, encoding, callback) {
24
+ try {
25
+ this.checksum.update(chunk);
26
+ this.push(chunk);
27
+ }
28
+ catch (e) {
29
+ return callback(e);
30
+ }
31
+ return callback();
32
+ }
33
+ async _final(callback) {
34
+ try {
35
+ const digest = await this.checksum.digest();
36
+ const received = this.base64Encoder(digest);
37
+ if (this.expectedChecksum !== received) {
38
+ return callback(new Error(`Checksum mismatch: expected "${this.expectedChecksum}" but received "${received}"` +
39
+ ` in response header "${this.checksumSourceLocation}".`));
40
+ }
41
+ }
42
+ catch (e) {
43
+ return callback(e);
44
+ }
45
+ this.push(null);
46
+ return callback();
47
+ }
48
+ }
49
+ exports.ChecksumStream = ChecksumStream;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createChecksumStream = void 0;
4
+ const util_base64_1 = require("@smithy/util-base64");
5
+ const stream_type_check_1 = require("../stream-type-check");
6
+ const ChecksumStream_browser_1 = require("./ChecksumStream.browser");
7
+ const createChecksumStream = ({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder, }) => {
8
+ var _a, _b;
9
+ if (!(0, stream_type_check_1.isReadableStream)(source)) {
10
+ throw new Error(`@smithy/util-stream: unsupported source type ${(_b = (_a = source === null || source === void 0 ? void 0 : source.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : source} in ChecksumStream.`);
11
+ }
12
+ const encoder = base64Encoder !== null && base64Encoder !== void 0 ? base64Encoder : util_base64_1.toBase64;
13
+ if (typeof TransformStream !== "function") {
14
+ throw new Error("@smithy/util-stream: unable to instantiate ChecksumStream because API unavailable: ReadableStream/TransformStream.");
15
+ }
16
+ const transform = new TransformStream({
17
+ start() { },
18
+ async transform(chunk, controller) {
19
+ checksum.update(chunk);
20
+ controller.enqueue(chunk);
21
+ },
22
+ async flush(controller) {
23
+ const digest = await checksum.digest();
24
+ const received = encoder(digest);
25
+ if (expectedChecksum !== received) {
26
+ const error = new Error(`Checksum mismatch: expected "${expectedChecksum}" but received "${received}"` +
27
+ ` in response header "${checksumSourceLocation}".`);
28
+ controller.error(error);
29
+ }
30
+ else {
31
+ controller.terminate();
32
+ }
33
+ },
34
+ });
35
+ source.pipeThrough(transform);
36
+ const readable = transform.readable;
37
+ Object.setPrototypeOf(readable, ChecksumStream_browser_1.ChecksumStream.prototype);
38
+ return readable;
39
+ };
40
+ exports.createChecksumStream = createChecksumStream;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createChecksumStream = void 0;
4
+ const stream_type_check_1 = require("../stream-type-check");
5
+ const ChecksumStream_1 = require("./ChecksumStream");
6
+ const createChecksumStream_browser_1 = require("./createChecksumStream.browser");
7
+ function createChecksumStream(init) {
8
+ if (typeof ReadableStream === "function" && (0, stream_type_check_1.isReadableStream)(init.source)) {
9
+ return (0, createChecksumStream_browser_1.createChecksumStream)(init);
10
+ }
11
+ return new ChecksumStream_1.ChecksumStream(init);
12
+ }
13
+ exports.createChecksumStream = createChecksumStream;
@@ -82,6 +82,8 @@ __reExport(src_exports, require("././sdk-stream-mixin"), module.exports);
82
82
  __reExport(src_exports, require("././splitStream"), module.exports);
83
83
  __reExport(src_exports, require("././headStream"), module.exports);
84
84
  __reExport(src_exports, require("././stream-type-check"), module.exports);
85
+ __reExport(src_exports, require("./checksum/createChecksumStream"), module.exports);
86
+ __reExport(src_exports, require("./checksum/ChecksumStream"), module.exports);
85
87
  // Annotate the CommonJS export names for ESM import in node:
86
88
 
87
89
  0 && (module.exports = {
@@ -90,6 +92,8 @@ __reExport(src_exports, require("././stream-type-check"), module.exports);
90
92
  sdkStreamMixin,
91
93
  splitStream,
92
94
  headStream,
93
- isReadableStream
95
+ isReadableStream,
96
+ createChecksumStream,
97
+ ChecksumStream
94
98
  });
95
99
 
@@ -0,0 +1,3 @@
1
+ const ReadableStreamRef = typeof ReadableStream === "function" ? ReadableStream : function () { };
2
+ export class ChecksumStream extends ReadableStreamRef {
3
+ }
@@ -0,0 +1,44 @@
1
+ import { toBase64 } from "@smithy/util-base64";
2
+ import { Duplex } from "stream";
3
+ export class ChecksumStream extends Duplex {
4
+ constructor({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder, }) {
5
+ super();
6
+ if (typeof source.pipe === "function") {
7
+ this.source = source;
8
+ }
9
+ else {
10
+ throw new Error(`@smithy/util-stream: unsupported source type ${source?.constructor?.name ?? source} in ChecksumStream.`);
11
+ }
12
+ this.base64Encoder = base64Encoder ?? toBase64;
13
+ this.expectedChecksum = expectedChecksum;
14
+ this.checksum = checksum;
15
+ this.checksumSourceLocation = checksumSourceLocation;
16
+ this.source.pipe(this);
17
+ }
18
+ _read(size) { }
19
+ _write(chunk, encoding, callback) {
20
+ try {
21
+ this.checksum.update(chunk);
22
+ this.push(chunk);
23
+ }
24
+ catch (e) {
25
+ return callback(e);
26
+ }
27
+ return callback();
28
+ }
29
+ async _final(callback) {
30
+ try {
31
+ const digest = await this.checksum.digest();
32
+ const received = this.base64Encoder(digest);
33
+ if (this.expectedChecksum !== received) {
34
+ return callback(new Error(`Checksum mismatch: expected "${this.expectedChecksum}" but received "${received}"` +
35
+ ` in response header "${this.checksumSourceLocation}".`));
36
+ }
37
+ }
38
+ catch (e) {
39
+ return callback(e);
40
+ }
41
+ this.push(null);
42
+ return callback();
43
+ }
44
+ }
@@ -0,0 +1,35 @@
1
+ import { toBase64 } from "@smithy/util-base64";
2
+ import { isReadableStream } from "../stream-type-check";
3
+ import { ChecksumStream } from "./ChecksumStream.browser";
4
+ export const createChecksumStream = ({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder, }) => {
5
+ if (!isReadableStream(source)) {
6
+ throw new Error(`@smithy/util-stream: unsupported source type ${source?.constructor?.name ?? source} in ChecksumStream.`);
7
+ }
8
+ const encoder = base64Encoder ?? toBase64;
9
+ if (typeof TransformStream !== "function") {
10
+ throw new Error("@smithy/util-stream: unable to instantiate ChecksumStream because API unavailable: ReadableStream/TransformStream.");
11
+ }
12
+ const transform = new TransformStream({
13
+ start() { },
14
+ async transform(chunk, controller) {
15
+ checksum.update(chunk);
16
+ controller.enqueue(chunk);
17
+ },
18
+ async flush(controller) {
19
+ const digest = await checksum.digest();
20
+ const received = encoder(digest);
21
+ if (expectedChecksum !== received) {
22
+ const error = new Error(`Checksum mismatch: expected "${expectedChecksum}" but received "${received}"` +
23
+ ` in response header "${checksumSourceLocation}".`);
24
+ controller.error(error);
25
+ }
26
+ else {
27
+ controller.terminate();
28
+ }
29
+ },
30
+ });
31
+ source.pipeThrough(transform);
32
+ const readable = transform.readable;
33
+ Object.setPrototypeOf(readable, ChecksumStream.prototype);
34
+ return readable;
35
+ };
@@ -0,0 +1,9 @@
1
+ import { isReadableStream } from "../stream-type-check";
2
+ import { ChecksumStream } from "./ChecksumStream";
3
+ import { createChecksumStream as createChecksumStreamWeb } from "./createChecksumStream.browser";
4
+ export function createChecksumStream(init) {
5
+ if (typeof ReadableStream === "function" && isReadableStream(init.source)) {
6
+ return createChecksumStreamWeb(init);
7
+ }
8
+ return new ChecksumStream(init);
9
+ }
@@ -4,3 +4,5 @@ export * from "./sdk-stream-mixin";
4
4
  export * from "./splitStream";
5
5
  export * from "./headStream";
6
6
  export * from "./stream-type-check";
7
+ export * from "./checksum/createChecksumStream";
8
+ export * from "./checksum/ChecksumStream";
@@ -0,0 +1,37 @@
1
+ import { Checksum, Encoder } from "@smithy/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export interface ChecksumStreamInit {
6
+ /**
7
+ * Base64 value of the expected checksum.
8
+ */
9
+ expectedChecksum: string;
10
+ /**
11
+ * For error messaging, the location from which the checksum value was read.
12
+ */
13
+ checksumSourceLocation: string;
14
+ /**
15
+ * The checksum calculator.
16
+ */
17
+ checksum: Checksum;
18
+ /**
19
+ * The stream to be checked.
20
+ */
21
+ source: ReadableStream;
22
+ /**
23
+ * Optional base 64 encoder if calling from a request context.
24
+ */
25
+ base64Encoder?: Encoder;
26
+ }
27
+ declare const ChecksumStream_base: any;
28
+ /**
29
+ * This stub exists so that the readable returned by createChecksumStream
30
+ * identifies as "ChecksumStream" in alignment with the Node.js
31
+ * implementation.
32
+ *
33
+ * @extends ReadableStream
34
+ */
35
+ export declare class ChecksumStream extends ChecksumStream_base {
36
+ }
37
+ export {};
@@ -0,0 +1,61 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Checksum, Encoder } from "@smithy/types";
4
+ import { Duplex, Readable } from "stream";
5
+ /**
6
+ * @internal
7
+ */
8
+ export interface ChecksumStreamInit<T extends Readable | ReadableStream> {
9
+ /**
10
+ * Base64 value of the expected checksum.
11
+ */
12
+ expectedChecksum: string;
13
+ /**
14
+ * For error messaging, the location from which the checksum value was read.
15
+ */
16
+ checksumSourceLocation: string;
17
+ /**
18
+ * The checksum calculator.
19
+ */
20
+ checksum: Checksum;
21
+ /**
22
+ * The stream to be checked.
23
+ */
24
+ source: T;
25
+ /**
26
+ * Optional base 64 encoder if calling from a request context.
27
+ */
28
+ base64Encoder?: Encoder;
29
+ }
30
+ /**
31
+ * @internal
32
+ *
33
+ * Wrapper for throwing checksum errors for streams without
34
+ * buffering the stream.
35
+ *
36
+ */
37
+ export declare class ChecksumStream extends Duplex {
38
+ private expectedChecksum;
39
+ private checksumSourceLocation;
40
+ private checksum;
41
+ private source?;
42
+ private base64Encoder;
43
+ constructor({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder, }: ChecksumStreamInit<Readable>);
44
+ /**
45
+ * @internal do not call this directly.
46
+ */
47
+ _read(size: number): void;
48
+ /**
49
+ * @internal do not call this directly.
50
+ *
51
+ * When the upstream source flows data to this stream,
52
+ * calculate a step update of the checksum.
53
+ */
54
+ _write(chunk: Buffer, encoding: string, callback: (err?: Error) => void): void;
55
+ /**
56
+ * @internal do not call this directly.
57
+ *
58
+ * When the upstream source finishes, perform the checksum comparison.
59
+ */
60
+ _final(callback: (err?: Error) => void): Promise<void>;
61
+ }
@@ -0,0 +1,15 @@
1
+ import { ChecksumStreamInit } from "./ChecksumStream.browser";
2
+ /**
3
+ * @internal
4
+ * Alias prevents compiler from turning
5
+ * ReadableStream into ReadableStream<any>, which is incompatible
6
+ * with the NodeJS.ReadableStream global type.
7
+ */
8
+ export type ReadableStreamType = ReadableStream;
9
+ /**
10
+ * @internal
11
+ *
12
+ * Creates a stream adapter for throwing checksum errors for streams without
13
+ * buffering the stream.
14
+ */
15
+ export declare const createChecksumStream: ({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder, }: ChecksumStreamInit) => ReadableStreamType;
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ import { Readable } from "stream";
3
+ import { ChecksumStreamInit } from "./ChecksumStream";
4
+ import { ReadableStreamType } from "./createChecksumStream.browser";
5
+ /**
6
+ * @internal
7
+ *
8
+ * Creates a stream mirroring the input stream's interface, but
9
+ * performs checksumming when reading to the end of the stream.
10
+ */
11
+ export declare function createChecksumStream(init: ChecksumStreamInit<ReadableStreamType>): ReadableStreamType;
12
+ export declare function createChecksumStream(init: ChecksumStreamInit<Readable>): Readable;
@@ -4,3 +4,5 @@ export * from "./sdk-stream-mixin";
4
4
  export * from "./splitStream";
5
5
  export * from "./headStream";
6
6
  export * from "./stream-type-check";
7
+ export * from "./checksum/createChecksumStream";
8
+ export * from "./checksum/ChecksumStream";
@@ -0,0 +1,37 @@
1
+ import { Checksum, Encoder } from "@smithy/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export interface ChecksumStreamInit {
6
+ /**
7
+ * Base64 value of the expected checksum.
8
+ */
9
+ expectedChecksum: string;
10
+ /**
11
+ * For error messaging, the location from which the checksum value was read.
12
+ */
13
+ checksumSourceLocation: string;
14
+ /**
15
+ * The checksum calculator.
16
+ */
17
+ checksum: Checksum;
18
+ /**
19
+ * The stream to be checked.
20
+ */
21
+ source: ReadableStream;
22
+ /**
23
+ * Optional base 64 encoder if calling from a request context.
24
+ */
25
+ base64Encoder?: Encoder;
26
+ }
27
+ declare const ChecksumStream_base: any;
28
+ /**
29
+ * This stub exists so that the readable returned by createChecksumStream
30
+ * identifies as "ChecksumStream" in alignment with the Node.js
31
+ * implementation.
32
+ *
33
+ * @extends ReadableStream
34
+ */
35
+ export declare class ChecksumStream extends ChecksumStream_base {
36
+ }
37
+ export {};
@@ -0,0 +1,60 @@
1
+ /// <reference types="node" />
2
+ import { Checksum, Encoder } from "@smithy/types";
3
+ import { Duplex, Readable } from "stream";
4
+ /**
5
+ * @internal
6
+ */
7
+ export interface ChecksumStreamInit<T extends Readable | ReadableStream> {
8
+ /**
9
+ * Base64 value of the expected checksum.
10
+ */
11
+ expectedChecksum: string;
12
+ /**
13
+ * For error messaging, the location from which the checksum value was read.
14
+ */
15
+ checksumSourceLocation: string;
16
+ /**
17
+ * The checksum calculator.
18
+ */
19
+ checksum: Checksum;
20
+ /**
21
+ * The stream to be checked.
22
+ */
23
+ source: T;
24
+ /**
25
+ * Optional base 64 encoder if calling from a request context.
26
+ */
27
+ base64Encoder?: Encoder;
28
+ }
29
+ /**
30
+ * @internal
31
+ *
32
+ * Wrapper for throwing checksum errors for streams without
33
+ * buffering the stream.
34
+ *
35
+ */
36
+ export declare class ChecksumStream extends Duplex {
37
+ private expectedChecksum;
38
+ private checksumSourceLocation;
39
+ private checksum;
40
+ private source?;
41
+ private base64Encoder;
42
+ constructor({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder, }: ChecksumStreamInit<Readable>);
43
+ /**
44
+ * @internal do not call this directly.
45
+ */
46
+ _read(size: number): void;
47
+ /**
48
+ * @internal do not call this directly.
49
+ *
50
+ * When the upstream source flows data to this stream,
51
+ * calculate a step update of the checksum.
52
+ */
53
+ _write(chunk: Buffer, encoding: string, callback: (err?: Error) => void): void;
54
+ /**
55
+ * @internal do not call this directly.
56
+ *
57
+ * When the upstream source finishes, perform the checksum comparison.
58
+ */
59
+ _final(callback: (err?: Error) => void): Promise<void>;
60
+ }
@@ -0,0 +1,15 @@
1
+ import { ChecksumStreamInit } from "./ChecksumStream.browser";
2
+ /**
3
+ * @internal
4
+ * Alias prevents compiler from turning
5
+ * ReadableStream into ReadableStream<any>, which is incompatible
6
+ * with the NodeJS.ReadableStream global type.
7
+ */
8
+ export type ReadableStreamType = ReadableStream;
9
+ /**
10
+ * @internal
11
+ *
12
+ * Creates a stream adapter for throwing checksum errors for streams without
13
+ * buffering the stream.
14
+ */
15
+ export declare const createChecksumStream: ({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder, }: ChecksumStreamInit) => ReadableStreamType;
@@ -0,0 +1,12 @@
1
+ /// <reference types="node" />
2
+ import { Readable } from "stream";
3
+ import { ChecksumStreamInit } from "./ChecksumStream";
4
+ import { ReadableStreamType } from "./createChecksumStream.browser";
5
+ /**
6
+ * @internal
7
+ *
8
+ * Creates a stream mirroring the input stream's interface, but
9
+ * performs checksumming when reading to the end of the stream.
10
+ */
11
+ export declare function createChecksumStream(init: ChecksumStreamInit<ReadableStreamType>): ReadableStreamType;
12
+ export declare function createChecksumStream(init: ChecksumStreamInit<Readable>): Readable;
@@ -4,3 +4,5 @@ export * from "./sdk-stream-mixin";
4
4
  export * from "./splitStream";
5
5
  export * from "./headStream";
6
6
  export * from "./stream-type-check";
7
+ export * from "./checksum/createChecksumStream";
8
+ export * from "./checksum/ChecksumStream";