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
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -18,14 +18,12 @@ import * as rtdb from '@firebase/database-types';
18
18
  import { App } from '../app';
19
19
  import { Database as TDatabase } from './database';
20
20
  /**
21
- * Gets the {@link database.Database `Database`} service for the default
21
+ * Gets the {@link firebase-admin.database#Database} service for the default
22
22
  * app or a given app.
23
23
  *
24
24
  * `admin.database()` can be called with no arguments to access the default
25
- * app's {@link database.Database `Database`} service or as
26
- * `admin.database(app)` to access the
27
- * {@link database.Database `Database`} service associated with a specific
28
- * app.
25
+ * app's `Database` service or as `admin.database(app)` to access the
26
+ * `Database` service associated with a specific app.
29
27
  *
30
28
  * `admin.database` is also a namespace that can be used to access global
31
29
  * constants and methods associated with the `Database` service.
@@ -42,25 +40,56 @@ import { Database as TDatabase } from './database';
42
40
  * var otherDatabase = admin.database(app);
43
41
  * ```
44
42
  *
45
- * @param App whose `Database` service to
43
+ * @param App - whose `Database` service to
46
44
  * return. If not provided, the default `Database` service will be returned.
47
45
  *
48
- * @return The default `Database` service if no app
46
+ * @returns The default `Database` service if no app
49
47
  * is provided or the `Database` service associated with the provided app.
50
48
  */
51
49
  export declare function database(app?: App): database.Database;
52
50
  export declare namespace database {
51
+ /**
52
+ * Type alias to {@link firebase-admin.database#Database}.
53
+ */
53
54
  type Database = TDatabase;
55
+ /**
56
+ * Type alias to {@link https://firebase.google.com/docs/reference/js/firebase.database.DataSnapshot | DataSnapshot}
57
+ * type from the `@firebase/database` package.
58
+ */
54
59
  type DataSnapshot = rtdb.DataSnapshot;
60
+ /**
61
+ * Type alias to the {@link https://firebase.google.com/docs/reference/js/firebase.database#eventtype | EventType}
62
+ * type from the `@firebase/database` package.
63
+ */
55
64
  type EventType = rtdb.EventType;
65
+ /**
66
+ * Type alias to {@link https://firebase.google.com/docs/reference/js/firebase.database.OnDisconnect | OnDisconnect}
67
+ * type from the `@firebase/database` package.
68
+ */
56
69
  type OnDisconnect = rtdb.OnDisconnect;
70
+ /**
71
+ * Type alias to {@link https://firebase.google.com/docs/reference/js/firebase.database.Query | Query}
72
+ * type from the `@firebase/database` package.
73
+ */
57
74
  type Query = rtdb.Query;
75
+ /**
76
+ * Type alias to {@link https://firebase.google.com/docs/reference/js/firebase.database.Reference | Reference}
77
+ * type from the `@firebase/database` package.
78
+ */
58
79
  type Reference = rtdb.Reference;
80
+ /**
81
+ * Type alias to {@link https://firebase.google.com/docs/reference/js/firebase.database.ThenableReference |
82
+ * ThenableReference} type from the `@firebase/database` package.
83
+ */
59
84
  type ThenableReference = rtdb.ThenableReference;
85
+ /**
86
+ * {@link https://firebase.google.com/docs/reference/js/firebase.database#enablelogging | enableLogging}
87
+ * function from the `@firebase/database` package.
88
+ */
60
89
  const enableLogging: typeof rtdb.enableLogging;
61
90
  /**
62
- * [`ServerValue`](https://firebase.google.com/docs/reference/js/firebase.database.ServerValue)
63
- * module from the `@firebase/database` package.
91
+ * {@link https://firebase.google.com/docs/reference/js/firebase.database.ServerValue | ServerValue}
92
+ * constant from the `@firebase/database` package.
64
93
  */
65
94
  const ServerValue: rtdb.ServerValue;
66
95
  }
