Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
rxfire-kaladivo
Advanced tools
Firebase and RxJS for all frameworks.
Status: Beta
# npm
npm i rxfire firebase rxjs --save
# yarn
yarn add rxfire firebase rxjs
Make sure to install Firebase and RxJS individually as they are peer dependencies of RxFire.
import firebase from 'firebase/app';
import 'firebase/firestore';
import { collectionData } from 'rxfire/firestore';
import { tap } from 'rxjs/operators';
const app = firebase.initializeApp({ /* config */ });
const citiesRef = app.firestore().collection('cities');
citiesRef.where('state', '==', 'CO');
collectionData(citiesRef, 'id')
.pipe(
tap(cities => console.log('This is just an observable!'))
)
.subscribe(cities => { /* update UI */ })
RxJS provides multiple operators and creation methods for combining observable streams. This makes it easy to combine data from multiple Firebase resources. You can also handle simplify high asynchronous tasks like joins into a flat stream.
The example below streams a list of "cities" from Firestore and then retrieves their image from a Cloud Storage bucket. Both tasks are asynchronous but RxJS makes it easy to combine these tasks together.
import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/storage';
import { collectionData } from 'rxfire/firestore';
import { getDownloadURL } from 'rxfire/storage';
import { switchMap } from 'rxjs/operators';
const app = firebase.initializeApp({ /* config */ });
const citiesRef = app.firestore().collection('cities');
citiesRef.where('state', '==', 'CO');
collectionData(citiesRef, 'id')
.pipe(
switchMap(cities => {
return combineLatest(...cities.map(c => {
const ref = storage.ref(`/cities/${c.id}.png`);
return getDownloadURL(ref).pipe(map(imageURL => ({ imageURL, ...c })));
}));
})
)
.subscribe(cities => {
cities.forEach(c => console.log(c.imageURL));
});
RxFire is a complementary library to Firebase. It is not meant to wrap the entire Firebase SDK. RxFire's purpose is to simplify async streams from Firebase. You need to import the Firebase SDK and initialize an app before using RxFire.
import firebase from 'firebase/app';
import 'firebase/storage'; // import only the features needed
import { getDownloadURL } from 'rxfire/storage';
const app = firebase.initializeApp({ /* config */ });
const ref = app.storage().ref('data.json');
// Now you can use RxFire!
const url$ = getDownloadURL(ref);
RxFire contains multiple entry points for module imports. Each Firebase library is an entry point.
import { } from 'rxfire/firestore';
import { } from 'rxfire/database';
import { } from 'rxfire/storage';
import { } from 'rxfire/auth';
import { } from 'rxfire/functions';
RxFire is a set of functions. Most functions create observables and from there you can use regular RxJS operators. Some functions are custom operators. But at the end of the day, it's all just functions. This is important for tree shaking. Any unused functions are stripped from your final build if you use a module bundler like Webpack or Rollup.
import firebase from 'firebase/app';
import 'firebase/storage';
import { getDownloadURL, put /* not used! */ } 'rxfire/storage';
const app = firebase.initializeApp({ /* config */ });
const ref = app.storage().ref('data.json');
const url$ = getDownloadURL(ref);
Examples: See this example repository for a list of ways to configure and use RxFire.
FAQs
Firebase JavaScript library RxJS
We found that rxfire-kaladivo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.