Socket
Socket
Sign inDemoInstall

firebase-admin

Package Overview
Dependencies
Maintainers
1
Versions
137
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.2.0 to 4.2.1

4

lib/auth/auth-api-request.js

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

'Content-Type': 'application/json',
'X-Client-Version': 'Node/Admin/4.2.0',
'X-Client-Version': 'Node/Admin/4.2.1',
};

@@ -22,0 +22,0 @@ /** Firebase Auth request timeout duration in milliseconds. */

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

@@ -15,2 +15,3 @@ "use strict";

this.credential_ = credential_;
this.isDeleted_ = false;
this.tokenListeners_ = [];

@@ -28,5 +29,21 @@ }

if (this.cachedTokenPromise_ && !forceRefresh && !expired) {
return this.cachedTokenPromise_;
return this.cachedTokenPromise_
.catch(function (error) {
// Update the cached token promise to avoid caching errors. Set it to resolve with the
// cached token if we have one (and return that promise since the token has still not
// expired).
if (_this.cachedToken_) {
_this.cachedTokenPromise_ = Promise.resolve(_this.cachedToken_);
return _this.cachedTokenPromise_;
}
// Otherwise, set the cached token promise to null so that it will force a refresh next
// time getToken() is called.
_this.cachedTokenPromise_ = null;
// And re-throw the caught error.
throw error;
});
}
else {
// Clear the outstanding token refresh timeout. This is a noop if the timeout is undefined.
clearTimeout(this.tokenRefreshTimeout_);
// this.credential_ may be an external class; resolving it in a promise helps us

@@ -57,13 +74,24 @@ // protect against exceptions and upgrades the result to a promise in all cases.

}
// Establish a timeout to proactively refresh the token every minute starting at five
// minutes before it expires. Once a token refresh succeeds, no further retries are
// needed; if it fails, retry every minute until the token expires (resulting in a total
// of four retries: at 4, 3, 2, and 1 minutes).
var refreshTimeInSeconds = (result.expires_in - (5 * 60));
var numRetries = 4;
// In the rare cases the token is short-lived (that is, it expires in less than five
// minutes from when it was fetched), establish the timeout to refresh it after the
// current minute ends and update the number of retries that should be attempted before
// the token expires.
if (refreshTimeInSeconds <= 0) {
refreshTimeInSeconds = result.expires_in % 60;
numRetries = Math.floor(result.expires_in / 60) - 1;
}
// The token refresh timeout keeps the Node.js process alive, so only create it if this
// instance has not already been deleted.
if (numRetries && !_this.isDeleted_) {
_this.setTokenRefreshTimeout(refreshTimeInSeconds * 1000, numRetries);
}
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 = (typeof error === 'string') ? error : error.message;

@@ -105,2 +133,31 @@ errorMessage = 'Credential implementation provided to initializeApp() via the ' +

};
/**
* Deletes the FirebaseAppInternals instance.
*/
FirebaseAppInternals.prototype.delete = function () {
this.isDeleted_ = true;
// Clear the token refresh timeout so it doesn't keep the Node.js process alive.
clearTimeout(this.tokenRefreshTimeout_);
};
/**
* Establishes timeout to refresh the Google OAuth2 access token used by the SDK.
*
* @param {number} delayInMilliseconds The delay to use for the timeout.
* @param {number} numRetries The number of times to retry fetching a new token if the prior fetch
* failed.
*/
FirebaseAppInternals.prototype.setTokenRefreshTimeout = function (delayInMilliseconds, numRetries) {
var _this = this;
this.tokenRefreshTimeout_ = setTimeout(function () {
_this.getToken(/* forceRefresh */ true)
.catch(function (error) {
// Ignore the error since this might just be an intermittent failure. If we really cannot
// refresh the token, an error will be logged once the existing token expires and we try
// to fetch a fresh one.
if (numRetries > 0) {
_this.setTokenRefreshTimeout(60 * 1000, numRetries - 1);
}
});
}, delayInMilliseconds);
};
return FirebaseAppInternals;

@@ -221,2 +278,3 @@ }());

this.firebaseInternals_.removeApp(this.name_);
this.INTERNAL.delete();
return Promise.all(Object.keys(this.services_).map(function (serviceName) {

@@ -223,0 +281,0 @@ return _this.services_[serviceName].INTERNAL.delete();

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

this.credential = firebaseCredential;
this.SDK_VERSION = '4.2.0';
this.SDK_VERSION = '4.2.1';
/* tslint:disable */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

@@ -3,0 +3,0 @@ declare namespace admin {

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

'Content-Type': 'application/json',
'Sdk-Version': 'Node/Admin/4.2.0',
'Sdk-Version': 'Node/Admin/4.2.1',
access_token_auth: 'true',

@@ -18,0 +18,0 @@ };

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

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

/*! firebase-admin v4.2.0
/*! firebase-admin v4.2.1
https://firebase.google.com/terms/ */

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

{
"name": "firebase-admin",
"version": "4.2.0",
"version": "4.2.1",
"dependencies": {

@@ -5,0 +5,0 @@ "@types/jsonwebtoken": {

{
"name": "firebase-admin",
"version": "4.2.0",
"version": "4.2.1",
"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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc