Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

firebase-admin

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firebase-admin - npm Package Compare versions

Comparing version 2.2.0 to 3.0.0

47

account.js

@@ -25,49 +25,6 @@

/**
* Gets a Firebase admin token given a username and password.
* @constructor
* @param {String} email The email address associated with the account.
* @param {String} password The password for the account.
* @property {external:Promise} ready A promise that will resolve when the
* token is retrieved, or reject if there's an error.
*/
FirebaseAccount.getToken = function(email, password) {
var deferred = Q.defer();
this._dbs = {};
request.get({
url: 'https://admin.firebase.com/account/login',
qs: {
email: email,
password: password
},
json: true
}, function(err, response, body) {
if (err) {
deferred.reject(err);
} else if (response.statusCode !== 200) {
deferred.reject(new Error(response.statusCode));
} else if (body.error) {
deferred.reject(new Error('Firebase error: ' + body.error));
} else if (body.success === false) {
deferred.reject(new Error('Bad credentials or server error.'));
} else {
deferred.resolve(body.adminToken);
}
});
return deferred.promise;
};
FirebaseAccount.defaultAuthConfig = {
domains: [
'localhost',
'127.0.0.1',
'casetext-goldibex.firebaseapp.com'
'127.0.0.1'
],

@@ -259,3 +216,3 @@ sessionLengthSeconds: 86400,

* // get a Firebase reference to the new instance
* var fb = new Firebase(db.toString());
* var fb = new Firebase(db.toString());
* fb.child('spam/spam/spam/spam').set('wonderful');

@@ -262,0 +219,0 @@ * }, function(err) {

22

instance.js

@@ -102,3 +102,3 @@

request.get({
url: 'https://' + this.name + '.firebaseio.com/.settings/secrets.json',
url: 'https://' + this.name + '.firebaseio.com//.settings/secrets.json',
qs: {

@@ -348,3 +348,3 @@ auth: this.personalToken

request.get({
url: 'https://' + this.name + '.firebaseio.com/.settings/authConfig.json',
url: 'https://' + this.name + '.firebaseio.com/.settings/.json',
qs: {

@@ -364,6 +364,6 @@ auth: this.personalToken,

if (typeof body === 'string' && body.length === 0) {
if (typeof body.authConfig === 'string' && body.authConfig.length === 0) {
deferred.resolve(null);
} else {
deferred.resolve(JSON.parse(body));
deferred.resolve(JSON.parse(body.authConfig));
}

@@ -383,9 +383,10 @@

request.put({
url: 'https://' + this.name + '.firebaseio.com/.settings/authConfig.json',
qs: {
auth: this.personalToken,
request.post({
url: 'https://admin.firebase.com/firebase/' + this.name + '/authConfig',
json: true,
body: {
token: this.adminToken,
authConfig: JSON.stringify(config),
_method: 'put'
},
json: true,
body: config
}, function(err, response, body) {

@@ -397,2 +398,3 @@ if (err) {

} else if (body && body.error) {
console.log(body.error);
deferred.reject(new Error(body.error));

@@ -399,0 +401,0 @@ } else {

@@ -12,6 +12,2 @@

login: function(account) {
console.log('FIREBASE_ADMIN_TOKEN=' + escape(account.adminToken));
},
bootstrap: function(account) {

@@ -18,0 +14,0 @@

{
"name": "firebase-admin",
"version": "2.2.0",
"version": "3.0.0",
"description": "Programmatically instantiate and modify Firebase instances.",

@@ -27,3 +27,3 @@ "keywords": [

"scripts": {
"test": "./script/test.bash",
"test": "mocha --recursive -u bdd -t 30000 -s 2000 -r ./test/setup test/spec",
"postpublish": "./script/postpublish.bash"

@@ -30,0 +30,0 @@ },

@@ -21,12 +21,10 @@ firebase-admin

var Firebase = require('firebase');
FirebaseAccount.getToken('user', 'pass')
.then(function(token) {
var account = new FirebaseAccount(token);
account.createDatabase('new-instance-name')
.then(function(instance) {
var fb = new Firebase(instance.toString());
})
.catch(function(err) {
console.error('Oops, error creating instance:', err);
});
var account = new FirebaseAccount(process.env.FIREBASE_ADMIN_TOKEN);
account.createDatabase('new-instance-name')
.then(function(instance) {
var fb = new Firebase(instance.toString());
})
.catch(function(err) {
console.error('Oops, error creating instance:', err);
});

@@ -33,0 +31,0 @@ ```

@@ -12,5 +12,5 @@

if (!process.env.FIREBASE_USER || !process.env.FIREBASE_PASS) {
if (!process.env.FIREBASE_ADMIN_TOKEN) {
console.error(
'You must set process.env.FIREBASE_USER and process.env.FIREBASE_PASS\n' +
'You must set process.env.FIREBASE_ADMIN_TOKEN\n' +
'before running these tests.'

@@ -17,0 +17,0 @@ );

@@ -6,8 +6,5 @@

var fbUser = process.env.FIREBASE_USER,
fbPass = process.env.FIREBASE_PASS,
FirebaseAccount = require('../../account.js'),
var FirebaseAccount = require('../../account.js'),
account;
describe('FirebaseAccount', function() {

@@ -18,8 +15,3 @@

before(function() {
return FirebaseAccount.getToken(fbUser, fbPass)
.then(function(newToken) {
token = newToken;
});
token = process.env.FIREBASE_ADMIN_TOKEN;
});

@@ -31,31 +23,2 @@

describe('getToken', function() {
describe('given valid credentials', function() {
it('resolves when authenticated', function() {
return expect(FirebaseAccount.getToken(fbUser, fbPass))
.to.be.fulfilled;
});
});
describe('given invalid credentials', function() {
it('has a "ready" promise that rejects with an error', function() {
return expect(
FirebaseAccount.getToken('wrong@wrongville.com', 'wrongpass')
)
.to.be.rejectedWith(Error);
});
});
});
describe('defaultAuthConfig', function() {

@@ -146,8 +109,3 @@

before(function() {
return FirebaseAccount.getToken(fbUser, fbPass)
.then(function(token) {
instancePromise = FirebaseAccount.bootstrapInstance(token);
});
instancePromise = FirebaseAccount.bootstrapInstance(token);
});

@@ -154,0 +112,0 @@

@@ -7,5 +7,3 @@

var fbUser = process.env.FIREBASE_USER,
fbPass = process.env.FIREBASE_PASS,
FirebaseAccount = require('../../account.js'),
var FirebaseAccount = require('../../account.js'),
account,

@@ -20,13 +18,7 @@ instance,

account = new FirebaseAccount(process.env.FIREBASE_ADMIN_TOKEN);
return FirebaseAccount.getToken(fbUser, fbPass)
.then(function(token) {
account = new FirebaseAccount(token);
return account.createDatabase(Math.random().toString(36).slice(2))
.then(function(newInstance) {
instance = newInstance;
});
return account.createDatabase(Math.random().toString(36).slice(2))
.then(function(newInstance) {
instance = newInstance;
});

@@ -165,4 +157,6 @@

config.password.enabled = true;
return expect(instance.setAuthConfig(config))
.to.be.resolved;
return instance.setAuthConfig(config)
.then(function() {
return Q.delay(1000);
});

@@ -169,0 +163,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc