22 lines
648 B
TypeScript
22 lines
648 B
TypeScript
// app:hostname adapter — returns the OS hostname via Node's `os.hostname()`.
|
|
// The renderer has no Node access (contextIsolation is ON), so it must ask
|
|
// main for this value. Used by AuthContext on first launch to populate the
|
|
// `devices` row with a human-readable default device name.
|
|
|
|
import os from 'node:os';
|
|
|
|
import { ipcMain } from 'electron';
|
|
|
|
import { CHANNELS } from '../ipc-types';
|
|
|
|
export function register(): void {
|
|
ipcMain.handle(CHANNELS.APP_HOSTNAME, (): string | null => {
|
|
try {
|
|
const h = os.hostname();
|
|
return typeof h === 'string' && h.length > 0 ? h : null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
});
|
|
}
|