Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
228a417
feat: add core JavaScript modules for website functionality
d-ulker Sep 27, 2025
c741ed1
fix: address remaining Copilot AI review comments
d-ulker Sep 27, 2025
edcad3f
Merge branch 'main' into feat/website-js-core
d-ulker Sep 27, 2025
ed4352a
refactor: improve architecture and separation of concerns
d-ulker Sep 27, 2025
dd95d97
Merge branch 'feat/website-js-core' of github.com:uelkerd/SAMO--DL in…
d-ulker Sep 27, 2025
ffaa91a
perf: reduce artificial UI delay for better perceived performance
d-ulker Sep 27, 2025
4a50db1
refactor: improve code quality and error handling in layout manager
d-ulker Sep 27, 2025
c4d2fb5
refactor: improve configuration clarity and remove code duplication
d-ulker Sep 27, 2025
0f17160
refactor: implement dependency injection to improve architecture
d-ulker Sep 27, 2025
d7606af
security: fix critical OpenAI API key exposure vulnerability
d-ulker Sep 27, 2025
bb00036
refactor: complete dependency injection for resetToInitialState
d-ulker Sep 27, 2025
3d38b95
fix: CodeRabbit AI critical issues - null safety and progress step st…
d-ulker Sep 27, 2025
31e4192
test: Add comprehensive tests for LayoutManager null safety
d-ulker Sep 27, 2025
6361fbc
test: Add component tests for config and notification manager
d-ulker Sep 27, 2025
a2760e9
build: Add Vitest testing framework for website JavaScript
d-ulker Sep 27, 2025
42007fc
fix: CodeRabbit AI accessibility improvements - ARIA roles and semant…
d-ulker Sep 27, 2025
148210b
fix: CodeRabbit AI accessibility - improve warning toast contrast
d-ulker Sep 27, 2025
8cc9627
fix: CodeRabbit AI MediaRecorder accuracy - use actual MIME type for …
d-ulker Sep 27, 2025
107b4c0
fix: CodeRabbit AI MIME type parameters - strip codec info for extens…
d-ulker Sep 27, 2025
425a76f
fix: CodeRabbit AI config test merging - properly test server config …
d-ulker Sep 27, 2025
c10baa6
fix: CodeRabbit AI location mocking - properly test environment detec…
d-ulker Sep 27, 2025
ba635df
Fix test suite failures - resolve module loading conflicts, DOM manip…
d-ulker Sep 27, 2025
d56a154
Fix Vitest configuration - remove invalid fakeTimers boolean
d-ulker Sep 27, 2025
fc7f662
Fix voice recorder processing state UI - only hide processing when shown
d-ulker Sep 27, 2025
8e85d29
Add recording re-entrancy guard - prevent duplicate recording sessions
d-ulker Sep 27, 2025
729bd41
Add skipcq pragma for test data - silence false positive security war…
d-ulker Sep 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions website/comprehensive-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ <h5 class="fw-bold mb-3">SAMO Deep Learning</h5>
<!-- Configuration -->
<script src="js/config.js"></script>

<!-- Notification Manager -->
<script src="js/notification-manager.js"></script>

<script>
// API Configuration (Unified API)
// Load API configuration from config.js
Expand Down
162 changes: 138 additions & 24 deletions website/js/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// SAMO-DL API Configuration
// This file centralizes API endpoint configuration for the website
/**
* SAMO-DL API Configuration
* Centralized configuration for API endpoints and keys
* This file should be loaded before other JavaScript files
*/

