2025-03-06 00:14:30 +01:00
|
|
|
class AttachPublicKeyMiddlewareProvider {
|
|
|
|
|
constructor(sessionService) {
|
|
|
|
|
this.sessionService = sessionService;
|
|
|
|
|
}
|
2025-02-14 01:32:03 +01:00
|
|
|
|
2025-03-06 00:14:30 +01:00
|
|
|
provide() {
|
|
|
|
|
return async (req, res, next) => {
|
|
|
|
|
const publicKey = await this.sessionService.getPublicKeyRelatedToSession(
|
|
|
|
|
req.cookies.sessionUuid
|
|
|
|
|
);
|
2025-02-14 01:32:03 +01:00
|
|
|
|
2025-03-06 00:14:30 +01:00
|
|
|
if (publicKey) {
|
|
|
|
|
req.cookies.publicKey = publicKey;
|
|
|
|
|
}
|
|
|
|
|
next();
|
|
|
|
|
};
|
2025-02-17 01:18:43 +01:00
|
|
|
}
|
2025-02-14 01:32:03 +01:00
|
|
|
}
|
|
|
|
|
|
2025-03-06 00:14:30 +01:00
|
|
|
module.exports = AttachPublicKeyMiddlewareProvider;
|