diff --git a/.circleci/config.yml b/.circleci/config.yml index 94dc680a4f7..219157bb18f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1218,6 +1218,7 @@ releasable_branches: &releasable_branches - ui-components/main - 1.0-stable - geo/main + - bump-aws-sdk-3.175.0 test_browsers: &test_browsers browser: [chrome, firefox] diff --git a/packages/amplify-ui-vue/tsconfig.json b/packages/amplify-ui-vue/tsconfig.json index 0db6e5d4edd..30dfb87dc88 100755 --- a/packages/amplify-ui-vue/tsconfig.json +++ b/packages/amplify-ui-vue/tsconfig.json @@ -18,7 +18,7 @@ "sourceMap": true, "jsx": "react", "target": "es2015", - "types": [] + "types": ["node"] }, "include": ["src/**/*.ts", "src/**/*.tsx"], "exclude": ["**/__tests__/**"], diff --git a/packages/analytics/package.json b/packages/analytics/package.json index d3fc5ec32f4..8ff6d8d6041 100644 --- a/packages/analytics/package.json +++ b/packages/analytics/package.json @@ -45,11 +45,11 @@ "dependencies": { "@aws-amplify/cache": "4.0.56", "@aws-amplify/core": "4.7.5", - "@aws-sdk/client-firehose": "3.6.1", - "@aws-sdk/client-kinesis": "3.6.1", - "@aws-sdk/client-personalize-events": "3.6.1", - "@aws-sdk/client-pinpoint": "3.6.1", - "@aws-sdk/util-utf8-browser": "3.6.1", + "@aws-sdk/client-firehose": "3.171.0", + "@aws-sdk/client-kinesis": "3.171.0", + "@aws-sdk/client-personalize-events": "3.171.0", + "@aws-sdk/client-pinpoint": "3.171.0", + "@aws-sdk/util-utf8-browser": "3.170.0", "lodash": "^4.17.20", "uuid": "^3.2.1" }, diff --git a/packages/aws-amplify-angular/rollup.config.js b/packages/aws-amplify-angular/rollup.config.js index 9af1e75161d..9f4d4f75e43 100644 --- a/packages/aws-amplify-angular/rollup.config.js +++ b/packages/aws-amplify-angular/rollup.config.js @@ -36,7 +36,7 @@ export default { '@aws-amplify/core', ], plugins: [ - nodeResolve({ preferBuiltins: false, modulesOnly: true }), + nodeResolve({ preferBuiltins: false, modulesOnly: true, browser: true }), commonjs({ include: 'node_modules/**' }), globals(), json(), diff --git a/packages/core/package.json b/packages/core/package.json index 525ad7fe737..1200c6a7345 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -56,11 +56,11 @@ }, "dependencies": { "@aws-crypto/sha256-js": "1.0.0-alpha.0", - "@aws-sdk/client-cloudwatch-logs": "3.6.1", - "@aws-sdk/client-cognito-identity": "3.6.1", - "@aws-sdk/credential-provider-cognito-identity": "3.6.1", - "@aws-sdk/types": "3.6.1", - "@aws-sdk/util-hex-encoding": "3.6.1", + "@aws-sdk/client-cloudwatch-logs": "3.171.0", + "@aws-sdk/client-cognito-identity": "3.171.0", + "@aws-sdk/credential-provider-cognito-identity": "3.171.0", + "@aws-sdk/types": "3.171.0", + "@aws-sdk/util-hex-encoding": "3.170.0", "universal-cookie": "^4.0.4", "zen-observable-ts": "0.8.19" }, diff --git a/packages/geo/package.json b/packages/geo/package.json index 74db09fde7f..e5d4ef7a6d8 100644 --- a/packages/geo/package.json +++ b/packages/geo/package.json @@ -42,7 +42,7 @@ "homepage": "https://aws-amplify.github.io/", "dependencies": { "@aws-amplify/core": "4.7.5", - "@aws-sdk/client-location": "3.48.0", + "@aws-sdk/client-location": "3.171.0", "@turf/boolean-clockwise": "6.5.0", "camelcase-keys": "6.2.2" }, diff --git a/packages/interactions/package.json b/packages/interactions/package.json index 5b288d111d5..c9f041382be 100644 --- a/packages/interactions/package.json +++ b/packages/interactions/package.json @@ -42,7 +42,7 @@ "homepage": "https://aws-amplify.github.io/", "dependencies": { "@aws-amplify/core": "4.7.5", - "@aws-sdk/client-lex-runtime-service": "3.6.1", + "@aws-sdk/client-lex-runtime-service": "3.171.0", "@aws-sdk/client-lex-runtime-v2": "3.171.0", "base-64": "1.0.0", "fflate": "0.7.3", diff --git a/packages/predictions/package.json b/packages/predictions/package.json index fd25b4f0464..c524dd27f98 100644 --- a/packages/predictions/package.json +++ b/packages/predictions/package.json @@ -42,13 +42,13 @@ "dependencies": { "@aws-amplify/core": "4.7.5", "@aws-amplify/storage": "4.5.7", - "@aws-sdk/client-comprehend": "3.6.1", - "@aws-sdk/client-polly": "3.6.1", - "@aws-sdk/client-rekognition": "3.6.1", - "@aws-sdk/client-textract": "3.6.1", - "@aws-sdk/client-translate": "3.6.1", - "@aws-sdk/eventstream-marshaller": "3.6.1", - "@aws-sdk/util-utf8-node": "3.6.1", + "@aws-sdk/client-comprehend": "3.171.0", + "@aws-sdk/client-polly": "3.171.0", + "@aws-sdk/client-rekognition": "3.171.0", + "@aws-sdk/client-textract": "3.171.0", + "@aws-sdk/client-translate": "3.171.0", + "@aws-sdk/eventstream-codec": "3.171.0", + "@aws-sdk/util-utf8-node": "3.170.0", "uuid": "^3.2.1" }, "jest": { diff --git a/packages/predictions/src/Providers/AmazonAIConvertPredictionsProvider.ts b/packages/predictions/src/Providers/AmazonAIConvertPredictionsProvider.ts index 686b8fe8816..f7b7f161d80 100644 --- a/packages/predictions/src/Providers/AmazonAIConvertPredictionsProvider.ts +++ b/packages/predictions/src/Providers/AmazonAIConvertPredictionsProvider.ts @@ -20,13 +20,13 @@ import { getAmplifyUserAgent, } from '@aws-amplify/core'; import { - EventStreamMarshaller, + EventStreamCodec, MessageHeaderValue, -} from '@aws-sdk/eventstream-marshaller'; +} from '@aws-sdk/eventstream-codec'; import { fromUtf8, toUtf8 } from '@aws-sdk/util-utf8-node'; const logger = new Logger('AmazonAIConvertPredictionsProvider'); -const eventBuilder = new EventStreamMarshaller(toUtf8, fromUtf8); +const eventCodec = new EventStreamCodec(toUtf8, fromUtf8); const LANGUAGES_CODE_IN_8KHZ = ['fr-FR', 'en-AU', 'en-GB', 'fr-CA']; @@ -206,9 +206,7 @@ export class AmazonAIConvertPredictionsProvider extends AbstractConvertPredictio public static serializeDataFromTranscribe(message) { let decodedMessage = ''; - const transcribeMessage = eventBuilder.unmarshall( - Buffer.from(message.data) - ); + const transcribeMessage = eventCodec.decode(Buffer.from(message.data)); const transcribeMessageJson = JSON.parse(toUtf8(transcribeMessage.body)); if (transcribeMessage.headers[':message-type'].value === 'exception') { logger.debug( @@ -254,9 +252,10 @@ export class AmazonAIConvertPredictionsProvider extends AbstractConvertPredictio let fullText = ''; connection.onmessage = message => { try { - const decodedMessage = AmazonAIConvertPredictionsProvider.serializeDataFromTranscribe( - message - ); + const decodedMessage = + AmazonAIConvertPredictionsProvider.serializeDataFromTranscribe( + message + ); if (decodedMessage) { fullText += decodedMessage + ' '; } @@ -290,7 +289,7 @@ export class AmazonAIConvertPredictionsProvider extends AbstractConvertPredictio // sending end frame const endFrameEventMessage = this.getAudioEventMessage(Buffer.from([])); - const endFrameBinary = eventBuilder.marshall(endFrameEventMessage); + const endFrameBinary = eventCodec.encode(endFrameEventMessage); connection.send(endFrameBinary); }); } @@ -306,7 +305,7 @@ export class AmazonAIConvertPredictionsProvider extends AbstractConvertPredictio const audioEventMessage = this.getAudioEventMessage( Buffer.from(pcmEncodedBuffer) ); - const binary = eventBuilder.marshall(audioEventMessage); + const binary = eventCodec.encode(audioEventMessage); connection.send(binary); } diff --git a/packages/storage/__tests__/common/S3ClientUtils-unit-test.ts b/packages/storage/__tests__/common/S3ClientUtils-unit-test.ts index 27245a9b52f..5676bd75dc2 100644 --- a/packages/storage/__tests__/common/S3ClientUtils-unit-test.ts +++ b/packages/storage/__tests__/common/S3ClientUtils-unit-test.ts @@ -10,7 +10,7 @@ import { Credentials, getAmplifyUserAgent, } from '@aws-amplify/core'; -import { S3ClientConfig } from '@aws-sdk/client-s3'; +import { S3ClientResolvedConfig } from '@aws-sdk/client-s3'; const credentials: ICredentials = { accessKeyId: 'accessKeyId', @@ -174,7 +174,7 @@ describe('S3ClientUtils tests', () => { const dateNow = Date.now(); // keep the Date.now() call inside the middleware consistent jest.spyOn(Date, 'now').mockImplementation(() => dateNow); - const s3ClientConfig = { systemClockOffset: 0 } as S3ClientConfig; + const s3ClientConfig = { systemClockOffset: 0 } as S3ClientResolvedConfig; const middleware = autoAdjustClockskewMiddleware(s3ClientConfig); const oneHourInMs = 1000 * 60 * 60; try { diff --git a/packages/storage/package.json b/packages/storage/package.json index 3fad4c4cf2f..f7b6e868369 100644 --- a/packages/storage/package.json +++ b/packages/storage/package.json @@ -42,10 +42,10 @@ "homepage": "https://aws-amplify.github.io/", "dependencies": { "@aws-amplify/core": "4.7.5", - "@aws-sdk/client-s3": "3.6.1", - "@aws-sdk/s3-request-presigner": "3.6.1", - "@aws-sdk/util-create-request": "3.6.1", - "@aws-sdk/util-format-url": "3.6.1", + "@aws-sdk/client-s3": "3.171.0", + "@aws-sdk/s3-request-presigner": "3.173.0", + "@aws-sdk/util-create-request": "3.171.0", + "@aws-sdk/util-format-url": "3.171.0", "axios": "0.26.0", "events": "^3.1.0" }, diff --git a/packages/storage/src/common/S3ClientUtils.ts b/packages/storage/src/common/S3ClientUtils.ts index 8366ff37e29..16739a77b4e 100644 --- a/packages/storage/src/common/S3ClientUtils.ts +++ b/packages/storage/src/common/S3ClientUtils.ts @@ -12,7 +12,7 @@ import { FinalizeRequestMiddleware, HandlerExecutionContext, } from '@aws-sdk/types'; -import { S3ClientConfig, S3Client } from '@aws-sdk/client-s3'; +import { S3ClientResolvedConfig, S3Client } from '@aws-sdk/client-s3'; import { CancelTokenSource } from 'axios'; import * as events from 'events'; import { AxiosHttpHandler } from '../providers/axios-http-handler'; @@ -62,24 +62,24 @@ export const getPrefix = (config: { } }; -export const createPrefixMiddleware = ( - opt: Record, - key: string -): InitializeMiddleware => (next, _context) => async args => { - const credentials = await Credentials.get(); - const cred = Credentials.shear(credentials); - const prefix = getPrefix({ ...opt, credentials: cred }); - const clonedInput = Object.assign({}, args.input); - if (Object.prototype.hasOwnProperty.call(args.input, 'Key')) { - clonedInput.Key = prefix + key; - args.input = clonedInput; - } else if (Object.prototype.hasOwnProperty.call(args.input, 'Prefix')) { - clonedInput.Prefix = prefix + key; - args.input = clonedInput; - } - const result = next(args); - return result; -}; +export const createPrefixMiddleware = + (opt: Record, key: string): InitializeMiddleware => + (next, _context) => + async args => { + const credentials = await Credentials.get(); + const cred = Credentials.shear(credentials); + const prefix = getPrefix({ ...opt, credentials: cred }); + const clonedInput = Object.assign({}, args.input); + if (Object.prototype.hasOwnProperty.call(args.input, 'Key')) { + clonedInput.Key = prefix + key; + args.input = clonedInput; + } else if (Object.prototype.hasOwnProperty.call(args.input, 'Prefix')) { + clonedInput.Prefix = prefix + key; + args.input = clonedInput; + } + const result = next(args); + return result; + }; const isTimeSkewedError = (err: any): boolean => err.ServerTime && @@ -87,27 +87,26 @@ const isTimeSkewedError = (err: any): boolean => err.Code === 'RequestTimeTooSkewed'; // we want to take the S3Client config in parameter so we can modify it's systemClockOffset -export const autoAdjustClockskewMiddleware = ( - config: S3ClientConfig -): FinalizeRequestMiddleware => ( - next, - _context: HandlerExecutionContext -) => async args => { - try { - return await next(args); - } catch (err) { - if (isTimeSkewedError(err)) { - const serverDate = new Date(err.ServerTime); - config.systemClockOffset = serverDate.getTime() - Date.now(); +export const autoAdjustClockskewMiddleware = + (config: S3ClientResolvedConfig): FinalizeRequestMiddleware => + (next, _context: HandlerExecutionContext) => + async args => { + try { + return await next(args); + } catch (err) { + if (isTimeSkewedError(err)) { + const serverDate = new Date(err.ServerTime); + config.systemClockOffset = serverDate.getTime() - Date.now(); + } + throw err; } - throw err; - } -}; + }; -export const autoAdjustClockskewMiddlewareOptions: FinalizeRequestHandlerOptions = { - step: 'finalizeRequest', - name: 'autoAdjustClockskewMiddleware', -}; +export const autoAdjustClockskewMiddlewareOptions: FinalizeRequestHandlerOptions = + { + step: 'finalizeRequest', + name: 'autoAdjustClockskewMiddleware', + }; export const prefixMiddlewareOptions: InitializeHandlerOptions = { step: 'initialize', diff --git a/packages/storage/src/providers/AWSS3ProviderManagedUpload.ts b/packages/storage/src/providers/AWSS3ProviderManagedUpload.ts index e8ce5fdb130..d9dbc4cc6fe 100644 --- a/packages/storage/src/providers/AWSS3ProviderManagedUpload.ts +++ b/packages/storage/src/providers/AWSS3ProviderManagedUpload.ts @@ -14,7 +14,7 @@ import { ConsoleLogger as Logger } from '@aws-amplify/core'; import { PutObjectCommand, - PutObjectRequest, + PutObjectCommandInput, CreateMultipartUploadCommand, UploadPartCommand, CompleteMultipartUploadCommand, @@ -55,7 +55,7 @@ export class AWSS3ProviderManagedUpload { // Data for current upload private body = null; - private params: PutObjectRequest = null; + private params: PutObjectCommandInput = null; private opts = null; private completedParts: CompletedPart[] = []; private s3client: S3Client; @@ -66,7 +66,11 @@ export class AWSS3ProviderManagedUpload { private totalBytesToUpload = 0; private emitter: events.EventEmitter = null; - constructor(params: PutObjectRequest, opts, emitter: events.EventEmitter) { + constructor( + params: PutObjectCommandInput, + opts, + emitter: events.EventEmitter + ) { this.params = params; this.opts = opts; this.emitter = emitter; @@ -97,7 +101,6 @@ export class AWSS3ProviderManagedUpload { start < numberOfPartsToUpload; start += this.queueSize ) { - // Upload as many as `queueSize` parts simultaneously await this.uploadParts( this.uploadId,