firebase-admin 10.3.0 → 11.0.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 (192) hide show
  1. package/README.md +1 -2
  2. package/lib/app/core.d.ts +1 -1
  3. package/lib/app/core.js +1 -1
  4. package/lib/app/credential-factory.d.ts +1 -1
  5. package/lib/app/credential-factory.js +8 -8
  6. package/lib/app/credential-internal.d.ts +1 -1
  7. package/lib/app/credential-internal.js +97 -106
  8. package/lib/app/credential.d.ts +1 -1
  9. package/lib/app/credential.js +1 -1
  10. package/lib/app/firebase-app.d.ts +1 -1
  11. package/lib/app/firebase-app.js +76 -91
  12. package/lib/app/firebase-namespace.d.ts +1 -1
  13. package/lib/app/firebase-namespace.js +209 -279
  14. package/lib/app/index.d.ts +1 -1
  15. package/lib/app/index.js +4 -4
  16. package/lib/app/lifecycle.d.ts +1 -1
  17. package/lib/app/lifecycle.js +37 -43
  18. package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
  19. package/lib/app-check/app-check-api-client-internal.js +54 -73
  20. package/lib/app-check/app-check-api.d.ts +1 -1
  21. package/lib/app-check/app-check-api.js +1 -1
  22. package/lib/app-check/app-check-namespace.d.ts +1 -1
  23. package/lib/app-check/app-check-namespace.js +1 -1
  24. package/lib/app-check/app-check.d.ts +1 -1
  25. package/lib/app-check/app-check.js +17 -19
  26. package/lib/app-check/index.d.ts +1 -1
  27. package/lib/app-check/index.js +7 -7
  28. package/lib/app-check/token-generator.d.ts +1 -1
  29. package/lib/app-check/token-generator.js +47 -52
  30. package/lib/app-check/token-verifier.d.ts +1 -1
  31. package/lib/app-check/token-verifier.js +46 -50
  32. package/lib/auth/action-code-settings-builder.d.ts +1 -1
  33. package/lib/auth/action-code-settings-builder.js +10 -11
  34. package/lib/auth/auth-api-request.d.ts +1 -1
  35. package/lib/auth/auth-api-request.js +346 -393
  36. package/lib/auth/auth-config.d.ts +1 -1
  37. package/lib/auth/auth-config.js +95 -106
  38. package/lib/auth/auth-namespace.d.ts +1 -1
  39. package/lib/auth/auth-namespace.js +1 -1
  40. package/lib/auth/auth.d.ts +1 -1
  41. package/lib/auth/auth.js +20 -40
  42. package/lib/auth/base-auth.d.ts +1 -1
  43. package/lib/auth/base-auth.js +137 -144
  44. package/lib/auth/identifier.d.ts +1 -1
  45. package/lib/auth/identifier.js +2 -2
  46. package/lib/auth/index.d.ts +1 -1
  47. package/lib/auth/index.js +7 -7
  48. package/lib/auth/tenant-manager.d.ts +1 -1
  49. package/lib/auth/tenant-manager.js +49 -71
  50. package/lib/auth/tenant.d.ts +1 -1
  51. package/lib/auth/tenant.js +44 -55
  52. package/lib/auth/token-generator.d.ts +1 -1
  53. package/lib/auth/token-generator.js +49 -53
  54. package/lib/auth/token-verifier.d.ts +1 -1
  55. package/lib/auth/token-verifier.js +83 -91
  56. package/lib/auth/user-import-builder.d.ts +1 -1
  57. package/lib/auth/user-import-builder.js +70 -73
  58. package/lib/auth/user-record.d.ts +1 -1
  59. package/lib/auth/user-record.js +61 -84
  60. package/lib/credential/index.d.ts +1 -1
  61. package/lib/credential/index.js +2 -2
  62. package/lib/database/database-namespace.d.ts +1 -1
  63. package/lib/database/database-namespace.js +1 -1
  64. package/lib/database/database.d.ts +1 -1
  65. package/lib/database/database.js +92 -108
  66. package/lib/database/index.d.ts +1 -1
  67. package/lib/database/index.js +10 -10
  68. package/lib/default-namespace.d.ts +1 -1
  69. package/lib/default-namespace.js +2 -2
  70. package/lib/eventarc/cloudevent.d.ts +1 -1
  71. package/lib/eventarc/cloudevent.js +1 -1
  72. package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
  73. package/lib/eventarc/eventarc-client-internal.js +63 -129
  74. package/lib/eventarc/eventarc-utils.d.ts +1 -1
  75. package/lib/eventarc/eventarc-utils.js +16 -32
  76. package/lib/eventarc/eventarc.d.ts +1 -1
  77. package/lib/eventarc/eventarc.js +51 -65
  78. package/lib/eventarc/index.d.ts +1 -1
  79. package/lib/eventarc/index.js +7 -7
  80. package/lib/firebase-namespace-api.d.ts +1 -1
  81. package/lib/firebase-namespace-api.js +8 -3
  82. package/lib/firestore/firestore-internal.d.ts +1 -1
  83. package/lib/firestore/firestore-internal.js +28 -37
  84. package/lib/firestore/firestore-namespace.d.ts +9 -1
  85. package/lib/firestore/firestore-namespace.js +2 -2
  86. package/lib/firestore/index.d.ts +2 -2
  87. package/lib/firestore/index.js +7 -7
  88. package/lib/functions/functions-api-client-internal.d.ts +1 -1
  89. package/lib/functions/functions-api-client-internal.js +71 -93
  90. package/lib/functions/functions-api.d.ts +1 -1
  91. package/lib/functions/functions-api.js +1 -1
  92. package/lib/functions/functions.d.ts +1 -1
  93. package/lib/functions/functions.js +13 -15
  94. package/lib/functions/index.d.ts +1 -1
  95. package/lib/functions/index.js +7 -7
  96. package/lib/index.d.ts +1 -1
  97. package/lib/index.js +14 -4
  98. package/lib/installations/index.d.ts +1 -1
  99. package/lib/installations/index.js +6 -6
  100. package/lib/installations/installations-namespace.d.ts +1 -1
  101. package/lib/installations/installations-namespace.js +1 -1
  102. package/lib/installations/installations-request-handler.d.ts +1 -1
  103. package/lib/installations/installations-request-handler.js +33 -36
  104. package/lib/installations/installations.d.ts +1 -1
  105. package/lib/installations/installations.js +17 -22
  106. package/lib/instance-id/index.d.ts +1 -1
  107. package/lib/instance-id/index.js +6 -6
  108. package/lib/instance-id/instance-id-namespace.d.ts +1 -1
  109. package/lib/instance-id/instance-id-namespace.js +1 -1
  110. package/lib/instance-id/instance-id.d.ts +1 -1
  111. package/lib/instance-id/instance-id.js +21 -26
  112. package/lib/machine-learning/index.d.ts +1 -1
  113. package/lib/machine-learning/index.js +7 -7
  114. package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
  115. package/lib/machine-learning/machine-learning-api-client.js +110 -124
  116. package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
  117. package/lib/machine-learning/machine-learning-namespace.js +1 -1
  118. package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
  119. package/lib/machine-learning/machine-learning-utils.js +9 -24
  120. package/lib/machine-learning/machine-learning.d.ts +1 -1
  121. package/lib/machine-learning/machine-learning.js +146 -207
  122. package/lib/messaging/batch-request-internal.d.ts +1 -1
  123. package/lib/messaging/batch-request-internal.js +33 -35
  124. package/lib/messaging/index.d.ts +1 -1
  125. package/lib/messaging/index.js +7 -7
  126. package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
  127. package/lib/messaging/messaging-api-request-internal.js +38 -40
  128. package/lib/messaging/messaging-api.d.ts +1 -1
  129. package/lib/messaging/messaging-api.js +1 -1
  130. package/lib/messaging/messaging-errors-internal.d.ts +1 -1
  131. package/lib/messaging/messaging-errors-internal.js +12 -13
  132. package/lib/messaging/messaging-internal.d.ts +1 -1
  133. package/lib/messaging/messaging-internal.js +51 -51
  134. package/lib/messaging/messaging-namespace.d.ts +1 -1
  135. package/lib/messaging/messaging-namespace.js +1 -1
  136. package/lib/messaging/messaging.d.ts +1 -1
  137. package/lib/messaging/messaging.js +184 -208
  138. package/lib/project-management/android-app.d.ts +1 -1
  139. package/lib/project-management/android-app.js +41 -43
  140. package/lib/project-management/app-metadata.d.ts +1 -1
  141. package/lib/project-management/app-metadata.js +1 -1
  142. package/lib/project-management/index.d.ts +1 -1
  143. package/lib/project-management/index.js +7 -7
  144. package/lib/project-management/ios-app.d.ts +1 -1
  145. package/lib/project-management/ios-app.js +25 -26
  146. package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
  147. package/lib/project-management/project-management-api-request-internal.js +84 -89
  148. package/lib/project-management/project-management-namespace.d.ts +1 -1
  149. package/lib/project-management/project-management-namespace.js +1 -1
  150. package/lib/project-management/project-management.d.ts +1 -1
  151. package/lib/project-management/project-management.js +80 -87
  152. package/lib/remote-config/index.d.ts +1 -1
  153. package/lib/remote-config/index.js +7 -7
  154. package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
  155. package/lib/remote-config/remote-config-api-client-internal.js +116 -154
  156. package/lib/remote-config/remote-config-api.d.ts +1 -1
  157. package/lib/remote-config/remote-config-api.js +1 -1
  158. package/lib/remote-config/remote-config-namespace.d.ts +1 -1
  159. package/lib/remote-config/remote-config-namespace.js +1 -1
  160. package/lib/remote-config/remote-config.d.ts +1 -1
  161. package/lib/remote-config/remote-config.js +51 -59
  162. package/lib/security-rules/index.d.ts +1 -1
  163. package/lib/security-rules/index.js +7 -7
  164. package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
  165. package/lib/security-rules/security-rules-api-client-internal.js +95 -107
  166. package/lib/security-rules/security-rules-internal.d.ts +1 -1
  167. package/lib/security-rules/security-rules-internal.js +6 -21
  168. package/lib/security-rules/security-rules-namespace.d.ts +1 -1
  169. package/lib/security-rules/security-rules-namespace.js +1 -1
  170. package/lib/security-rules/security-rules.d.ts +1 -1
  171. package/lib/security-rules/security-rules.js +82 -91
  172. package/lib/storage/index.d.ts +1 -1
  173. package/lib/storage/index.js +7 -7
  174. package/lib/storage/storage-namespace.d.ts +1 -1
  175. package/lib/storage/storage-namespace.js +1 -1
  176. package/lib/storage/storage.d.ts +1 -1
  177. package/lib/storage/storage.js +25 -30
  178. package/lib/utils/api-request.d.ts +3 -1
  179. package/lib/utils/api-request.js +278 -356
  180. package/lib/utils/crypto-signer.d.ts +1 -1
  181. package/lib/utils/crypto-signer.js +58 -93
  182. package/lib/utils/deep-copy.d.ts +1 -1
  183. package/lib/utils/deep-copy.js +3 -3
  184. package/lib/utils/error.d.ts +1 -1
  185. package/lib/utils/error.js +611 -681
  186. package/lib/utils/index.d.ts +1 -1
  187. package/lib/utils/index.js +38 -43
  188. package/lib/utils/jwt.d.ts +1 -1
  189. package/lib/utils/jwt.js +97 -123
  190. package/lib/utils/validator.d.ts +1 -1
  191. package/lib/utils/validator.js +13 -13
  192. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -34,7 +34,7 @@ function isPhoneIdentifier(id) {
34
34
  }
