Skip to content

Commit 32740ee

Browse files
fix: More descriptive error in case that discovery endpoint returns an invalid issuer (#12611)
* add a more descriptive error in case that discovery endpoint returns an invalid issuer * Update authorization-url.ts * Update authorization-url.ts --------- Co-authored-by: Balázs Orbán <info@balazsorban.com>
1 parent 31ead6d commit 32740ee

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/core/src/lib/actions/signin/authorization-url.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ export async function getAuthorizationUrl(
3030
// TODO: move away from allowing insecure HTTP requests
3131
[o.allowInsecureRequests]: true,
3232
})
33-
const as = await o.processDiscoveryResponse(issuer, discoveryResponse)
33+
const as = await o
34+
.processDiscoveryResponse(issuer, discoveryResponse)
35+
.catch((error) => {
36+
if (!(error instanceof TypeError) || error.message !== "Invalid URL")
37+
throw error
38+
throw new TypeError(
39+
`Discovery request responded with an invalid issuer. expected: ${issuer}`
40+
)
41+
})
3442

3543
if (!as.authorization_endpoint) {
3644
throw new TypeError(

0 commit comments

Comments
 (0)