
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
node-fireuser
Advanced tools
This is a library for easy user management with Firebase Realtime Database and Firestore.
Install the library easily with npm.
npm install node-fireuser
You'll also need the Firebase-admin SDK for this library. Just install it aswell with npm.
npm install firebase-admin
After you installed both, you have to include them and do the first commands. If you don't know how to initialize the Firebase Admin SDK look here
With Webpack
import * as fireuser from ('node-fireuser')
import * as admin from ('firebase-admin')
import * as serviceWorker from ('path/to/your/json/file');
/* Initialize Firebase Admin
It's necassary to do this BEFORE you init the Fireuser library
*/
admin.initializeApp({
credential: admin.credential.cert(serviceWorker),
databaseURL: "https://[YOUR PROJECT].firebaseio.com/"
});
/* Init Fireuser
Use the firebase-admin variable as argument! In this case it's admin
*/
if(fireuser.init(admin)){
console.log("Everything fine");
...
}else{
console.log("An error appeared");
}
Without Webpack
const fireuser = require('node-fireuser')
const admin = require('firebase-admin')
const serviceWorker = require('path/to/your/json/file');
...
}
You'll need this command every time, you want to create a new user in the database. It uses the parameter authID and options . For authID you should use the Firebase Authentication ID of the user. options is an object where you can enter every data the user should have in the database.
// Basic syntax
fireuser.database.createUser(authID, options)
// Example
const authID = req.body.authID;
const rqUsername = req.body.username;
const rqEmail = req.body.email;
const rqFullname = req.body.fullname;
fireuser.database.createUser(authID, {
username: rqUsername,
email: rqEmail,
fullname: rqFullname
});
If you want to retrieve the data of a special user, you can use this function. As parameter, it takes the authID of the user. The function is a promise which returns an object.
fireuser.database.getUserById(authID).then(res => {
let username = res.username;
let email = res.email;
console.log("The username is: " + username);
console.log("The email address is: " + email);
});
coming soon...
Use this command to change data of an existing user. Parameters are the Firebase AuthID and the options object.
fireuser.database.changeUserData(authID, {
username: newUsername,
email: newEmail,
newElement: newElement
});
If you want to watch changes of the user data live and interact with it, use this function. You need the Firebase AuthID and a throwback function.
fireuser.database.watchUserChanges(authID, newData => f(newData));
// gets fired every time the user data changes
function tb(newData){
console.log(newData.username);
}
Removes a user from the database
if(fireuser.database.removeUser(authID)){
// user removed
}
Returns (a promise of) the total amount of users in the databse
fireuser.database.getUserNumber().then(number => console.log(number.toString()));
... under construction
FAQs
A user-management system for firestore & realtime database
The npm package node-fireuser receives a total of 2 weekly downloads. As such, node-fireuser popularity was classified as not popular.
We found that node-fireuser 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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.