firebase-admin 6.5.0 → 6.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,10 +2,17 @@
2
2
 
3
3
  -
4
4
 
5
+ # v6.5.1
6
+
7
+ - [fixed] Implemented a Node.js environment check that will be executed at
8
+ package import time.
9
+ - [fixed] Setting GOOGLE_APPLICATION_CREDENTIALS environment variable
10
+ to a refresh token instead of a certificate token now supported
11
+
5
12
  # v6.5.0
6
13
 
7
- - [fixed] Correctly parses error codes with details messages in Firebase Auth.
8
- - [fixed] Fixed optional fields in UserRecord types to be optional.
14
+ - [fixed] Correctly parses error codes sent by Firebase Auth backend servers.
15
+ - [fixed] Correctly marked the optional fields in `UserRecord` types.
9
16
  - [added] `admin.projectManagement().shaCertificate()` method to create an
10
17
  instance of admin.projectManagement.ShaCertificate.
11
18
 
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -31,7 +31,7 @@ var FIREBASE_AUTH_PORT = 443;
31
31
  var FIREBASE_AUTH_PATH = '/identitytoolkit/v3/relyingparty/';
32
32
  /** Firebase Auth request header. */
33
33
  var FIREBASE_AUTH_HEADER = {
34
- 'X-Client-Version': 'Node/Admin/6.5.0',
34
+ 'X-Client-Version': 'Node/Admin/6.5.1',
35
35
  };
36
36
  /** Firebase Auth request timeout duration in milliseconds. */
37
37
  var FIREBASE_AUTH_TIMEOUT = 25000;
package/lib/auth/auth.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -277,8 +277,7 @@ exports.MetadataServiceCredential = MetadataServiceCredential;
277
277
  var ApplicationDefaultCredential = /** @class */ (function () {
278
278
  function ApplicationDefaultCredential(httpAgent) {
279
279
  if (process.env.GOOGLE_APPLICATION_CREDENTIALS) {
280
- var serviceAccount = Certificate.fromPath(process.env.GOOGLE_APPLICATION_CREDENTIALS);
281
- this.credential_ = new CertCredential(serviceAccount, httpAgent);
280
+ this.credential_ = credentialFromFile(process.env.GOOGLE_APPLICATION_CREDENTIALS, httpAgent);
282
281
  return;
283
282
  }
284
283
  // It is OK to not have this file. If it is present, it must be valid.
@@ -302,3 +301,34 @@ var ApplicationDefaultCredential = /** @class */ (function () {
302
301
  return ApplicationDefaultCredential;
303
302
  }());
304
303
  exports.ApplicationDefaultCredential = ApplicationDefaultCredential;
304
+ function credentialFromFile(filePath, httpAgent) {
305
+ var credentialsFile = readCredentialFile(filePath);
306
+ if (typeof credentialsFile !== 'object') {
307
+ throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse contents of the credentials file as an object');
308
+ }
309
+ if (credentialsFile.type === 'service_account') {
310
+ return new CertCredential(credentialsFile, httpAgent);
311
+ }
312
+ if (credentialsFile.type === 'authorized_user') {
313
+ return new RefreshTokenCredential(credentialsFile, httpAgent);
314
+ }
315
+ throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Invalid contents in the credentials file');
316
+ }
317
+ function readCredentialFile(filePath) {
318
+ if (typeof filePath !== 'string') {
319
+ throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse credentials file: TypeError: path must be a string');
320
+ }
321
+ var fileText;
322
+ try {
323
+ fileText = fs.readFileSync(filePath, 'utf8');
324
+ }
325
+ catch (error) {
326
+ throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, "Failed to read credentials from file " + filePath + ": " + error);
327
+ }
328
+ try {
329
+ return JSON.parse(fileText);
330
+ }
331
+ catch (error) {
332
+ throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse contents of the credentials file as an object: ' + error);
333
+ }
334
+ }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  var error_1 = require("../utils/error");
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -246,7 +246,7 @@ var FirebaseNamespace = /** @class */ (function () {
246
246
  this.__esModule = true;
247
247
  /* tslint:enable:variable-name */
248
248
  this.credential = firebaseCredential;
249
- this.SDK_VERSION = '6.5.0';
249
+ this.SDK_VERSION = '6.5.1';
250
250
  /* tslint:disable */
251
251
  // TODO(jwenger): Database is the only consumer of firebase.Promise. We should update it to use
252
252
  // use the native Promise and then remove this.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  /*!
3
3
  * Copyright 2017 Google Inc.
4
4
  *
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -16,4 +16,11 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  var firebase = require("./default-namespace");
19
+ // Only Node.js has a process variable that is of [[Class]] process
20
+ var processGlobal = typeof process !== 'undefined' ? process : 0;
21
+ if (Object.prototype.toString.call(processGlobal) !== '[object process]') {
22
+ var message = "\n======== WARNING! ========\n\nfirebase-admin appears to have been installed in an unsupported environment.\nThis package should only be used in server-side or backend Node.js environments,\nand should not be used in web browsers or other client-side environments.\n\nUse the Firebase JS SDK for client-side Firebase integrations:\n\nhttps://firebase.google.com/docs/web/setup\n";
23
+ // tslint:disable-next-line:no-console
24
+ console.error(message);
25
+ }
19
26
  module.exports = firebase;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -23,7 +23,7 @@ var validator = require("../utils/validator");
23
23
  var FIREBASE_MESSAGING_TIMEOUT = 10000;
24
24
  var FIREBASE_MESSAGING_HTTP_METHOD = 'POST';
25
25
  var FIREBASE_MESSAGING_HEADERS = {
26
- 'Sdk-Version': 'Node/Admin/6.5.0',
26
+ 'Sdk-Version': 'Node/Admin/6.5.1',
27
27
  'access_token_auth': 'true',
28
28
  };
29
29
  /**
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -27,7 +27,7 @@ var PROJECT_MANAGEMENT_PATH = '/v1/';
27
27
  var PROJECT_MANAGEMENT_BETA_PATH = '/v1beta1/';
28
28
  /** Project management request header. */
29
29
  var PROJECT_MANAGEMENT_HEADERS = {
30
- 'X-Client-Version': 'Node/Admin/6.5.0',
30
+ 'X-Client-Version': 'Node/Admin/6.5.1',
31
31
  };
32
32
  /** Project management request timeout duration in milliseconds. */
33
33
  var PROJECT_MANAGEMENT_TIMEOUT_MILLIS = 10000;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v6.5.0 */
1
+ /*! firebase-admin v6.5.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2017 Google Inc.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-admin",
3
- "version": "6.5.0",
3
+ "version": "6.5.1",
4
4
  "description": "Firebase admin SDK for Node.js",
5
5
  "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
6
6
  "license": "Apache-2.0",