mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 06:06:41 +01:00
Check code_challenge_methods_supported too
This commit is contained in:
parent
0e961e87a4
commit
9fd17ad5e6
1 changed files with 4 additions and 2 deletions
|
@ -26,7 +26,7 @@ export async function generateCodeChallenge(v) {
|
||||||
return base64urlencode(hashed);
|
return base64urlencode(hashed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If https://mastodon.social/.well-known/oauth-authorization-server exists, means support PKCE
|
// If /.well-known/oauth-authorization-server exists and code_challenge_methods_supported includes "S256", means support PKCE
|
||||||
export async function supportsPKCE({ instanceURL }) {
|
export async function supportsPKCE({ instanceURL }) {
|
||||||
if (!instanceURL) return false;
|
if (!instanceURL) return false;
|
||||||
try {
|
try {
|
||||||
|
@ -34,7 +34,9 @@ export async function supportsPKCE({ instanceURL }) {
|
||||||
`https://${instanceURL}/.well-known/oauth-authorization-server`,
|
`https://${instanceURL}/.well-known/oauth-authorization-server`,
|
||||||
);
|
);
|
||||||
if (!res.ok || res.status !== 200) return false;
|
if (!res.ok || res.status !== 200) return false;
|
||||||
return true;
|
const json = await res.json();
|
||||||
|
if (json.code_challenge_methods_supported?.includes('S256')) return true;
|
||||||
|
return false;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue