Skip to content
Merged
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions code/firebase-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Firebase V9 Compat Initialization
// Strict Silent Client Mandate: Do not add console.log or error logging.

const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_AUTH_DOMAIN",
projectId: "YOUR_PROJECT_ID",
storageBucket: "YOUR_STORAGE_BUCKET",
messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
appId: "YOUR_APP_ID"
};
Comment on lines +4 to +11

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

Committing configuration files with credential placeholders poses a security risk, as developers might accidentally commit real credentials. While Firebase web API keys are not considered secret, it's a security best practice to keep all credentials out of source control. This also simplifies managing different environments (e.g., development, production).

A safer pattern is to load these values from environment variables at build time. If a build process isn't in place, consider renaming this file to firebase-config.js.example, adding firebase-config.js to .gitignore, and documenting that developers need to create this file locally from the example.


// Defensive execution to prevent UI thread blocking if the CDN fails to load
if (typeof firebase !== 'undefined') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To make the Firebase initialization more robust, it's a good practice to also check if a Firebase app has already been initialized before attempting to initialize it again. Calling initializeApp() more than once for the default app throws an error. While your try/catch block handles this, preventing the error in the first place is cleaner and more explicit.

Suggested change
if (typeof firebase !== 'undefined') {
if (typeof firebase !== 'undefined' && !firebase.apps.length) {

try {
firebase.initializeApp(firebaseConfig);
} catch (e) {
// Absolute silence mandated. No console.error here.
// The failure will be naturally caught by experiment.js falling back to localStorage.
}
}
Loading