-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirebase-config.js
More file actions
257 lines (231 loc) · 7.52 KB
/
firebase-config.js
File metadata and controls
257 lines (231 loc) · 7.52 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
(async function() {
if (typeof window.FIREBASE_ENV === 'undefined') {
console.error('Environment configuration not found.');
return;
}
try {
const { initializeApp } = await import('https://www.gstatic.com/firebasejs/10.7.0/firebase-app.js');
const { getFirestore, collection, addDoc, doc, updateDoc, setDoc, getDoc, getDocs, query, where, serverTimestamp } = await import('https://www.gstatic.com/firebasejs/10.7.0/firebase-firestore.js');
const { getAuth, GoogleAuthProvider, signInWithPopup, signOut, onAuthStateChanged, setPersistence, browserLocalPersistence } = await import('https://www.gstatic.com/firebasejs/10.7.0/firebase-auth.js');
const app = initializeApp(window.FIREBASE_ENV.config);
const db = getFirestore(app);
const auth = getAuth(app);
// Configure auth persistence for mobile compatibility
if (navigator.userAgent.includes('Mobile')) {
console.log('Configuring Firebase Auth persistence for mobile device');
setPersistence(auth, browserLocalPersistence).catch((error) => {
console.warn('Failed to set Firebase Auth persistence:', error);
});
}
window.firebase = {
app,
db,
auth,
collection,
addDoc,
doc,
updateDoc,
setDoc,
getDoc,
getDocs,
query,
where,
serverTimestamp,
GoogleAuthProvider,
signInWithPopup,
signOut,
onAuthStateChanged,
security: window.FIREBASE_ENV.security,
environment: window.FIREBASE_ENV.environment
};
window.firebaseLoaded = true;
window.dispatchEvent(new CustomEvent('firebaseLoaded'));
} catch (error) {
console.error('initialization failed:', error);
window.firebaseLoaded = false;
}
})();
window.validationRules = {
firstName: {
minLength: 2,
maxLength: 50,
pattern: /^[a-zA-Z\s'-]+$/,
required: true
},
lastName: {
minLength: 2,
maxLength: 50,
pattern: /^[a-zA-Z\s'-]+$/,
required: true
},
email: {
pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
maxLength: 254,
required: true
},
phone: {
pattern: /^[+]?[\d\s()-]{10,15}$/,
required: true
},
regNumber: {
pattern: /^[0-9]{2}[A-Z]{3}[0-9]{4}$/,
required: true
},
skills: {
minLength: 10,
maxLength: 1000,
required: true
},
motivation: {
minLength: 20,
maxLength: 2000,
required: true
},
contribution: {
minLength: 0,
maxLength: 2000,
required: false
}
};
window.sanitize = {
// Remove HTML tags and escape special characters
html: (str) => {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
},
// Remove potentially dangerous characters
strict: (str) => {
return str.replace(/[<>\"'%;()&+]/g, '');
},
// Clean whitespace
whitespace: (str) => {
return str.trim().replace(/\s+/g, ' ');
}
};
// Rate limiting configuration (make available globally)
window.rateLimiting = {
submissionCooldown: 30000, // 30 seconds between submissions
maxAttemptsPerHour: 5, // Maximum 5 attempts per hour
blockedDuration: 3600000 // 1 hour block after exceeding limit
};
// Security headers and CSP (make available globally)
window.securityConfig = {
// Content Security Policy
csp: {
'default-src': "'self'",
'script-src': "'self' https://www.gstatic.com https://cdn.jsdelivr.net https://cdnjs.cloudflare.com",
'style-src': "'self' 'unsafe-inline' https://cdn.jsdelivr.net",
'img-src': "'self' data: https:",
'connect-src': "'self' https://*.googleapis.com https://*.firebaseio.com",
'font-src': "'self' https://cdn.jsdelivr.net",
'object-src': "'none'",
'media-src': "'self'",
'frame-src': "'none'"
},
// Additional security headers
headers: {
'X-Frame-Options': 'DENY',
'X-Content-Type-Options': 'nosniff',
'X-XSS-Protection': '1; mode=block',
'Referrer-Policy': 'strict-origin-when-cross-origin'
}
};
// Department configuration with security validation (make available globally)
window.departments = {
'technical': {
name: 'Technical',
description: 'Hardware, software security, and technical implementations',
icon: '🔧',
validSkills: [
'cybersecurity', 'networking', 'linux', 'windows', 'penetration testing',
'vulnerability assessment', 'incident response', 'forensics', 'malware analysis',
'security tools', 'firewalls', 'ids', 'ips', 'siem'
]
},
'design': {
name: 'Design',
description: 'UI/UX design, graphics, and visual communications',
icon: '🎨',
validSkills: [
'figma', 'adobe creative suite', 'photoshop', 'illustrator', 'sketch',
'ui design', 'ux design', 'graphic design', 'branding', 'typography',
'web design', 'mobile design', 'prototyping'
]
},
'dev': {
name: 'Development',
description: 'Web development, mobile apps, and software solutions',
icon: '💻',
validSkills: [
'javascript', 'python', 'java', 'c++', 'html', 'css', 'react', 'node.js',
'vue.js', 'angular', 'mongodb', 'mysql', 'git', 'docker', 'aws',
'mobile development', 'web development', 'api development'
]
},
'social-media': {
name: 'Social Media',
description: 'Social media management and digital marketing',
icon: '📱',
validSkills: [
'social media marketing', 'content creation', 'instagram', 'twitter',
'linkedin', 'facebook', 'tiktok', 'canva', 'video editing',
'analytics', 'engagement', 'brand management', 'campaigns'
]
},
'content': {
name: 'Content',
description: 'Content creation, writing, and documentation',
icon: '✍️',
validSkills: [
'technical writing', 'content creation', 'blogging', 'copywriting',
'editing', 'proofreading', 'research', 'seo', 'documentation',
'storytelling', 'journalism', 'creative writing'
]
},
'event-management': {
name: 'Event Management',
description: 'Event planning, coordination, and execution',
icon: '🎪',
validSkills: [
'event planning', 'project management', 'coordination', 'logistics',
'vendor management', 'budgeting', 'marketing', 'communication',
'team leadership', 'problem solving', 'time management'
]
}
};
// Error messages (make available globally)
window.errorMessages = {
validation: {
firstName: 'First name must be 2-50 characters and contain only letters',
lastName: 'Last name must be 2-50 characters and contain only letters',
email: 'Please enter a valid email address',
phone: 'Please enter a valid phone number',
regNumber: 'Please enter a valid VIT registration number (e.g., 22BCE1234)',
department: 'Please select a department',
skills: 'Please describe your skills (10-1000 characters)',
motivation: 'Please explain your motivation (20-2000 characters)',
contribution: 'Use your creativity'
},
security: {
rateLimited: 'Too many submission attempts. Please wait before trying again.',
suspiciousActivity: 'Suspicious activity detected. Please contact support.',
networkError: 'Network error. Please check your connection and try again.',
serverError: 'Server error. Please try again later.'
}
};
// Logging configuration for security monitoring (make available globally)
window.loggingConfig = {
levels: {
INFO: 'info',
WARN: 'warn',
ERROR: 'error',
SECURITY: 'security'
},
events: {
FORM_SUBMIT: 'form_submit',
VALIDATION_ERROR: 'validation_error',
RATE_LIMIT_EXCEEDED: 'rate_limit_exceeded',
SUSPICIOUS_ACTIVITY: 'suspicious_activity'
}
};