firebase-admin 9.100.0-alpha.0 → 10.0.2

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 (188) hide show
  1. package/README.md +7 -3
  2. package/lib/app/core.d.ts +15 -22
  3. package/lib/app/core.js +1 -1
  4. package/lib/app/credential-factory.d.ts +17 -33
  5. package/lib/app/credential-factory.js +17 -33
  6. package/lib/app/credential-internal.d.ts +10 -9
  7. package/lib/app/credential-internal.js +15 -13
  8. package/lib/app/credential.d.ts +3 -9
  9. package/lib/app/credential.js +1 -1
  10. package/lib/app/firebase-app.d.ts +6 -30
  11. package/lib/app/firebase-app.js +72 -216
  12. package/lib/app/firebase-namespace.d.ts +28 -34
  13. package/lib/app/firebase-namespace.js +119 -99
  14. package/lib/app/index.d.ts +6 -1
  15. package/lib/app/index.js +1 -1
  16. package/lib/app/lifecycle.d.ts +24 -3
  17. package/lib/app/lifecycle.js +119 -25
  18. package/lib/app-check/app-check-api-client-internal.d.ts +32 -0
  19. package/lib/app-check/app-check-api-client-internal.js +197 -0
  20. package/lib/app-check/app-check-api.d.ts +95 -0
  21. package/lib/app-check/app-check-api.js +19 -0
  22. package/lib/app-check/app-check-namespace.d.ts +65 -0
  23. package/lib/app-check/app-check-namespace.js +18 -0
  24. package/lib/app-check/app-check.d.ts +49 -0
  25. package/lib/app-check/app-check.js +82 -0
  26. package/lib/app-check/index.d.ts +53 -0
  27. package/lib/app-check/index.js +63 -0
  28. package/lib/app-check/token-generator.d.ts +25 -0
  29. package/lib/app-check/token-generator.js +159 -0
  30. package/lib/app-check/token-verifier.d.ts +17 -0
  31. package/lib/app-check/token-verifier.js +151 -0
  32. package/lib/auth/action-code-settings-builder.d.ts +1 -1
  33. package/lib/auth/action-code-settings-builder.js +2 -2
  34. package/lib/auth/auth-api-request.d.ts +28 -32
  35. package/lib/auth/auth-api-request.js +167 -125
  36. package/lib/auth/auth-config.d.ts +123 -21
  37. package/lib/auth/auth-config.js +85 -34
  38. package/lib/auth/auth-namespace.d.ts +157 -4
  39. package/lib/auth/auth-namespace.js +1 -1
  40. package/lib/auth/auth.d.ts +5 -3
  41. package/lib/auth/auth.js +6 -4
  42. package/lib/auth/base-auth.d.ts +134 -116
  43. package/lib/auth/base-auth.js +213 -143
  44. package/lib/auth/identifier.d.ts +5 -5
  45. package/lib/auth/identifier.js +1 -1
  46. package/lib/auth/index.d.ts +10 -5
  47. package/lib/auth/index.js +9 -4
  48. package/lib/auth/tenant-manager.d.ts +19 -19
  49. package/lib/auth/tenant-manager.js +21 -25
  50. package/lib/auth/tenant.d.ts +14 -5
  51. package/lib/auth/tenant.js +19 -11
  52. package/lib/auth/token-generator.d.ts +7 -108
  53. package/lib/auth/token-generator.js +52 -145
  54. package/lib/auth/token-verifier.d.ts +3 -4
  55. package/lib/auth/token-verifier.js +96 -145
  56. package/lib/auth/user-import-builder.d.ts +11 -11
  57. package/lib/auth/user-import-builder.js +9 -9
  58. package/lib/auth/user-record.d.ts +23 -15
  59. package/lib/auth/user-record.js +30 -20
  60. package/lib/credential/index.d.ts +18 -35
  61. package/lib/credential/index.js +17 -33
  62. package/lib/database/database-namespace.d.ts +39 -10
  63. package/lib/database/database-namespace.js +1 -1
  64. package/lib/database/database.d.ts +16 -6
  65. package/lib/database/database.js +61 -6
  66. package/lib/database/index.d.ts +19 -18
  67. package/lib/database/index.js +21 -23
  68. package/lib/default-namespace.d.ts +7 -1
  69. package/lib/default-namespace.js +4 -4
  70. package/lib/esm/app/index.js +10 -0
  71. package/lib/esm/app-check/index.js +4 -0
  72. package/lib/esm/auth/index.js +14 -0
  73. package/lib/esm/database/index.js +6 -0
  74. package/lib/esm/firestore/index.js +24 -0
  75. package/lib/esm/installations/index.js +4 -0
  76. package/lib/esm/instance-id/index.js +4 -0
  77. package/lib/esm/machine-learning/index.js +5 -0
  78. package/lib/esm/messaging/index.js +4 -0
  79. package/lib/esm/package.json +1 -0
  80. package/lib/esm/project-management/index.js +8 -0
  81. package/lib/esm/remote-config/index.js +4 -0
  82. package/lib/esm/security-rules/index.js +6 -0
  83. package/lib/esm/storage/index.js +4 -0
  84. package/lib/firebase-namespace-api.d.ts +12 -6
  85. package/lib/firebase-namespace-api.js +5 -1
  86. package/lib/firestore/firestore-internal.d.ts +2 -2
  87. package/lib/firestore/firestore-internal.js +2 -2
  88. package/lib/firestore/firestore-namespace.d.ts +6 -1
  89. package/lib/firestore/firestore-namespace.js +2 -1
  90. package/lib/firestore/index.d.ts +36 -4
  91. package/lib/firestore/index.js +29 -1
  92. package/lib/index.d.ts +1 -1
  93. package/lib/index.js +1 -1
  94. package/lib/installations/index.d.ts +52 -0
  95. package/lib/installations/index.js +62 -0
  96. package/lib/installations/installations-namespace.d.ts +55 -0
  97. package/lib/installations/installations-namespace.js +18 -0
  98. package/lib/{instance-id/instance-id-request-internal.d.ts → installations/installations-request-handler.d.ts} +8 -8
  99. package/lib/{instance-id/instance-id-request-internal.js → installations/installations-request-handler.js} +23 -23
  100. package/lib/installations/installations.d.ts +38 -0
  101. package/lib/installations/installations.js +63 -0
  102. package/lib/instance-id/index.d.ts +20 -9
  103. package/lib/instance-id/index.js +20 -9
  104. package/lib/instance-id/instance-id-namespace.d.ts +9 -8
  105. package/lib/instance-id/instance-id-namespace.js +1 -1
  106. package/lib/instance-id/instance-id.d.ts +8 -6
  107. package/lib/instance-id/instance-id.js +20 -11
  108. package/lib/machine-learning/index.d.ts +29 -27
  109. package/lib/machine-learning/index.js +29 -27
  110. package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
  111. package/lib/machine-learning/machine-learning-api-client.js +4 -4
  112. package/lib/machine-learning/machine-learning-namespace.d.ts +33 -8
  113. package/lib/machine-learning/machine-learning-namespace.js +1 -1
  114. package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
  115. package/lib/machine-learning/machine-learning-utils.js +1 -1
  116. package/lib/machine-learning/machine-learning.d.ts +19 -19
  117. package/lib/machine-learning/machine-learning.js +20 -20
  118. package/lib/messaging/batch-request-internal.d.ts +3 -3
  119. package/lib/messaging/batch-request-internal.js +9 -9
  120. package/lib/messaging/index.d.ts +11 -9
  121. package/lib/messaging/index.js +11 -9
  122. package/lib/messaging/messaging-api-request-internal.d.ts +8 -8
  123. package/lib/messaging/messaging-api-request-internal.js +8 -8
  124. package/lib/messaging/messaging-api.d.ts +79 -75
  125. package/lib/messaging/messaging-api.js +1 -1
  126. package/lib/messaging/messaging-errors-internal.d.ts +5 -5
  127. package/lib/messaging/messaging-errors-internal.js +7 -7
  128. package/lib/messaging/messaging-internal.d.ts +1 -1
  129. package/lib/messaging/messaging-internal.js +6 -31
  130. package/lib/messaging/messaging-namespace.d.ts +105 -8
  131. package/lib/messaging/messaging-namespace.js +1 -1
  132. package/lib/messaging/messaging.d.ts +70 -86
  133. package/lib/messaging/messaging.js +76 -89
  134. package/lib/project-management/android-app.d.ts +11 -12
  135. package/lib/project-management/android-app.js +13 -14
  136. package/lib/project-management/app-metadata.d.ts +1 -1
  137. package/lib/project-management/app-metadata.js +1 -1
  138. package/lib/project-management/index.d.ts +11 -9
  139. package/lib/project-management/index.js +11 -9
  140. package/lib/project-management/ios-app.d.ts +6 -7
  141. package/lib/project-management/ios-app.js +6 -7
  142. package/lib/project-management/project-management-api-request-internal.d.ts +1 -80
  143. package/lib/project-management/project-management-api-request-internal.js +14 -14
  144. package/lib/project-management/project-management-namespace.d.ts +31 -9
  145. package/lib/project-management/project-management-namespace.js +1 -1
  146. package/lib/project-management/project-management.d.ts +18 -21
  147. package/lib/project-management/project-management.js +19 -22
  148. package/lib/remote-config/index.d.ts +12 -10
  149. package/lib/remote-config/index.js +11 -9
  150. package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
  151. package/lib/remote-config/remote-config-api-client-internal.js +2 -2
  152. package/lib/remote-config/remote-config-api.d.ts +12 -2
  153. package/lib/remote-config/remote-config-api.js +1 -1
  154. package/lib/remote-config/remote-config-namespace.d.ts +50 -9
  155. package/lib/remote-config/remote-config-namespace.js +1 -1
  156. package/lib/remote-config/remote-config.d.ts +19 -21
  157. package/lib/remote-config/remote-config.js +25 -25
  158. package/lib/security-rules/index.d.ts +12 -10
  159. package/lib/security-rules/index.js +12 -10
  160. package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
  161. package/lib/security-rules/security-rules-api-client-internal.js +1 -1
  162. package/lib/security-rules/security-rules-internal.d.ts +1 -1
  163. package/lib/security-rules/security-rules-internal.js +1 -1
  164. package/lib/security-rules/security-rules-namespace.d.ts +43 -28
  165. package/lib/security-rules/security-rules-namespace.js +1 -1
  166. package/lib/security-rules/security-rules.d.ts +39 -42
  167. package/lib/security-rules/security-rules.js +38 -39
  168. package/lib/storage/index.d.ts +9 -7
  169. package/lib/storage/index.js +9 -7
  170. package/lib/storage/storage-namespace.d.ts +7 -6
  171. package/lib/storage/storage-namespace.js +1 -1
  172. package/lib/storage/storage.d.ts +3 -3
  173. package/lib/storage/storage.js +14 -4
  174. package/lib/utils/api-request.d.ts +24 -24
  175. package/lib/utils/api-request.js +25 -25
  176. package/lib/utils/crypto-signer.d.ts +128 -0
  177. package/lib/utils/crypto-signer.js +237 -0
  178. package/lib/utils/deep-copy.d.ts +6 -6
  179. package/lib/utils/deep-copy.js +6 -6
  180. package/lib/utils/error.d.ts +69 -36
  181. package/lib/utils/error.js +98 -43
  182. package/lib/utils/index.d.ts +30 -19
  183. package/lib/utils/index.js +47 -20
  184. package/lib/utils/jwt.d.ts +131 -0
  185. package/lib/utils/jwt.js +355 -0
  186. package/lib/utils/validator.d.ts +37 -37
  187. package/lib/utils/validator.js +37 -37
  188. package/package.json +126 -53
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.100.0-alpha.0 */
1
+ /*! firebase-admin v10.0.2 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -22,113 +22,78 @@ var credential_internal_1 = require("./credential-internal");
22
22
  var validator = require("../utils/validator");
23
23
  var deep_copy_1 = require("../utils/deep-copy");
24
24
  var error_1 = require("../utils/error");
25
+ var TOKEN_EXPIRY_THRESHOLD_MILLIS = 5 * 60 * 1000;
25
26
  /**
26
27
  * Internals of a FirebaseApp instance.
27
28
  */