@@ -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
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.100.0-alpha.0 */
1
+ /*! firebase-admin v10.0.2 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -17,40 +17,50 @@
17
17
  /// <reference types="node" />
18
18
  import { FirebaseDatabase } from '@firebase/database-types';
19
19
  import { App } from '../app';
20
+ /**
21
+ * The Firebase Database service interface. Extends the
22
+ * {@link https://firebase.google.com/docs/reference/js/firebase.database.Database | Database}
23
+ * interface provided by the `@firebase/database` package.
24
+ */
20
25
  export interface Database extends FirebaseDatabase {
21
26
  /**
22
27
  * Gets the currently applied security rules as a string. The return value consists of
23
28
  * the rules source including comments.
24
29
  *
25
- * @return A promise fulfilled with the rules as a raw string.
30
+ * @returns A promise fulfilled with the rules as a raw string.
26
31
  */
27
32
  getRules(): Promise<string>;
28
33
  /**
29
34
  * Gets the currently applied security rules as a parsed JSON object. Any comments in
30
35
  * the original source are stripped away.
31
36
  *
32
- * @return A promise fulfilled with the parsed rules object.
37
+ * @returns A promise fulfilled with the parsed rules object.
33
38
  */
34
39
  getRulesJSON(): Promise<object>;
35
40
  /**
36
41
  * Sets the specified rules on the Firebase Realtime Database instance. If the rules source is
37
42
  * specified as a string or a Buffer, it may include comments.
38
43
  *
39
- * @param source Source of the rules to apply. Must not be `null` or empty.
40
- * @return Resolves when the rules are set on the Realtime Database.
44
+ * @param source - Source of the rules to apply. Must not be `null` or empty.
45
+ * @returns Resolves when the rules are set on the Realtime Database.
41
46
  */
42
47
  setRules(source: string | Buffer | object): Promise<void>;
43
48
  }
44
49
  export declare class DatabaseService {
45
50
  private readonly appInternal;
51
+ private tokenListener;
52
+ private tokenRefreshTimeout;
46
53
  private databases;
47
54
  constructor(app: App);
55
+ private get firebaseApp();
48
56
  /**
49
57
  * Returns the app associated with this DatabaseService instance.
50
58
  *
51
- * @return The app associated with this DatabaseService instance.
59
+ * @returns The app associated with this DatabaseService instance.
52
60
  */
53
61
  get app(): App;
54
62
  getDatabase(url?: string): Database;
63
+ private onTokenChange;
64
+ private scheduleTokenRefresh;
55
65
  private ensureUrl;
56
66
  }
@@ -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
  * Copyright 2020 Google Inc.
@@ -23,6 +23,7 @@ var error_1 = require("../utils/error");
23
23
  var validator = require("../utils/validator");
24
24
  var api_request_1 = require("../utils/api-request");
25
25
  var index_1 = require("../utils/index");