window.SAMO_CONFIG = {
// API Configuration
API: {
// Base URL for the SAMO-DL API
// Replace with your actual deployment URL
Expand All @@ -15,18 +19,14 @@ window.SAMO_CONFIG = {

// API endpoints
ENDPOINTS: {
PREDICT: '/predict',
PREDICT_BATCH: '/predict_batch',
TRANSCRIBE_VOICE: '/transcribe/voice',
TRANSCRIBE_BATCH: '/transcribe/batch',
SUMMARIZE_TEXT: '/summarize/text',
ANALYZE_JOURNAL: '/analyze/journal',
EMOTION: '/analyze/emotion',
SUMMARIZE: '/analyze/summarize',
JOURNAL: '/analyze/journal',
VOICE_JOURNAL: '/analyze/voice-journal',
HEALTH: '/health',
METRICS: '/metrics',
MONITORING_DASHBOARD: '/monitoring/dashboard',
VERSION: '/version',
DOCS: '/docs',
OPENAPI: '/openapi.json',
READY: '/ready',
TRANSCRIBE: '/transcribe',
OPENAI_PROXY: '/proxy/openai',

// Authentication endpoints
AUTH: {
Expand Down Expand Up @@ -55,9 +55,25 @@ window.SAMO_CONFIG = {
RATE_LIMITS: {
MAX_REQUESTS_PER_MINUTE: 60,
BURST_LIMIT: 10
}
},

// Legacy compatibility - keep these for backward compatibility
TIMEOUT: 45000, // 45 seconds (emotion analysis can take ~28s)
RETRY_ATTEMPTS: 3,
API_KEY: null, // Set via server injection or user input
REQUIRE_AUTH: false // Set to true for production with API key requirement
},

// OpenAI Configuration - DISABLED for security (use proxy instead)
// WARNING: Direct client-side OpenAI calls expose API keys!
// All OpenAI functionality must use the /proxy/openai endpoint
OPENAI: {
// API_URL: 'https://api.openai.com/v1/chat/completions', // DISABLED - Security risk
// MODEL: 'gpt-4o-mini', // DISABLED - Use proxy endpoint
// MAX_TOKENS: 4000, // DISABLED - Use proxy endpoint
// TEMPERATURE: 0.7 // DISABLED - Use proxy endpoint
},

// UI Configuration
UI: {
// Demo settings
Expand All @@ -78,18 +94,52 @@ window.SAMO_CONFIG = {
}
},

// Feature flags
FEATURES: {
ENABLE_AUTH: true,
ENABLE_VOICE_TRANSCRIPTION: true,
ENABLE_BATCH_PROCESSING: true,
ENABLE_TEXT_SUMMARIZATION: true,
ENABLE_REAL_TIME_MONITORING: true,
ENABLE_SECURITY_TESTING: true,
ENABLE_WEBSOCKET_CHAT: true
}
// External Services
EXTERNAL: {
HUGGINGFACE: {
API_URL: 'https://api-inference.huggingface.co/models/gpt2',
MAX_LENGTH: 150
},
GOOGLE_FONTS: 'https://fonts.googleapis.com',
CDN: {
BOOTSTRAP: 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css',
CHART_JS: 'https://cdn.jsdelivr.net/npm/chart.js',
FONT_AWESOME: 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css'
}
},

// Development/Production flags
ENVIRONMENT: 'production', // 'development' or 'production'
DEBUG: false,

// Feature flags
FEATURES: {
ENABLE_OPENAI: false, // DISABLED - Security risk (use /proxy/openai endpoint instead)
ENABLE_MOCK_DATA: false, // Always use real APIs
ENABLE_ANALYTICS: false,
ENABLE_AUTH: true,
ENABLE_VOICE_TRANSCRIPTION: true,
ENABLE_BATCH_PROCESSING: true,
ENABLE_TEXT_SUMMARIZATION: true,
ENABLE_REAL_TIME_MONITORING: true,
ENABLE_SECURITY_TESTING: true,
ENABLE_WEBSOCKET_CHAT: true
}
};

// Environment-specific overrides - USE DEPLOYED API FOR DEVELOPMENT
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
window.SAMO_CONFIG.ENVIRONMENT = 'development';
window.SAMO_CONFIG.DEBUG = true;

// Use local unified API server (has the correct /analyze/emotion endpoints)
// This server has the exact endpoints the frontend expects
window.SAMO_CONFIG.API.BASE_URL = 'https://localhost:8002';
// Note: ENDPOINTS remain unchanged from production config (no override needed)

console.log('πŸ”§ Running in localhost development mode - using local API server at https://localhost:8002');
}

// Helper function to get API URL with fallback
window.SAMO_CONFIG.getApiUrl = function(endpoint) {
const baseUrl = this.API.BASE_URL;
Expand Down Expand Up @@ -123,4 +173,68 @@ window.SAMO_CONFIG.getWebSocketUrl = function(endpoint) {
return wsUrl + cleanEndpoint;
};

// Deep merge utility function
function deepMerge(target, source) {
const result = { ...target };

for (const key in source) {
if (source.hasOwnProperty(key)) {
if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
// Recursively merge objects
result[key] = deepMerge(target[key] || {}, source[key]);
} else {
// Replace primitives and arrays
result[key] = source[key];
}
}
}

return result;
}

// Server-side configuration injection (if available)
if (window.SAMO_SERVER_CONFIG) {
window.SAMO_CONFIG = deepMerge(window.SAMO_CONFIG, window.SAMO_SERVER_CONFIG);
}

// Recursive redaction utility function
function redactSensitiveValues(obj) {
if (obj === null || typeof obj !== 'object') {
return obj;
}

if (Array.isArray(obj)) {
return obj.map(item => redactSensitiveValues(item));
}

const result = {};
const SENSITIVE_PATTERNS = [
/^(api[-_]?key|authorization|x[-_]?api[-_]?key|bearer)$/i,
/^(token|access[_-]?token|refresh[_-]?token)$/i,
/^(secret|client[_-]?secret)$/i,
/^(password|passwd)$/i,
/^(credential|credentials|auth|authkey)$/i
];

for (const [key, value] of Object.entries(obj)) {
const isSensitive = SENSITIVE_PATTERNS.some(re => re.test(key));

if (isSensitive) {
result[key] = 'REDACTED';
} else if (value && typeof value === 'object') {
result[key] = redactSensitiveValues(value);
} else {
result[key] = value;
}
}

return result;
}

// Only log config in debug mode and redact sensitive fields
if (window.SAMO_CONFIG && window.SAMO_CONFIG.DEBUG) {
const sanitizedConfig = redactSensitiveValues(window.SAMO_CONFIG);
console.log('πŸ”§ SAMO Configuration loaded (debug mode):', sanitizedConfig);
}

console.log('SAMO-DL configuration loaded successfully');
Loading
Loading