ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: Plane live access и logout handoff

This commit is contained in:
DCCONSTRUCTIONS
2026-05-04 18:54:21 +03:00
parent 55318f14e5
commit 3b13e5be52
15 changed files with 435 additions and 36 deletions
+50
View File
@@ -0,0 +1,50 @@
export function shouldUseNodeDCOIDC(): boolean {
const flag = process.env.VITE_NODEDC_OIDC_LOGIN_ENABLED;
if (flag === "1" || flag === "true") {
return true;
}
if (flag === "0" || flag === "false") {
return false;
}
if (typeof window === "undefined") {
return false;
}
const hostname = window.location.hostname.toLowerCase();
return hostname.endsWith(".local.nodedc") || hostname.endsWith(".notdc.ru") || hostname.endsWith(".nodedc.ru");
}
export function buildNodeDCOIDCLoginUrl(nextPath?: string | null): string {
const configuredUrl = process.env.VITE_NODEDC_OIDC_LOGIN_URL || "/auth/oidc/login/";
const url = new URL(configuredUrl, window.location.origin);
const safeNextPath = sanitizeNextPath(nextPath || getCurrentRelativePath());
if (safeNextPath) {
url.searchParams.set("next_path", safeNextPath);
}
return url.toString();
}
export function buildNodeDCLauncherUrl(): string {
return process.env.VITE_NODEDC_LAUNCHER_URL || "http://launcher.local.nodedc/";
}
export function getCurrentRelativePath(): string {
if (typeof window === "undefined") {
return "/";
}
return `${window.location.pathname}${window.location.search}`;
}
export function sanitizeNextPath(value?: string | null): string {
if (!value || !value.startsWith("/") || value.startsWith("//")) {
return "/";
}
return value;
}