// Minimal eSignet stand-in for the e2e stack. freight-api-e2e's // FAYDA_TOKEN_ENDPOINT / FAYDA_USERINFO_ENDPOINT point here instead of the // real (unreachable) Fayda infrastructure. It does not validate the // client_assertion, code, or code_verifier it's sent — Cypress drives the // verification via the API directly (POST start, then POST complete with a // throwaway code), never through the real popup+SMS flow, so nothing here // needs to be cryptographically real, only shaped like a working OIDC token // + userinfo response. const http = require("node:http"); const PORT = process.env.PORT || 4400; const USERINFO = { sub: "e2e-fayda-sub-0001", name: "Abebe Bekele", "name#en": "Abebe Bekele", email: "abebe.bekele@example.com", phone_number: "+251911223344", gender: "Male", "gender#en": "Male", birthdate: "1990-01-01", "address#en": "Bole Sub City, Addis Ababa, Ethiopia", }; const server = http.createServer((req, res) => { // Drain the body so the client's request completes cleanly even though we // never read it (POST /token sends a form-urlencoded body we don't parse). req.on("data", () => {}); req.on("end", () => { if (req.method === "POST" && req.url.startsWith("/token")) { res.writeHead(200, { "content-type": "application/json" }); res.end( JSON.stringify({ access_token: "e2e-mock-access-token", token_type: "Bearer", expires_in: 3600, }), ); return; } if (req.method === "GET" && req.url.startsWith("/userinfo")) { res.writeHead(200, { "content-type": "application/json" }); res.end(JSON.stringify(USERINFO)); return; } res.writeHead(404).end(); }); }); server.listen(PORT, () => { console.log(`fayda-mock listening on ${PORT}`); });