firebase-admin 10.1.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/README.md +1 -1
  2. package/lib/app/core.d.ts +1 -1
  3. package/lib/app/core.js +1 -1
  4. package/lib/app/credential-factory.d.ts +1 -1
  5. package/lib/app/credential-factory.js +8 -8
  6. package/lib/app/credential-internal.d.ts +3 -1
  7. package/lib/app/credential-internal.js +103 -95
  8. package/lib/app/credential.d.ts +1 -1
  9. package/lib/app/credential.js +1 -1
  10. package/lib/app/firebase-app.d.ts +1 -1
  11. package/lib/app/firebase-app.js +76 -91
  12. package/lib/app/firebase-namespace.d.ts +1 -1
  13. package/lib/app/firebase-namespace.js +209 -279
  14. package/lib/app/index.d.ts +1 -1
  15. package/lib/app/index.js +4 -4
  16. package/lib/app/lifecycle.d.ts +1 -1
  17. package/lib/app/lifecycle.js +37 -43
  18. package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
  19. package/lib/app-check/app-check-api-client-internal.js +54 -73
  20. package/lib/app-check/app-check-api.d.ts +1 -1
  21. package/lib/app-check/app-check-api.js +1 -1
  22. package/lib/app-check/app-check-namespace.d.ts +1 -1
  23. package/lib/app-check/app-check-namespace.js +1 -1
  24. package/lib/app-check/app-check.d.ts +1 -1
  25. package/lib/app-check/app-check.js +17 -19
  26. package/lib/app-check/index.d.ts +1 -1
  27. package/lib/app-check/index.js +7 -7
  28. package/lib/app-check/token-generator.d.ts +1 -1
  29. package/lib/app-check/token-generator.js +47 -52
  30. package/lib/app-check/token-verifier.d.ts +1 -1
  31. package/lib/app-check/token-verifier.js +46 -50
  32. package/lib/auth/action-code-settings-builder.d.ts +1 -1
  33. package/lib/auth/action-code-settings-builder.js +10 -11
  34. package/lib/auth/auth-api-request.d.ts +1 -1
  35. package/lib/auth/auth-api-request.js +355 -382
  36. package/lib/auth/auth-config.d.ts +1 -1
  37. package/lib/auth/auth-config.js +95 -106
  38. package/lib/auth/auth-namespace.d.ts +1 -1
  39. package/lib/auth/auth-namespace.js +1 -1
  40. package/lib/auth/auth.d.ts +1 -1
  41. package/lib/auth/auth.js +20 -40
  42. package/lib/auth/base-auth.d.ts +26 -1
  43. package/lib/auth/base-auth.js +162 -142
  44. package/lib/auth/identifier.d.ts +1 -1
  45. package/lib/auth/identifier.js +2 -2
  46. package/lib/auth/index.d.ts +1 -1
  47. package/lib/auth/index.js +7 -7
  48. package/lib/auth/tenant-manager.d.ts +1 -1
  49. package/lib/auth/tenant-manager.js +49 -71
  50. package/lib/auth/tenant.d.ts +1 -1
  51. package/lib/auth/tenant.js +44 -55
  52. package/lib/auth/token-generator.d.ts +1 -1
  53. package/lib/auth/token-generator.js +49 -53
  54. package/lib/auth/token-verifier.d.ts +1 -1
  55. package/lib/auth/token-verifier.js +83 -91
  56. package/lib/auth/user-import-builder.d.ts +1 -1
  57. package/lib/auth/user-import-builder.js +70 -73
  58. package/lib/auth/user-record.d.ts +1 -1
  59. package/lib/auth/user-record.js +61 -84
  60. package/lib/credential/index.d.ts +1 -1
  61. package/lib/credential/index.js +2 -2
  62. package/lib/database/database-namespace.d.ts +1 -1
  63. package/lib/database/database-namespace.js +1 -1
  64. package/lib/database/database.d.ts +1 -1
  65. package/lib/database/database.js +92 -108
  66. package/lib/database/index.d.ts +1 -1
  67. package/lib/database/index.js +10 -10
  68. package/lib/default-namespace.d.ts +1 -1
  69. package/lib/default-namespace.js +2 -2
  70. package/lib/esm/eventarc/index.js +5 -0
  71. package/lib/esm/functions/index.js +5 -0
  72. package/lib/eventarc/cloudevent.d.ts +84 -0
  73. package/lib/eventarc/cloudevent.js +19 -0
  74. package/lib/eventarc/eventarc-client-internal.d.ts +18 -0
  75. package/lib/eventarc/eventarc-client-internal.js +139 -0
  76. package/lib/eventarc/eventarc-utils.d.ts +31 -0
  77. package/lib/eventarc/eventarc-utils.js +125 -0
  78. package/lib/eventarc/eventarc.d.ts +107 -0
  79. package/lib/eventarc/eventarc.js +125 -0
  80. package/lib/eventarc/index.d.ts +53 -0
  81. package/lib/eventarc/index.js +64 -0
  82. package/lib/firebase-namespace-api.d.ts +1 -1
  83. package/lib/firebase-namespace-api.js +8 -3
  84. package/lib/firestore/firestore-internal.d.ts +1 -1
  85. package/lib/firestore/firestore-internal.js +28 -37
  86. package/lib/firestore/firestore-namespace.d.ts +9 -1
  87. package/lib/firestore/firestore-namespace.js +2 -2
  88. package/lib/firestore/index.d.ts +2 -2
  89. package/lib/firestore/index.js +7 -7
  90. package/lib/functions/functions-api-client-internal.d.ts +32 -0
  91. package/lib/functions/functions-api-client-internal.js +257 -0
  92. package/lib/functions/functions-api.d.ts +67 -0
  93. package/lib/functions/functions-api.js +19 -0
  94. package/lib/functions/functions.d.ts +63 -0
  95. package/lib/functions/functions.js +97 -0
  96. package/lib/functions/index.d.ts +53 -0
  97. package/lib/functions/index.js +64 -0
  98. package/lib/index.d.ts +1 -1
  99. package/lib/index.js +14 -4
  100. package/lib/installations/index.d.ts +1 -1
  101. package/lib/installations/index.js +6 -6
  102. package/lib/installations/installations-namespace.d.ts +1 -1
  103. package/lib/installations/installations-namespace.js +1 -1
  104. package/lib/installations/installations-request-handler.d.ts +1 -1
  105. package/lib/installations/installations-request-handler.js +33 -36
  106. package/lib/installations/installations.d.ts +1 -1
  107. package/lib/installations/installations.js +17 -22
  108. package/lib/instance-id/index.d.ts +1 -1
  109. package/lib/instance-id/index.js +6 -6
  110. package/lib/instance-id/instance-id-namespace.d.ts +1 -1
  111. package/lib/instance-id/instance-id-namespace.js +1 -1
  112. package/lib/instance-id/instance-id.d.ts +1 -1
  113. package/lib/instance-id/instance-id.js +21 -26
  114. package/lib/machine-learning/index.d.ts +1 -1
  115. package/lib/machine-learning/index.js +7 -7
  116. package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
  117. package/lib/machine-learning/machine-learning-api-client.js +110 -124
  118. package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
  119. package/lib/machine-learning/machine-learning-namespace.js +1 -1
  120. package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
  121. package/lib/machine-learning/machine-learning-utils.js +9 -24
  122. package/lib/machine-learning/machine-learning.d.ts +1 -1
  123. package/lib/machine-learning/machine-learning.js +146 -207
  124. package/lib/messaging/batch-request-internal.d.ts +1 -1
  125. package/lib/messaging/batch-request-internal.js +33 -35
  126. package/lib/messaging/index.d.ts +1 -1
  127. package/lib/messaging/index.js +7 -7
  128. package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
  129. package/lib/messaging/messaging-api-request-internal.js +38 -40
  130. package/lib/messaging/messaging-api.d.ts +1 -1
  131. package/lib/messaging/messaging-api.js +1 -1
  132. package/lib/messaging/messaging-errors-internal.d.ts +1 -1
  133. package/lib/messaging/messaging-errors-internal.js +12 -13
  134. package/lib/messaging/messaging-internal.d.ts +1 -1
  135. package/lib/messaging/messaging-internal.js +51 -51
  136. package/lib/messaging/messaging-namespace.d.ts +1 -1
  137. package/lib/messaging/messaging-namespace.js +1 -1
  138. package/lib/messaging/messaging.d.ts +1 -1
  139. package/lib/messaging/messaging.js +184 -208
  140. package/lib/project-management/android-app.d.ts +1 -1
  141. package/lib/project-management/android-app.js +41 -43
  142. package/lib/project-management/app-metadata.d.ts +1 -1
  143. package/lib/project-management/app-metadata.js +1 -1
  144. package/lib/project-management/index.d.ts +1 -1
  145. package/lib/project-management/index.js +7 -7
  146. package/lib/project-management/ios-app.d.ts +1 -1
  147. package/lib/project-management/ios-app.js +25 -26
  148. package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
  149. package/lib/project-management/project-management-api-request-internal.js +84 -89
  150. package/lib/project-management/project-management-namespace.d.ts +1 -1
  151. package/lib/project-management/project-management-namespace.js +1 -1
  152. package/lib/project-management/project-management.d.ts +1 -1
  153. package/lib/project-management/project-management.js +80 -87
  154. package/lib/remote-config/index.d.ts +1 -1
  155. package/lib/remote-config/index.js +7 -7
  156. package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
  157. package/lib/remote-config/remote-config-api-client-internal.js +116 -154
  158. package/lib/remote-config/remote-config-api.d.ts +1 -1
  159. package/lib/remote-config/remote-config-api.js +1 -1
  160. package/lib/remote-config/remote-config-namespace.d.ts +1 -1
  161. package/lib/remote-config/remote-config-namespace.js +1 -1
  162. package/lib/remote-config/remote-config.d.ts +1 -1
  163. package/lib/remote-config/remote-config.js +51 -59
  164. package/lib/security-rules/index.d.ts +1 -1
  165. package/lib/security-rules/index.js +7 -7
  166. package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
  167. package/lib/security-rules/security-rules-api-client-internal.js +95 -107
  168. package/lib/security-rules/security-rules-internal.d.ts +1 -1
  169. package/lib/security-rules/security-rules-internal.js +6 -21
  170. package/lib/security-rules/security-rules-namespace.d.ts +1 -1
  171. package/lib/security-rules/security-rules-namespace.js +1 -1
  172. package/lib/security-rules/security-rules.d.ts +1 -1
  173. package/lib/security-rules/security-rules.js +82 -91
  174. package/lib/storage/index.d.ts +1 -1
  175. package/lib/storage/index.js +7 -7
  176. package/lib/storage/storage-namespace.d.ts +1 -1
  177. package/lib/storage/storage-namespace.js +1 -1
  178. package/lib/storage/storage.d.ts +1 -1
  179. package/lib/storage/storage.js +25 -30
  180. package/lib/utils/api-request.d.ts +3 -1
  181. package/lib/utils/api-request.js +278 -356
  182. package/lib/utils/crypto-signer.d.ts +1 -1
  183. package/lib/utils/crypto-signer.js +58 -93
  184. package/lib/utils/deep-copy.d.ts +1 -1
  185. package/lib/utils/deep-copy.js +3 -3
  186. package/lib/utils/error.d.ts +5 -1
  187. package/lib/utils/error.js +613 -677
  188. package/lib/utils/index.d.ts +43 -1
  189. package/lib/utils/index.js +99 -34
  190. package/lib/utils/jwt.d.ts +1 -1
  191. package/lib/utils/jwt.js +97 -123
  192. package/lib/utils/validator.d.ts +1 -1
  193. package/lib/utils/validator.js +13 -13
  194. package/package.json +43 -11
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -17,18 +17,18 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.RemoteConfig = void 0;
20
- var validator = require("../utils/validator");
21
- var remote_config_api_client_internal_1 = require("./remote-config-api-client-internal");
20
+ const validator = require("../utils/validator");
21
+ const remote_config_api_client_internal_1 = require("./remote-config-api-client-internal");
22
22
  /**
23
23
  * The Firebase `RemoteConfig` service interface.
24
24
  */
