-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from conceptadev/feature/export-verify-token-…
…helpers feat: export create verify token helpers
- Loading branch information
Showing
11 changed files
with
64 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
packages/nestjs-auth-jwt/src/utils/create-verify-token-callback.util.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
packages/nestjs-auth-refresh/src/utils/create-verify-token-callback.util.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
packages/nestjs-jwt/src/interfaces/jwt-strategy-options.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import { StrategyOptions } from 'passport-jwt'; | ||
import { JwtVerifyTokenCallback } from '../jwt.types'; | ||
|
||
export interface JwtStrategyOptionsInterface | ||
extends Pick<StrategyOptions, 'jwtFromRequest'> { | ||
verifyToken: ( | ||
token: string, | ||
done: (err?: Error, decodedToken?: unknown) => void, | ||
) => void; | ||
verifyToken: JwtVerifyTokenCallback; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
export type JwtTokenType = 'access' | 'refresh'; | ||
|
||
export type JwtVerifyTokenCallback< | ||
ErrorType extends Error = Error, | ||
DecodedTokenType extends unknown = unknown, | ||
> = ( | ||
token: string, | ||
done: (err?: ErrorType, decodedToken?: DecodedTokenType) => void, | ||
) => void; |
16 changes: 16 additions & 0 deletions
16
packages/nestjs-jwt/src/utils/create-verify-access-token-callback.util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { JwtVerifyServiceInterface } from '../interfaces/jwt-verify-service.interface'; | ||
import { JwtVerifyTokenCallback } from '../jwt.types'; | ||
|
||
export const createVerifyAccessTokenCallback = ( | ||
verifyTokenService: JwtVerifyServiceInterface, | ||
): JwtVerifyTokenCallback => { | ||
return ( | ||
token: string, | ||
done: (error?: Error, decodedToken?: unknown) => void, | ||
): void => { | ||
verifyTokenService | ||
.accessToken(token) | ||
.then((decodedToken: unknown) => done(undefined, decodedToken)) | ||
.catch((error) => done(error)); | ||
}; | ||
}; |
16 changes: 16 additions & 0 deletions
16
packages/nestjs-jwt/src/utils/create-verify-refresh-token-callback.util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { JwtVerifyServiceInterface } from '../interfaces/jwt-verify-service.interface'; | ||
import { JwtVerifyTokenCallback } from '../jwt.types'; | ||
|
||
export const createVerifyRefreshTokenCallback = ( | ||
verifyTokenService: JwtVerifyServiceInterface, | ||
): JwtVerifyTokenCallback => { | ||
return ( | ||
token: string, | ||
done: (error?: Error, decodedToken?: unknown) => void, | ||
): void => { | ||
verifyTokenService | ||
.refreshToken(token) | ||
.then((decodedToken: unknown) => done(undefined, decodedToken)) | ||
.catch((error) => done(error)); | ||
}; | ||
}; |