// Entirely local, test-only journey. The owner callback checks challenge // plumbing but does NOT validate a real XML signature or authenticate anyone. const express = require('express'); const { makeRouter } = require('./signWidget.server'); const app = express(); app.get('/', (_req, res) => res.type('html').send(` KazEDS local mock

eGov widget mock journey

Local UI test only. The signature is fabricated.

`)); app.get('/signWidget.js', (_req, res) => res.sendFile(require('node:path').join(__dirname, 'signWidget.js'))); app.use('/api/egov-login', makeRouter({ onComplete: async ({ challenge, nonce, signedDocuments }) => { const xml = signedDocuments?.[0]?.documentXml || ''; if (!xml.includes(`${challenge}`) || !xml.includes(`${nonce}`)) { throw new Error('Mock challenge/nonce mismatch'); } if (!xml.includes('NOT_A_SIGNATURE')) { throw new Error('This demo expects the test mock response'); } return { mockOnly: true, message: 'Challenge handoff passed; no signature was verified.' }; }, })); const port = Number(process.env.PORT || 3102); app.listen(port, '127.0.0.1', () => console.log(`TEST WIDGET ADAPTER ONLY at http://127.0.0.1:${port}`));