Skip to content

Commit

Permalink
fixed an issue with educaitonid personas
Browse files Browse the repository at this point in the history
  • Loading branch information
endimion committed Sep 18, 2024
1 parent 6e0d7ff commit d1c284c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 10 additions & 7 deletions routes/educationalRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,24 @@ 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) {
// 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) {
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
Expand Down Expand Up @@ -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"],
Expand Down
1 change: 1 addition & 0 deletions routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit d1c284c

Please sign in to comment.