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
package/lib/index.js CHANGED
@@ -1,6 +1,7 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
+ * @license
4
5
  * Copyright 2017 Google Inc.
5
6
  *
6
7
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -0,0 +1,81 @@
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 instanceId.InstanceId `InstanceId`} service for the
20
+ * default app or a given app.
21
+ *
22
+ * `admin.instanceId()` can be called with no arguments to access the default
23
+ * app's {@link instanceId.InstanceId `InstanceId`} service or as
24
+ * `admin.instanceId(app)` to access the
25
+ * {@link instanceId.InstanceId `InstanceId`} service associated with a
26
+ * specific app.
27
+ *
28
+ * @example
29
+ * ```javascript
30
+ * // Get the Instance ID service for the default app
31
+ * var defaultInstanceId = admin.instanceId();
32
+ * ```
33
+ *
34
+ * @example
35
+ * ```javascript
36
+ * // Get the Instance ID service for a given app
37
+ * var otherInstanceId = admin.instanceId(otherApp);
38
+ *```
39
+ *
40
+ * @param app Optional app whose `InstanceId` service to
41
+ * return. If not provided, the default `InstanceId` service will be
42
+ * returned.
43
+ *
44
+ * @return The default `InstanceId` service if
45
+ * no app is provided or the `InstanceId` service associated with the
46
+ * provided app.
47
+ */
48
+ export declare function instanceId(app?: app.App): instanceId.InstanceId;
49
+ export declare namespace instanceId {
50
+ /**
51
+ * Gets the {@link InstanceId `InstanceId`} service for the
52
+ * current app.
53
+ *
54
+ * @example
55
+ * ```javascript
56
+ * var instanceId = app.instanceId();
57
+ * // The above is shorthand for:
58
+ * // var instanceId = admin.instanceId(app);
59
+ * ```
60
+ *
61
+ * @return The `InstanceId` service for the
62
+ * current app.
63
+ */
64
+ interface InstanceId {
65
+ app: app.App;
66
+ /**
67
+ * Deletes the specified instance ID and the associated data from Firebase.
68
+ *
69
+ * Note that Google Analytics for Firebase uses its own form of Instance ID to
70
+ * keep track of analytics data. Therefore deleting a Firebase Instance ID does
71
+ * not delete Analytics data. See
72
+ * [Delete an Instance ID](/support/privacy/manage-iids#delete_an_instance_id)
73
+ * for more information.
74
+ *
75
+ * @param instanceId The instance ID to be deleted.
76
+ *
77
+ * @return A promise fulfilled when the instance ID is deleted.
78
+ */
79
+ deleteInstanceId(instanceId: string): Promise<void>;
80
+ }
81
+ }
@@ -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,12 +16,3 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.instanceId = void 0;
20
- var firebaseAdmin = require("../index");
21
- function instanceId(app) {
22
- if (typeof (app) === 'undefined') {
23
- app = firebaseAdmin.app();
24
- }
25
- return app.instanceId();
26
- }
27
- exports.instanceId = instanceId;
@@ -1,6 +1,7 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
+ * @license
4
5
  * Copyright 2017 Google Inc.
5
6
  *
6
7
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -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.
@@ -20,23 +20,6 @@ exports.InstanceId = void 0;
20
20
  var error_1 = require("../utils/error");
21
21
  var instance_id_request_internal_1 = require("./instance-id-request-internal");
22
22
  var validator = require("../utils/validator");
