diff --git a/dashboard/dist/index.js b/dashboard/dist/index.js index 4f1ca9c..0cf1fd7 100644 --- a/dashboard/dist/index.js +++ b/dashboard/dist/index.js @@ -6,34 +6,11 @@ const { useState, useEffect, useCallback } = SDK.hooks; const { Card, CardHeader, CardTitle, CardContent, Button } = SDK.components; - // Use native fetch with session token header for remote dashboard - function getSessionToken() { - return window.__HERMES_SESSION_TOKEN__ || ""; - } - - async function apiFetch(path) { - const res = await fetch(path, { - credentials: "include", - headers: { "x-hermes-session-token": getSessionToken() } - }); - if (!res.ok) { - const text = await res.text(); - throw new Error("API error " + res.status + ": " + text.slice(0, 100)); - } - return res.json(); - } + const fetchJSON = SDK.fetchJSON; async function apiPost(path) { - const res = await fetch(path, { - method: "POST", - credentials: "include", - headers: { "x-hermes-session-token": getSessionToken() } - }); - if (!res.ok) { - const text = await res.text(); - throw new Error("API error " + res.status + ": " + text.slice(0, 100)); - } - return res.json(); + const res = await fetchJSON(path, { method: "POST" }); + return res; } function SSHXPage() { @@ -45,7 +22,7 @@ setStatus("loading"); setError(null); try { - const res = await apiFetch("/api/plugins/sshx-link/start"); + const res = await fetchJSON("/api/plugins/sshx-link/start"); if (res.link) { setLink(res.link); setStatus("running"); @@ -71,7 +48,7 @@ const checkStatus = useCallback(async function () { try { - const res = await apiFetch("/api/plugins/sshx-link/status"); + const res = await fetchJSON("/api/plugins/sshx-link/status"); if (res.status === "running" && res.link) { setLink(res.link); setStatus("running"); diff --git a/dashboard/plugin_api.py b/dashboard/plugin_api.py index d566366..2ded768 100644 --- a/dashboard/plugin_api.py +++ b/dashboard/plugin_api.py @@ -9,6 +9,7 @@ import subprocess import re import shutil import logging +from typing import Optional from fastapi import APIRouter from fastapi.responses import JSONResponse @@ -20,7 +21,7 @@ _sshx_process = None _sshx_link = None -def _find_link(text: str) -> str | None: +def _find_link(text: str) -> Optional[str]: """Extract sshx link from output.""" match = re.search(r"https://sshx\.io/s/[A-Za-z0-9_-]+", text) return match.group(0) if match else None