28
29
  var FirebaseAppInternals = /** @class */ (function () {
30
+ // eslint-disable-next-line @typescript-eslint/naming-convention
29
31
  function FirebaseAppInternals(credential_) {
30
32
  this.credential_ = credential_;
31
- this.isDeleted_ = false;
32
33
  this.tokenListeners_ = [];
33
34
  }
34
- /**
35
- * Gets an auth token for the associated app.
36
- *
37
- * @param {boolean} forceRefresh Whether or not to force a token refresh.
38
- * @return {Promise<FirebaseAccessToken>} A Promise that will be fulfilled with the current or
39
- * new token.
40
- */
41
35
  FirebaseAppInternals.prototype.getToken = function (forceRefresh) {
42
- var _this = this;
43
- var expired = this.cachedToken_ && this.cachedToken_.expirationTime < Date.now();
44
- if (this.cachedTokenPromise_ && !forceRefresh && !expired) {
45
- return this.cachedTokenPromise_
46
- .catch(function (error) {
47
- // Update the cached token promise to avoid caching errors. Set it to resolve with the
48
- // cached token if we have one (and return that promise since the token has still not
49
- // expired).
50
- if (_this.cachedToken_) {
51
- _this.cachedTokenPromise_ = Promise.resolve(_this.cachedToken_);
52
- return _this.cachedTokenPromise_;
53
- }
54
- // Otherwise, set the cached token promise to null so that it will force a refresh next
55
- // time getToken() is called.
56
- _this.cachedTokenPromise_ = null;
57
- // And re-throw the caught error.
58
- throw error;
59
- });
60
- }
61
- else {
62
- // Clear the outstanding token refresh timeout. This is a noop if the timeout is undefined.
63
- clearTimeout(this.tokenRefreshTimeout_);
64
- // this.credential_ may be an external class; resolving it in a promise helps us
65
- // protect against exceptions and upgrades the result to a promise in all cases.
66
- this.cachedTokenPromise_ = Promise.resolve(this.credential_.getAccessToken())
67
- .then(function (result) {
68
- // Since the developer can provide the credential implementation, we want to weakly verify
69
- // the return type until the type is properly exported.
70
- if (!validator.isNonNullObject(result) ||
71
- typeof result.expires_in !== 'number' ||
72
- typeof result.access_token !== 'string') {
73
- throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, "Invalid access token generated: \"" + JSON.stringify(result) + "\". Valid access " +
74
- 'tokens must be an object with the "expires_in" (number) and "access_token" ' +
75
- '(string) properties.');
76
- }
77
- var token = {
78
- accessToken: result.access_token,
79
- expirationTime: Date.now() + (result.expires_in * 1000),
80
- };
81
- var hasAccessTokenChanged = (_this.cachedToken_ && _this.cachedToken_.accessToken !== token.accessToken);
82
- var hasExpirationChanged = (_this.cachedToken_ && _this.cachedToken_.expirationTime !== token.expirationTime);
83
- if (!_this.cachedToken_ || hasAccessTokenChanged || hasExpirationChanged) {
84
- _this.cachedToken_ = token;
85
- _this.tokenListeners_.forEach(function (listener) {
86
- listener(token.accessToken);
87
- });
88
- }
89
- // Establish a timeout to proactively refresh the token every minute starting at five
90
- // minutes before it expires. Once a token refresh succeeds, no further retries are
91
- // needed; if it fails, retry every minute until the token expires (resulting in a total
92
- // of four retries: at 4, 3, 2, and 1 minutes).
93
- var refreshTimeInSeconds = (result.expires_in - (5 * 60));
94
- var numRetries = 4;
95
- // In the rare cases the token is short-lived (that is, it expires in less than five
96
- // minutes from when it was fetched), establish the timeout to refresh it after the
97
- // current minute ends and update the number of retries that should be attempted before
98
- // the token expires.
99
- if (refreshTimeInSeconds <= 0) {
100
- refreshTimeInSeconds = result.expires_in % 60;
101
- numRetries = Math.floor(result.expires_in / 60) - 1;
102
- }
103
- // The token refresh timeout keeps the Node.js process alive, so only create it if this
104
- // instance has not already been deleted.
105
- if (numRetries && !_this.isDeleted_) {
106
- _this.setTokenRefreshTimeout(refreshTimeInSeconds * 1000, numRetries);
107
- }
108
- return token;
109
- })
110
- .catch(function (error) {
111
- var errorMessage = (typeof error === 'string') ? error : error.message;
112
- errorMessage = 'Credential implementation provided to initializeApp() via the ' +
113
- '"credential" property failed to fetch a valid Google OAuth2 access token with the ' +
114
- ("following error: \"" + errorMessage + "\".");
115
- if (errorMessage.indexOf('invalid_grant') !== -1) {
116
- errorMessage += ' There are two likely causes: (1) your server time is not properly ' +
117
- 'synced or (2) your certificate key file has been revoked. To solve (1), re-sync the ' +
118
- 'time on your server. To solve (2), make sure the key ID for your key file is still ' +
119
- 'present at https://console.firebase.google.com/iam-admin/serviceaccounts/project. If ' +
120
- 'not, generate a new key file at ' +
121
- 'https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk.';
122
- }
123
- throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, errorMessage);
124
- });
125
- return this.cachedTokenPromise_;
36
+ if (forceRefresh === void 0) { forceRefresh = false; }
37
+ if (forceRefresh || this.shouldRefresh()) {
38
+ return this.refreshToken();
126
39
  }
40
+ return Promise.resolve(this.cachedToken_);
41
+ };
42
+ FirebaseAppInternals.prototype.getCachedToken = function () {
43
+ return this.cachedToken_ || null;
44
+ };
45
+ FirebaseAppInternals.prototype.refreshToken = function () {
46
+ var _this = this;
47
+ return Promise.resolve(this.credential_.getAccessToken())
48
+ .then(function (result) {
49
+ // Since the developer can provide the credential implementation, we want to weakly verify
50
+ // the return type until the type is properly exported.
51
+ if (!validator.isNonNullObject(result) ||
52
+ typeof result.expires_in !== 'number' ||
53
+ typeof result.access_token !== 'string') {
54
+ throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, "Invalid access token generated: \"" + JSON.stringify(result) + "\". Valid access " +
55
+ 'tokens must be an object with the "expires_in" (number) and "access_token" ' +
56
+ '(string) properties.');
57
+ }
58
+ var token = {
59
+ accessToken: result.access_token,
60
+ expirationTime: Date.now() + (result.expires_in * 1000),
61
+ };
62
+ if (!_this.cachedToken_
63
+ || _this.cachedToken_.accessToken !== token.accessToken
64
+ || _this.cachedToken_.expirationTime !== token.expirationTime) {
65
+ // Update the cache before firing listeners. Listeners may directly query the
66
+ // cached token state.
67
+ _this.cachedToken_ = token;
68
+ _this.tokenListeners_.forEach(function (listener) {
69
+ listener(token.accessToken);
70
+ });
71
+ }
72
+ return token;
73
+ })
74
+ .catch(function (error) {
75
+ var errorMessage = (typeof error === 'string') ? error : error.message;
76
+ errorMessage = 'Credential implementation provided to initializeApp() via the ' +
77
+ '"credential" property failed to fetch a valid Google OAuth2 access token with the ' +
78
+ ("following error: \"" + errorMessage + "\".");
79
+ if (errorMessage.indexOf('invalid_grant') !== -1) {
80
+ errorMessage += ' There are two likely causes: (1) your server time is not properly ' +
81
+ 'synced or (2) your certificate key file has been revoked. To solve (1), re-sync the ' +
82
+ 'time on your server. To solve (2), make sure the key ID for your key file is still ' +
83
+ 'present at https://console.firebase.google.com/iam-admin/serviceaccounts/project. If ' +
84
+ 'not, generate a new key file at ' +
85
+ 'https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk.';
86
+ }
87
+ throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, errorMessage);
88
+ });
89
+ };
90
+ FirebaseAppInternals.prototype.shouldRefresh = function () {
91
+ return !this.cachedToken_ || (this.cachedToken_.expirationTime - Date.now()) <= TOKEN_EXPIRY_THRESHOLD_MILLIS;
127
92
  };
