wip
This commit is contained in:
@@ -20,6 +20,17 @@ export interface AuthActionResponse {
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface CheckoutConfirmationRequest {
|
||||
price: string;
|
||||
state: 'ready' | 'insufficient_funds';
|
||||
sessionMetadata: {
|
||||
sessionName: string;
|
||||
trackId: string;
|
||||
carIds: string[];
|
||||
};
|
||||
timeoutMs: number;
|
||||
}
|
||||
|
||||
export interface ElectronAPI {
|
||||
startAutomation: (config: HostedSessionConfig) => Promise<{
|
||||
success: boolean;
|
||||
@@ -37,6 +48,12 @@ export interface ElectronAPI {
|
||||
initiateLogin: () => Promise<AuthActionResponse>;
|
||||
confirmLogin: () => Promise<AuthActionResponse>;
|
||||
logout: () => Promise<AuthActionResponse>;
|
||||
// Browser Mode APIs
|
||||
getBrowserMode: () => Promise<{ mode: 'headed' | 'headless'; isDevelopment: boolean }>;
|
||||
setBrowserMode: (mode: 'headed' | 'headless') => Promise<{ success: boolean; mode?: string; error?: string }>;
|
||||
// Checkout Confirmation APIs
|
||||
onCheckoutConfirmationRequest: (callback: (request: CheckoutConfirmationRequest) => void) => () => void;
|
||||
confirmCheckout: (decision: 'confirmed' | 'cancelled' | 'timeout') => void;
|
||||
}
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
@@ -56,4 +73,18 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
initiateLogin: () => ipcRenderer.invoke('auth:login'),
|
||||
confirmLogin: () => ipcRenderer.invoke('auth:confirmLogin'),
|
||||
logout: () => ipcRenderer.invoke('auth:logout'),
|
||||
// Browser Mode APIs
|
||||
getBrowserMode: () => ipcRenderer.invoke('browser-mode:get'),
|
||||
setBrowserMode: (mode: 'headed' | 'headless') => ipcRenderer.invoke('browser-mode:set', mode),
|
||||
// Checkout Confirmation APIs
|
||||
onCheckoutConfirmationRequest: (callback: (request: CheckoutConfirmationRequest) => void) => {
|
||||
const listener = (_event: any, request: CheckoutConfirmationRequest) => callback(request);
|
||||
ipcRenderer.on('checkout:request-confirmation', listener);
|
||||
return () => {
|
||||
ipcRenderer.removeListener('checkout:request-confirmation', listener);
|
||||
};
|
||||
},
|
||||
confirmCheckout: (decision: 'confirmed' | 'cancelled' | 'timeout') => {
|
||||
ipcRenderer.send('checkout:confirm', decision);
|
||||
},
|
||||
} as ElectronAPI);
|
||||
Reference in New Issue
Block a user