AUXteam commited on
Commit
6df60a2
·
verified ·
1 Parent(s): ce0ea5d

Upload folder using huggingface_hub

Browse files
components/ChatPage.tsx CHANGED
@@ -1,6 +1,6 @@
1
 
2
  import React, { useState, useRef, useEffect } from 'react';
3
- import { X, ClipboardList, Linkedin, Instagram, Mail, Layout, Edit3, MonitorPlay, Lightbulb, Image, Plus, Sparkles, Zap, AlertCircle, Video, Megaphone, Link as LinkIcon, Loader2, RefreshCw, CheckCircle2, MessageSquare } from 'lucide-react';
4
  import { GradioService } from '../services/gradioService';
5
 
6
  // --- Types ---
@@ -292,9 +292,7 @@ const ChatPage: React.FC<ChatPageProps> = ({ onBack, simulationResult, setSimula
292
  {showNotification && (
293
  <div className="absolute top-24 left-1/2 -translate-x-1/2 z-50 w-[90%] max-w-lg animate-in slide-in-from-top-4 fade-in duration-500">
294
  <div className="bg-[#0f1f15] backdrop-blur-xl border border-green-500/20 text-green-100 px-6 py-5 rounded-2xl shadow-2xl flex items-start gap-4 ring-1 ring-green-500/10">
295
- <div className="p-1.5 bg-green-500/20 rounded-full mt-0.5 shrink-0">
296
- <AlertCircle size={18} className="text-green-400" />
297
- </div>
298
  <div className="flex-1">
299
  <h4 className="font-semibold text-green-300 mb-1">Simulation Status</h4>
300
  <p className="text-sm text-green-200/70 leading-relaxed">
 
1
 
2
  import React, { useState, useRef, useEffect } from 'react';
3
+ import { X, ClipboardList, Linkedin, Instagram, Mail, Layout, Edit3, MonitorPlay, Lightbulb, Image, Plus, Sparkles, Zap, Video, Megaphone, Link as LinkIcon, Loader2, RefreshCw, CheckCircle2, MessageSquare } from 'lucide-react';
4
  import { GradioService } from '../services/gradioService';
5
 
6
  // --- Types ---
 
292
  {showNotification && (
293
  <div className="absolute top-24 left-1/2 -translate-x-1/2 z-50 w-[90%] max-w-lg animate-in slide-in-from-top-4 fade-in duration-500">
294
  <div className="bg-[#0f1f15] backdrop-blur-xl border border-green-500/20 text-green-100 px-6 py-5 rounded-2xl shadow-2xl flex items-start gap-4 ring-1 ring-green-500/10">
295
+ {/* Eliminated service alert signal */}
 
 
296
  <div className="flex-1">
297
  <h4 className="font-semibold text-green-300 mb-1">Simulation Status</h4>
298
  <p className="text-sm text-green-200/70 leading-relaxed">
components/SimulationPage.tsx CHANGED
@@ -1,5 +1,5 @@
1
  import React, { useState, useEffect } from 'react';
2
- import { ChevronDown, Plus, Info, MessageSquare, BookOpen, LogOut, PanelLeftClose, MessageCircle, AlertTriangle, Menu, PanelRightClose, RefreshCw } from 'lucide-react';
3
  import SimulationGraph from './SimulationGraph';
4
  import { GradioService } from '../services/gradioService';
5
 
@@ -79,7 +79,7 @@ const SimulationPage: React.FC<SimulationPageProps> = ({
79
  if (typeof s === 'object' && s !== null) return s.id || s.name || '';
80
  return '';
81
  })
82
- .filter(name => name.length > 0 && !name.toLowerCase().includes('default') && !name.toLowerCase().includes('template'));
83
 
84
  setSocieties(names);
85
  if (names.length > 0 && (!society || !names.includes(society))) {
 
1
  import React, { useState, useEffect } from 'react';
2
+ import { ChevronDown, Plus, Info, MessageSquare, BookOpen, LogOut, PanelLeftClose, MessageCircle, Menu, PanelRightClose, RefreshCw } from 'lucide-react';
3
  import SimulationGraph from './SimulationGraph';
4
  import { GradioService } from '../services/gradioService';
5
 
 
79
  if (typeof s === 'object' && s !== null) return s.id || s.name || '';
80
  return '';
81
  })
82
+ .filter(name => name.length > 0 && !name.toLowerCase().includes('default') && !name.toLowerCase().includes('template') && !name.toLowerCase().includes('current'));
83
 
84
  setSocieties(names);
85
  if (names.length > 0 && (!society || !names.includes(society))) {
server.cjs CHANGED
@@ -1,6 +1,7 @@
1
  const express = require('express');
2
  const path = require('path');
3
  const cookieParser = require('cookie-parser');
 
4
  const app = express();
5
  const port = 7860;
6
 
@@ -71,18 +72,28 @@ app.get('/login', (req, res) => {
71
  return res.status(500).json({ error: "OAuth is not configured (missing OAUTH_CLIENT_ID)" });
72
  }
73
 
 
 
 
74
  const authUrl = `${OPENID_PROVIDER_URL}/oauth/authorize` +
75
  `?client_id=${OAUTH_CLIENT_ID}` +
76
- `?redirect_uri=${encodeURIComponent(REDIRECT_URI)}` +
77
- `?scope=${encodeURIComponent(OAUTH_SCOPES)}` +
78
- `?response_type=code` +
79
- `?state=secure_random_state_string`;
80
 
81
  res.redirect(authUrl);
82
  });
83
 
84
  app.get('/oauth/callback', async (req, res) => {
85
- const { code } = req.query;
 
 
 
 
 
 
 
86
  const tokenUrl = `${OPENID_PROVIDER_URL}/oauth/token`;
87
 
88
  const authStr = Buffer.from(`${OAUTH_CLIENT_ID}:${OAUTH_CLIENT_SECRET}`).toString('base64');
 
1
  const express = require('express');
2
  const path = require('path');
3
  const cookieParser = require('cookie-parser');
4
+ const crypto = require('crypto');
5
  const app = express();
6
  const port = 7860;
7
 
 
72
  return res.status(500).json({ error: "OAuth is not configured (missing OAUTH_CLIENT_ID)" });
73
  }
74
 
75
+ const state = crypto.randomBytes(16).toString('hex');
76
+ res.cookie('oauth_state', state, { httpOnly: true, maxAge: 600000 }); // 10 mins
77
+
78
  const authUrl = `${OPENID_PROVIDER_URL}/oauth/authorize` +
79
  `?client_id=${OAUTH_CLIENT_ID}` +
80
+ `&redirect_uri=${encodeURIComponent(REDIRECT_URI)}` +
81
+ `&scope=${encodeURIComponent(OAUTH_SCOPES)}` +
82
+ `&response_type=code` +
83
+ `&state=${state}`;
84
 
85
  res.redirect(authUrl);
86
  });
87
 
88
  app.get('/oauth/callback', async (req, res) => {
89
+ const { code, state } = req.query;
90
+ const savedState = req.cookies.oauth_state;
91
+
92
+ if (!state || state !== savedState) {
93
+ console.error("State mismatch:", { state, savedState });
94
+ return res.status(403).json({ error: "Invalid OAuth state" });
95
+ }
96
+ res.clearCookie('oauth_state');
97
  const tokenUrl = `${OPENID_PROVIDER_URL}/oauth/token`;
98
 
99
  const authStr = Buffer.from(`${OAUTH_CLIENT_ID}:${OAUTH_CLIENT_SECRET}`).toString('base64');