BangSo/apps/desktop/src/window-open.ts

24 lines
570 B
TypeScript
Raw Normal View History

2026-09-01 16:51:19 +00:00
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);
}