v1.8.0 #429
@@ -64,6 +64,8 @@ function createWindow() {
|
|||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
webSecurity: true,
|
webSecurity: true,
|
||||||
preload: path.join(__dirname, "preload.js"),
|
preload: path.join(__dirname, "preload.js"),
|
||||||
|
partition: "persist:termix",
|
||||||
|
allowRunningInsecureContent: false,
|
||||||
},
|
},
|
||||||
show: false,
|
show: false,
|
||||||
});
|
});
|
||||||
@@ -123,6 +125,20 @@ function createWindow() {
|
|||||||
delete headers["Content-Security-Policy"];
|
delete headers["Content-Security-Policy"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (headers["set-cookie"]) {
|
||||||
|
headers["set-cookie"] = headers["set-cookie"].map((cookie) => {
|
||||||
|
let modified = cookie.replace(/;\s*SameSite=Strict/gi, "; SameSite=None");
|
||||||
|
modified = modified.replace(/;\s*SameSite=Lax/gi, "; SameSite=None");
|
||||||
|
if (!modified.includes("SameSite=")) {
|
||||||
|
modified += "; SameSite=None";
|
||||||
|
}
|
||||||
|
if (!modified.includes("Secure") && details.url.startsWith("https")) {
|
||||||
|
modified += "; Secure";
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
callback({ responseHeaders: headers });
|
callback({ responseHeaders: headers });
|
||||||
|
|||||||
@@ -37,7 +37,11 @@ app.use(
|
|||||||
return callback(null, true);
|
return callback(null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, true);
|
if (origin.startsWith("http://")) {
|
||||||
|
return callback(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(new Error("Not allowed by CORS"));
|
||||||
},
|
},
|
||||||
credentials: true,
|
credentials: true,
|
||||||
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
|
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ app.use(
|
|||||||
return callback(null, true);
|
return callback(null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (origin.startsWith("http://")) {
|
||||||
|
return callback(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
callback(new Error("Not allowed by CORS"));
|
callback(new Error("Not allowed by CORS"));
|
||||||
},
|
},
|
||||||
credentials: true,
|
credentials: true,
|
||||||
|
|||||||
@@ -65,7 +65,11 @@ app.use(
|
|||||||
return callback(null, true);
|
return callback(null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, true);
|
if (origin.startsWith("http://")) {
|
||||||
|
return callback(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(new Error("Not allowed by CORS"));
|
||||||
},
|
},
|
||||||
credentials: true,
|
credentials: true,
|
||||||
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
||||||
|
|||||||
@@ -603,7 +603,11 @@ app.use(
|
|||||||
return callback(null, true);
|
return callback(null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, true);
|
if (origin.startsWith("http://")) {
|
||||||
|
return callback(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(new Error("Not allowed by CORS"));
|
||||||
},
|
},
|
||||||
credentials: true,
|
credentials: true,
|
||||||
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
|
methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ app.use(
|
|||||||
return callback(null, true);
|
return callback(null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, true);
|
if (origin.startsWith("http://")) {
|
||||||
|
return callback(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(new Error("Not allowed by CORS"));
|
||||||
},
|
},
|
||||||
credentials: true,
|
credentials: true,
|
||||||
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
||||||
|
|||||||
36
src/main.tsx
36
src/main.tsx
@@ -76,25 +76,23 @@ function RootApp() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isElectron() && (
|
<div
|
||||||
<div
|
className="fixed inset-0 pointer-events-none"
|
||||||
className="fixed inset-0 pointer-events-none"
|
style={{
|
||||||
style={{
|
backgroundColor: "#09090b",
|
||||||
backgroundColor: "#09090b",
|
backgroundImage: `linear-gradient(
|
||||||
backgroundImage: `linear-gradient(
|
135deg,
|
||||||
135deg,
|
transparent 0%,
|
||||||
transparent 0%,
|
transparent 49%,
|
||||||
transparent 49%,
|
rgba(255, 255, 255, 0.03) 49%,
|
||||||
rgba(255, 255, 255, 0.03) 49%,
|
rgba(255, 255, 255, 0.03) 51%,
|
||||||
rgba(255, 255, 255, 0.03) 51%,
|
transparent 51%,
|
||||||
transparent 51%,
|
transparent 100%
|
||||||
transparent 100%
|
)`,
|
||||||
)`,
|
backgroundSize: "80px 80px",
|
||||||
backgroundSize: "80px 80px",
|
zIndex: 0,
|
||||||
zIndex: 0,
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
|
||||||
)}
|
|
||||||
<div className="relative min-h-screen" style={{ zIndex: 1 }}>
|
<div className="relative min-h-screen" style={{ zIndex: 1 }}>
|
||||||
{isElectron() && showVersionCheck ? (
|
{isElectron() && showVersionCheck ? (
|
||||||
<ElectronVersionCheck
|
<ElectronVersionCheck
|
||||||
|
|||||||
@@ -646,7 +646,21 @@ export function Auth({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isElectron() && currentServerUrl && !loggedIn && !authLoading) {
|
if (isElectron() && currentServerUrl && authLoading) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`w-[420px] max-w-full p-6 flex flex-col bg-dark-bg border-2 border-dark-border rounded-md overflow-y-auto my-2 ${className || ""}`}
|
||||||
|
style={{ maxHeight: "calc(100vh - 1rem)" }}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<div className="flex items-center justify-center h-32">
|
||||||
|
<div className="w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isElectron() && currentServerUrl && !loggedIn) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="w-full h-screen flex items-center justify-center p-4"
|
className="w-full h-screen flex items-center justify-center p-4"
|
||||||
|
|||||||
@@ -129,6 +129,36 @@ export function ElectronLoginForm({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearAuthData() {
|
||||||
|
try {
|
||||||
|
localStorage.removeItem('jwt');
|
||||||
|
sessionStorage.removeItem('jwt');
|
||||||
|
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i];
|
||||||
|
const eqPos = cookie.indexOf('=');
|
||||||
|
const name = eqPos > -1 ? cookie.substr(0, eqPos).trim() : cookie.trim();
|
||||||
|
if (name === 'jwt') {
|
||||||
|
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/';
|
||||||
|
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=' + window.location.hostname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('message', function(event) {
|
||||||
|
try {
|
||||||
|
if (event.data && typeof event.data === 'object') {
|
||||||
|
if (event.data.type === 'CLEAR_AUTH_DATA') {
|
||||||
|
clearAuthData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function checkAuth() {
|
function checkAuth() {
|
||||||
try {
|
try {
|
||||||
const localToken = localStorage.getItem('jwt');
|
const localToken = localStorage.getItem('jwt');
|
||||||
@@ -312,7 +342,8 @@ export function ElectronLoginForm({
|
|||||||
className="w-full h-full border-0"
|
className="w-full h-full border-0"
|
||||||
title="Server Authentication"
|
title="Server Authentication"
|
||||||
sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-storage-access-by-user-activation allow-top-navigation allow-top-navigation-by-user-activation allow-modals allow-downloads"
|
sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-storage-access-by-user-activation allow-top-navigation allow-top-navigation-by-user-activation allow-modals allow-downloads"
|
||||||
allow="clipboard-read; clipboard-write; cross-origin-isolated; camera; microphone; geolocation"
|
allow="clipboard-read; clipboard-write; cross-origin-isolated; camera; microphone; geolocation; storage-access"
|
||||||
|
credentialless={false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ export function LeftSidebar({
|
|||||||
>
|
>
|
||||||
<span>{t("profile.title")}</span>
|
<span>{t("profile.title")}</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
{isAdmin && !isElectron() && (
|
{isAdmin && (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
className="rounded px-2 py-1.5 hover:bg-white/15 hover:text-accent-foreground focus:bg-white/20 focus:text-accent-foreground cursor-pointer focus:outline-none"
|
className="rounded px-2 py-1.5 hover:bg-white/15 hover:text-accent-foreground focus:bg-white/20 focus:text-accent-foreground cursor-pointer focus:outline-none"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@@ -34,6 +34,29 @@ async function handleLogout() {
|
|||||||
|
|
||||||
if (isElectron()) {
|
if (isElectron()) {
|
||||||
localStorage.removeItem("jwt");
|
localStorage.removeItem("jwt");
|
||||||
|
|
||||||
|
const configuredServerUrl = (
|
||||||
|
window as Window &
|
||||||
|
typeof globalThis & {
|
||||||
|
configuredServerUrl?: string;
|
||||||
|
}
|
||||||
|
).configuredServerUrl;
|
||||||
|
|
||||||
|
if (configuredServerUrl) {
|
||||||
|
const iframe = document.querySelector("iframe");
|
||||||
|
if (iframe && iframe.contentWindow) {
|
||||||
|
try {
|
||||||
|
const serverOrigin = new URL(configuredServerUrl).origin;
|
||||||
|
iframe.contentWindow.postMessage(
|
||||||
|
{
|
||||||
|
type: "CLEAR_AUTH_DATA",
|
||||||
|
timestamp: Date.now(),
|
||||||
|
},
|
||||||
|
serverOrigin,
|
||||||
|
);
|
||||||
|
} catch (err) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
|||||||
Reference in New Issue
Block a user