Skip to content

Commit

Permalink
Upgrade aws-sdk clients from alpha to beta (#5209)
Browse files Browse the repository at this point in the history
* Migrate zen-observable to zen-observable-ts and fix zen-push import

* Fix unit tests

* Pin aws-sdk versions and rename presignRequest to presign

* Upgrade aws-sdk clients from alpha to beta

* Update expiration type to Date as per change in aws-sdk

* Fix unit tests as per expiration type change
  • Loading branch information
Amplifiyer committed Mar 27, 2020
1 parent 68cfdf6 commit 2a7fd81
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 28 deletions.
8 changes: 4 additions & 4 deletions packages/analytics/package.json
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
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
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
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
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
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
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

0 comments on commit 2a7fd81

Please sign in to comment.