Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/jwtPublic

Commit0a2e09b

Browse files
chore: update deps
1 parent732daf5 commit0a2e09b

File tree

4 files changed

+2027
-3186
lines changed

4 files changed

+2027
-3186
lines changed

‎lib/jwt.service.spec.ts‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import{Test}from'@nestjs/testing';
12
import{
23
createPrivateKey,
34
createPublicKey,
45
createSecretKey,
56
generateKeyPairSync,
67
KeyObject
78
}from'crypto';
8-
import{Test}from'@nestjs/testing';
99
import*asjwtfrom'jsonwebtoken';
1010
import{
1111
JwtModuleOptions,
@@ -306,10 +306,7 @@ describe('JwtService', () => {
306306
consttestPayload:string=getRandomString();
307307

308308
beforeAll(async()=>{
309-
jwtService=awaitsetup({
310-
...config,
311-
secretOrKeyProvider:undefined
312-
});
309+
jwtService=awaitsetup({ ...config,secretOrKeyProvider:undefined});
313310
});
314311

315312
constsecret='custom_secret';
@@ -401,9 +398,7 @@ describe('JwtService', () => {
401398
});
402399

403400
describe('should use invalid sign options',()=>{
404-
constsignOptions:jwt.SignOptions={
405-
expiresIn:'1d'
406-
};
401+
constsignOptions:jwt.SignOptions={expiresIn:'1d'};
407402

408403
letjwtService:JwtService;
409404
consttestPayloadStr:string=getRandomString();
@@ -417,7 +412,7 @@ describe('JwtService', () => {
417412
expect(()=>
418413
//@ts-expect-error
419414
jwtService.sign(testPayloadStr,{expiresIn:60})
420-
).toThrowError(
415+
).toThrow(
421416
'Payload as string is not allowed with the following sign options: expiresIn'
422417
);
423418
});
@@ -426,7 +421,7 @@ describe('JwtService', () => {
426421
expect(()=>
427422
//@ts-expect-error
428423
jwtService.signAsync(testPayloadStr,{notBefore:60})
429-
).toThrowError(
424+
).toThrow(
430425
'Payload as string is not allowed with the following sign options: expiresIn, notBefore'
431426
);
432427
});
@@ -442,13 +437,13 @@ describe('JwtService', () => {
442437
});
443438

444439
it('should "sign" expect errors using "payload" string with already defined invalid sign options',()=>{
445-
expect(()=>jwtService.sign(testPayloadStr)).toThrowError(
440+
expect(()=>jwtService.sign(testPayloadStr)).toThrow(
446441
'Payload as string is not allowed with the following sign options: expiresIn'
447442
);
448443
});
449444

450445
it('should "signAsync" expect errors using "payload" string with already defined invalid sign options',()=>{
451-
expect(()=>jwtService.signAsync(testPayloadStr)).toThrowError(
446+
expect(()=>jwtService.signAsync(testPayloadStr)).toThrow(
452447
'Payload as string is not allowed with the following sign options: expiresIn'
453448
);
454449
});

‎lib/jwt.service.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class JwtService {
128128
thrownewWrongSecretProviderError();
129129
}
130130

131-
returnjwt.verify(token,secret,verifyOptions)asT;
131+
returnjwt.verify(token,secret,verifyOptionsasjwt.VerifyOptions)asT;
132132
}
133133

134134
verifyAsync<Textendsobject=any>(
@@ -147,8 +147,11 @@ export class JwtService {
147147
Promise.resolve()
148148
.then(()=>secret)
149149
.then((scrt:GetSecretKeyResult)=>{
150-
jwt.verify(token,scrt,verifyOptions,(err,decoded)=>
151-
err ?reject(err) :resolve(decodedasT)
150+
jwt.verify(
151+
token,
152+
scrt,
153+
verifyOptionsasjwt.VerifyOptions,
154+
(err,decoded)=>(err ?reject(err) :resolve(decodedasT))
152155
);
153156
})
154157
.catch(reject)
@@ -170,10 +173,7 @@ export class JwtService {
170173
delete(optionsasJwtVerifyOptions).publicKey;
171174
}
172175
returnoptions
173-
?{
174-
...(this.options[key]||{}),
175-
...options
176-
}
176+
?({ ...(this.options[key]||{}), ...options}asjwt.VerifyOptions)
177177
:this.options[key];
178178
}
179179

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp