From 09f1d20aff0fe42795ede2afb214bca6e01fbf2a Mon Sep 17 00:00:00 2001 From: JulesVerner <49474517+JulesVerner@users.noreply.github.com> Date: Sat, 20 Jul 2024 11:39:05 +0200 Subject: [PATCH] fix(middleware/jwt): Changed the jwt-secret type to SignatureKey (#3167) * Changed the jwt-secret type to SignatureKey * Changed import to type-import --- src/middleware/jwt/jwt.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/middleware/jwt/jwt.ts b/src/middleware/jwt/jwt.ts index d1e9f2b6..99355fd6 100644 --- a/src/middleware/jwt/jwt.ts +++ b/src/middleware/jwt/jwt.ts @@ -11,6 +11,7 @@ import type { CookiePrefixOptions } from '../../utils/cookie' import { Jwt } from '../../utils/jwt' import '../../context' import type { SignatureAlgorithm } from '../../utils/jwt/jwa' +import type { SignatureKey } from '../../utils/jwt/jws' export type JwtVariables = { // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -23,7 +24,7 @@ export type JwtVariables = { * @see {@link https://hono.dev/docs/middleware/builtin/jwt} * * @param {object} options - The options for the JWT middleware. - * @param {string} [options.secret] - A value of your secret key. + * @param {SignatureKey} [options.secret] - A value of your secret key. * @param {string} [options.cookie] - If this value is set, then the value is retrieved from the cookie header using that value as a key, which is then validated as a token. * @param {SignatureAlgorithm} [options.alg=HS256] - An algorithm type that is used for verifying. Available types are `HS256` | `HS384` | `HS512` | `RS256` | `RS384` | `RS512` | `PS256` | `PS384` | `PS512` | `ES256` | `ES384` | `ES512` | `EdDSA`. * @returns {MiddlewareHandler} The middleware handler function. @@ -45,7 +46,7 @@ export type JwtVariables = { * ``` */ export const jwt = (options: { - secret: string + secret: SignatureKey cookie?: | string | { key: string; secret?: string | BufferSource; prefixOptions?: CookiePrefixOptions }