28 lines
838 B
TypeScript
28 lines
838 B
TypeScript
// electron/ipc/tokenHandler.ts
|
|
import { ipcMain } from 'electron';
|
|
import { getToken, saveToken, clearToken } from '../utils/tokenHelper.js';
|
|
import { handleLogin, takeScreenshot } from '../utils/utilityFunctions.js';
|
|
|
|
ipcMain.handle('get-token', async (_, TOKEN_KEY: string) => {
|
|
return await getToken(TOKEN_KEY);
|
|
});
|
|
|
|
ipcMain.handle('save-token', async (_, TOKEN_KEY: string, token: string) => {
|
|
await saveToken(TOKEN_KEY, token);
|
|
return true;
|
|
});
|
|
|
|
ipcMain.handle('clear-token', async (_, TOKEN_KEY: string) => {
|
|
await clearToken(TOKEN_KEY);
|
|
return true;
|
|
});
|
|
|
|
|
|
ipcMain.handle('upload-screenshot', async () => {
|
|
takeScreenshot()
|
|
})
|
|
|
|
// Handle login request from renderer
|
|
ipcMain.handle('login-request', async (event, credentials: { email: string, password: string }) => {
|
|
return handleLogin(credentials);
|
|
}); |