File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import { loadJWKs } from '#server/utils/atproto/oauth'
33export default defineEventHandler ( async _ => {
44 const keys = await loadJWKs ( )
55 if ( ! keys ) {
6- console . error ( 'Failed to load JWKs. May not be set' )
76 return [ ]
87 }
98
Original file line number Diff line number Diff line change @@ -89,13 +89,25 @@ export async function loadJWKs(): Promise<Keyset | undefined> {
8989 // If we ever need to add multiple JWKs to rotate keys we will need to add a new one
9090 // under a new variable and update here
9191 const jwkOne = useRuntimeConfig ( ) . oauthJwkOne
92- if ( ! jwkOne ) return undefined
92+ if ( ! jwkOne ) {
93+ if ( import . meta. test ) {
94+ // eslint-disable-next-line no-console
95+ console . error ( 'Failed to load JWKs (not set).' )
96+ }
97+ return undefined
98+ }
9399
94100 // For multiple keys if we need to rotate
95101 // const keys = await Promise.all([JoseKey.fromImportable(jwkOne)])
96102
97- const keys = await JoseKey . fromImportable ( jwkOne )
98- return new Keyset ( [ keys ] )
103+ try {
104+ const keys = await JoseKey . fromImportable ( jwkOne )
105+ return new Keyset ( [ keys ] )
106+ } catch ( e ) {
107+ // eslint-disable-next-line no-console
108+ console . error ( 'Failed to load JWKs.' , e )
109+ return undefined
110+ }
99111}
100112
101113async function getOAuthSession ( event : H3Event ) : Promise < {
You can’t perform that action at this time.
0 commit comments