firebase-admin
Advanced tools
Comparing version 4.0.5 to 4.0.6
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -7,2 +7,3 @@ "use strict"; | ||
var error_1 = require("../utils/error"); | ||
var error_2 = require("../utils/error"); | ||
var api_request_1 = require("../utils/api-request"); | ||
@@ -19,3 +20,3 @@ /** Firebase Auth backend host. */ | ||
}; | ||
/** Firebase Auth request timeout duration in seconds. */ | ||
/** Firebase Auth request timeout duration in milliseconds. */ | ||
var FIREBASE_AUTH_TIMEOUT = 10000; | ||
@@ -54,3 +55,3 @@ /** | ||
typeof request.displayName !== 'string') { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_DISPLAY_NAME); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INVALID_DISPLAY_NAME); | ||
} | ||
@@ -60,7 +61,7 @@ if (typeof request.localId !== 'undefined' && !validator.isUid(request.localId)) { | ||
// uid externally. So the error message should use the client facing name. | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_UID); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INVALID_UID); | ||
} | ||
// email should be a string and a valid email. | ||
if (typeof request.email !== 'undefined' && !validator.isEmail(request.email)) { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_EMAIL); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INVALID_EMAIL); | ||
} | ||
@@ -70,3 +71,3 @@ // password should be a string and a minimum of 6 chars. | ||
!validator.isPassword(request.password)) { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_PASSWORD); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INVALID_PASSWORD); | ||
} | ||
@@ -78,3 +79,3 @@ // rawPassword should be a string and a minimum of 6 chars. | ||
// password externally. So the error message should use the client facing name. | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_PASSWORD); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INVALID_PASSWORD); | ||
} | ||
@@ -84,3 +85,3 @@ // emailVerified should be a boolean. | ||
typeof request.emailVerified !== 'boolean') { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_EMAIL_VERIFIED); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INVALID_EMAIL_VERIFIED); | ||
} | ||
@@ -92,3 +93,3 @@ // photoUrl should be a URL. | ||
// photoURL externally. So the error message should use the client facing name. | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_PHOTO_URL); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INVALID_PHOTO_URL); | ||
} | ||
@@ -98,3 +99,3 @@ // disabled should be a boolean. | ||
typeof request.disabled !== 'boolean') { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_DISABLED_FIELD); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INVALID_DISABLED_FIELD); | ||
} | ||
@@ -106,3 +107,3 @@ // disableUser should be a boolean. | ||
// disabled externally. So the error message should use the client facing name. | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_DISABLED_FIELD); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INVALID_DISABLED_FIELD); | ||
} | ||
@@ -115,3 +116,3 @@ } | ||
if (!request.localId && !request.email) { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Server request is missing user identifier'); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Server request is missing user identifier'); | ||
} | ||
@@ -121,3 +122,3 @@ }) | ||
if (!response.users) { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.USER_NOT_FOUND); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.USER_NOT_FOUND); | ||
} | ||
@@ -129,3 +130,3 @@ }); | ||
if (!request.localId) { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Server request is missing user identifier'); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Server request is missing user identifier'); | ||
} | ||
@@ -138,3 +139,3 @@ }); | ||
if (typeof request.localId === 'undefined') { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Server request is missing user identifier'); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Server request is missing user identifier'); | ||
} | ||
@@ -146,3 +147,3 @@ validateCreateEditRequest(request); | ||
if (!response.localId) { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.USER_NOT_FOUND); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.USER_NOT_FOUND); | ||
} | ||
@@ -173,3 +174,3 @@ }); | ||
!request.users.length) { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid uploadAccount request. No users provider.'); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid uploadAccount request. No users provider.'); | ||
} | ||
@@ -181,3 +182,3 @@ // Validate each user within users. | ||
if (typeof user.localId === 'undefined') { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Server request is missing user identifier'); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Server request is missing user identifier'); | ||
} | ||
@@ -198,9 +199,9 @@ // Validate user. | ||
// Duplicate user error. | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.UID_ALREADY_EXISTS, response.error[0].message); | ||
throw new error_2.FirebaseAuthError(error_2.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_2.FirebaseAuthError(error_2.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); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: ' + response.error[0].message); | ||
} | ||
@@ -217,3 +218,3 @@ }); | ||
if (typeof request.localId !== 'undefined') { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: User identifier must not be specified'); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: User identifier must not be specified'); | ||
} | ||
@@ -225,3 +226,3 @@ validateCreateEditRequest(request); | ||
if (!response.localId) { | ||
throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Unable to create new user'); | ||
throw new error_2.FirebaseAuthError(error_2.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Unable to create new user'); | ||
} | ||
@@ -231,7 +232,8 @@ }); | ||
* Class that provides mechanism to send requests to the Firebase Auth backend endpoints. | ||
* | ||
* @param {Credential} credential The service account credential used to sign HTTP requests. | ||
* @constructor | ||
*/ | ||
var FirebaseAuthRequestHandler = (function () { | ||
/** | ||
* @param {FirebaseApp} app The app used to fetch access tokens to sign API requests. | ||
* @constructor | ||
*/ | ||
function FirebaseAuthRequestHandler(app) { | ||
@@ -412,3 +414,3 @@ this.host = FIREBASE_AUTH_HOST; | ||
if (errorCode) { | ||
throw error_1.FirebaseAuthError.fromServerError(errorCode, /* message */ undefined, response); | ||
throw error_2.FirebaseAuthError.fromServerError(errorCode, /* message */ undefined, response); | ||
} | ||
@@ -420,2 +422,9 @@ // Validate response. | ||
return response; | ||
}) | ||
.catch(function (error) { | ||
if (error instanceof error_1.FirebaseError) { | ||
throw error; | ||
} | ||
var errorCode = FirebaseAuthRequestHandler.getErrorCode(error) || 'INTERNAL_ERROR'; | ||
throw error_2.FirebaseAuthError.fromServerError(errorCode, /* message */ undefined, error); | ||
}); | ||
@@ -422,0 +431,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -28,7 +28,8 @@ "use strict"; | ||
* Auth service bound to the provided app. | ||
* | ||
* @param {Object} app The app for this auth service | ||
* @constructor | ||
*/ | ||
var Auth = (function () { | ||
/** | ||
* @param {Object} app The app for this Auth service. | ||
* @constructor | ||
*/ | ||
function Auth(app) { | ||
@@ -53,2 +54,7 @@ this.INTERNAL = new AuthInternals(); | ||
Object.defineProperty(Auth.prototype, "app", { | ||
/** | ||
* Returns the app associated with this Auth instance. | ||
* | ||
* @return {FirebaseApp} The app associated with this Auth instance. | ||
*/ | ||
get: function () { | ||
@@ -81,3 +87,3 @@ return this.app_; | ||
* @param {string} idToken The JWT to verify. | ||
* @return {Object} A Promise that will be fulfilled after a successful verification. | ||
* @return {Promise<Object>} A Promise that will be fulfilled after a successful verification. | ||
*/ | ||
@@ -84,0 +90,0 @@ Auth.prototype.verifyIdToken = function (idToken) { |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -186,5 +186,5 @@ "use strict"; | ||
scope: [ | ||
'https://www.googleapis.com/auth/userinfo.email', | ||
'https://www.googleapis.com/auth/firebase.database', | ||
'https://www.googleapis.com/auth/identitytoolkit', | ||
'https://www.googleapis.com/auth/userinfo.email', | ||
].join(' '), | ||
@@ -191,0 +191,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -7,7 +7,8 @@ "use strict"; | ||
/** | ||
* Factory function that creates a new auth service. | ||
* @param {Object} app The app for this service | ||
* @param {function(Object)} extendApp An extend function to extend the app | ||
* namespace | ||
* @return {Auth} The auth service for the specified app. | ||
* Factory function that creates a new Auth service. | ||
* | ||
* @param {Object} app The app for this service. | ||
* @param {function(Object)} extendApp An extend function to extend the app namespace. | ||
* | ||
* @return {Auth} The Auth service for the specified app. | ||
*/ | ||
@@ -18,3 +19,3 @@ function serviceFactory(app, extendApp) { | ||
/** | ||
* Handles app life-cycle events. Initializes auth so listerners and getToken() functions are | ||
* Handles app life-cycle events. Initializes auth so listeners and getToken() functions are | ||
* available to other services immediately. | ||
@@ -21,0 +22,0 @@ * |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -193,4 +193,8 @@ "use strict"; | ||
function FirebaseNamespace() { | ||
// Hack to prevent Babel from modifying the object returned as the default admin namespace. | ||
/* tslint:disable:variable-name */ | ||
this.__esModule = true; | ||
/* tslint:enable:variable-name */ | ||
this.credential = firebaseCredential; | ||
this.SDK_VERSION = '4.0.5'; | ||
this.SDK_VERSION = '4.0.6'; | ||
/* tslint:disable */ | ||
@@ -197,0 +201,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.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
"use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ declare namespace admin { |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -6,3 +6,3 @@ "use strict"; | ||
var register_auth_1 = require("./auth/register-auth"); | ||
// Register the database service | ||
// Register the Database service | ||
// For historical reasons, the database code is included as minified code and registers itself | ||
@@ -13,4 +13,4 @@ // as a side effect of requiring the file. | ||
/* tslint:enable:no-var-requires */ | ||
// Register the auth service | ||
// Register the Auth service | ||
register_auth_1.default(); | ||
module.exports = firebase; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -10,2 +10,3 @@ "use strict"; | ||
var deep_copy_1 = require("./deep-copy"); | ||
var error_1 = require("./error"); | ||
var https = require("https"); | ||
@@ -53,8 +54,34 @@ /** | ||
res.on('end', function () { | ||
try { | ||
var json = JSON.parse(Buffer.concat(buffers).toString()); | ||
resolve(json); | ||
var response = Buffer.concat(buffers).toString(); | ||
var statusCode = res.statusCode || 200; | ||
var responseHeaders = res.headers || {}; | ||
var contentType = responseHeaders['content-type'] || 'application/json'; | ||
if (contentType.indexOf('text/html') !== -1) { | ||
// Text response | ||
if (statusCode >= 200 && statusCode < 300) { | ||
resolve(response); | ||
} | ||
else { | ||
reject(response); | ||
} | ||
} | ||
catch (err) { | ||
reject('Failed to parse response data: ' + err.toString()); | ||
else { | ||
// JSON response | ||
try { | ||
var json = JSON.parse(response); | ||
if (statusCode >= 200 && statusCode < 300) { | ||
resolve(json); | ||
} | ||
else { | ||
reject(json); | ||
} | ||
} | ||
catch (error) { | ||
var parsingError = new error_1.FirebaseError({ | ||
code: 'unable-to-parse-response', | ||
message: "Failed to parse response data: \"" + error.toString() + "\". Raw server " + | ||
("response: \"" + response + ".\""), | ||
}); | ||
reject(parsingError); | ||
} | ||
} | ||
@@ -69,7 +96,17 @@ }); | ||
req.abort(); | ||
reject(new Error(host + ' network timeout. Try again.')); | ||
var networkTimeoutError = new error_1.FirebaseError({ | ||
code: 'network-timeout', | ||
message: host + " network timeout. Please try again.", | ||
}); | ||
reject(networkTimeoutError); | ||
}); | ||
}); | ||
} | ||
req.on('error', reject); | ||
req.on('error', function (error) { | ||
var networkRequestError = new error_1.FirebaseError({ | ||
code: 'network-error', | ||
message: "A network request error has occurred: " + (error && error.message), | ||
}); | ||
reject(networkRequestError); | ||
}); | ||
if (requestData) { | ||
@@ -141,3 +178,3 @@ req.write(requestData); | ||
if (!endpoint) { | ||
throw new Error('Unspecified API settings endpoint'); | ||
throw new Error("INTERNAL ASSERT FAILED: Unspecified API settings endpoint: " + endpoint); | ||
} | ||
@@ -144,0 +181,0 @@ this.setRequestValidator(null) |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -69,3 +69,3 @@ "use strict"; | ||
/** | ||
* Creates the developer facing error corresponding to the backend error code. | ||
* Creates the developer-facing error corresponding to the backend error code. | ||
* | ||
@@ -76,3 +76,3 @@ * @param {string} serverErrorCode The server error code. | ||
* @param {Object} [rawServerResponse] The error's raw server response. | ||
* @return {FirebaseAuthError} The corresponding developer facing error. | ||
* @return {FirebaseAuthError} The corresponding developer-facing error. | ||
*/ | ||
@@ -86,3 +86,3 @@ FirebaseAuthError.fromServerError = function (serverErrorCode, message, rawServerResponse) { | ||
try { | ||
error.message += " Raw server response: " + JSON.stringify(rawServerResponse); | ||
error.message += " Raw server response: \"" + JSON.stringify(rawServerResponse) + "\""; | ||
} | ||
@@ -97,3 +97,5 @@ catch (e) { | ||
exports.FirebaseAuthError = FirebaseAuthError; | ||
/** @const {TODO} Auth client error codes and their default messages. */ | ||
/** | ||
* Auth client error codes and their default messages. | ||
*/ | ||
var AuthClientErrorCode = (function () { | ||
@@ -100,0 +102,0 @@ function AuthClientErrorCode() { |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.0.5 | ||
/*! firebase-admin v4.0.6 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
{ | ||
"name": "firebase-admin", | ||
"version": "4.0.5", | ||
"version": "4.0.6", | ||
"dependencies": { | ||
@@ -11,5 +11,5 @@ "@types/jsonwebtoken": { | ||
"@types/node": { | ||
"version": "7.0.0", | ||
"version": "7.0.4", | ||
"from": "@types/node@*", | ||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.0.tgz" | ||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.4.tgz" | ||
}, | ||
@@ -16,0 +16,0 @@ "base64url": { |
{ | ||
"name": "firebase-admin", | ||
"version": "4.0.5", | ||
"version": "4.0.6", | ||
"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
241057
3376