panva / openid-client

OAuth 2 / OpenID Connect Client API for JavaScript Runtimes
MIT License
1.83k stars 392 forks source link

supportPKCE return value is incorrect #710

Closed mo36924 closed 1 week ago

mo36924 commented 1 week ago

What happened?

supportsPKCE return value is incorrect.

https://github.com/panva/openid-client/blob/ff1436ea991d771b0257a7c12752621ae6abaaf9/src/index.ts#L1464-L1472

The following code may be more correct.

metadata.code_challenge_methods_supported?.includes(method) === true 

Version

v6.1.0

Runtime

Node.js

Runtime Details

v20.17.0

Code to reproduce

import { equal } from "node:assert";
import { discovery } from "openid-client";

const config = await discovery(new URL("https://accounts.google.com"), "clientId", "clientSecret");
equal(config.serverMetadata().code_challenge_methods_supported?.includes("S256"), true);
// The following line throws an error
equal(config.serverMetadata().supportsPKCE(), true);

Required

panva commented 1 week ago

Damn you're right, i took the code from my previous examples that was checking for anything but true.

panva commented 1 week ago

Fixed in https://github.com/panva/openid-client/releases/tag/v6.1.1