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

Upgrade aws-sdk clients from alpha to beta #5209

Merged
merged 8 commits into from
Mar 27, 2020
8 changes: 4 additions & 4 deletions packages/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"dependencies": {
"@aws-amplify/cache": "^2.1.6",
"@aws-amplify/core": "^2.2.5",
"@aws-sdk/client-firehose": "1.0.0-alpha.26",
"@aws-sdk/client-kinesis": "1.0.0-alpha.26",
"@aws-sdk/client-personalize-events": "1.0.0-alpha.24",
"@aws-sdk/client-pinpoint": "1.0.0-alpha.24",
"@aws-sdk/client-firehose": "1.0.0-beta.1",
"@aws-sdk/client-kinesis": "1.0.0-beta.1",
"@aws-sdk/client-personalize-events": "1.0.0-beta.1",
"@aws-sdk/client-pinpoint": "1.0.0-beta.1",
"uuid": "^3.2.1"
},
"jest": {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/__tests__/Credentials-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ describe('Credentials test', () => {
Amplify.register(cacheClass);
const credentials = new Credentials(null);

const expiration = new Date().getTime() + 20 * 60 * 1000;
const expiration = new Date(new Date().getTime() + 20 * 60 * 1000);
credentials['_credentials'] = {
expiration,
};
credentials['_nextCredentialsRefresh'] = expiration + 1;
credentials['_nextCredentialsRefresh'] = expiration.getTime() + 1;
expect(await credentials.get()).toEqual(credentials['_credentials']);
});

Expand Down
12 changes: 6 additions & 6 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
},
"dependencies": {
"@aws-crypto/sha256-js": "1.0.0-alpha.0",
"@aws-sdk/client-cognito-identity": "1.0.0-alpha.26",
"@aws-sdk/credential-provider-cognito-identity": "1.0.0-alpha.24",
"@aws-sdk/node-http-handler": "1.0.0-alpha.9",
"@aws-sdk/types": "1.0.0-alpha.6",
"@aws-sdk/util-hex-encoding": "1.0.0-alpha.3",
"@aws-sdk/util-user-agent-browser": "1.0.0-alpha.9",
"@aws-sdk/client-cognito-identity": "1.0.0-beta.1",
"@aws-sdk/credential-provider-cognito-identity": "1.0.0-beta.1",
"@aws-sdk/node-http-handler": "1.0.0-beta.1",
"@aws-sdk/types": "1.0.0-beta.1",
"@aws-sdk/util-hex-encoding": "1.0.0-beta.1",
"@aws-sdk/util-user-agent-browser": "1.0.0-beta.1",
"url": "^0.11.0",
"zen-observable-ts": "0.8.19"
},
Expand Down
14 changes: 10 additions & 4 deletions packages/core/src/Credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,17 @@ export class CredentialsClass {
return true;
}
logger.debug('are these credentials expired?', credentials);
const ts = Math.floor(Date.now() / 1000);
const delta = 10 * 60; // 10 minutes in seconds
const { expiration } = credentials; // returns unix time stamp
const ts = Date.now();
const delta = 10 * 60 * 1000; // 10 minutes in milli seconds

if (expiration > ts + delta && ts < this._nextCredentialsRefresh) {
/* returns date object.
https://github.com/aws/aws-sdk-js-v3/blob/v1.0.0-beta.1/packages/types/src/credentials.ts#L26
*/
const { expiration } = credentials;
if (
expiration.getTime() > ts + delta &&
ts < this._nextCredentialsRefresh
) {
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion packages/interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"homepage": "https://aws-amplify.github.io/",
"dependencies": {
"@aws-amplify/core": "^2.2.5",
"@aws-sdk/client-lex-runtime-service": "1.0.0-alpha.24"
"@aws-sdk/client-lex-runtime-service": "1.0.0-beta.1"
},
"jest": {
"globals": {
Expand Down
14 changes: 7 additions & 7 deletions packages/predictions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
"dependencies": {
"@aws-amplify/core": "^2.2.5",
"@aws-amplify/storage": "^2.2.1",
"@aws-sdk/client-comprehend": "1.0.0-alpha.26",
"@aws-sdk/client-polly": "1.0.0-alpha.25",
"@aws-sdk/client-rekognition": "1.0.0-alpha.26",
"@aws-sdk/client-textract": "1.0.0-alpha.25",
"@aws-sdk/client-translate": "1.0.0-alpha.26",
"@aws-sdk/eventstream-marshaller": "1.0.0-alpha.8",
"@aws-sdk/util-utf8-node": "1.0.0-alpha.3",
"@aws-sdk/client-comprehend": "1.0.0-beta.1",
"@aws-sdk/client-polly": "1.0.0-beta.1",
"@aws-sdk/client-rekognition": "1.0.0-beta.1",
"@aws-sdk/client-textract": "1.0.0-beta.1",
"@aws-sdk/client-translate": "1.0.0-beta.1",
"@aws-sdk/eventstream-marshaller": "1.0.0-beta.1",
"@aws-sdk/util-utf8-node": "1.0.0-beta.1",
"uuid": "^3.2.1"
},
"jest": {
Expand Down
8 changes: 4 additions & 4 deletions packages/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"homepage": "https://aws-amplify.github.io/",
"dependencies": {
"@aws-amplify/core": "^2.2.5",
"@aws-sdk/client-s3": "1.0.0-alpha.21",
"@aws-sdk/s3-request-presigner": "1.0.0-alpha.18",
"@aws-sdk/util-create-request": "1.0.0-alpha.13",
"@aws-sdk/util-format-url": "1.0.0-alpha.6",
"@aws-sdk/client-s3": "1.0.0-beta.1",
"@aws-sdk/s3-request-presigner": "1.0.0-beta.1",
"@aws-sdk/util-create-request": "1.0.0-beta.1",
"@aws-sdk/util-format-url": "1.0.0-beta.1",
"events": "^3.1.0",
"sinon": "^7.5.0"
},
Expand Down