Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// #1
const a1: firebase.app.App = firebase.initializeApp({
apiKey: 'apiKey',
databaseURL: 'databaseURL',
projectId: '42',
})
// #2
// $ExpectError
const a2: firebase.app.App = firebase.initializeApp({
storageBucker: 'storageBucket',
projectId: '42',
})
// #3
const a3: app.App = app('DEFAULT')
// #4
firebase
.auth()
.createUserWithEmailAndPassword('email', 'password')
.then()
.catch()
// #5
firebase.auth().onAuthStateChanged(user => {
if (user) {
user.displayName
user.email
user.emailVerified
user.photoURL
user.isAnonymous
}
};
// A config file that contains your firebase project credentials (not included in the repo)
const CONFIG = tryRequire('./firebase-config.json') || {
apiKey: "AIzaSyAcq_Vr-wbCjctpWIXJdeXBHnQgSqCLRY8",
authDomain: "jellyfin-a9ff6.firebaseapp.com",
databaseURL: "https://jellyfin-a9ff6.firebaseio.com",
projectId: "jellyfin-a9ff6",
storageBucket: "",
messagingSenderId: "505439361090"
};
// Initialize Cloud Firestore through Firebase
const app = firebase.initializeApp(CONFIG);
const db = firebase.firestore();
// Disable deprecated features
db.settings({
timestampsInSnapshots: true,
});
// Add a document to a collection
db.collection("test-collection").add({
title: 'post title',
content: 'This is the test post content.',
date: new Date(),
})
.then(docRef => {
console.log('Document written with ID: ', docRef);
const connect = (props, dispatch) => {
console.log("Connecting to ", props.config, props.name)
const settings = { /* your settings... */
timestampsInSnapshots: true
};
const db = firebase.initializeApp(props.config, props.name).firestore()
db.settings(settings);
db.collection("/sessions").doc().set({
started: new Date()
})
console.log("dispatching", props.action)
dispatch(props.action)
}
public ngOnInit(): void {
firebase.initializeApp({
apiKey: 'AIzaSyA9tQLQ5WJOBS7-e9zcdGkRKjaroRI0T18',
authDomain: 'test-59779.firebaseapp.com',
databaseURL: 'https://test-59779.firebaseio.com',
projectId: 'test-59779',
storageBucket: '',
messagingSenderId: '289255988111',
})
this.message = GTG
this.renderer.setStyle(this.document.body.parentElement, 'background', 'green')
// use e2e ready since firebase uses an interval to poll for auth updates, which breaks protractor's angular
// ready detection
ready()
}
// Firestore plugin
import firebase from '@firebase/app';
import '@firebase/auth';
import '@firebase/firestore';
import Config from '../background/js/config';
import firebaseConfig from './config-firebase';
import _GORGIAS_API_PLUGIN from './plugin-api';
// firebase
firebase.initializeApp(firebaseConfig);
var db = firebase.firestore();
db.enablePersistence().catch((err) => {
console.log('Firestore Persistance Error', err);
});
function mock () {
return Promise.resolve();
}
function fsDate (date) {
if (!date) {
return firebase.firestore.Timestamp.now();
}
return firebase.firestore.Timestamp.fromDate(date);
}
// A config file that contains your firebase project credentials (not included in the repo)
const CONFIG = tryRequire('./firebase-config.json') || {
apiKey: "AIzaSyAcq_Vr-wbCjctpWIXJdeXBHnQgSqCLRY8",
authDomain: "jellyfin-a9ff6.firebaseapp.com",
databaseURL: "https://jellyfin-a9ff6.firebaseio.com",
projectId: "jellyfin-a9ff6",
storageBucket: "",
messagingSenderId: "505439361090"
};
// Initialize Cloud Firestore through Firebase
const app = firebase.initializeApp(CONFIG);
const db = firebase.firestore();
// Disable deprecated features
db.settings({
timestampsInSnapshots: true,
});
// Add a document to a collection
db.collection("test-collection").add({
title: 'post title',
content: 'This is the test post content.',
date: new Date(),
})
.then(docRef => {
console.log('Document written with ID: ', docRef);
})
.catch(error => {
if (getRuntimeEnv() == RuntimeEnv.ELECTRON_RENDERER) {
vue.onSignInSuccessWithAuthResult();
return false;
} else {
return true;
}
},
uiShown: function () {
// The widget is rendered.
// Hide the loader.
}
},
signInSuccessUrl: '/home',
signInOptions: Services.getInstance().config.authProviders,
};
let ui = firebaseui.auth.AuthUI.getInstance() ? firebaseui.auth.AuthUI.getInstance() : new firebaseui.auth.AuthUI(firebase.auth());
ui.start('#firebaseui-auth-container', uiConfig);
console.log(Services.getInstance().config.authProviders);
}
const getMessagingToken = async () => {
try {
const messaging = firebase.messaging();
await messaging.requestPermission();
const token = await messaging.getToken();
// TODO: debugging
console.log({ token });
return token;
} catch (error) {
console.error(error);
return null;
}
};
await this.mergeService.mergeDeck(mergeInfo.deckId, mergeInfo.userToken, user.id);
// Delete previous anonymous user from our backend
await this.userService.delete(mergeInfo.userId, mergeInfo.userToken);
// Delete previous anonymous user from Firebase
if (this.firebaseUser) {
await this.firebaseUser.delete();
}
await this.navigateRedirect();
resolve();
});
await firebase.auth().signInWithCredential(cred);
resolve();
});
};
loadDocument() {
if (this.startedLoad) { return null; }
this.startedLoad = true;
/* Authenticate with Firebase if a firebaseToken is provided in the client data */
const authenticationFunction = this.localClientData.firebaseToken
? firebase.auth(this.firebaseApp).signInWithCustomToken(this.localClientData.firebaseToken)
: new Promise((resolve)=> { return resolve(); });
return authenticationFunction
.then(()=> {
/* Load the checkpoint if available */
return this.firebaseRef.child('checkpoint').once('value');
})
.then((checkpointSnapshot) => {
const checkpointSnapshotVal = checkpointSnapshot.val() || { k: '0', d: { type: 'doc', attrs: { meta: {} }, content: [{ type: 'paragraph' }] } };
this.mostRecentRemoteKey = Number(checkpointSnapshotVal.k);
const newDoc = Node.fromJSON(this.view.state.schema, uncompressStateJSON({ d: checkpointSnapshotVal.d }).doc);
/* Get all changes since mostRecentRemoteKey */
const getChanges = this.firebaseRef.child('changes')
.orderByKey()