diff --git a/backend/src/auth/auth.ts b/backend/src/auth/auth.ts index 527c84394..7be67764b 100644 --- a/backend/src/auth/auth.ts +++ b/backend/src/auth/auth.ts @@ -20,5 +20,5 @@ export const isAuthorized: AuthChecker = async ({ root, args, context, info return result.success } } - return false + throw new Error('401 Unauthorized') } diff --git a/backend/src/jwt/decode.ts b/backend/src/jwt/decode.ts index 086267bc2..34b3ed836 100644 --- a/backend/src/jwt/decode.ts +++ b/backend/src/jwt/decode.ts @@ -1,6 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ - import jwt, { JwtPayload } from 'jsonwebtoken' import CONFIG from '../config/' @@ -9,8 +6,14 @@ interface CustomJwtPayload extends JwtPayload { pubKey: Buffer } -export default (token: string): any => { - if (!token) return new Error('401 Unauthorized') +type DecodedJwt = { + token: string + sessionId: number + pubKey: Buffer +} + +export default (token: string): DecodedJwt => { + if (!token) throw new Error('401 Unauthorized') let sessionId = null let pubKey = null try {