From 7957ed06e404542859714e18994f266addd69f68 Mon Sep 17 00:00:00 2001 From: LukeGus Date: Thu, 21 Aug 2025 22:47:38 -0500 Subject: [PATCH 1/7] Fix localhost connection issues --- src/ui/Homepage/HomepageAuth.tsx | 118 +++++++------ src/ui/main-axios.ts | 284 ++++++++++++++++++++++--------- 2 files changed, 265 insertions(+), 137 deletions(-) diff --git a/src/ui/Homepage/HomepageAuth.tsx b/src/ui/Homepage/HomepageAuth.tsx index 43241e55..8cb5a221 100644 --- a/src/ui/Homepage/HomepageAuth.tsx +++ b/src/ui/Homepage/HomepageAuth.tsx @@ -1,10 +1,21 @@ import React, {useState, useEffect} from "react"; -import {cn} from "@/lib/utils.ts"; -import {Button} from "@/components/ui/button.tsx"; -import {Input} from "@/components/ui/input.tsx"; -import {Label} from "@/components/ui/label.tsx"; -import {Alert, AlertTitle, AlertDescription} from "@/components/ui/alert.tsx"; -import axios from "axios"; +import {cn} from "../../lib/utils.ts"; +import {Button} from "../../components/ui/button.tsx"; +import {Input} from "../../components/ui/input.tsx"; +import {Label} from "../../components/ui/label.tsx"; +import {Alert, AlertTitle, AlertDescription} from "../../components/ui/alert.tsx"; +import { + registerUser, + loginUser, + getUserInfo, + getRegistrationAllowed, + getOIDCConfig, + getUserCount, + initiatePasswordReset, + verifyPasswordResetCode, + completePasswordReset, + getOIDCAuthorizeUrl +} from "../main-axios.ts"; function setCookie(name: string, value: string, days = 7) { const expires = new Date(Date.now() + days * 864e5).toUTCString(); @@ -18,11 +29,7 @@ function getCookie(name: string) { }, ""); } -const apiBase = import.meta.env.DEV ? "http://localhost:8081/users" : "/users"; -const API = axios.create({ - baseURL: apiBase, -}); interface HomepageAuthProps extends React.ComponentProps<"div"> { setLoggedIn: (loggedIn: boolean) => void; @@ -74,14 +81,14 @@ export function HomepageAuth({ }, [loggedIn]); useEffect(() => { - API.get("/registration-allowed").then(res => { - setRegistrationAllowed(res.data.allowed); + getRegistrationAllowed().then(res => { + setRegistrationAllowed(res.allowed); }); }, []); useEffect(() => { - API.get("/oidc-config").then((response) => { - if (response.data) { + getOIDCConfig().then((response) => { + if (response) { setOidcConfigured(true); } else { setOidcConfigured(false); @@ -96,8 +103,8 @@ export function HomepageAuth({ }, []); useEffect(() => { - API.get("/count").then(res => { - if (res.data.count === 0) { + getUserCount().then(res => { + if (res.count === 0) { setFirstUser(true); setTab("signup"); } else { @@ -123,7 +130,7 @@ export function HomepageAuth({ try { let res, meRes; if (tab === "login") { - res = await API.post("/login", {username: localUsername, password}); + res = await loginUser(localUsername, password); } else { if (password !== signupConfirmPassword) { setError("Passwords do not match"); @@ -135,31 +142,37 @@ export function HomepageAuth({ setLoading(false); return; } - await API.post("/create", {username: localUsername, password}); - res = await API.post("/login", {username: localUsername, password}); + + await registerUser(localUsername, password); + res = await loginUser(localUsername, password); } - setCookie("jwt", res.data.token); + + if (!res || !res.token) { + throw new Error('No token received from login'); + } + + setCookie("jwt", res.token); [meRes] = await Promise.all([ - API.get("/me", {headers: {Authorization: `Bearer ${res.data.token}`}}), - API.get("/db-health") + getUserInfo(), ]); + setInternalLoggedIn(true); setLoggedIn(true); - setIsAdmin(!!meRes.data.is_admin); - setUsername(meRes.data.username || null); - setUserId(meRes.data.id || null); + setIsAdmin(!!meRes.is_admin); + setUsername(meRes.username || null); + setUserId(meRes.userId || null); setDbError(null); onAuthSuccess({ - isAdmin: !!meRes.data.is_admin, - username: meRes.data.username || null, - userId: meRes.data.id || null + isAdmin: !!meRes.is_admin, + username: meRes.username || null, + userId: meRes.userId || null }); setInternalLoggedIn(true); if (tab === "signup") { setSignupConfirmPassword(""); } } catch (err: any) { - setError(err?.response?.data?.error || "Unknown error"); + setError(err?.response?.data?.error || err?.message || "Unknown error"); setInternalLoggedIn(false); setLoggedIn(false); setIsAdmin(false); @@ -176,29 +189,26 @@ export function HomepageAuth({ } } - async function initiatePasswordReset() { + async function handleInitiatePasswordReset() { setError(null); setResetLoading(true); try { - await API.post("/initiate-reset", {username: localUsername}); + const result = await initiatePasswordReset(localUsername); setResetStep("verify"); setError(null); } catch (err: any) { - setError(err?.response?.data?.error || "Failed to initiate password reset"); + setError(err?.response?.data?.error || err?.message || "Failed to initiate password reset"); } finally { setResetLoading(false); } } - async function verifyResetCode() { + async function handleVerifyResetCode() { setError(null); setResetLoading(true); try { - const response = await API.post("/verify-reset-code", { - username: localUsername, - resetCode: resetCode - }); - setTempToken(response.data.tempToken); + const response = await verifyPasswordResetCode(localUsername, resetCode); + setTempToken(response.tempToken); setResetStep("newPassword"); setError(null); } catch (err: any) { @@ -208,7 +218,7 @@ export function HomepageAuth({ } } - async function completePasswordReset() { + async function handleCompletePasswordReset() { setError(null); setResetLoading(true); @@ -225,11 +235,7 @@ export function HomepageAuth({ } try { - await API.post("/complete-reset", { - username: localUsername, - tempToken: tempToken, - newPassword: newPassword - }); + await completePasswordReset(localUsername, tempToken, newPassword); setResetStep("initiate"); setResetCode(""); @@ -267,8 +273,8 @@ export function HomepageAuth({ setError(null); setOidcLoading(true); try { - const authResponse = await API.get("/oidc/authorize"); - const {auth_url: authUrl} = authResponse.data; + const authResponse = await getOIDCAuthorizeUrl(); + const {auth_url: authUrl} = authResponse; if (!authUrl || authUrl === 'undefined') { throw new Error('Invalid authorization URL received from backend'); @@ -299,18 +305,18 @@ export function HomepageAuth({ setError(null); setCookie("jwt", token); - API.get("/me", {headers: {Authorization: `Bearer ${token}`}}) + getUserInfo() .then(meRes => { setInternalLoggedIn(true); setLoggedIn(true); - setIsAdmin(!!meRes.data.is_admin); - setUsername(meRes.data.username || null); - setUserId(meRes.data.id || null); + setIsAdmin(!!meRes.is_admin); + setUsername(meRes.username || null); + setUserId(meRes.id || null); setDbError(null); onAuthSuccess({ - isAdmin: !!meRes.data.is_admin, - username: meRes.data.username || null, - userId: meRes.data.id || null + isAdmin: !!meRes.is_admin, + username: meRes.username || null, + userId: meRes.id || null }); setInternalLoggedIn(true); window.history.replaceState({}, document.title, window.location.pathname); @@ -486,7 +492,7 @@ export function HomepageAuth({ type="button" className="w-full h-11 text-base font-semibold" disabled={resetLoading || !localUsername.trim()} - onClick={initiatePasswordReset} + onClick={handleInitiatePasswordReset} > {resetLoading ? Spinner : "Send Reset Code"} @@ -519,7 +525,7 @@ export function HomepageAuth({ type="button" className="w-full h-11 text-base font-semibold" disabled={resetLoading || resetCode.length !== 6} - onClick={verifyResetCode} + onClick={handleVerifyResetCode} > {resetLoading ? Spinner : "Verify Code"} @@ -598,7 +604,7 @@ export function HomepageAuth({ type="button" className="w-full h-11 text-base font-semibold" disabled={resetLoading || !newPassword || !confirmPassword} - onClick={completePasswordReset} + onClick={handleCompletePasswordReset} > {resetLoading ? Spinner : "Reset Password"} diff --git a/src/ui/main-axios.ts b/src/ui/main-axios.ts index c1192d85..771cb493 100644 --- a/src/ui/main-axios.ts +++ b/src/ui/main-axios.ts @@ -105,35 +105,51 @@ export type ServerMetrics = { lastChecked: string; }; -const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'; +interface AuthResponse { + token: string; +} -const sshHostApi = axios.create({ - baseURL: isLocalhost ? 'http://localhost:8081' : '', - headers: { - 'Content-Type': 'application/json', - }, -}); +interface UserInfo { + id: string; + username: string; + is_admin: boolean; +} -const tunnelApi = axios.create({ - baseURL: isLocalhost ? 'http://localhost:8083' : '', - headers: { - 'Content-Type': 'application/json', - }, -}); +interface RegistrationResponse { + allowed: boolean; +} -const fileManagerApi = axios.create({ - baseURL: isLocalhost ? 'http://localhost:8084' : '', - headers: { - 'Content-Type': 'application/json', - } -}) +interface OIDCConfig { + configured: boolean; +} -const statsApi = axios.create({ - baseURL: isLocalhost ? 'http://localhost:8085' : '', - headers: { - 'Content-Type': 'application/json', - } -}) +interface UserCount { + count: number; +} + +interface PasswordResetInitiate { + username: string; +} + +interface PasswordResetVerify { + username: string; + resetCode: string; +} + +interface PasswordResetComplete { + username: string; + tempToken: string; + newPassword: string; +} + +interface OIDCAuthorize { + auth_url: string; +} + +function setCookie(name: string, value: string, days = 7) { + const expires = new Date(Date.now() + days * 864e5).toUTCString(); + document.cookie = `${name}=${encodeURIComponent(value)}; expires=${expires}; path=/`; +} function getCookie(name: string): string | undefined { const value = `; ${document.cookie}`; @@ -141,41 +157,54 @@ function getCookie(name: string): string | undefined { if (parts.length === 2) return parts.pop()?.split(';').shift(); } -sshHostApi.interceptors.request.use((config) => { - const token = getCookie('jwt'); - if (token) { - config.headers.Authorization = `Bearer ${token}`; - } - return config; +const sshHostApi = axios.create({ + baseURL: import.meta.env.DEV ? 'http://localhost:8081/ssh' : '/ssh', + headers: { + 'Content-Type': 'application/json', + }, }); -statsApi.interceptors.request.use((config) => { - const token = getCookie('jwt'); - if (token) { - config.headers.Authorization = `Bearer ${token}`; - } - return config; +const tunnelApi = axios.create({ + baseURL: import.meta.env.DEV ? 'http://localhost:8083/ssh' : '/ssh', + headers: { + 'Content-Type': 'application/json', + }, }); -tunnelApi.interceptors.request.use((config) => { - const token = getCookie('jwt'); - if (token) { - config.headers.Authorization = `Bearer ${token}`; +const fileManagerApi = axios.create({ + baseURL: import.meta.env.DEV ? 'http://localhost:8084/ssh' : '/ssh', + headers: { + 'Content-Type': 'application/json', } - return config; }); -fileManagerApi.interceptors.request.use((config) => { - const token = getCookie('jwt'); - if (token) { - config.headers.Authorization = `Bearer ${token}`; +const statsApi = axios.create({ + baseURL: import.meta.env.DEV ? 'http://localhost:8085' : '', + headers: { + 'Content-Type': 'application/json', } - return config; +}); + +const authApi = axios.create({ + baseURL: import.meta.env.DEV ? 'http://localhost:8081/users' : '/users', + headers: { + 'Content-Type': 'application/json', + } +}); + +[sshHostApi, tunnelApi, fileManagerApi, statsApi, authApi].forEach(api => { + api.interceptors.request.use((config) => { + const token = getCookie('jwt'); + if (token) { + config.headers.Authorization = `Bearer ${token}`; + } + return config; + }); }); export async function getSSHHosts(): Promise { try { - const response = await sshHostApi.get('/ssh/db/host'); + const response = await sshHostApi.get('/db/host'); return response.data; } catch (error) { throw error; @@ -220,7 +249,7 @@ export async function createSSHHost(hostData: SSHHostData): Promise { delete dataWithoutFile.key; formData.append('data', JSON.stringify(dataWithoutFile)); - const response = await sshHostApi.post('/ssh/db/host', formData, { + const response = await sshHostApi.post('/db/host', formData, { headers: { 'Content-Type': 'multipart/form-data', }, @@ -228,7 +257,7 @@ export async function createSSHHost(hostData: SSHHostData): Promise { return response.data; } else { - const response = await sshHostApi.post('/ssh/db/host', submitData); + const response = await sshHostApi.post('/db/host', submitData); return response.data; } } catch (error) { @@ -273,7 +302,7 @@ export async function updateSSHHost(hostId: number, hostData: SSHHostData): Prom delete dataWithoutFile.key; formData.append('data', JSON.stringify(dataWithoutFile)); - const response = await sshHostApi.put(`/ssh/db/host/${hostId}`, formData, { + const response = await sshHostApi.put(`/db/host/${hostId}`, formData, { headers: { 'Content-Type': 'multipart/form-data', }, @@ -281,7 +310,7 @@ export async function updateSSHHost(hostId: number, hostData: SSHHostData): Prom return response.data; } else { - const response = await sshHostApi.put(`/ssh/db/host/${hostId}`, submitData); + const response = await sshHostApi.put(`/db/host/${hostId}`, submitData); return response.data; } } catch (error) { @@ -296,7 +325,7 @@ export async function bulkImportSSHHosts(hosts: SSHHostData[]): Promise<{ errors: string[]; }> { try { - const response = await sshHostApi.post('/ssh/bulk-import', {hosts}); + const response = await sshHostApi.post('/bulk-import', {hosts}); return response.data; } catch (error) { throw error; @@ -305,7 +334,7 @@ export async function bulkImportSSHHosts(hosts: SSHHostData[]): Promise<{ export async function deleteSSHHost(hostId: number): Promise { try { - const response = await sshHostApi.delete(`/ssh/db/host/${hostId}`); + const response = await sshHostApi.delete(`/db/host/${hostId}`); return response.data; } catch (error) { throw error; @@ -314,7 +343,7 @@ export async function deleteSSHHost(hostId: number): Promise { export async function getSSHHostById(hostId: number): Promise { try { - const response = await sshHostApi.get(`/ssh/db/host/${hostId}`); + const response = await sshHostApi.get(`/db/host/${hostId}`); return response.data; } catch (error) { throw error; @@ -323,7 +352,7 @@ export async function getSSHHostById(hostId: number): Promise { export async function getTunnelStatuses(): Promise> { try { - const response = await tunnelApi.get('/ssh/tunnel/status'); + const response = await tunnelApi.get('/tunnel/status'); return response.data || {}; } catch (error) { throw error; @@ -337,7 +366,7 @@ export async function getTunnelStatusByName(tunnelName: string): Promise { try { - const response = await tunnelApi.post('/ssh/tunnel/connect', tunnelConfig); + const response = await tunnelApi.post('/tunnel/connect', tunnelConfig); return response.data; } catch (error) { throw error; @@ -346,7 +375,7 @@ export async function connectTunnel(tunnelConfig: TunnelConfig): Promise { export async function disconnectTunnel(tunnelName: string): Promise { try { - const response = await tunnelApi.post('/ssh/tunnel/disconnect', {tunnelName}); + const response = await tunnelApi.post('/tunnel/disconnect', {tunnelName}); return response.data; } catch (error) { throw error; @@ -355,7 +384,7 @@ export async function disconnectTunnel(tunnelName: string): Promise { export async function cancelTunnel(tunnelName: string): Promise { try { - const response = await tunnelApi.post('/ssh/tunnel/cancel', {tunnelName}); + const response = await tunnelApi.post('/tunnel/cancel', {tunnelName}); return response.data; } catch (error) { throw error; @@ -364,7 +393,7 @@ export async function cancelTunnel(tunnelName: string): Promise { export async function getFileManagerRecent(hostId: number): Promise { try { - const response = await sshHostApi.get(`/ssh/file_manager/recent?hostId=${hostId}`); + const response = await sshHostApi.get(`/file_manager/recent?hostId=${hostId}`); return response.data || []; } catch (error) { return []; @@ -379,7 +408,7 @@ export async function addFileManagerRecent(file: { hostId: number }): Promise { try { - const response = await sshHostApi.post('/ssh/file_manager/recent', file); + const response = await sshHostApi.post('/file_manager/recent', file); return response.data; } catch (error) { throw error; @@ -394,7 +423,7 @@ export async function removeFileManagerRecent(file: { hostId: number }): Promise { try { - const response = await sshHostApi.delete('/ssh/file_manager/recent', {data: file}); + const response = await sshHostApi.delete('/file_manager/recent', {data: file}); return response.data; } catch (error) { throw error; @@ -403,7 +432,7 @@ export async function removeFileManagerRecent(file: { export async function getFileManagerPinned(hostId: number): Promise { try { - const response = await sshHostApi.get(`/ssh/file_manager/pinned?hostId=${hostId}`); + const response = await sshHostApi.get(`/file_manager/pinned?hostId=${hostId}`); return response.data || []; } catch (error) { return []; @@ -418,7 +447,7 @@ export async function addFileManagerPinned(file: { hostId: number }): Promise { try { - const response = await sshHostApi.post('/ssh/file_manager/pinned', file); + const response = await sshHostApi.post('/file_manager/pinned', file); return response.data; } catch (error) { throw error; @@ -433,7 +462,7 @@ export async function removeFileManagerPinned(file: { hostId: number }): Promise { try { - const response = await sshHostApi.delete('/ssh/file_manager/pinned', {data: file}); + const response = await sshHostApi.delete('/file_manager/pinned', {data: file}); return response.data; } catch (error) { throw error; @@ -442,7 +471,7 @@ export async function removeFileManagerPinned(file: { export async function getFileManagerShortcuts(hostId: number): Promise { try { - const response = await sshHostApi.get(`/ssh/file_manager/shortcuts?hostId=${hostId}`); + const response = await sshHostApi.get(`/file_manager/shortcuts?hostId=${hostId}`); return response.data || []; } catch (error) { return []; @@ -457,7 +486,7 @@ export async function addFileManagerShortcut(shortcut: { hostId: number }): Promise { try { - const response = await sshHostApi.post('/ssh/file_manager/shortcuts', shortcut); + const response = await sshHostApi.post('/file_manager/shortcuts', shortcut); return response.data; } catch (error) { throw error; @@ -472,7 +501,7 @@ export async function removeFileManagerShortcut(shortcut: { hostId: number }): Promise { try { - const response = await sshHostApi.delete('/ssh/file_manager/shortcuts', {data: shortcut}); + const response = await sshHostApi.delete('/file_manager/shortcuts', {data: shortcut}); return response.data; } catch (error) { throw error; @@ -488,7 +517,7 @@ export async function connectSSH(sessionId: string, config: { keyPassword?: string; }): Promise { try { - const response = await fileManagerApi.post('/ssh/file_manager/ssh/connect', { + const response = await fileManagerApi.post('/ssh/connect', { sessionId, ...config }); @@ -500,7 +529,7 @@ export async function connectSSH(sessionId: string, config: { export async function disconnectSSH(sessionId: string): Promise { try { - const response = await fileManagerApi.post('/ssh/file_manager/ssh/disconnect', {sessionId}); + const response = await fileManagerApi.post('/ssh/disconnect', {sessionId}); return response.data; } catch (error) { throw error; @@ -509,7 +538,7 @@ export async function disconnectSSH(sessionId: string): Promise { export async function getSSHStatus(sessionId: string): Promise<{ connected: boolean }> { try { - const response = await fileManagerApi.get('/ssh/file_manager/ssh/status', { + const response = await fileManagerApi.get('/ssh/status', { params: {sessionId} }); return response.data; @@ -520,7 +549,7 @@ export async function getSSHStatus(sessionId: string): Promise<{ connected: bool export async function listSSHFiles(sessionId: string, path: string): Promise { try { - const response = await fileManagerApi.get('/ssh/file_manager/ssh/listFiles', { + const response = await fileManagerApi.get('/ssh/listFiles', { params: {sessionId, path} }); return response.data || []; @@ -531,7 +560,7 @@ export async function listSSHFiles(sessionId: string, path: string): Promise { try { - const response = await fileManagerApi.get('/ssh/file_manager/ssh/readFile', { + const response = await fileManagerApi.get('/ssh/readFile', { params: {sessionId, path} }); return response.data; @@ -542,7 +571,7 @@ export async function readSSHFile(sessionId: string, path: string): Promise<{ co export async function writeSSHFile(sessionId: string, path: string, content: string): Promise { try { - const response = await fileManagerApi.post('/ssh/file_manager/ssh/writeFile', { + const response = await fileManagerApi.post('/ssh/writeFile', { sessionId, path, content @@ -560,7 +589,7 @@ export async function writeSSHFile(sessionId: string, path: string, content: str export async function uploadSSHFile(sessionId: string, path: string, fileName: string, content: string): Promise { try { - const response = await fileManagerApi.post('/ssh/file_manager/ssh/uploadFile', { + const response = await fileManagerApi.post('/ssh/uploadFile', { sessionId, path, fileName, @@ -574,7 +603,7 @@ export async function uploadSSHFile(sessionId: string, path: string, fileName: s export async function createSSHFile(sessionId: string, path: string, fileName: string, content: string = ''): Promise { try { - const response = await fileManagerApi.post('/ssh/file_manager/ssh/createFile', { + const response = await fileManagerApi.post('/ssh/createFile', { sessionId, path, fileName, @@ -588,7 +617,7 @@ export async function createSSHFile(sessionId: string, path: string, fileName: s export async function createSSHFolder(sessionId: string, path: string, folderName: string): Promise { try { - const response = await fileManagerApi.post('/ssh/file_manager/ssh/createFolder', { + const response = await fileManagerApi.post('/ssh/createFolder', { sessionId, path, folderName @@ -601,7 +630,7 @@ export async function createSSHFolder(sessionId: string, path: string, folderNam export async function deleteSSHItem(sessionId: string, path: string, isDirectory: boolean): Promise { try { - const response = await fileManagerApi.delete('/ssh/file_manager/ssh/deleteItem', { + const response = await fileManagerApi.delete('/ssh/deleteItem', { data: { sessionId, path, @@ -616,7 +645,7 @@ export async function deleteSSHItem(sessionId: string, path: string, isDirectory export async function renameSSHItem(sessionId: string, oldPath: string, newName: string): Promise { try { - const response = await fileManagerApi.put('/ssh/file_manager/ssh/renameItem', { + const response = await fileManagerApi.put('/ssh/renameItem', { sessionId, oldPath, newName @@ -627,7 +656,7 @@ export async function renameSSHItem(sessionId: string, oldPath: string, newName: } } -export {sshHostApi, tunnelApi, fileManagerApi}; + export async function getAllServerStatuses(): Promise> { try { @@ -654,4 +683,97 @@ export async function getServerMetricsById(id: number): Promise { } catch (error) { throw error; } -} \ No newline at end of file +} + +// Auth-related functions +export async function registerUser(username: string, password: string): Promise { + try { + const response = await authApi.post('/create', { username, password }); + return response.data; + } catch (error) { + throw error; + } +} + +export async function loginUser(username: string, password: string): Promise { + try { + const response = await authApi.post('/login', { username, password }); + return response.data; + } catch (error) { + throw error; + } +} + +export async function getUserInfo(): Promise { + try { + const response = await authApi.get('/me'); + return response.data; + } catch (error) { + throw error; + } +} + +export async function getRegistrationAllowed(): Promise<{ allowed: boolean }> { + try { + const response = await authApi.get('/registration-allowed'); + return response.data; + } catch (error) { + throw error; + } +} + +export async function getOIDCConfig(): Promise { + try { + const response = await authApi.get('/oidc-config'); + return response.data; + } catch (error) { + throw error; + } +} + +export async function getUserCount(): Promise { + try { + const response = await authApi.get('/count'); + return response.data; + } catch (error) { + throw error; + } +} + +export async function initiatePasswordReset(username: string): Promise { + try { + const response = await authApi.post('/initiate-reset', { username }); + return response.data; + } catch (error) { + throw error; + } +} + +export async function verifyPasswordResetCode(username: string, resetCode: string): Promise { + try { + const response = await authApi.post('/verify-reset-code', { username, resetCode }); + return response.data; + } catch (error) { + throw error; + } +} + +export async function completePasswordReset(username: string, tempToken: string, newPassword: string): Promise { + try { + const response = await authApi.post('/complete-reset', { username, tempToken, newPassword }); + return response.data; + } catch (error) { + throw error; + } +} + +export async function getOIDCAuthorizeUrl(): Promise { + try { + const response = await authApi.get('/oidc/authorize'); + return response.data; + } catch (error) { + throw error; + } +} + +export {sshHostApi, tunnelApi, fileManagerApi, authApi}; \ No newline at end of file -- 2.49.1 From 23e72aedfd6b81a795ee835793482d337a202dbd Mon Sep 17 00:00:00 2001 From: LukeGus Date: Sun, 24 Aug 2025 00:59:39 -0500 Subject: [PATCH 2/7] Migrate to new websocket link for locahlost --- src/ui/apps/Terminal/TerminalComponent.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ui/apps/Terminal/TerminalComponent.tsx b/src/ui/apps/Terminal/TerminalComponent.tsx index d77ac606..322afa41 100644 --- a/src/ui/apps/Terminal/TerminalComponent.tsx +++ b/src/ui/apps/Terminal/TerminalComponent.tsx @@ -226,7 +226,9 @@ export const TerminalComponent = forwardRef(function SSHT const cols = terminal.cols; const rows = terminal.rows; - const wsUrl = window.location.hostname === 'localhost' ? 'ws://localhost:8082' : `${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${window.location.host}/ssh/websocket/`; + const wsUrl = import.meta.env.DEV + ? 'ws://localhost:8082' + : `${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${window.location.host}/ssh/websocket/`; const ws = new WebSocket(wsUrl); webSocketRef.current = ws; -- 2.49.1 From 94f69cee3f1f001f6ea091a5c4a860c1a193a0ef Mon Sep 17 00:00:00 2001 From: LukeGus Date: Sun, 24 Aug 2025 01:10:59 -0500 Subject: [PATCH 3/7] Migrate to new websocket link for locahlost --- src/backend/database/routes/users.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/database/routes/users.ts b/src/backend/database/routes/users.ts index 790ac7be..aca004ab 100644 --- a/src/backend/database/routes/users.ts +++ b/src/backend/database/routes/users.ts @@ -79,7 +79,7 @@ async function verifyOIDCToken(idToken: string, issuerUrl: string, clientId: str const key = await importJWK(publicKey); const {payload} = await jwtVerify(idToken, key, { - issuer: issuerUrl, + issuer: [issuerUrl, issuerUrl.replace(/\/application\/o\/[^\/]+$/, '')], audience: clientId, }); -- 2.49.1 From cef420d1d8d7c74595f2f48db370cf753b0d7fd0 Mon Sep 17 00:00:00 2001 From: LukeGus Date: Sun, 24 Aug 2025 01:27:41 -0500 Subject: [PATCH 4/7] Clean up main-axios.ts --- src/ui/main-axios.ts | 390 ++++++++++++++++++++++++------------------- 1 file changed, 218 insertions(+), 172 deletions(-) diff --git a/src/ui/main-axios.ts b/src/ui/main-axios.ts index 771cb493..4c3a5c99 100644 --- a/src/ui/main-axios.ts +++ b/src/ui/main-axios.ts @@ -1,4 +1,8 @@ -import axios from 'axios'; +import axios, { AxiosError, AxiosInstance } from 'axios'; + +// ============================================================================ +// TYPES & INTERFACES +// ============================================================================ interface SSHHostData { name?: string; @@ -93,15 +97,41 @@ interface FileManagerShortcut { path: string; } +interface FileManagerOperation { + name: string; + path: string; + isSSH: boolean; + sshSessionId?: string; + hostId: number; +} + export type ServerStatus = { status: 'online' | 'offline'; lastChecked: string; }; +interface CpuMetrics { + percent: number | null; + cores: number | null; + load: [number, number, number] | null; +} + +interface MemoryMetrics { + percent: number | null; + usedGiB: number | null; + totalGiB: number | null; +} + +interface DiskMetrics { + percent: number | null; + usedHuman: string | null; + totalHuman: string | null; +} + export type ServerMetrics = { - cpu: { percent: number | null; cores: number | null; load: [number, number, number] | null }; - memory: { percent: number | null; usedGiB: number | null; totalGiB: number | null }; - disk: { percent: number | null; usedHuman: string | null; totalHuman: string | null }; + cpu: CpuMetrics; + memory: MemoryMetrics; + disk: DiskMetrics; lastChecked: string; }; @@ -115,38 +145,19 @@ interface UserInfo { is_admin: boolean; } -interface RegistrationResponse { - allowed: boolean; -} - -interface OIDCConfig { - configured: boolean; -} - interface UserCount { count: number; } -interface PasswordResetInitiate { - username: string; -} - -interface PasswordResetVerify { - username: string; - resetCode: string; -} - -interface PasswordResetComplete { - username: string; - tempToken: string; - newPassword: string; -} - interface OIDCAuthorize { auth_url: string; } -function setCookie(name: string, value: string, days = 7) { +// ============================================================================ +// UTILITY FUNCTIONS +// ============================================================================ + +function setCookie(name: string, value: string, days = 7): void { const expires = new Date(Date.now() + days * 864e5).toUTCString(); document.cookie = `${name}=${encodeURIComponent(value)}; expires=${expires}; path=/`; } @@ -157,57 +168,118 @@ function getCookie(name: string): string | undefined { if (parts.length === 2) return parts.pop()?.split(';').shift(); } -const sshHostApi = axios.create({ - baseURL: import.meta.env.DEV ? 'http://localhost:8081/ssh' : '/ssh', - headers: { - 'Content-Type': 'application/json', - }, -}); +function createApiInstance(baseURL: string): AxiosInstance { + const instance = axios.create({ + baseURL, + headers: { 'Content-Type': 'application/json' }, + timeout: 30000, + }); -const tunnelApi = axios.create({ - baseURL: import.meta.env.DEV ? 'http://localhost:8083/ssh' : '/ssh', - headers: { - 'Content-Type': 'application/json', - }, -}); - -const fileManagerApi = axios.create({ - baseURL: import.meta.env.DEV ? 'http://localhost:8084/ssh' : '/ssh', - headers: { - 'Content-Type': 'application/json', - } -}); - -const statsApi = axios.create({ - baseURL: import.meta.env.DEV ? 'http://localhost:8085' : '', - headers: { - 'Content-Type': 'application/json', - } -}); - -const authApi = axios.create({ - baseURL: import.meta.env.DEV ? 'http://localhost:8081/users' : '/users', - headers: { - 'Content-Type': 'application/json', - } -}); - -[sshHostApi, tunnelApi, fileManagerApi, statsApi, authApi].forEach(api => { - api.interceptors.request.use((config) => { + // Add JWT token to all requests + instance.interceptors.request.use((config) => { const token = getCookie('jwt'); if (token) { config.headers.Authorization = `Bearer ${token}`; } return config; }); -}); + + // Global error handling + instance.interceptors.response.use( + (response) => response, + (error: AxiosError) => { + if (error.response?.status === 401) { + // Token expired or invalid - clear cookie + document.cookie = 'jwt=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'; + } + return Promise.reject(error); + } + ); + + return instance; +} + +// ============================================================================ +// API INSTANCES +// ============================================================================ + +const isDev = process.env.NODE_ENV === 'development' || window.location.hostname === 'localhost'; + +// SSH Host Management API (port 8081) +export const sshHostApi = createApiInstance( + isDev ? 'http://localhost:8081/ssh' : '/ssh' +); + +// Tunnel Management API (port 8083) +export const tunnelApi = createApiInstance( + isDev ? 'http://localhost:8083/ssh' : '/ssh' +); + +// File Manager Operations API (port 8084) - SSH file operations +export const fileManagerApi = createApiInstance( + isDev ? 'http://localhost:8084/ssh/file_manager' : '/ssh/file_manager' +); + +// Server Statistics API (port 8085) +export const statsApi = createApiInstance( + isDev ? 'http://localhost:8085' : '' +); + +// Authentication API (port 8081) +export const authApi = createApiInstance( + isDev ? 'http://localhost:8081/users' : '/users' +); + +// ============================================================================ +// ERROR HANDLING +// ============================================================================ + +class ApiError extends Error { + constructor( + message: string, + public status?: number, + public code?: string + ) { + super(message); + this.name = 'ApiError'; + } +} + +function handleApiError(error: unknown, operation: string): never { + if (axios.isAxiosError(error)) { + const status = error.response?.status; + const message = error.response?.data?.error || error.message; + + if (status === 401) { + throw new ApiError('Authentication required', 401); + } else if (status === 403) { + throw new ApiError('Access denied', 403); + } else if (status === 404) { + throw new ApiError('Resource not found', 404); + } else if (status && status >= 500) { + throw new ApiError('Server error occurred', status); + } else { + throw new ApiError(message || `Failed to ${operation}`, status); + } + } + + if (error instanceof ApiError) { + throw error; + } + + throw new ApiError(`Unexpected error during ${operation}: ${error instanceof Error ? error.message : 'Unknown error'}`); +} + +// ============================================================================ +// SSH HOST MANAGEMENT +// ============================================================================ export async function getSSHHosts(): Promise { try { const response = await sshHostApi.get('/db/host'); return response.data; } catch (error) { - throw error; + handleApiError(error, 'fetch SSH hosts'); } } @@ -245,23 +317,20 @@ export async function createSSHHost(hostData: SSHHostData): Promise { const formData = new FormData(); formData.append('key', hostData.key); - const dataWithoutFile = {...submitData}; + const dataWithoutFile = { ...submitData }; delete dataWithoutFile.key; formData.append('data', JSON.stringify(dataWithoutFile)); const response = await sshHostApi.post('/db/host', formData, { - headers: { - 'Content-Type': 'multipart/form-data', - }, + headers: { 'Content-Type': 'multipart/form-data' }, }); - return response.data; } else { const response = await sshHostApi.post('/db/host', submitData); return response.data; } } catch (error) { - throw error; + handleApiError(error, 'create SSH host'); } } @@ -298,23 +367,20 @@ export async function updateSSHHost(hostId: number, hostData: SSHHostData): Prom const formData = new FormData(); formData.append('key', hostData.key); - const dataWithoutFile = {...submitData}; + const dataWithoutFile = { ...submitData }; delete dataWithoutFile.key; formData.append('data', JSON.stringify(dataWithoutFile)); const response = await sshHostApi.put(`/db/host/${hostId}`, formData, { - headers: { - 'Content-Type': 'multipart/form-data', - }, + headers: { 'Content-Type': 'multipart/form-data' }, }); - return response.data; } else { const response = await sshHostApi.put(`/db/host/${hostId}`, submitData); return response.data; } } catch (error) { - throw error; + handleApiError(error, 'update SSH host'); } } @@ -325,10 +391,10 @@ export async function bulkImportSSHHosts(hosts: SSHHostData[]): Promise<{ errors: string[]; }> { try { - const response = await sshHostApi.post('/bulk-import', {hosts}); + const response = await sshHostApi.post('/bulk-import', { hosts }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'bulk import SSH hosts'); } } @@ -337,7 +403,7 @@ export async function deleteSSHHost(hostId: number): Promise { const response = await sshHostApi.delete(`/db/host/${hostId}`); return response.data; } catch (error) { - throw error; + handleApiError(error, 'delete SSH host'); } } @@ -346,16 +412,20 @@ export async function getSSHHostById(hostId: number): Promise { const response = await sshHostApi.get(`/db/host/${hostId}`); return response.data; } catch (error) { - throw error; + handleApiError(error, 'fetch SSH host'); } } +// ============================================================================ +// TUNNEL MANAGEMENT +// ============================================================================ + export async function getTunnelStatuses(): Promise> { try { const response = await tunnelApi.get('/tunnel/status'); return response.data || {}; } catch (error) { - throw error; + handleApiError(error, 'fetch tunnel statuses'); } } @@ -369,64 +439,57 @@ export async function connectTunnel(tunnelConfig: TunnelConfig): Promise { const response = await tunnelApi.post('/tunnel/connect', tunnelConfig); return response.data; } catch (error) { - throw error; + handleApiError(error, 'connect tunnel'); } } export async function disconnectTunnel(tunnelName: string): Promise { try { - const response = await tunnelApi.post('/tunnel/disconnect', {tunnelName}); + const response = await tunnelApi.post('/tunnel/disconnect', { tunnelName }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'disconnect tunnel'); } } export async function cancelTunnel(tunnelName: string): Promise { try { - const response = await tunnelApi.post('/tunnel/cancel', {tunnelName}); + const response = await tunnelApi.post('/tunnel/cancel', { tunnelName }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'cancel tunnel'); } } +// ============================================================================ +// FILE MANAGER METADATA (Recent, Pinned, Shortcuts) +// ============================================================================ + export async function getFileManagerRecent(hostId: number): Promise { try { const response = await sshHostApi.get(`/file_manager/recent?hostId=${hostId}`); return response.data || []; } catch (error) { + // Don't throw for file manager metadata - return empty array return []; } } -export async function addFileManagerRecent(file: { - name: string; - path: string; - isSSH: boolean; - sshSessionId?: string; - hostId: number -}): Promise { +export async function addFileManagerRecent(file: FileManagerOperation): Promise { try { const response = await sshHostApi.post('/file_manager/recent', file); return response.data; } catch (error) { - throw error; + handleApiError(error, 'add recent file'); } } -export async function removeFileManagerRecent(file: { - name: string; - path: string; - isSSH: boolean; - sshSessionId?: string; - hostId: number -}): Promise { +export async function removeFileManagerRecent(file: FileManagerOperation): Promise { try { - const response = await sshHostApi.delete('/file_manager/recent', {data: file}); + const response = await sshHostApi.delete('/file_manager/recent', { data: file }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'remove recent file'); } } @@ -439,33 +502,21 @@ export async function getFileManagerPinned(hostId: number): Promise { +export async function addFileManagerPinned(file: FileManagerOperation): Promise { try { const response = await sshHostApi.post('/file_manager/pinned', file); return response.data; } catch (error) { - throw error; + handleApiError(error, 'add pinned file'); } } -export async function removeFileManagerPinned(file: { - name: string; - path: string; - isSSH: boolean; - sshSessionId?: string; - hostId: number -}): Promise { +export async function removeFileManagerPinned(file: FileManagerOperation): Promise { try { - const response = await sshHostApi.delete('/file_manager/pinned', {data: file}); + const response = await sshHostApi.delete('/file_manager/pinned', { data: file }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'remove pinned file'); } } @@ -478,36 +529,28 @@ export async function getFileManagerShortcuts(hostId: number): Promise { +export async function addFileManagerShortcut(shortcut: FileManagerOperation): Promise { try { const response = await sshHostApi.post('/file_manager/shortcuts', shortcut); return response.data; } catch (error) { - throw error; + handleApiError(error, 'add shortcut'); } } -export async function removeFileManagerShortcut(shortcut: { - name: string; - path: string; - isSSH: boolean; - sshSessionId?: string; - hostId: number -}): Promise { +export async function removeFileManagerShortcut(shortcut: FileManagerOperation): Promise { try { - const response = await sshHostApi.delete('/file_manager/shortcuts', {data: shortcut}); + const response = await sshHostApi.delete('/file_manager/shortcuts', { data: shortcut }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'remove shortcut'); } } +// ============================================================================ +// SSH FILE OPERATIONS +// ============================================================================ + export async function connectSSH(sessionId: string, config: { ip: string; port: number; @@ -523,49 +566,49 @@ export async function connectSSH(sessionId: string, config: { }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'connect SSH'); } } export async function disconnectSSH(sessionId: string): Promise { try { - const response = await fileManagerApi.post('/ssh/disconnect', {sessionId}); + const response = await fileManagerApi.post('/ssh/disconnect', { sessionId }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'disconnect SSH'); } } export async function getSSHStatus(sessionId: string): Promise<{ connected: boolean }> { try { const response = await fileManagerApi.get('/ssh/status', { - params: {sessionId} + params: { sessionId } }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'get SSH status'); } } export async function listSSHFiles(sessionId: string, path: string): Promise { try { const response = await fileManagerApi.get('/ssh/listFiles', { - params: {sessionId, path} + params: { sessionId, path } }); return response.data || []; } catch (error) { - throw error; + handleApiError(error, 'list SSH files'); } } export async function readSSHFile(sessionId: string, path: string): Promise<{ content: string; path: string }> { try { const response = await fileManagerApi.get('/ssh/readFile', { - params: {sessionId, path} + params: { sessionId, path } }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'read SSH file'); } } @@ -583,7 +626,7 @@ export async function writeSSHFile(sessionId: string, path: string, content: str throw new Error('File write operation did not return success status'); } } catch (error) { - throw error; + handleApiError(error, 'write SSH file'); } } @@ -597,7 +640,7 @@ export async function uploadSSHFile(sessionId: string, path: string, fileName: s }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'upload SSH file'); } } @@ -611,7 +654,7 @@ export async function createSSHFile(sessionId: string, path: string, fileName: s }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'create SSH file'); } } @@ -624,7 +667,7 @@ export async function createSSHFolder(sessionId: string, path: string, folderNam }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'create SSH folder'); } } @@ -639,7 +682,7 @@ export async function deleteSSHItem(sessionId: string, path: string, isDirectory }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'delete SSH item'); } } @@ -652,18 +695,20 @@ export async function renameSSHItem(sessionId: string, oldPath: string, newName: }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'rename SSH item'); } } - +// ============================================================================ +// SERVER STATISTICS +// ============================================================================ export async function getAllServerStatuses(): Promise> { try { const response = await statsApi.get('/status'); return response.data || {}; } catch (error) { - throw error; + handleApiError(error, 'fetch server statuses'); } } @@ -672,7 +717,7 @@ export async function getServerStatusById(id: number): Promise { const response = await statsApi.get(`/status/${id}`); return response.data; } catch (error) { - throw error; + handleApiError(error, 'fetch server status'); } } @@ -681,17 +726,20 @@ export async function getServerMetricsById(id: number): Promise { const response = await statsApi.get(`/metrics/${id}`); return response.data; } catch (error) { - throw error; + handleApiError(error, 'fetch server metrics'); } } -// Auth-related functions +// ============================================================================ +// AUTHENTICATION +// ============================================================================ + export async function registerUser(username: string, password: string): Promise { try { const response = await authApi.post('/create', { username, password }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'register user'); } } @@ -700,7 +748,7 @@ export async function loginUser(username: string, password: string): Promise { const response = await authApi.get('/me'); return response.data; } catch (error) { - throw error; + handleApiError(error, 'fetch user info'); } } @@ -718,7 +766,7 @@ export async function getRegistrationAllowed(): Promise<{ allowed: boolean }> { const response = await authApi.get('/registration-allowed'); return response.data; } catch (error) { - throw error; + handleApiError(error, 'check registration status'); } } @@ -727,7 +775,7 @@ export async function getOIDCConfig(): Promise { const response = await authApi.get('/oidc-config'); return response.data; } catch (error) { - throw error; + handleApiError(error, 'fetch OIDC config'); } } @@ -736,7 +784,7 @@ export async function getUserCount(): Promise { const response = await authApi.get('/count'); return response.data; } catch (error) { - throw error; + handleApiError(error, 'fetch user count'); } } @@ -745,7 +793,7 @@ export async function initiatePasswordReset(username: string): Promise { const response = await authApi.post('/initiate-reset', { username }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'initiate password reset'); } } @@ -754,7 +802,7 @@ export async function verifyPasswordResetCode(username: string, resetCode: strin const response = await authApi.post('/verify-reset-code', { username, resetCode }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'verify reset code'); } } @@ -763,7 +811,7 @@ export async function completePasswordReset(username: string, tempToken: string, const response = await authApi.post('/complete-reset', { username, tempToken, newPassword }); return response.data; } catch (error) { - throw error; + handleApiError(error, 'complete password reset'); } } @@ -772,8 +820,6 @@ export async function getOIDCAuthorizeUrl(): Promise { const response = await authApi.get('/oidc/authorize'); return response.data; } catch (error) { - throw error; + handleApiError(error, 'get OIDC authorize URL'); } -} - -export {sshHostApi, tunnelApi, fileManagerApi, authApi}; \ No newline at end of file +} \ No newline at end of file -- 2.49.1 From f2fb938e5f3781c1bed3723837c36ddedb197b83 Mon Sep 17 00:00:00 2001 From: LukeGus Date: Sun, 24 Aug 2025 01:28:18 -0500 Subject: [PATCH 5/7] Clean up main-axios.ts --- src/ui/main-axios.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ui/main-axios.ts b/src/ui/main-axios.ts index 4c3a5c99..85766006 100644 --- a/src/ui/main-axios.ts +++ b/src/ui/main-axios.ts @@ -175,7 +175,6 @@ function createApiInstance(baseURL: string): AxiosInstance { timeout: 30000, }); - // Add JWT token to all requests instance.interceptors.request.use((config) => { const token = getCookie('jwt'); if (token) { @@ -184,7 +183,6 @@ function createApiInstance(baseURL: string): AxiosInstance { return config; }); - // Global error handling instance.interceptors.response.use( (response) => response, (error: AxiosError) => { -- 2.49.1 From 5fbac89e67ad1f262bdc111ddf591a18c29c4453 Mon Sep 17 00:00:00 2001 From: Karmaa <88517757+LukeGus@users.noreply.github.com> Date: Sun, 24 Aug 2025 15:39:53 -0500 Subject: [PATCH 6/7] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index f57d712e..b36e2762 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,12 @@ If you would like, you can support the project here!\ [![GitHub Sponsor](https://img.shields.io/badge/Sponsor-LukeGus-181717?style=for-the-badge&logo=github&logoColor=white)](https://github.com/sponsors/LukeGus) # Overview + +

+ + Termix Banner +

+ Termix is an open-source, forever-free, self-hosted all-in-one server management platform. It provides a web-based solution for managing your servers and infrastructure through a single, intuitive interface. Termix offers SSH terminal access, SSH tunneling capabilities, and remote file editing, with many more tools to come. # Features -- 2.49.1 From 6e175e2b3615a033830445558f3d32ab2faafb90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 24 Aug 2025 21:14:55 +0000 Subject: [PATCH 7/7] Bump @vitejs/plugin-react-swc from 3.10.2 to 4.0.1 Bumps [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/tree/HEAD/packages/plugin-react-swc) from 3.10.2 to 4.0.1. - [Release notes](https://github.com/vitejs/vite-plugin-react/releases) - [Changelog](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite-plugin-react/commits/plugin-react@4.0.1/packages/plugin-react-swc) --- updated-dependencies: - dependency-name: "@vitejs/plugin-react-swc" dependency-version: 4.0.1 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package-lock.json | 171 ++++++++++++++++++++++++++++++---------------- package.json | 2 +- 2 files changed, 115 insertions(+), 58 deletions(-) diff --git a/package-lock.json b/package-lock.json index dc2db2ae..5ea143ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -82,7 +82,7 @@ "@types/react-dom": "^19.1.6", "@types/ssh2": "^1.15.5", "@types/ws": "^8.18.1", - "@vitejs/plugin-react-swc": "^3.10.2", + "@vitejs/plugin-react-swc": "^4.0.1", "autoprefixer": "^10.4.21", "eslint": "^9.30.1", "eslint-plugin-react-hooks": "^5.2.0", @@ -2811,9 +2811,9 @@ } }, "node_modules/@rolldown/pluginutils": { - "version": "1.0.0-beta.11", - "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.11.tgz", - "integrity": "sha512-L/gAA/hyCSuzTF1ftlzUSI/IKr2POHsv1Dd78GfqkR83KMNuswWD61JxGV2L7nRwBBBSDr6R1gCkdTmoN7W4ag==", + "version": "1.0.0-beta.32", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.32.tgz", + "integrity": "sha512-QReCdvxiUZAPkvp1xpAg62IeNzykOFA6syH2CnClif4YmALN1XKpB39XneL80008UbtMShthSVDKmrx05N1q/g==", "dev": true, "license": "MIT" }, @@ -3084,15 +3084,15 @@ "license": "MIT" }, "node_modules/@swc/core": { - "version": "1.12.14", - "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.12.14.tgz", - "integrity": "sha512-CJSn2vstd17ddWIHBsjuD4OQnn9krQfaq6EO+w9YfId5DKznyPmzxAARlOXG99cC8/3Kli8ysKy6phL43bSr0w==", + "version": "1.13.5", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.13.5.tgz", + "integrity": "sha512-WezcBo8a0Dg2rnR82zhwoR6aRNxeTGfK5QCD6TQ+kg3xx/zNT02s/0o+81h/3zhvFSB24NtqEr8FTw88O5W/JQ==", "dev": true, "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { "@swc/counter": "^0.1.3", - "@swc/types": "^0.1.23" + "@swc/types": "^0.1.24" }, "engines": { "node": ">=10" @@ -3102,16 +3102,16 @@ "url": "https://opencollective.com/swc" }, "optionalDependencies": { - "@swc/core-darwin-arm64": "1.12.14", - "@swc/core-darwin-x64": "1.12.14", - "@swc/core-linux-arm-gnueabihf": "1.12.14", - "@swc/core-linux-arm64-gnu": "1.12.14", - "@swc/core-linux-arm64-musl": "1.12.14", - "@swc/core-linux-x64-gnu": "1.12.14", - "@swc/core-linux-x64-musl": "1.12.14", - "@swc/core-win32-arm64-msvc": "1.12.14", - "@swc/core-win32-ia32-msvc": "1.12.14", - "@swc/core-win32-x64-msvc": "1.12.14" + "@swc/core-darwin-arm64": "1.13.5", + "@swc/core-darwin-x64": "1.13.5", + "@swc/core-linux-arm-gnueabihf": "1.13.5", + "@swc/core-linux-arm64-gnu": "1.13.5", + "@swc/core-linux-arm64-musl": "1.13.5", + "@swc/core-linux-x64-gnu": "1.13.5", + "@swc/core-linux-x64-musl": "1.13.5", + "@swc/core-win32-arm64-msvc": "1.13.5", + "@swc/core-win32-ia32-msvc": "1.13.5", + "@swc/core-win32-x64-msvc": "1.13.5" }, "peerDependencies": { "@swc/helpers": ">=0.5.17" @@ -3123,9 +3123,9 @@ } }, "node_modules/@swc/core-darwin-arm64": { - "version": "1.12.14", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.12.14.tgz", - "integrity": "sha512-HNukQoOKgMsHSETj8vgGGKK3SEcH7Cz6k4bpntCxBKNkO3sH7RcBTDulWGGHJfZaDNix7Rw2ExUVWtLZlzkzXg==", + "version": "1.13.5", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.13.5.tgz", + "integrity": "sha512-lKNv7SujeXvKn16gvQqUQI5DdyY8v7xcoO3k06/FJbHJS90zEwZdQiMNRiqpYw/orU543tPaWgz7cIYWhbopiQ==", "cpu": [ "arm64" ], @@ -3140,9 +3140,9 @@ } }, "node_modules/@swc/core-darwin-x64": { - "version": "1.12.14", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.12.14.tgz", - "integrity": "sha512-4Ttf3Obtk3MvFrR0e04qr6HfXh4L1Z+K3dRej63TAFuYpo+cPXeOZdPUddAW73lSUGkj+61IHnGPoXD3OQYy4Q==", + "version": "1.13.5", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.13.5.tgz", + "integrity": "sha512-ILd38Fg/w23vHb0yVjlWvQBoE37ZJTdlLHa8LRCFDdX4WKfnVBiblsCU9ar4QTMNdeTBEX9iUF4IrbNWhaF1Ng==", "cpu": [ "x64" ], @@ -3157,9 +3157,9 @@ } }, "node_modules/@swc/core-linux-arm-gnueabihf": { - "version": "1.12.14", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.12.14.tgz", - "integrity": "sha512-zhJOH2KWjtQpzJ27Xjw/RKLVOa1aiEJC2b70xbCwEX6ZTVAl8tKbhkZ3GMphhfVmLJ9gf/2UQR58oxVnsXqX5Q==", + "version": "1.13.5", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.13.5.tgz", + "integrity": "sha512-Q6eS3Pt8GLkXxqz9TAw+AUk9HpVJt8Uzm54MvPsqp2yuGmY0/sNaPPNVqctCX9fu/Nu8eaWUen0si6iEiCsazQ==", "cpu": [ "arm" ], @@ -3174,9 +3174,9 @@ } }, "node_modules/@swc/core-linux-arm64-gnu": { - "version": "1.12.14", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.12.14.tgz", - "integrity": "sha512-akUAe1YrBqZf1EDdUxahQ8QZnJi8Ts6Ya0jf6GBIMvnXL4Y6QIuvKTRwfNxy7rJ+x9zpzP1Vlh14ZZkSKZ1EGA==", + "version": "1.13.5", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.13.5.tgz", + "integrity": "sha512-aNDfeN+9af+y+M2MYfxCzCy/VDq7Z5YIbMqRI739o8Ganz6ST+27kjQFd8Y/57JN/hcnUEa9xqdS3XY7WaVtSw==", "cpu": [ "arm64" ], @@ -3191,9 +3191,9 @@ } }, "node_modules/@swc/core-linux-arm64-musl": { - "version": "1.12.14", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.12.14.tgz", - "integrity": "sha512-ZkOOIpSMXuPAjfOXEIAEQcrPOgLi6CaXvA5W+GYnpIpFG21Nd0qb0WbwFRv4K8BRtl993Q21v0gPpOaFHU+wdA==", + "version": "1.13.5", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.13.5.tgz", + "integrity": "sha512-9+ZxFN5GJag4CnYnq6apKTnnezpfJhCumyz0504/JbHLo+Ue+ZtJnf3RhyA9W9TINtLE0bC4hKpWi8ZKoETyOQ==", "cpu": [ "arm64" ], @@ -3208,9 +3208,9 @@ } }, "node_modules/@swc/core-linux-x64-gnu": { - "version": "1.12.14", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.12.14.tgz", - "integrity": "sha512-71EPPccwJiJUxd2aMwNlTfom2mqWEWYGdbeTju01tzSHsEuD7E6ePlgC3P3ngBqB3urj41qKs87z7zPOswT5Iw==", + "version": "1.13.5", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.13.5.tgz", + "integrity": "sha512-WD530qvHrki8Ywt/PloKUjaRKgstQqNGvmZl54g06kA+hqtSE2FTG9gngXr3UJxYu/cNAjJYiBifm7+w4nbHbA==", "cpu": [ "x64" ], @@ -3225,9 +3225,9 @@ } }, "node_modules/@swc/core-linux-x64-musl": { - "version": "1.12.14", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.12.14.tgz", - "integrity": "sha512-nImF1hZJqKTcl0WWjHqlelOhvuB9rU9kHIw/CmISBUZXogjLIvGyop1TtJNz0ULcz2Oxr3Q2YpwfrzsgvgbGkA==", + "version": "1.13.5", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.13.5.tgz", + "integrity": "sha512-Luj8y4OFYx4DHNQTWjdIuKTq2f5k6uSXICqx+FSabnXptaOBAbJHNbHT/06JZh6NRUouaf0mYXN0mcsqvkhd7Q==", "cpu": [ "x64" ], @@ -3242,9 +3242,9 @@ } }, "node_modules/@swc/core-win32-arm64-msvc": { - "version": "1.12.14", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.12.14.tgz", - "integrity": "sha512-sABFQFxSuStFoxvEWZUHWYldtB1B4A9eDNFd4Ty50q7cemxp7uoscFoaCqfXSGNBwwBwpS5EiPB6YN4y6hqmLQ==", + "version": "1.13.5", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.13.5.tgz", + "integrity": "sha512-cZ6UpumhF9SDJvv4DA2fo9WIzlNFuKSkZpZmPG1c+4PFSEMy5DFOjBSllCvnqihCabzXzpn6ykCwBmHpy31vQw==", "cpu": [ "arm64" ], @@ -3259,9 +3259,9 @@ } }, "node_modules/@swc/core-win32-ia32-msvc": { - "version": "1.12.14", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.12.14.tgz", - "integrity": "sha512-KBznRB02NASkpepRdWIK4f1AvmaJCDipKWdW1M1xV9QL2tE4aySJFojVuG1+t0tVDkjRfwcZjycQfRoJ4RjD7Q==", + "version": "1.13.5", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.13.5.tgz", + "integrity": "sha512-C5Yi/xIikrFUzZcyGj9L3RpKljFvKiDMtyDzPKzlsDrKIw2EYY+bF88gB6oGY5RGmv4DAX8dbnpRAqgFD0FMEw==", "cpu": [ "ia32" ], @@ -3276,9 +3276,9 @@ } }, "node_modules/@swc/core-win32-x64-msvc": { - "version": "1.12.14", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.12.14.tgz", - "integrity": "sha512-SymoP2CJHzrYaFKjWvuQljcF7BkTpzaS1vpywv7K9EzdTb5N8qPDvNd+PhWUqBz9JHBhbJxpaeTDQBXF/WWPmw==", + "version": "1.13.5", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.13.5.tgz", + "integrity": "sha512-YrKdMVxbYmlfybCSbRtrilc6UA8GF5aPmGKBdPvjrarvsmf4i7ZHGCEnLtfOMd3Lwbs2WUZq3WdMbozYeLU93Q==", "cpu": [ "x64" ], @@ -3300,9 +3300,9 @@ "license": "Apache-2.0" }, "node_modules/@swc/types": { - "version": "0.1.23", - "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.23.tgz", - "integrity": "sha512-u1iIVZV9Q0jxY+yM2vw/hZGDNudsN85bBpTqzAQ9rzkxW9D+e3aEM4Han+ow518gSewkXgjmEK0BD79ZcNVgPw==", + "version": "0.1.24", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.24.tgz", + "integrity": "sha512-tjTMh3V4vAORHtdTprLlfoMptu1WfTZG9Rsca6yOKyNYsRr+MUXutKmliB17orgSZk5DpnDxs8GUdd/qwYxOng==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -3525,6 +3525,60 @@ "node": ">=14.0.0" } }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/core": { + "version": "1.4.3", + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.0.2", + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/runtime": { + "version": "1.4.3", + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/wasi-threads": { + "version": "1.0.2", + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@napi-rs/wasm-runtime": { + "version": "0.2.11", + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "^1.4.3", + "@emnapi/runtime": "^1.4.3", + "@tybys/wasm-util": "^0.9.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@tybys/wasm-util": { + "version": "0.9.0", + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/tslib": { + "version": "2.8.0", + "inBundle": true, + "license": "0BSD", + "optional": true + }, "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.1.11.tgz", @@ -4204,17 +4258,20 @@ } }, "node_modules/@vitejs/plugin-react-swc": { - "version": "3.10.2", - "resolved": "https://registry.npmjs.org/@vitejs/plugin-react-swc/-/plugin-react-swc-3.10.2.tgz", - "integrity": "sha512-xD3Rdvrt5LgANug7WekBn1KhcvLn1H3jNBfJRL3reeOIua/WnZOEV5qi5qIBq5T8R0jUDmRtxuvk4bPhzGHDWw==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react-swc/-/plugin-react-swc-4.0.1.tgz", + "integrity": "sha512-NQhPjysi5duItyrMd5JWZFf2vNOuSMyw+EoZyTBDzk+DkfYD8WNrsUs09sELV2cr1P15nufsN25hsUBt4CKF9Q==", "dev": true, "license": "MIT", "dependencies": { - "@rolldown/pluginutils": "1.0.0-beta.11", - "@swc/core": "^1.11.31" + "@rolldown/pluginutils": "1.0.0-beta.32", + "@swc/core": "^1.13.2" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" }, "peerDependencies": { - "vite": "^4 || ^5 || ^6 || ^7.0.0-beta.0" + "vite": "^4 || ^5 || ^6 || ^7" } }, "node_modules/@xterm/addon-attach": { diff --git a/package.json b/package.json index e53653c2..eec23c0c 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,7 @@ "@types/react-dom": "^19.1.6", "@types/ssh2": "^1.15.5", "@types/ws": "^8.18.1", - "@vitejs/plugin-react-swc": "^3.10.2", + "@vitejs/plugin-react-swc": "^4.0.1", "autoprefixer": "^10.4.21", "eslint": "^9.30.1", "eslint-plugin-react-hooks": "^5.2.0", -- 2.49.1