firebase-admin 9.3.0 → 9.5.0

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.
Files changed (82) hide show
  1. package/lib/auth/action-code-settings-builder.js +1 -1
  2. package/lib/auth/auth-api-request.js +98 -25
  3. package/lib/auth/auth-config.js +15 -15
  4. package/lib/auth/auth.js +82 -61
  5. package/lib/auth/identifier.js +3 -2
  6. package/lib/auth/index.d.ts +1868 -0
  7. package/lib/{credential/credential-interfaces.js → auth/index.js} +1 -1
  8. package/lib/auth/tenant-manager.js +1 -1
  9. package/lib/auth/tenant.js +7 -1
  10. package/lib/auth/token-generator.js +6 -4
  11. package/lib/auth/token-verifier.js +32 -36
  12. package/lib/auth/user-import-builder.js +18 -15
  13. package/lib/auth/user-record.js +4 -4
  14. package/lib/credential/credential-internal.js +1 -2
  15. package/lib/credential/credential.js +8 -122
  16. package/lib/credential/index.d.ts +169 -0
  17. package/lib/credential/index.js +5 -17
  18. package/lib/database/database-internal.js +19 -26
  19. package/lib/database/index.d.ts +89 -0
  20. package/lib/database/index.js +12 -28
  21. package/lib/default-namespace.js +2 -1
  22. package/lib/firebase-app.js +26 -48
  23. package/lib/firebase-namespace-api.d.ts +238 -0
  24. package/lib/{firebase-service.js → firebase-namespace-api.js} +2 -2
  25. package/lib/{database/database.js → firebase-namespace.d.ts} +14 -7
  26. package/lib/firebase-namespace.js +22 -92
  27. package/lib/firestore/firestore-internal.js +2 -19
  28. package/lib/firestore/index.d.ts +50 -0
  29. package/lib/firestore/index.js +28 -43
  30. package/lib/index.d.ts +3 -932
  31. package/lib/index.js +2 -1
  32. package/lib/instance-id/index.d.ts +81 -0
  33. package/lib/instance-id/index.js +1 -10
  34. package/lib/instance-id/instance-id-request-internal.js +2 -1
  35. package/lib/instance-id/instance-id.js +1 -19
  36. package/lib/machine-learning/index.d.ts +249 -0
  37. package/lib/{messaging/messaging-types.js → machine-learning/index.js} +2 -2
  38. package/lib/machine-learning/machine-learning-api-client.js +1 -1
  39. package/lib/machine-learning/machine-learning-utils.js +1 -1
  40. package/lib/machine-learning/machine-learning.js +3 -22
  41. package/lib/messaging/batch-request-internal.js +1 -1
  42. package/lib/messaging/index.d.ts +1174 -0
  43. package/lib/messaging/index.js +1 -24
  44. package/lib/messaging/messaging-api-request-internal.js +2 -1
  45. package/lib/messaging/messaging-errors-internal.js +1 -1
  46. package/lib/messaging/messaging-internal.js +1 -1
  47. package/lib/messaging/messaging.js +21 -25
  48. package/lib/project-management/android-app.js +7 -6
  49. package/lib/project-management/index.d.ts +363 -0
  50. package/lib/project-management/index.js +23 -25
  51. package/lib/project-management/ios-app.js +5 -4
  52. package/lib/project-management/project-management-api-request-internal.js +5 -5
  53. package/lib/project-management/project-management.js +9 -26
  54. package/lib/remote-config/index.d.ts +359 -0
  55. package/lib/remote-config/index.js +1 -26
  56. package/lib/remote-config/remote-config-api-client-internal.js +3 -3
  57. package/lib/remote-config/remote-config.js +15 -32
  58. package/lib/security-rules/index.d.ts +216 -0
  59. package/lib/security-rules/index.js +1 -24
  60. package/lib/security-rules/security-rules-api-client-internal.js +1 -1
  61. package/lib/security-rules/security-rules-internal.js +1 -1
  62. package/lib/security-rules/security-rules.js +6 -15
  63. package/lib/storage/index.d.ts +60 -0
  64. package/lib/storage/index.js +1 -10
  65. package/lib/storage/storage.js +2 -19
  66. package/lib/utils/api-request.js +10 -3
  67. package/lib/utils/deep-copy.js +2 -1
  68. package/lib/utils/error.js +2 -1
  69. package/lib/utils/index.js +6 -5
  70. package/lib/utils/validator.js +2 -1
  71. package/package.json +15 -12
  72. package/lib/auth.d.ts +0 -2016
  73. package/lib/credential.d.ts +0 -150
  74. package/lib/database.d.ts +0 -1663
  75. package/lib/instance-id.d.ts +0 -37
  76. package/lib/messaging.d.ts +0 -1341
  77. package/lib/project-management/app-metadata.js +0 -37
  78. package/lib/project-management.d.ts +0 -361
  79. package/lib/remote-config/remote-config-api-client.js +0 -36
  80. package/lib/remote-config.d.ts +0 -350
  81. package/lib/security-rules.d.ts +0 -192
  82. package/lib/storage.d.ts +0 -40
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -47,6 +47,7 @@ var Tenant = /** @class */ (function () {
47
47
  allowPasswordSignup: false,
48
48
  });
