From 9811b7d6389fd47b54e08735c08033d7f0bcc8a3 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:00:50 +0000 Subject: [PATCH 01/11] chore: update core tsconfig based on @tsconfig/node16 --- tsconfig.cjs.json | 9 +-------- tsconfig.es.json | 7 ++----- tsconfig.json | 7 +++++-- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json index 757be2aa643b..fc8520e73765 100644 --- a/tsconfig.cjs.json +++ b/tsconfig.cjs.json @@ -1,10 +1,3 @@ { - "extends": "./tsconfig.json", - "compilerOptions": { - "importHelpers": true, - "module": "commonjs", - "noEmitHelpers": false, - "target": "ES2018", - "strict": true - } + "extends": "./tsconfig.json" } diff --git a/tsconfig.es.json b/tsconfig.es.json index 0bb615bbace9..bb86e255de1e 100644 --- a/tsconfig.es.json +++ b/tsconfig.es.json @@ -1,10 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "importHelpers": true, - "module": "esnext", - "noEmitHelpers": false, - "target": "ES2020", - "strict": true + "lib": ["dom"], + "module": "esnext" } } diff --git a/tsconfig.json b/tsconfig.json index f81876cbdff8..86b7ce4f2025 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,8 +4,12 @@ "downlevelIteration": true, "esModuleInterop": true, "incremental": true, - "lib": ["es2015", "dom"], + "importHelpers": true, + "noEmitHelpers": false, + "strict": true, + "lib": ["es2021"], "module": "commonjs", + "target": "es2021", "moduleResolution": "node", "noFallthroughCasesInSwitch": true, "paths": { @@ -17,7 +21,6 @@ "preserveConstEnums": true, "removeComments": true, "resolveJsonModule": true, - "target": "es5", "useUnknownInCatchVariables": false, "experimentalDecorators": true, "jsx": "react", From b579950acba7e0437785cef7eb3e61208446ed8b Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Wed, 1 May 2024 23:04:59 +0000 Subject: [PATCH 02/11] chore: extend root tsconfig from @tsconfig/node16 --- tsconfig.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 86b7ce4f2025..23b53a5142d6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,11 @@ { + "extends": "@tsconfig/node16/tsconfig.json", "compilerOptions": { "baseUrl": ".", "downlevelIteration": true, - "esModuleInterop": true, "incremental": true, "importHelpers": true, "noEmitHelpers": false, - "strict": true, - "lib": ["es2021"], - "module": "commonjs", - "target": "es2021", - "moduleResolution": "node", "noFallthroughCasesInSwitch": true, "paths": { "@aws-sdk/*": ["packages/*/"], From ee2e41fbc0379b96ffb474d034c50dfef3332871 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Wed, 1 May 2024 23:14:16 +0000 Subject: [PATCH 03/11] chore: set module to commonjs and moduleResolution to node error TS2835 is thrown --- tsconfig.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tsconfig.json b/tsconfig.json index 23b53a5142d6..ad00e298aab0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,8 @@ "downlevelIteration": true, "incremental": true, "importHelpers": true, + "module": "commonjs", + "moduleResolution": "node", "noEmitHelpers": false, "noFallthroughCasesInSwitch": true, "paths": { From d37b4e3fa11c565e91fb3e9b2c539efbf43bec3c Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Thu, 2 May 2024 16:12:50 +0000 Subject: [PATCH 04/11] fix: enable isolatedModules to true in ts-jest config --- jest.config.base.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jest.config.base.js b/jest.config.base.js index 693dd2c32873..1db67fb68b85 100644 --- a/jest.config.base.js +++ b/jest.config.base.js @@ -10,6 +10,7 @@ module.exports = { ...compilerOptions, noImplicitAny: false, strictNullChecks: false, + isolatedModules: true, }, ], }, From 88b690389acff2f5b73af8ab65391d6a72bc6613 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Thu, 2 May 2024 18:04:21 +0000 Subject: [PATCH 05/11] fix: enable isolatedModules to true in ts-jest config --- packages/core/jest.config.integ.js | 3 +++ packages/credential-provider-node/jest.config.integ.js | 3 +++ packages/middleware-endpoint-discovery/jest.config.integ.js | 3 +++ packages/middleware-eventstream/jest.config.integ.js | 3 +++ packages/middleware-expect-continue/jest.config.integ.js | 3 +++ packages/middleware-flexible-checksums/jest.config.integ.js | 3 +++ packages/middleware-host-header/jest.config.integ.js | 3 +++ packages/middleware-location-constraint/jest.config.integ.js | 3 +++ packages/middleware-logger/jest.config.integ.js | 3 +++ packages/middleware-recursion-detection/jest.config.integ.js | 3 +++ packages/middleware-sdk-api-gateway/jest.config.integ.js | 3 +++ packages/middleware-sdk-ec2/jest.config.integ.js | 3 +++ packages/middleware-sdk-glacier/jest.config.integ.js | 3 +++ packages/middleware-sdk-machinelearning/jest.config.integ.js | 3 +++ packages/middleware-sdk-rds/jest.config.integ.js | 3 +++ packages/middleware-sdk-route53/jest.config.integ.js | 3 +++ packages/middleware-sdk-s3-control/jest.config.integ.js | 3 +++ packages/middleware-sdk-s3/jest.config.integ.js | 3 +++ packages/middleware-sdk-sqs/jest.config.integ.js | 3 +++ packages/middleware-sdk-sts/jest.config.integ.js | 3 +++ .../middleware-sdk-transcribe-streaming/jest.config.integ.js | 3 +++ packages/middleware-signing/jest.config.integ.js | 3 +++ packages/middleware-ssec/jest.config.integ.js | 3 +++ packages/middleware-token/jest.config.integ.js | 3 +++ packages/middleware-user-agent/jest.config.integ.js | 3 +++ packages/middleware-websocket/jest.config.integ.js | 3 +++ packages/util-endpoints/jest.config.integ.js | 3 +++ private/aws-util-test/jest.config.integ.js | 3 +++ 28 files changed, 84 insertions(+) diff --git a/packages/core/jest.config.integ.js b/packages/core/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/core/jest.config.integ.js +++ b/packages/core/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/credential-provider-node/jest.config.integ.js b/packages/credential-provider-node/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/credential-provider-node/jest.config.integ.js +++ b/packages/credential-provider-node/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-endpoint-discovery/jest.config.integ.js b/packages/middleware-endpoint-discovery/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-endpoint-discovery/jest.config.integ.js +++ b/packages/middleware-endpoint-discovery/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-eventstream/jest.config.integ.js b/packages/middleware-eventstream/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-eventstream/jest.config.integ.js +++ b/packages/middleware-eventstream/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-expect-continue/jest.config.integ.js b/packages/middleware-expect-continue/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-expect-continue/jest.config.integ.js +++ b/packages/middleware-expect-continue/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-flexible-checksums/jest.config.integ.js b/packages/middleware-flexible-checksums/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-flexible-checksums/jest.config.integ.js +++ b/packages/middleware-flexible-checksums/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-host-header/jest.config.integ.js b/packages/middleware-host-header/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-host-header/jest.config.integ.js +++ b/packages/middleware-host-header/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-location-constraint/jest.config.integ.js b/packages/middleware-location-constraint/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-location-constraint/jest.config.integ.js +++ b/packages/middleware-location-constraint/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-logger/jest.config.integ.js b/packages/middleware-logger/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-logger/jest.config.integ.js +++ b/packages/middleware-logger/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-recursion-detection/jest.config.integ.js b/packages/middleware-recursion-detection/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-recursion-detection/jest.config.integ.js +++ b/packages/middleware-recursion-detection/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-sdk-api-gateway/jest.config.integ.js b/packages/middleware-sdk-api-gateway/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-sdk-api-gateway/jest.config.integ.js +++ b/packages/middleware-sdk-api-gateway/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-sdk-ec2/jest.config.integ.js b/packages/middleware-sdk-ec2/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-sdk-ec2/jest.config.integ.js +++ b/packages/middleware-sdk-ec2/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-sdk-glacier/jest.config.integ.js b/packages/middleware-sdk-glacier/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-sdk-glacier/jest.config.integ.js +++ b/packages/middleware-sdk-glacier/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-sdk-machinelearning/jest.config.integ.js b/packages/middleware-sdk-machinelearning/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-sdk-machinelearning/jest.config.integ.js +++ b/packages/middleware-sdk-machinelearning/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-sdk-rds/jest.config.integ.js b/packages/middleware-sdk-rds/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-sdk-rds/jest.config.integ.js +++ b/packages/middleware-sdk-rds/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-sdk-route53/jest.config.integ.js b/packages/middleware-sdk-route53/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-sdk-route53/jest.config.integ.js +++ b/packages/middleware-sdk-route53/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-sdk-s3-control/jest.config.integ.js b/packages/middleware-sdk-s3-control/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-sdk-s3-control/jest.config.integ.js +++ b/packages/middleware-sdk-s3-control/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-sdk-s3/jest.config.integ.js b/packages/middleware-sdk-s3/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-sdk-s3/jest.config.integ.js +++ b/packages/middleware-sdk-s3/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-sdk-sqs/jest.config.integ.js b/packages/middleware-sdk-sqs/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-sdk-sqs/jest.config.integ.js +++ b/packages/middleware-sdk-sqs/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-sdk-sts/jest.config.integ.js b/packages/middleware-sdk-sts/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-sdk-sts/jest.config.integ.js +++ b/packages/middleware-sdk-sts/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-sdk-transcribe-streaming/jest.config.integ.js b/packages/middleware-sdk-transcribe-streaming/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-sdk-transcribe-streaming/jest.config.integ.js +++ b/packages/middleware-sdk-transcribe-streaming/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-signing/jest.config.integ.js b/packages/middleware-signing/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-signing/jest.config.integ.js +++ b/packages/middleware-signing/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-ssec/jest.config.integ.js b/packages/middleware-ssec/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-ssec/jest.config.integ.js +++ b/packages/middleware-ssec/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-token/jest.config.integ.js b/packages/middleware-token/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-token/jest.config.integ.js +++ b/packages/middleware-token/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-user-agent/jest.config.integ.js b/packages/middleware-user-agent/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-user-agent/jest.config.integ.js +++ b/packages/middleware-user-agent/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/middleware-websocket/jest.config.integ.js b/packages/middleware-websocket/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/middleware-websocket/jest.config.integ.js +++ b/packages/middleware-websocket/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/packages/util-endpoints/jest.config.integ.js b/packages/util-endpoints/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/packages/util-endpoints/jest.config.integ.js +++ b/packages/util-endpoints/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; diff --git a/private/aws-util-test/jest.config.integ.js b/private/aws-util-test/jest.config.integ.js index d09aba7398c7..5406924a53d9 100644 --- a/private/aws-util-test/jest.config.integ.js +++ b/private/aws-util-test/jest.config.integ.js @@ -1,4 +1,7 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], + transform: { + "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], + }, }; From 4997d3ac3173a2c12bea2c35b5d3391b29abb5b9 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Thu, 2 May 2024 18:34:04 +0000 Subject: [PATCH 06/11] fix: revert enable isolatedModules to true in ts-jest config This reverts commit 19b7e0d590418376eb7fb6d870420b12324b9d1e. --- jest.config.base.js | 1 - 1 file changed, 1 deletion(-) diff --git a/jest.config.base.js b/jest.config.base.js index 1db67fb68b85..693dd2c32873 100644 --- a/jest.config.base.js +++ b/jest.config.base.js @@ -10,7 +10,6 @@ module.exports = { ...compilerOptions, noImplicitAny: false, strictNullChecks: false, - isolatedModules: true, }, ], }, From 2a9826eb7c6aeadbcb35000b3582758e0e87a970 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Thu, 2 May 2024 18:34:52 +0000 Subject: [PATCH 07/11] fix: revert enable isolatedModules to true in ts-jest config This reverts commit 2c33f0b87303c4ee3a037ee9bf3cb89beca3fe4f. --- packages/core/jest.config.integ.js | 3 --- packages/credential-provider-node/jest.config.integ.js | 3 --- packages/middleware-endpoint-discovery/jest.config.integ.js | 3 --- packages/middleware-eventstream/jest.config.integ.js | 3 --- packages/middleware-expect-continue/jest.config.integ.js | 3 --- packages/middleware-flexible-checksums/jest.config.integ.js | 3 --- packages/middleware-host-header/jest.config.integ.js | 3 --- packages/middleware-location-constraint/jest.config.integ.js | 3 --- packages/middleware-logger/jest.config.integ.js | 3 --- packages/middleware-recursion-detection/jest.config.integ.js | 3 --- packages/middleware-sdk-api-gateway/jest.config.integ.js | 3 --- packages/middleware-sdk-ec2/jest.config.integ.js | 3 --- packages/middleware-sdk-glacier/jest.config.integ.js | 3 --- packages/middleware-sdk-machinelearning/jest.config.integ.js | 3 --- packages/middleware-sdk-rds/jest.config.integ.js | 3 --- packages/middleware-sdk-route53/jest.config.integ.js | 3 --- packages/middleware-sdk-s3-control/jest.config.integ.js | 3 --- packages/middleware-sdk-s3/jest.config.integ.js | 3 --- packages/middleware-sdk-sqs/jest.config.integ.js | 3 --- packages/middleware-sdk-sts/jest.config.integ.js | 3 --- .../middleware-sdk-transcribe-streaming/jest.config.integ.js | 3 --- packages/middleware-signing/jest.config.integ.js | 3 --- packages/middleware-ssec/jest.config.integ.js | 3 --- packages/middleware-token/jest.config.integ.js | 3 --- packages/middleware-user-agent/jest.config.integ.js | 3 --- packages/middleware-websocket/jest.config.integ.js | 3 --- packages/util-endpoints/jest.config.integ.js | 3 --- private/aws-util-test/jest.config.integ.js | 3 --- 28 files changed, 84 deletions(-) diff --git a/packages/core/jest.config.integ.js b/packages/core/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/core/jest.config.integ.js +++ b/packages/core/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/credential-provider-node/jest.config.integ.js b/packages/credential-provider-node/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/credential-provider-node/jest.config.integ.js +++ b/packages/credential-provider-node/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-endpoint-discovery/jest.config.integ.js b/packages/middleware-endpoint-discovery/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-endpoint-discovery/jest.config.integ.js +++ b/packages/middleware-endpoint-discovery/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-eventstream/jest.config.integ.js b/packages/middleware-eventstream/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-eventstream/jest.config.integ.js +++ b/packages/middleware-eventstream/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-expect-continue/jest.config.integ.js b/packages/middleware-expect-continue/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-expect-continue/jest.config.integ.js +++ b/packages/middleware-expect-continue/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-flexible-checksums/jest.config.integ.js b/packages/middleware-flexible-checksums/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-flexible-checksums/jest.config.integ.js +++ b/packages/middleware-flexible-checksums/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-host-header/jest.config.integ.js b/packages/middleware-host-header/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-host-header/jest.config.integ.js +++ b/packages/middleware-host-header/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-location-constraint/jest.config.integ.js b/packages/middleware-location-constraint/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-location-constraint/jest.config.integ.js +++ b/packages/middleware-location-constraint/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-logger/jest.config.integ.js b/packages/middleware-logger/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-logger/jest.config.integ.js +++ b/packages/middleware-logger/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-recursion-detection/jest.config.integ.js b/packages/middleware-recursion-detection/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-recursion-detection/jest.config.integ.js +++ b/packages/middleware-recursion-detection/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-sdk-api-gateway/jest.config.integ.js b/packages/middleware-sdk-api-gateway/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-sdk-api-gateway/jest.config.integ.js +++ b/packages/middleware-sdk-api-gateway/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-sdk-ec2/jest.config.integ.js b/packages/middleware-sdk-ec2/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-sdk-ec2/jest.config.integ.js +++ b/packages/middleware-sdk-ec2/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-sdk-glacier/jest.config.integ.js b/packages/middleware-sdk-glacier/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-sdk-glacier/jest.config.integ.js +++ b/packages/middleware-sdk-glacier/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-sdk-machinelearning/jest.config.integ.js b/packages/middleware-sdk-machinelearning/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-sdk-machinelearning/jest.config.integ.js +++ b/packages/middleware-sdk-machinelearning/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-sdk-rds/jest.config.integ.js b/packages/middleware-sdk-rds/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-sdk-rds/jest.config.integ.js +++ b/packages/middleware-sdk-rds/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-sdk-route53/jest.config.integ.js b/packages/middleware-sdk-route53/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-sdk-route53/jest.config.integ.js +++ b/packages/middleware-sdk-route53/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-sdk-s3-control/jest.config.integ.js b/packages/middleware-sdk-s3-control/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-sdk-s3-control/jest.config.integ.js +++ b/packages/middleware-sdk-s3-control/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-sdk-s3/jest.config.integ.js b/packages/middleware-sdk-s3/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-sdk-s3/jest.config.integ.js +++ b/packages/middleware-sdk-s3/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-sdk-sqs/jest.config.integ.js b/packages/middleware-sdk-sqs/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-sdk-sqs/jest.config.integ.js +++ b/packages/middleware-sdk-sqs/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-sdk-sts/jest.config.integ.js b/packages/middleware-sdk-sts/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-sdk-sts/jest.config.integ.js +++ b/packages/middleware-sdk-sts/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-sdk-transcribe-streaming/jest.config.integ.js b/packages/middleware-sdk-transcribe-streaming/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-sdk-transcribe-streaming/jest.config.integ.js +++ b/packages/middleware-sdk-transcribe-streaming/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-signing/jest.config.integ.js b/packages/middleware-signing/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-signing/jest.config.integ.js +++ b/packages/middleware-signing/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-ssec/jest.config.integ.js b/packages/middleware-ssec/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-ssec/jest.config.integ.js +++ b/packages/middleware-ssec/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-token/jest.config.integ.js b/packages/middleware-token/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-token/jest.config.integ.js +++ b/packages/middleware-token/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-user-agent/jest.config.integ.js b/packages/middleware-user-agent/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-user-agent/jest.config.integ.js +++ b/packages/middleware-user-agent/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/middleware-websocket/jest.config.integ.js b/packages/middleware-websocket/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/middleware-websocket/jest.config.integ.js +++ b/packages/middleware-websocket/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/packages/util-endpoints/jest.config.integ.js b/packages/util-endpoints/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/packages/util-endpoints/jest.config.integ.js +++ b/packages/util-endpoints/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; diff --git a/private/aws-util-test/jest.config.integ.js b/private/aws-util-test/jest.config.integ.js index 5406924a53d9..d09aba7398c7 100644 --- a/private/aws-util-test/jest.config.integ.js +++ b/private/aws-util-test/jest.config.integ.js @@ -1,7 +1,4 @@ module.exports = { preset: "ts-jest", testMatch: ["**/*.integ.spec.ts"], - transform: { - "^.+\\.tsx?$": ["ts-jest", { isolatedModules: true }], - }, }; From 61b856921b4caaab0f52b07b6bc1528dfb2a520c Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Tue, 7 May 2024 20:59:36 +0000 Subject: [PATCH 08/11] test(util-dynamodb): remove ts-expect-error checks for BigInt --- packages/util-dynamodb/src/convertToAttr.spec.ts | 7 ------- packages/util-dynamodb/src/convertToAttrToNative.spec.ts | 3 --- 2 files changed, 10 deletions(-) diff --git a/packages/util-dynamodb/src/convertToAttr.spec.ts b/packages/util-dynamodb/src/convertToAttr.spec.ts index 07e77655522f..4c9f3a90f576 100644 --- a/packages/util-dynamodb/src/convertToAttr.spec.ts +++ b/packages/util-dynamodb/src/convertToAttr.spec.ts @@ -99,11 +99,8 @@ describe("convertToAttr", () => { [true, false].forEach((convertClassInstanceToMap) => { const maxSafe = BigInt(Number.MAX_SAFE_INTEGER); [ - // @ts-expect-error BigInt literals are not available when targeting lower than ES2020. 1n, - // @ts-expect-error BigInt literals are not available when targeting lower than ES2020. maxSafe * 2n, - // @ts-expect-error BigInt literals are not available when targeting lower than ES2020. maxSafe * -2n, BigInt(Number.MAX_VALUE), BigInt("0x1fffffffffffff"), @@ -120,11 +117,8 @@ describe("convertToAttr", () => { [true, false].forEach((convertClassInstanceToMap) => { const maxSafe = BigInt(Number.MAX_SAFE_INTEGER); [ - // @ts-expect-error BigInt literals are not available when targeting lower than ES2020. 1n, - // @ts-expect-error BigInt literals are not available when targeting lower than ES2020. maxSafe * 2n, - // @ts-expect-error BigInt literals are not available when targeting lower than ES2020. maxSafe * -2n, BigInt(Number.MAX_VALUE), BigInt("0x1fffffffffffff"), @@ -263,7 +257,6 @@ describe("convertToAttr", () => { }); it("bigint set", () => { - // @ts-expect-error BigInt literals are not available when targeting lower than ES2020. const bigNum = BigInt(Number.MAX_SAFE_INTEGER) + 2n; const set = new Set([bigNum, -bigNum]); expect(convertToAttr(set)).toEqual({ NS: Array.from(set).map((num) => num.toString()) }); diff --git a/packages/util-dynamodb/src/convertToAttrToNative.spec.ts b/packages/util-dynamodb/src/convertToAttrToNative.spec.ts index 9a1b1b540809..f9a2116eff15 100644 --- a/packages/util-dynamodb/src/convertToAttrToNative.spec.ts +++ b/packages/util-dynamodb/src/convertToAttrToNative.spec.ts @@ -45,9 +45,7 @@ describe("convertToAttrToNative", () => { describe("bigint", () => { const maxSafe = BigInt(Number.MAX_SAFE_INTEGER); [ - // @ts-expect-error BigInt literals are not available when targeting lower than ES2020. maxSafe * 2n, - // @ts-expect-error BigInt literals are not available when targeting lower than ES2020. maxSafe * -2n, BigInt(Number.MAX_VALUE), BigInt("0x1fffffffffffffff"), @@ -147,7 +145,6 @@ describe("convertToAttrToNative", () => { }); describe("bigint set", () => { - // @ts-expect-error BigInt literals are not available when targeting lower than ES2020. const bigNum = BigInt(Number.MAX_SAFE_INTEGER) + 2n; const set = new Set([bigNum, -bigNum]); From 5d1fef70d61668676648f417586a090a39dbd6da Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Tue, 7 May 2024 21:59:15 +0000 Subject: [PATCH 09/11] chore(core): dist folders with tsconfig from main --- .../client/emitWarningIfUnsupportedVersion.js | 1 + packages/core/distcjs/client/index.js | 1 + .../aws_sdk/AwsSdkSigV4Signer.js | 1 + .../distcjs/httpAuthSchemes/aws_sdk/index.js | 1 + .../aws_sdk/resolveAwsSdkSigV4Config.js | 1 + .../core/distcjs/httpAuthSchemes/index.js | 1 + .../httpAuthSchemes/utils/getDateHeader.js | 1 + .../utils/getSkewCorrectedDate.js | 1 + .../utils/getUpdatedSystemClockOffset.js | 1 + .../distcjs/httpAuthSchemes/utils/index.js | 1 + .../httpAuthSchemes/utils/isClockSkewed.js | 1 + packages/core/distcjs/index.js | 466 ++++++++++++++++++ .../distcjs/protocols/coercing-serializers.js | 1 + packages/core/distcjs/protocols/common.js | 1 + packages/core/distcjs/protocols/index.js | 1 + .../distcjs/protocols/json/awsExpectUnion.js | 1 + .../distcjs/protocols/json/parseJsonBody.js | 1 + .../distcjs/protocols/xml/parseXmlBody.js | 1 + .../client/emitWarningIfUnsupportedVersion.js | 6 + packages/core/distes/client/index.js | 1 + .../aws_sdk/AwsSdkSigV4Signer.js | 60 +++ .../distes/httpAuthSchemes/aws_sdk/index.js | 2 + .../aws_sdk/resolveAwsSdkSigV4Config.js | 93 ++++ packages/core/distes/httpAuthSchemes/index.js | 1 + .../httpAuthSchemes/utils/getDateHeader.js | 3 + .../utils/getSkewCorrectedDate.js | 1 + .../utils/getUpdatedSystemClockOffset.js | 8 + .../distes/httpAuthSchemes/utils/index.js | 3 + .../httpAuthSchemes/utils/isClockSkewed.js | 3 + packages/core/distes/index.js | 3 + .../distes/protocols/coercing-serializers.js | 53 ++ packages/core/distes/protocols/common.js | 3 + packages/core/distes/protocols/index.js | 4 + .../distes/protocols/json/awsExpectUnion.js | 10 + .../distes/protocols/json/parseJsonBody.js | 51 ++ .../core/distes/protocols/xml/parseXmlBody.js | 57 +++ 36 files changed, 845 insertions(+) create mode 100644 packages/core/distcjs/client/emitWarningIfUnsupportedVersion.js create mode 100644 packages/core/distcjs/client/index.js create mode 100644 packages/core/distcjs/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js create mode 100644 packages/core/distcjs/httpAuthSchemes/aws_sdk/index.js create mode 100644 packages/core/distcjs/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js create mode 100644 packages/core/distcjs/httpAuthSchemes/index.js create mode 100644 packages/core/distcjs/httpAuthSchemes/utils/getDateHeader.js create mode 100644 packages/core/distcjs/httpAuthSchemes/utils/getSkewCorrectedDate.js create mode 100644 packages/core/distcjs/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js create mode 100644 packages/core/distcjs/httpAuthSchemes/utils/index.js create mode 100644 packages/core/distcjs/httpAuthSchemes/utils/isClockSkewed.js create mode 100644 packages/core/distcjs/index.js create mode 100644 packages/core/distcjs/protocols/coercing-serializers.js create mode 100644 packages/core/distcjs/protocols/common.js create mode 100644 packages/core/distcjs/protocols/index.js create mode 100644 packages/core/distcjs/protocols/json/awsExpectUnion.js create mode 100644 packages/core/distcjs/protocols/json/parseJsonBody.js create mode 100644 packages/core/distcjs/protocols/xml/parseXmlBody.js create mode 100644 packages/core/distes/client/emitWarningIfUnsupportedVersion.js create mode 100644 packages/core/distes/client/index.js create mode 100644 packages/core/distes/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js create mode 100644 packages/core/distes/httpAuthSchemes/aws_sdk/index.js create mode 100644 packages/core/distes/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js create mode 100644 packages/core/distes/httpAuthSchemes/index.js create mode 100644 packages/core/distes/httpAuthSchemes/utils/getDateHeader.js create mode 100644 packages/core/distes/httpAuthSchemes/utils/getSkewCorrectedDate.js create mode 100644 packages/core/distes/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js create mode 100644 packages/core/distes/httpAuthSchemes/utils/index.js create mode 100644 packages/core/distes/httpAuthSchemes/utils/isClockSkewed.js create mode 100644 packages/core/distes/index.js create mode 100644 packages/core/distes/protocols/coercing-serializers.js create mode 100644 packages/core/distes/protocols/common.js create mode 100644 packages/core/distes/protocols/index.js create mode 100644 packages/core/distes/protocols/json/awsExpectUnion.js create mode 100644 packages/core/distes/protocols/json/parseJsonBody.js create mode 100644 packages/core/distes/protocols/xml/parseXmlBody.js diff --git a/packages/core/distcjs/client/emitWarningIfUnsupportedVersion.js b/packages/core/distcjs/client/emitWarningIfUnsupportedVersion.js new file mode 100644 index 000000000000..fa1ab10d97dc --- /dev/null +++ b/packages/core/distcjs/client/emitWarningIfUnsupportedVersion.js @@ -0,0 +1 @@ +module.exports = require("../index.js"); diff --git a/packages/core/distcjs/client/index.js b/packages/core/distcjs/client/index.js new file mode 100644 index 000000000000..fa1ab10d97dc --- /dev/null +++ b/packages/core/distcjs/client/index.js @@ -0,0 +1 @@ +module.exports = require("../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js b/packages/core/distcjs/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js new file mode 100644 index 000000000000..ecafff3570ff --- /dev/null +++ b/packages/core/distcjs/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js @@ -0,0 +1 @@ +module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/aws_sdk/index.js b/packages/core/distcjs/httpAuthSchemes/aws_sdk/index.js new file mode 100644 index 000000000000..ecafff3570ff --- /dev/null +++ b/packages/core/distcjs/httpAuthSchemes/aws_sdk/index.js @@ -0,0 +1 @@ +module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js b/packages/core/distcjs/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js new file mode 100644 index 000000000000..ecafff3570ff --- /dev/null +++ b/packages/core/distcjs/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js @@ -0,0 +1 @@ +module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/index.js b/packages/core/distcjs/httpAuthSchemes/index.js new file mode 100644 index 000000000000..fa1ab10d97dc --- /dev/null +++ b/packages/core/distcjs/httpAuthSchemes/index.js @@ -0,0 +1 @@ +module.exports = require("../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/utils/getDateHeader.js b/packages/core/distcjs/httpAuthSchemes/utils/getDateHeader.js new file mode 100644 index 000000000000..ecafff3570ff --- /dev/null +++ b/packages/core/distcjs/httpAuthSchemes/utils/getDateHeader.js @@ -0,0 +1 @@ +module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/utils/getSkewCorrectedDate.js b/packages/core/distcjs/httpAuthSchemes/utils/getSkewCorrectedDate.js new file mode 100644 index 000000000000..ecafff3570ff --- /dev/null +++ b/packages/core/distcjs/httpAuthSchemes/utils/getSkewCorrectedDate.js @@ -0,0 +1 @@ +module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js b/packages/core/distcjs/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js new file mode 100644 index 000000000000..ecafff3570ff --- /dev/null +++ b/packages/core/distcjs/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js @@ -0,0 +1 @@ +module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/utils/index.js b/packages/core/distcjs/httpAuthSchemes/utils/index.js new file mode 100644 index 000000000000..ecafff3570ff --- /dev/null +++ b/packages/core/distcjs/httpAuthSchemes/utils/index.js @@ -0,0 +1 @@ +module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/utils/isClockSkewed.js b/packages/core/distcjs/httpAuthSchemes/utils/isClockSkewed.js new file mode 100644 index 000000000000..ecafff3570ff --- /dev/null +++ b/packages/core/distcjs/httpAuthSchemes/utils/isClockSkewed.js @@ -0,0 +1 @@ +module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/index.js b/packages/core/distcjs/index.js new file mode 100644 index 000000000000..3637eee66b9a --- /dev/null +++ b/packages/core/distcjs/index.js @@ -0,0 +1,466 @@ +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); +var __export = (target, all) => { + for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if ((from && typeof from === "object") || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { + get: () => from[key], + enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable, + }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/index.ts +var src_exports = {}; +__export(src_exports, { + AWSSDKSigV4Signer: () => AWSSDKSigV4Signer, + AwsSdkSigV4Signer: () => AwsSdkSigV4Signer, + _toBool: () => _toBool, + _toNum: () => _toNum, + _toStr: () => _toStr, + awsExpectUnion: () => awsExpectUnion, + emitWarningIfUnsupportedVersion: () => emitWarningIfUnsupportedVersion, + loadRestJsonErrorCode: () => loadRestJsonErrorCode, + loadRestXmlErrorCode: () => loadRestXmlErrorCode, + parseJsonBody: () => parseJsonBody, + parseJsonErrorBody: () => parseJsonErrorBody, + parseXmlBody: () => parseXmlBody, + parseXmlErrorBody: () => parseXmlErrorBody, + resolveAWSSDKSigV4Config: () => resolveAWSSDKSigV4Config, + resolveAwsSdkSigV4Config: () => resolveAwsSdkSigV4Config, +}); +module.exports = __toCommonJS(src_exports); + +// src/client/emitWarningIfUnsupportedVersion.ts +var warningEmitted = false; +var emitWarningIfUnsupportedVersion = /* @__PURE__ */ __name((version) => { + if (version && !warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 16) { + warningEmitted = true; + } +}, "emitWarningIfUnsupportedVersion"); + +// src/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.ts + +// src/httpAuthSchemes/utils/getDateHeader.ts +var import_protocol_http = require("@smithy/protocol-http"); +var getDateHeader = /* @__PURE__ */ __name((response) => { + var _a, _b; + return import_protocol_http.HttpResponse.isInstance(response) + ? ((_a = response.headers) == null ? void 0 : _a.date) ?? ((_b = response.headers) == null ? void 0 : _b.Date) + : void 0; +}, "getDateHeader"); + +// src/httpAuthSchemes/utils/getSkewCorrectedDate.ts +var getSkewCorrectedDate = /* @__PURE__ */ __name( + (systemClockOffset) => new Date(Date.now() + systemClockOffset), + "getSkewCorrectedDate" +); + +// src/httpAuthSchemes/utils/isClockSkewed.ts +var isClockSkewed = /* @__PURE__ */ __name( + (clockTime, systemClockOffset) => Math.abs(getSkewCorrectedDate(systemClockOffset).getTime() - clockTime) >= 3e5, + "isClockSkewed" +); + +// src/httpAuthSchemes/utils/getUpdatedSystemClockOffset.ts +var getUpdatedSystemClockOffset = /* @__PURE__ */ __name((clockTime, currentSystemClockOffset) => { + const clockTimeInMs = Date.parse(clockTime); + if (isClockSkewed(clockTimeInMs, currentSystemClockOffset)) { + return clockTimeInMs - Date.now(); + } + return currentSystemClockOffset; +}, "getUpdatedSystemClockOffset"); + +// src/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.ts +var throwSigningPropertyError = /* @__PURE__ */ __name((name, property) => { + if (!property) { + throw new Error(`Property \`${name}\` is not resolved for AWS SDK SigV4Auth`); + } + return property; +}, "throwSigningPropertyError"); +var validateSigningProperties = /* @__PURE__ */ __name(async (signingProperties) => { + var _a, _b, _c; + const context = throwSigningPropertyError("context", signingProperties.context); + const config = throwSigningPropertyError("config", signingProperties.config); + const authScheme = + (_c = (_b = (_a = context.endpointV2) == null ? void 0 : _a.properties) == null ? void 0 : _b.authSchemes) == null + ? void 0 + : _c[0]; + const signerFunction = throwSigningPropertyError("signer", config.signer); + const signer = await signerFunction(authScheme); + const signingRegion = signingProperties == null ? void 0 : signingProperties.signingRegion; + const signingName = signingProperties == null ? void 0 : signingProperties.signingName; + return { + config, + signer, + signingRegion, + signingName, + }; +}, "validateSigningProperties"); +var _AwsSdkSigV4Signer = class _AwsSdkSigV4Signer { + async sign(httpRequest, identity, signingProperties) { + if (!import_protocol_http.HttpRequest.isInstance(httpRequest)) { + throw new Error("The request is not an instance of `HttpRequest` and cannot be signed"); + } + const { config, signer, signingRegion, signingName } = await validateSigningProperties(signingProperties); + const signedRequest = await signer.sign(httpRequest, { + signingDate: getSkewCorrectedDate(config.systemClockOffset), + signingRegion, + signingService: signingName, + }); + return signedRequest; + } + errorHandler(signingProperties) { + return (error) => { + const serverTime = error.ServerTime ?? getDateHeader(error.$response); + if (serverTime) { + const config = throwSigningPropertyError("config", signingProperties.config); + const initialSystemClockOffset = config.systemClockOffset; + config.systemClockOffset = getUpdatedSystemClockOffset(serverTime, config.systemClockOffset); + const clockSkewCorrected = config.systemClockOffset !== initialSystemClockOffset; + if (clockSkewCorrected && error.$metadata) { + error.$metadata.clockSkewCorrected = true; + } + } + throw error; + }; + } + successHandler(httpResponse, signingProperties) { + const dateHeader = getDateHeader(httpResponse); + if (dateHeader) { + const config = throwSigningPropertyError("config", signingProperties.config); + config.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, config.systemClockOffset); + } + } +}; +__name(_AwsSdkSigV4Signer, "AwsSdkSigV4Signer"); +var AwsSdkSigV4Signer = _AwsSdkSigV4Signer; +var AWSSDKSigV4Signer = AwsSdkSigV4Signer; + +// src/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.ts +var import_core = require("@smithy/core"); +var import_signature_v4 = require("@smithy/signature-v4"); +var resolveAwsSdkSigV4Config = /* @__PURE__ */ __name((config) => { + let normalizedCreds; + if (config.credentials) { + normalizedCreds = (0, import_core.memoizeIdentityProvider)( + config.credentials, + import_core.isIdentityExpired, + import_core.doesIdentityRequireRefresh + ); + } + if (!normalizedCreds) { + if (config.credentialDefaultProvider) { + normalizedCreds = (0, import_core.normalizeProvider)( + config.credentialDefaultProvider( + Object.assign({}, config, { + parentClientConfig: config, + }) + ) + ); + } else { + normalizedCreds = /* @__PURE__ */ __name(async () => { + throw new Error("`credentials` is missing"); + }, "normalizedCreds"); + } + } + const { + // Default for signingEscapePath + signingEscapePath = true, + // Default for systemClockOffset + systemClockOffset = config.systemClockOffset || 0, + // No default for sha256 since it is platform dependent + sha256, + } = config; + let signer; + if (config.signer) { + signer = (0, import_core.normalizeProvider)(config.signer); + } else if (config.regionInfoProvider) { + signer = /* @__PURE__ */ __name( + () => + (0, import_core.normalizeProvider)(config.region)() + .then(async (region) => [ + (await config.regionInfoProvider(region, { + useFipsEndpoint: await config.useFipsEndpoint(), + useDualstackEndpoint: await config.useDualstackEndpoint(), + })) || {}, + region, + ]) + .then(([regionInfo, region]) => { + const { signingRegion, signingService } = regionInfo; + config.signingRegion = config.signingRegion || signingRegion || region; + config.signingName = config.signingName || signingService || config.serviceId; + const params = { + ...config, + credentials: normalizedCreds, + region: config.signingRegion, + service: config.signingName, + sha256, + uriEscapePath: signingEscapePath, + }; + const SignerCtor = config.signerConstructor || import_signature_v4.SignatureV4; + return new SignerCtor(params); + }), + "signer" + ); + } else { + signer = /* @__PURE__ */ __name(async (authScheme) => { + authScheme = Object.assign( + {}, + { + name: "sigv4", + signingName: config.signingName || config.defaultSigningName, + signingRegion: await (0, import_core.normalizeProvider)(config.region)(), + properties: {}, + }, + authScheme + ); + const signingRegion = authScheme.signingRegion; + const signingService = authScheme.signingName; + config.signingRegion = config.signingRegion || signingRegion; + config.signingName = config.signingName || signingService || config.serviceId; + const params = { + ...config, + credentials: normalizedCreds, + region: config.signingRegion, + service: config.signingName, + sha256, + uriEscapePath: signingEscapePath, + }; + const SignerCtor = config.signerConstructor || import_signature_v4.SignatureV4; + return new SignerCtor(params); + }, "signer"); + } + return { + ...config, + systemClockOffset, + signingEscapePath, + credentials: normalizedCreds, + signer, + }; +}, "resolveAwsSdkSigV4Config"); +var resolveAWSSDKSigV4Config = resolveAwsSdkSigV4Config; + +// src/protocols/coercing-serializers.ts +var _toStr = /* @__PURE__ */ __name((val) => { + if (val == null) { + return val; + } + if (typeof val === "number" || typeof val === "bigint") { + const warning = new Error(`Received number ${val} where a string was expected.`); + warning.name = "Warning"; + console.warn(warning); + return String(val); + } + if (typeof val === "boolean") { + const warning = new Error(`Received boolean ${val} where a string was expected.`); + warning.name = "Warning"; + console.warn(warning); + return String(val); + } + return val; +}, "_toStr"); +var _toBool = /* @__PURE__ */ __name((val) => { + if (val == null) { + return val; + } + if (typeof val === "number") { + } + if (typeof val === "string") { + const lowercase = val.toLowerCase(); + if (val !== "" && lowercase !== "false" && lowercase !== "true") { + const warning = new Error(`Received string "${val}" where a boolean was expected.`); + warning.name = "Warning"; + console.warn(warning); + } + return val !== "" && lowercase !== "false"; + } + return val; +}, "_toBool"); +var _toNum = /* @__PURE__ */ __name((val) => { + if (val == null) { + return val; + } + if (typeof val === "boolean") { + } + if (typeof val === "string") { + const num = Number(val); + if (num.toString() !== val) { + const warning = new Error(`Received string "${val}" where a number was expected.`); + warning.name = "Warning"; + console.warn(warning); + return val; + } + return num; + } + return val; +}, "_toNum"); + +// src/protocols/json/awsExpectUnion.ts +var import_smithy_client = require("@smithy/smithy-client"); +var awsExpectUnion = /* @__PURE__ */ __name((value) => { + if (value == null) { + return void 0; + } + if (typeof value === "object" && "__type" in value) { + delete value.__type; + } + return (0, import_smithy_client.expectUnion)(value); +}, "awsExpectUnion"); + +// src/protocols/common.ts + +var collectBodyString = /* @__PURE__ */ __name( + (streamBody, context) => + (0, import_smithy_client.collectBody)(streamBody, context).then((body) => context.utf8Encoder(body)), + "collectBodyString" +); + +// src/protocols/json/parseJsonBody.ts +var parseJsonBody = /* @__PURE__ */ __name( + (streamBody, context) => + collectBodyString(streamBody, context).then((encoded) => { + if (encoded.length) { + try { + return JSON.parse(encoded); + } catch (e) { + if ((e == null ? void 0 : e.name) === "SyntaxError") { + Object.defineProperty(e, "$responseBodyText", { + value: encoded, + }); + } + throw e; + } + } + return {}; + }), + "parseJsonBody" +); +var parseJsonErrorBody = /* @__PURE__ */ __name(async (errorBody, context) => { + const value = await parseJsonBody(errorBody, context); + value.message = value.message ?? value.Message; + return value; +}, "parseJsonErrorBody"); +var loadRestJsonErrorCode = /* @__PURE__ */ __name((output, data) => { + const findKey = /* @__PURE__ */ __name( + (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()), + "findKey" + ); + const sanitizeErrorCode = /* @__PURE__ */ __name((rawValue) => { + let cleanValue = rawValue; + if (typeof cleanValue === "number") { + cleanValue = cleanValue.toString(); + } + if (cleanValue.indexOf(",") >= 0) { + cleanValue = cleanValue.split(",")[0]; + } + if (cleanValue.indexOf(":") >= 0) { + cleanValue = cleanValue.split(":")[0]; + } + if (cleanValue.indexOf("#") >= 0) { + cleanValue = cleanValue.split("#")[1]; + } + return cleanValue; + }, "sanitizeErrorCode"); + const headerKey = findKey(output.headers, "x-amzn-errortype"); + if (headerKey !== void 0) { + return sanitizeErrorCode(output.headers[headerKey]); + } + if (data.code !== void 0) { + return sanitizeErrorCode(data.code); + } + if (data["__type"] !== void 0) { + return sanitizeErrorCode(data["__type"]); + } +}, "loadRestJsonErrorCode"); + +// src/protocols/xml/parseXmlBody.ts + +var import_fast_xml_parser = require("fast-xml-parser"); +var parseXmlBody = /* @__PURE__ */ __name( + (streamBody, context) => + collectBodyString(streamBody, context).then((encoded) => { + if (encoded.length) { + const parser = new import_fast_xml_parser.XMLParser({ + attributeNamePrefix: "", + htmlEntities: true, + ignoreAttributes: false, + ignoreDeclaration: true, + parseTagValue: false, + trimValues: false, + tagValueProcessor: (_, val) => (val.trim() === "" && val.includes("\n") ? "" : void 0), + }); + parser.addEntity("#xD", "\r"); + parser.addEntity("#10", "\n"); + let parsedObj; + try { + parsedObj = parser.parse(encoded, true); + } catch (e) { + if (e && typeof e === "object") { + Object.defineProperty(e, "$responseBodyText", { + value: encoded, + }); + } + throw e; + } + const textNodeName = "#text"; + const key = Object.keys(parsedObj)[0]; + const parsedObjToReturn = parsedObj[key]; + if (parsedObjToReturn[textNodeName]) { + parsedObjToReturn[key] = parsedObjToReturn[textNodeName]; + delete parsedObjToReturn[textNodeName]; + } + return (0, import_smithy_client.getValueFromTextNode)(parsedObjToReturn); + } + return {}; + }), + "parseXmlBody" +); +var parseXmlErrorBody = /* @__PURE__ */ __name(async (errorBody, context) => { + const value = await parseXmlBody(errorBody, context); + if (value.Error) { + value.Error.message = value.Error.message ?? value.Error.Message; + } + return value; +}, "parseXmlErrorBody"); +var loadRestXmlErrorCode = /* @__PURE__ */ __name((output, data) => { + var _a; + if (((_a = data == null ? void 0 : data.Error) == null ? void 0 : _a.Code) !== void 0) { + return data.Error.Code; + } + if ((data == null ? void 0 : data.Code) !== void 0) { + return data.Code; + } + if (output.statusCode == 404) { + return "NotFound"; + } +}, "loadRestXmlErrorCode"); +// Annotate the CommonJS export names for ESM import in node: + +0 && + (module.exports = { + emitWarningIfUnsupportedVersion, + AwsSdkSigV4Signer, + AWSSDKSigV4Signer, + resolveAwsSdkSigV4Config, + resolveAWSSDKSigV4Config, + _toStr, + _toBool, + _toNum, + awsExpectUnion, + parseJsonBody, + parseJsonErrorBody, + loadRestJsonErrorCode, + parseXmlBody, + parseXmlErrorBody, + loadRestXmlErrorCode, + }); diff --git a/packages/core/distcjs/protocols/coercing-serializers.js b/packages/core/distcjs/protocols/coercing-serializers.js new file mode 100644 index 000000000000..fa1ab10d97dc --- /dev/null +++ b/packages/core/distcjs/protocols/coercing-serializers.js @@ -0,0 +1 @@ +module.exports = require("../index.js"); diff --git a/packages/core/distcjs/protocols/common.js b/packages/core/distcjs/protocols/common.js new file mode 100644 index 000000000000..fa1ab10d97dc --- /dev/null +++ b/packages/core/distcjs/protocols/common.js @@ -0,0 +1 @@ +module.exports = require("../index.js"); diff --git a/packages/core/distcjs/protocols/index.js b/packages/core/distcjs/protocols/index.js new file mode 100644 index 000000000000..fa1ab10d97dc --- /dev/null +++ b/packages/core/distcjs/protocols/index.js @@ -0,0 +1 @@ +module.exports = require("../index.js"); diff --git a/packages/core/distcjs/protocols/json/awsExpectUnion.js b/packages/core/distcjs/protocols/json/awsExpectUnion.js new file mode 100644 index 000000000000..ecafff3570ff --- /dev/null +++ b/packages/core/distcjs/protocols/json/awsExpectUnion.js @@ -0,0 +1 @@ +module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/protocols/json/parseJsonBody.js b/packages/core/distcjs/protocols/json/parseJsonBody.js new file mode 100644 index 000000000000..ecafff3570ff --- /dev/null +++ b/packages/core/distcjs/protocols/json/parseJsonBody.js @@ -0,0 +1 @@ +module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/protocols/xml/parseXmlBody.js b/packages/core/distcjs/protocols/xml/parseXmlBody.js new file mode 100644 index 000000000000..ecafff3570ff --- /dev/null +++ b/packages/core/distcjs/protocols/xml/parseXmlBody.js @@ -0,0 +1 @@ +module.exports = require("../../index.js"); diff --git a/packages/core/distes/client/emitWarningIfUnsupportedVersion.js b/packages/core/distes/client/emitWarningIfUnsupportedVersion.js new file mode 100644 index 000000000000..4c6bf51626b8 --- /dev/null +++ b/packages/core/distes/client/emitWarningIfUnsupportedVersion.js @@ -0,0 +1,6 @@ +let warningEmitted = false; +export const emitWarningIfUnsupportedVersion = (version) => { + if (version && !warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 16) { + warningEmitted = true; + } +}; diff --git a/packages/core/distes/client/index.js b/packages/core/distes/client/index.js new file mode 100644 index 000000000000..ed9af92686a2 --- /dev/null +++ b/packages/core/distes/client/index.js @@ -0,0 +1 @@ +export * from "./emitWarningIfUnsupportedVersion"; diff --git a/packages/core/distes/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js b/packages/core/distes/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js new file mode 100644 index 000000000000..9270be813a24 --- /dev/null +++ b/packages/core/distes/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js @@ -0,0 +1,60 @@ +import { HttpRequest } from "@smithy/protocol-http"; +import { getDateHeader, getSkewCorrectedDate, getUpdatedSystemClockOffset } from "../utils"; +const throwSigningPropertyError = (name, property) => { + if (!property) { + throw new Error(`Property \`${name}\` is not resolved for AWS SDK SigV4Auth`); + } + return property; +}; +const validateSigningProperties = async (signingProperties) => { + const context = throwSigningPropertyError("context", signingProperties.context); + const config = throwSigningPropertyError("config", signingProperties.config); + const authScheme = context.endpointV2?.properties?.authSchemes?.[0]; + const signerFunction = throwSigningPropertyError("signer", config.signer); + const signer = await signerFunction(authScheme); + const signingRegion = signingProperties?.signingRegion; + const signingName = signingProperties?.signingName; + return { + config, + signer, + signingRegion, + signingName, + }; +}; +export class AwsSdkSigV4Signer { + async sign(httpRequest, identity, signingProperties) { + if (!HttpRequest.isInstance(httpRequest)) { + throw new Error("The request is not an instance of `HttpRequest` and cannot be signed"); + } + const { config, signer, signingRegion, signingName } = await validateSigningProperties(signingProperties); + const signedRequest = await signer.sign(httpRequest, { + signingDate: getSkewCorrectedDate(config.systemClockOffset), + signingRegion: signingRegion, + signingService: signingName, + }); + return signedRequest; + } + errorHandler(signingProperties) { + return (error) => { + const serverTime = error.ServerTime ?? getDateHeader(error.$response); + if (serverTime) { + const config = throwSigningPropertyError("config", signingProperties.config); + const initialSystemClockOffset = config.systemClockOffset; + config.systemClockOffset = getUpdatedSystemClockOffset(serverTime, config.systemClockOffset); + const clockSkewCorrected = config.systemClockOffset !== initialSystemClockOffset; + if (clockSkewCorrected && error.$metadata) { + error.$metadata.clockSkewCorrected = true; + } + } + throw error; + }; + } + successHandler(httpResponse, signingProperties) { + const dateHeader = getDateHeader(httpResponse); + if (dateHeader) { + const config = throwSigningPropertyError("config", signingProperties.config); + config.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, config.systemClockOffset); + } + } +} +export const AWSSDKSigV4Signer = AwsSdkSigV4Signer; diff --git a/packages/core/distes/httpAuthSchemes/aws_sdk/index.js b/packages/core/distes/httpAuthSchemes/aws_sdk/index.js new file mode 100644 index 000000000000..6d17c7096d04 --- /dev/null +++ b/packages/core/distes/httpAuthSchemes/aws_sdk/index.js @@ -0,0 +1,2 @@ +export * from "./AwsSdkSigV4Signer"; +export * from "./resolveAwsSdkSigV4Config"; diff --git a/packages/core/distes/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js b/packages/core/distes/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js new file mode 100644 index 000000000000..e8222e1e7163 --- /dev/null +++ b/packages/core/distes/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js @@ -0,0 +1,93 @@ +import { + doesIdentityRequireRefresh, + isIdentityExpired, + memoizeIdentityProvider, + normalizeProvider, +} from "@smithy/core"; +import { SignatureV4 } from "@smithy/signature-v4"; +export const resolveAwsSdkSigV4Config = (config) => { + let normalizedCreds; + if (config.credentials) { + normalizedCreds = memoizeIdentityProvider(config.credentials, isIdentityExpired, doesIdentityRequireRefresh); + } + if (!normalizedCreds) { + if (config.credentialDefaultProvider) { + normalizedCreds = normalizeProvider( + config.credentialDefaultProvider( + Object.assign({}, config, { + parentClientConfig: config, + }) + ) + ); + } else { + normalizedCreds = async () => { + throw new Error("`credentials` is missing"); + }; + } + } + const { signingEscapePath = true, systemClockOffset = config.systemClockOffset || 0, sha256 } = config; + let signer; + if (config.signer) { + signer = normalizeProvider(config.signer); + } else if (config.regionInfoProvider) { + signer = () => + normalizeProvider(config.region)() + .then(async (region) => [ + (await config.regionInfoProvider(region, { + useFipsEndpoint: await config.useFipsEndpoint(), + useDualstackEndpoint: await config.useDualstackEndpoint(), + })) || {}, + region, + ]) + .then(([regionInfo, region]) => { + const { signingRegion, signingService } = regionInfo; + config.signingRegion = config.signingRegion || signingRegion || region; + config.signingName = config.signingName || signingService || config.serviceId; + const params = { + ...config, + credentials: normalizedCreds, + region: config.signingRegion, + service: config.signingName, + sha256, + uriEscapePath: signingEscapePath, + }; + const SignerCtor = config.signerConstructor || SignatureV4; + return new SignerCtor(params); + }); + } else { + signer = async (authScheme) => { + authScheme = Object.assign( + {}, + { + name: "sigv4", + signingName: config.signingName || config.defaultSigningName, + signingRegion: await normalizeProvider(config.region)(), + properties: {}, + }, + authScheme + ); + const signingRegion = authScheme.signingRegion; + const signingService = authScheme.signingName; + config.signingRegion = config.signingRegion || signingRegion; + config.signingName = config.signingName || signingService || config.serviceId; + const params = { + ...config, + credentials: normalizedCreds, + region: config.signingRegion, + service: config.signingName, + sha256, + uriEscapePath: signingEscapePath, + }; + const SignerCtor = config.signerConstructor || SignatureV4; + return new SignerCtor(params); + }; + } + return { + ...config, + systemClockOffset, + signingEscapePath, + credentials: normalizedCreds, + signer, + }; +}; +export const resolveAWSSDKSigV4Config = resolveAwsSdkSigV4Config; diff --git a/packages/core/distes/httpAuthSchemes/index.js b/packages/core/distes/httpAuthSchemes/index.js new file mode 100644 index 000000000000..29d0c3bdf9f8 --- /dev/null +++ b/packages/core/distes/httpAuthSchemes/index.js @@ -0,0 +1 @@ +export * from "./aws_sdk"; diff --git a/packages/core/distes/httpAuthSchemes/utils/getDateHeader.js b/packages/core/distes/httpAuthSchemes/utils/getDateHeader.js new file mode 100644 index 000000000000..dd7255dbcc3f --- /dev/null +++ b/packages/core/distes/httpAuthSchemes/utils/getDateHeader.js @@ -0,0 +1,3 @@ +import { HttpResponse } from "@smithy/protocol-http"; +export const getDateHeader = (response) => + HttpResponse.isInstance(response) ? response.headers?.date ?? response.headers?.Date : undefined; diff --git a/packages/core/distes/httpAuthSchemes/utils/getSkewCorrectedDate.js b/packages/core/distes/httpAuthSchemes/utils/getSkewCorrectedDate.js new file mode 100644 index 000000000000..6ee803634879 --- /dev/null +++ b/packages/core/distes/httpAuthSchemes/utils/getSkewCorrectedDate.js @@ -0,0 +1 @@ +export const getSkewCorrectedDate = (systemClockOffset) => new Date(Date.now() + systemClockOffset); diff --git a/packages/core/distes/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js b/packages/core/distes/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js new file mode 100644 index 000000000000..69623d6b9d76 --- /dev/null +++ b/packages/core/distes/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js @@ -0,0 +1,8 @@ +import { isClockSkewed } from "./isClockSkewed"; +export const getUpdatedSystemClockOffset = (clockTime, currentSystemClockOffset) => { + const clockTimeInMs = Date.parse(clockTime); + if (isClockSkewed(clockTimeInMs, currentSystemClockOffset)) { + return clockTimeInMs - Date.now(); + } + return currentSystemClockOffset; +}; diff --git a/packages/core/distes/httpAuthSchemes/utils/index.js b/packages/core/distes/httpAuthSchemes/utils/index.js new file mode 100644 index 000000000000..07c21953a4dd --- /dev/null +++ b/packages/core/distes/httpAuthSchemes/utils/index.js @@ -0,0 +1,3 @@ +export * from "./getDateHeader"; +export * from "./getSkewCorrectedDate"; +export * from "./getUpdatedSystemClockOffset"; diff --git a/packages/core/distes/httpAuthSchemes/utils/isClockSkewed.js b/packages/core/distes/httpAuthSchemes/utils/isClockSkewed.js new file mode 100644 index 000000000000..62f11064725c --- /dev/null +++ b/packages/core/distes/httpAuthSchemes/utils/isClockSkewed.js @@ -0,0 +1,3 @@ +import { getSkewCorrectedDate } from "./getSkewCorrectedDate"; +export const isClockSkewed = (clockTime, systemClockOffset) => + Math.abs(getSkewCorrectedDate(systemClockOffset).getTime() - clockTime) >= 300000; diff --git a/packages/core/distes/index.js b/packages/core/distes/index.js new file mode 100644 index 000000000000..532feb93c8c9 --- /dev/null +++ b/packages/core/distes/index.js @@ -0,0 +1,3 @@ +export * from "./client/index"; +export * from "./httpAuthSchemes/index"; +export * from "./protocols/index"; diff --git a/packages/core/distes/protocols/coercing-serializers.js b/packages/core/distes/protocols/coercing-serializers.js new file mode 100644 index 000000000000..cbe29e273881 --- /dev/null +++ b/packages/core/distes/protocols/coercing-serializers.js @@ -0,0 +1,53 @@ +export const _toStr = (val) => { + if (val == null) { + return val; + } + if (typeof val === "number" || typeof val === "bigint") { + const warning = new Error(`Received number ${val} where a string was expected.`); + warning.name = "Warning"; + console.warn(warning); + return String(val); + } + if (typeof val === "boolean") { + const warning = new Error(`Received boolean ${val} where a string was expected.`); + warning.name = "Warning"; + console.warn(warning); + return String(val); + } + return val; +}; +export const _toBool = (val) => { + if (val == null) { + return val; + } + if (typeof val === "number") { + } + if (typeof val === "string") { + const lowercase = val.toLowerCase(); + if (val !== "" && lowercase !== "false" && lowercase !== "true") { + const warning = new Error(`Received string "${val}" where a boolean was expected.`); + warning.name = "Warning"; + console.warn(warning); + } + return val !== "" && lowercase !== "false"; + } + return val; +}; +export const _toNum = (val) => { + if (val == null) { + return val; + } + if (typeof val === "boolean") { + } + if (typeof val === "string") { + const num = Number(val); + if (num.toString() !== val) { + const warning = new Error(`Received string "${val}" where a number was expected.`); + warning.name = "Warning"; + console.warn(warning); + return val; + } + return num; + } + return val; +}; diff --git a/packages/core/distes/protocols/common.js b/packages/core/distes/protocols/common.js new file mode 100644 index 000000000000..65c9a2c329e0 --- /dev/null +++ b/packages/core/distes/protocols/common.js @@ -0,0 +1,3 @@ +import { collectBody } from "@smithy/smithy-client"; +export const collectBodyString = (streamBody, context) => + collectBody(streamBody, context).then((body) => context.utf8Encoder(body)); diff --git a/packages/core/distes/protocols/index.js b/packages/core/distes/protocols/index.js new file mode 100644 index 000000000000..09a6ac214ca0 --- /dev/null +++ b/packages/core/distes/protocols/index.js @@ -0,0 +1,4 @@ +export * from "./coercing-serializers"; +export * from "./json/awsExpectUnion"; +export * from "./json/parseJsonBody"; +export * from "./xml/parseXmlBody"; diff --git a/packages/core/distes/protocols/json/awsExpectUnion.js b/packages/core/distes/protocols/json/awsExpectUnion.js new file mode 100644 index 000000000000..8af9a9659ef5 --- /dev/null +++ b/packages/core/distes/protocols/json/awsExpectUnion.js @@ -0,0 +1,10 @@ +import { expectUnion } from "@smithy/smithy-client"; +export const awsExpectUnion = (value) => { + if (value == null) { + return undefined; + } + if (typeof value === "object" && "__type" in value) { + delete value.__type; + } + return expectUnion(value); +}; diff --git a/packages/core/distes/protocols/json/parseJsonBody.js b/packages/core/distes/protocols/json/parseJsonBody.js new file mode 100644 index 000000000000..aebfbf3d0e94 --- /dev/null +++ b/packages/core/distes/protocols/json/parseJsonBody.js @@ -0,0 +1,51 @@ +import { collectBodyString } from "../common"; +export const parseJsonBody = (streamBody, context) => + collectBodyString(streamBody, context).then((encoded) => { + if (encoded.length) { + try { + return JSON.parse(encoded); + } catch (e) { + if (e?.name === "SyntaxError") { + Object.defineProperty(e, "$responseBodyText", { + value: encoded, + }); + } + throw e; + } + } + return {}; + }); +export const parseJsonErrorBody = async (errorBody, context) => { + const value = await parseJsonBody(errorBody, context); + value.message = value.message ?? value.Message; + return value; +}; +export const loadRestJsonErrorCode = (output, data) => { + const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); + const sanitizeErrorCode = (rawValue) => { + let cleanValue = rawValue; + if (typeof cleanValue === "number") { + cleanValue = cleanValue.toString(); + } + if (cleanValue.indexOf(",") >= 0) { + cleanValue = cleanValue.split(",")[0]; + } + if (cleanValue.indexOf(":") >= 0) { + cleanValue = cleanValue.split(":")[0]; + } + if (cleanValue.indexOf("#") >= 0) { + cleanValue = cleanValue.split("#")[1]; + } + return cleanValue; + }; + const headerKey = findKey(output.headers, "x-amzn-errortype"); + if (headerKey !== undefined) { + return sanitizeErrorCode(output.headers[headerKey]); + } + if (data.code !== undefined) { + return sanitizeErrorCode(data.code); + } + if (data["__type"] !== undefined) { + return sanitizeErrorCode(data["__type"]); + } +}; diff --git a/packages/core/distes/protocols/xml/parseXmlBody.js b/packages/core/distes/protocols/xml/parseXmlBody.js new file mode 100644 index 000000000000..4725538800ce --- /dev/null +++ b/packages/core/distes/protocols/xml/parseXmlBody.js @@ -0,0 +1,57 @@ +import { getValueFromTextNode } from "@smithy/smithy-client"; +import { XMLParser } from "fast-xml-parser"; +import { collectBodyString } from "../common"; +export const parseXmlBody = (streamBody, context) => + collectBodyString(streamBody, context).then((encoded) => { + if (encoded.length) { + const parser = new XMLParser({ + attributeNamePrefix: "", + htmlEntities: true, + ignoreAttributes: false, + ignoreDeclaration: true, + parseTagValue: false, + trimValues: false, + tagValueProcessor: (_, val) => (val.trim() === "" && val.includes("\n") ? "" : undefined), + }); + parser.addEntity("#xD", "\r"); + parser.addEntity("#10", "\n"); + let parsedObj; + try { + parsedObj = parser.parse(encoded, true); + } catch (e) { + if (e && typeof e === "object") { + Object.defineProperty(e, "$responseBodyText", { + value: encoded, + }); + } + throw e; + } + const textNodeName = "#text"; + const key = Object.keys(parsedObj)[0]; + const parsedObjToReturn = parsedObj[key]; + if (parsedObjToReturn[textNodeName]) { + parsedObjToReturn[key] = parsedObjToReturn[textNodeName]; + delete parsedObjToReturn[textNodeName]; + } + return getValueFromTextNode(parsedObjToReturn); + } + return {}; + }); +export const parseXmlErrorBody = async (errorBody, context) => { + const value = await parseXmlBody(errorBody, context); + if (value.Error) { + value.Error.message = value.Error.message ?? value.Error.Message; + } + return value; +}; +export const loadRestXmlErrorCode = (output, data) => { + if (data?.Error?.Code !== undefined) { + return data.Error.Code; + } + if (data?.Code !== undefined) { + return data.Code; + } + if (output.statusCode == 404) { + return "NotFound"; + } +}; From 6bdafa2c519d911b0b68a35843f667db87e43af0 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Tue, 7 May 2024 22:00:23 +0000 Subject: [PATCH 10/11] chore(core): dist folders with tsconfig from branch --- packages/core/distcjs/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core/distcjs/index.js b/packages/core/distcjs/index.js index 3637eee66b9a..c7aa3763e2bf 100644 --- a/packages/core/distcjs/index.js +++ b/packages/core/distcjs/index.js @@ -1,3 +1,4 @@ +"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; From 0c9c5c947c735f23657ae134ba69e7ff888d8116 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Tue, 7 May 2024 22:00:47 +0000 Subject: [PATCH 11/11] chore(core): delete dist folders --- .../client/emitWarningIfUnsupportedVersion.js | 1 - packages/core/distcjs/client/index.js | 1 - .../aws_sdk/AwsSdkSigV4Signer.js | 1 - .../distcjs/httpAuthSchemes/aws_sdk/index.js | 1 - .../aws_sdk/resolveAwsSdkSigV4Config.js | 1 - .../core/distcjs/httpAuthSchemes/index.js | 1 - .../httpAuthSchemes/utils/getDateHeader.js | 1 - .../utils/getSkewCorrectedDate.js | 1 - .../utils/getUpdatedSystemClockOffset.js | 1 - .../distcjs/httpAuthSchemes/utils/index.js | 1 - .../httpAuthSchemes/utils/isClockSkewed.js | 1 - packages/core/distcjs/index.js | 467 ------------------ .../distcjs/protocols/coercing-serializers.js | 1 - packages/core/distcjs/protocols/common.js | 1 - packages/core/distcjs/protocols/index.js | 1 - .../distcjs/protocols/json/awsExpectUnion.js | 1 - .../distcjs/protocols/json/parseJsonBody.js | 1 - .../distcjs/protocols/xml/parseXmlBody.js | 1 - .../client/emitWarningIfUnsupportedVersion.js | 6 - packages/core/distes/client/index.js | 1 - .../aws_sdk/AwsSdkSigV4Signer.js | 60 --- .../distes/httpAuthSchemes/aws_sdk/index.js | 2 - .../aws_sdk/resolveAwsSdkSigV4Config.js | 93 ---- packages/core/distes/httpAuthSchemes/index.js | 1 - .../httpAuthSchemes/utils/getDateHeader.js | 3 - .../utils/getSkewCorrectedDate.js | 1 - .../utils/getUpdatedSystemClockOffset.js | 8 - .../distes/httpAuthSchemes/utils/index.js | 3 - .../httpAuthSchemes/utils/isClockSkewed.js | 3 - packages/core/distes/index.js | 3 - .../distes/protocols/coercing-serializers.js | 53 -- packages/core/distes/protocols/common.js | 3 - packages/core/distes/protocols/index.js | 4 - .../distes/protocols/json/awsExpectUnion.js | 10 - .../distes/protocols/json/parseJsonBody.js | 51 -- .../core/distes/protocols/xml/parseXmlBody.js | 57 --- 36 files changed, 846 deletions(-) delete mode 100644 packages/core/distcjs/client/emitWarningIfUnsupportedVersion.js delete mode 100644 packages/core/distcjs/client/index.js delete mode 100644 packages/core/distcjs/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js delete mode 100644 packages/core/distcjs/httpAuthSchemes/aws_sdk/index.js delete mode 100644 packages/core/distcjs/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js delete mode 100644 packages/core/distcjs/httpAuthSchemes/index.js delete mode 100644 packages/core/distcjs/httpAuthSchemes/utils/getDateHeader.js delete mode 100644 packages/core/distcjs/httpAuthSchemes/utils/getSkewCorrectedDate.js delete mode 100644 packages/core/distcjs/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js delete mode 100644 packages/core/distcjs/httpAuthSchemes/utils/index.js delete mode 100644 packages/core/distcjs/httpAuthSchemes/utils/isClockSkewed.js delete mode 100644 packages/core/distcjs/index.js delete mode 100644 packages/core/distcjs/protocols/coercing-serializers.js delete mode 100644 packages/core/distcjs/protocols/common.js delete mode 100644 packages/core/distcjs/protocols/index.js delete mode 100644 packages/core/distcjs/protocols/json/awsExpectUnion.js delete mode 100644 packages/core/distcjs/protocols/json/parseJsonBody.js delete mode 100644 packages/core/distcjs/protocols/xml/parseXmlBody.js delete mode 100644 packages/core/distes/client/emitWarningIfUnsupportedVersion.js delete mode 100644 packages/core/distes/client/index.js delete mode 100644 packages/core/distes/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js delete mode 100644 packages/core/distes/httpAuthSchemes/aws_sdk/index.js delete mode 100644 packages/core/distes/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js delete mode 100644 packages/core/distes/httpAuthSchemes/index.js delete mode 100644 packages/core/distes/httpAuthSchemes/utils/getDateHeader.js delete mode 100644 packages/core/distes/httpAuthSchemes/utils/getSkewCorrectedDate.js delete mode 100644 packages/core/distes/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js delete mode 100644 packages/core/distes/httpAuthSchemes/utils/index.js delete mode 100644 packages/core/distes/httpAuthSchemes/utils/isClockSkewed.js delete mode 100644 packages/core/distes/index.js delete mode 100644 packages/core/distes/protocols/coercing-serializers.js delete mode 100644 packages/core/distes/protocols/common.js delete mode 100644 packages/core/distes/protocols/index.js delete mode 100644 packages/core/distes/protocols/json/awsExpectUnion.js delete mode 100644 packages/core/distes/protocols/json/parseJsonBody.js delete mode 100644 packages/core/distes/protocols/xml/parseXmlBody.js diff --git a/packages/core/distcjs/client/emitWarningIfUnsupportedVersion.js b/packages/core/distcjs/client/emitWarningIfUnsupportedVersion.js deleted file mode 100644 index fa1ab10d97dc..000000000000 --- a/packages/core/distcjs/client/emitWarningIfUnsupportedVersion.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../index.js"); diff --git a/packages/core/distcjs/client/index.js b/packages/core/distcjs/client/index.js deleted file mode 100644 index fa1ab10d97dc..000000000000 --- a/packages/core/distcjs/client/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js b/packages/core/distcjs/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js deleted file mode 100644 index ecafff3570ff..000000000000 --- a/packages/core/distcjs/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/aws_sdk/index.js b/packages/core/distcjs/httpAuthSchemes/aws_sdk/index.js deleted file mode 100644 index ecafff3570ff..000000000000 --- a/packages/core/distcjs/httpAuthSchemes/aws_sdk/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js b/packages/core/distcjs/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js deleted file mode 100644 index ecafff3570ff..000000000000 --- a/packages/core/distcjs/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/index.js b/packages/core/distcjs/httpAuthSchemes/index.js deleted file mode 100644 index fa1ab10d97dc..000000000000 --- a/packages/core/distcjs/httpAuthSchemes/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/utils/getDateHeader.js b/packages/core/distcjs/httpAuthSchemes/utils/getDateHeader.js deleted file mode 100644 index ecafff3570ff..000000000000 --- a/packages/core/distcjs/httpAuthSchemes/utils/getDateHeader.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/utils/getSkewCorrectedDate.js b/packages/core/distcjs/httpAuthSchemes/utils/getSkewCorrectedDate.js deleted file mode 100644 index ecafff3570ff..000000000000 --- a/packages/core/distcjs/httpAuthSchemes/utils/getSkewCorrectedDate.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js b/packages/core/distcjs/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js deleted file mode 100644 index ecafff3570ff..000000000000 --- a/packages/core/distcjs/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/utils/index.js b/packages/core/distcjs/httpAuthSchemes/utils/index.js deleted file mode 100644 index ecafff3570ff..000000000000 --- a/packages/core/distcjs/httpAuthSchemes/utils/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/httpAuthSchemes/utils/isClockSkewed.js b/packages/core/distcjs/httpAuthSchemes/utils/isClockSkewed.js deleted file mode 100644 index ecafff3570ff..000000000000 --- a/packages/core/distcjs/httpAuthSchemes/utils/isClockSkewed.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/index.js b/packages/core/distcjs/index.js deleted file mode 100644 index c7aa3763e2bf..000000000000 --- a/packages/core/distcjs/index.js +++ /dev/null @@ -1,467 +0,0 @@ -"use strict"; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); -var __export = (target, all) => { - for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); -}; -var __copyProps = (to, from, except, desc) => { - if ((from && typeof from === "object") || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { - get: () => from[key], - enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable, - }); - } - return to; -}; -var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); - -// src/index.ts -var src_exports = {}; -__export(src_exports, { - AWSSDKSigV4Signer: () => AWSSDKSigV4Signer, - AwsSdkSigV4Signer: () => AwsSdkSigV4Signer, - _toBool: () => _toBool, - _toNum: () => _toNum, - _toStr: () => _toStr, - awsExpectUnion: () => awsExpectUnion, - emitWarningIfUnsupportedVersion: () => emitWarningIfUnsupportedVersion, - loadRestJsonErrorCode: () => loadRestJsonErrorCode, - loadRestXmlErrorCode: () => loadRestXmlErrorCode, - parseJsonBody: () => parseJsonBody, - parseJsonErrorBody: () => parseJsonErrorBody, - parseXmlBody: () => parseXmlBody, - parseXmlErrorBody: () => parseXmlErrorBody, - resolveAWSSDKSigV4Config: () => resolveAWSSDKSigV4Config, - resolveAwsSdkSigV4Config: () => resolveAwsSdkSigV4Config, -}); -module.exports = __toCommonJS(src_exports); - -// src/client/emitWarningIfUnsupportedVersion.ts -var warningEmitted = false; -var emitWarningIfUnsupportedVersion = /* @__PURE__ */ __name((version) => { - if (version && !warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 16) { - warningEmitted = true; - } -}, "emitWarningIfUnsupportedVersion"); - -// src/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.ts - -// src/httpAuthSchemes/utils/getDateHeader.ts -var import_protocol_http = require("@smithy/protocol-http"); -var getDateHeader = /* @__PURE__ */ __name((response) => { - var _a, _b; - return import_protocol_http.HttpResponse.isInstance(response) - ? ((_a = response.headers) == null ? void 0 : _a.date) ?? ((_b = response.headers) == null ? void 0 : _b.Date) - : void 0; -}, "getDateHeader"); - -// src/httpAuthSchemes/utils/getSkewCorrectedDate.ts -var getSkewCorrectedDate = /* @__PURE__ */ __name( - (systemClockOffset) => new Date(Date.now() + systemClockOffset), - "getSkewCorrectedDate" -); - -// src/httpAuthSchemes/utils/isClockSkewed.ts -var isClockSkewed = /* @__PURE__ */ __name( - (clockTime, systemClockOffset) => Math.abs(getSkewCorrectedDate(systemClockOffset).getTime() - clockTime) >= 3e5, - "isClockSkewed" -); - -// src/httpAuthSchemes/utils/getUpdatedSystemClockOffset.ts -var getUpdatedSystemClockOffset = /* @__PURE__ */ __name((clockTime, currentSystemClockOffset) => { - const clockTimeInMs = Date.parse(clockTime); - if (isClockSkewed(clockTimeInMs, currentSystemClockOffset)) { - return clockTimeInMs - Date.now(); - } - return currentSystemClockOffset; -}, "getUpdatedSystemClockOffset"); - -// src/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.ts -var throwSigningPropertyError = /* @__PURE__ */ __name((name, property) => { - if (!property) { - throw new Error(`Property \`${name}\` is not resolved for AWS SDK SigV4Auth`); - } - return property; -}, "throwSigningPropertyError"); -var validateSigningProperties = /* @__PURE__ */ __name(async (signingProperties) => { - var _a, _b, _c; - const context = throwSigningPropertyError("context", signingProperties.context); - const config = throwSigningPropertyError("config", signingProperties.config); - const authScheme = - (_c = (_b = (_a = context.endpointV2) == null ? void 0 : _a.properties) == null ? void 0 : _b.authSchemes) == null - ? void 0 - : _c[0]; - const signerFunction = throwSigningPropertyError("signer", config.signer); - const signer = await signerFunction(authScheme); - const signingRegion = signingProperties == null ? void 0 : signingProperties.signingRegion; - const signingName = signingProperties == null ? void 0 : signingProperties.signingName; - return { - config, - signer, - signingRegion, - signingName, - }; -}, "validateSigningProperties"); -var _AwsSdkSigV4Signer = class _AwsSdkSigV4Signer { - async sign(httpRequest, identity, signingProperties) { - if (!import_protocol_http.HttpRequest.isInstance(httpRequest)) { - throw new Error("The request is not an instance of `HttpRequest` and cannot be signed"); - } - const { config, signer, signingRegion, signingName } = await validateSigningProperties(signingProperties); - const signedRequest = await signer.sign(httpRequest, { - signingDate: getSkewCorrectedDate(config.systemClockOffset), - signingRegion, - signingService: signingName, - }); - return signedRequest; - } - errorHandler(signingProperties) { - return (error) => { - const serverTime = error.ServerTime ?? getDateHeader(error.$response); - if (serverTime) { - const config = throwSigningPropertyError("config", signingProperties.config); - const initialSystemClockOffset = config.systemClockOffset; - config.systemClockOffset = getUpdatedSystemClockOffset(serverTime, config.systemClockOffset); - const clockSkewCorrected = config.systemClockOffset !== initialSystemClockOffset; - if (clockSkewCorrected && error.$metadata) { - error.$metadata.clockSkewCorrected = true; - } - } - throw error; - }; - } - successHandler(httpResponse, signingProperties) { - const dateHeader = getDateHeader(httpResponse); - if (dateHeader) { - const config = throwSigningPropertyError("config", signingProperties.config); - config.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, config.systemClockOffset); - } - } -}; -__name(_AwsSdkSigV4Signer, "AwsSdkSigV4Signer"); -var AwsSdkSigV4Signer = _AwsSdkSigV4Signer; -var AWSSDKSigV4Signer = AwsSdkSigV4Signer; - -// src/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.ts -var import_core = require("@smithy/core"); -var import_signature_v4 = require("@smithy/signature-v4"); -var resolveAwsSdkSigV4Config = /* @__PURE__ */ __name((config) => { - let normalizedCreds; - if (config.credentials) { - normalizedCreds = (0, import_core.memoizeIdentityProvider)( - config.credentials, - import_core.isIdentityExpired, - import_core.doesIdentityRequireRefresh - ); - } - if (!normalizedCreds) { - if (config.credentialDefaultProvider) { - normalizedCreds = (0, import_core.normalizeProvider)( - config.credentialDefaultProvider( - Object.assign({}, config, { - parentClientConfig: config, - }) - ) - ); - } else { - normalizedCreds = /* @__PURE__ */ __name(async () => { - throw new Error("`credentials` is missing"); - }, "normalizedCreds"); - } - } - const { - // Default for signingEscapePath - signingEscapePath = true, - // Default for systemClockOffset - systemClockOffset = config.systemClockOffset || 0, - // No default for sha256 since it is platform dependent - sha256, - } = config; - let signer; - if (config.signer) { - signer = (0, import_core.normalizeProvider)(config.signer); - } else if (config.regionInfoProvider) { - signer = /* @__PURE__ */ __name( - () => - (0, import_core.normalizeProvider)(config.region)() - .then(async (region) => [ - (await config.regionInfoProvider(region, { - useFipsEndpoint: await config.useFipsEndpoint(), - useDualstackEndpoint: await config.useDualstackEndpoint(), - })) || {}, - region, - ]) - .then(([regionInfo, region]) => { - const { signingRegion, signingService } = regionInfo; - config.signingRegion = config.signingRegion || signingRegion || region; - config.signingName = config.signingName || signingService || config.serviceId; - const params = { - ...config, - credentials: normalizedCreds, - region: config.signingRegion, - service: config.signingName, - sha256, - uriEscapePath: signingEscapePath, - }; - const SignerCtor = config.signerConstructor || import_signature_v4.SignatureV4; - return new SignerCtor(params); - }), - "signer" - ); - } else { - signer = /* @__PURE__ */ __name(async (authScheme) => { - authScheme = Object.assign( - {}, - { - name: "sigv4", - signingName: config.signingName || config.defaultSigningName, - signingRegion: await (0, import_core.normalizeProvider)(config.region)(), - properties: {}, - }, - authScheme - ); - const signingRegion = authScheme.signingRegion; - const signingService = authScheme.signingName; - config.signingRegion = config.signingRegion || signingRegion; - config.signingName = config.signingName || signingService || config.serviceId; - const params = { - ...config, - credentials: normalizedCreds, - region: config.signingRegion, - service: config.signingName, - sha256, - uriEscapePath: signingEscapePath, - }; - const SignerCtor = config.signerConstructor || import_signature_v4.SignatureV4; - return new SignerCtor(params); - }, "signer"); - } - return { - ...config, - systemClockOffset, - signingEscapePath, - credentials: normalizedCreds, - signer, - }; -}, "resolveAwsSdkSigV4Config"); -var resolveAWSSDKSigV4Config = resolveAwsSdkSigV4Config; - -// src/protocols/coercing-serializers.ts -var _toStr = /* @__PURE__ */ __name((val) => { - if (val == null) { - return val; - } - if (typeof val === "number" || typeof val === "bigint") { - const warning = new Error(`Received number ${val} where a string was expected.`); - warning.name = "Warning"; - console.warn(warning); - return String(val); - } - if (typeof val === "boolean") { - const warning = new Error(`Received boolean ${val} where a string was expected.`); - warning.name = "Warning"; - console.warn(warning); - return String(val); - } - return val; -}, "_toStr"); -var _toBool = /* @__PURE__ */ __name((val) => { - if (val == null) { - return val; - } - if (typeof val === "number") { - } - if (typeof val === "string") { - const lowercase = val.toLowerCase(); - if (val !== "" && lowercase !== "false" && lowercase !== "true") { - const warning = new Error(`Received string "${val}" where a boolean was expected.`); - warning.name = "Warning"; - console.warn(warning); - } - return val !== "" && lowercase !== "false"; - } - return val; -}, "_toBool"); -var _toNum = /* @__PURE__ */ __name((val) => { - if (val == null) { - return val; - } - if (typeof val === "boolean") { - } - if (typeof val === "string") { - const num = Number(val); - if (num.toString() !== val) { - const warning = new Error(`Received string "${val}" where a number was expected.`); - warning.name = "Warning"; - console.warn(warning); - return val; - } - return num; - } - return val; -}, "_toNum"); - -// src/protocols/json/awsExpectUnion.ts -var import_smithy_client = require("@smithy/smithy-client"); -var awsExpectUnion = /* @__PURE__ */ __name((value) => { - if (value == null) { - return void 0; - } - if (typeof value === "object" && "__type" in value) { - delete value.__type; - } - return (0, import_smithy_client.expectUnion)(value); -}, "awsExpectUnion"); - -// src/protocols/common.ts - -var collectBodyString = /* @__PURE__ */ __name( - (streamBody, context) => - (0, import_smithy_client.collectBody)(streamBody, context).then((body) => context.utf8Encoder(body)), - "collectBodyString" -); - -// src/protocols/json/parseJsonBody.ts -var parseJsonBody = /* @__PURE__ */ __name( - (streamBody, context) => - collectBodyString(streamBody, context).then((encoded) => { - if (encoded.length) { - try { - return JSON.parse(encoded); - } catch (e) { - if ((e == null ? void 0 : e.name) === "SyntaxError") { - Object.defineProperty(e, "$responseBodyText", { - value: encoded, - }); - } - throw e; - } - } - return {}; - }), - "parseJsonBody" -); -var parseJsonErrorBody = /* @__PURE__ */ __name(async (errorBody, context) => { - const value = await parseJsonBody(errorBody, context); - value.message = value.message ?? value.Message; - return value; -}, "parseJsonErrorBody"); -var loadRestJsonErrorCode = /* @__PURE__ */ __name((output, data) => { - const findKey = /* @__PURE__ */ __name( - (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()), - "findKey" - ); - const sanitizeErrorCode = /* @__PURE__ */ __name((rawValue) => { - let cleanValue = rawValue; - if (typeof cleanValue === "number") { - cleanValue = cleanValue.toString(); - } - if (cleanValue.indexOf(",") >= 0) { - cleanValue = cleanValue.split(",")[0]; - } - if (cleanValue.indexOf(":") >= 0) { - cleanValue = cleanValue.split(":")[0]; - } - if (cleanValue.indexOf("#") >= 0) { - cleanValue = cleanValue.split("#")[1]; - } - return cleanValue; - }, "sanitizeErrorCode"); - const headerKey = findKey(output.headers, "x-amzn-errortype"); - if (headerKey !== void 0) { - return sanitizeErrorCode(output.headers[headerKey]); - } - if (data.code !== void 0) { - return sanitizeErrorCode(data.code); - } - if (data["__type"] !== void 0) { - return sanitizeErrorCode(data["__type"]); - } -}, "loadRestJsonErrorCode"); - -// src/protocols/xml/parseXmlBody.ts - -var import_fast_xml_parser = require("fast-xml-parser"); -var parseXmlBody = /* @__PURE__ */ __name( - (streamBody, context) => - collectBodyString(streamBody, context).then((encoded) => { - if (encoded.length) { - const parser = new import_fast_xml_parser.XMLParser({ - attributeNamePrefix: "", - htmlEntities: true, - ignoreAttributes: false, - ignoreDeclaration: true, - parseTagValue: false, - trimValues: false, - tagValueProcessor: (_, val) => (val.trim() === "" && val.includes("\n") ? "" : void 0), - }); - parser.addEntity("#xD", "\r"); - parser.addEntity("#10", "\n"); - let parsedObj; - try { - parsedObj = parser.parse(encoded, true); - } catch (e) { - if (e && typeof e === "object") { - Object.defineProperty(e, "$responseBodyText", { - value: encoded, - }); - } - throw e; - } - const textNodeName = "#text"; - const key = Object.keys(parsedObj)[0]; - const parsedObjToReturn = parsedObj[key]; - if (parsedObjToReturn[textNodeName]) { - parsedObjToReturn[key] = parsedObjToReturn[textNodeName]; - delete parsedObjToReturn[textNodeName]; - } - return (0, import_smithy_client.getValueFromTextNode)(parsedObjToReturn); - } - return {}; - }), - "parseXmlBody" -); -var parseXmlErrorBody = /* @__PURE__ */ __name(async (errorBody, context) => { - const value = await parseXmlBody(errorBody, context); - if (value.Error) { - value.Error.message = value.Error.message ?? value.Error.Message; - } - return value; -}, "parseXmlErrorBody"); -var loadRestXmlErrorCode = /* @__PURE__ */ __name((output, data) => { - var _a; - if (((_a = data == null ? void 0 : data.Error) == null ? void 0 : _a.Code) !== void 0) { - return data.Error.Code; - } - if ((data == null ? void 0 : data.Code) !== void 0) { - return data.Code; - } - if (output.statusCode == 404) { - return "NotFound"; - } -}, "loadRestXmlErrorCode"); -// Annotate the CommonJS export names for ESM import in node: - -0 && - (module.exports = { - emitWarningIfUnsupportedVersion, - AwsSdkSigV4Signer, - AWSSDKSigV4Signer, - resolveAwsSdkSigV4Config, - resolveAWSSDKSigV4Config, - _toStr, - _toBool, - _toNum, - awsExpectUnion, - parseJsonBody, - parseJsonErrorBody, - loadRestJsonErrorCode, - parseXmlBody, - parseXmlErrorBody, - loadRestXmlErrorCode, - }); diff --git a/packages/core/distcjs/protocols/coercing-serializers.js b/packages/core/distcjs/protocols/coercing-serializers.js deleted file mode 100644 index fa1ab10d97dc..000000000000 --- a/packages/core/distcjs/protocols/coercing-serializers.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../index.js"); diff --git a/packages/core/distcjs/protocols/common.js b/packages/core/distcjs/protocols/common.js deleted file mode 100644 index fa1ab10d97dc..000000000000 --- a/packages/core/distcjs/protocols/common.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../index.js"); diff --git a/packages/core/distcjs/protocols/index.js b/packages/core/distcjs/protocols/index.js deleted file mode 100644 index fa1ab10d97dc..000000000000 --- a/packages/core/distcjs/protocols/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../index.js"); diff --git a/packages/core/distcjs/protocols/json/awsExpectUnion.js b/packages/core/distcjs/protocols/json/awsExpectUnion.js deleted file mode 100644 index ecafff3570ff..000000000000 --- a/packages/core/distcjs/protocols/json/awsExpectUnion.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/protocols/json/parseJsonBody.js b/packages/core/distcjs/protocols/json/parseJsonBody.js deleted file mode 100644 index ecafff3570ff..000000000000 --- a/packages/core/distcjs/protocols/json/parseJsonBody.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../index.js"); diff --git a/packages/core/distcjs/protocols/xml/parseXmlBody.js b/packages/core/distcjs/protocols/xml/parseXmlBody.js deleted file mode 100644 index ecafff3570ff..000000000000 --- a/packages/core/distcjs/protocols/xml/parseXmlBody.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("../../index.js"); diff --git a/packages/core/distes/client/emitWarningIfUnsupportedVersion.js b/packages/core/distes/client/emitWarningIfUnsupportedVersion.js deleted file mode 100644 index 4c6bf51626b8..000000000000 --- a/packages/core/distes/client/emitWarningIfUnsupportedVersion.js +++ /dev/null @@ -1,6 +0,0 @@ -let warningEmitted = false; -export const emitWarningIfUnsupportedVersion = (version) => { - if (version && !warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 16) { - warningEmitted = true; - } -}; diff --git a/packages/core/distes/client/index.js b/packages/core/distes/client/index.js deleted file mode 100644 index ed9af92686a2..000000000000 --- a/packages/core/distes/client/index.js +++ /dev/null @@ -1 +0,0 @@ -export * from "./emitWarningIfUnsupportedVersion"; diff --git a/packages/core/distes/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js b/packages/core/distes/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js deleted file mode 100644 index 9270be813a24..000000000000 --- a/packages/core/distes/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.js +++ /dev/null @@ -1,60 +0,0 @@ -import { HttpRequest } from "@smithy/protocol-http"; -import { getDateHeader, getSkewCorrectedDate, getUpdatedSystemClockOffset } from "../utils"; -const throwSigningPropertyError = (name, property) => { - if (!property) { - throw new Error(`Property \`${name}\` is not resolved for AWS SDK SigV4Auth`); - } - return property; -}; -const validateSigningProperties = async (signingProperties) => { - const context = throwSigningPropertyError("context", signingProperties.context); - const config = throwSigningPropertyError("config", signingProperties.config); - const authScheme = context.endpointV2?.properties?.authSchemes?.[0]; - const signerFunction = throwSigningPropertyError("signer", config.signer); - const signer = await signerFunction(authScheme); - const signingRegion = signingProperties?.signingRegion; - const signingName = signingProperties?.signingName; - return { - config, - signer, - signingRegion, - signingName, - }; -}; -export class AwsSdkSigV4Signer { - async sign(httpRequest, identity, signingProperties) { - if (!HttpRequest.isInstance(httpRequest)) { - throw new Error("The request is not an instance of `HttpRequest` and cannot be signed"); - } - const { config, signer, signingRegion, signingName } = await validateSigningProperties(signingProperties); - const signedRequest = await signer.sign(httpRequest, { - signingDate: getSkewCorrectedDate(config.systemClockOffset), - signingRegion: signingRegion, - signingService: signingName, - }); - return signedRequest; - } - errorHandler(signingProperties) { - return (error) => { - const serverTime = error.ServerTime ?? getDateHeader(error.$response); - if (serverTime) { - const config = throwSigningPropertyError("config", signingProperties.config); - const initialSystemClockOffset = config.systemClockOffset; - config.systemClockOffset = getUpdatedSystemClockOffset(serverTime, config.systemClockOffset); - const clockSkewCorrected = config.systemClockOffset !== initialSystemClockOffset; - if (clockSkewCorrected && error.$metadata) { - error.$metadata.clockSkewCorrected = true; - } - } - throw error; - }; - } - successHandler(httpResponse, signingProperties) { - const dateHeader = getDateHeader(httpResponse); - if (dateHeader) { - const config = throwSigningPropertyError("config", signingProperties.config); - config.systemClockOffset = getUpdatedSystemClockOffset(dateHeader, config.systemClockOffset); - } - } -} -export const AWSSDKSigV4Signer = AwsSdkSigV4Signer; diff --git a/packages/core/distes/httpAuthSchemes/aws_sdk/index.js b/packages/core/distes/httpAuthSchemes/aws_sdk/index.js deleted file mode 100644 index 6d17c7096d04..000000000000 --- a/packages/core/distes/httpAuthSchemes/aws_sdk/index.js +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./AwsSdkSigV4Signer"; -export * from "./resolveAwsSdkSigV4Config"; diff --git a/packages/core/distes/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js b/packages/core/distes/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js deleted file mode 100644 index e8222e1e7163..000000000000 --- a/packages/core/distes/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.js +++ /dev/null @@ -1,93 +0,0 @@ -import { - doesIdentityRequireRefresh, - isIdentityExpired, - memoizeIdentityProvider, - normalizeProvider, -} from "@smithy/core"; -import { SignatureV4 } from "@smithy/signature-v4"; -export const resolveAwsSdkSigV4Config = (config) => { - let normalizedCreds; - if (config.credentials) { - normalizedCreds = memoizeIdentityProvider(config.credentials, isIdentityExpired, doesIdentityRequireRefresh); - } - if (!normalizedCreds) { - if (config.credentialDefaultProvider) { - normalizedCreds = normalizeProvider( - config.credentialDefaultProvider( - Object.assign({}, config, { - parentClientConfig: config, - }) - ) - ); - } else { - normalizedCreds = async () => { - throw new Error("`credentials` is missing"); - }; - } - } - const { signingEscapePath = true, systemClockOffset = config.systemClockOffset || 0, sha256 } = config; - let signer; - if (config.signer) { - signer = normalizeProvider(config.signer); - } else if (config.regionInfoProvider) { - signer = () => - normalizeProvider(config.region)() - .then(async (region) => [ - (await config.regionInfoProvider(region, { - useFipsEndpoint: await config.useFipsEndpoint(), - useDualstackEndpoint: await config.useDualstackEndpoint(), - })) || {}, - region, - ]) - .then(([regionInfo, region]) => { - const { signingRegion, signingService } = regionInfo; - config.signingRegion = config.signingRegion || signingRegion || region; - config.signingName = config.signingName || signingService || config.serviceId; - const params = { - ...config, - credentials: normalizedCreds, - region: config.signingRegion, - service: config.signingName, - sha256, - uriEscapePath: signingEscapePath, - }; - const SignerCtor = config.signerConstructor || SignatureV4; - return new SignerCtor(params); - }); - } else { - signer = async (authScheme) => { - authScheme = Object.assign( - {}, - { - name: "sigv4", - signingName: config.signingName || config.defaultSigningName, - signingRegion: await normalizeProvider(config.region)(), - properties: {}, - }, - authScheme - ); - const signingRegion = authScheme.signingRegion; - const signingService = authScheme.signingName; - config.signingRegion = config.signingRegion || signingRegion; - config.signingName = config.signingName || signingService || config.serviceId; - const params = { - ...config, - credentials: normalizedCreds, - region: config.signingRegion, - service: config.signingName, - sha256, - uriEscapePath: signingEscapePath, - }; - const SignerCtor = config.signerConstructor || SignatureV4; - return new SignerCtor(params); - }; - } - return { - ...config, - systemClockOffset, - signingEscapePath, - credentials: normalizedCreds, - signer, - }; -}; -export const resolveAWSSDKSigV4Config = resolveAwsSdkSigV4Config; diff --git a/packages/core/distes/httpAuthSchemes/index.js b/packages/core/distes/httpAuthSchemes/index.js deleted file mode 100644 index 29d0c3bdf9f8..000000000000 --- a/packages/core/distes/httpAuthSchemes/index.js +++ /dev/null @@ -1 +0,0 @@ -export * from "./aws_sdk"; diff --git a/packages/core/distes/httpAuthSchemes/utils/getDateHeader.js b/packages/core/distes/httpAuthSchemes/utils/getDateHeader.js deleted file mode 100644 index dd7255dbcc3f..000000000000 --- a/packages/core/distes/httpAuthSchemes/utils/getDateHeader.js +++ /dev/null @@ -1,3 +0,0 @@ -import { HttpResponse } from "@smithy/protocol-http"; -export const getDateHeader = (response) => - HttpResponse.isInstance(response) ? response.headers?.date ?? response.headers?.Date : undefined; diff --git a/packages/core/distes/httpAuthSchemes/utils/getSkewCorrectedDate.js b/packages/core/distes/httpAuthSchemes/utils/getSkewCorrectedDate.js deleted file mode 100644 index 6ee803634879..000000000000 --- a/packages/core/distes/httpAuthSchemes/utils/getSkewCorrectedDate.js +++ /dev/null @@ -1 +0,0 @@ -export const getSkewCorrectedDate = (systemClockOffset) => new Date(Date.now() + systemClockOffset); diff --git a/packages/core/distes/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js b/packages/core/distes/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js deleted file mode 100644 index 69623d6b9d76..000000000000 --- a/packages/core/distes/httpAuthSchemes/utils/getUpdatedSystemClockOffset.js +++ /dev/null @@ -1,8 +0,0 @@ -import { isClockSkewed } from "./isClockSkewed"; -export const getUpdatedSystemClockOffset = (clockTime, currentSystemClockOffset) => { - const clockTimeInMs = Date.parse(clockTime); - if (isClockSkewed(clockTimeInMs, currentSystemClockOffset)) { - return clockTimeInMs - Date.now(); - } - return currentSystemClockOffset; -}; diff --git a/packages/core/distes/httpAuthSchemes/utils/index.js b/packages/core/distes/httpAuthSchemes/utils/index.js deleted file mode 100644 index 07c21953a4dd..000000000000 --- a/packages/core/distes/httpAuthSchemes/utils/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./getDateHeader"; -export * from "./getSkewCorrectedDate"; -export * from "./getUpdatedSystemClockOffset"; diff --git a/packages/core/distes/httpAuthSchemes/utils/isClockSkewed.js b/packages/core/distes/httpAuthSchemes/utils/isClockSkewed.js deleted file mode 100644 index 62f11064725c..000000000000 --- a/packages/core/distes/httpAuthSchemes/utils/isClockSkewed.js +++ /dev/null @@ -1,3 +0,0 @@ -import { getSkewCorrectedDate } from "./getSkewCorrectedDate"; -export const isClockSkewed = (clockTime, systemClockOffset) => - Math.abs(getSkewCorrectedDate(systemClockOffset).getTime() - clockTime) >= 300000; diff --git a/packages/core/distes/index.js b/packages/core/distes/index.js deleted file mode 100644 index 532feb93c8c9..000000000000 --- a/packages/core/distes/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export * from "./client/index"; -export * from "./httpAuthSchemes/index"; -export * from "./protocols/index"; diff --git a/packages/core/distes/protocols/coercing-serializers.js b/packages/core/distes/protocols/coercing-serializers.js deleted file mode 100644 index cbe29e273881..000000000000 --- a/packages/core/distes/protocols/coercing-serializers.js +++ /dev/null @@ -1,53 +0,0 @@ -export const _toStr = (val) => { - if (val == null) { - return val; - } - if (typeof val === "number" || typeof val === "bigint") { - const warning = new Error(`Received number ${val} where a string was expected.`); - warning.name = "Warning"; - console.warn(warning); - return String(val); - } - if (typeof val === "boolean") { - const warning = new Error(`Received boolean ${val} where a string was expected.`); - warning.name = "Warning"; - console.warn(warning); - return String(val); - } - return val; -}; -export const _toBool = (val) => { - if (val == null) { - return val; - } - if (typeof val === "number") { - } - if (typeof val === "string") { - const lowercase = val.toLowerCase(); - if (val !== "" && lowercase !== "false" && lowercase !== "true") { - const warning = new Error(`Received string "${val}" where a boolean was expected.`); - warning.name = "Warning"; - console.warn(warning); - } - return val !== "" && lowercase !== "false"; - } - return val; -}; -export const _toNum = (val) => { - if (val == null) { - return val; - } - if (typeof val === "boolean") { - } - if (typeof val === "string") { - const num = Number(val); - if (num.toString() !== val) { - const warning = new Error(`Received string "${val}" where a number was expected.`); - warning.name = "Warning"; - console.warn(warning); - return val; - } - return num; - } - return val; -}; diff --git a/packages/core/distes/protocols/common.js b/packages/core/distes/protocols/common.js deleted file mode 100644 index 65c9a2c329e0..000000000000 --- a/packages/core/distes/protocols/common.js +++ /dev/null @@ -1,3 +0,0 @@ -import { collectBody } from "@smithy/smithy-client"; -export const collectBodyString = (streamBody, context) => - collectBody(streamBody, context).then((body) => context.utf8Encoder(body)); diff --git a/packages/core/distes/protocols/index.js b/packages/core/distes/protocols/index.js deleted file mode 100644 index 09a6ac214ca0..000000000000 --- a/packages/core/distes/protocols/index.js +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./coercing-serializers"; -export * from "./json/awsExpectUnion"; -export * from "./json/parseJsonBody"; -export * from "./xml/parseXmlBody"; diff --git a/packages/core/distes/protocols/json/awsExpectUnion.js b/packages/core/distes/protocols/json/awsExpectUnion.js deleted file mode 100644 index 8af9a9659ef5..000000000000 --- a/packages/core/distes/protocols/json/awsExpectUnion.js +++ /dev/null @@ -1,10 +0,0 @@ -import { expectUnion } from "@smithy/smithy-client"; -export const awsExpectUnion = (value) => { - if (value == null) { - return undefined; - } - if (typeof value === "object" && "__type" in value) { - delete value.__type; - } - return expectUnion(value); -}; diff --git a/packages/core/distes/protocols/json/parseJsonBody.js b/packages/core/distes/protocols/json/parseJsonBody.js deleted file mode 100644 index aebfbf3d0e94..000000000000 --- a/packages/core/distes/protocols/json/parseJsonBody.js +++ /dev/null @@ -1,51 +0,0 @@ -import { collectBodyString } from "../common"; -export const parseJsonBody = (streamBody, context) => - collectBodyString(streamBody, context).then((encoded) => { - if (encoded.length) { - try { - return JSON.parse(encoded); - } catch (e) { - if (e?.name === "SyntaxError") { - Object.defineProperty(e, "$responseBodyText", { - value: encoded, - }); - } - throw e; - } - } - return {}; - }); -export const parseJsonErrorBody = async (errorBody, context) => { - const value = await parseJsonBody(errorBody, context); - value.message = value.message ?? value.Message; - return value; -}; -export const loadRestJsonErrorCode = (output, data) => { - const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase()); - const sanitizeErrorCode = (rawValue) => { - let cleanValue = rawValue; - if (typeof cleanValue === "number") { - cleanValue = cleanValue.toString(); - } - if (cleanValue.indexOf(",") >= 0) { - cleanValue = cleanValue.split(",")[0]; - } - if (cleanValue.indexOf(":") >= 0) { - cleanValue = cleanValue.split(":")[0]; - } - if (cleanValue.indexOf("#") >= 0) { - cleanValue = cleanValue.split("#")[1]; - } - return cleanValue; - }; - const headerKey = findKey(output.headers, "x-amzn-errortype"); - if (headerKey !== undefined) { - return sanitizeErrorCode(output.headers[headerKey]); - } - if (data.code !== undefined) { - return sanitizeErrorCode(data.code); - } - if (data["__type"] !== undefined) { - return sanitizeErrorCode(data["__type"]); - } -}; diff --git a/packages/core/distes/protocols/xml/parseXmlBody.js b/packages/core/distes/protocols/xml/parseXmlBody.js deleted file mode 100644 index 4725538800ce..000000000000 --- a/packages/core/distes/protocols/xml/parseXmlBody.js +++ /dev/null @@ -1,57 +0,0 @@ -import { getValueFromTextNode } from "@smithy/smithy-client"; -import { XMLParser } from "fast-xml-parser"; -import { collectBodyString } from "../common"; -export const parseXmlBody = (streamBody, context) => - collectBodyString(streamBody, context).then((encoded) => { - if (encoded.length) { - const parser = new XMLParser({ - attributeNamePrefix: "", - htmlEntities: true, - ignoreAttributes: false, - ignoreDeclaration: true, - parseTagValue: false, - trimValues: false, - tagValueProcessor: (_, val) => (val.trim() === "" && val.includes("\n") ? "" : undefined), - }); - parser.addEntity("#xD", "\r"); - parser.addEntity("#10", "\n"); - let parsedObj; - try { - parsedObj = parser.parse(encoded, true); - } catch (e) { - if (e && typeof e === "object") { - Object.defineProperty(e, "$responseBodyText", { - value: encoded, - }); - } - throw e; - } - const textNodeName = "#text"; - const key = Object.keys(parsedObj)[0]; - const parsedObjToReturn = parsedObj[key]; - if (parsedObjToReturn[textNodeName]) { - parsedObjToReturn[key] = parsedObjToReturn[textNodeName]; - delete parsedObjToReturn[textNodeName]; - } - return getValueFromTextNode(parsedObjToReturn); - } - return {}; - }); -export const parseXmlErrorBody = async (errorBody, context) => { - const value = await parseXmlBody(errorBody, context); - if (value.Error) { - value.Error.message = value.Error.message ?? value.Error.Message; - } - return value; -}; -export const loadRestXmlErrorCode = (output, data) => { - if (data?.Error?.Code !== undefined) { - return data.Error.Code; - } - if (data?.Code !== undefined) { - return data.Code; - } - if (output.statusCode == 404) { - return "NotFound"; - } -};