Class: FirebaseInstance

FirebaseInstance

<protected> new FirebaseInstance(name, adminToken)

Creates a new reference to a Firebase instance. NOTE: don't use the constructor yourself, use a FirebaseAccount instance instead.

Parameters:
Name Type Description
name String

The name of the Firebase.

adminToken String

The administrative token to use

Source:
See:

Methods

addAuthToken() → {external:Promise}

Promises to create and return a new auth token.

Source:
Returns:

A promise that resolves with a new auth token (String) that is guaranteed to be valid and rejects with an Error if there's an error.

Type
external:Promise
Example
instance.addAuthToken().then(function(token) {
  fb.auth(token, function(err) {
    // err should be null
  });
});

changeUserPassword(email, newPassword) → {external:Promise}

Promises to change a Simple Login user's password.

Parameters:
Name Type Description
email String

The email address of the user to remove.

newPassword String

The new password.

Source:
Returns:

A promise that resolves with the new user info if the user's password is changed successfully and rejects with an Error if there's an error.

Type
external:Promise

createUser(email, password) → {external:Promise}

Promises to create a Firebase Simple Login password-type user.

Parameters:
Name Type Description
email String

The email address of the new user.

password String

The password of the new user.

Source:
Returns:

A promise that resolves if the rules are changed successfully and rejects with an Error if there's an error.

Type
external:Promise

getAuthConfig() → {external:Promise}

Promises to obtain the current authentication configuration for the instance.

Source:
Returns:

A promise that resolves with the auth config and rejects with an Error if there's an error.

Type
external:Promise

getAuthTokens() → {external:Promise}

Promises to get all the auth tokens associated with the instance.

Source:
Returns:

A promise that resolves with an Array of the instance's currently-valid auth tokens and rejects with an Error if there's an error.

Type
external:Promise
Example
instance.getAuthTokens().then(function(tokens) {
  fb.auth(tokens[0], function(err) {
    // err should be null
  });
});

getRules() → {external:Promise}

Promises to get a Javascript object containing the current security rules. NOTE: the top-level "rules" part of the JSON will be stripped.

Source:
Returns:

A promise that resolves with an Object containing the rules if they're retrieved successfully and rejects with an Error if there's an error.

Type
external:Promise
Example
instance.getRules().then(function(rules) {
  if (rules['.read'] === 'true' && rules['.write'] === 'true') {
    console.log('WARNING: this Firebase has default global rules!');
  }
});

listUsers() → {external:Promise}

Promises to return a list of all Simple Login password users in the Firebase.

Source:
Returns:

A promise that resolves with a list of users and rejects with an Error if there's an error.

Type
external:Promise

removeAuthToken(token) → {external:Promise}

Promises to remove an existing auth token.

Parameters:
Name Type Description
token String

The token to be removed.

Source:
Returns:

A promise that resolves if token has been removed successfully and rejects with an Error if token isn't valid or if there's an error.

Type
external:Promise
Example
instance.removeAuthToken(token).then(function() {
  fb.auth(token, function(err) {
    // should get an error indicating invalid credentials here
  });
});

removeUser(email) → {external:Promise}

Promises to remove a Simple Login user.

Parameters:
Name Type Description
email String

The email address of the user to remove.

Source:
Returns:

A promise that resolves with the new user info if the user is removed successfully and rejects with an Error if there's an error.

Type
external:Promise

sendResetEmail(email) → {external:Promise}

Promises to send a password reset email to a Simple Login user.

Parameters:
Name Type Description
email String

The email address of the user to send a message to.

Source:
Returns:

A promise that resolves if the message is sent successfully and rejects with an Error if there's an error.

Type
external:Promise

setRules(newRules) → {external:Promise}

Promises to change current security rules.

Parameters:
Name Type Description
newRules Object

The new security rules as a Javascript object. This object need not have a top-level "rules" key, although it will be handled gracefully if it does.

Source:
Returns:

A promise that resolves if the rules are changed successfully and rejects with an Error if there's an error.

Type
external:Promise
Example
instance.setRules({
  '.read': 'true',
  '.write': 'false'
}).then(function() {
  console.log('Disabled write access to this Firebase.');
}).catch(function() {
  console.log('Oops, something went wrong!');
});

toString() → {String}

Gets the URL to the instance, for use with the Firebase API.

Source:
Returns:

The full URL to the instance.

Type
String
Example
var fb = new Firebase(instance.toString());