128
93
  /**
129
94
  * Adds a listener that is called each time a token changes.
130
95
  *
131
- * @param {function(string)} listener The listener that will be called with each new token.
96
+ * @param listener - The listener that will be called with each new token.
132
97
  */
133
98
  FirebaseAppInternals.prototype.addAuthTokenListener = function (listener) {
134
99
  this.tokenListeners_.push(listener);
@@ -139,40 +104,11 @@ var FirebaseAppInternals = /** @class */ (function () {
139
104
  /**
140
105
  * Removes a token listener.
141
106
  *
142
- * @param {function(string)} listener The listener to remove.
107
+ * @param listener - The listener to remove.
143
108
  */
144
109
  FirebaseAppInternals.prototype.removeAuthTokenListener = function (listener) {
145
110
  this.tokenListeners_ = this.tokenListeners_.filter(function (other) { return other !== listener; });
146
111
  };
147
- /**
148
- * Deletes the FirebaseAppInternals instance.
149
- */
150
- FirebaseAppInternals.prototype.delete = function () {
151
- this.isDeleted_ = true;
152
- // Clear the token refresh timeout so it doesn't keep the Node.js process alive.
153
- clearTimeout(this.tokenRefreshTimeout_);
154
- };
155
- /**
156
- * Establishes timeout to refresh the Google OAuth2 access token used by the SDK.
157
- *
158
- * @param {number} delayInMilliseconds The delay to use for the timeout.
159
- * @param {number} numRetries The number of times to retry fetching a new token if the prior fetch
160
- * failed.
161
- */
162
- FirebaseAppInternals.prototype.setTokenRefreshTimeout = function (delayInMilliseconds, numRetries) {
163
- var _this = this;
164
- this.tokenRefreshTimeout_ = setTimeout(function () {
165
- _this.getToken(/* forceRefresh */ true)
166
- .catch(function () {
167
- // Ignore the error since this might just be an intermittent failure. If we really cannot
168
- // refresh the token, an error will be logged once the existing token expires and we try
169
- // to fetch a fresh one.
170
- if (numRetries > 0) {
171
- _this.setTokenRefreshTimeout(60 * 1000, numRetries - 1);
172
- }
173
- });
174
- }, delayInMilliseconds);
175
- };
176
112
  return FirebaseAppInternals;
177
113
  }());
178
114
  exports.FirebaseAppInternals = FirebaseAppInternals;
@@ -182,8 +118,8 @@ exports.FirebaseAppInternals = FirebaseAppInternals;
182
118
  * @internal
183
119
  */
184
120
  var FirebaseApp = /** @class */ (function () {
185
- function FirebaseApp(options, name, firebaseInternals_) {
186
- this.firebaseInternals_ = firebaseInternals_;
121
+ function FirebaseApp(options, name, appStore) {
122
+ this.appStore = appStore;
187
123
  this.services_ = {};
188
124
  this.isDeleted_ = false;
189
125
  this.name_ = name;
@@ -204,96 +140,11 @@ var FirebaseApp = /** @class */ (function () {
204
140
  }
205
141
  this.INTERNAL = new FirebaseAppInternals(credential);
206
142
  }
207
- /**
208
- * Returns the Auth service instance associated with this app.
209
- *
210
- * @return The Auth service instance of this app.
211
- */
212
- FirebaseApp.prototype.auth = function () {
213
- var fn = require('../auth/index').getAuth;
214
- return fn(this);
215
- };
216
- /**
217
- * Returns the Database service for the specified URL, and the current app.
218
- *
219
- * @return The Database service instance of this app.
220
- */
221
- FirebaseApp.prototype.database = function (url) {
222
- var fn = require('../database/index').getDatabaseWithUrl;
223
- return fn(url, this);
224
- };
225
- /**
226
- * Returns the Messaging service instance associated with this app.
227
- *
228
- * @return The Messaging service instance of this app.
229
- */
230
- FirebaseApp.prototype.messaging = function () {
231
- var fn = require('../messaging/index').getMessaging;
232
- return fn(this);
233
- };
234
- /**
235
- * Returns the Storage service instance associated with this app.
236
- *
237
- * @return The Storage service instance of this app.
238
- */
239
- FirebaseApp.prototype.storage = function () {
240
- var fn = require('../storage/index').getStorage;
241
- return fn(this);
242
- };
243
- FirebaseApp.prototype.firestore = function () {
244
- var fn = require('../firestore/index').getFirestore;
245
- return fn(this);
246
- };
247
- /**
248
- * Returns the InstanceId service instance associated with this app.
249
- *
250
- * @return The InstanceId service instance of this app.
251
- */
252
- FirebaseApp.prototype.instanceId = function () {
253
- var fn = require('../instance-id/index').getInstanceId;
254
- return fn(this);
255
- };
256
- /**
257
- * Returns the MachineLearning service instance associated with this app.
258
- *
259
- * @return The Machine Learning service instance of this app
260
- */
261
- FirebaseApp.prototype.machineLearning = function () {
262
- var fn = require('../machine-learning/index').getMachineLearning;
263
- return fn(this);
264
- };
265
- /**
266
- * Returns the ProjectManagement service instance associated with this app.
267
- *
268
- * @return The ProjectManagement service instance of this app.
269
- */
270
- FirebaseApp.prototype.projectManagement = function () {
271
- var fn = require('../project-management/index').getProjectManagement;
272
- return fn(this);
273
- };
274
- /**
275
- * Returns the SecurityRules service instance associated with this app.
276
- *
277
- * @return The SecurityRules service instance of this app.
278
- */
279
- FirebaseApp.prototype.securityRules = function () {
280
- var fn = require('../security-rules/index').getSecurityRules;
281
- return fn(this);
282
- };
283
- /**
284
- * Returns the RemoteConfig service instance associated with this app.
285
- *
286
- * @return The RemoteConfig service instance of this app.
287
- */
288
- FirebaseApp.prototype.remoteConfig = function () {
289
- var fn = require('../remote-config/index').getRemoteConfig;
290
- return fn(this);
291
- };
292
143
  Object.defineProperty(FirebaseApp.prototype, "name", {
293
144
  /**
294
145
  * Returns the name of the FirebaseApp instance.
295
146
  *
296
- * @return The name of the FirebaseApp instance.
147
+ * @returns The name of the FirebaseApp instance.
297
148
  */
298
149
  get: function () {
299
150
  this.checkDestroyed_();
@@ -306,7 +157,7 @@ var FirebaseApp = /** @class */ (function () {
306
157
  /**
307
158
  * Returns the options for the FirebaseApp instance.
308
159
  *
309
- * @return The options for the FirebaseApp instance.
160
+ * @returns The options for the FirebaseApp instance.
310
161
  */
311
162
  get: function () {
312
163
  this.checkDestroyed_();
@@ -325,13 +176,16 @@ var FirebaseApp = /** @class */ (function () {
325
176
  /**
326
177
  * Deletes the FirebaseApp instance.
327
178
  *
328
- * @return An empty Promise fulfilled once the FirebaseApp instance is deleted.
179
+ * @returns An empty Promise fulfilled once the FirebaseApp instance is deleted.
329
180
  */
330
181
  FirebaseApp.prototype.delete = function () {
331
182
  var _this = this;
183
+ var _a;
332
184
  this.checkDestroyed_();
333
- this.firebaseInternals_.removeApp(this.name_);
334
- this.INTERNAL.delete();
185
+ // Also remove the instance from the AppStore. This is needed to support the existing
186
+ // app.delete() use case. In the future we can remove this API, and deleteApp() will
187
+ // become the only way to tear down an App.
188
+ (_a = this.appStore) === null || _a === void 0 ? void 0 : _a.removeApp(this.name);
335
189
  return Promise.all(Object.keys(this.services_).map(function (serviceName) {
336
190
  var service = _this.services_[serviceName];
337
191
  if (isStateful(service)) {
@@ -343,6 +197,7 @@ var FirebaseApp = /** @class */ (function () {
343
197
  _this.isDeleted_ = true;
344
198
  });
345
199
  };
200
+ // eslint-disable-next-line @typescript-eslint/naming-convention
346
201
  FirebaseApp.prototype.ensureService_ = function (serviceName, initializer) {
347
202
  this.checkDestroyed_();
348
203
  if (!(serviceName in this.services_)) {
@@ -353,6 +208,7 @@ var FirebaseApp = /** @class */ (function () {
353
208
  /**
354
209
  * Throws an Error if the FirebaseApp instance has already been deleted.
355
210
  */
211
+ // eslint-disable-next-line @typescript-eslint/naming-convention
356
212
  FirebaseApp.prototype.checkDestroyed_ = function () {
357
213
  if (this.isDeleted_) {
358
214
  throw new error_1.FirebaseAppError(error_1.AppErrorCodes.APP_DELETED, "Firebase app named \"" + this.name_ + "\" has already been deleted.");
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.100.0-alpha.0 */
1
+ /*! firebase-admin v10.0.2 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.
@@ -15,12 +15,15 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- import { app, auth, messaging, machineLearning, storage, firestore, database, instanceId, projectManagement, securityRules, remoteConfig, AppOptions } from '../firebase-namespace-api';
18
+ import { AppStore } from './lifecycle';
19
+ import { app, appCheck, auth, messaging, machineLearning, storage, firestore, database, instanceId, installations, projectManagement, securityRules, remoteConfig, AppOptions } from '../firebase-namespace-api';
19
20
  import { cert, refreshToken, applicationDefault } from './credential-factory';
20
21
  import App = app.App;
22
+ import AppCheck = appCheck.AppCheck;
21
23
  import Auth = auth.Auth;
22
24
  import Database = database.Database;
23
25
  import Firestore = firestore.Firestore;
26
+ import Installations = installations.Installations;
24
27
  import InstanceId = instanceId.InstanceId;
25
28
  import MachineLearning = machineLearning.MachineLearning;
26
29
  import Messaging = messaging.Messaging;
@@ -28,12 +31,6 @@ import ProjectManagement = projectManagement.ProjectManagement;
28
31
  import RemoteConfig = remoteConfig.RemoteConfig;
29
32
  import SecurityRules = securityRules.SecurityRules;
30
33
  import Storage = storage.Storage;
31
- /**
32
- * Constant holding the environment variable name with the default config.
33
- * If the environment variable contains a string that starts with '{' it will be parsed as JSON,
34
- * otherwise it will be assumed to be pointing to a file.
35
- */
36
- export declare const FIREBASE_CONFIG_VAR = "FIREBASE_CONFIG";
37
34
  export interface FirebaseServiceNamespace<T> {
38
35
  (app?: App): T;
39
36
  [key: string]: any;
@@ -42,42 +39,29 @@ export interface FirebaseServiceNamespace<T> {
42
39
  * Internals of a FirebaseNamespace instance.
43
40
  */
44
41
  export declare class FirebaseNamespaceInternals {
45
- firebase_: {
46
- [key: string]: any;
47
- };
48
- private apps_;
49
- constructor(firebase_: {
50
- [key: string]: any;
51
- });
42
+ private readonly appStore;
43
+ constructor(appStore: AppStore);
52
44
  /**
53
45
  * Initializes the App instance.
54
46
  *
55
- * @param options Optional options for the App instance. If none present will try to initialize
47
+ * @param options - Optional options for the App instance. If none present will try to initialize
56
48
  * from the FIREBASE_CONFIG environment variable. If the environment variable contains a string
57
49
  * that starts with '{' it will be parsed as JSON, otherwise it will be assumed to be pointing
58
50
  * to a file.
59
- * @param appName Optional name of the FirebaseApp instance.
51
+ * @param appName - Optional name of the FirebaseApp instance.
60
52
  *
61
- * @return A new App instance.
53
+ * @returns A new App instance.
62
54
  */
63
55
  initializeApp(options?: AppOptions, appName?: string): App;
64
56
  /**
65
57
  * Returns the App instance with the provided name (or the default App instance
66
58
  * if no name is provided).
67
59
  *
68
- * @param appName Optional name of the FirebaseApp instance to return.
69
- * @return The App instance which has the provided name.
60
+ * @param appName - Optional name of the FirebaseApp instance to return.
61
+ * @returns The App instance which has the provided name.
70
62
  */
71
63
  app(appName?: string): App;
72
64
  get apps(): App[];
73
- removeApp(appName: string): void;
74
- /**
75
- * Parse the file pointed to by the FIREBASE_CONFIG_VAR, if it exists.
76
- * Or if the FIREBASE_CONFIG_ENV contains a valid JSON object, parse it directly.
77
- * If the environment variable contains a string that starts with '{' it will be parsed as JSON,
78
- * otherwise it will be assumed to be pointing to a file.
79
- */
80
- private loadOptionsFromEnvVar;
81
65
  }
82
66
  /**
83
67
  * Global Firebase context object.
@@ -92,7 +76,7 @@ export declare class FirebaseNamespace {
92
76
  SDK_VERSION: string;
93
77
  INTERNAL: FirebaseNamespaceInternals;
94
78
  Promise: any;
95
- constructor();
79
+ constructor(appStore?: AppStore);
96
80
  /**
97
81
  * Gets the `Auth` service namespace. The returned namespace can be used to get the
98
82
  * `Auth` service for the default app or an explicitly specified app.
@@ -124,6 +108,11 @@ export declare class FirebaseNamespace {
124
108
  * explicityly specified app.
125
109
  */
126
110
  get machineLearning(): FirebaseServiceNamespace<MachineLearning>;
111
+ /**
112
+ * Gets the `Installations` service namespace. The returned namespace can be used to get the
113
+ * `Installations` service for the default app or an explicitly specified app.
114
+ */
115
+ get installations(): FirebaseServiceNamespace<Installations>;
127
116
  /**
128
117
  * Gets the `InstanceId` service namespace. The returned namespace can be used to get the
129
118
  * `Instance` service for the default app or an explicitly specified app.
@@ -144,24 +133,29 @@ export declare class FirebaseNamespace {
144
133
  * `RemoteConfig` service for the default app or an explicitly specified app.
145
134
  */
146
135
  get remoteConfig(): FirebaseServiceNamespace<RemoteConfig>;
136
+ /**
137
+ * Gets the `AppCheck` service namespace. The returned namespace can be used to get the
138
+ * `AppCheck` service for the default app or an explicitly specified app.
139
+ */
140
+ get appCheck(): FirebaseServiceNamespace<AppCheck>;
147
141
  /**
148
142
  * Initializes the FirebaseApp instance.
149
143
  *
150
- * @param options Optional options for the FirebaseApp instance.
144
+ * @param options - Optional options for the FirebaseApp instance.
151
145
  * If none present will try to initialize from the FIREBASE_CONFIG environment variable.
152
146
  * If the environment variable contains a string that starts with '{' it will be parsed as JSON,
153
147
  * otherwise it will be assumed to be pointing to a file.
154
- * @param appName Optional name of the FirebaseApp instance.
148
+ * @param appName - Optional name of the FirebaseApp instance.
155
149
  *
156
- * @return A new FirebaseApp instance.
150
+ * @returns A new FirebaseApp instance.
157
151
  */
158
152
  initializeApp(options?: AppOptions, appName?: string): App;
159
153
  /**
160
154
  * Returns the FirebaseApp instance with the provided name (or the default FirebaseApp instance
161
155
  * if no name is provided).
162
156
  *
163
- * @param appName Optional name of the FirebaseApp instance to return.
164
- * @return The FirebaseApp instance which has the provided name.
157
+ * @param appName - Optional name of the FirebaseApp instance to return.
158
+ * @returns The FirebaseApp instance which has the provided name.
165
159
  */
166
160
  app(appName?: string): App;
167
161
  get apps(): App[];