23
- /**
24
- * Internals of an InstanceId service instance.
25
- */
26
- var InstanceIdInternals = /** @class */ (function () {
27
- function InstanceIdInternals() {
28
- }
29
- /**
30
- * Deletes the service and its associated resources.
31
- *
32
- * @return {Promise<()>} An empty Promise that will be fulfilled when the service is deleted.
33
- */
34
- InstanceIdInternals.prototype.delete = function () {
35
- // There are no resources to clean up
36
- return Promise.resolve(undefined);
37
- };
38
- return InstanceIdInternals;
39
- }());
40
23
  /**
41
24
  * Gets the {@link InstanceId `InstanceId`} service for the
42
25
  * current app.
@@ -57,7 +40,6 @@ var InstanceId = /** @class */ (function () {
57
40
  * @constructor
58
41
  */
59
42
  function InstanceId(app) {
60
- this.INTERNAL = new InstanceIdInternals();
61
43
  if (!validator.isNonNullObject(app) || !('options' in app)) {
62
44
  throw new error_1.FirebaseInstanceIdError(error_1.InstanceIdClientErrorCode.INVALID_ARGUMENT, 'First argument passed to admin.instanceId() must be a valid Firebase app instance.');
63
45
  }
@@ -0,0 +1,249 @@
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 machineLearning.MachineLearning `MachineLearning`} service for the
20
+ * default app or a given app.
21
+ *
22
+ * `admin.machineLearning()` can be called with no arguments to access the
23
+ * default app's {@link machineLearning.MachineLearning
24
+ * `MachineLearning`} service or as `admin.machineLearning(app)` to access
25
+ * the {@link machineLearning.MachineLearning `MachineLearning`}
26
+ * service associated with a specific app.
27
+ *
28
+ * @example
29
+ * ```javascript
30
+ * // Get the MachineLearning service for the default app
31
+ * var defaultMachineLearning = admin.machineLearning();
32
+ * ```
33
+ *
34
+ * @example
35
+ * ```javascript
36
+ * // Get the MachineLearning service for a given app
37
+ * var otherMachineLearning = admin.machineLearning(otherApp);
38
+ * ```
39
+ *
40
+ * @param app Optional app whose `MachineLearning` service to
41
+ * return. If not provided, the default `MachineLearning` service
42
+ * will be returned.
43
+ *
44
+ * @return The default `MachineLearning` service if no app is provided or the
45
+ * `MachineLearning` service associated with the provided app.
46
+ */
47
+ export declare function machineLearning(app?: app.App): machineLearning.MachineLearning;
48
+ export declare namespace machineLearning {
49
+ /**
50
+ * Firebase ML Model input objects
51
+ */
52
+ interface ModelOptionsBase {
53
+ displayName?: string;
54
+ tags?: string[];
55
+ }
56
+ interface GcsTfliteModelOptions extends ModelOptionsBase {
57
+ tfliteModel: {
58
+ gcsTfliteUri: string;
59
+ };
60
+ }
61
+ interface AutoMLTfliteModelOptions extends ModelOptionsBase {
62
+ tfliteModel: {
63
+ automlModel: string;
64
+ };
65
+ }
66
+ type ModelOptions = ModelOptionsBase | GcsTfliteModelOptions | AutoMLTfliteModelOptions;
67
+ /**
68
+ * A TensorFlow Lite Model output object
69
+ *
70
+ * One of either the `gcsTfliteUri` or `automlModel` properties will be
71
+ * defined.
72
+ */
73
+ interface TFLiteModel {
74
+ /** The size of the model. */
75
+ readonly sizeBytes: number;
76
+ /** The URI from which the model was originally provided to Firebase. */
77
+ readonly gcsTfliteUri?: string;
78
+ /**
79
+ * The AutoML model reference from which the model was originally provided
80
+ * to Firebase.
81
+ */
82
+ readonly automlModel?: string;
83
+ }
84
+ /**
85
+ * A Firebase ML Model output object
86
+ */
87
+ interface Model {
88
+ /** The ID of the model. */
89
+ readonly modelId: string;
90
+ /**
91
+ * The model's name. This is the name you use from your app to load the
92
+ * model.
93
+ */
94
+ readonly displayName: string;
95
+ /**
96
+ * The model's tags, which can be used to group or filter models in list
97
+ * operations.
98
+ */
99
+ readonly tags?: string[];
100
+ /** The timestamp of the model's creation. */
101
+ readonly createTime: string;
102
+ /** The timestamp of the model's most recent update. */
103
+ readonly updateTime: string;
104
+ /** Error message when model validation fails. */
105
+ readonly validationError?: string;
106
+ /** True if the model is published. */
107
+ readonly published: boolean;
108
+ /**
109
+ * The ETag identifier of the current version of the model. This value
110
+ * changes whenever you update any of the model's properties.
111
+ */
112
+ readonly etag: string;
113
+ /**
114
+ * The hash of the model's `tflite` file. This value changes only when
115
+ * you upload a new TensorFlow Lite model.
116
+ */
117
+ readonly modelHash?: string;
118
+ /**
119
+ * True if the model is locked by a server-side operation. You can't make
120
+ * changes to a locked model. See {@link waitForUnlocked `waitForUnlocked()`}.
121
+ */
122
+ readonly locked: boolean;
123
+ /**
124
+ * Wait for the model to be unlocked.
125
+ *
126
+ * @param {number} maxTimeMillis The maximum time in milliseconds to wait.
127
+ * If not specified, a default maximum of 2 minutes is used.
128
+ *
129
+ * @return {Promise<void>} A promise that resolves when the model is unlocked
130
+ * or the maximum wait time has passed.
131
+ */
132
+ waitForUnlocked(maxTimeMillis?: number): Promise<void>;
133
+ /**
134
+ * Return the model as a JSON object.
135
+ */
136
+ toJSON(): {
137
+ [key: string]: any;
138
+ };
139
+ /** Metadata about the model's TensorFlow Lite model file. */
140
+ readonly tfliteModel?: TFLiteModel;
141
+ }
142
+ /**
143
+ * Interface representing options for listing Models.
144
+ */
145
+ interface ListModelsOptions {
146
+ /**
147
+ * An expression that specifies how to filter the results.
148
+ *
149
+ * Examples:
150
+ *
151
+ * ```
152
+ * display_name = your_model
153
+ * display_name : experimental_*
154
+ * tags: face_detector AND tags: experimental
155
+ * state.published = true
156
+ * ```
157
+ *
158
+ * See https://firebase.google.com/docs/ml/manage-hosted-models#list_your_projects_models
159
+ */
160
+ filter?: string;
161
+ /** The number of results to return in each page. */
162
+ pageSize?: number;
163
+ /** A token that specifies the result page to return. */
164
+ pageToken?: string;
165
+ }
166
+ /** Response object for a listModels operation. */
167
+ interface ListModelsResult {
168
+ /** A list of models in your project. */
169
+ readonly models: Model[];
170
+ /**
171
+ * A token you can use to retrieve the next page of results. If null, the
172
+ * current page is the final page.
173
+ */
174
+ readonly pageToken?: string;
175
+ }
176
+ /**
177
+ * The Firebase `MachineLearning` service interface.
178
+ *
179
+ * Do not call this constructor directly. Instead, use
180
+ * [`admin.machineLearning()`](admin.machineLearning#machineLearning).
181
+ */
182
+ interface MachineLearning {
183
+ /**
184
+ * The {@link app.App} associated with the current `MachineLearning`
185
+ * service instance.
186
+ */
187
+ app: app.App;
188
+ /**
189
+ * Creates a model in the current Firebase project.
190
+ *
191
+ * @param {ModelOptions} model The model to create.
192
+ *
193
+ * @return {Promise<Model>} A Promise fulfilled with the created model.
194
+ */
195
+ createModel(model: ModelOptions): Promise<Model>;
196
+ /**
197
+ * Updates a model's metadata or model file.
198
+ *
199
+ * @param {string} modelId The ID of the model to update.
200
+ * @param {ModelOptions} model The model fields to update.
201
+ *
202
+ * @return {Promise<Model>} A Promise fulfilled with the updated model.
203
+ */
204
+ updateModel(modelId: string, model: ModelOptions): Promise<Model>;
205
+ /**
206
+ * Publishes a Firebase ML model.
207
+ *
208
+ * A published model can be downloaded to client apps.
209
+ *
210
+ * @param {string} modelId The ID of the model to publish.
211
+ *
212
+ * @return {Promise<Model>} A Promise fulfilled with the published model.
213
+ */
214
+ publishModel(modelId: string): Promise<Model>;
215
+ /**
216
+ * Unpublishes a Firebase ML model.
217
+ *
218
+ * @param {string} modelId The ID of the model to unpublish.
219
+ *
220
+ * @return {Promise<Model>} A Promise fulfilled with the unpublished model.
221
+ */
222
+ unpublishModel(modelId: string): Promise<Model>;
223
+ /**
224
+ * Gets the model specified by the given ID.
225
+ *
226
+ * @param {string} modelId The ID of the model to get.
227
+ *
228
+ * @return {Promise<Model>} A Promise fulfilled with the model object.
229
+ */
230
+ getModel(modelId: string): Promise<Model>;
231
+ /**
232
+ * Lists the current project's models.
233
+ *
234
+ * @param {ListModelsOptions} options The listing options.
235
+ *
236
+ * @return {Promise<ListModelsResult>} A promise that
237
+ * resolves with the current (filtered) list of models and the next page
238
+ * token. For the last page, an empty list of models and no page token
239
+ * are returned.
240
+ */
241
+ listModels(options?: ListModelsOptions): Promise<ListModelsResult>;
242
+ /**
243
+ * Deletes a model from the current project.
244
+ *
245
+ * @param {string} modelId The ID of the model to delete.
246
+ */
247
+ deleteModel(modelId: string): Promise<void>;
248
+ }
249
+ }
@@ -1,7 +1,7 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
- * Copyright 2019 Google Inc.
4
+ * Copyright 2020 Google Inc.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -23,24 +23,6 @@ var validator = require("../utils/validator");
23
23
  var machine_learning_utils_1 = require("./machine-learning-utils");
24
24
  var deep_copy_1 = require("../utils/deep-copy");
25
25
  var utils = require("../utils");
26
- /**
27
- * Internals of an ML instance.
28
- */
29
- var MachineLearningInternals = /** @class */ (function () {
30
- function MachineLearningInternals() {
31
- }
32
- /**
33
- * Deletes the service and its associated resources.
34
- *
35
- * @return {Promise<void>} An empty Promise that will be resolved when the
36
- * service is deleted.
37
- */
38
- MachineLearningInternals.prototype.delete = function () {
39
- // There are no resources to clean up.
40
- return Promise.resolve();
41
- };
42
- return MachineLearningInternals;
43
- }());
44
26
  /**
45
27
  * The Firebase Machine Learning class
46
28
  */
@@ -50,7 +32,6 @@ var MachineLearning = /** @class */ (function () {
50
32
  * @constructor
51
33
  */
52
34
  function MachineLearning(app) {
53
- this.INTERNAL = new MachineLearningInternals();
54
35
  if (!validator.isNonNullObject(app) || !('options' in app)) {
55
36
  throw new error_1.FirebaseError({
56
37
  code: 'machine-learning/invalid-argument',
@@ -370,8 +351,8 @@ var Model = /** @class */ (function () {
370
351
  delete tmpModel.tfliteModel;
371
352
  }
372
353
  // Remove '@type' field. We don't need it.
373
- if (tmpModel["@type"]) {
374
- delete tmpModel["@type"];
354
+ if (tmpModel['@type']) {
355
+ delete tmpModel['@type'];
375
356
  }
376
357
  return tmpModel;
377
358
  };
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.3.0 */
1
+ /*! firebase-admin v9.5.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.