25
- var RemoteConfig = /** @class */ (function () {
25
+ class RemoteConfig {
26
26
  /**
27
27
  * @param app - The app for this RemoteConfig service.
28
28
  * @constructor
29
29
  * @internal
30
30
  */
31
- function RemoteConfig(app) {
31
+ constructor(app) {
32
32
  this.app = app;
33
33
  this.client = new remote_config_api_client_internal_1.RemoteConfigApiClient(app);
34
34
  }
@@ -37,12 +37,12 @@ var RemoteConfig = /** @class */ (function () {
37
37
  *
38
38
  * @returns A promise that fulfills with a `RemoteConfigTemplate`.
39
39
  */
40
- RemoteConfig.prototype.getTemplate = function () {
40
+ getTemplate() {
41
41
  return this.client.getTemplate()
42
- .then(function (templateResponse) {
42
+ .then((templateResponse) => {
43
43
  return new RemoteConfigTemplateImpl(templateResponse);
44
44
  });
45
- };
45
+ }
46
46
  /**
47
47
  * Gets the requested version of the {@link RemoteConfigTemplate} of the project.
48
48
  *
@@ -50,24 +50,24 @@ var RemoteConfig = /** @class */ (function () {
50
50
  *
51
51
  * @returns A promise that fulfills with a `RemoteConfigTemplate`.
52
52
  */
53
- RemoteConfig.prototype.getTemplateAtVersion = function (versionNumber) {
53
+ getTemplateAtVersion(versionNumber) {
54
54
  return this.client.getTemplateAtVersion(versionNumber)
55
- .then(function (templateResponse) {
55
+ .then((templateResponse) => {
56
56
  return new RemoteConfigTemplateImpl(templateResponse);
57
57
  });
58
- };
58
+ }
59
59
  /**
60
60
  * Validates a {@link RemoteConfigTemplate}.
61
61
  *
62
62
  * @param template - The Remote Config template to be validated.
63
63
  * @returns A promise that fulfills with the validated `RemoteConfigTemplate`.
64
64
  */
65
- RemoteConfig.prototype.validateTemplate = function (template) {
65
+ validateTemplate(template) {
66
66
  return this.client.validateTemplate(template)
67
- .then(function (templateResponse) {
67
+ .then((templateResponse) => {
68
68
  return new RemoteConfigTemplateImpl(templateResponse);
69
69
  });
70
- };
70
+ }
71
71
  /**
72
72
  * Publishes a Remote Config template.
73
73
  *
@@ -82,12 +82,12 @@ var RemoteConfig = /** @class */ (function () {
82
82
  *
83
83
  * @returns A Promise that fulfills with the published `RemoteConfigTemplate`.
84
84
  */
85
- RemoteConfig.prototype.publishTemplate = function (template, options) {
85
+ publishTemplate(template, options) {
86
86
  return this.client.publishTemplate(template, options)
87
- .then(function (templateResponse) {
87
+ .then((templateResponse) => {
88
88
  return new RemoteConfigTemplateImpl(templateResponse);
89
89
  });
90
- };
90
+ }
91
91
  /**
92
92
  * Rolls back a project's published Remote Config template to the specified version.
93
93
  * A rollback is equivalent to getting a previously published Remote Config
@@ -100,12 +100,12 @@ var RemoteConfig = /** @class */ (function () {
100
100
  * template that is being fetched by clients) are also deleted if they are more than 90 days old.
101
101
  * @returns A promise that fulfills with the published `RemoteConfigTemplate`.
102
102
  */
103
- RemoteConfig.prototype.rollback = function (versionNumber) {
103
+ rollback(versionNumber) {
104
104
  return this.client.rollback(versionNumber)
105
- .then(function (templateResponse) {
105
+ .then((templateResponse) => {
106
106
  return new RemoteConfigTemplateImpl(templateResponse);
107
107
  });
108
- };
108
+ }
109
109
  /**
110
110
  * Gets a list of Remote Config template versions that have been published, sorted in reverse
111
111
  * chronological order. Only the last 300 versions are stored.
@@ -115,16 +115,15 @@ var RemoteConfig = /** @class */ (function () {
115
115
  * @param options - Optional options object for getting a list of versions.
116
116
  * @returns A promise that fulfills with a `ListVersionsResult`.
117
117
  */
118
- RemoteConfig.prototype.listVersions = function (options) {
118
+ listVersions(options) {
119
119
  return this.client.listVersions(options)
120
- .then(function (listVersionsResponse) {
121
- var _a, _b;
120
+ .then((listVersionsResponse) => {
122
121
  return {
123
- versions: (_b = (_a = listVersionsResponse.versions) === null || _a === void 0 ? void 0 : _a.map(function (version) { return new VersionImpl(version); })) !== null && _b !== void 0 ? _b : [],
122
+ versions: listVersionsResponse.versions?.map(version => new VersionImpl(version)) ?? [],
124
123
  nextPageToken: listVersionsResponse.nextPageToken,
125
124
  };
126
125
  });
127
- };
126
+ }
128
127
  /**
129
128
  * Creates and returns a new Remote Config template from a JSON string.
130
129
  *
@@ -132,30 +131,29 @@ var RemoteConfig = /** @class */ (function () {
132
131
  *
133
132
  * @returns A new template instance.
134
133
  */
135
- RemoteConfig.prototype.createTemplateFromJSON = function (json) {
134
+ createTemplateFromJSON(json) {
136
135
  if (!validator.isNonEmptyString(json)) {
137
136
  throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'JSON string must be a valid non-empty string');
138
137
  }
139
- var template;
138
+ let template;
140
139
  try {
141
140
  template = JSON.parse(json);
142
141
  }
143
142
  catch (e) {
144
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', "Failed to parse the JSON string: " + json + ". " + e);
143
+ throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Failed to parse the JSON string: ${json}. ` + e);
145
144
  }
146
145
  return new RemoteConfigTemplateImpl(template);
147
- };
148
- return RemoteConfig;
149
- }());
146
+ }
147
+ }
150
148
  exports.RemoteConfig = RemoteConfig;
151
149
  /**
152
150
  * Remote Config template internal implementation.
153
151
  */
154
- var RemoteConfigTemplateImpl = /** @class */ (function () {
155
- function RemoteConfigTemplateImpl(config) {
152
+ class RemoteConfigTemplateImpl {
153
+ constructor(config) {
156
154
  if (!validator.isNonNullObject(config) ||
157
155
  !validator.isNonEmptyString(config.etag)) {
158
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', "Invalid Remote Config template: " + JSON.stringify(config));
156
+ throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Invalid Remote Config template: ${JSON.stringify(config)}`);
159
157
  }
160
158
  this.etagInternal = config.etag;
161
159
  if (typeof config.parameters !== 'undefined') {
@@ -189,24 +187,20 @@ var RemoteConfigTemplateImpl = /** @class */ (function () {
189
187
  this.version = new VersionImpl(config.version);
190
188
  }
191
189
  }
192
- Object.defineProperty(RemoteConfigTemplateImpl.prototype, "etag", {
193
- /**
194
- * Gets the ETag of the template.
195
- *
196
- * @returns The ETag of the Remote Config template.
197
- */
198
- get: function () {
199
- return this.etagInternal;
200
- },
201
- enumerable: false,
202
- configurable: true
203
- });
190
+ /**
191
+ * Gets the ETag of the template.
192
+ *
193
+ * @returns The ETag of the Remote Config template.
194
+ */
195
+ get etag() {
196
+ return this.etagInternal;
197
+ }
204
198
  /**
205
199
  * Returns a JSON-serializable representation of this object.
206
200
  *
207
201
  * @returns A JSON-serializable representation of this object.
208
202
  */
209
- RemoteConfigTemplateImpl.prototype.toJSON = function () {
203
+ toJSON() {
210
204
  return {
211
205
  conditions: this.conditions,
212
206
  parameters: this.parameters,
@@ -214,16 +208,15 @@ var RemoteConfigTemplateImpl = /** @class */ (function () {
214
208
  etag: this.etag,
215
209
  version: this.version,
216
210
  };
217
- };
218
- return RemoteConfigTemplateImpl;
219
- }());
211
+ }
212
+ }
220
213
  /**
221
214
  * Remote Config Version internal implementation.
222
215
  */
223
- var VersionImpl = /** @class */ (function () {
224
- function VersionImpl(version) {
216
+ class VersionImpl {
217
+ constructor(version) {
225
218
  if (!validator.isNonNullObject(version)) {
226
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', "Invalid Remote Config version instance: " + JSON.stringify(version));
219
+ throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Invalid Remote Config version instance: ${JSON.stringify(version)}`);
227
220
  }
228
221
  if (typeof version.versionNumber !== 'undefined') {
229
222
  if (!validator.isNonEmptyString(version.versionNumber) &&
@@ -284,7 +277,7 @@ var VersionImpl = /** @class */ (function () {
284
277
  /**
285
278
  * @returns A JSON-serializable representation of this object.
286
279
  */
287
- VersionImpl.prototype.toJSON = function () {
280
+ toJSON() {
288
281
  return {
289
282
  versionNumber: this.versionNumber,
290
283
  updateOrigin: this.updateOrigin,
@@ -295,11 +288,10 @@ var VersionImpl = /** @class */ (function () {
295
288
  isLegacy: this.isLegacy,
296
289
  updateTime: this.updateTime,
297
290
  };
298
- };
299
- VersionImpl.prototype.isValidTimestamp = function (timestamp) {
291
+ }
292
+ isValidTimestamp(timestamp) {
300
293
  // This validation fails for timestamps earlier than January 1, 1970 and considers strings
301
294
  // such as "1.2" as valid timestamps.
302
295
  return validator.isNonEmptyString(timestamp) && (new Date(timestamp)).getTime() > 0;
303
- };
304
- return VersionImpl;
305
- }());
296
+ }
297
+ }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -16,14 +16,14 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.getSecurityRules = void 0;
19
+ exports.getSecurityRules = exports.SecurityRules = exports.RulesetMetadataList = exports.Ruleset = void 0;
20
20
  /**
21
21
  * Security Rules for Cloud Firestore and Cloud Storage.
22
22
  *
23
23
  * @packageDocumentation
24
24
  */
25
- var app_1 = require("../app");
26
- var security_rules_1 = require("./security-rules");
25
+ const app_1 = require("../app");
26
+ const security_rules_1 = require("./security-rules");
27
27
  var security_rules_2 = require("./security-rules");
28
28
  Object.defineProperty(exports, "Ruleset", { enumerable: true, get: function () { return security_rules_2.Ruleset; } });
29
29
  Object.defineProperty(exports, "RulesetMetadataList", { enumerable: true, get: function () { return security_rules_2.RulesetMetadataList; } });
@@ -55,9 +55,9 @@ Object.defineProperty(exports, "SecurityRules", { enumerable: true, get: functio
55
55
  */
56
56
  function getSecurityRules(app) {
57
57
  if (typeof app === 'undefined') {
58
- app = app_1.getApp();
58
+ app = (0, app_1.getApp)();
59
59
  }
60
- var firebaseApp = app;
61
- return firebaseApp.getOrInitService('securityRules', function (app) { return new security_rules_1.SecurityRules(app); });
60
+ const firebaseApp = app;
61
+ return firebaseApp.getOrInitService('securityRules', (app) => new security_rules_1.SecurityRules(app));
62
62
  }
63
63
  exports.getSecurityRules = getSecurityRules;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -17,22 +17,22 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.SecurityRulesApiClient = void 0;
20
- var api_request_1 = require("../utils/api-request");
21
- var error_1 = require("../utils/error");
22
- var security_rules_internal_1 = require("./security-rules-internal");
23
- var utils = require("../utils/index");
24
- var validator = require("../utils/validator");
25
- var RULES_V1_API = 'https://firebaserules.googleapis.com/v1';
26
- var FIREBASE_VERSION_HEADER = {
27
- 'X-Firebase-Client': "fire-admin-node/" + utils.getSdkVersion(),
20
+ const api_request_1 = require("../utils/api-request");
21
+ const error_1 = require("../utils/error");
22
+ const security_rules_internal_1 = require("./security-rules-internal");
23
+ const utils = require("../utils/index");
24
+ const validator = require("../utils/validator");
25
+ const RULES_V1_API = 'https://firebaserules.googleapis.com/v1';
26
+ const FIREBASE_VERSION_HEADER = {
27
+ 'X-Firebase-Client': `fire-admin-node/${utils.getSdkVersion()}`,
28
28
  };
29
29
  /**
30
30
  * Class that facilitates sending requests to the Firebase security rules backend API.
31
31
  *
32
32
  * @private
33
33
  */
34
- var SecurityRulesApiClient = /** @class */ (function () {
35
- function SecurityRulesApiClient(app) {
34
+ class SecurityRulesApiClient {
35
+ constructor(app) {
36
36
  this.app = app;
37
37
  if (!validator.isNonNullObject(app) || !('options' in app)) {
38
38
  throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'First argument passed to admin.securityRules() must be a valid Firebase app '
@@ -40,127 +40,119 @@ var SecurityRulesApiClient = /** @class */ (function () {
40
40
  }
41
41
  this.httpClient = new api_request_1.AuthorizedHttpClient(app);
42
42
  }
43
- SecurityRulesApiClient.prototype.getRuleset = function (name) {
44
- var _this = this;
43
+ getRuleset(name) {
45
44
  return Promise.resolve()
46
- .then(function () {
47
- return _this.getRulesetName(name);
45
+ .then(() => {
46
+ return this.getRulesetName(name);
48
47
  })
49
- .then(function (rulesetName) {
50
- return _this.getResource(rulesetName);
48
+ .then((rulesetName) => {
49
+ return this.getResource(rulesetName);
51
50
  });
52
- };
53
- SecurityRulesApiClient.prototype.createRuleset = function (ruleset) {
54
- var _this = this;
51
+ }
52
+ createRuleset(ruleset) {
55
53
  if (!validator.isNonNullObject(ruleset) ||
56
54
  !validator.isNonNullObject(ruleset.source) ||
57
55
  !validator.isNonEmptyArray(ruleset.source.files)) {
58
- var err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Invalid rules content.');
56
+ const err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Invalid rules content.');
59
57
  return Promise.reject(err);
60
58
  }
61
- for (var _i = 0, _a = ruleset.source.files; _i < _a.length; _i++) {
62
- var rf = _a[_i];
59
+ for (const rf of ruleset.source.files) {
63
60
  if (!validator.isNonNullObject(rf) ||
64
61
  !validator.isNonEmptyString(rf.name) ||
65
62
  !validator.isNonEmptyString(rf.content)) {
66
- var err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', "Invalid rules file argument: " + JSON.stringify(rf));
63
+ const err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', `Invalid rules file argument: ${JSON.stringify(rf)}`);
67
64
  return Promise.reject(err);
68
65
  }
69
66
  }
70
67
  return this.getUrl()
71
- .then(function (url) {
72
- var request = {
68
+ .then((url) => {
69
+ const request = {
73
70
  method: 'POST',
74
- url: url + "/rulesets",
71
+ url: `${url}/rulesets`,
75
72
  data: ruleset,
76
73
  };
77
- return _this.sendRequest(request);
74
+ return this.sendRequest(request);
78
75
  });
79
- };
80
- SecurityRulesApiClient.prototype.deleteRuleset = function (name) {
81
- var _this = this;
76
+ }
77
+ deleteRuleset(name) {
82
78
  return this.getUrl()
83
- .then(function (url) {
84
- var rulesetName = _this.getRulesetName(name);
85
- var request = {
79
+ .then((url) => {
80
+ const rulesetName = this.getRulesetName(name);
81
+ const request = {
86
82
  method: 'DELETE',
87
- url: url + "/" + rulesetName,
83
+ url: `${url}/${rulesetName}`,
88
84
  };
89
- return _this.sendRequest(request);
85
+ return this.sendRequest(request);
90
86
  });
91
- };
92
- SecurityRulesApiClient.prototype.listRulesets = function (pageSize, pageToken) {
93
- var _this = this;
94
- if (pageSize === void 0) { pageSize = 100; }
87
+ }
88
+ listRulesets(pageSize = 100, pageToken) {
95
89
  if (!validator.isNumber(pageSize)) {
96
- var err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Invalid page size.');
90
+ const err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Invalid page size.');
97
91
  return Promise.reject(err);
98
92
  }
99
93
  if (pageSize < 1 || pageSize > 100) {
100
- var err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Page size must be between 1 and 100.');
94
+ const err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Page size must be between 1 and 100.');
101
95
  return Promise.reject(err);
102
96
  }
103
97
  if (typeof pageToken !== 'undefined' && !validator.isNonEmptyString(pageToken)) {
104
- var err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Next page token must be a non-empty string.');
98
+ const err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Next page token must be a non-empty string.');
105
99
  return Promise.reject(err);
106
100
  }
107
- var data = {
108
- pageSize: pageSize,
109
- pageToken: pageToken,
101
+ const data = {
102
+ pageSize,
103
+ pageToken,
110
104
  };
111
105
  if (!pageToken) {
112
106
  delete data.pageToken;
113
107
  }
114
108
  return this.getUrl()
115
- .then(function (url) {
116
- var request = {
109
+ .then((url) => {
110
+ const request = {
117
111
  method: 'GET',
118
- url: url + "/rulesets",
119
- data: data,
112
+ url: `${url}/rulesets`,
113
+ data,
120
114
  };
121
- return _this.sendRequest(request);
115
+ return this.sendRequest(request);
122
116
  });
123
- };
124
- SecurityRulesApiClient.prototype.getRelease = function (name) {
125
- return this.getResource("releases/" + name);
126
- };
127
- SecurityRulesApiClient.prototype.updateRelease = function (name, rulesetName) {
128
- var _this = this;
117
+ }
118
+ getRelease(name) {
119
+ return this.getResource(`releases/${name}`);
120
+ }
121
+ updateRelease(name, rulesetName) {
129
122
  return this.getUrl()
130
- .then(function (url) {
131
- return _this.getReleaseDescription(name, rulesetName)
132
- .then(function (release) {
133
- var request = {
123
+ .then((url) => {
124
+ return this.getReleaseDescription(name, rulesetName)
125
+ .then((release) => {
126
+ const request = {
134
127
  method: 'PATCH',
135
- url: url + "/releases/" + name,
136
- data: { release: release },
128
+ url: `${url}/releases/${name}`,
129
+ data: { release },
137
130
  };
138
- return _this.sendRequest(request);
131
+ return this.sendRequest(request);
139
132
  });
140
133
  });
141
- };
142
- SecurityRulesApiClient.prototype.getUrl = function () {
134
+ }
135
+ getUrl() {
143
136
  return this.getProjectIdPrefix()
144
- .then(function (projectIdPrefix) {
145
- return RULES_V1_API + "/" + projectIdPrefix;
137
+ .then((projectIdPrefix) => {
138
+ return `${RULES_V1_API}/${projectIdPrefix}`;
146
139
  });
147
- };
148
- SecurityRulesApiClient.prototype.getProjectIdPrefix = function () {
149
- var _this = this;
140
+ }
141
+ getProjectIdPrefix() {
150
142
  if (this.projectIdPrefix) {
151
143
  return Promise.resolve(this.projectIdPrefix);
152
144
  }
153
145
  return utils.findProjectId(this.app)
154
- .then(function (projectId) {
146
+ .then((projectId) => {
155
147
  if (!validator.isNonEmptyString(projectId)) {
156
148
  throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Failed to determine project ID. Initialize the SDK with service account credentials, or '
157
149
  + 'set project ID as an app option. Alternatively, set the GOOGLE_CLOUD_PROJECT '
158
150
  + 'environment variable.');
159
151
  }
160
- _this.projectIdPrefix = "projects/" + projectId;
161
- return _this.projectIdPrefix;
152
+ this.projectIdPrefix = `projects/${projectId}`;
153
+ return this.projectIdPrefix;
162
154
  });
163
- };
155
+ }
164
156
  /**
165
157
  * Gets the specified resource from the rules API. Resource names must be the short names without project
166
158
  * ID prefix (e.g. `rulesets/ruleset-name`).
@@ -168,67 +160,63 @@ var SecurityRulesApiClient = /** @class */ (function () {
168
160
  * @param {string} name Full qualified name of the resource to get.
169
161
  * @returns {Promise<T>} A promise that fulfills with the resource.
170
162
  */
171
- SecurityRulesApiClient.prototype.getResource = function (name) {
172
- var _this = this;
163
+ getResource(name) {
173
164
  return this.getUrl()
174
- .then(function (url) {
175
- var request = {
165
+ .then((url) => {
166
+ const request = {
176
167
  method: 'GET',
177
- url: url + "/" + name,
168
+ url: `${url}/${name}`,
178
169
  };
179
- return _this.sendRequest(request);
170
+ return this.sendRequest(request);
180
171
  });
181
- };
182
- SecurityRulesApiClient.prototype.getReleaseDescription = function (name, rulesetName) {
183
- var _this = this;
172
+ }
173
+ getReleaseDescription(name, rulesetName) {
184
174
  return this.getProjectIdPrefix()
185
- .then(function (projectIdPrefix) {
175
+ .then((projectIdPrefix) => {
186
176
  return {
187
- name: projectIdPrefix + "/releases/" + name,
188
- rulesetName: projectIdPrefix + "/" + _this.getRulesetName(rulesetName),
177
+ name: `${projectIdPrefix}/releases/${name}`,
178
+ rulesetName: `${projectIdPrefix}/${this.getRulesetName(rulesetName)}`,
189
179
  };
190
180
  });
191
- };
192
- SecurityRulesApiClient.prototype.getRulesetName = function (name) {
181
+ }
182
+ getRulesetName(name) {
193
183
  if (!validator.isNonEmptyString(name)) {
194
184
  throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Ruleset name must be a non-empty string.');
195
185
  }
196
186
  if (name.indexOf('/') !== -1) {
197
187
  throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Ruleset name must not contain any "/" characters.');
198
188
  }
199
- return "rulesets/" + name;
200
- };
201
- SecurityRulesApiClient.prototype.sendRequest = function (request) {
202
- var _this = this;
189
+ return `rulesets/${name}`;
190
+ }
191
+ sendRequest(request) {
203
192
  request.headers = FIREBASE_VERSION_HEADER;
204
193
  return this.httpClient.send(request)
205
- .then(function (resp) {
194
+ .then((resp) => {
206
195
  return resp.data;
207
196
  })
208
- .catch(function (err) {
209
- throw _this.toFirebaseError(err);
197
+ .catch((err) => {
198
+ throw this.toFirebaseError(err);
210
199
  });
211
- };
212
- SecurityRulesApiClient.prototype.toFirebaseError = function (err) {
200
+ }
201
+ toFirebaseError(err) {
213
202
  if (err instanceof error_1.PrefixedFirebaseError) {
214
203
  return err;
215
204
  }
216
- var response = err.response;
205
+ const response = err.response;
217
206
  if (!response.isJson()) {
218
- return new security_rules_internal_1.FirebaseSecurityRulesError('unknown-error', "Unexpected response with status: " + response.status + " and body: " + response.text);
207
+ return new security_rules_internal_1.FirebaseSecurityRulesError('unknown-error', `Unexpected response with status: ${response.status} and body: ${response.text}`);
219
208
  }
220
- var error = response.data.error || {};
221
- var code = 'unknown-error';
209
+ const error = response.data.error || {};
210
+ let code = 'unknown-error';
222
211
  if (error.status && error.status in ERROR_CODE_MAPPING) {
223
212
  code = ERROR_CODE_MAPPING[error.status];
224
213
  }
225
- var message = error.message || "Unknown server error: " + response.text;
214
+ const message = error.message || `Unknown server error: ${response.text}`;
226
215
  return new security_rules_internal_1.FirebaseSecurityRulesError(code, message);
227
- };
228
- return SecurityRulesApiClient;
229
- }());
216
+ }
217
+ }
230
218
  exports.SecurityRulesApiClient = SecurityRulesApiClient;
231
- var ERROR_CODE_MAPPING = {
219
+ const ERROR_CODE_MAPPING = {
232
220
  INVALID_ARGUMENT: 'invalid-argument',
233
221
  NOT_FOUND: 'not-found',
234
222
  RESOURCE_EXHAUSTED: 'resource-exhausted',
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.1.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -15,27 +15,12 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- var __extends = (this && this.__extends) || (function () {
19
- var extendStatics = function (d, b) {
20
- extendStatics = Object.setPrototypeOf ||
21
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
23
- return extendStatics(d, b);
24
- };
25
- return function (d, b) {
26
- extendStatics(d, b);
27
- function __() { this.constructor = d; }
28
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29
- };
30
- })();
31
18
  Object.defineProperty(exports, "__esModule", { value: true });
32
19
  exports.FirebaseSecurityRulesError = void 0;
33
- var error_1 = require("../utils/error");
34
- var FirebaseSecurityRulesError = /** @class */ (function (_super) {
35
- __extends(FirebaseSecurityRulesError, _super);
36
- function FirebaseSecurityRulesError(code, message) {
37
- return _super.call(this, 'security-rules', code, message) || this;
20
+ const error_1 = require("../utils/error");
21
+ class FirebaseSecurityRulesError extends error_1.PrefixedFirebaseError {
22
+ constructor(code, message) {
23
+ super('security-rules', code, message);
38
24
  }
39
- return FirebaseSecurityRulesError;
40
- }(error_1.PrefixedFirebaseError));
25
+ }
41
26
  exports.FirebaseSecurityRulesError = FirebaseSecurityRulesError;