-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-sync.js
More file actions
80 lines (67 loc) · 2.61 KB
/
setup-sync.js
File metadata and controls
80 lines (67 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Hera Extension - Sync Configuration Setup
// Run this in the browser console on the extension popup to configure remote sync
async function setupHeraSync() {
console.log('🔧 Setting up Hera sync configuration...');
// Configuration options
const config = {
syncEndpoint: 'http://localhost:8000/auth-events', // Change to your backend URL
riskThreshold: 50, // Alert threshold for risk scores
enableRealTimeAlerts: true,
syncInterval: 5, // minutes
maxLocalStorage: 1000 // max events to keep locally
};
try {
// Store configuration
await chrome.storage.local.set({ heraConfig: config });
console.log('Hera sync configuration saved:', config);
console.log('📡 Extension will now sync authentication events to:', config.syncEndpoint);
// Test connection to backend
try {
const response = await fetch(config.syncEndpoint.replace('/auth-events', '/dashboard/stats'));
if (response.ok) {
const stats = await response.json();
console.log(' Backend connection successful! Current stats:', stats);
} else {
console.log(' Backend connection failed. Make sure your backend is running.');
}
} catch (e) {
console.log(' Could not connect to backend. Events will be stored locally only.');
}
return config;
} catch (error) {
console.error(' Failed to setup sync:', error);
throw error;
}
}
// Example usage for different deployment scenarios
const deploymentExamples = {
// Local development
local: {
syncEndpoint: 'http://localhost:8000/auth-events',
description: 'For local development with Python FastAPI backend'
},
// Cloud deployment examples
aws: {
syncEndpoint: 'https://your-api-gateway.amazonaws.com/prod/auth-events',
description: 'AWS API Gateway + Lambda deployment'
},
heroku: {
syncEndpoint: 'https://your-hera-backend.herokuapp.com/auth-events',
description: 'Heroku deployment'
},
digitalocean: {
syncEndpoint: 'https://your-droplet-ip:8000/auth-events',
description: 'DigitalOcean droplet deployment'
},
// Self-hosted options
selfHosted: {
syncEndpoint: 'https://your-domain.com/hera/auth-events',
description: 'Self-hosted with reverse proxy (nginx/apache)'
}
};
console.log('Hera Sync Setup Ready!');
console.log('Available deployment options:', deploymentExamples);
console.log('🔧 Run setupHeraSync() to configure with default local settings');
console.log('🔧 Or modify the config object above and run setupHeraSync() with your settings');
// Auto-setup for development (uncomment to auto-configure)
// setupHeraSync();