Files
zitadel/acceptance/tests/otp.ts

32 lines
763 B
TypeScript
Raw Normal View History

2024-11-15 09:29:48 +01:00
import * as http from "node:http";
let messages = new Map<string, any>();
export function startSink() {
2024-11-15 13:48:42 +01:00
const hostname = "127.0.0.1";
const port = 3030;
2024-11-15 09:29:48 +01:00
2024-11-15 13:48:42 +01:00
const server = http.createServer((req, res) => {
console.log("Sink received message: ");
let body = "";
req.on("data", (chunk) => {
body += chunk;
2024-11-15 09:29:48 +01:00
});
2024-11-15 13:48:42 +01:00
req.on("end", () => {
console.log(body);
const data = JSON.parse(body);
messages.set(data.contextInfo.recipientEmailAddress, data.args.code);
res.statusCode = 200;
res.setHeader("Content-Type", "text/plain");
res.write("OK");
res.end();
2024-11-15 09:29:48 +01:00
});
2024-11-15 13:48:42 +01:00
});
server.listen(port, hostname, () => {
console.log(`Sink running at http://${hostname}:${port}/`);
});
return server;
}