Add Electron desktop shell workspace

This commit is contained in:
dirtydishes 2026-05-13 09:21:06 -04:00
parent b803d10836
commit 5d8e5ea44a
16 changed files with 1652 additions and 21 deletions

View file

@ -0,0 +1,44 @@
export const DESKTOP_PRODUCTION_URL = "https://flow.deltaisland.io";
export const DESKTOP_LOCAL_DEV_URL = "http://127.0.0.1:3000";
const TRUSTED_ORIGINS = new Set([
new URL(DESKTOP_PRODUCTION_URL).origin,
new URL(DESKTOP_LOCAL_DEV_URL).origin,
"http://localhost:3000"
]);
const HTTP_PROTOCOLS = new Set(["http:", "https:"]);
const parseUrl = (candidate: string): URL | null => {
try {
return new URL(candidate);
} catch {
return null;
}
};
export const isTrustedAppUrl = (candidate: string): boolean => {
const url = parseUrl(candidate);
if (!url || !HTTP_PROTOCOLS.has(url.protocol)) {
return false;
}
return TRUSTED_ORIGINS.has(url.origin);
};
export const isSafeExternalUrl = (candidate: string): boolean => {
const url = parseUrl(candidate);
if (!url || !HTTP_PROTOCOLS.has(url.protocol)) {
return false;
}
return !TRUSTED_ORIGINS.has(url.origin);
};
export const resolveDesktopStartUrl = (candidate: string | undefined): string => {
if (candidate && isTrustedAppUrl(candidate)) {
return candidate;
}
return DESKTOP_PRODUCTION_URL;
};