in src/auth/auth-core.ts [959:994]
private async _checkForAuthResponse() {
// getAuthResponseURL may throw an exception
const authResponse = this._responseParser.getAuthResponseFromURL();
const {scope: defaultScope, defaultExpiresIn, cleanHash} = this.config;
if (authResponse && cleanHash) {
this.setHash('');
}
if (!authResponse) {
return undefined;
}
const {state: stateId, scope, expiresIn, accessToken} = authResponse;
let newState: AuthState | null = null;
if (stateId) {
newState = await this._storage.getState(stateId);
if (!newState) {
newState = this._makeStateFromResponse(authResponse);
}
}
if (!newState) {
throw new Error(`Could not create state where stateId="${stateId}"`);
}
const scopes = scope ? scope.split(' ') : newState.scopes || defaultScope || [];
const effectiveExpiresIn = expiresIn ? parseInt(expiresIn, 10) : defaultExpiresIn;
const expires = TokenValidator._epoch() + effectiveExpiresIn;
if (accessToken !== undefined) {
await this._storage?.saveToken({accessToken, scopes, expires, lifeTime: effectiveExpiresIn});
}
return newState;
}