6ede33ccdb
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64, , runner, false, cpu) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_web, cpu, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64, , runner, false, cpu) (push) Blocked by required conditions
Build and Push Docker Images / compute_version (push) Waiting to run
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, , production, false, cpu) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda126, production, true, cuda126) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_backend, cu126, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda126, production, true, cuda126) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, -cuda, production, true, cuda) (push) Blocked by required conditions
Build and Push Docker Images / verify_digests (push) Blocked by required conditions
Build and Push Docker Images / create_manifest (backend, surfsense-backend, , cpu) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_backend, cpu, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64, , production, false, cpu) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_backend, cu128, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64, -cuda, production, true, cuda) (push) Blocked by required conditions
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda, cuda) (push) Blocked by required conditions
Build and Push Docker Images / create_manifest (backend, surfsense-backend, -cuda126, cuda126) (push) Blocked by required conditions
Build and Push Docker Images / create_manifest (web, surfsense-web, , cpu) (push) Blocked by required conditions
Build and Push Docker Images / finalize_release (push) Blocked by required conditions
Obsidian Plugin Lint / lint (push) Waiting to run
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
export const RUNTIME_AUTH_TYPE_COOKIE_NAME = "surfsense_auth_type";
|
|
|
|
export type RuntimeAuthUiMode = "GOOGLE" | "LOCAL";
|
|
|
|
export function resolveRuntimeAuthUiMode(
|
|
value: string | null | undefined,
|
|
fallback: string | null | undefined = "LOCAL"
|
|
): RuntimeAuthUiMode {
|
|
const candidate = value?.trim().toUpperCase();
|
|
if (candidate === "GOOGLE") return "GOOGLE";
|
|
if (candidate === "LOCAL") return "LOCAL";
|
|
|
|
const fallbackCandidate = fallback?.trim().toUpperCase();
|
|
return fallbackCandidate === "GOOGLE" ? "GOOGLE" : "LOCAL";
|
|
}
|
|
|
|
export function getRuntimeAuthInitScript(fallbackAuthType: string): string {
|
|
const fallback = resolveRuntimeAuthUiMode(fallbackAuthType);
|
|
const cookieName = JSON.stringify(RUNTIME_AUTH_TYPE_COOKIE_NAME);
|
|
const fallbackValue = JSON.stringify(fallback);
|
|
|
|
return `
|
|
(function() {
|
|
try {
|
|
var cookieName = ${cookieName};
|
|
var fallback = ${fallbackValue};
|
|
var prefix = cookieName + "=";
|
|
var rawValue = fallback;
|
|
var cookies = document.cookie ? document.cookie.split(";") : [];
|
|
for (var i = 0; i < cookies.length; i++) {
|
|
var cookie = cookies[i].trim();
|
|
if (cookie.indexOf(prefix) === 0) {
|
|
rawValue = decodeURIComponent(cookie.slice(prefix.length));
|
|
break;
|
|
}
|
|
}
|
|
var normalized = String(rawValue || fallback).toUpperCase() === "GOOGLE" ? "GOOGLE" : "LOCAL";
|
|
window.__SURFSENSE_AUTH_TYPE__ = normalized;
|
|
document.documentElement.setAttribute("data-surfsense-auth-type", normalized);
|
|
} catch (_) {
|
|
window.__SURFSENSE_AUTH_TYPE__ = ${fallbackValue};
|
|
document.documentElement.setAttribute("data-surfsense-auth-type", ${fallbackValue});
|
|
}
|
|
})();
|
|
`;
|
|
}
|
|
|
|
declare global {
|
|
interface Window {
|
|
__SURFSENSE_AUTH_TYPE__?: RuntimeAuthUiMode;
|
|
}
|
|
}
|