35
35
  exports.isPhoneIdentifier = isPhoneIdentifier;
36
36
  function isProviderIdentifier(id) {
37
- var pid = id;
37
+ const pid = id;
38
38
  return pid.providerId !== undefined && pid.providerUid !== undefined;
39
39
  }
40
40
  exports.isProviderIdentifier = isProviderIdentifier;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
package/lib/auth/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -16,14 +16,14 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.getAuth = void 0;
19
+ exports.UserRecord = exports.UserMetadata = exports.UserInfo = exports.PhoneMultiFactorInfo = exports.MultiFactorSettings = exports.MultiFactorInfo = exports.TenantManager = exports.TenantAwareAuth = exports.Tenant = exports.BaseAuth = exports.Auth = exports.getAuth = void 0;
20
20
  /**
21
21
  * Firebase Authentication.
22
22
  *
23
23
  * @packageDocumentation
24
24
  */
25
- var index_1 = require("../app/index");
26
- var auth_1 = require("./auth");
25
+ const index_1 = require("../app/index");
26
+ const auth_1 = require("./auth");
27
27
  /**
28
28
  * Gets the {@link Auth} service for the default app or a
29
29
  * given app.
@@ -47,10 +47,10 @@ var auth_1 = require("./auth");
47
47
  */
48
48
  function getAuth(app) {
49
49
  if (typeof app === 'undefined') {
50
- app = index_1.getApp();
50
+ app = (0, index_1.getApp)();
51
51
  }
52
- var firebaseApp = app;
53
- return firebaseApp.getOrInitService('auth', function (app) { return new auth_1.Auth(app); });
52
+ const firebaseApp = app;
53
+ return firebaseApp.getOrInitService('auth', (app) => new auth_1.Auth(app));
54
54
  }
