Projektstart

- Phase 1 "Twitch Login" abgeschlossen
This commit is contained in:
Andre
2026-04-07 20:11:00 +02:00
commit 7d19ccf652
23 changed files with 8606 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
import { contextBridge, ipcRenderer, type IpcRendererEvent } from 'electron'
const IPC = {
authStatus: 'auth:get-status',
authStart: 'auth:start-device-flow',
authCancel: 'auth:cancel',
authLogout: 'auth:logout',
authConfigured: 'auth:is-configured',
authEvent: 'auth:event'
} as const
export type AuthStatus = 'logged-out' | 'logged-in'
export interface DeviceFlowStartInfo {
userCode: string
verificationUri: string
expiresInSec: number
}
export type AuthEvent =
| { kind: 'authorized' }
| { kind: 'denied' }
| { kind: 'expired' }
| { kind: 'cancelled' }
| { kind: 'error'; message: string }
const api = {
appVersion: process.env.npm_package_version ?? '0.0.0',
auth: {
isConfigured: (): Promise<boolean> => ipcRenderer.invoke(IPC.authConfigured),
getStatus: (): Promise<AuthStatus> => ipcRenderer.invoke(IPC.authStatus),
startDeviceFlow: (): Promise<DeviceFlowStartInfo> => ipcRenderer.invoke(IPC.authStart),
cancel: (): Promise<void> => ipcRenderer.invoke(IPC.authCancel),
logout: (): Promise<void> => ipcRenderer.invoke(IPC.authLogout),
onEvent: (cb: (event: AuthEvent) => void): (() => void) => {
const listener = (_e: IpcRendererEvent, event: AuthEvent): void => cb(event)
ipcRenderer.on(IPC.authEvent, listener)
return () => ipcRenderer.removeListener(IPC.authEvent, listener)
}
}
}
contextBridge.exposeInMainWorld('t4sd', api)
export type T4sdApi = typeof api