From 45e81fbbe0ec4d9ba61ede5700b430ae39e882bc Mon Sep 17 00:00:00 2001 From: Nikos Triantafyllou Date: Mon, 10 Jun 2024 22:15:32 +0300 Subject: [PATCH] fix for sessionIds that dont have persona attached --- routes/educationalRoutes.js | 12 +++++++++--- routes/routes.js | 18 +++++++++--------- routes/verifierRoutes.js | 16 ++++++++-------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/routes/educationalRoutes.js b/routes/educationalRoutes.js index c305847..e399c74 100644 --- a/routes/educationalRoutes.js +++ b/routes/educationalRoutes.js @@ -40,12 +40,18 @@ educationalRouter.get(["/pre-offer-jwt-edu"], async (req, res) => { const uuid = req.query.sessionId ? req.query.sessionId : uuidv4(); const personaId = req.query.persona; const preSessions = getPreCodeSessions(); - if (preSessions.sessions.indexOf(uuid + "-persona=" + personaId) < 0) { - preSessions.sessions.push(uuid + "-persona=" + personaId); + //if (preSessions.sessions.indexOf(uuid + "-persona=" + personaId) < 0) { + // preSessions.sessions.push(uuid + "-persona=" + personaId); + // preSessions.results.push({ sessionId: uuid, status: "pending" }); + // preSessions.personas.push(null); + // preSessions.accessTokens.push(null); + // } + if (preSessions.sessions.indexOf(uuid ) < 0) { + preSessions.sessions.push(uuid); preSessions.results.push({ sessionId: uuid, status: "pending" }); preSessions.personas.push(null); preSessions.accessTokens.push(null); - } + } let credentialOffer = ""; if (personaId) { credentialOffer = `openid-credential-offer://?credential_offer_uri=${serverURL}/credential-offer-pre-jwt-edu/${uuid}?persona=${personaId}`; //OfferUUID diff --git a/routes/routes.js b/routes/routes.js index f438c11..47945b0 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -852,15 +852,15 @@ function checkIfExistsIssuanceStatus( let index = sessions.indexOf(sessionId); console.log("index is"); console.log(index); - if (index < 0) { - sessions.forEach((value, _index) => { - console.log("checking value to " + value.replace(/-persona=\s+$/, "") +"-checking vs" + sessionId) - if (value.replace(/-persona=.*$/, "") === sessionId) { - console.log("updated index") - index = _index; - } - }); - } + // if (index < 0) { + // sessions.forEach((value, _index) => { + // console.log("checking value to " + value.replace(/-persona=\s+$/, "") +"-checking vs" + sessionId) + // if (value.replace(/-persona=.*$/, "") === sessionId) { + // console.log("updated index") + // index = _index; + // } + // }); + // } if (index >= 0) { let status = sessionResults[index].status; console.log(`sending status ${status} for session ${sessionId}`); diff --git a/routes/verifierRoutes.js b/routes/verifierRoutes.js index 254ff84..6461edc 100644 --- a/routes/verifierRoutes.js +++ b/routes/verifierRoutes.js @@ -349,14 +349,14 @@ verifierRouter.post("/direct_post_jwt/:id", async (req, res) => { verifierRouter.get(["/verificationStatus"], (req, res) => { let sessionId = req.query.sessionId; let index = sessions.indexOf(sessionId); // sessions.indexOf(sessionId+""); // - if (index < 0) { - sessions.forEach((value, _index) => { - if (value.replace(/-persona=.*$/, "") === sessionId) { - console.log("updated index"); - index = _index; - } - }); - } + // if (index < 0) { + // sessions.forEach((value, _index) => { + // if (value.replace(/-persona=.*$/, "") === sessionId) { + // console.log("updated index"); + // index = _index; + // } + // }); + // } console.log("index is"); console.log(index); let result = null;