Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
performWithFreshTokens(): Promise {
if (!this.configuration) {
log("Unknown service configuration");
return Promise.reject("Unknown service configuration");
}
if (!this.refreshToken) {
log("Missing refreshToken.");
return Promise.resolve("Missing refreshToken.");
}
if (this.accessTokenResponse && this.accessTokenResponse.isValid()) {
// do nothing
return Promise.resolve(this.accessTokenResponse.accessToken);
}
let request = new TokenRequest(
clientId,
redirectUri,
GRANT_TYPE_REFRESH_TOKEN,
undefined,
this.refreshToken
);
return this.tokenHandler
.performTokenRequest(this.configuration, request)
.then(response => {
this.accessTokenResponse = response;
return response.accessToken;
});
}
}
_performWithInitTokenRequest(code) {
if (!this.authConfiguration) {
return Promise.resolve();
}
const extra = [];
if (this.codePair) {
extra['code_verifier'] = this.codePair.codeVrifier;
log.debug(extra);
}
// use the code to make the token request.
const request = new TokenRequest(
this.config.clientId, this.config.redirectUri,
GRANT_TYPE_AUTHORIZATION_CODE, code, undefined, extra);
return this.tokenHandler.performTokenRequest(this.authConfiguration, request)
.then(response => {
this.accessTokenResponse = response;
return new AuthAccessToken(
response.accessToken,
response.refreshToken,
response.issuedAt + response.expiresIn
);
})
.then(this.tokenStoreHander);
}
_performWithFreshTokens(accessToken) {
private makeRefreshTokenRequest(code: string): Promise {
if (!this.configuration) {
log("Unknown service configuration");
return Promise.resolve();
}
// use the code to make the token request.
let request = new TokenRequest(
clientId,
redirectUri,
GRANT_TYPE_AUTHORIZATION_CODE,
code,
undefined
);
return this.tokenHandler
.performTokenRequest(this.configuration, request)
.then(response => {
log(`Refresh Token is ${response.refreshToken}`);
this.refreshToken = response.refreshToken;
this.accessTokenResponse = response;
return response;
})
.then(() => {});
_performWithFreshTokens(accessToken) {
if (!this.config || !this.authConfiguration) {
return Promise.reject('Unknown service configuration');
}
if (!accessToken || !accessToken.refreshToken) {
return Promise.resolve('Missing refreshToken.');
}
if (accessToken && accessToken.isValid()) {
log.debug('accessToken is valid');
// do nothing
return Promise.resolve(accessToken);
}
const request = new TokenRequest(
this.config.clientId, this.config.redirectUri,
GRANT_TYPE_REFRESH_TOKEN, undefined, accessToken.refreshToken);
return this.tokenHandler.performTokenRequest(this.authConfiguration, request)
.then(response => {
this.accessTokenResponse = response;
return new AuthAccessToken(
response.accessToken,
response.refreshToken,
response.issuedAt + response.expiresIn
);
})
.then(this.tokenStoreHander);
}
logout() {