49
49
  }
50
+ this.anonymousSignInEnabled = !!response.enableAnonymousUser;
50
51
  if (typeof response.mfaConfig !== 'undefined') {
51
52
  this.multiFactorConfig = new auth_config_1.MultiFactorAuthConfig(response.mfaConfig);
52
53
  }
@@ -71,6 +72,9 @@ var Tenant = /** @class */ (function () {
71
72
  if (typeof tenantOptions.displayName !== 'undefined') {
72
73
  request.displayName = tenantOptions.displayName;
73
74
  }
75
+ if (typeof tenantOptions.anonymousSignInEnabled !== 'undefined') {
76
+ request.enableAnonymousUser = tenantOptions.anonymousSignInEnabled;
77
+ }
74
78
  if (typeof tenantOptions.multiFactorConfig !== 'undefined') {
75
79
  request.mfaConfig = auth_config_1.MultiFactorAuthConfig.buildServerRequest(tenantOptions.multiFactorConfig);
76
80
  }
@@ -104,6 +108,7 @@ var Tenant = /** @class */ (function () {
104
108
  var validKeys = {
105
109
  displayName: true,
106
110
  emailSignInConfig: true,
111
+ anonymousSignInEnabled: true,
107
112
  multiFactorConfig: true,
108
113
  testPhoneNumbers: true,
109
114
  };
@@ -149,6 +154,7 @@ var Tenant = /** @class */ (function () {
149
154
  tenantId: this.tenantId,
150
155
  displayName: this.displayName,
151
156
  emailSignInConfig: (_a = this.emailSignInConfig) === null || _a === void 0 ? void 0 : _a.toJSON(),
157
+ anonymousSignInEnabled: this.anonymousSignInEnabled,
152
158
  multiFactorConfig: (_b = this.multiFactorConfig) === null || _b === void 0 ? void 0 : _b.toJSON(),
153
159
  testPhoneNumbers: this.testPhoneNumbers,
154
160
  };
@@ -1,6 +1,7 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
+ * @license
4
5
  * Copyright 2017 Google Inc.
5
6
  *
6
7
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -142,8 +143,8 @@ var IAMSigner = /** @class */ (function () {
142
143
  _this.serviceAccountId = response.text;
143
144
  return response.text;
144
145
  }).catch(function (err) {
145
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CREDENTIAL, "Failed to determine service account. Make sure to initialize " +
146
- "the SDK with a service account credential. Alternatively specify a service " +
146
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CREDENTIAL, 'Failed to determine service account. Make sure to initialize ' +
147
+ 'the SDK with a service account credential. Alternatively specify a service ' +
147
148
  ("account with iam.serviceAccounts.signBlob permission. Original error: " + err));
148
149
  });
149
150
  };
@@ -161,7 +162,8 @@ var EmulatedSigner = /** @class */ (function () {
161
162
  /**
162
163
  * @inheritDoc
163
164
  */
164
- EmulatedSigner.prototype.sign = function (_) {
165
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
166
+ EmulatedSigner.prototype.sign = function (buffer) {
165
167
  return Promise.resolve(Buffer.from(''));
166
168
  };
167
169
  /**
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -57,31 +57,31 @@ var FirebaseTokenVerifier = /** @class */ (function () {
57
57
  this.tokenInfo = tokenInfo;
58
58
  this.app = app;
59
59
  if (!validator.isURL(clientCertUrl)) {
60
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "The provided public client certificate URL is an invalid URL.");
60
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'The provided public client certificate URL is an invalid URL.');
61
61
  }
62
62
  else if (!validator.isNonEmptyString(algorithm)) {
63
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "The provided JWT algorithm is an empty string.");
63
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'The provided JWT algorithm is an empty string.');
64
64
  }
65
65
  else if (!validator.isURL(issuer)) {
66
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "The provided JWT issuer is an invalid URL.");
66
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'The provided JWT issuer is an invalid URL.');
67
67
  }
68
68
  else if (!validator.isNonNullObject(tokenInfo)) {
69
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "The provided JWT information is not an object or null.");
69
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'The provided JWT information is not an object or null.');
70
70
  }
