Commit c763a0e committed Mar 11, 2025 · 18 / 18
1 parent f7898a9 commit c763a0e Copy full SHA for c763a0e
File tree 1 file changed +12
-8
lines changed
1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -196,14 +196,18 @@ export class EncryptJWT implements types.ProduceJWT {
196
196
options ?: types . EncryptOptions ,
197
197
) : Promise < string > {
198
198
const enc = new CompactEncrypt ( this . #jwt. data ( ) )
199
- if ( this . #replicateIssuerAsHeader) {
200
- this . #protectedHeader = { ...this . #protectedHeader, iss : this . #jwt. iss }
201
- }
202
- if ( this . #replicateSubjectAsHeader) {
203
- this . #protectedHeader = { ...this . #protectedHeader, sub : this . #jwt. sub }
204
- }
205
- if ( this . #replicateAudienceAsHeader) {
206
- this . #protectedHeader = { ...this . #protectedHeader, aud : this . #jwt. aud }
199
+ if (
200
+ this . #protectedHeader &&
201
+ ( this . #replicateIssuerAsHeader ||
202
+ this . #replicateSubjectAsHeader ||
203
+ this . #replicateAudienceAsHeader)
204
+ ) {
205
+ this . #protectedHeader = {
206
+ ...this . #protectedHeader,
207
+ iss : this . #replicateIssuerAsHeader ? this . #jwt. iss : undefined ,
208
+ sub : this . #replicateSubjectAsHeader ? this . #jwt. sub : undefined ,
209
+ aud : this . #replicateAudienceAsHeader ? this . #jwt. aud : undefined ,
210
+ }
207
211
}
208
212
enc . setProtectedHeader ( this . #protectedHeader)
209
213
if ( this . #iv) {
You can’t perform that action at this time.
0 commit comments