Skip to content

Commit

Permalink
fix: assert no client secret is provided unless needed
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Apr 27, 2022
1 parent ac6be64 commit 604d8f3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ function assertNoClientPrivateKey(clientAuthMethod: string, clientPrivateKey: un
}
}

function assertNoClientSecret(clientAuthMethod: string, clientSecret?: unknown) {
function assertNoClientSecret(clientAuthMethod: string, clientSecret: unknown) {
if (clientSecret !== undefined) {
throw new TypeError(
`"client.client_secret" property must not be provided when ${clientAuthMethod} client authentication method is used.`,
Expand Down Expand Up @@ -1295,7 +1295,7 @@ async function clientAuthentication(
break
}
case 'private_key_jwt': {
assertNoClientSecret('private_key_jwt')
assertNoClientSecret('private_key_jwt', client.client_secret)
if (clientPrivateKey === undefined) {
throw new TypeError(
'"options.clientPrivateKey" must be provided when "client.token_endpoint_auth_method" is "private_key_jwt"',
Expand All @@ -1311,7 +1311,7 @@ async function clientAuthentication(
break
}
case 'none': {
assertNoClientSecret('none')
assertNoClientSecret('none', client.client_secret)
assertNoClientPrivateKey('none', clientPrivateKey)
body.set('client_id', client.client_id)
break
Expand Down

0 comments on commit 604d8f3

Please sign in to comment.