remove confusing return [false];

This commit is contained in:
Kagami Sascha Rosylight 2023-06-04 15:53:49 +02:00
parent 78c6bb1cc2
commit bfe6e5abb8

View file

@ -204,17 +204,17 @@ export class OAuth2ProviderService {
})().then(args => done(null, ...args), err => done(err)); })().then(args => done(null, ...args), err => done(err));
})); }));
this.#server.exchange(oauth2orize.exchange.authorizationCode((client, code, redirectUri, body, authInfo, done) => { this.#server.exchange(oauth2orize.exchange.authorizationCode((client, code, redirectUri, body, authInfo, done) => {
(async (): Promise<OmitFirstElement<Parameters<typeof done>>> => { (async (): Promise<OmitFirstElement<Parameters<typeof done>> | undefined> => {
const granted = grantCodeCache.get(code); const granted = grantCodeCache.get(code);
console.log(granted, body, code, redirectUri); console.log(granted, body, code, redirectUri);
if (!granted) { if (!granted) {
return [false]; return;
} }
grantCodeCache.delete(code); grantCodeCache.delete(code);
if (body.client_id !== granted.clientId) return [false]; if (body.client_id !== granted.clientId) return;
if (redirectUri !== granted.redirectUri) return [false]; if (redirectUri !== granted.redirectUri) return;
if (!body.code_verifier) return [false]; if (!body.code_verifier) return;
if (!(await verifyChallenge(body.code_verifier as string, granted.codeChallenge))) return [false]; if (!(await verifyChallenge(body.code_verifier as string, granted.codeChallenge))) return;
const accessToken = secureRndstr(128, true); const accessToken = secureRndstr(128, true);
@ -233,7 +233,7 @@ export class OAuth2ProviderService {
}); });
return [accessToken, undefined, { scope: granted.scopes.join(' ') }]; return [accessToken, undefined, { scope: granted.scopes.join(' ') }];
})().then(args => done(null, ...args), err => done(err)); })().then(args => done(null, ...args ?? []), err => done(err));
})); }));
this.#server.serializeClient((client, done) => done(null, client)); this.#server.serializeClient((client, done) => done(null, client));
this.#server.deserializeClient((id, done) => done(null, id)); this.#server.deserializeClient((id, done) => done(null, id));
@ -265,9 +265,6 @@ export class OAuth2ProviderService {
issuer: this.config.url, issuer: this.config.url,
authorization_endpoint: new URL('/oauth/authorize', this.config.url), authorization_endpoint: new URL('/oauth/authorize', this.config.url),
token_endpoint: new URL('/oauth/token', this.config.url), token_endpoint: new URL('/oauth/token', this.config.url),
// TODO: support or not?
// introspection_endpoint: ...
// introspection_endpoint_auth_methods_supported: ...
scopes_supported: kinds, scopes_supported: kinds,
response_types_supported: ['code'], response_types_supported: ['code'],
grant_types_supported: ['authorization_code'], grant_types_supported: ['authorization_code'],