Skip to content

Commit 2cfe390

Browse files
bugfix: Fix clientAssertionSigningKey type mismatch (#2243)
1 parent 533c4b7 commit 2cfe390

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/server/auth-client.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ ca/T0LLtgmbMmxSv/MmzIg==
160160
audience?: string;
161161
issuer?: string;
162162
alg?: string;
163-
privateKey?: CryptoKey;
163+
privateKey?: jose.CryptoKey;
164164
}): Promise<string> {
165165
return await new jose.SignJWT({
166166
events: {

src/server/auth-client.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export interface AuthClientOptions {
118118
domain: string;
119119
clientId: string;
120120
clientSecret?: string;
121-
clientAssertionSigningKey?: string | CryptoKey;
121+
clientAssertionSigningKey?: string | jose.CryptoKey;
122122
clientAssertionSigningAlg?: string;
123123
authorizationParameters?: AuthorizationParameters;
124124
pushedAuthorizationRequests?: boolean;
@@ -156,7 +156,7 @@ export class AuthClient {
156156

157157
private clientMetadata: oauth.Client;
158158
private clientSecret?: string;
159-
private clientAssertionSigningKey?: string | CryptoKey;
159+
private clientAssertionSigningKey?: string | jose.CryptoKey;
160160
private clientAssertionSigningAlg: string;
161161
private domain: string;
162162
private authorizationParameters: AuthorizationParameters;
@@ -1079,19 +1079,18 @@ export class AuthClient {
10791079
);
10801080
}
10811081

1082-
let clientPrivateKey = this.clientAssertionSigningKey as
1083-
| CryptoKey
1084-
| undefined;
1082+
let clientPrivateKey: jose.CryptoKey | undefined = this
1083+
.clientAssertionSigningKey as jose.CryptoKey | undefined;
10851084

1086-
if (clientPrivateKey && !(clientPrivateKey instanceof CryptoKey)) {
1085+
if (clientPrivateKey && typeof clientPrivateKey === "string") {
10871086
clientPrivateKey = await jose.importPKCS8(
10881087
clientPrivateKey,
10891088
this.clientAssertionSigningAlg
10901089
);
10911090
}
10921091

10931092
return clientPrivateKey
1094-
? oauth.PrivateKeyJwt(clientPrivateKey)
1093+
? oauth.PrivateKeyJwt(clientPrivateKey as CryptoKey)
10951094
: oauth.ClientSecretPost(this.clientSecret!);
10961095
}
10971096

0 commit comments

Comments
 (0)