Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump up @aws-sdk packages to 3.175.0 #10362

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-ui-vue/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"sourceMap": true,
"jsx": "react",
"target": "es2015",
"types": []
"types": ["node"]
},
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": ["**/__tests__/**"],
Expand Down
10 changes: 5 additions & 5 deletions packages/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-amplify-angular/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
10 changes: 5 additions & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions packages/predictions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 + ' ';
}
Expand Down Expand Up @@ -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);
});
}
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions packages/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
75 changes: 37 additions & 38 deletions packages/storage/src/common/S3ClientUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -62,52 +62,51 @@ export const getPrefix = (config: {
}
};

export const createPrefixMiddleware = (
opt: Record<string, any>,
key: string
): InitializeMiddleware<any, any> => (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<string, any>, key: string): InitializeMiddleware<any, any> =>
(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 &&
typeof err.Code === 'string' &&
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<any, any> => (
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<any, any> =>
(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',
Expand Down
11 changes: 7 additions & 4 deletions packages/storage/src/providers/AWSS3ProviderManagedUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { ConsoleLogger as Logger } from '@aws-amplify/core';
import {
PutObjectCommand,
PutObjectRequest,
PutObjectCommandInput,
CreateMultipartUploadCommand,
UploadPartCommand,
CompleteMultipartUploadCommand,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -97,7 +101,6 @@ export class AWSS3ProviderManagedUpload {
start < numberOfPartsToUpload;
start += this.queueSize
) {

// Upload as many as `queueSize` parts simultaneously
await this.uploadParts(
this.uploadId,
Expand Down