Socket
Socket
Sign inDemoInstall

firebase-admin

Package Overview
Dependencies
Maintainers
1
Versions
135
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 4.0.4 to 4.0.5

22

lib/auth/auth-api-request.js

@@ -1,8 +0,8 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
"use strict";
var validator = require('../utils/validator');
var deep_copy_1 = require('../utils/deep-copy');
var error_1 = require('../utils/error');
var api_request_1 = require('../utils/api-request');
var validator = require("../utils/validator");
var deep_copy_1 = require("../utils/deep-copy");
var error_1 = require("../utils/error");
var api_request_1 = require("../utils/api-request");
/** Firebase Auth backend host. */

@@ -180,5 +180,9 @@ var FIREBASE_AUTH_HOST = 'www.googleapis.com';

if (response.error[0].message.indexOf('can not overwrite') !== -1) {
// Duplicate user error
// Duplicate user error.
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.UID_ALREADY_EXISTS, response.error[0].message);
}
else if (response.error[0].message.indexOf('email exists') !== -1) {
// Email exists error.
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.EMAIL_ALREADY_EXISTS, response.error[0].message);
}
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: ' + response.error[0].message);

@@ -213,3 +217,3 @@ }

var FirebaseAuthRequestHandler = (function () {
function FirebaseAuthRequestHandler(credential) {
function FirebaseAuthRequestHandler(app) {
this.host = FIREBASE_AUTH_HOST;

@@ -220,3 +224,3 @@ this.port = FIREBASE_AUTH_PORT;

this.timeout = FIREBASE_AUTH_TIMEOUT;
this.signedApiRequestHandler = new api_request_1.SignedApiRequestHandler(credential);
this.signedApiRequestHandler = new api_request_1.SignedApiRequestHandler(app);
}

@@ -390,3 +394,3 @@ /**

if (errorCode) {
throw error_1.FirebaseAuthError.fromServerError(errorCode);
throw error_1.FirebaseAuthError.fromServerError(errorCode, /* message */ undefined, response);
}

@@ -393,0 +397,0 @@ // Validate response.

@@ -1,33 +0,26 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
"use strict";
var token_generator_1 = require('./token-generator');
var credential_1 = require('./credential');
var auth_api_request_1 = require('./auth-api-request');
var user_record_1 = require('./user-record');
var error_1 = require('../utils/error');
var user_record_1 = require("./user-record");
var token_generator_1 = require("./token-generator");
var auth_api_request_1 = require("./auth-api-request");
var error_1 = require("../utils/error");
/**
* Gets a Credential from app options.
*
* @return {Credential}
* Internals of an Auth instance.
*/
function getCredential(app) {
var opts = app.options;
if (opts.credential) {
return opts.credential;
var AuthInternals = (function () {
function AuthInternals() {
}
// We must be careful because '' is falsy. An opt || env test would coalesce '' || undefined as undefined.
var certificateOrPath = typeof opts.serviceAccount === 'undefined' ?
process.env.GOOGLE_APPLICATION_CREDENTIALS :
opts.serviceAccount;
if (typeof certificateOrPath === 'string') {
return new credential_1.CertCredential(credential_1.Certificate.fromPath(certificateOrPath));
}
else if (typeof certificateOrPath === 'object') {
return new credential_1.CertCredential(new credential_1.Certificate(certificateOrPath));
}
else {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_SERVICE_ACCOUNT);
}
}
/**
* Deletes the service and its associated resources.
*
* @return {Promise<()>} An empty Promise that will be fulfilled when the service is deleted.
*/
AuthInternals.prototype.delete = function () {
// There are no resources to clean up
return Promise.resolve(undefined);
};
return AuthInternals;
}());
exports.AuthInternals = AuthInternals;
/**

@@ -41,16 +34,12 @@ * Auth service bound to the provided app.

function Auth(app) {
if (typeof app !== 'object' || !('options' in app)) {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'First parameter to Auth constructor must be an instance of FirebaseApp');
this.INTERNAL = new AuthInternals();
if (typeof app !== 'object' || app === null || !('options' in app)) {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'First argument passed to admin.auth() must be a valid Firebase app instance.');
}
this.app_ = app;
var credential = getCredential(app);
if (credential && typeof credential.getAccessToken !== 'function') {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CREDENTIAL, 'Called initializeApp() with an invalid credential parameter');
}
this.authTokenManager_ = new AuthTokenManager(credential);
// TODO (inlined): plumb this into a factory method for tokenGenerator_ once we
// can generate custom tokens from access tokens.
var serviceAccount;
if (typeof credential.getCertificate === 'function') {
serviceAccount = credential.getCertificate();
if (typeof app.options.credential.getCertificate === 'function') {
serviceAccount = app.options.credential.getCertificate();
}

@@ -60,13 +49,4 @@ if (serviceAccount) {

}
// Initialize auth request handler with the credential.
this.authRequestHandler = new auth_api_request_1.FirebaseAuthRequestHandler(credential);
// Initialize user record write map (uid to queue).
// Firebase auth backend does not lock transactions running on the same user record.
// Edits on the same user record could overwrite each other, depending on the last one
// to execute.
// Multiple create user requests with the same email could create multiple
// records where one will always be used depending on the backend lookup algorithm.
// This promise queue ensures user record writes are serialized.
// TODO(bojeil): Remove this logic (b/32584015) which is currently blocked by b/32556583
this.userWriteMap = {};
// Initialize auth request handler with the app.
this.authRequestHandler = new auth_api_request_1.FirebaseAuthRequestHandler(app);
}

@@ -80,9 +60,2 @@ Object.defineProperty(Auth.prototype, "app", {

});
Object.defineProperty(Auth.prototype, "INTERNAL", {
get: function () {
return this.authTokenManager_;
},
enumerable: true,
configurable: true
});
/**

@@ -178,27 +151,2 @@ * Creates a new custom token that can be sent back to a client to use with

Auth.prototype.deleteUser = function (uid) {
// Add to queue and wait for it to execute.
return this.serializeApiRequest(uid, this.deleteUserUnserialized.bind(this, uid));
};
;
/**
* Updates an existing user with the properties provided.
*
* @param {string} uid The uid identifier of the user to update.
* @param {Object} properties The properties to update on the existing user.
* @return {Promise<UserRecord>} A promise that resolves with the modified user record.
*/
Auth.prototype.updateUser = function (uid, properties) {
// Add to queue and wait for it to execute.
return this.serializeApiRequest(uid, this.updateUserUnserialized.bind(this, uid, properties));
};
;
/**
* Deletes the user identified by the provided user id and returns a promise that is
* fulfilled when the user is found and successfully deleted.
* This will run without being serialized in the user write queue.
*
* @param {string} uid The uid of the user to delete.
* @return {Promise<void>} A promise that resolves when the user is successfully deleted.
*/
Auth.prototype.deleteUserUnserialized = function (uid) {
return this.authRequestHandler.deleteAccount(uid)

@@ -212,3 +160,2 @@ .then(function (response) {

* Updates an existing user with the properties provided.
* This will run without being serialized in the user write queue.
*

@@ -219,3 +166,3 @@ * @param {string} uid The uid identifier of the user to update.

*/
Auth.prototype.updateUserUnserialized = function (uid, properties) {
Auth.prototype.updateUser = function (uid, properties) {
var _this = this;

@@ -229,45 +176,2 @@ return this.authRequestHandler.updateExistingAccount(uid, properties)

;
/**
* @param {string} uid The uid identifier of the request.
* @param {() => Promise<any>} boundFn Promise returning function to queue with this
* context and arguments already bound.
* @return {Promise<any>} The resulting promise which resolves when all pending previous
* promises on the same user are resolved.
*/
Auth.prototype.serializeApiRequest = function (uid, boundFn) {
var _this = this;
// Check if there is a pending queue for the current user.
// If not initialize one.
if (typeof this.userWriteMap[uid] === 'undefined') {
this.userWriteMap[uid] = {
queue: Promise.resolve(),
pending: 0,
};
}
// Increment pending counter for current user.
this.userWriteMap[uid].pending++;
this.userWriteMap[uid].queue = this.userWriteMap[uid].queue
.then(function () {
return boundFn();
}, function (error) {
return boundFn();
})
.then(function (result) {
// Clean up any user specific queues that are no longer pending.
if (--_this.userWriteMap[uid].pending === 0) {
delete _this.userWriteMap[uid];
}
// Funnel result back.
return result;
}, function (error) {
// Clean up any user specific queues that are no longer pending.
if (--_this.userWriteMap[uid].pending === 0) {
delete _this.userWriteMap[uid];
}
// Rethrow error.
throw error;
});
return this.userWriteMap[uid].queue;
};
;
return Auth;

@@ -277,90 +181,1 @@ }());

;
var FirebaseAccessToken = (function () {
function FirebaseAccessToken() {
}
return FirebaseAccessToken;
}());
exports.FirebaseAccessToken = FirebaseAccessToken;
var AuthTokenManager = (function () {
function AuthTokenManager(credential) {
this.credential = credential;
this.tokenListeners = [];
}
/**
* Deletes the service and its associated resources.
*
* @return {Promise<()>} An empty Promise that will be fulfilled when the service is deleted.
*/
AuthTokenManager.prototype.delete = function () {
// There are no resources to clean up
return Promise.resolve(undefined);
};
/**
* Gets an auth token for the associated app.
*
* @param {boolean} forceRefresh Whether or not to force a token refresh.
* @return {Promise<Object>} A Promise that will be fulfilled with the current or new token.
*/
AuthTokenManager.prototype.getToken = function (forceRefresh) {
var _this = this;
var expired = this.cachedToken && this.cachedToken.expirationTime < Date.now();
if (this.cachedToken && !forceRefresh && !expired) {
return Promise.resolve(this.cachedToken);
}
else {
// credential may be an external class; resolving it in a promise helps us
// protect against exceptions and upgrades the result to a promise in all cases.
return Promise.resolve()
.then(function () {
return _this.credential.getAccessToken();
})
.then(function (result) {
if (result === null) {
return null;
}
// Since the customer can provide the credential implementation, we want to weakly verify
// the return type until the type is properly exported.
if (typeof result !== 'object' ||
typeof result.expires_in !== 'number' ||
typeof result.access_token !== 'string') {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CREDENTIAL, 'initializeApp() was called with a credential ' +
'that creates invalid access tokens: ' + JSON.stringify(result));
}
var token = {
accessToken: result.access_token,
expirationTime: Date.now() + (result.expires_in * 1000),
};
var hasAccessTokenChanged = (_this.cachedToken && _this.cachedToken.accessToken !== token.accessToken);
var hasExpirationChanged = (_this.cachedToken && _this.cachedToken.expirationTime !== token.expirationTime);
if (!_this.cachedToken || hasAccessTokenChanged || hasExpirationChanged) {
_this.cachedToken = token;
_this.tokenListeners.forEach(function (listener) {
listener(token.accessToken);
});
}
return token;
});
}
};
/**
* Adds a listener that is called each time a token changes.
*
* @param {function(string)} listener The listener that will be called with each new token.
*/
AuthTokenManager.prototype.addAuthTokenListener = function (listener) {
this.tokenListeners.push(listener);
if (this.cachedToken) {
listener(this.cachedToken.accessToken);
}
};
/**
* Removes a token listener.
*
* @param {function(string)} listener The listener to remove.
*/
AuthTokenManager.prototype.removeAuthTokenListener = function (listener) {
this.tokenListeners = this.tokenListeners.filter(function (other) { return other !== listener; });
};
return AuthTokenManager;
}());
exports.AuthTokenManager = AuthTokenManager;

@@ -1,11 +0,11 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
"use strict";
var jwt = require('jsonwebtoken');
var jwt = require("jsonwebtoken");
// Use untyped import syntax for Node built-ins
var fs = require('fs');
var os = require('os');
var http = require('http');
var path = require('path');
var https = require('https');
var fs = require("fs");
var os = require("os");
var http = require("http");
var path = require("path");
var https = require("https");
var GOOGLE_TOKEN_AUDIENCE = 'https://accounts.google.com/o/oauth2/token';

@@ -47,12 +47,12 @@ var GOOGLE_AUTH_TOKEN_HOST = 'accounts.google.com';

if (typeof this.clientId !== 'string' || !this.clientId) {
throw new Error('Refresh token must contain a "client_id" field');
throw new Error('Refresh token must contain a "client_id" property');
}
else if (typeof this.clientSecret !== 'string' || !this.clientSecret) {
throw new Error('Refresh token must contain a "client_secret" field');
throw new Error('Refresh token must contain a "client_secret" property');
}
else if (typeof this.refreshToken !== 'string' || !this.refreshToken) {
throw new Error('Refresh token must contain a "refresh_token" field');
throw new Error('Refresh token must contain a "refresh_token" property');
}
else if (typeof this.type !== 'string' || !this.type) {
throw new Error('Refresh token must contain a "type" field');
throw new Error('Refresh token must contain a "type" property');
}

@@ -85,7 +85,9 @@ }

/**
* A struct containing the fields necessary to use service-account JSON credentials.
* A struct containing the properties necessary to use service-account JSON credentials.
*/
var Certificate = (function () {
function Certificate(json) {
// TODO: validate Certificate
if (typeof json !== 'object' || json === null) {
throw new Error('Certificate object must be an object.');
}
copyAttr(this, json, 'projectId', 'project_id');

@@ -95,6 +97,6 @@ copyAttr(this, json, 'privateKey', 'private_key');

if (typeof this.privateKey !== 'string' || !this.privateKey) {
throw new Error('Service account key must contain a string "private_key" field');
throw new Error('Certificate object must contain a string "private_key" property');
}
else if (typeof this.clientEmail !== 'string' || !this.clientEmail) {
throw new Error('Service account key must contain a string "client_email" field');
throw new Error('Certificate object must contain a string "client_email" property');
}

@@ -108,3 +110,3 @@ }

// Throw a nicely formed error message if the file contents cannot be parsed
throw new Error('Failed to parse service account key file: ' + error);
throw new Error('Failed to parse certificate key file: ' + error);
}

@@ -111,0 +113,0 @@ };

@@ -1,6 +0,6 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
"use strict";
var auth_1 = require('./auth');
var firebase = require('../default-namespace');
var auth_1 = require("./auth");
var firebase = require("../default-namespace");
/**

@@ -14,11 +14,3 @@ * Factory function that creates a new auth service.

function serviceFactory(app, extendApp) {
var auth = new auth_1.Auth(app);
extendApp({
INTERNAL: {
getToken: auth.INTERNAL.getToken.bind(auth.INTERNAL),
addAuthTokenListener: auth.INTERNAL.addAuthTokenListener.bind(auth.INTERNAL),
removeAuthTokenListener: auth.INTERNAL.removeAuthTokenListener.bind(auth.INTERNAL),
},
});
return auth;
return new auth_1.Auth(app);
}

@@ -25,0 +17,0 @@ /**

@@ -1,7 +0,7 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
"use strict";
var jwt = require('jsonwebtoken');
var jwt = require("jsonwebtoken");
// Use untyped import syntax for Node built-ins
var https = require('https');
var https = require("https");
var ALGORITHM = 'RS256';

@@ -8,0 +8,0 @@ var ONE_HOUR_IN_SECONDS = 60 * 60;

@@ -1,5 +0,5 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
"use strict";
var error_1 = require('../utils/error');
var error_1 = require("../utils/error");
/**

@@ -32,7 +32,7 @@ * Parses a time stamp string or number and returns the corresponding date if valid.

function UserMetadata(response) {
// Creation date is required.
// Creation date should always be available but due to some backend bugs there
// were cases in the past where users did not have creation date properly set.
// This included legacy Firebase migrating project users and some anonymous users.
// These bugs have already been addressed since then.
this.createdAtInternal = parseDate(response.createdAt);
if (!this.createdAtInternal) {
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid metadata response');
}
this.lastSignedInAtInternal = parseDate(response.lastLoginAt);

@@ -39,0 +39,0 @@ }

@@ -1,5 +0,5 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
"use strict";
var firebase_namespace_1 = require('./firebase-namespace');
var firebase_namespace_1 = require("./firebase-namespace");
var firebaseAdmin = new firebase_namespace_1.FirebaseNamespace();

@@ -6,0 +6,0 @@ // Inject a circular default export to allow users to use both:

@@ -1,6 +0,102 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
"use strict";
var deep_copy_1 = require('./utils/deep-copy');
var deep_copy_1 = require("./utils/deep-copy");
var credential_1 = require("./auth/credential");
/**
* Internals of a FirebaseApp instance.
*/
var FirebaseAppInternals = (function () {
function FirebaseAppInternals(credential_) {
this.credential_ = credential_;
this.tokenListeners_ = [];
}
/**
* Gets an auth token for the associated app.
*
* @param {boolean} forceRefresh Whether or not to force a token refresh.
* @return {Promise<Object>} A Promise that will be fulfilled with the current or new token.
*/
FirebaseAppInternals.prototype.getToken = function (forceRefresh) {
var _this = this;
var expired = this.cachedToken_ && this.cachedToken_.expirationTime < Date.now();
if (this.cachedTokenPromise_ && !forceRefresh && !expired) {
return this.cachedTokenPromise_;
}
else {
// this.credential_ may be an external class; resolving it in a promise helps us
// protect against exceptions and upgrades the result to a promise in all cases.
this.cachedTokenPromise_ = Promise.resolve(this.credential_.getAccessToken())
.then(function (result) {
if (result === null) {
return null;
}
// Since the developer can provide the credential implementation, we want to weakly verify
// the return type until the type is properly exported.
if (typeof result !== 'object' ||
typeof result.expires_in !== 'number' ||
typeof result.access_token !== 'string') {
throw new Error("Invalid access token generated: " + JSON.stringify(result) + ". Valid access tokens must " +
'be an object with the "expires_in" (number) and "access_token" (string) properties.');
}
var token = {
accessToken: result.access_token,
expirationTime: Date.now() + (result.expires_in * 1000),
};
var hasAccessTokenChanged = (_this.cachedToken_ && _this.cachedToken_.accessToken !== token.accessToken);
var hasExpirationChanged = (_this.cachedToken_ && _this.cachedToken_.expirationTime !== token.expirationTime);
if (!_this.cachedToken_ || hasAccessTokenChanged || hasExpirationChanged) {
_this.cachedToken_ = token;
_this.tokenListeners_.forEach(function (listener) {
listener(token.accessToken);
});
}
return token;
})
.catch(function (error) {
// Update the cached token promise to avoid caching errors. Set it to resolve with the
// cached token if we have one; otherwise, set it to null.
if (_this.cachedToken_) {
_this.cachedTokenPromise_ = Promise.resolve(_this.cachedToken_);
}
else {
_this.cachedTokenPromise_ = null;
}
var errorMessage = 'Credential implementation provided to initializeApp() via the ' +
'"credential" property failed to fetch a valid Google OAuth2 access token with the ' +
("following error: \"" + error.message + "\".");
if (error.message.indexOf('invalid_grant') !== -1) {
errorMessage += ' The most likely cause of this error is using a certificate key file ' +
'which has been revoked. Make sure the key ID for your key file is still present at ' +
'https://console.firebase.google.com/iam-admin/serviceaccounts/project. If not, generate' +
'a new key file at https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk.';
}
throw new Error(errorMessage);
});
return this.cachedTokenPromise_;
}
};
/**
* Adds a listener that is called each time a token changes.
*
* @param {function(string)} listener The listener that will be called with each new token.
*/
FirebaseAppInternals.prototype.addAuthTokenListener = function (listener) {
this.tokenListeners_.push(listener);
if (this.cachedToken_) {
listener(this.cachedToken_.accessToken);
}
};
/**
* Removes a token listener.
*
* @param {function(string)} listener The listener to remove.
*/
FirebaseAppInternals.prototype.removeAuthTokenListener = function (listener) {
this.tokenListeners_ = this.tokenListeners_.filter(function (other) { return other !== listener; });
};
return FirebaseAppInternals;
}());
exports.FirebaseAppInternals = FirebaseAppInternals;
/**
* Global context object for a collection of services using a shared authentication state.

@@ -30,2 +126,17 @@ */

// TODO(jwenger): NEXT MAJOR RELEASE - throw error if the "credential" property is not specified
if (hasServiceAccount) {
var serviceAccount = this.options_.serviceAccount;
var serviceAccountIsString = (typeof serviceAccount === 'string');
var serviceAccountIsNonNullObject = (typeof serviceAccount === 'object' && serviceAccount !== null);
if (!serviceAccountIsString && !serviceAccountIsNonNullObject) {
errorMessage = 'The "serviceAccount" property must be a string representing the file path to ' +
'a key file or an object representing the contents of a key file.';
}
}
else if (hasCredential) {
var credential = this.options_.credential;
if (typeof credential !== 'object' || credential === null || typeof credential.getAccessToken !== 'function') {
errorMessage = 'The "credential" property must be an object which implements the Credential interface.';
}
}
if (typeof errorMessage !== 'undefined') {

@@ -35,8 +146,11 @@ throw new Error("Invalid Firebase app options passed as the first argument to initializeApp() for the " +

}
// TODO(jwenger): NEXT MAJOR RELEASE - remove "serviceAccount" property deprecation warning
// TODO(jwenger): NEXT MAJOR RELEASE - remove "serviceAccount" property deprecation warning and
// relevant error handling above
if (hasServiceAccount) {
/* tslint:disable:no-console */
console.log('WARNING: The "serviceAccount" property specified in the first argument to initializeApp() ' +
console.warn('WARNING: The "serviceAccount" property specified in the first argument to initializeApp() ' +
'is deprecated and will be removed in the next major version. You should instead use the ' +
'"credential" property.');
/* tslint:enable:no-console */
this.options_.credential = new credential_1.CertCredential(this.options_.serviceAccount);
}

@@ -47,2 +161,13 @@ Object.keys(firebaseInternals_.serviceFactories).forEach(function (serviceName) {

});
this.INTERNAL = new FirebaseAppInternals(this.options_.credential);
// Asynchronously ensure the provided credential can generate OAuth access tokens. We explicitly
// call this here to provide the developer with an error as soon as possible and so that each
// individual service doesn't have to worry about logging this class of error. Because getToken()
// caches tokens, there is no real performance penalty for calling this here.
this.INTERNAL.getToken()
.catch(function (error) {
/* tslint:disable:no-console */
console.error(error);
/* tslint:enable:no-console */
});
}

@@ -49,0 +174,0 @@ /**

@@ -1,7 +0,7 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
"use strict";
var deep_copy_1 = require('./utils/deep-copy');
var firebase_app_1 = require('./firebase-app');
var credential_1 = require('./auth/credential');
var deep_copy_1 = require("./utils/deep-copy");
var firebase_app_1 = require("./firebase-app");
var credential_1 = require("./auth/credential");
var DEFAULT_APP_NAME = '[DEFAULT]';

@@ -11,2 +11,5 @@ var globalAppDefaultCred;

var globalRefreshTokenCreds = {};
/**
* Internals of a FirebaseNamespace instance.
*/
var FirebaseNamespaceInternals = (function () {

@@ -41,3 +44,3 @@ function FirebaseNamespaceInternals(firebase_) {

else {
throw new Error(("Firebase app named \"" + appName + "\" already exists. This means you called initializeApp() ") +
throw new Error("Firebase app named \"" + appName + "\" already exists. This means you called initializeApp() " +
'more than once with the same app name as the second argument. Make sure you provide a ' +

@@ -193,3 +196,3 @@ 'unique name every time you call initializeApp().');

this.credential = firebaseCredential;
this.SDK_VERSION = '4.0.4';
this.SDK_VERSION = '4.0.5';
/* tslint:disable */

@@ -196,0 +199,0 @@ // TODO(jwenger): Database is the only consumer of firebase.Promise. We should update it to use

@@ -1,3 +0,3 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
"use strict";

@@ -1,4 +0,223 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
import * as firebase from './default-namespace';
export = firebase;
declare namespace admin {
class Promise<T> extends Promise_Instance<T> {
static all(values: admin.Promise<any>[]): admin.Promise<any[]>;
static reject(error: Error): admin.Promise<any>;
static resolve<T>(value?: T): admin.Promise<T>;
}
class Promise_Instance<T> implements admin.Thenable<any> {
constructor(resolver: (a?: (a: T) => undefined, b?: (a: Error) => undefined) => any);
catch(onReject?: (a: Error) => any): admin.Thenable<any>;
then(onResolve?: (a: T) => any, onReject?: (a: Error) => any): admin.Promise<any>;
}
interface Thenable<T> {
catch(onReject?: (a: Error) => any): admin.Thenable<any>;
then(onResolve?: (a: T) => any, onReject?: (a: Error) => any): admin.Thenable<any>;
}
interface ServiceAccount {
projectId?: string;
clientEmail?: string;
privateKey?: string;
}
interface GoogleOAuthAccessToken {
access_token: string;
expires_in: number;
}
interface AppOptions {
databaseURL?: string;
credential?: admin.credential.Credential;
serviceAccount?: string|admin.ServiceAccount;
databaseAuthVariableOverride?: Object;
}
var SDK_VERSION: string;
var apps: (admin.app.App|null)[];
function app(name?: string): admin.app.App;
function auth(app?: admin.app.App): admin.auth.Auth;
function database(app?: admin.app.App): admin.database.Database;
function initializeApp(options: admin.AppOptions, name?: string): admin.app.App;
}
declare namespace admin.app {
interface App {
name: string;
options: admin.AppOptions;
auth(): admin.auth.Auth;
database(): admin.database.Database;
delete(): admin.Promise<undefined>;
}
}
declare namespace admin.auth {
interface UserMetadata {
lastSignedInAt: Date;
createdAt: Date;
}
interface UserInfo {
uid: string;
displayName: string;
email: string;
photoURL: string;
providerId: string;
}
interface UserRecord {
uid: string;
email: string;
emailVerified: boolean;
displayName: string;
photoURL: string;
disabled: boolean;
metadata: admin.auth.UserMetadata;
providerData: admin.auth.UserInfo[];
}
interface DecodedIdToken {
uid: string;
sub: string;
[other: string]: any;
}
interface Auth {
app: admin.app.App;
createCustomToken(uid: string, developerClaims?: Object): admin.Promise<string>;
createUser(properties: Object): admin.Promise<admin.auth.UserRecord>;
deleteUser(uid: string): admin.Promise<undefined>;
getUser(uid: string): admin.Promise<admin.auth.UserRecord>;
getUserByEmail(email: string): admin.Promise<admin.auth.UserRecord>;
updateUser(uid: string, properties: Object): admin.Promise<admin.auth.UserRecord>;
verifyIdToken(idToken: string): admin.Promise<DecodedIdToken>;
}
}
declare namespace admin.credential {
interface Credential {
getAccessToken(): admin.Promise<admin.GoogleOAuthAccessToken>;
}
function applicationDefault(): admin.credential.Credential;
function cert(serviceAccountPathOrObject: string|admin.ServiceAccount): admin.credential.Credential;
function refreshToken(refreshTokenPathOrObject: string|Object): admin.credential.Credential;
}
declare namespace admin.database {
interface Database {
app: admin.app.App;
goOffline(): undefined;
goOnline(): undefined;
ref(path?: string): admin.database.Reference;
refFromURL(url: string): admin.database.Reference;
}
interface DataSnapshot {
key: string|null;
ref: admin.database.Reference;
child(path: string): admin.database.DataSnapshot;
exists(): boolean;
exportVal(): any;
forEach(action: (a: admin.database.DataSnapshot) => boolean): boolean;
getPriority(): string|number|null;
hasChild(path: string): boolean;
hasChildren(): boolean;
numChildren(): number;
val(): any;
}
interface OnDisconnect {
cancel(onComplete?: (a: Error|null) => any): admin.Promise<undefined>;
remove(onComplete?: (a: Error|null) => any): admin.Promise<undefined>;
set(value: any, onComplete?: (a: Error|null) => any): admin.Promise<undefined>;
setWithPriority(
value: any,
priority: number|string|null,
onComplete?: (a: Error|null) => any
): admin.Promise<undefined>;
update(values: Object, onComplete?: (a: Error|null) => any): admin.Promise<undefined>;
}
interface Query {
ref: admin.database.Reference;
endAt(value: number|string|boolean|null, key?: string): admin.database.Query;
equalTo(value: number|string|boolean|null, key?: string): admin.database.Query;
isEqual(other: admin.database.Query|null): boolean;
limitToFirst(limit: number): admin.database.Query;
limitToLast(limit: number): admin.database.Query;
off(
eventType?: string,
callback?: (a: admin.database.DataSnapshot, b?: string|null) => any,
context?: Object|null
): undefined;
on(
eventType: string,
callback: (a: admin.database.DataSnapshot|null, b?: string) => any,
cancelCallbackOrContext?: Object|null,
context?: Object|null
): (a: admin.database.DataSnapshot|null, b?: string) => any;
once(
eventType: string,
successCallback?: (a: admin.database.DataSnapshot, b?: string) => any,
failureCallbackOrContext?: Object|null,
context?: Object|null
): admin.Promise<any>;
orderByChild(path: string): admin.database.Query;
orderByKey(): admin.database.Query;
orderByPriority(): admin.database.Query;
orderByValue(): admin.database.Query;
startAt(value: number|string|boolean|null, key?: string): admin.database.Query;
toString(): string;
}
interface Reference extends admin.database.Query {
key: string|null;
parent: admin.database.Reference|null;
root: admin.database.Reference;
child(path: string): admin.database.Reference;
onDisconnect(): admin.database.OnDisconnect;
push(value?: any, onComplete?: (a: Error|null) => any): admin.database.ThenableReference;
remove(onComplete?: (a: Error|null) => any): admin.Promise<undefined>;
set(value: any, onComplete?: (a: Error|null) => any): admin.Promise<undefined>;
setPriority(
priority: string|number|null,
onComplete: (a: Error|null) => any
): admin.Promise<undefined>;
setWithPriority(
newVal: any, newPriority: string|number|null,
onComplete?: (a: Error|null) => any
): admin.Promise<undefined>;
transaction(
transactionUpdate: (a: any) => any,
onComplete?: (a: Error|null, b: boolean, c: admin.database.DataSnapshot|null) => any,
applyLocally?: boolean
): admin.Promise<{
committed: boolean,
snapshot: admin.database.DataSnapshot|null
}>;
update(values: Object, onComplete?: (a: Error|null) => any): admin.Promise<undefined>;
}
interface ThenableReference extends admin.database.Reference, admin.Thenable<any> {}
function enableLogging(logger?: boolean|((message: string) => any), persistent?: boolean): any;
}
declare namespace admin.database.ServerValue {
var TIMESTAMP: number;
}
declare module 'firebase-admin' {
export = admin;
}

@@ -1,6 +0,6 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
"use strict";
var firebase = require('./default-namespace');
var register_auth_1 = require('./auth/register-auth');
var firebase = require("./default-namespace");
var register_auth_1 = require("./auth/register-auth");
// Register the database service

@@ -7,0 +7,0 @@ // For historical reasons, the database code is included as minified code and registers itself

@@ -1,2 +0,2 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */

@@ -9,4 +9,4 @@ "use strict";

};
var deep_copy_1 = require('./deep-copy');
var https = require('https');
var deep_copy_1 = require("./deep-copy");
var https = require("https");
/**

@@ -92,5 +92,6 @@ * Base class for handling HTTP requests.

__extends(SignedApiRequestHandler, _super);
function SignedApiRequestHandler(credential) {
_super.call(this);
this.credential = credential;
function SignedApiRequestHandler(app_) {
var _this = _super.call(this) || this;
_this.app_ = app_;
return _this;
}

@@ -111,3 +112,3 @@ /**

var ancestorSendRequest = _super.prototype.sendRequest;
return this.credential.getAccessToken().then(function (accessTokenObj) {
return this.app_.INTERNAL.getToken().then(function (accessTokenObj) {
if (accessTokenObj == null) {

@@ -120,3 +121,3 @@ return Promise.reject('Unable to fetch Google OAuth2 access token. ' +

var authorizationHeaderKey = 'Authorization';
headersCopy[authorizationHeaderKey] = 'Bearer ' + accessTokenObj.access_token;
headersCopy[authorizationHeaderKey] = 'Bearer ' + accessTokenObj.accessToken;
return ancestorSendRequest(host, port, path, httpMethod, data, headersCopy, timeout);

@@ -123,0 +124,0 @@ });

@@ -1,2 +0,2 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */

@@ -3,0 +3,0 @@ "use strict";

@@ -1,2 +0,2 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */

@@ -9,3 +9,3 @@ "use strict";

};
var deep_copy_1 = require('../utils/deep-copy');
var deep_copy_1 = require("../utils/deep-copy");
/**

@@ -20,4 +20,10 @@ * Firebase error code structure. This extends Error.

function FirebaseError(errorInfo) {
_super.call(this, errorInfo.message);
this.errorInfo = errorInfo;
var _this = _super.call(this, errorInfo.message) || this;
_this.errorInfo = errorInfo;
/* tslint:disable:max-line-length */
// Set the prototype explicitly. See the following link for more details:
// https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
/* tslint:enable:max-line-length */
_this.__proto__ = FirebaseError.prototype;
return _this;
}

@@ -62,3 +68,3 @@ Object.defineProperty(FirebaseError.prototype, "code", {

// Override default message if custom message provided.
_super.call(this, { code: 'auth/' + info.code, message: message || info.message });
return _super.call(this, { code: 'auth/' + info.code, message: message || info.message }) || this;
}

@@ -71,5 +77,6 @@ /**

* if not provided.
* @param {Object} [rawServerResponse] The error's raw server response.
* @return {FirebaseAuthError} The corresponding developer facing error.
*/
FirebaseAuthError.fromServerError = function (serverErrorCode, message) {
FirebaseAuthError.fromServerError = function (serverErrorCode, message, rawServerResponse) {
// If not found, default to internal error.

@@ -79,2 +86,9 @@ var clientCodeKey = AUTH_SERVER_TO_CLIENT_CODE[serverErrorCode] || 'INTERNAL_ERROR';

error.message = message || error.message;
if (clientCodeKey === 'INTERNAL_ERROR' && typeof rawServerResponse !== 'undefined') {
try {
error.message += " Raw server response: " + JSON.stringify(rawServerResponse);
}
catch (e) {
}
}
return new FirebaseAuthError(error);

@@ -89,74 +103,77 @@ };

}
AuthClientErrorCode.INVALID_ARGUMENT = {
code: 'argument-error',
message: 'Invalid argument provided.',
};
AuthClientErrorCode.EMAIL_ALREADY_EXISTS = {
code: 'email-already-exists',
message: 'The email address is already in use by another account.',
};
AuthClientErrorCode.INTERNAL_ERROR = {
code: 'internal-error',
message: 'An internal error has occurred.',
};
AuthClientErrorCode.INVALID_CREDENTIAL = {
code: 'invalid-credential',
message: 'Invalid credential object provided.',
};
AuthClientErrorCode.INVALID_DISABLED_FIELD = {
code: 'invalid-disabled-field',
message: 'The disabled field must be a boolean.',
};
AuthClientErrorCode.INVALID_DISPLAY_NAME = {
code: 'invalid-display-name',
message: 'The displayName field must be a valid string.',
};
AuthClientErrorCode.INVALID_EMAIL_VERIFIED = {
code: 'invalid-email-verified',
message: 'The emailVerified field must be a boolean.',
};
AuthClientErrorCode.INVALID_EMAIL = {
code: 'invalid-email',
message: 'The email address is improperly formatted.',
};
AuthClientErrorCode.INVALID_PASSWORD = {
code: 'invalid-password',
message: 'The password must be a string with at least 6 characters.',
};
AuthClientErrorCode.INVALID_PHOTO_URL = {
code: 'invalid-photo-url',
message: 'The photoURL field must be a valid URL.',
};
AuthClientErrorCode.INVALID_SERVICE_ACCOUNT = {
code: 'invalid-service-account',
message: 'The service account provided is invalid.',
};
AuthClientErrorCode.INVALID_UID = {
code: 'invalid-uid',
message: 'The uid must be a non-empty string with at most 128 characters.',
};
AuthClientErrorCode.MISSING_UID = {
code: 'missing-uid',
message: 'A uid identifier is required for the current operation.',
};
AuthClientErrorCode.OPERATION_NOT_ALLOWED = {
code: 'operation-not-allowed',
message: 'The given sign-in provider is disabled for this Firebase project. ' +
'Enable it in the Firebase console, under the sign-in method tab of the ' +
'Auth section.',
};
AuthClientErrorCode.PROJECT_NOT_FOUND = {
code: 'project-not-found',
message: 'No Firebase project was found for the provided credential.',
};
AuthClientErrorCode.UID_ALREADY_EXISTS = {
code: 'uid-already-exists',
message: 'The user with the provided uid already exists.',
};
AuthClientErrorCode.USER_NOT_FOUND = {
code: 'user-not-found',
message: 'There is no user record corresponding to the provided identifier.',
};
return AuthClientErrorCode;
}());
AuthClientErrorCode.INVALID_ARGUMENT = {
code: 'argument-error',
message: 'Invalid argument provided.',
};
AuthClientErrorCode.EMAIL_ALREADY_EXISTS = {
code: 'email-already-exists',
message: 'The email address is already in use by another account.',
};
AuthClientErrorCode.INTERNAL_ERROR = {
code: 'internal-error',
message: 'An internal error has occurred.',
};
AuthClientErrorCode.INVALID_CREDENTIAL = {
code: 'invalid-credential',
message: 'Invalid credential object provided.',
};
AuthClientErrorCode.INVALID_DISABLED_FIELD = {
code: 'invalid-disabled-field',
message: 'The disabled field must be a boolean.',
};
AuthClientErrorCode.INVALID_DISPLAY_NAME = {
code: 'invalid-display-name',
message: 'The displayName field must be a valid string.',
};
AuthClientErrorCode.INVALID_EMAIL_VERIFIED = {
code: 'invalid-email-verified',
message: 'The emailVerified field must be a boolean.',
};
AuthClientErrorCode.INVALID_EMAIL = {
code: 'invalid-email',
message: 'The email address is improperly formatted.',
};
AuthClientErrorCode.INVALID_PASSWORD = {
code: 'invalid-password',
message: 'The password must be a string with at least 6 characters.',
};
AuthClientErrorCode.INVALID_PHOTO_URL = {
code: 'invalid-photo-url',
message: 'The photoURL field must be a valid URL.',
};
AuthClientErrorCode.INVALID_UID = {
code: 'invalid-uid',
message: 'The uid must be a non-empty string with at most 128 characters.',
};
AuthClientErrorCode.MISSING_UID = {
code: 'missing-uid',
message: 'A uid identifier is required for the current operation.',
};
AuthClientErrorCode.OPERATION_NOT_ALLOWED = {
code: 'operation-not-allowed',
message: 'The given sign-in provider is disabled for this Firebase project. ' +
'Enable it in the Firebase console, under the sign-in method tab of the ' +
'Auth section.',
};
AuthClientErrorCode.PROJECT_NOT_FOUND = {
code: 'project-not-found',
message: 'No Firebase project was found for the provided credential.',
};
AuthClientErrorCode.INSUFFICIENT_PERMISSION = {
code: 'insufficient-permission',
message: 'Credential implementation provided to initializeApp() via the "credential" property ' +
'has insufficient permission to access the requested resource. See ' +
'https://firebase.google.com/docs/admin/setup for details on how to authenticate this SDK ' +
'with appropriate permissions.',
};
AuthClientErrorCode.UID_ALREADY_EXISTS = {
code: 'uid-already-exists',
message: 'The user with the provided uid already exists.',
};
AuthClientErrorCode.USER_NOT_FOUND = {
code: 'user-not-found',
message: 'There is no user record corresponding to the provided identifier.',
};
exports.AuthClientErrorCode = AuthClientErrorCode;

@@ -168,2 +185,4 @@ ;

CONFIGURATION_NOT_FOUND: 'PROJECT_NOT_FOUND',
// Provided credential has insufficient permissions.
INSUFFICIENT_PERMISSION: 'INSUFFICIENT_PERMISSION',
// uploadAccount provides an email that already exists.

@@ -170,0 +189,0 @@ DUPLICATE_EMAIL: 'EMAIL_EXISTS',

@@ -1,5 +0,5 @@

/*! firebase-admin v4.0.4
/*! firebase-admin v4.0.5
https://firebase.google.com/terms/ */
"use strict";
var url = require('url');
var url = require("url");
/**

@@ -6,0 +6,0 @@ * Validates that a string is a valid Firebase Auth uid.

{
"name": "firebase-admin",
"version": "4.0.4",
"version": "4.0.5",
"dependencies": {
"@types/jsonwebtoken": {
"version": "7.1.33",
"version": "7.2.0",
"from": "@types/jsonwebtoken@>=7.1.33 <8.0.0",
"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-7.1.33.tgz"
"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-7.2.0.tgz"
},
"@types/node": {
"version": "0.0.2",
"version": "7.0.0",
"from": "@types/node@*",
"resolved": "https://registry.npmjs.org/@types/node/-/node-0.0.2.tgz"
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.0.tgz"
},

@@ -15,0 +15,0 @@ "base64url": {

{
"name": "firebase-admin",
"version": "4.0.4",
"version": "4.0.5",
"description": "Firebase admin SDK for Node.js",

@@ -5,0 +5,0 @@ "author": "Firebase (https://firebase.google.com/)",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc