firebase-admin 9.3.0 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/lib/auth/action-code-settings-builder.js +1 -1
  2. package/lib/auth/auth-api-request.js +98 -25
  3. package/lib/auth/auth-config.js +15 -15
  4. package/lib/auth/auth.js +82 -61
  5. package/lib/auth/identifier.js +3 -2
  6. package/lib/auth/index.d.ts +1868 -0
  7. package/lib/{credential/credential-interfaces.js → auth/index.js} +1 -1
  8. package/lib/auth/tenant-manager.js +1 -1
  9. package/lib/auth/tenant.js +7 -1
  10. package/lib/auth/token-generator.js +6 -4
  11. package/lib/auth/token-verifier.js +32 -36
  12. package/lib/auth/user-import-builder.js +18 -15
  13. package/lib/auth/user-record.js +4 -4
  14. package/lib/credential/credential-internal.js +1 -2
  15. package/lib/credential/credential.js +8 -122
  16. package/lib/credential/index.d.ts +169 -0
  17. package/lib/credential/index.js +5 -17
  18. package/lib/database/database-internal.js +19 -26
  19. package/lib/database/index.d.ts +89 -0
  20. package/lib/database/index.js +12 -28
  21. package/lib/default-namespace.js +2 -1
  22. package/lib/firebase-app.js +26 -48
  23. package/lib/firebase-namespace-api.d.ts +238 -0
  24. package/lib/{firebase-service.js → firebase-namespace-api.js} +2 -2
  25. package/lib/{database/database.js → firebase-namespace.d.ts} +14 -7
  26. package/lib/firebase-namespace.js +22 -92
  27. package/lib/firestore/firestore-internal.js +2 -19
  28. package/lib/firestore/index.d.ts +50 -0
  29. package/lib/firestore/index.js +28 -43
  30. package/lib/index.d.ts +3 -932
  31. package/lib/index.js +2 -1
  32. package/lib/instance-id/index.d.ts +81 -0
  33. package/lib/instance-id/index.js +1 -10
  34. package/lib/instance-id/instance-id-request-internal.js +2 -1
  35. package/lib/instance-id/instance-id.js +1 -19
  36. package/lib/machine-learning/index.d.ts +249 -0
  37. package/lib/{messaging/messaging-types.js → machine-learning/index.js} +2 -2
  38. package/lib/machine-learning/machine-learning-api-client.js +1 -1
  39. package/lib/machine-learning/machine-learning-utils.js +1 -1
  40. package/lib/machine-learning/machine-learning.js +3 -22
  41. package/lib/messaging/batch-request-internal.js +1 -1
  42. package/lib/messaging/index.d.ts +1174 -0
  43. package/lib/messaging/index.js +1 -24
  44. package/lib/messaging/messaging-api-request-internal.js +2 -1
  45. package/lib/messaging/messaging-errors-internal.js +1 -1
  46. package/lib/messaging/messaging-internal.js +1 -1
  47. package/lib/messaging/messaging.js +21 -25
  48. package/lib/project-management/android-app.js +7 -6
  49. package/lib/project-management/index.d.ts +363 -0
  50. package/lib/project-management/index.js +23 -25
  51. package/lib/project-management/ios-app.js +5 -4
  52. package/lib/project-management/project-management-api-request-internal.js +5 -5
  53. package/lib/project-management/project-management.js +9 -26
  54. package/lib/remote-config/index.d.ts +359 -0
  55. package/lib/remote-config/index.js +1 -26
  56. package/lib/remote-config/remote-config-api-client-internal.js +3 -3
  57. package/lib/remote-config/remote-config.js +15 -32
  58. package/lib/security-rules/index.d.ts +216 -0
  59. package/lib/security-rules/index.js +1 -24
  60. package/lib/security-rules/security-rules-api-client-internal.js +1 -1
  61. package/lib/security-rules/security-rules-internal.js +1 -1
  62. package/lib/security-rules/security-rules.js +6 -15
  63. package/lib/storage/index.d.ts +60 -0
  64. package/lib/storage/index.js +1 -10
  65. package/lib/storage/storage.js +2 -19
  66. package/lib/utils/api-request.js +10 -3
  67. package/lib/utils/deep-copy.js +2 -1
  68. package/lib/utils/error.js +2 -1
  69. package/lib/utils/index.js +6 -5
  70. package/lib/utils/validator.js +2 -1
  71. package/package.json +15 -12
  72. package/lib/auth.d.ts +0 -2016
  73. package/lib/credential.d.ts +0 -150
  74. package/lib/database.d.ts +0 -1663
  75. package/lib/instance-id.d.ts +0 -37
  76. package/lib/messaging.d.ts +0 -1341
  77. package/lib/project-management/app-metadata.js +0 -37
  78. package/lib/project-management.d.ts +0 -361
  79. package/lib/remote-config/remote-config-api-client.js +0 -36
  80. package/lib/remote-config.d.ts +0 -350
  81. package/lib/security-rules.d.ts +0 -192
  82. package/lib/storage.d.ts +0 -40
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -140,8 +140,8 @@ var ProjectManagementRequestHandler = /** @class */ (function () {
140
140
  return this
141
141
  .invokeRequestHandler('POST', parentResourceName + "/androidApps", requestData, 'v1beta1')
142
142
  .then(function (responseData) {
143
- assertServerResponse(validator.isNonNullObject(responseData), responseData, "createAndroidApp's responseData must be a non-null object.");
144
- assertServerResponse(validator.isNonEmptyString(responseData.name), responseData, "createAndroidApp's responseData.name must be a non-empty string.");
143
+ assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createAndroidApp\'s responseData must be a non-null object.');
144
+ assertServerResponse(validator.isNonEmptyString(responseData.name), responseData, 'createAndroidApp\'s responseData.name must be a non-empty string.');
145
145
  return _this.pollRemoteOperationWithExponentialBackoff(responseData.name);
146
146
  });
147
147
  };
@@ -160,8 +160,8 @@ var ProjectManagementRequestHandler = /** @class */ (function () {
160
160
  return this
161
161
  .invokeRequestHandler('POST', parentResourceName + "/iosApps", requestData, 'v1beta1')
162
162
  .then(function (responseData) {
163
- assertServerResponse(validator.isNonNullObject(responseData), responseData, "createIosApp's responseData must be a non-null object.");
164
- assertServerResponse(validator.isNonEmptyString(responseData.name), responseData, "createIosApp's responseData.name must be a non-empty string.");
163
+ assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createIosApp\'s responseData must be a non-null object.');
164
+ assertServerResponse(validator.isNonEmptyString(responseData.name), responseData, 'createIosApp\'s responseData.name must be a non-empty string.');
165
165
  return _this.pollRemoteOperationWithExponentialBackoff(responseData.name);
166
166
  });
167
167
  };
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -23,29 +23,13 @@ var validator = require("../utils/validator");
23
23
  var android_app_1 = require("./android-app");
24
24
  var ios_app_1 = require("./ios-app");
25
25
  var project_management_api_request_internal_1 = require("./project-management-api-request-internal");
26
- var app_metadata_1 = require("./app-metadata");
27
- /**
28
- * Internals of a Project Management instance.
29
- */
30
- var ProjectManagementInternals = /** @class */ (function () {
31
- function ProjectManagementInternals() {
32
- }
33
- /**
34
- * Deletes the service and its associated resources.
35
- *
36
- * @return {Promise<void>} An empty Promise that will be resolved when the service is deleted.
37
- */
38
- ProjectManagementInternals.prototype.delete = function () {
39
- // There are no resources to clean up.
40
- return Promise.resolve();
41
- };
42
- return ProjectManagementInternals;
43
- }());
26
+ var index_1 = require("./index");
27
+ var AppPlatform = index_1.projectManagement.AppPlatform;
44
28
  /**
45
29
  * The Firebase ProjectManagement service interface.
46
30
  *
47
31
  * Do not call this constructor directly. Instead, use
48
- * [`admin.projectManagement()`](admin.projectManagement#projectManagement).
32
+ * [`admin.projectManagement()`](projectManagement#projectManagement).
49
33
  */
50
34
  var ProjectManagement = /** @class */ (function () {
51
35
  /**
@@ -54,7 +38,6 @@ var ProjectManagement = /** @class */ (function () {
54
38
  */
55
39
  function ProjectManagement(app) {
56
40
  this.app = app;
57
- this.INTERNAL = new ProjectManagementInternals();
58
41
  if (!validator.isNonNullObject(app) || !('options' in app)) {
59
42
  throw new error_1.FirebaseProjectManagementError('invalid-argument', 'First argument passed to admin.projectManagement() must be a valid Firebase app '
60
43
  + 'instance.');
@@ -133,7 +116,7 @@ var ProjectManagement = /** @class */ (function () {
133
116
  })
134
117
  .then(function (responseData) {
135
118
  project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createAndroidApp()\'s responseData must be a non-null object.');
136
- project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(responseData.appId), responseData, "\"responseData.appId\" field must be present in createAndroidApp()'s response data.");
119
+ project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(responseData.appId), responseData, '"responseData.appId" field must be present in createAndroidApp()\'s response data.');
137
120
  return new android_app_1.AndroidApp(responseData.appId, _this.requestHandler);
138
121
  });
139
122
  };
@@ -154,7 +137,7 @@ var ProjectManagement = /** @class */ (function () {
154
137
  })
155
138
  .then(function (responseData) {
156
139
  project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createIosApp()\'s responseData must be a non-null object.');
157
- project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(responseData.appId), responseData, "\"responseData.appId\" field must be present in createIosApp()'s response data.");
140
+ project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(responseData.appId), responseData, '"responseData.appId" field must be present in createIosApp()\'s response data.');
158
141
  return new ios_app_1.IosApp(responseData.appId, _this.requestHandler);
159
142
  });
160
143
  };
@@ -196,11 +179,11 @@ var ProjectManagement = /** @class */ (function () {
196
179
  return [];
197
180
  }
198
181
  return responseData.apps.map(function (appJson) {
199
- project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(appJson.appId), responseData, "\"apps[].appId\" field must be present in the listAppMetadata() response data.");
200
- project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(appJson.platform), responseData, "\"apps[].platform\" field must be present in the listAppMetadata() response data.");
182
+ project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(appJson.appId), responseData, '"apps[].appId" field must be present in the listAppMetadata() response data.');
183
+ project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(appJson.platform), responseData, '"apps[].platform" field must be present in the listAppMetadata() response data.');
201
184
  var metadata = {
202
185
  appId: appJson.appId,
203
- platform: app_metadata_1.AppPlatform[appJson.platform] || app_metadata_1.AppPlatform.PLATFORM_UNKNOWN,
186
+ platform: AppPlatform[appJson.platform] || AppPlatform.PLATFORM_UNKNOWN,
204
187
  projectId: projectId,
205
188
  resourceName: appJson.name,
206
189
  };
@@ -0,0 +1,359 @@
1
+ /*! firebase-admin v9.5.0 */
2
+ /*!
3
+ * Copyright 2020 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { app } from '../firebase-namespace-api';
18
+ /**
19
+ * Gets the {@link remoteConfig.RemoteConfig `RemoteConfig`} service for the
20
+ * default app or a given app.
21
+ *
22
+ * `admin.remoteConfig()` can be called with no arguments to access the default
23
+ * app's {@link remoteConfig.RemoteConfig `RemoteConfig`} service or as
24
+ * `admin.remoteConfig(app)` to access the
25
+ * {@link remoteConfig.RemoteConfig `RemoteConfig`} service associated with a
26
+ * specific app.
27
+ *
28
+ * @example
29
+ * ```javascript
30
+ * // Get the `RemoteConfig` service for the default app
31
+ * var defaultRemoteConfig = admin.remoteConfig();
32
+ * ```
33
+ *
34
+ * @example
35
+ * ```javascript
36
+ * // Get the `RemoteConfig` service for a given app
37
+ * var otherRemoteConfig = admin.remoteConfig(otherApp);
38
+ * ```
39
+ *
40
+ * @param app Optional app for which to return the `RemoteConfig` service.
41
+ * If not provided, the default `RemoteConfig` service is returned.
42
+ *
43
+ * @return The default `RemoteConfig` service if no
44
+ * app is provided, or the `RemoteConfig` service associated with the provided
45
+ * app.
46
+ */
47
+ export declare function remoteConfig(app?: app.App): remoteConfig.RemoteConfig;
48
+ export declare namespace remoteConfig {
49
+ /**
50
+ * Interface representing options for Remote Config list versions operation.
51
+ */
52
+ interface ListVersionsOptions {
53
+ /**
54
+ * The maximum number of items to return per page.
55
+ */
56
+ pageSize?: number;
57
+ /**
58
+ * The `nextPageToken` value returned from a previous list versions request, if any.
59
+ */
60
+ pageToken?: string;
61
+ /**
62
+ * Specifies the newest version number to include in the results.
63
+ * If specified, must be greater than zero. Defaults to the newest version.
64
+ */
65
+ endVersionNumber?: string | number;
66
+ /**
67
+ * Specifies the earliest update time to include in the results. Any entries updated before this
68
+ * time are omitted.
69
+ */
70
+ startTime?: Date | string;
71
+ /**
72
+ * Specifies the latest update time to include in the results. Any entries updated on or after
73
+ * this time are omitted.
74
+ */
75
+ endTime?: Date | string;
76
+ }
77
+ /**
78
+ * Interface representing a list of Remote Config template versions.
79
+ */
80
+ interface ListVersionsResult {
81
+ /**
82
+ * A list of version metadata objects, sorted in reverse chronological order.
83
+ */
84
+ versions: Version[];
85
+ /**
86
+ * Token to retrieve the next page of results, or empty if there are no more results
87
+ * in the list.
88
+ */
89
+ nextPageToken?: string;
90
+ }
91
+ /**
92
+ * Interface representing a Remote Config condition.
93
+ * A condition targets a specific group of users. A list of these conditions make up
94
+ * part of a Remote Config template.
95
+ */
96
+ interface RemoteConfigCondition {
97
+ /**
98
+ * A non-empty and unique name of this condition.
99
+ */
100
+ name: string;
101
+ /**
102
+ * The logic of this condition.
103
+ * See the documentation on
104
+ * {@link https://firebase.google.com/docs/remote-config/condition-reference condition expressions}
105
+ * for the expected syntax of this field.
106
+ */
107
+ expression: string;
108
+ /**
109
+ * The color associated with this condition for display purposes in the Firebase Console.
110
+ * Not specifying this value results in the console picking an arbitrary color to associate
111
+ * with the condition.
112
+ */
113
+ tagColor?: TagColor;
114
+ }
115
+ /**
116
+ * Interface representing a Remote Config parameter.
117
+ * At minimum, a `defaultValue` or a `conditionalValues` entry must be present for the
118
+ * parameter to have any effect.
119
+ */
120
+ interface RemoteConfigParameter {
121
+ /**
122
+ * The value to set the parameter to, when none of the named conditions evaluate to `true`.
123
+ */
124
+ defaultValue?: RemoteConfigParameterValue;
125
+ /**
126
+ * A `(condition name, value)` map. The condition name of the highest priority
127
+ * (the one listed first in the Remote Config template's conditions list) determines the value of
128
+ * this parameter.
129
+ */
130
+ conditionalValues?: {
131
+ [key: string]: RemoteConfigParameterValue;
132
+ };
133
+ /**
134
+ * A description for this parameter. Should not be over 100 characters and may contain any
135
+ * Unicode characters.
136
+ */
137
+ description?: string;
138
+ }
139
+ /**
140
+ * Interface representing a Remote Config parameter group.
141
+ * Grouping parameters is only for management purposes and does not affect client-side
142
+ * fetching of parameter values.
143
+ */
144
+ interface RemoteConfigParameterGroup {
145
+ /**
146
+ * A description for the group. Its length must be less than or equal to 256 characters.
147
+ * A description may contain any Unicode characters.
148
+ */
149
+ description?: string;
150
+ /**
151
+ * Map of parameter keys to their optional default values and optional conditional values for
152
+ * parameters that belong to this group. A parameter only appears once per
153
+ * Remote Config template. An ungrouped parameter appears at the top level, whereas a
154
+ * parameter organized within a group appears within its group's map of parameters.
155
+ */
156
+ parameters: {
157
+ [key: string]: RemoteConfigParameter;
158
+ };
159
+ }
160
+ /**
161
+ * Interface representing an explicit parameter value.
162
+ */
163
+ interface ExplicitParameterValue {
164
+ /**
165
+ * The `string` value that the parameter is set to.
166
+ */
167
+ value: string;
168
+ }
169
+ /**
170
+ * Interface representing an in-app-default value.
171
+ */
172
+ interface InAppDefaultValue {
173
+ /**
174
+ * If `true`, the parameter is omitted from the parameter values returned to a client.
175
+ */
176
+ useInAppDefault: boolean;
177
+ }
178
+ /**
179
+ * Type representing a Remote Config parameter value.
180
+ * A `RemoteConfigParameterValue` could be either an `ExplicitParameterValue` or
181
+ * an `InAppDefaultValue`.
182
+ */
183
+ type RemoteConfigParameterValue = ExplicitParameterValue | InAppDefaultValue;
184
+ /**
185
+ * Interface representing a Remote Config template.
186
+ */
187
+ interface RemoteConfigTemplate {
188
+ /**
189
+ * A list of conditions in descending order by priority.
190
+ */
191
+ conditions: RemoteConfigCondition[];
192
+ /**
193
+ * Map of parameter keys to their optional default values and optional conditional values.
194
+ */
195
+ parameters: {
196
+ [key: string]: RemoteConfigParameter;
197
+ };
198
+ /**
199
+ * Map of parameter group names to their parameter group objects.
200
+ * A group's name is mutable but must be unique among groups in the Remote Config template.
201
+ * The name is limited to 256 characters and intended to be human-readable. Any Unicode
202
+ * characters are allowed.
203
+ */
204
+ parameterGroups: {
205
+ [key: string]: RemoteConfigParameterGroup;
206
+ };
207
+ /**
208
+ * ETag of the current Remote Config template (readonly).
209
+ */
210
+ readonly etag: string;
211
+ /**
212
+ * Version information for the current Remote Config template.
213
+ */
214
+ version?: Version;
215
+ }
216
+ /**
217
+ * Interface representing a Remote Config user.
218
+ */
219
+ interface RemoteConfigUser {
220
+ /**
221
+ * Email address. Output only.
222
+ */
223
+ email: string;
224
+ /**
225
+ * Display name. Output only.
226
+ */
227
+ name?: string;
228
+ /**
229
+ * Image URL. Output only.
230
+ */
231
+ imageUrl?: string;
232
+ }
233
+ /**
234
+ * Colors that are associated with conditions for display purposes.
235
+ */
236
+ type TagColor = 'BLUE' | 'BROWN' | 'CYAN' | 'DEEP_ORANGE' | 'GREEN' | 'INDIGO' | 'LIME' | 'ORANGE' | 'PINK' | 'PURPLE' | 'TEAL';
237
+ /**
238
+ * Interface representing a Remote Config template version.
239
+ * Output only, except for the version description. Contains metadata about a particular
240
+ * version of the Remote Config template. All fields are set at the time the specified Remote
241
+ * Config template is published. A version's description field may be specified in
242
+ * `publishTemplate` calls.
243
+ */
244
+ interface Version {
245
+ /**
246
+ * The version number of a Remote Config template.
247
+ */
248
+ versionNumber?: string;
249
+ /**
250
+ * The timestamp of when this version of the Remote Config template was written to the
251
+ * Remote Config backend.
252
+ */
253
+ updateTime?: string;
254
+ /**
255
+ * The origin of the template update action.
256
+ */
257
+ updateOrigin?: ('REMOTE_CONFIG_UPDATE_ORIGIN_UNSPECIFIED' | 'CONSOLE' | 'REST_API' | 'ADMIN_SDK_NODE');
258
+ /**
259
+ * The type of the template update action.
260
+ */
261
+ updateType?: ('REMOTE_CONFIG_UPDATE_TYPE_UNSPECIFIED' | 'INCREMENTAL_UPDATE' | 'FORCED_UPDATE' | 'ROLLBACK');
262
+ /**
263
+ * Aggregation of all metadata fields about the account that performed the update.
264
+ */
265
+ updateUser?: RemoteConfigUser;
266
+ /**
267
+ * The user-provided description of the corresponding Remote Config template.
268
+ */
269
+ description?: string;
270
+ /**
271
+ * The version number of the Remote Config template that has become the current version
272
+ * due to a rollback. Only present if this version is the result of a rollback.
273
+ */
274
+ rollbackSource?: string;
275
+ /**
276
+ * Indicates whether this Remote Config template was published before version history was
277
+ * supported.
278
+ */
279
+ isLegacy?: boolean;
280
+ }
281
+ /**
282
+ * The Firebase `RemoteConfig` service interface.
283
+ */
284
+ interface RemoteConfig {
285
+ app: app.App;
286
+ /**
287
+ * Gets the current active version of the {@link remoteConfig.RemoteConfigTemplate
288
+ * `RemoteConfigTemplate`} of the project.
289
+ *
290
+ * @return A promise that fulfills with a `RemoteConfigTemplate`.
291
+ */
292
+ getTemplate(): Promise<RemoteConfigTemplate>;
293
+ /**
294
+ * Gets the requested version of the {@link remoteConfig.RemoteConfigTemplate
295
+ * `RemoteConfigTemplate`} of the project.
296
+ *
297
+ * @param versionNumber Version number of the Remote Config template to look up.
298
+ *
299
+ * @return A promise that fulfills with a `RemoteConfigTemplate`.
300
+ */
301
+ getTemplateAtVersion(versionNumber: number | string): Promise<RemoteConfigTemplate>;
302
+ /**
303
+ * Validates a {@link remoteConfig.RemoteConfigTemplate `RemoteConfigTemplate`}.
304
+ *
305
+ * @param template The Remote Config template to be validated.
306
+ * @returns A promise that fulfills with the validated `RemoteConfigTemplate`.
307
+ */
308
+ validateTemplate(template: RemoteConfigTemplate): Promise<RemoteConfigTemplate>;
309
+ /**
310
+ * Publishes a Remote Config template.
311
+ *
312
+ * @param template The Remote Config template to be published.
313
+ * @param options Optional options object when publishing a Remote Config template:
314
+ * - {boolean} `force` Setting this to `true` forces the Remote Config template to
315
+ * be updated and circumvent the ETag. This approach is not recommended
316
+ * because it risks causing the loss of updates to your Remote Config
317
+ * template if multiple clients are updating the Remote Config template.
318
+ * See {@link https://firebase.google.com/docs/remote-config/use-config-rest#etag_usage_and_forced_updates
319
+ * ETag usage and forced updates}.
320
+ *
321
+ * @return A Promise that fulfills with the published `RemoteConfigTemplate`.
322
+ */
323
+ publishTemplate(template: RemoteConfigTemplate, options?: {
324
+ force: boolean;
325
+ }): Promise<RemoteConfigTemplate>;
326
+ /**
327
+ * Rolls back a project's published Remote Config template to the specified version.
328
+ * A rollback is equivalent to getting a previously published Remote Config
329
+ * template and re-publishing it using a force update.
330
+ *
331
+ * @param versionNumber The version number of the Remote Config template to roll back to.
332
+ * The specified version number must be lower than the current version number, and not have
333
+ * been deleted due to staleness. Only the last 300 versions are stored.
334
+ * All versions that correspond to non-active Remote Config templates (that is, all except the
335
+ * template that is being fetched by clients) are also deleted if they are more than 90 days old.
336
+ * @return A promise that fulfills with the published `RemoteConfigTemplate`.
337
+ */
338
+ rollback(versionNumber: string | number): Promise<RemoteConfigTemplate>;
339
+ /**
340
+ * Gets a list of Remote Config template versions that have been published, sorted in reverse
341
+ * chronological order. Only the last 300 versions are stored.
342
+ * All versions that correspond to non-active Remote Config templates (that is, all except the
343
+ * template that is being fetched by clients) are also deleted if they are more than 90 days old.
344
+ *
345
+ * @param options Optional {@link remoteConfig.ListVersionsOptions `ListVersionsOptions`}
346
+ * object for getting a list of template versions.
347
+ * @return A promise that fulfills with a `ListVersionsResult`.
348
+ */
349
+ listVersions(options?: ListVersionsOptions): Promise<ListVersionsResult>;
350
+ /**
351
+ * Creates and returns a new Remote Config template from a JSON string.
352
+ *
353
+ * @param json The JSON string to populate a Remote Config template.
354
+ *
355
+ * @return A new template instance.
356
+ */
357
+ createTemplateFromJSON(json: string): RemoteConfigTemplate;
358
+ }
359
+ }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -16,28 +16,3 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.admin = exports.remoteConfig = void 0;
20
- var remoteConfigClientApi = require("./remote-config-api-client");
21
- var firebaseAdmin = require("../index");
22
- function remoteConfig(app) {
23
- if (typeof (app) === 'undefined') {
24
- app = firebaseAdmin.app();
25
- }
26
- return app.remoteConfig();
27
- }
28
- exports.remoteConfig = remoteConfig;
29
- /**
30
- * We must define a namespace to make the typings work correctly. Otherwise
31
- * `admin.remoteConfig()` cannot be called like a function. Temporarily,
32
- * admin.remoteConfig is used as the namespace name because we cannot barrel
33
- * re-export the contents from remote-config, and we want it to
34
- * match the namespacing in the re-export inside src/index.d.ts
35
- */
36
- /* eslint-disable @typescript-eslint/no-namespace */
37
- var admin;
38
- (function (admin) {
39
- var remoteConfig;
40
- (function (remoteConfig) {
41
- remoteConfig.TagColor = remoteConfigClientApi.TagColor;
42
- })(remoteConfig = admin.remoteConfig || (admin.remoteConfig = {}));
43
- })(admin = exports.admin || (exports.admin = {}));
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -112,7 +112,7 @@ var RemoteConfigApiClient = /** @class */ (function () {
112
112
  template = this.validateInputRemoteConfigTemplate(template);
113
113
  return this.sendPutRequest(template, template.etag, true)
114
114
  .then(function (resp) {
115
- // validating a template returns an etag with the suffix -0 means that your update
115
+ // validating a template returns an etag with the suffix -0 means that your update
116
116
  // was successfully validated. We set the etag back to the original etag of the template
117
117
  // to allow future operations.
118
118
  _this.validateEtag(resp.headers['etag']);
@@ -379,7 +379,7 @@ var RemoteConfigApiClient = /** @class */ (function () {
379
379
  exports.RemoteConfigApiClient = RemoteConfigApiClient;
380
380
  var ERROR_CODE_MAPPING = {
381
381
  ABORTED: 'aborted',
382
- ALREADY_EXISTS: "already-exists",
382
+ ALREADY_EXISTS: 'already-exists',
383
383
  INVALID_ARGUMENT: 'invalid-argument',
384
384
  INTERNAL: 'internal-error',
385
385
  FAILED_PRECONDITION: 'failed-precondition',
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -19,38 +19,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.RemoteConfig = void 0;
20
20
  var validator = require("../utils/validator");
21
21
  var remote_config_api_client_internal_1 = require("./remote-config-api-client-internal");
22
- /**
23
- * Internals of an RemoteConfig service instance.
24
- */
25
- var RemoteConfigInternals = /** @class */ (function () {
26
- function RemoteConfigInternals() {
27
- }
28
- /**
29
- * Deletes the service and its associated resources.
30
- *
31
- * @return {Promise<()>} An empty Promise that will be fulfilled when the service is deleted.
32
- */
33
- RemoteConfigInternals.prototype.delete = function () {
34
- // There are no resources to clean up
35
- return Promise.resolve(undefined);
36
- };
37
- return RemoteConfigInternals;
38
- }());
39
22
  /**
40
23
  * Remote Config service bound to the provided app.
41
24
  */
42
25
  var RemoteConfig = /** @class */ (function () {
43
26
  /**
44
- * @param {FirebaseApp} app The app for this RemoteConfig service.
27
+ * @param app The app for this RemoteConfig service.
45
28
  * @constructor
46
29
  */
47
30
  function RemoteConfig(app) {
48
31
  this.app = app;
49
- this.INTERNAL = new RemoteConfigInternals();
50
32
  this.client = new remote_config_api_client_internal_1.RemoteConfigApiClient(app);
51
33
  }
52
34
  /**
53
- * Gets the current active version of the {@link admin.remoteConfig.RemoteConfigTemplate
35
+ * Gets the current active version of the {@link remoteConfig.RemoteConfigTemplate
54
36
  * `RemoteConfigTemplate`} of the project.
55
37
  *
56
38
  * @return A promise that fulfills with a `RemoteConfigTemplate`.
@@ -62,7 +44,7 @@ var RemoteConfig = /** @class */ (function () {
62
44
  });
63
45
  };
64
46
  /**
65
- * Gets the requested version of the {@link admin.remoteConfig.RemoteConfigTemplate
47
+ * Gets the requested version of the {@link remoteConfig.RemoteConfigTemplate
66
48
  * `RemoteConfigTemplate`} of the project.
67
49
  *
68
50
  * @param versionNumber Version number of the Remote Config template to look up.
@@ -76,7 +58,7 @@ var RemoteConfig = /** @class */ (function () {
76
58
  });
77
59
  };
78
60
  /**
79
- * Validates a {@link admin.remoteConfig.RemoteConfigTemplate `RemoteConfigTemplate`}.
61
+ * Validates a {@link remoteConfig.RemoteConfigTemplate `RemoteConfigTemplate`}.
80
62
  *
81
63
  * @param template The Remote Config template to be validated.
82
64
  * @returns A promise that fulfills with the validated `RemoteConfigTemplate`.
@@ -131,7 +113,7 @@ var RemoteConfig = /** @class */ (function () {
131
113
  * All versions that correspond to non-active Remote Config templates (i.e., all except the
132
114
  * template that is being fetched by clients) are also deleted if they are older than 90 days.
133
115
  *
134
- * @param {ListVersionsOptions} options Optional options object for getting a list of versions.
116
+ * @param options Optional options object for getting a list of versions.
135
117
  * @return A promise that fulfills with a `ListVersionsResult`.
136
118
  */
137
119
  RemoteConfig.prototype.listVersions = function (options) {
@@ -288,18 +270,14 @@ var VersionImpl = /** @class */ (function () {
288
270
  }
289
271
  this.isLegacy = version.isLegacy;
290
272
  }
291
- // The backend API provides timestamps as ISO date strings. The Admin SDK exposes timestamps
292
- // as UTC date strings. If a developer uses a previously obtained template with UTC timestamps
273
+ // The backend API provides timestamps in ISO date strings. The Admin SDK exposes timestamps
274
+ // in UTC date strings. If a developer uses a previously obtained template with UTC timestamps
293
275
  // we could still validate it below.
294
276
  if (typeof version.updateTime !== 'undefined') {
295
- if (!validator.isISODateString(version.updateTime) &&
296
- !validator.isUTCDateString(version.updateTime)) {
277
+ if (!this.isValidTimestamp(version.updateTime)) {
297
278
  throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update time must be a valid date string');
298
279
  }
299
- if (validator.isISODateString(version.updateTime)) {
300
- // timestamps in output `Version` obtained from the API should be in UTC.
301
- this.updateTime = new Date(version.updateTime).toUTCString();
302
- }
280
+ this.updateTime = new Date(version.updateTime).toUTCString();
303
281
  }
304
282
  }
305
283
  /**
@@ -317,5 +295,10 @@ var VersionImpl = /** @class */ (function () {
317
295
  updateTime: this.updateTime,
318
296
  };
319
297
  };
298
+ VersionImpl.prototype.isValidTimestamp = function (timestamp) {
299
+ // This validation fails for timestamps earlier than January 1, 1970 and considers strings
300
+ // such as "1.2" as valid timestamps.
301
+ return validator.isNonEmptyString(timestamp) && (new Date(timestamp)).getTime() > 0;
302
+ };
320
303
  return VersionImpl;
321
304
  }());