hermes-agent/apps/desktop/electron/oauth-navigation.ts
Gille a7059225d5
fix(desktop): keep Cloud portal sign-in alive through redirect aborts (#123091)
* fix(desktop): keep portal sign-in alive across redirect aborts

(cherry picked from commit 3de10973b8e234853ddd0a8ed15bdb66722f5728)

* refactor(desktop): share the ERR_ABORTED predicate between both cookie windows

The remote OAuth window (main.ts, #110308) and the portal window
(portal-session.ts) each carried the same inline `code === -3 ||
/ERR_ABORTED/` test. One resolver per policy: extract it to
oauth-navigation.ts so the two windows cannot drift on what counts as a
superseded navigation. Helper and its unit test come from #89377.

Co-authored-by: Matt Earls <[email protected]>

---------

Co-authored-by: Austin Pickett <[email protected]>
Co-authored-by: Matt Earls <[email protected]>
2026-09-26 20:43:56 +00:00

10 lines
369 B
TypeScript

export function isExpectedOauthNavigationAbort(error: unknown): boolean {
if (!error || typeof error !== 'object') {
return false
}
const code = 'code' in error ? Number((error as { code?: unknown }).code) : Number.NaN
const message = error instanceof Error ? error.message : String(error)
return code === -3 || /\bERR_ABORTED\b|\(-3\)/.test(message)
}