Skip to content

Commit d9b8118

Browse files
committed
docs(changeset): feat: add kid to the JwtSigner interface
Signed-off-by: Timo Glastra <[email protected]>
1 parent c3ed260 commit d9b8118

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

.changeset/three-clouds-return.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@openid4vc/oauth2": patch
3+
---
4+
5+
feat: add `kid` to the JwtSigner interface

packages/oauth2/src/common/jwt/decode-jwt.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export function jwtSignerFromJwt({
124124
alg: header.alg,
125125
method: 'x5c',
126126
x5c: header.x5c,
127+
kid: header.kid,
127128
},
128129
})
129130
}
@@ -208,6 +209,7 @@ export function jwtSignerFromJwt({
208209
return {
209210
method: 'custom',
210211
alg: header.alg,
212+
kid: header.kid,
211213
}
212214
}
213215

packages/oauth2/src/common/jwt/z-jwt.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,62 @@ export type JwtSignerDid = {
77
method: 'did'
88
didUrl: string
99
alg: string
10+
11+
/**
12+
* The key id that should be used for signing. You need to make sure the kid actuall matches
13+
* with the key associated with the didUrl.
14+
*/
15+
kid?: string
1016
}
1117

1218
export type JwtSignerJwk = {
1319
method: 'jwk'
1420
publicJwk: Jwk
1521
alg: string
22+
23+
/**
24+
* The key id that should be used for signing. You need to make sure the kid actuall matches
25+
* with the key associated with the jwk.
26+
*
27+
* If not provided the kid can also be extracted from the `publicJwk`. Providing it here means the `kid` won't
28+
* be included in the JWT header.
29+
*/
30+
kid?: string
1631
}
1732

1833
export type JwtSignerX5c = {
1934
method: 'x5c'
2035
x5c: string[]
2136
alg: string
37+
38+
/**
39+
* The key id that should be used for signing. You need to make sure the kid actuall matches
40+
* with the key associated with the leaf certificate.
41+
*/
42+
kid?: string
2243
}
2344

2445
export type JwtSignerFederation = {
2546
method: 'federation'
2647
trustChain?: [string, ...string[]]
2748
alg: string
49+
50+
/**
51+
* The key id that should be used for signing. You need to make sure the kid actuall matches
52+
* with a key present in the federation.
53+
*/
2854
kid: string
2955
}
3056

3157
// In case of custom nothing will be added to the header
3258
export type JwtSignerCustom = {
3359
method: 'custom'
3460
alg: string
61+
62+
/**
63+
* The key id that should be used for signing.
64+
*/
65+
kid?: string
3566
}
3667

3768
export type JwtSigner = JwtSignerDid | JwtSignerJwk | JwtSignerX5c | JwtSignerFederation | JwtSignerCustom

0 commit comments

Comments
 (0)