55
55
  exports.getAuth = getAuth;
56
56
  var auth_2 = require("./auth");
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -15,27 +15,14 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- var __extends = (this && this.__extends) || (function () {
19
- var extendStatics = function (d, b) {
20
- extendStatics = Object.setPrototypeOf ||
21
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23
- return extendStatics(d, b);
24
- };
25
- return function (d, b) {
26
- extendStatics(d, b);
27
- function __() { this.constructor = d; }
28
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29
- };
30
- })();
31
18
  Object.defineProperty(exports, "__esModule", { value: true });
32
19
  exports.TenantManager = exports.TenantAwareAuth = void 0;
33
- var validator = require("../utils/validator");
34
- var utils = require("../utils/index");
35
- var error_1 = require("../utils/error");
36
- var base_auth_1 = require("./base-auth");
37
- var tenant_1 = require("./tenant");
38
- var auth_api_request_1 = require("./auth-api-request");
20
+ const validator = require("../utils/validator");
21
+ const utils = require("../utils/index");
22
+ const error_1 = require("../utils/error");
23
+ const base_auth_1 = require("./base-auth");
24
+ const tenant_1 = require("./tenant");
25
+ const auth_api_request_1 = require("./auth-api-request");
39
26
  /**
40
27
  * Tenant-aware `Auth` interface used for managing users, configuring SAML/OIDC providers,
41
28
  * generating email links for password reset, email verification, etc for specific tenants.
@@ -53,8 +40,7 @@ var auth_api_request_1 = require("./auth-api-request");
53
40
  * `TenantAwareAuth` instances for a specific `tenantId` can be instantiated by calling
54
41
  * {@link TenantManager.authForTenant}.
55
42
  */
