in src/login/server.ts [176:201]
async function callback(nonce: string, reqUrl: url.Url): Promise<string> {
let query: ParsedUrlQuery;
let error: string | undefined;
let code: string | undefined;
if (reqUrl.query) {
query = typeof reqUrl.query === 'string' ? parse(reqUrl.query) : reqUrl.query;
error = getQueryProp(query, 'error_description') || getQueryProp(query, 'error');
code = getQueryProp(query, 'code');
if (!error) {
const state: string = getQueryProp(query, 'state');
const receivedNonce: string = (state?.split(',')[1] || '').replace(/ /g, '+');
if (receivedNonce !== nonce) {
error = 'Nonce does not match.';
}
}
}
if (!error && code) {
return code;
}
throw new Error(error || 'No code received.');
}