const OAUTH_POPUP_NAMES = new Set([ "rakazo-app-connect", "rakazo-mcp-oauth", "rakazo-model-oauth", "rakazo-plugin-connect", ]); export function shouldOpenInAppPopup( appOrigin: string | null, childUrl: string, frameName: string, ) { let target: URL; try { target = new URL(childUrl); } catch { return false; } const isHttp = target.protocol === "http:" || target.protocol === "https:"; if (appOrigin !== null && target.origin === appOrigin) return isHttp; return target.protocol === "https:" && OAUTH_POPUP_NAMES.has(frameName); }