From 370816d825cf16fcf4c2548376dcbf272308891f Mon Sep 17 00:00:00 2001 From: Anatoli Kurtsevich Date: Fri, 25 Aug 2023 10:41:29 -0400 Subject: [PATCH 1/3] modified AccessToken.createdOn to be in seconds instead of milliseconds --- CHANGELOG.md | 3 +++ src/credentials.ts | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6ee34f..4097fac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## Unreleased +- Storing `AccessToken.createdOn` in seconds to be consistent with other RAI SDKs. + ## [v0.7.0](https://github.com/relationalai/rai-sdk-javascript/tree/v0.7.0) (2022-XX-XX) [Full Changelog](https://github.com/relationalai/rai-sdk-javascript/compare/v0.6.3...v0.7.0) diff --git a/src/credentials.ts b/src/credentials.ts index 97e7e3a..4188ffd 100644 --- a/src/credentials.ts +++ b/src/credentials.ts @@ -41,8 +41,8 @@ class AccessToken { ) {} get isExpired() { - // experiesIn stored in seconds - const delta = (Date.now() - this.createdOn) / 1000; + // createdOn and experiesIn stored in seconds + const delta = Date.now() / 1000 - this.createdOn; // anticipate access token expiration by 60 seconds return delta + 60 >= this.experiesIn; @@ -126,7 +126,7 @@ export class ClientCredentials extends Credentials { const token: AccessTokenCache = { access_token: data.access_token, expires_in: data.expires_in, - created_on: Date.now(), + created_on: Date.now() / 1000, }; this.accessToken = new AccessToken( From be50ea63f32264c54fe7626506b28d61dce20906 Mon Sep 17 00:00:00 2001 From: Anatoli Kurtsevich Date: Fri, 25 Aug 2023 10:51:35 -0400 Subject: [PATCH 2/3] updated CHANGELOG --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4097fac..a381d20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,10 @@ # Change Log -## Unreleased +## v0.7.1-alpha27 - Storing `AccessToken.createdOn` in seconds to be consistent with other RAI SDKs. +## v0.7.0 + ## [v0.7.0](https://github.com/relationalai/rai-sdk-javascript/tree/v0.7.0) (2022-XX-XX) [Full Changelog](https://github.com/relationalai/rai-sdk-javascript/compare/v0.6.3...v0.7.0) From 241d8250880cea2deee5131c63039b1bb374f34c Mon Sep 17 00:00:00 2001 From: Anatoli Kurtsevich Date: Fri, 25 Aug 2023 11:07:14 -0400 Subject: [PATCH 3/3] updated changelog and version in package.json --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a381d20..c74376f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## v0.7.1-alpha27 +## v0.7.1-alpha - Storing `AccessToken.createdOn` in seconds to be consistent with other RAI SDKs. ## v0.7.0 diff --git a/package.json b/package.json index 9aeb408..94df398 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@relationalai/rai-sdk-javascript", "description": "RelationalAI SDK for JavaScript", - "version": "0.7.0", + "version": "0.7.1-alpha", "author": { "name": "RelationalAI", "url": "https://relational.ai"