26
+ var TOKEN_REFRESH_THRESHOLD_MILLIS = 5 * 60 * 1000;
26
27
  var DatabaseService = /** @class */ (function () {
27
28
  function DatabaseService(app) {
28
29
  this.databases = {};
@@ -34,11 +35,22 @@ var DatabaseService = /** @class */ (function () {
34
35
  }
35
36
  this.appInternal = app;
36
37
  }
38
+ Object.defineProperty(DatabaseService.prototype, "firebaseApp", {
39
+ get: function () {
40
+ return this.app;
41
+ },
42
+ enumerable: false,
43
+ configurable: true
44
+ });
37
45
  /**
38
46
  * @internal
39
47
  */
40
48
  DatabaseService.prototype.delete = function () {
41
49
  var _this = this;
50
+ if (this.tokenListener) {
51
+ this.firebaseApp.INTERNAL.removeAuthTokenListener(this.tokenListener);
52
+ clearTimeout(this.tokenRefreshTimeout);
53
+ }
42
54
  var promises = [];
43
55
  for (var _i = 0, _a = Object.keys(this.databases); _i < _a.length; _i++) {
44
56
  var dbUrl = _a[_i];
@@ -53,7 +65,7 @@ var DatabaseService = /** @class */ (function () {
53
65
  /**
54
66
  * Returns the app associated with this DatabaseService instance.
55
67
  *
56
- * @return The app associated with this DatabaseService instance.
68
+ * @returns The app associated with this DatabaseService instance.
57
69
  */
58
70
  get: function () {
59
71
  return this.appInternal;
@@ -71,7 +83,8 @@ var DatabaseService = /** @class */ (function () {
71
83
  }
72
84
  var db = this.databases[dbUrl];
73
85
  if (typeof db === 'undefined') {
74
- var rtdb = require('@firebase/database'); // eslint-disable-line @typescript-eslint/no-var-requires
86
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
87
+ var rtdb = require('@firebase/database-compat/standalone');
75
88
  db = rtdb.initStandalone(this.appInternal, dbUrl, index_1.getSdkVersion()).instance;
76
89
  var rulesClient_1 = new DatabaseRulesClient(this.app, dbUrl);
77
90
  db.getRules = function () {
@@ -85,8 +98,36 @@ var DatabaseService = /** @class */ (function () {
85
98
  };
86
99
  this.databases[dbUrl] = db;
87
100
  }
101
+ if (!this.tokenListener) {
102
+ this.tokenListener = this.onTokenChange.bind(this);
103
+ this.firebaseApp.INTERNAL.addAuthTokenListener(this.tokenListener);
104
+ }
88
105
  return db;
89
106
  };
107
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
108
+ DatabaseService.prototype.onTokenChange = function (_) {
109
+ var token = this.firebaseApp.INTERNAL.getCachedToken();
110
+ if (token) {
111
+ var delayMillis = token.expirationTime - TOKEN_REFRESH_THRESHOLD_MILLIS - Date.now();
112
+ // If the new token is set to expire soon (unlikely), do nothing. Somebody will eventually
113
+ // notice and refresh the token, at which point this callback will fire again.
114
+ if (delayMillis > 0) {
115
+ this.scheduleTokenRefresh(delayMillis);
116
+ }
117
+ }
118
+ };
119
+ DatabaseService.prototype.scheduleTokenRefresh = function (delayMillis) {
120
+ var _this = this;
121
+ clearTimeout(this.tokenRefreshTimeout);
122
+ this.tokenRefreshTimeout = setTimeout(function () {
123
+ _this.firebaseApp.INTERNAL.getToken(/*forceRefresh=*/ true)
124
+ .catch(function () {
125
+ // Ignore the error since this might just be an intermittent failure. If we really cannot
126
+ // refresh the token, an error will be logged once the existing token expires and we try
127
+ // to fetch a fresh one.
128
+ });
129
+ }, delayMillis);
130
+ };
90
131
  DatabaseService.prototype.ensureUrl = function (url) {
91
132
  if (typeof url !== 'undefined') {
92
133
  return url;
@@ -109,6 +150,11 @@ var RULES_URL_PATH = '.settings/rules.json';
109
150
  var DatabaseRulesClient = /** @class */ (function () {
110
151
  function DatabaseRulesClient(app, dbUrl) {
111
152
  var parsedUrl = new url_1.URL(dbUrl);
153
+ var emulatorHost = process.env.FIREBASE_DATABASE_EMULATOR_HOST;
154
+ if (emulatorHost) {
155
+ var namespace = extractNamespace(parsedUrl);
156
+ parsedUrl = new url_1.URL("http://" + emulatorHost + "?ns=" + namespace);
157
+ }
112
158
  parsedUrl.pathname = path.join(parsedUrl.pathname, RULES_URL_PATH);
113
159
  this.dbUrl = parsedUrl.toString();
114
160
  this.httpClient = new api_request_1.AuthorizedHttpClient(app);
@@ -117,7 +163,7 @@ var DatabaseRulesClient = /** @class */ (function () {
117
163
  * Gets the currently applied security rules as a string. The return value consists of
118
164
  * the rules source including comments.
119
165
  *
120
- * @return {Promise<string>} A promise fulfilled with the rules as a raw string.
166
+ * @returns A promise fulfilled with the rules as a raw string.
121
167
  */
122
168
  DatabaseRulesClient.prototype.getRules = function () {
123
169
  var _this = this;
@@ -140,7 +186,7 @@ var DatabaseRulesClient = /** @class */ (function () {
140
186
  * Gets the currently applied security rules as a parsed JSON object. Any comments in
141
187
  * the original source are stripped away.
142
188
  *
143
- * @return {Promise<object>} A promise fulfilled with the parsed rules source.
189
+ * @returns {Promise<object>} A promise fulfilled with the parsed rules source.
144
190
  */
145
191
  DatabaseRulesClient.prototype.getRulesJSON = function () {
146
192
  var _this = this;
@@ -163,7 +209,7 @@ var DatabaseRulesClient = /** @class */ (function () {
163
209
  *
164
210
  * @param {string|Buffer|object} source Source of the rules to apply. Must not be `null`
165
211
  * or empty.
166
- * @return {Promise<void>} Resolves when the rules are set on the Database.
212
+ * @returns {Promise<void>} Resolves when the rules are set on the Database.
167
213
  */
168
214
  DatabaseRulesClient.prototype.setRules = function (source) {
169
215
  var _this = this;
@@ -216,3 +262,12 @@ var DatabaseRulesClient = /** @class */ (function () {
216
262
  };
217
263
  return DatabaseRulesClient;
218
264
  }());
265
+ function extractNamespace(parsedUrl) {
266
+ var ns = parsedUrl.searchParams.get('ns');
267
+ if (ns) {
268
+ return ns;
269
+ }
270
+ var hostname = parsedUrl.hostname;
271
+ var dotIndex = hostname.indexOf('.');
272
+ return hostname.substring(0, dotIndex).toLowerCase();
273
+ }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.100.0-alpha.0 */
1
+ /*! firebase-admin v10.0.2 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -14,30 +14,33 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ /**
18
+ * Firebase Realtime Database.
19
+ *
20
+ * @packageDocumentation
21
+ */
17
22
  import * as rtdb from '@firebase/database-types';
18
23
  import { App } from '../app';
19
24
  import { Database } from './database';
20
25
  export { Database };
21
26
  export { DataSnapshot, EventType, OnDisconnect, Query, Reference, ThenableReference, } from '@firebase/database-types';
22
27
  /**
23
- * [`enableLogging`](https://firebase.google.com/docs/reference/js/firebase.database#enablelogging)
28
+ * {@link https://firebase.google.com/docs/reference/js/firebase.database#enablelogging | enableLogging}
24
29
  * function from the `@firebase/database` package.
25
30
  */
26
31
  export declare const enableLogging: typeof rtdb.enableLogging;
27
32
  /**
28
- * [`ServerValue`](https://firebase.google.com/docs/reference/js/firebase.database.ServerValue)
29
- * module from the `@firebase/database` package.
33
+ * {@link https://firebase.google.com/docs/reference/js/firebase.database.ServerValue | ServerValue}
34
+ * constant from the `@firebase/database` package.
30
35
  */
31
36
  export declare const ServerValue: rtdb.ServerValue;
32
37
  /**
33
- * Gets the {@link database.Database `Database`} service for the default
38
+ * Gets the {@link Database} service for the default
34
39
  * app or a given app.
35
40
  *
36
41
  * `getDatabase()` can be called with no arguments to access the default
37
- * app's {@link database.Database `Database`} service or as
38
- * `getDatabase(app)` to access the
39
- * {@link database.Database `Database`} service associated with a specific
40
- * app.
42
+ * app's `Database` service or as `getDatabase(app)` to access the
43
+ * `Database` service associated with a specific app.
41
44
  *
42
45
  * @example
43
46
  * ```javascript
@@ -51,22 +54,20 @@ export declare const ServerValue: rtdb.ServerValue;
51
54
  * const otherDatabase = getDatabase(app);
52
55
  * ```
53
56
  *
54
- * @param App whose `Database` service to
57
+ * @param App - whose `Database` service to
55
58
  * return. If not provided, the default `Database` service will be returned.
56
59
  *
57
- * @return The default `Database` service if no app
60
+ * @returns The default `Database` service if no app
58
61
  * is provided or the `Database` service associated with the provided app.
59
62
  */
60
63
  export declare function getDatabase(app?: App): Database;
61
64
  /**
62
- * Gets the {@link database.Database `Database`} service for the default
65
+ * Gets the {@link Database} service for the default
63
66
  * app or a given app.
64
67
  *
65
68
  * `getDatabaseWithUrl()` can be called with no arguments to access the default
66
- * app's {@link database.Database `Database`} service or as
67
- * `getDatabaseWithUrl(app)` to access the
68
- * {@link database.Database `Database`} service associated with a specific
69
- * app.
69
+ * app's {@link Database} service or as `getDatabaseWithUrl(app)` to access the
70
+ * {@link Database} service associated with a specific app.
70
71
  *
71
72
  * @example
72
73
  * ```javascript
@@ -80,10 +81,10 @@ export declare function getDatabase(app?: App): Database;
80
81
  * const otherDatabase = getDatabaseWithUrl('https://example.firebaseio.com', app);
81
82
  * ```
82
83
  *
83
- * @param App whose `Database` service to
84
+ * @param App - whose `Database` service to
84
85
  * return. If not provided, the default `Database` service will be returned.
85
86
  *
86
- * @return The default `Database` service if no app
87
+ * @returns The default `Database` service if no app
87
88
  * is provided or the `Database` service associated with the provided app.
88
89
  */
89
90
  export declare function getDatabaseWithUrl(url: string, app?: App): Database;
@@ -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
  * Copyright 2020 Google Inc.
@@ -17,28 +17,28 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.getDatabaseWithUrl = exports.getDatabase = exports.ServerValue = exports.enableLogging = void 0;
20
- var database_1 = require("@firebase/database");
20
+ var standalone_1 = require("@firebase/database-compat/standalone");
21
21
  var app_1 = require("../app");
22
- var database_2 = require("./database");
22
+ var database_1 = require("./database");
23
+ // TODO: Remove the following any-cast once the typins in @firebase/database-types are fixed.
23
24
  /**
24
- * [`enableLogging`](https://firebase.google.com/docs/reference/js/firebase.database#enablelogging)
25
+ * {@link https://firebase.google.com/docs/reference/js/firebase.database#enablelogging | enableLogging}
25
26
  * function from the `@firebase/database` package.
26
27
  */
27
- exports.enableLogging = database_1.enableLogging;
28
+ exports.enableLogging = standalone_1.enableLogging;
28
29
  /**
29
- * [`ServerValue`](https://firebase.google.com/docs/reference/js/firebase.database.ServerValue)
30
- * module from the `@firebase/database` package.
30
+ * {@link https://firebase.google.com/docs/reference/js/firebase.database.ServerValue | ServerValue}
31
+ * constant from the `@firebase/database` package.
31
32
  */
32
- exports.ServerValue = database_1.ServerValue;
33
+ // eslint-disable-next-line @typescript-eslint/naming-convention
34
+ exports.ServerValue = standalone_1.ServerValue;
33
35
  /**
34
- * Gets the {@link database.Database `Database`} service for the default
36
+ * Gets the {@link Database} service for the default
35
37
  * app or a given app.
36
38
  *
37
39
  * `getDatabase()` can be called with no arguments to access the default
38
- * app's {@link database.Database `Database`} service or as
39
- * `getDatabase(app)` to access the
40
- * {@link database.Database `Database`} service associated with a specific
41
- * app.
40
+ * app's `Database` service or as `getDatabase(app)` to access the
41
+ * `Database` service associated with a specific app.
42
42
  *
43
43
  * @example
44
44
  * ```javascript
@@ -52,10 +52,10 @@ exports.ServerValue = database_1.ServerValue;
52
52
  * const otherDatabase = getDatabase(app);
53
53
  * ```
54
54
  *
55
- * @param App whose `Database` service to
55
+ * @param App - whose `Database` service to
56
56
  * return. If not provided, the default `Database` service will be returned.
57
57
  *
58
- * @return The default `Database` service if no app
58
+ * @returns The default `Database` service if no app
59
59
  * is provided or the `Database` service associated with the provided app.
60
60
  */
61
61
  function getDatabase(app) {
@@ -63,14 +63,12 @@ function getDatabase(app) {
63
63
  }
64
64
  exports.getDatabase = getDatabase;
65
65
  /**
66
- * Gets the {@link database.Database `Database`} service for the default
66
+ * Gets the {@link Database} service for the default
67
67
  * app or a given app.
68
68
  *
69
69
  * `getDatabaseWithUrl()` can be called with no arguments to access the default
70
- * app's {@link database.Database `Database`} service or as
71
- * `getDatabaseWithUrl(app)` to access the
72
- * {@link database.Database `Database`} service associated with a specific
73
- * app.
70
+ * app's {@link Database} service or as `getDatabaseWithUrl(app)` to access the
71
+ * {@link Database} service associated with a specific app.
74
72
  *
75
73
  * @example
76
74
  * ```javascript
@@ -84,10 +82,10 @@ exports.getDatabase = getDatabase;
84
82
  * const otherDatabase = getDatabaseWithUrl('https://example.firebaseio.com', app);
85
83
  * ```
86
84
  *
87
- * @param App whose `Database` service to
85
+ * @param App - whose `Database` service to
88
86
  * return. If not provided, the default `Database` service will be returned.
89
87
  *
90
- * @return The default `Database` service if no app
88
+ * @returns The default `Database` service if no app
91
89
  * is provided or the `Database` service associated with the provided app.
92
90
  */
93
91
  function getDatabaseWithUrl(url, app) {
@@ -100,6 +98,6 @@ function getDatabaseInstance(options) {
100
98
  app = app_1.getApp();
101
99
  }
102
100
  var firebaseApp = app;
103
- var dbService = firebaseApp.getOrInitService('database', function (app) { return new database_2.DatabaseService(app); });
101
+ var dbService = firebaseApp.getOrInitService('database', function (app) { return new database_1.DatabaseService(app); });
104
102
  return dbService.getDatabase(options.url);
105
103
  }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.100.0-alpha.0 */
1
+ /*! firebase-admin v10.0.2 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -15,4 +15,10 @@
15
15
  * limitations under the License.
16
16
  */
17
17
 
18
+ /**
19
+ * Firebase namespaced API (legacy).
20
+ *
21
+ * @packageDocumentation
22
+ */
23
+
18
24
  export * from './firebase-namespace-api';
@@ -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
@@ -16,7 +16,7 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
- var lifecycle_1 = require("./app/lifecycle");
19
+ var firebase_namespace_1 = require("./app/firebase-namespace");
20
20
  // Inject a circular default export to allow users to use both:
21
21
  //
22
22
  // import firebaseAdmin from 'firebase-admin';
@@ -26,5 +26,5 @@ var lifecycle_1 = require("./app/lifecycle");
26
26
  //
27
27
  // import * as firebaseAdmin from 'firebase-admin';
28
28
  // which becomes: var firebaseAdmin = require('firebase-admin');
29
- lifecycle_1.defaultNamespace.default = lifecycle_1.defaultNamespace;
30
- module.exports = lifecycle_1.defaultNamespace;
29
+ firebase_namespace_1.defaultNamespace.default = firebase_namespace_1.defaultNamespace;
30
+ module.exports = firebase_namespace_1.defaultNamespace;
@@ -0,0 +1,10 @@
1
+ import mod from "../../app/index.js";
2
+
3
+ export const SDK_VERSION = mod.SDK_VERSION;
4
+ export const applicationDefault = mod.applicationDefault;
5
+ export const cert = mod.cert;
6
+ export const deleteApp = mod.deleteApp;
7
+ export const getApp = mod.getApp;
8
+ export const getApps = mod.getApps;
9
+ export const initializeApp = mod.initializeApp;
10
+ export const refreshToken = mod.refreshToken;
@@ -0,0 +1,4 @@
1
+ import mod from "../../app-check/index.js";
2
+
3
+ export const AppCheck = mod.AppCheck;
4
+ export const getAppCheck = mod.getAppCheck;
@@ -0,0 +1,14 @@
1
+ import mod from "../../auth/index.js";
2
+
3
+ export const Auth = mod.Auth;
4
+ export const BaseAuth = mod.BaseAuth;
5
+ export const MultiFactorInfo = mod.MultiFactorInfo;
6
+ export const MultiFactorSettings = mod.MultiFactorSettings;
7
+ export const PhoneMultiFactorInfo = mod.PhoneMultiFactorInfo;
8
+ export const Tenant = mod.Tenant;
9
+ export const TenantAwareAuth = mod.TenantAwareAuth;
10
+ export const TenantManager = mod.TenantManager;
11
+ export const UserInfo = mod.UserInfo;
12
+ export const UserMetadata = mod.UserMetadata;
13
+ export const UserRecord = mod.UserRecord;
14
+ export const getAuth = mod.getAuth;
@@ -0,0 +1,6 @@
1
+ import mod from "../../database/index.js";
2
+
3
+ export const ServerValue = mod.ServerValue;
4
+ export const enableLogging = mod.enableLogging;
5
+ export const getDatabase = mod.getDatabase;
6
+ export const getDatabaseWithUrl = mod.getDatabaseWithUrl;
@@ -0,0 +1,24 @@
1
+ import mod from "../../firestore/index.js";
2
+
3
+ export const BulkWriter = mod.BulkWriter;
4
+ export const BundleBuilder = mod.BundleBuilder;
5
+ export const CollectionGroup = mod.CollectionGroup;
6
+ export const CollectionReference = mod.CollectionReference;
7
+ export const DocumentReference = mod.DocumentReference;
8
+ export const DocumentSnapshot = mod.DocumentSnapshot;
9
+ export const FieldPath = mod.FieldPath;
10
+ export const FieldValue = mod.FieldValue;
11
+ export const Firestore = mod.Firestore;
12
+ export const GeoPoint = mod.GeoPoint;
13
+ export const GrpcStatus = mod.GrpcStatus;
14
+ export const Query = mod.Query;
15
+ export const QueryDocumentSnapshot = mod.QueryDocumentSnapshot;
16
+ export const QueryPartition = mod.QueryPartition;
17
+ export const QuerySnapshot = mod.QuerySnapshot;
18
+ export const Timestamp = mod.Timestamp;
19
+ export const Transaction = mod.Transaction;
20
+ export const WriteBatch = mod.WriteBatch;
21
+ export const WriteResult = mod.WriteResult;
22
+ export const getFirestore = mod.getFirestore;
23
+ export const setLogFunction = mod.setLogFunction;
24
+ export const v1 = mod.v1;
@@ -0,0 +1,4 @@
1
+ import mod from "../../installations/index.js";
2
+
3
+ export const Installations = mod.Installations;
4
+ export const getInstallations = mod.getInstallations;
@@ -0,0 +1,4 @@
1
+ import mod from "../../instance-id/index.js";
2
+
3
+ export const InstanceId = mod.InstanceId;
4
+ export const getInstanceId = mod.getInstanceId;
@@ -0,0 +1,5 @@
1
+ import mod from "../../machine-learning/index.js";
2
+
3
+ export const MachineLearning = mod.MachineLearning;
4
+ export const Model = mod.Model;
5
+ export const getMachineLearning = mod.getMachineLearning;
@@ -0,0 +1,4 @@
1
+ import mod from "../../messaging/index.js";
2
+
3
+ export const Messaging = mod.Messaging;
4
+ export const getMessaging = mod.getMessaging;
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,8 @@
1
+ import mod from "../../project-management/index.js";
2
+
3
+ export const AndroidApp = mod.AndroidApp;
4
+ export const AppPlatform = mod.AppPlatform;
5
+ export const IosApp = mod.IosApp;
6
+ export const ProjectManagement = mod.ProjectManagement;
7
+ export const ShaCertificate = mod.ShaCertificate;
8
+ export const getProjectManagement = mod.getProjectManagement;
@@ -0,0 +1,4 @@
1
+ import mod from "../../remote-config/index.js";
2
+
3
+ export const RemoteConfig = mod.RemoteConfig;
4
+ export const getRemoteConfig = mod.getRemoteConfig;
@@ -0,0 +1,6 @@
1
+ import mod from "../../security-rules/index.js";
2
+
3
+ export const Ruleset = mod.Ruleset;
4
+ export const RulesetMetadataList = mod.RulesetMetadataList;
5
+ export const SecurityRules = mod.SecurityRules;
6
+ export const getSecurityRules = mod.getSecurityRules;
@@ -0,0 +1,4 @@
1
+ import mod from "../../storage/index.js";
2
+
3
+ export const Storage = mod.Storage;
4
+ export const getStorage = mod.getStorage;