firebase-admin
Advanced tools
Comparing version 4.1.2 to 4.1.3
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -19,3 +19,3 @@ "use strict"; | ||
'Content-Type': 'application/json', | ||
'X-Client-Version': 'Node/Admin/4.1.2', | ||
'X-Client-Version': 'Node/Admin/4.1.3', | ||
}; | ||
@@ -22,0 +22,0 @@ /** Firebase Auth request timeout duration in milliseconds. */ |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -12,2 +12,3 @@ "use strict"; | ||
var https = require("https"); | ||
var error_1 = require("../utils/error"); | ||
var GOOGLE_TOKEN_AUDIENCE = 'https://accounts.google.com/o/oauth2/token'; | ||
@@ -48,14 +49,18 @@ var GOOGLE_AUTH_TOKEN_HOST = 'accounts.google.com'; | ||
copyAttr(this, json, 'type', 'type'); | ||
var errorMessage; | ||
if (typeof this.clientId !== 'string' || !this.clientId) { | ||
throw new Error('Refresh token must contain a "client_id" property'); | ||
errorMessage = '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" property'); | ||
errorMessage = '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" property'); | ||
errorMessage = '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" property'); | ||
errorMessage = 'Refresh token must contain a "type" property.'; | ||
} | ||
if (typeof errorMessage !== 'undefined') { | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, errorMessage); | ||
} | ||
} | ||
@@ -80,3 +85,3 @@ /* | ||
// Throw a nicely formed error message if the file contents cannot be parsed | ||
throw new Error('Failed to parse refresh token file: ' + error); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse refresh token file: ' + error); | ||
} | ||
@@ -93,3 +98,3 @@ }; | ||
if (typeof json !== 'object' || json === null) { | ||
throw new Error('Certificate object must be an object.'); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Certificate object must be an object.'); | ||
} | ||
@@ -99,8 +104,12 @@ copyAttr(this, json, 'projectId', 'project_id'); | ||
copyAttr(this, json, 'clientEmail', 'client_email'); | ||
var errorMessage; | ||
if (typeof this.privateKey !== 'string' || !this.privateKey) { | ||
throw new Error('Certificate object must contain a string "private_key" property'); | ||
errorMessage = 'Certificate object must contain a string "private_key" property.'; | ||
} | ||
else if (typeof this.clientEmail !== 'string' || !this.clientEmail) { | ||
throw new Error('Certificate object must contain a string "client_email" property'); | ||
errorMessage = 'Certificate object must contain a string "client_email" property.'; | ||
} | ||
if (typeof errorMessage !== 'undefined') { | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, errorMessage); | ||
} | ||
} | ||
@@ -110,3 +119,3 @@ Certificate.fromPath = function (path) { | ||
if (typeof path !== 'string') { | ||
throw new Error('Failed to parse certificate key file: TypeError: path must be a string'); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse certificate key file: TypeError: path must be a string'); | ||
} | ||
@@ -118,3 +127,3 @@ try { | ||
// Throw a nicely formed error message if the file contents cannot be parsed | ||
throw new Error('Failed to parse certificate key file: ' + error); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse certificate key file: ' + error); | ||
} | ||
@@ -138,10 +147,10 @@ }; | ||
if (json.error) { | ||
var msg = 'Error fetching access token: ' + json.error; | ||
var errorMessage = 'Error fetching access token: ' + json.error; | ||
if (json.error_description) { | ||
msg += ' (' + json.error_description + ')'; | ||
errorMessage += ' (' + json.error_description + ')'; | ||
} | ||
reject(new Error(msg)); | ||
reject(new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, errorMessage)); | ||
} | ||
else if (!json.access_token || !json.expires_in) { | ||
reject(new Error('Unexpected response from server')); | ||
reject(new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, "Unexpected response while fetching access token: " + JSON.stringify(json))); | ||
} | ||
@@ -153,3 +162,3 @@ else { | ||
catch (err) { | ||
reject(err); | ||
reject(new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, "Failed to parse access token response: " + err.toString())); | ||
} | ||
@@ -156,0 +165,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -155,10 +155,9 @@ "use strict"; | ||
if (typeof errorMessage !== 'undefined') { | ||
return Promise.reject(new Error(errorMessage)); | ||
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, errorMessage)); | ||
} | ||
return this.fetchPublicKeys_().then(function (publicKeys) { | ||
if (!publicKeys.hasOwnProperty(header.kid)) { | ||
errorMessage = 'Firebase ID token has "kid" claim which does not correspond to a known ' + | ||
'public key. Most likely the ID token is expired, so get a fresh token from your client ' + | ||
'app and try again.' + verifyIdTokenDocsMessage; | ||
return Promise.reject(new Error(errorMessage)); | ||
return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'Firebase ID token has "kid" claim which does not correspond to a known public key. ' + | ||
'Most likely the ID token is expired, so get a fresh token from your client app and ' + | ||
'try again.' + verifyIdTokenDocsMessage)); | ||
} | ||
@@ -177,3 +176,3 @@ return new Promise(function (resolve, reject) { | ||
} | ||
reject(new Error(errorMessage)); | ||
return reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, errorMessage)); | ||
} | ||
@@ -229,3 +228,3 @@ else { | ||
} | ||
reject(new Error(errorMessage)); | ||
reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, errorMessage)); | ||
} | ||
@@ -232,0 +231,0 @@ else { |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,7 +0,9 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var validator = require("./utils/validator"); | ||
var deep_copy_1 = require("./utils/deep-copy"); | ||
var credential_1 = require("./auth/credential"); | ||
var error_1 = require("./utils/error"); | ||
/** | ||
@@ -32,12 +34,10 @@ * Internals of a FirebaseApp instance. | ||
.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' || | ||
if (!validator.isNonNullObject(result) || | ||
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.'); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, "Invalid access token generated: \"" + JSON.stringify(result) + "\". Valid access " + | ||
'tokens must be an object with the "expires_in" (number) and "access_token" ' + | ||
'(string) properties.'); | ||
} | ||
@@ -67,6 +67,7 @@ var token = { | ||
} | ||
var errorMessage = 'Credential implementation provided to initializeApp() via the ' + | ||
var errorMessage = (typeof error === 'string') ? error : error.message; | ||
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) { | ||
("following error: \"" + errorMessage + "\"."); | ||
if (errorMessage.indexOf('invalid_grant') !== -1) { | ||
errorMessage += ' There are two likely causes: (1) your server time is not properly ' + | ||
@@ -79,3 +80,3 @@ 'synced or (2) your certificate key file has been revoked. To solve (1), re-sync the ' + | ||
} | ||
throw new Error(errorMessage); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, errorMessage); | ||
}); | ||
@@ -148,3 +149,3 @@ return this.cachedTokenPromise_; | ||
if (typeof errorMessage !== 'undefined') { | ||
throw new Error("Invalid Firebase app options passed as the first argument to initializeApp() for the " + | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS, "Invalid Firebase app options passed as the first argument to initializeApp() for the " + | ||
("app named \"" + this.name_ + "\". " + errorMessage)); | ||
@@ -167,20 +168,2 @@ } | ||
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. | ||
// b/35366344: We only do this if the credential has a non-null certificate to ensure we do not | ||
// do this check for things like Application Default Credentials on Cloud Functions, which | ||
// often results in ECONNTIMEOUT errors. | ||
if (typeof this.options_.credential.getCertificate === 'function') { | ||
var certificate = this.options_.credential.getCertificate(); | ||
if (certificate) { | ||
this.INTERNAL.getToken() | ||
.catch(function (error) { | ||
/* tslint:disable:no-console */ | ||
console.error(error); | ||
/* tslint:enable:no-console */ | ||
}); | ||
} | ||
} | ||
} | ||
@@ -194,11 +177,11 @@ /** | ||
FirebaseApp.prototype.auth = function () { | ||
throw new Error('INTERNAL ASSERT FAILED: Firebase auth() service has not been registered.'); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Firebase auth() service has not been registered.'); | ||
}; | ||
/* istanbul ignore next */ | ||
FirebaseApp.prototype.database = function () { | ||
throw new Error('INTERNAL ASSERT FAILED: Firebase database() service has not been registered.'); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Firebase database() service has not been registered.'); | ||
}; | ||
/* istanbul ignore next */ | ||
FirebaseApp.prototype.messaging = function () { | ||
throw new Error('INTERNAL ASSERT FAILED: Firebase messaging() service has not been registered.'); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Firebase messaging() service has not been registered.'); | ||
}; | ||
@@ -272,3 +255,3 @@ Object.defineProperty(FirebaseApp.prototype, "name", { | ||
if (this.isDeleted_) { | ||
throw new Error("Firebase app named \"" + this.name_ + "\" has already been deleted."); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.APP_DELETED, "Firebase app named \"" + this.name_ + "\" has already been deleted."); | ||
} | ||
@@ -275,0 +258,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -6,2 +6,3 @@ "use strict"; | ||
var deep_copy_1 = require("./utils/deep-copy"); | ||
var error_1 = require("./utils/error"); | ||
var firebase_app_1 = require("./firebase-app"); | ||
@@ -34,7 +35,7 @@ var credential_1 = require("./auth/credential"); | ||
if (typeof appName !== 'string' || appName === '') { | ||
throw new Error("Illegal Firebase app name \"" + appName + "\" provided. App name must be a non-empty string."); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_NAME, "Invalid Firebase app name \"" + appName + "\" provided. App name must be a non-empty string."); | ||
} | ||
else if (appName in this.apps_) { | ||
if (appName === DEFAULT_APP_NAME) { | ||
throw new Error('The default Firebase app already exists. This means you called initializeApp() ' + | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.DUPLICATE_APP, 'The default Firebase app already exists. This means you called initializeApp() ' + | ||
'more than once without providing an app name as the second argument. In most cases ' + | ||
@@ -46,3 +47,3 @@ 'you only need to call initializeApp() once. But if you do want to initialize ' + | ||
else { | ||
throw new Error("Firebase app named \"" + appName + "\" already exists. This means you called initializeApp() " + | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.DUPLICATE_APP, "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 ' + | ||
@@ -67,3 +68,3 @@ 'unique name every time you call initializeApp().'); | ||
if (typeof appName !== 'string' || appName === '') { | ||
throw new Error("Illegal Firebase app name \"" + appName + "\" provided. App name must be a non-empty string."); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_NAME, "Invalid Firebase app name \"" + appName + "\" provided. App name must be a non-empty string."); | ||
} | ||
@@ -79,3 +80,3 @@ else if (!(appName in this.apps_)) { | ||
errorMessage += 'Make sure you call initializeApp() before using any of the Firebase services.'; | ||
throw new Error(errorMessage); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.NO_APP, errorMessage); | ||
} | ||
@@ -105,3 +106,3 @@ return this.apps_[appName]; | ||
if (typeof appName === 'undefined') { | ||
throw new Error("No Firebase app name provided. App name must be a non-empty string."); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_NAME, "No Firebase app name provided. App name must be a non-empty string."); | ||
} | ||
@@ -123,11 +124,15 @@ var appToRemove = this.app(appName); | ||
var _this = this; | ||
var errorMessage; | ||
if (typeof serviceName === 'undefined') { | ||
throw new Error("No service name provided. Service name must be a non-empty string."); | ||
errorMessage = "No service name provided. Service name must be a non-empty string."; | ||
} | ||
else if (typeof serviceName !== 'string' || serviceName === '') { | ||
throw new Error("Illegal service name \"" + serviceName + "\" provided. Service name must be a non-empty string."); | ||
errorMessage = "Invalid service name \"" + serviceName + "\" provided. Service name must be a non-empty string."; | ||
} | ||
else if (serviceName in this.serviceFactories) { | ||
throw new Error("Firebase service named \"" + serviceName + "\" has already been registered."); | ||
errorMessage = "Firebase service named \"" + serviceName + "\" has already been registered."; | ||
} | ||
if (typeof errorMessage !== 'undefined') { | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INTERNAL_ERROR, "INTERNAL ASSERT FAILED: " + errorMessage); | ||
} | ||
this.serviceFactories[serviceName] = createService; | ||
@@ -206,3 +211,3 @@ if (appHook) { | ||
this.credential = firebaseCredential; | ||
this.SDK_VERSION = '4.1.2'; | ||
this.SDK_VERSION = '4.1.3'; | ||
/* tslint:disable */ | ||
@@ -221,11 +226,11 @@ // TODO(jwenger): Database is the only consumer of firebase.Promise. We should update it to use | ||
FirebaseNamespace.prototype.auth = function () { | ||
throw new Error('INTERNAL ASSERT FAILED: Firebase auth() service has not been registered.'); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Firebase auth() service has not been registered.'); | ||
}; | ||
/* istanbul ignore next */ | ||
FirebaseNamespace.prototype.database = function () { | ||
throw new Error('INTERNAL ASSERT FAILED: Firebase database() service has not been registered.'); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Firebase database() service has not been registered.'); | ||
}; | ||
/* istanbul ignore next */ | ||
FirebaseNamespace.prototype.messaging = function () { | ||
throw new Error('INTERNAL ASSERT FAILED: Firebase messaging() service has not been registered.'); | ||
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Firebase messaging() service has not been registered.'); | ||
}; | ||
@@ -232,0 +237,0 @@ /** |
@@ -1,4 +0,4 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -12,19 +12,2 @@ 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 { | ||
@@ -67,3 +50,3 @@ projectId?: string; | ||
messaging(): admin.messaging.Messaging; | ||
delete(): admin.Promise<undefined>; | ||
delete(): Promise<void>; | ||
} | ||
@@ -104,5 +87,17 @@ } | ||
interface DecodedIdToken { | ||
aud: string; | ||
auth_time: number; | ||
exp: number; | ||
firebase: { | ||
identities: { | ||
[key: string]: any; | ||
}; | ||
sign_in_provider: string; | ||
[key: string]: any; | ||
}; | ||
iat: number; | ||
iss: string; | ||
sub: string; | ||
uid: string; | ||
sub: string; | ||
[other: string]: any; | ||
[key: string]: any; | ||
} | ||
@@ -113,9 +108,9 @@ | ||
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>; | ||
createCustomToken(uid: string, developerClaims?: Object): Promise<string>; | ||
createUser(properties: Object): Promise<admin.auth.UserRecord>; | ||
deleteUser(uid: string): Promise<void>; | ||
getUser(uid: string): Promise<admin.auth.UserRecord>; | ||
getUserByEmail(email: string): Promise<admin.auth.UserRecord>; | ||
updateUser(uid: string, properties: Object): Promise<admin.auth.UserRecord>; | ||
verifyIdToken(idToken: string): Promise<admin.auth.DecodedIdToken>; | ||
} | ||
@@ -126,3 +121,3 @@ } | ||
interface Credential { | ||
getAccessToken(): admin.Promise<admin.GoogleOAuthAccessToken>; | ||
getAccessToken(): Promise<admin.GoogleOAuthAccessToken>; | ||
} | ||
@@ -139,4 +134,4 @@ | ||
goOffline(): undefined; | ||
goOnline(): undefined; | ||
goOffline(): void; | ||
goOnline(): void; | ||
ref(path?: string): admin.database.Reference; | ||
@@ -163,5 +158,5 @@ refFromURL(url: string): admin.database.Reference; | ||
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>; | ||
cancel(onComplete?: (a: Error|null) => any): Promise<void>; | ||
remove(onComplete?: (a: Error|null) => any): Promise<void>; | ||
set(value: any, onComplete?: (a: Error|null) => any): Promise<void>; | ||
setWithPriority( | ||
@@ -171,6 +166,7 @@ value: any, | ||
onComplete?: (a: Error|null) => any | ||
): admin.Promise<undefined>; | ||
update(values: Object, onComplete?: (a: Error|null) => any): admin.Promise<undefined>; | ||
): Promise<void>; | ||
update(values: Object, onComplete?: (a: Error|null) => any): Promise<void>; | ||
} | ||
type EventType = 'value' | 'child_added' | 'child_changed' | 'child_moved' | 'child_removed'; | ||
interface Query { | ||
@@ -185,8 +181,8 @@ ref: admin.database.Reference; | ||
off( | ||
eventType?: string, | ||
eventType?: admin.database.EventType, | ||
callback?: (a: admin.database.DataSnapshot, b?: string|null) => any, | ||
context?: Object|null | ||
): undefined; | ||
): void; | ||
on( | ||
eventType: string, | ||
eventType: admin.database.EventType, | ||
callback: (a: admin.database.DataSnapshot|null, b?: string) => any, | ||
@@ -197,7 +193,7 @@ cancelCallbackOrContext?: Object|null, | ||
once( | ||
eventType: string, | ||
eventType: admin.database.EventType, | ||
successCallback?: (a: admin.database.DataSnapshot, b?: string) => any, | ||
failureCallbackOrContext?: Object|null, | ||
context?: Object|null | ||
): admin.Promise<any>; | ||
): Promise<any>; | ||
orderByChild(path: string): admin.database.Query; | ||
@@ -220,12 +216,12 @@ orderByKey(): admin.database.Query; | ||
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>; | ||
remove(onComplete?: (a: Error|null) => any): Promise<void>; | ||
set(value: any, onComplete?: (a: Error|null) => any): Promise<void>; | ||
setPriority( | ||
priority: string|number|null, | ||
onComplete: (a: Error|null) => any | ||
): admin.Promise<undefined>; | ||
): Promise<void>; | ||
setWithPriority( | ||
newVal: any, newPriority: string|number|null, | ||
onComplete?: (a: Error|null) => any | ||
): admin.Promise<undefined>; | ||
): Promise<void>; | ||
transaction( | ||
@@ -235,10 +231,10 @@ transactionUpdate: (a: any) => any, | ||
applyLocally?: boolean | ||
): admin.Promise<{ | ||
): Promise<{ | ||
committed: boolean, | ||
snapshot: admin.database.DataSnapshot|null | ||
}>; | ||
update(values: Object, onComplete?: (a: Error|null) => any): admin.Promise<undefined>; | ||
update(values: Object, onComplete?: (a: Error|null) => any): Promise<void>; | ||
} | ||
interface ThenableReference extends admin.database.Reference, admin.Thenable<any> {} | ||
interface ThenableReference extends admin.database.Reference, Promise<any> {} | ||
@@ -270,3 +266,3 @@ function enableLogging(logger?: boolean|((message: string) => any), persistent?: boolean): any; | ||
titleLocArgs?: string; | ||
[other: string]: string; | ||
[key: string]: string | undefined; | ||
}; | ||
@@ -287,3 +283,3 @@ | ||
restrictedPackageName?: string; | ||
[other: string]: any; | ||
[key: string]: any | undefined; | ||
}; | ||
@@ -326,3 +322,3 @@ | ||
options?: admin.messaging.MessagingOptions | ||
): admin.Promise<admin.messaging.MessagingDevicesResponse>; | ||
): Promise<admin.messaging.MessagingDevicesResponse>; | ||
sendToDevice( | ||
@@ -332,3 +328,3 @@ registrationTokens: string[], | ||
options?: admin.messaging.MessagingOptions | ||
): admin.Promise<admin.messaging.MessagingDevicesResponse>; | ||
): Promise<admin.messaging.MessagingDevicesResponse>; | ||
sendToDeviceGroup( | ||
@@ -338,3 +334,3 @@ notificationKey: string, | ||
options?: admin.messaging.MessagingOptions | ||
): admin.Promise<admin.messaging.MessagingDeviceGroupResponse>; | ||
): Promise<admin.messaging.MessagingDeviceGroupResponse>; | ||
sendToTopic( | ||
@@ -344,3 +340,3 @@ topic: string, | ||
options?: admin.messaging.MessagingOptions | ||
): admin.Promise<admin.messaging.MessagingTopicResponse>; | ||
): Promise<admin.messaging.MessagingTopicResponse>; | ||
sendToCondition( | ||
@@ -350,3 +346,3 @@ condition: string, | ||
options?: admin.messaging.MessagingOptions | ||
): admin.Promise<admin.messaging.MessagingConditionResponse>; | ||
): Promise<admin.messaging.MessagingConditionResponse>; | ||
} | ||
@@ -353,0 +349,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -17,3 +17,3 @@ "use strict"; | ||
'Content-Type': 'application/json', | ||
'Sdk-Version': 'Node/Admin/4.1.2', | ||
'Sdk-Version': 'Node/Admin/4.1.3', | ||
access_token_auth: 'true', | ||
@@ -75,3 +75,6 @@ }; | ||
// Re-throw the error if it already has the proper format. | ||
if (response.error instanceof error_1.FirebaseError) { | ||
if (response instanceof error_1.FirebaseError) { | ||
throw response; | ||
} | ||
else if (response.error instanceof error_1.FirebaseError) { | ||
throw response.error; | ||
@@ -78,0 +81,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -90,7 +90,4 @@ "use strict"; | ||
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 + ".\""), | ||
}); | ||
var parsingError = new error_1.FirebaseAppError(error_1.AppErrorCodes.UNABLE_TO_PARSE_RESPONSE, "Failed to parse response data: \"" + error.toString() + "\". Raw server" + | ||
("response: \"" + response + ".\"")); | ||
reject({ | ||
@@ -110,6 +107,3 @@ statusCode: statusCode, | ||
req.abort(); | ||
var networkTimeoutError = new error_1.FirebaseError({ | ||
code: 'network-timeout', | ||
message: host + " network timeout. Please try again.", | ||
}); | ||
var networkTimeoutError = new error_1.FirebaseAppError(error_1.AppErrorCodes.NETWORK_TIMEOUT, host + " network timeout. Please try again."); | ||
reject({ | ||
@@ -123,6 +117,3 @@ statusCode: 408, | ||
req.on('error', function (error) { | ||
var networkRequestError = new error_1.FirebaseError({ | ||
code: 'network-error', | ||
message: "A network request error has occurred: " + (error && error.message), | ||
}); | ||
var networkRequestError = new error_1.FirebaseAppError(error_1.AppErrorCodes.NETWORK_ERROR, "A network request error has occurred: " + (error && error.message)); | ||
reject({ | ||
@@ -172,7 +163,2 @@ statusCode: 502, | ||
return this.app_.INTERNAL.getToken().then(function (accessTokenObj) { | ||
if (accessTokenObj == null) { | ||
return Promise.reject('Unable to fetch Google OAuth2 access token. ' + | ||
'Make sure you initialized the SDK with a credential that can f' + | ||
'etch access tokens.'); | ||
} | ||
var headersCopy = deep_copy_1.deepCopy(headers); | ||
@@ -199,5 +185,2 @@ var authorizationHeaderKey = 'Authorization'; | ||
this.httpMethod = httpMethod; | ||
if (!endpoint) { | ||
throw new Error("INTERNAL ASSERT FAILED: Unspecified API settings endpoint: " + endpoint); | ||
} | ||
this.setRequestValidator(null) | ||
@@ -204,0 +187,0 @@ .setResponseValidator(null); |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -61,2 +61,20 @@ "use strict"; | ||
/** | ||
* Firebase App error code structure. This extends FirebaseError. | ||
* | ||
* @param {string} code The error code. | ||
* @param {string} message The error message. | ||
* @constructor | ||
*/ | ||
var FirebaseAppError = (function (_super) { | ||
__extends(FirebaseAppError, _super); | ||
function FirebaseAppError(code, message) { | ||
return _super.call(this, { | ||
code: 'app/' + code, | ||
message: message, | ||
}) || this; | ||
} | ||
return FirebaseAppError; | ||
}(FirebaseError)); | ||
exports.FirebaseAppError = FirebaseAppError; | ||
/** | ||
* Firebase Auth error code structure. This extends FirebaseError. | ||
@@ -143,2 +161,22 @@ * | ||
/** | ||
* App client error codes and their default messages. | ||
*/ | ||
var AppErrorCodes = (function () { | ||
function AppErrorCodes() { | ||
} | ||
return AppErrorCodes; | ||
}()); | ||
AppErrorCodes.APP_DELETED = 'app-deleted'; | ||
AppErrorCodes.DUPLICATE_APP = 'duplicate-app'; | ||
AppErrorCodes.INTERNAL_ERROR = 'internal-error'; | ||
AppErrorCodes.INVALID_APP_NAME = 'invalid-app-name'; | ||
AppErrorCodes.INVALID_APP_OPTIONS = 'invalid-app-options'; | ||
AppErrorCodes.INVALID_CREDENTIAL = 'invalid-credential'; | ||
AppErrorCodes.NETWORK_ERROR = 'network-error'; | ||
AppErrorCodes.NETWORK_TIMEOUT = 'network-timeout'; | ||
AppErrorCodes.NO_APP = 'no-app'; | ||
AppErrorCodes.UNABLE_TO_PARSE_RESPONSE = 'unable-to-parse-response'; | ||
exports.AppErrorCodes = AppErrorCodes; | ||
; | ||
/** | ||
* Auth client error codes and their default messages. | ||
@@ -145,0 +183,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.2 | ||
/*! firebase-admin v4.1.3 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
{ | ||
"name": "firebase-admin", | ||
"version": "4.1.2", | ||
"version": "4.1.3", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "@types/jsonwebtoken": { |
{ | ||
"name": "firebase-admin", | ||
"version": "4.1.2", | ||
"version": "4.1.3", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
292097
4408