Skip to content

Commit

Permalink
bug fix with multiple posts of same session id
Browse files Browse the repository at this point in the history
  • Loading branch information
endimion committed Apr 25, 2024
1 parent a944be7 commit d973e9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 6 additions & 2 deletions routes/codeFlowJwtRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ const publicKeyPem = fs.readFileSync("./public-key.pem", "utf-8");
// auth code flow
codeFlowRouter.get(["/offer-code"], async (req, res) => {
const uuid = req.query.sessionId ? req.query.sessionId : uuidv4();

const codeSessions = getAuthCodeSessions();
codeSessions.sessions.push(uuid);
codeSessions.results.push({ sessionId: uuid, status: "pending" });
if (codeSessions.indexOf(uuid) < 0) {
codeSessions.sessions.push(uuid);
codeSessions.results.push({ sessionId: uuid, status: "pending" });
}

// console.log("active sessions");
// console.log(issuanceResults);
let credentialOffer = `openid-credential-offer://?credential_offer_uri=${serverURL}/credential-offer-code/${uuid}`;
Expand Down
6 changes: 4 additions & 2 deletions routes/codeFlowSdJwtRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ const serverURL = process.env.SERVER_URL || "http://localhost:3000";
codeFlowRouterSDJWT.get(["/offer-code-sd-jwt"], async (req, res) => {
const uuid = req.query.sessionId ? req.query.sessionId : uuidv4();
const codeSessions = getAuthCodeSessions();
codeSessions.sessions.push(uuid);
codeSessions.results.push({ sessionId: uuid, status: "pending" });
if (codeSessions.indexOf(uuid) < 0) {
codeSessions.sessions.push(uuid);
codeSessions.results.push({ sessionId: uuid, status: "pending" });
}
let credentialOffer = `openid-credential-offer://?credential_offer_uri=${serverURL}/credential-offer-code-sd-jwt/${uuid}`;

let code = qr.image(credentialOffer, {
Expand Down
7 changes: 5 additions & 2 deletions routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ console.log(privateKey);
router.get(["/offer"], async (req, res) => {
const uuid = req.query.sessionId ? req.query.sessionId : uuidv4();
const preSessions = getPreCodeSessions();
preSessions.sessions.push(uuid);
preSessions.results.push({ sessionId: uuid, status: "pending" });
if (preSessions.indexOf(uuid) < 0) {
preSessions.sessions.push(uuid);
preSessions.results.push({ sessionId: uuid, status: "pending" });
}

// console.log("active sessions");
// console.log(issuanceResults);
let credentialOffer = `openid-credential-offer://?credential_offer_uri=${serverURL}/credential-offer/${uuid}`; //OfferUUID
Expand Down

0 comments on commit d973e9d

Please sign in to comment.