Use native Chrome for Reddit login handoff

This commit is contained in:
jjbrunton committed 2026-08-08 16:16:11 +01:00
1 parent 2c533fa52a
commit dbb1842ef4
13 files changed
+324 -60

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
export interface NativeLoginHandoff {
request(): void;
}
export interface ProcessNativeLoginHandoffOptions {
exitCode?: number;
delayMs?: number;
exit?: (code: number) => void;
}
export class ProcessNativeLoginHandoff implements NativeLoginHandoff {
private requested = false;
private readonly exitCode: number;
private readonly delayMs: number;
private readonly exit: (code: number) => void;
constructor(options: ProcessNativeLoginHandoffOptions = {}) {
this.exitCode = options.exitCode ?? 75;
this.delayMs = options.delayMs ?? 250;
this.exit = options.exit ?? ((code) => process.exit(code));
}
request(): void {
if (this.requested) return;
this.requested = true;
setTimeout(() => this.exit(this.exitCode), this.delayMs).unref();
}
}