71
71
  else if (!validator.isURL(tokenInfo.url)) {
72
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "The provided JWT verification documentation URL is invalid.");
72
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'The provided JWT verification documentation URL is invalid.');
73
73
  }
74
74
  else if (!validator.isNonEmptyString(tokenInfo.verifyApiName)) {
75
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "The JWT verify API name must be a non-empty string.");
75
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'The JWT verify API name must be a non-empty string.');
76
76
  }
77
77
  else if (!validator.isNonEmptyString(tokenInfo.jwtName)) {
78
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "The JWT public full name must be a non-empty string.");
78
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'The JWT public full name must be a non-empty string.');
79
79
  }
80
80
  else if (!validator.isNonEmptyString(tokenInfo.shortName)) {
81
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "The JWT public short name must be a non-empty string.");
81
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'The JWT public short name must be a non-empty string.');
82
82
  }
83
83
  else if (!validator.isNonNullObject(tokenInfo.expiredErrorCode) || !('code' in tokenInfo.expiredErrorCode)) {
84
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "The JWT expiration error code must be a non-null ErrorInfo object.");
84
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, 'The JWT expiration error code must be a non-null ErrorInfo object.');
85
85
  }
86
86
  this.shortNameArticle = tokenInfo.shortName.charAt(0).match(/[aeiou]/i) ? 'an' : 'a';
87
87
  // For backward compatibility, the project ID is validated in the verification call.