56
- var TenantAwareAuth = /** @class */ (function (_super) {
57
- __extends(TenantAwareAuth, _super);
43
+ class TenantAwareAuth extends base_auth_1.BaseAuth {
58
44
  /**
59
45
  * The TenantAwareAuth class constructor.
60
46
  *
@@ -63,31 +49,27 @@ var TenantAwareAuth = /** @class */ (function (_super) {
63
49
  * @constructor
64
50
  * @internal
65
51
  */
66
- function TenantAwareAuth(app, tenantId) {
67
- var _this = _super.call(this, app, new auth_api_request_1.TenantAwareAuthRequestHandler(app, tenantId), base_auth_1.createFirebaseTokenGenerator(app, tenantId)) || this;
68
- utils.addReadonlyGetter(_this, 'tenantId', tenantId);
69
- return _this;
52
+ constructor(app, tenantId) {
53
+ super(app, new auth_api_request_1.TenantAwareAuthRequestHandler(app, tenantId), (0, base_auth_1.createFirebaseTokenGenerator)(app, tenantId));
54
+ utils.addReadonlyGetter(this, 'tenantId', tenantId);
70
55
  }
71
56
  /**
72
57
  * {@inheritdoc BaseAuth.verifyIdToken}
73
58
  */
74
- TenantAwareAuth.prototype.verifyIdToken = function (idToken, checkRevoked) {
75
- var _this = this;
76
- if (checkRevoked === void 0) { checkRevoked = false; }
77
- return _super.prototype.verifyIdToken.call(this, idToken, checkRevoked)
78
- .then(function (decodedClaims) {
59
+ verifyIdToken(idToken, checkRevoked = false) {
60
+ return super.verifyIdToken(idToken, checkRevoked)
61
+ .then((decodedClaims) => {
79
62
  // Validate tenant ID.
80
- if (decodedClaims.firebase.tenant !== _this.tenantId) {
63
+ if (decodedClaims.firebase.tenant !== this.tenantId) {
81
64
  throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.MISMATCHING_TENANT_ID);
82
65
  }
83
66
  return decodedClaims;
84
67
  });
85
- };
68
+ }
86
69
  /**
87
70
  * {@inheritdoc BaseAuth.createSessionCookie}
88
71
  */
89
- TenantAwareAuth.prototype.createSessionCookie = function (idToken, sessionCookieOptions) {
90
- var _this = this;
72
+ createSessionCookie(idToken, sessionCookieOptions) {
91
73
  // Validate arguments before processing.
92
74
  if (!validator.isNonEmptyString(idToken)) {
93
75
  return Promise.reject(new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ID_TOKEN));
@@ -98,26 +80,23 @@ var TenantAwareAuth = /** @class */ (function (_super) {
98
80
  }
99
81
  // This will verify the ID token and then match the tenant ID before creating the session cookie.
100
82
  return this.verifyIdToken(idToken)
101
- .then(function () {
102
- return _super.prototype.createSessionCookie.call(_this, idToken, sessionCookieOptions);
83
+ .then(() => {
84
+ return super.createSessionCookie(idToken, sessionCookieOptions);
103
85
  });
104
- };
86
+ }
105
87
  /**
106
88
  * {@inheritdoc BaseAuth.verifySessionCookie}
107
89
  */
108
- TenantAwareAuth.prototype.verifySessionCookie = function (sessionCookie, checkRevoked) {
109
- var _this = this;
110
- if (checkRevoked === void 0) { checkRevoked = false; }
111
- return _super.prototype.verifySessionCookie.call(this, sessionCookie, checkRevoked)
112
- .then(function (decodedClaims) {
113
- if (decodedClaims.firebase.tenant !== _this.tenantId) {
90
+ verifySessionCookie(sessionCookie, checkRevoked = false) {
91
+ return super.verifySessionCookie(sessionCookie, checkRevoked)
92
+ .then((decodedClaims) => {
93
+ if (decodedClaims.firebase.tenant !== this.tenantId) {
114
94
  throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.MISMATCHING_TENANT_ID);
115
95
  }
116
96
  return decodedClaims;
117
97
  });
118
- };
119
- return TenantAwareAuth;
120
- }(base_auth_1.BaseAuth));
98
+ }
99
+ }
121
100
  exports.TenantAwareAuth = TenantAwareAuth;
122
101
  /**
123
102
  * Defines the tenant manager used to help manage tenant related operations.
@@ -130,7 +109,7 @@ exports.TenantAwareAuth = TenantAwareAuth;
130
109
  * email link generation, etc) in the context of a specified tenant.</li>
131
110
  * </ul>
132
111
  */
133
- var TenantManager = /** @class */ (function () {
112
+ class TenantManager {
134
113
  /**
135
114
  * Initializes a TenantManager instance for a specified FirebaseApp.
136
115
  *
@@ -139,7 +118,7 @@ var TenantManager = /** @class */ (function () {
139
118
  * @constructor
140
119
  * @internal
141
120
  */
142
- function TenantManager(app) {
121
+ constructor(app) {
143
122
  this.app = app;
144
123
  this.authRequestHandler = new auth_api_request_1.AuthRequestHandler(app);
145
124
  this.tenantsMap = {};
@@ -151,7 +130,7 @@ var TenantManager = /** @class */ (function () {
151
130
  *
152
131
  * @returns The `TenantAwareAuth` instance corresponding to this tenant identifier.
153
132
  */
154
- TenantManager.prototype.authForTenant = function (tenantId) {
133
+ authForTenant(tenantId) {
155
134
  if (!validator.isNonEmptyString(tenantId)) {
156
135
  throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_TENANT_ID);
157
136
  }
@@ -159,7 +138,7 @@ var TenantManager = /** @class */ (function () {
159
138
  this.tenantsMap[tenantId] = new TenantAwareAuth(this.app, tenantId);
160
139
  }
161
140
  return this.tenantsMap[tenantId];
162
- };
141
+ }
163
142
  /**
164
143
  * Gets the tenant configuration for the tenant corresponding to a given `tenantId`.
165
144
  *
@@ -167,12 +146,12 @@ var TenantManager = /** @class */ (function () {
167
146
  *
168
147
  * @returns A promise fulfilled with the tenant configuration to the provided `tenantId`.
169
148
  */
170
- TenantManager.prototype.getTenant = function (tenantId) {
149
+ getTenant(tenantId) {
171
150
  return this.authRequestHandler.getTenant(tenantId)
172
- .then(function (response) {
151
+ .then((response) => {
173
152
  return new tenant_1.Tenant(response);
174
153
  });
175
- };
154
+ }
176
155
  /**
177
156
  * Retrieves a list of tenants (single batch only) with a size of `maxResults`
178
157
  * starting from the offset as specified by `pageToken`. This is used to
@@ -186,18 +165,18 @@ var TenantManager = /** @class */ (function () {
186
165
  * @returns A promise that resolves with
187
166
  * a batch of downloaded tenants and the next page token.
188
167
  */
189
- TenantManager.prototype.listTenants = function (maxResults, pageToken) {
168
+ listTenants(maxResults, pageToken) {
190
169
  return this.authRequestHandler.listTenants(maxResults, pageToken)
191
- .then(function (response) {
170
+ .then((response) => {
192
171
  // List of tenants to return.
193
- var tenants = [];
172
+ const tenants = [];
194
173
  // Convert each user response to a Tenant.
195
- response.tenants.forEach(function (tenantResponse) {
174
+ response.tenants.forEach((tenantResponse) => {
196
175
  tenants.push(new tenant_1.Tenant(tenantResponse));
197
176
  });
198
177
  // Return list of tenants and the next page token if available.
199
- var result = {
200
- tenants: tenants,
178
+ const result = {
179
+ tenants,
201
180
  pageToken: response.nextPageToken,
202
181
  };
203
182
  // Delete result.pageToken if undefined.
@@ -206,7 +185,7 @@ var TenantManager = /** @class */ (function () {
206
185
  }
207
186
  return result;
208
187
  });
209
- };
188
+ }
210
189
  /**
211
190
  * Deletes an existing tenant.
212
191
  *
@@ -214,9 +193,9 @@ var TenantManager = /** @class */ (function () {
214
193
  *
215
194
  * @returns An empty promise fulfilled once the tenant has been deleted.
216
195
  */
217
- TenantManager.prototype.deleteTenant = function (tenantId) {
196
+ deleteTenant(tenantId) {
218
197
  return this.authRequestHandler.deleteTenant(tenantId);
219
- };
198
+ }
220
199
  /**
221
200
  * Creates a new tenant.
222
201
  * When creating new tenants, tenants that use separate billing and quota will require their
@@ -227,12 +206,12 @@ var TenantManager = /** @class */ (function () {
227
206
  * @returns A promise fulfilled with the tenant configuration corresponding to the newly
228
207
  * created tenant.
229
208
  */
230
- TenantManager.prototype.createTenant = function (tenantOptions) {
209
+ createTenant(tenantOptions) {
231
210
  return this.authRequestHandler.createTenant(tenantOptions)
232
- .then(function (response) {
211
+ .then((response) => {
233
212
  return new tenant_1.Tenant(response);
234
213
  });
235
- };
214
+ }
236
215
  /**
237
216
  * Updates an existing tenant configuration.
238
217
  *
@@ -241,12 +220,11 @@ var TenantManager = /** @class */ (function () {
241
220
  *
242
221
  * @returns A promise fulfilled with the update tenant data.
243
222
  */
244
- TenantManager.prototype.updateTenant = function (tenantId, tenantOptions) {
223
+ updateTenant(tenantId, tenantOptions) {
245
224
  return this.authRequestHandler.updateTenant(tenantId, tenantOptions)
246
- .then(function (response) {
225
+ .then((response) => {
247
226
  return new tenant_1.Tenant(response);
248
227
  });
249
- };
250
- return TenantManager;
251
- }());
228
+ }
229
+ }
252
230
  exports.TenantManager = TenantManager;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -17,10 +17,10 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.Tenant = void 0;
20
- var validator = require("../utils/validator");
21
- var deep_copy_1 = require("../utils/deep-copy");
22
- var error_1 = require("../utils/error");
23
- var auth_config_1 = require("./auth-config");
20
+ const validator = require("../utils/validator");
21
+ const deep_copy_1 = require("../utils/deep-copy");
22
+ const error_1 = require("../utils/error");
23
+ const auth_config_1 = require("./auth-config");
24
24
  /**
25
25
  * Represents a tenant configuration.
26
26
  *
@@ -41,7 +41,7 @@ var auth_config_1 = require("./auth-config");
41
41
  * All other settings of a tenant will also be inherited. These will need to be managed
42
42
  * from the Cloud Console UI.
43
43
  */
44
- var Tenant = /** @class */ (function () {
44
+ class Tenant {
45
45
  /**
46
46
  * The Tenant object constructor.
47
47
  *
@@ -49,8 +49,8 @@ var Tenant = /** @class */ (function () {
49
49
  * @constructor
50
50
  * @internal
51
51
  */
52
- function Tenant(response) {
53
- var tenantId = Tenant.getTenantIdFromResourceName(response.name);
52
+ constructor(response) {
53
+ const tenantId = Tenant.getTenantIdFromResourceName(response.name);
54
54
  if (!tenantId) {
55
55
  throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INTERNAL_ERROR, 'INTERNAL ASSERT FAILED: Invalid tenant response');
56
56
  }
@@ -70,7 +70,7 @@ var Tenant = /** @class */ (function () {
70
70
  this.multiFactorConfig_ = new auth_config_1.MultiFactorAuthConfig(response.mfaConfig);
71
71
  }
72
72
  if (typeof response.testPhoneNumbers !== 'undefined') {
73
- this.testPhoneNumbers = deep_copy_1.deepCopy(response.testPhoneNumbers || {});
73
+ this.testPhoneNumbers = (0, deep_copy_1.deepCopy)(response.testPhoneNumbers || {});
74
74
  }
75
75
  }
76
76
  /**
@@ -82,10 +82,9 @@ var Tenant = /** @class */ (function () {
82
82
  *
83
83
  * @internal
84
84
  */
85
- Tenant.buildServerRequest = function (tenantOptions, createRequest) {
86
- var _a;
85
+ static buildServerRequest(tenantOptions, createRequest) {
87
86
  Tenant.validate(tenantOptions, createRequest);
88
- var request = {};
87
+ let request = {};
89
88
  if (typeof tenantOptions.emailSignInConfig !== 'undefined') {
90
89
  request = auth_config_1.EmailSignInConfig.buildServerRequest(tenantOptions.emailSignInConfig);
91
90
  }
@@ -100,10 +99,10 @@ var Tenant = /** @class */ (function () {
100
99
  }
101
100
  if (typeof tenantOptions.testPhoneNumbers !== 'undefined') {
102
101
  // null will clear existing test phone numbers. Translate to empty object.
103
- request.testPhoneNumbers = (_a = tenantOptions.testPhoneNumbers) !== null && _a !== void 0 ? _a : {};
102
+ request.testPhoneNumbers = tenantOptions.testPhoneNumbers ?? {};
104
103
  }
105
104
  return request;
106
- };
105
+ }
107
106
  /**
108
107
  * Returns the tenant ID corresponding to the resource name if available.
109
108
  *
@@ -112,42 +111,42 @@ var Tenant = /** @class */ (function () {
112
111
  *
113
112
  * @internal
114
113
  */
115
- Tenant.getTenantIdFromResourceName = function (resourceName) {
114
+ static getTenantIdFromResourceName(resourceName) {
116
115
  // name is of form projects/project1/tenants/tenant1
117
- var matchTenantRes = resourceName.match(/\/tenants\/(.*)$/);
116
+ const matchTenantRes = resourceName.match(/\/tenants\/(.*)$/);
118
117
  if (!matchTenantRes || matchTenantRes.length < 2) {
119
118
  return null;
120
119
  }
121
120
  return matchTenantRes[1];
122
- };
121
+ }
123
122
  /**
124
123
  * Validates a tenant options object. Throws an error on failure.
125
124
  *
126
125
  * @param request - The tenant options object to validate.
127
126
  * @param createRequest - Whether this is a create request.
128
127
  */
129
- Tenant.validate = function (request, createRequest) {
130
- var validKeys = {
128
+ static validate(request, createRequest) {
129
+ const validKeys = {
131
130
  displayName: true,
132
131
  emailSignInConfig: true,
133
132
  anonymousSignInEnabled: true,
134
133
  multiFactorConfig: true,
135
134
  testPhoneNumbers: true,
136
135
  };
137
- var label = createRequest ? 'CreateTenantRequest' : 'UpdateTenantRequest';
136
+ const label = createRequest ? 'CreateTenantRequest' : 'UpdateTenantRequest';
138
137
  if (!validator.isNonNullObject(request)) {
139
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "\"" + label + "\" must be a valid non-null object.");
138
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, `"${label}" must be a valid non-null object.`);
140
139
  }
141
140
  // Check for unsupported top level attributes.
142
- for (var key in request) {
141
+ for (const key in request) {
143
142
  if (!(key in validKeys)) {
144
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "\"" + key + "\" is not a valid " + label + " parameter.");
143
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, `"${key}" is not a valid ${label} parameter.`);
145
144
  }
146
145
  }
147
146
  // Validate displayName type if provided.
148
147
  if (typeof request.displayName !== 'undefined' &&
149
148
  !validator.isNonEmptyString(request.displayName)) {
150
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "\"" + label + ".displayName\" must be a valid non-empty string.");
149
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, `"${label}.displayName" must be a valid non-empty string.`);
151
150
  }
152
151
  // Validate emailSignInConfig type if provided.
153
152
  if (typeof request.emailSignInConfig !== 'undefined') {
@@ -157,50 +156,41 @@ var Tenant = /** @class */ (function () {
157
156
  // Validate test phone numbers if provided.
158
157
  if (typeof request.testPhoneNumbers !== 'undefined' &&
159
158
  request.testPhoneNumbers !== null) {
160
- auth_config_1.validateTestPhoneNumbers(request.testPhoneNumbers);
159
+ (0, auth_config_1.validateTestPhoneNumbers)(request.testPhoneNumbers);
161
160
  }
162
161
  else if (request.testPhoneNumbers === null && createRequest) {
163
162
  // null allowed only for update operations.
164
- throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, "\"" + label + ".testPhoneNumbers\" must be a non-null object.");
163
+ throw new error_1.FirebaseAuthError(error_1.AuthClientErrorCode.INVALID_ARGUMENT, `"${label}.testPhoneNumbers" must be a non-null object.`);
165
164
  }
166
165
  // Validate multiFactorConfig type if provided.
167
166
  if (typeof request.multiFactorConfig !== 'undefined') {
168
167
  // This will throw an error if invalid.
169
168
  auth_config_1.MultiFactorAuthConfig.buildServerRequest(request.multiFactorConfig);
170
169
  }
171
- };
172
- Object.defineProperty(Tenant.prototype, "emailSignInConfig", {
173
- /**
174
- * The email sign in provider configuration.
175
- */
176
- get: function () {
177
- return this.emailSignInConfig_;
178
- },
179
- enumerable: false,
180
- configurable: true
181
- });
182
- Object.defineProperty(Tenant.prototype, "multiFactorConfig", {
183
- /**
184
- * The multi-factor auth configuration on the current tenant.
185
- */
186
- get: function () {
187
- return this.multiFactorConfig_;
188
- },
189
- enumerable: false,
190
- configurable: true
191
- });
170
+ }
171
+ /**
172
+ * The email sign in provider configuration.
173
+ */
174
+ get emailSignInConfig() {
175
+ return this.emailSignInConfig_;
176
+ }
177
+ /**
178
+ * The multi-factor auth configuration on the current tenant.
179
+ */
180
+ get multiFactorConfig() {
181
+ return this.multiFactorConfig_;
182
+ }
192
183
  /**
193
184
  * Returns a JSON-serializable representation of this object.
194
185
  *
195
186
  * @returns A JSON-serializable representation of this object.
196
187
  */
197
- Tenant.prototype.toJSON = function () {
198
- var _a, _b;
199
- var json = {
188
+ toJSON() {
189
+ const json = {
200
190
  tenantId: this.tenantId,
201
191
  displayName: this.displayName,
202
- emailSignInConfig: (_a = this.emailSignInConfig_) === null || _a === void 0 ? void 0 : _a.toJSON(),
203
- multiFactorConfig: (_b = this.multiFactorConfig_) === null || _b === void 0 ? void 0 : _b.toJSON(),
192
+ emailSignInConfig: this.emailSignInConfig_?.toJSON(),
193
+ multiFactorConfig: this.multiFactorConfig_?.toJSON(),
204
194
  anonymousSignInEnabled: this.anonymousSignInEnabled,
205
195
  testPhoneNumbers: this.testPhoneNumbers,
206
196
  };
@@ -211,7 +201,6 @@ var Tenant = /** @class */ (function () {
211
201
  delete json.testPhoneNumbers;
212
202
  }
213
203
  return json;
214
- };
215
- return Tenant;
216
- }());
204
+ }
205
+ }
217
206
  exports.Tenant = Tenant;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.