rest-client-sdk
Advanced tools
Comparing version 4.1.3 to 4.1.4
# Changelog | ||
## 4.1.4 | ||
### Changed | ||
- Passing a string as argument to `ProvidedTokenGenerator` is now deprecated. You should pass the token object instead. It should have had a weird comportment before by the way. | ||
### Fixed | ||
- Fix issue when two token generation are send on the same time : the second one will not throw an error now. | ||
## 4.1.3 | ||
@@ -4,0 +14,0 @@ |
{ | ||
"name": "rest-client-sdk", | ||
"version": "4.1.3", | ||
"version": "4.1.4", | ||
"description": "Rest Client SDK for API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -240,7 +240,5 @@ import URI from 'urijs'; | ||
if (this._tokenStorage) { | ||
return Promise.all([ | ||
this._tokenStorage.getCurrentTokenExpiresIn(), | ||
this._tokenStorage.getAccessToken(), | ||
]) | ||
.then(([accessTokenExpiresIn, accessToken]) => { | ||
return this._tokenStorage | ||
.getCurrentTokenExpiresIn() | ||
.then((accessTokenExpiresIn) => { | ||
if ( | ||
@@ -257,3 +255,3 @@ accessTokenExpiresIn !== null && | ||
return accessToken; | ||
return this._tokenStorage.getAccessToken(); | ||
}) | ||
@@ -260,0 +258,0 @@ .then((token) => this._doFetch(token, input, requestParams)); |
@@ -6,2 +6,9 @@ import AbstractTokenGenerator from './AbstractTokenGenerator'; | ||
super(); | ||
if (typeof token === 'string') { | ||
// eslint-disable-next-line no-console | ||
console.warn( | ||
'passing a string to ProvidedTokenGenerator is deprecated and has a weird comportment. You should pass an object containing a token object with an `access_token` key' | ||
); | ||
} | ||
this._token = token; | ||
@@ -13,5 +20,10 @@ this.canAutogenerateToken = true; | ||
generateToken() { | ||
return Promise.resolve({ | ||
access_token: this._token, | ||
}); | ||
const accessToken = | ||
typeof this._token === 'string' | ||
? { | ||
access_token: this._token, | ||
} | ||
: this._token; | ||
return Promise.resolve(accessToken); | ||
} | ||
@@ -18,0 +30,0 @@ |
@@ -78,3 +78,2 @@ class TokenStorage { | ||
generateToken(parameters) { | ||
this._hasATokenBeenGenerated = true; | ||
const callTimestamp = Date.now(); | ||
@@ -89,3 +88,6 @@ return this._tokenGenerator | ||
return this._storeAccessToken(updatedResponseData, callTimestamp).then( | ||
() => updatedResponseData | ||
() => { | ||
this._hasATokenBeenGenerated = true; | ||
return updatedResponseData; | ||
} | ||
); | ||
@@ -92,0 +94,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
387131
4825