File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export async function decode<Payload = JWT>(
108108}
109109
110110type GetTokenParamsBase = {
111- secret : JWTDecodeParams [ "secret" ]
111+ secret ? : JWTDecodeParams [ "secret" ]
112112 salt ?: JWTDecodeParams [ "salt" ]
113113}
114114
@@ -155,8 +155,6 @@ export async function getToken(
155155 } = params
156156
157157 if ( ! req ) throw new Error ( "Must pass `req` to JWT getToken()" )
158- if ( ! secret )
159- throw new MissingSecret ( "Must pass `secret` if not set to JWT getToken()" )
160158
161159 const headers =
162160 req . headers instanceof Headers ? req . headers : new Headers ( req . headers )
@@ -180,6 +178,9 @@ export async function getToken(
180178
181179 if ( raw ) return token
182180
181+ if ( ! secret )
182+ throw new MissingSecret ( "Must pass `secret` if not set to JWT getToken()" )
183+
183184 try {
184185 return await _decode ( { token, secret, salt } )
185186 } catch {
You can’t perform that action at this time.
0 commit comments