1
0

add generics to sign

This commit is contained in:
2023-11-16 20:34:27 +01:00
parent 03c66f4223
commit e235d835aa
2 changed files with 9 additions and 4 deletions

View File

@@ -213,7 +213,7 @@ function decodePayload<T = any>(raw: string): T | undefined {
* @throws {Error} If there's a validation issue.
* @returns {Promise<string>} Returns token as a `string`.
*/
export async function sign(payload: JwtPayload, secret: string | JsonWebKey, options: JwtSignOptions | JwtAlgorithm = 'HS256'): Promise<string> {
export async function sign<Payload = {}>(payload: JwtPayload<Payload>, secret: string | JsonWebKey, options: JwtSignOptions | JwtAlgorithm = 'HS256'): Promise<string> {
if (typeof options === 'string')
options = { algorithm: options }