diff --git a/CHANGELOG.md b/CHANGELOG.md index a6ee34f..c74376f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## v0.7.1-alpha +- 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) 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" 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(