@@ -90,30 +90,25 @@ var FirebaseTokenVerifier = /** @class */ (function () {
90
90
  * Verifies the format and signature of a Firebase Auth JWT token.
91
91
  *
92
92
  * @param {string} jwtToken The Firebase Auth JWT token to verify.
93
+ * @param {boolean=} isEmulator Whether to accept Auth Emulator tokens.
93
94
  * @return {Promise<DecodedIdToken>} A promise fulfilled with the decoded claims of the Firebase Auth ID
94
95
  * token.
95
96
  */
96
- FirebaseTokenVerifier.prototype.verifyJWT = function (jwtToken) {
97
+ FirebaseTokenVerifier.prototype.verifyJWT = function (jwtToken, isEmulator) {
97
98
  var _this = this;
99
+ if (isEmulator === void 0) { isEmulator = false; }
98
100
  if (!validator.isString(jwtToken)) {
99
101
  throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "First argument to " + this.tokenInfo.verifyApiName + " must be a " + this.tokenInfo.jwtName + " string.");
100
102
  }
101
103
  return util.findProjectId(this.app)
102
104
  .then(function (projectId) {
103
- return _this.verifyJWTWithProjectId(jwtToken, projectId);
105
+ return _this.verifyJWTWithProjectId(jwtToken, projectId, isEmulator);
104
106
  });
105
107
  };
106
- /**
107
- * Override the JWT signing algorithm.
108
- * @param algorithm the new signing algorithm.
109
- */
110
- FirebaseTokenVerifier.prototype.setAlgorithm = function (algorithm) {
111
- this.algorithm = algorithm;
112
- };
113
- FirebaseTokenVerifier.prototype.verifyJWTWithProjectId = function (jwtToken, projectId) {
108
+ FirebaseTokenVerifier.prototype.verifyJWTWithProjectId = function (jwtToken, projectId, isEmulator) {
114
109
  var _this = this;
115
110
  if (!validator.isNonEmptyString(projectId)) {
116
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CREDENTIAL, "Must initialize app with a cert credential or set your Firebase project ID as the " +
111
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_CREDENTIAL, 'Must initialize app with a cert credential or set your Firebase project ID as the ' +
117
112
  ("GOOGLE_CLOUD_PROJECT environment variable to call " + this.tokenInfo.verifyApiName + "."));
118
113
  }
119
114
  var fullDecodedToken = jwt.decode(jwtToken, {
@@ -122,7 +117,7 @@ var FirebaseTokenVerifier = /** @class */ (function () {
122
117
  var header = fullDecodedToken && fullDecodedToken.header;
123
118
  var payload = fullDecodedToken && fullDecodedToken.payload;
124
119
  var projectIdMatchMessage = " Make sure the " + this.tokenInfo.shortName + " comes from the same " +
125
- "Firebase project as the service account used to authenticate this SDK.";
120
+ 'Firebase project as the service account used to authenticate this SDK.';
126
121
  var verifyJwtTokenDocsMessage = " See " + this.tokenInfo.url + " " +
127
122
  ("for details on how to retrieve " + this.shortNameArticle + " " + this.tokenInfo.shortName + ".");
128
123
  var errorMessage;
@@ -130,7 +125,7 @@ var FirebaseTokenVerifier = /** @class */ (function () {
130
125
  errorMessage = "Decoding " + this.tokenInfo.jwtName + " failed. Make sure you passed the entire string JWT " +
131
126
  ("which represents " + this.shortNameArticle + " " + this.tokenInfo.shortName + ".") + verifyJwtTokenDocsMessage;
132
127
  }
133
- else if (typeof header.kid === 'undefined' && this.algorithm !== 'none') {
128
+ else if (!isEmulator && typeof header.kid === 'undefined') {
134
129
  var isCustomToken = (payload.aud === FIREBASE_AUDIENCE);
135
130
  var isLegacyCustomToken = (header.alg === 'HS256' && payload.v === 0 && 'd' in payload && 'uid' in payload.d);
136
131
  if (isCustomToken) {
@@ -146,19 +141,19 @@ var FirebaseTokenVerifier = /** @class */ (function () {
146
141
  }
147
142
  errorMessage += verifyJwtTokenDocsMessage;
148
143
  }
149
- else if (header.alg !== this.algorithm) {
150
- errorMessage = this.tokenInfo.jwtName + " has incorrect algorithm. Expected \"" + this.algorithm + "\" but got " +
151
- "\"" + header.alg + "\"." + verifyJwtTokenDocsMessage;
144
+ else if (!isEmulator && header.alg !== this.algorithm) {
145
+ errorMessage = this.tokenInfo.jwtName + " has incorrect algorithm. Expected \"" + this.algorithm + '" but got ' +
146
+ '"' + header.alg + '".' + verifyJwtTokenDocsMessage;
152
147
  }
153
148
  else if (payload.aud !== projectId) {
154
149
  errorMessage = this.tokenInfo.jwtName + " has incorrect \"aud\" (audience) claim. Expected \"" +
155
- projectId + "\" but got \"" + payload.aud + "\"." + projectIdMatchMessage +
150
+ projectId + '" but got "' + payload.aud + '".' + projectIdMatchMessage +
156
151
  verifyJwtTokenDocsMessage;
157
152
  }
158
153
  else if (payload.iss !== this.issuer + projectId) {
159
154
  errorMessage = this.tokenInfo.jwtName + " has incorrect \"iss\" (issuer) claim. Expected " +
160
- ("\"" + this.issuer + "\"") + projectId + "\" but got \"" +
161
- payload.iss + "\"." + projectIdMatchMessage + verifyJwtTokenDocsMessage;
155
+ ("\"" + this.issuer) + projectId + '" but got "' +
156
+ payload.iss + '".' + projectIdMatchMessage + verifyJwtTokenDocsMessage;
162
157
  }
163
158
  else if (typeof payload.sub !== 'string') {
164
159
  errorMessage = this.tokenInfo.jwtName + " has no \"sub\" (subject) claim." + verifyJwtTokenDocsMessage;
@@ -173,16 +168,15 @@ var FirebaseTokenVerifier = /** @class */ (function () {
173
168
  if (errorMessage) {
174
169
  return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, errorMessage));
175
170
  }
176
- // When the algorithm is set to 'none' there will be no signature and therefore we don't check
177
- // the public keys.
178
- if (this.algorithm === 'none') {
171
+ if (isEmulator) {
172
+ // Signature checks skipped for emulator; no need to fetch public keys.
179
173
  return this.verifyJwtSignatureWithKey(jwtToken, null);
180
174
  }
181
175
  return this.fetchPublicKeys().then(function (publicKeys) {
182
176
  if (!Object.prototype.hasOwnProperty.call(publicKeys, header.kid)) {
183
177
  return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, _this.tokenInfo.jwtName + " has \"kid\" claim which does not correspond to a known public key. " +
184
178
  ("Most likely the " + _this.tokenInfo.shortName + " is expired, so get a fresh token from your ") +
185
- "client app and try again."));
179
+ 'client app and try again.'));
186
180
  }
187
181
  else {
188
182
  return _this.verifyJwtSignatureWithKey(jwtToken, publicKeys[header.kid]);
@@ -201,9 +195,11 @@ var FirebaseTokenVerifier = /** @class */ (function () {
201
195
  var verifyJwtTokenDocsMessage = " See " + this.tokenInfo.url + " " +
202
196
  ("for details on how to retrieve " + this.shortNameArticle + " " + this.tokenInfo.shortName + ".");
203
197
  return new Promise(function (resolve, reject) {
204
- jwt.verify(jwtToken, publicKey || "", {
205
- algorithms: [_this.algorithm],
206
- }, function (error, decodedToken) {
198
+ var verifyOptions = {};
199
+ if (publicKey !== null) {
200
+ verifyOptions.algorithms = [_this.algorithm];
201
+ }
202
+ jwt.verify(jwtToken, publicKey || '', verifyOptions, function (error, decodedToken) {
207
203
  if (error) {
208
204
  if (error.name === 'TokenExpiredError') {
209
205
  var errorMessage = _this.tokenInfo.jwtName + " has expired. Get a fresh " + _this.tokenInfo.shortName +
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -35,11 +35,11 @@ function convertMultiFactorInfoToServerFormat(multiFactorInfo) {
35
35
  }
36
36
  else {
37
37
  throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ENROLLMENT_TIME, "The second factor \"enrollmentTime\" for \"" + multiFactorInfo.uid + "\" must be a valid " +
38
- "UTC date string.");
38
+ 'UTC date string.');
39
39
  }
40
40
  }
41
41
  // Currently only phone second factors are supported.
42
- if (multiFactorInfo.factorId === 'phone') {
42
+ if (isPhoneFactor(multiFactorInfo)) {
43
43
  // If any required field is missing or invalid, validation will still fail later.
44
44
  var authFactorInfo = {
45
45
  mfaEnrollmentId: multiFactorInfo.uid,
@@ -61,6 +61,9 @@ function convertMultiFactorInfoToServerFormat(multiFactorInfo) {
61
61
  }
62
62
  }
63
63
  exports.convertMultiFactorInfoToServerFormat = convertMultiFactorInfoToServerFormat;
64
+ function isPhoneFactor(multiFactorInfo) {
65
+ return multiFactorInfo.factorId === 'phone';
66
+ }
64
67
  /**
65
68
  * @param {any} obj The object to check for number field within.
66
69
  * @param {string} key The entry key.
@@ -227,11 +230,11 @@ var UserImportBuilder = /** @class */ (function () {
227
230
  throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, '"UserImportOptions" are required when importing users with passwords.');
228
231
  }
229
232
  if (!validator.isNonNullObject(options.hash)) {
230
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.MISSING_HASH_ALGORITHM, "\"hash.algorithm\" is missing from the provided \"UserImportOptions\".");
233
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.MISSING_HASH_ALGORITHM, '"hash.algorithm" is missing from the provided "UserImportOptions".');
231
234
  }
232
235
  if (typeof options.hash.algorithm === 'undefined' ||
233
236
  !validator.isNonEmptyString(options.hash.algorithm)) {
234
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ALGORITHM, "\"hash.algorithm\" must be a string matching the list of supported algorithms.");
237
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ALGORITHM, '"hash.algorithm" must be a string matching the list of supported algorithms.');
235
238
  }
236
239
  var rounds;
237
240
  switch (options.hash.algorithm) {
@@ -240,7 +243,7 @@ var UserImportBuilder = /** @class */ (function () {
240
243
  case 'HMAC_SHA1':
241
244
  case 'HMAC_MD5':
242
245
  if (!validator.isBuffer(options.hash.key)) {
243
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_KEY, "A non-empty \"hash.key\" byte buffer must be provided for " +
246
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_KEY, 'A non-empty "hash.key" byte buffer must be provided for ' +
244
247
  ("hash algorithm " + options.hash.algorithm + "."));
245
248
  }
246
249
  populatedOptions = {
@@ -269,7 +272,7 @@ var UserImportBuilder = /** @class */ (function () {
269
272
  case 'PBKDF2_SHA256':
270
273
  rounds = getNumberField(options.hash, 'rounds');
271
274
  if (isNaN(rounds) || rounds < 0 || rounds > 120000) {
272
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ROUNDS, "A valid \"hash.rounds\" number between 0 and 120000 must be provided for " +
275
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ROUNDS, 'A valid "hash.rounds" number between 0 and 120000 must be provided for ' +
273
276
  ("hash algorithm " + options.hash.algorithm + "."));
274
277
  }
275
278
  populatedOptions = {
@@ -279,22 +282,22 @@ var UserImportBuilder = /** @class */ (function () {
279
282
  break;
280
283
  case 'SCRYPT': {
281
284
  if (!validator.isBuffer(options.hash.key)) {
282
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_KEY, "A \"hash.key\" byte buffer must be provided for " +
285
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_KEY, 'A "hash.key" byte buffer must be provided for ' +
283
286
  ("hash algorithm " + options.hash.algorithm + "."));
284
287
  }
285
288
  rounds = getNumberField(options.hash, 'rounds');
286
289
  if (isNaN(rounds) || rounds <= 0 || rounds > 8) {
287
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ROUNDS, "A valid \"hash.rounds\" number between 1 and 8 must be provided for " +
290
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_ROUNDS, 'A valid "hash.rounds" number between 1 and 8 must be provided for ' +
288
291
  ("hash algorithm " + options.hash.algorithm + "."));
289
292
  }
290
293
  var memoryCost = getNumberField(options.hash, 'memoryCost');
291
294
  if (isNaN(memoryCost) || memoryCost <= 0 || memoryCost > 14) {
292
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_MEMORY_COST, "A valid \"hash.memoryCost\" number between 1 and 14 must be provided for " +
295
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_MEMORY_COST, 'A valid "hash.memoryCost" number between 1 and 14 must be provided for ' +
293
296
  ("hash algorithm " + options.hash.algorithm + "."));
294
297
  }
295
298
  if (typeof options.hash.saltSeparator !== 'undefined' &&
296
299
  !validator.isBuffer(options.hash.saltSeparator)) {
297
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_SALT_SEPARATOR, "\"hash.saltSeparator\" must be a byte buffer.");
300
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_SALT_SEPARATOR, '"hash.saltSeparator" must be a byte buffer.');
298
301
  }
299
302
  populatedOptions = {
300
303
  hashAlgorithm: options.hash.algorithm,
@@ -313,22 +316,22 @@ var UserImportBuilder = /** @class */ (function () {
313
316
  case 'STANDARD_SCRYPT': {
314
317
  var cpuMemCost = getNumberField(options.hash, 'memoryCost');
315
318
  if (isNaN(cpuMemCost)) {
316
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_MEMORY_COST, "A valid \"hash.memoryCost\" number must be provided for " +
319
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_MEMORY_COST, 'A valid "hash.memoryCost" number must be provided for ' +
317
320
  ("hash algorithm " + options.hash.algorithm + "."));
318
321
  }
319
322
  var parallelization = getNumberField(options.hash, 'parallelization');
320
323
  if (isNaN(parallelization)) {
321
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_PARALLELIZATION, "A valid \"hash.parallelization\" number must be provided for " +
324
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_PARALLELIZATION, 'A valid "hash.parallelization" number must be provided for ' +
322
325
  ("hash algorithm " + options.hash.algorithm + "."));
323
326
  }
324
327
  var blockSize = getNumberField(options.hash, 'blockSize');
325
328
  if (isNaN(blockSize)) {
326
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_BLOCK_SIZE, "A valid \"hash.blockSize\" number must be provided for " +
329
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_BLOCK_SIZE, 'A valid "hash.blockSize" number must be provided for ' +
327
330
  ("hash algorithm " + options.hash.algorithm + "."));
328
331
  }
329
332
  var dkLen = getNumberField(options.hash, 'derivedKeyLength');
330
333
  if (isNaN(dkLen)) {
331
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_DERIVED_KEY_LENGTH, "A valid \"hash.derivedKeyLength\" number must be provided for " +
334
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_HASH_DERIVED_KEY_LENGTH, 'A valid "hash.derivedKeyLength" number must be provided for ' +
332
335
  ("hash algorithm " + options.hash.algorithm + "."));
333
336
  }
334
337
  populatedOptions = {
@@ -1,6 +1,7 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
+ * @license
4
5
  * Copyright 2017 Google Inc.
5
6
  *
6
7
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,7 +30,7 @@ var __extends = (this && this.__extends) || (function () {
29
30
  };
30
31
  })();
31
32
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.UserRecord = exports.UserInfo = exports.UserMetadata = exports.MultiFactor = exports.PhoneMultiFactorInfo = exports.MultiFactorInfo = exports.MultiFactorId = void 0;
33
+ exports.UserRecord = exports.UserInfo = exports.UserMetadata = exports.MultiFactor = exports.PhoneMultiFactorInfo = exports.MultiFactorInfo = void 0;
33
34
  var deep_copy_1 = require("../utils/deep-copy");
34
35
  var validator_1 = require("../utils/validator");
35
36
  var utils = require("../utils");
@@ -56,11 +57,10 @@ function parseDate(time) {
56
57
  }
57
58
  return null;
58
59
  }
59
- /** Enums for multi-factor identifiers. */
60
60
  var MultiFactorId;
61
61
  (function (MultiFactorId) {
62
62
  MultiFactorId["Phone"] = "phone";
63
- })(MultiFactorId = exports.MultiFactorId || (exports.MultiFactorId = {}));
63
+ })(MultiFactorId || (MultiFactorId = {}));
64
64
  /**
65
65
  * Abstract class representing a multi-factor info interface.
66
66
  */
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -17,7 +17,6 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.getApplicationDefault = exports.isApplicationDefault = exports.RefreshTokenCredential = exports.ComputeEngineCredential = exports.ServiceAccountCredential = void 0;
20
- // Use untyped import syntax for Node built-ins
21
20
  var fs = require("fs");
22
21
  var os = require("os");
23
22
  var path = require("path");
@@ -1,6 +1,7 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
+ * @license
4
5
  * Copyright 2017 Google Inc.
5
6
  *
6
7
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,138 +22,23 @@ var credential_internal_1 = require("./credential-internal");
21
22
  var globalAppDefaultCred;
22
23
  var globalCertCreds = {};
23
24
  var globalRefreshTokenCreds = {};
24
- /**
25
- * Returns a credential created from the
26
- * {@link
27
- * https://developers.google.com/identity/protocols/application-default-credentials
28
- * Google Application Default Credentials}
29
- * that grants admin access to Firebase services. This credential can be used
30
- * in the call to
31
- * {@link
32
- * https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
33
- * `admin.initializeApp()`}.
34
- *
35
- * Google Application Default Credentials are available on any Google
36
- * infrastructure, such as Google App Engine and Google Compute Engine.
37
- *
38
- * See
39
- * {@link
40
- * https://firebase.google.com/docs/admin/setup#initialize_the_sdk
41
- * Initialize the SDK}
42
- * for more details.
43
- *
44
- * @example
45
- * ```javascript
46
- * admin.initializeApp({
47
- * credential: admin.credential.applicationDefault(),
48
- * databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
49
- * });
50
- * ```
51
- *
52
- * @param {!Object=} httpAgent Optional [HTTP Agent](https://nodejs.org/api/http.html#http_class_http_agent)
53
- * to be used when retrieving access tokens from Google token servers.
54
- *
55
- * @return {!admin.credential.Credential} A credential authenticated via Google
56
- * Application Default Credentials that can be used to initialize an app.
57
- */
58
- function applicationDefault(httpAgent) {
25
+ exports.applicationDefault = function (httpAgent) {
59
26
  if (typeof globalAppDefaultCred === 'undefined') {
60
27
  globalAppDefaultCred = credential_internal_1.getApplicationDefault(httpAgent);
61
28
  }
62
29
  return globalAppDefaultCred;
63
- }
64
- exports.applicationDefault = applicationDefault;
65
- /**
66
- * Returns a credential created from the provided service account that grants
67
- * admin access to Firebase services. This credential can be used in the call
68
- * to
69
- * {@link
70
- * https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
71
- * `admin.initializeApp()`}.
72
- *
73
- * See
74
- * {@link
75
- * https://firebase.google.com/docs/admin/setup#initialize_the_sdk
76
- * Initialize the SDK}
77
- * for more details.
78
- *
79
- * @example
80
- * ```javascript
81
- * // Providing a path to a service account key JSON file
82
- * var serviceAccount = require("path/to/serviceAccountKey.json");
83
- * admin.initializeApp({
84
- * credential: admin.credential.cert(serviceAccount),
85
- * databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
86
- * });
87
- * ```
88
- *
89
- * @example
90
- * ```javascript
91
- * // Providing a service account object inline
92
- * admin.initializeApp({
93
- * credential: admin.credential.cert({
94
- * projectId: "<PROJECT_ID>",
95
- * clientEmail: "foo@<PROJECT_ID>.iam.gserviceaccount.com",
96
- * privateKey: "-----BEGIN PRIVATE KEY-----<KEY>-----END PRIVATE KEY-----\n"
97
- * }),
98
- * databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
99
- * });
100
- * ```
101
- *
102
- * @param serviceAccountPathOrObject The path to a service
103
- * account key JSON file or an object representing a service account key.
104
- * @param httpAgent Optional [HTTP Agent](https://nodejs.org/api/http.html#http_class_http_agent)
105
- * to be used when retrieving access tokens from Google token servers.
106
- *
107
- * @return A credential authenticated via the
108
- * provided service account that can be used to initialize an app.
109
- */
110
- function cert(serviceAccountPathOrObject, httpAgent) {
30
+ };
31
+ exports.cert = function (serviceAccountPathOrObject, httpAgent) {
111
32
  var stringifiedServiceAccount = JSON.stringify(serviceAccountPathOrObject);
112
33
  if (!(stringifiedServiceAccount in globalCertCreds)) {
113
34
  globalCertCreds[stringifiedServiceAccount] = new credential_internal_1.ServiceAccountCredential(serviceAccountPathOrObject, httpAgent);
114
35
  }
115
36
  return globalCertCreds[stringifiedServiceAccount];
116
- }
117
- exports.cert = cert;
118
- /**
119
- * Returns a credential created from the provided refresh token that grants
120
- * admin access to Firebase services. This credential can be used in the call
121
- * to
122
- * {@link
123
- * https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
124
- * `admin.initializeApp()`}.
125
- *
126
- * See
127
- * {@link
128
- * https://firebase.google.com/docs/admin/setup#initialize_the_sdk
129
- * Initialize the SDK}
130
- * for more details.
131
- *
132
- * @example
133
- * ```javascript
134
- * // Providing a path to a refresh token JSON file
135
- * var refreshToken = require("path/to/refreshToken.json");
136
- * admin.initializeApp({
137
- * credential: admin.credential.refreshToken(refreshToken),
138
- * databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
139
- * });
140
- * ```
141
- *
142
- * @param refreshTokenPathOrObject The path to a Google
143
- * OAuth2 refresh token JSON file or an object representing a Google OAuth2
144
- * refresh token.
145
- * @param httpAgent Optional [HTTP Agent](https://nodejs.org/api/http.html#http_class_http_agent)
146
- * to be used when retrieving access tokens from Google token servers.
147
- *
148
- * @return A credential authenticated via the
149
- * provided service account that can be used to initialize an app.
150
- */
151
- function refreshToken(refreshTokenPathOrObject, httpAgent) {
37
+ };
38
+ exports.refreshToken = function (refreshTokenPathOrObject, httpAgent) {
152
39
  var stringifiedRefreshToken = JSON.stringify(refreshTokenPathOrObject);
153
40
  if (!(stringifiedRefreshToken in globalRefreshTokenCreds)) {
154
41
  globalRefreshTokenCreds[stringifiedRefreshToken] = new credential_internal_1.RefreshTokenCredential(refreshTokenPathOrObject, httpAgent);
155
42
  }
156
43
  return globalRefreshTokenCreds[stringifiedRefreshToken];
157
- }
158
- exports.refreshToken = refreshToken;
44
+ };