From 4fce681840b2456b53c54af4923e3fc58c210617 Mon Sep 17 00:00:00 2001 From: "juancarlos.cavero" Date: Sat, 20 Dec 2025 03:20:52 +0100 Subject: [PATCH] addded encryption --- dashboard/index.html | 2 +- dashboard/src/App.jsx | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/dashboard/index.html b/dashboard/index.html index aa2822a..47fc6b5 100644 --- a/dashboard/index.html +++ b/dashboard/index.html @@ -2,7 +2,7 @@ - + OpenShorts.app diff --git a/dashboard/src/App.jsx b/dashboard/src/App.jsx index ea13f50..522dce6 100644 --- a/dashboard/src/App.jsx +++ b/dashboard/src/App.jsx @@ -6,6 +6,25 @@ import ResultCard from './components/ResultCard'; import ProcessingAnimation from './components/ProcessingAnimation'; import { getApiUrl } from './config'; +// Simple helper for basic obfuscation (not secure encryption) +const encrypt = (text) => { + if (!text) return ''; + try { + return btoa(text); + } catch (e) { + return text; + } +}; + +const decrypt = (text) => { + if (!text) return ''; + try { + return atob(text); + } catch (e) { + return text; + } +}; + // Simple TikTok icon sine Lucide might not have it or it varies const TikTokIcon = ({ size = 16, className = "" }) => ( @@ -88,8 +107,14 @@ const pollJob = async (jobId) => { function App() { const [apiKey, setApiKey] = useState(localStorage.getItem('gemini_key') || ''); - // Social API State - const [uploadPostKey, setUploadPostKey] = useState(() => localStorage.getItem('uploadPostKey') || ''); + // Social API State - Load encrypted or plain + const [uploadPostKey, setUploadPostKey] = useState(() => { + const stored = localStorage.getItem('uploadPostKey_enc'); + if (stored) return decrypt(stored); + // Fallback to plain text for transition + return localStorage.getItem('uploadPostKey') || ''; + }); + const [uploadUserId, setUploadUserId] = useState(() => localStorage.getItem('uploadUserId') || ''); const [userProfiles, setUserProfiles] = useState([]); // List of {username, connected: []} const [jobId, setJobId] = useState(null); @@ -105,8 +130,14 @@ function App() { }, [apiKey]); useEffect(() => { - localStorage.setItem('uploadPostKey', uploadPostKey); - localStorage.setItem('uploadUserId', uploadUserId); + if (uploadPostKey) { + localStorage.setItem('uploadPostKey_enc', encrypt(uploadPostKey)); + // Remove old plain text key if exists + localStorage.removeItem('uploadPostKey'); + } + if (uploadUserId) { + localStorage.setItem('uploadUserId', uploadUserId); + } }, [uploadPostKey, uploadUserId]); useEffect(() => {