mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
17 lines
488 B
TypeScript
17 lines
488 B
TypeScript
import jwt from "jsonwebtoken";
|
|
|
|
import { userAuthRepository } from "@main/repository";
|
|
import { registerEvent } from "../register-event";
|
|
|
|
const getSessionHash = async (_event: Electron.IpcMainInvokeEvent) => {
|
|
const auth = await userAuthRepository.findOne({ where: { id: 1 } });
|
|
|
|
if (!auth) return null;
|
|
const payload = jwt.decode(auth.accessToken) as jwt.JwtPayload;
|
|
|
|
if (!payload) return null;
|
|
|
|
return payload.sessionId;
|
|
};
|
|
|
|
registerEvent("getSessionHash", getSessionHash);
|