From aa6b89456cf64a29b7c34c898c507fa397662fae Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Sat, 13 Jan 2024 19:13:36 -0800 Subject: [PATCH] chore: Throw error for expired token to make it easier to debug --- kits/cdk/viewer.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/kits/cdk/viewer.ts b/kits/cdk/viewer.ts index a6a0b96c..dfd51e7c 100644 --- a/kits/cdk/viewer.ts +++ b/kits/cdk/viewer.ts @@ -169,13 +169,16 @@ export const makeJwtClient = zFunction( message: 'JWT payload must be an object, not a string.', }) } + // console.log('jwt.verify', data) return zViewerFromJwtPayload.parse(data) } catch (err) { - if (!`${err}`.includes('TokenExpiredError')) { - // This dependency is not great... But don't know of a better pattern for now - throw new TRPCError({code: 'UNAUTHORIZED', message: `${err}`}) - } - return {role: 'anon'} + // console.log('jwt.verify Error', err) + // Actually throw token expired errror + throw new TRPCError({code: 'UNAUTHORIZED', message: `${err}`}) + // if (!`${err}`.includes('TokenExpiredError')) { + // // This dependency is not great... But don't know of a better pattern for now + // } + // return {role: 'anon'} } }, signViewer: (