From d1c284c6bb76526fe5d1d50c459911a25680a694 Mon Sep 17 00:00:00 2001 From: Nikos Triantafyllou Date: Wed, 18 Sep 2024 15:51:26 +0300 Subject: [PATCH] fixed an issue with educaitonid personas --- package.json | 2 +- routes/educationalRoutes.js | 17 ++++++++++------- routes/routes.js | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 071a674..48685d2 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "dev": "SERVER_URL=https://442b-2a02-587-870d-e900-1bc9-d886-85a8-9109.ngrok-free.app node server.js" + "dev": "SERVER_URL=https://a6bf-2a02-587-870d-e900-8ba6-393a-385b-5730.ngrok-free.app node server.js" }, "author": "", "license": "ISC", diff --git a/routes/educationalRoutes.js b/routes/educationalRoutes.js index b25c71c..76c5c9e 100644 --- a/routes/educationalRoutes.js +++ b/routes/educationalRoutes.js @@ -37,7 +37,7 @@ const privateKey = fs.readFileSync("./private-key.pem", "utf-8"); const publicKeyPem = fs.readFileSync("./public-key.pem", "utf-8"); educationalRouter.get(["/pre-offer-jwt-edu"], async (req, res) => { - const uuid = req.query.sessionId ? req.query.sessionId : uuidv4(); + let uuid = req.query.sessionId ? req.query.sessionId : uuidv4(); const personaId = req.query.persona; const preSessions = getPreCodeSessions(); //if (preSessions.sessions.indexOf(uuid + "-persona=" + personaId) < 0) { @@ -45,14 +45,16 @@ educationalRouter.get(["/pre-offer-jwt-edu"], async (req, res) => { // preSessions.results.push({ sessionId: uuid, status: "pending" }); // preSessions.personas.push(null); // preSessions.accessTokens.push(null); - // } - if (preSessions.sessions.indexOf(uuid ) < 0) { - console.log(uuid) - preSessions.sessions.push(uuid); + //142d9d92-3375-498b-b097-baac74d68c0a-persona=3 + // } + if (preSessions.sessions.indexOf(uuid) < 0) { + if (personaId) preSessions.sessions.push(uuid + "-persona=" + personaId); + else preSessions.sessions.push(uuid); + preSessions.results.push({ sessionId: uuid, status: "pending" }); - preSessions.personas.push(null); + preSessions.personas.push(personaId); 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 @@ -89,6 +91,7 @@ educationalRouter.get(["/credential-offer-pre-jwt-edu/:id"], (req, res) => { }, }); } else { + // console.log("pre-authorized_code:"+ req.params.id + "-persona=" + persona) res.json({ credential_issuer: serverURL, credentials: ["StudentID"], diff --git a/routes/routes.js b/routes/routes.js index 6444dfa..21febf6 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -882,6 +882,7 @@ function checkIfExistsIssuanceStatus( function getPersonaFromAccessToken(accessToken, personas, accessTokens) { let persona = null; for (let i = 0; i < accessTokens.length; i++) { + console.log(accessTokens[i]) if (accessTokens[i] === accessToken) { persona = personas[i]; }