From db5578faea9fac06f6b1aa8e6989f76c6a77fbca Mon Sep 17 00:00:00 2001 From: Nikos Triantafyllou Date: Thu, 6 Jun 2024 19:58:58 +0300 Subject: [PATCH] catch error if clientmetada is missing in /authorize endpoint --- routes/codeFlowJwtRoutes.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/routes/codeFlowJwtRoutes.js b/routes/codeFlowJwtRoutes.js index 56753a7..691bb29 100644 --- a/routes/codeFlowJwtRoutes.js +++ b/routes/codeFlowJwtRoutes.js @@ -72,10 +72,15 @@ codeFlowRouter.get("/authorize", async (req, res) => { const nonce = req.query.nonce; const codeChallenge = decodeURIComponent(req.query.code_challenge); const codeChallengeMethod = req.query.code_challenge_method; //this should equal to S256 + try { + const clientMetadata = JSON.parse( + decodeURIComponent(req.query.client_metadata) + ); + } catch (error) { + console.log("client_metadata was missing"); + console.log(error); + } - const clientMetadata = JSON.parse( - decodeURIComponent(req.query.client_metadata) - ); //validations let errors = []; if (!authorizationDetails) {