firebase-admin 9.12.0 → 10.0.1

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 (189) hide show
  1. package/README.md +7 -3
  2. package/lib/app/core.d.ts +188 -0
  3. package/lib/app/core.js +19 -0
  4. package/lib/app/credential-factory.d.ts +123 -0
  5. package/lib/app/credential-factory.js +150 -0
  6. package/lib/app/credential-internal.d.ts +90 -0
  7. package/lib/{credential → app}/credential-internal.js +15 -13
  8. package/lib/app/credential.d.ts +45 -0
  9. package/lib/app/credential.js +19 -0
  10. package/lib/app/firebase-app.d.ts +51 -0
  11. package/lib/{firebase-app.js → app/firebase-app.js} +26 -156
  12. package/lib/app/firebase-namespace.d.ts +163 -0
  13. package/lib/{firebase-namespace.js → app/firebase-namespace.js} +99 -111
  14. package/lib/app/index.d.ts +27 -0
  15. package/lib/app/index.js +31 -0
  16. package/lib/app/lifecycle.d.ts +60 -0
  17. package/lib/app/lifecycle.js +165 -0
  18. package/lib/app-check/app-check-api-client-internal.d.ts +32 -0
  19. package/lib/app-check/app-check-api-client-internal.js +10 -10
  20. package/lib/app-check/app-check-api.d.ts +95 -0
  21. package/lib/app-check/app-check-api.js +19 -0
  22. package/lib/app-check/app-check-namespace.d.ts +65 -0
  23. package/lib/app-check/app-check-namespace.js +18 -0
  24. package/lib/app-check/app-check.d.ts +49 -0
  25. package/lib/app-check/app-check.js +13 -10
  26. package/lib/app-check/index.d.ts +19 -126
  27. package/lib/app-check/index.js +45 -1
  28. package/lib/app-check/token-generator.d.ts +25 -0
  29. package/lib/app-check/token-generator.js +9 -9
  30. package/lib/app-check/token-verifier.d.ts +17 -0
  31. package/lib/app-check/token-verifier.js +6 -6
  32. package/lib/auth/action-code-settings-builder.d.ts +87 -0
  33. package/lib/auth/action-code-settings-builder.js +4 -2
  34. package/lib/auth/auth-api-request.d.ts +174 -0
  35. package/lib/auth/auth-api-request.js +202 -127
  36. package/lib/auth/auth-config.d.ts +575 -0
  37. package/lib/auth/auth-config.js +43 -34
  38. package/lib/auth/auth-namespace.d.ts +255 -0
  39. package/lib/auth/auth-namespace.js +18 -0
  40. package/lib/auth/auth.d.ts +40 -0
  41. package/lib/auth/auth.js +12 -772
  42. package/lib/auth/base-auth.d.ts +613 -0
  43. package/lib/auth/base-auth.js +951 -0
  44. package/lib/auth/identifier.d.ts +57 -0
  45. package/lib/auth/identifier.js +1 -1
  46. package/lib/auth/index.d.ts +25 -1897
  47. package/lib/auth/index.js +54 -1
  48. package/lib/auth/tenant-manager.d.ts +146 -0
  49. package/lib/auth/tenant-manager.js +151 -39
  50. package/lib/auth/tenant.d.ts +130 -0
  51. package/lib/auth/tenant.js +62 -16
  52. package/lib/auth/token-generator.d.ts +44 -0
  53. package/lib/auth/token-generator.js +11 -9
  54. package/lib/auth/token-verifier.d.ts +150 -0
  55. package/lib/auth/token-verifier.js +27 -15
  56. package/lib/auth/user-import-builder.d.ts +322 -0
  57. package/lib/auth/user-import-builder.js +9 -9
  58. package/lib/auth/user-record.d.ts +265 -0
  59. package/lib/auth/user-record.js +80 -45
  60. package/lib/credential/index.d.ts +24 -66
  61. package/lib/credential/index.js +101 -1
  62. package/lib/database/database-namespace.d.ts +95 -0
  63. package/lib/database/database-namespace.js +23 -0
  64. package/lib/database/database.d.ts +66 -0
  65. package/lib/database/{database-internal.js → database.js} +16 -9
  66. package/lib/database/index.d.ts +55 -54
  67. package/lib/database/index.js +84 -13
  68. package/lib/{firebase-namespace.d.ts → default-namespace.d.ts} +7 -14
  69. package/lib/default-namespace.js +4 -5
  70. package/lib/esm/app/index.js +10 -0
  71. package/lib/esm/app-check/index.js +4 -0
  72. package/lib/esm/auth/index.js +14 -0
  73. package/lib/esm/database/index.js +6 -0
  74. package/lib/esm/firestore/index.js +24 -0
  75. package/lib/esm/installations/index.js +4 -0
  76. package/lib/esm/instance-id/index.js +4 -0
  77. package/lib/esm/machine-learning/index.js +5 -0
  78. package/lib/esm/messaging/index.js +4 -0
  79. package/lib/esm/package.json +1 -0
  80. package/lib/esm/project-management/index.js +8 -0
  81. package/lib/esm/remote-config/index.js +4 -0
  82. package/lib/esm/security-rules/index.js +6 -0
  83. package/lib/esm/storage/index.js +4 -0
  84. package/lib/firebase-namespace-api.d.ts +34 -186
  85. package/lib/firebase-namespace-api.js +37 -2
  86. package/lib/firestore/firestore-internal.d.ts +32 -0
  87. package/lib/firestore/firestore-internal.js +3 -3
  88. package/lib/firestore/firestore-namespace.d.ts +55 -0
  89. package/lib/firestore/firestore-namespace.js +48 -0
  90. package/lib/firestore/index.d.ts +37 -35
  91. package/lib/firestore/index.js +62 -30
  92. package/lib/index.d.ts +2 -2
  93. package/lib/index.js +1 -1
  94. package/lib/installations/index.d.ts +34 -63
  95. package/lib/installations/index.js +45 -1
  96. package/lib/installations/installations-namespace.d.ts +55 -0
  97. package/lib/installations/installations-namespace.js +18 -0
  98. package/lib/installations/installations-request-handler.d.ts +43 -0
  99. package/lib/installations/installations-request-handler.js +4 -4
  100. package/lib/installations/installations.d.ts +38 -0
  101. package/lib/installations/installations.js +6 -5
  102. package/lib/instance-id/index.d.ts +23 -45
  103. package/lib/instance-id/index.js +54 -1
  104. package/lib/instance-id/instance-id-namespace.d.ts +38 -0
  105. package/lib/instance-id/instance-id-namespace.js +3 -0
  106. package/lib/instance-id/instance-id.d.ts +47 -0
  107. package/lib/instance-id/instance-id.js +14 -19
  108. package/lib/machine-learning/index.d.ts +19 -216
  109. package/lib/machine-learning/index.js +46 -1
  110. package/lib/machine-learning/machine-learning-api-client.d.ts +102 -0
  111. package/lib/machine-learning/machine-learning-api-client.js +6 -6
  112. package/lib/machine-learning/machine-learning-namespace.d.ts +85 -0
  113. package/lib/machine-learning/machine-learning-namespace.js +18 -0
  114. package/lib/machine-learning/machine-learning-utils.d.ts +22 -0
  115. package/lib/machine-learning/machine-learning-utils.js +1 -1
  116. package/lib/machine-learning/machine-learning.d.ts +181 -0
  117. package/lib/machine-learning/machine-learning.js +72 -37
  118. package/lib/messaging/batch-request-internal.d.ts +55 -0
  119. package/lib/messaging/batch-request-internal.js +9 -9
  120. package/lib/messaging/index.d.ts +18 -1140
  121. package/lib/messaging/index.js +45 -1
  122. package/lib/messaging/messaging-api-request-internal.d.ts +50 -0
  123. package/lib/messaging/messaging-api-request-internal.js +8 -8
  124. package/lib/messaging/messaging-api.d.ts +980 -0
  125. package/lib/messaging/messaging-api.js +19 -0
  126. package/lib/messaging/messaging-errors-internal.d.ts +31 -0
  127. package/lib/messaging/messaging-errors-internal.js +7 -7
  128. package/lib/messaging/messaging-internal.d.ts +27 -0
  129. package/lib/messaging/messaging-internal.js +2 -2
  130. package/lib/messaging/messaging-namespace.d.ts +181 -0
  131. package/lib/messaging/messaging-namespace.js +18 -0
  132. package/lib/messaging/messaging.d.ts +269 -0
  133. package/lib/messaging/messaging.js +83 -91
  134. package/lib/project-management/android-app.d.ts +110 -0
  135. package/lib/project-management/android-app.js +24 -15
  136. package/lib/project-management/app-metadata.d.ts +85 -0
  137. package/lib/project-management/app-metadata.js +37 -0
  138. package/lib/project-management/index.d.ts +21 -331
  139. package/lib/project-management/index.js +51 -24
  140. package/lib/project-management/ios-app.d.ts +66 -0
  141. package/lib/project-management/ios-app.js +15 -8
  142. package/lib/project-management/project-management-api-request-internal.d.ts +17 -0
  143. package/lib/project-management/project-management-api-request-internal.js +15 -15
  144. package/lib/project-management/project-management-namespace.d.ts +82 -0
  145. package/lib/project-management/project-management-namespace.js +18 -0
  146. package/lib/project-management/project-management.d.ts +115 -0
  147. package/lib/project-management/project-management.js +22 -25
  148. package/lib/remote-config/index.d.ts +19 -336
  149. package/lib/remote-config/index.js +45 -1
  150. package/lib/remote-config/remote-config-api-client-internal.d.ts +28 -0
  151. package/lib/remote-config/remote-config-api-client-internal.js +3 -3
  152. package/lib/remote-config/remote-config-api.d.ts +258 -0
  153. package/lib/remote-config/remote-config-api.js +18 -0
  154. package/lib/remote-config/remote-config-namespace.d.ts +105 -0
  155. package/lib/remote-config/remote-config-namespace.js +18 -0
  156. package/lib/remote-config/remote-config.d.ts +94 -0
  157. package/lib/remote-config/remote-config.js +27 -26
  158. package/lib/security-rules/index.d.ts +18 -184
  159. package/lib/security-rules/index.js +46 -1
  160. package/lib/security-rules/security-rules-api-client-internal.d.ts +73 -0
  161. package/lib/security-rules/security-rules-api-client-internal.js +1 -1
  162. package/lib/security-rules/security-rules-internal.d.ts +21 -0
  163. package/lib/security-rules/security-rules-internal.js +1 -1
  164. package/lib/security-rules/security-rules-namespace.d.ts +69 -0
  165. package/lib/security-rules/security-rules-namespace.js +18 -0
  166. package/lib/security-rules/security-rules.d.ts +196 -0
  167. package/lib/security-rules/security-rules.js +73 -55
  168. package/lib/storage/index.d.ts +16 -32
  169. package/lib/storage/index.js +38 -1
  170. package/lib/storage/storage-namespace.d.ts +45 -0
  171. package/lib/storage/storage-namespace.js +18 -0
  172. package/lib/storage/storage.d.ts +42 -0
  173. package/lib/storage/storage.js +9 -6
  174. package/lib/utils/api-request.d.ts +230 -0
  175. package/lib/utils/api-request.js +25 -25
  176. package/lib/utils/crypto-signer.d.ts +128 -0
  177. package/lib/utils/crypto-signer.js +9 -9
  178. package/lib/utils/deep-copy.d.ts +40 -0
  179. package/lib/utils/deep-copy.js +6 -6
  180. package/lib/utils/error.d.ts +650 -0
  181. package/lib/utils/error.js +36 -34
  182. package/lib/utils/index.d.ts +105 -0
  183. package/lib/utils/index.js +22 -21
  184. package/lib/utils/jwt.d.ts +131 -0
  185. package/lib/utils/jwt.js +11 -11
  186. package/lib/utils/validator.d.ts +144 -0
  187. package/lib/utils/validator.js +37 -37
  188. package/package.json +112 -10
  189. package/lib/credential/credential.js +0 -44
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.12.0 */
1
+ /*! firebase-admin v10.0.1 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -14,203 +14,37 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- /// <reference types="node" />
18
- import { app } from '../firebase-namespace-api';
19
17
  /**
20
- * Gets the {@link securityRules.SecurityRules
21
- * `SecurityRules`} service for the default app or a given app.
18
+ * Security Rules for Cloud Firestore and Cloud Storage.
19
+ *
20
+ * @packageDocumentation
21
+ */
22
+ import { App } from '../app';
23
+ import { SecurityRules } from './security-rules';
24
+ export { RulesFile, Ruleset, RulesetMetadata, RulesetMetadataList, SecurityRules, } from './security-rules';
25
+ /**
26
+ * Gets the {@link SecurityRules} service for the default app or a given app.
22
27
  *
23
28
  * `admin.securityRules()` can be called with no arguments to access the
24
- * default app's {@link securityRules.SecurityRules
25
- * `SecurityRules`} service, or as `admin.securityRules(app)` to access
26
- * the {@link securityRules.SecurityRules `SecurityRules`}
27
- * service associated with a specific app.
29
+ * default app's `SecurityRules` service, or as `admin.securityRules(app)` to access
30
+ * the `SecurityRules` service associated with a specific app.
28
31
  *
29
32
  * @example
30
33
  * ```javascript
31
34
  * // Get the SecurityRules service for the default app
32
- * var defaultSecurityRules = admin.securityRules();
35
+ * const defaultSecurityRules = getSecurityRules();
33
36
  * ```
34
37
  *
35
38
  * @example
36
- * ```javascript
39
+ * ```javascript
37
40
  * // Get the SecurityRules service for a given app
38
- * var otherSecurityRules = admin.securityRules(otherApp);
41
+ * const otherSecurityRules = getSecurityRules(otherApp);
39
42
  * ```
40
43
  *
41
- * @param app Optional app to return the `SecurityRules` service
44
+ * @param app - Optional app to return the `SecurityRules` service
42
45
  * for. If not provided, the default `SecurityRules` service
43
46
  * is returned.
44
- * @return The default `SecurityRules` service if no app is provided, or the
47
+ * @returns The default `SecurityRules` service if no app is provided, or the
45
48
  * `SecurityRules` service associated with the provided app.
46
49
  */
47
- export declare function securityRules(app?: app.App): securityRules.SecurityRules;
48
- export declare namespace securityRules {
49
- /**
50
- * A source file containing some Firebase security rules. The content includes raw
51
- * source code including text formatting, indentation and comments. Use the
52
- * [`securityRules.createRulesFileFromSource()`](securityRules.SecurityRules#createRulesFileFromSource)
53
- * method to create new instances of this type.
54
- */
55
- interface RulesFile {
56
- readonly name: string;
57
- readonly content: string;
58
- }
59
- /**
60
- * Required metadata associated with a ruleset.
61
- */
62
- interface RulesetMetadata {
63
- /**
64
- * Name of the `Ruleset` as a short string. This can be directly passed into APIs
65
- * like {@link securityRules.SecurityRules.getRuleset `securityRules.getRuleset()`}
66
- * and {@link securityRules.SecurityRules.deleteRuleset `securityRules.deleteRuleset()`}.
67
- */
68
- readonly name: string;
69
- /**
70
- * Creation time of the `Ruleset` as a UTC timestamp string.
71
- */
72
- readonly createTime: string;
73
- }
74
- /**
75
- * A page of ruleset metadata.
76
- */
77
- interface RulesetMetadataList {
78
- /**
79
- * A batch of ruleset metadata.
80
- */
81
- readonly rulesets: RulesetMetadata[];
82
- /**
83
- * The next page token if available. This is needed to retrieve the next batch.
84
- */
85
- readonly nextPageToken?: string;
86
- }
87
- /**
88
- * A set of Firebase security rules.
89
- */
90
- interface Ruleset extends RulesetMetadata {
91
- readonly source: RulesFile[];
92
- }
93
- /**
94
- * The Firebase `SecurityRules` service interface.
95
- */
96
- interface SecurityRules {
97
- app: app.App;
98
- /**
99
- * Creates a {@link securityRules.RulesFile `RuleFile`} with the given name
100
- * and source. Throws an error if any of the arguments are invalid. This is a local
101
- * operation, and does not involve any network API calls.
102
- *
103
- * @example
104
- * ```javascript
105
- * const source = '// Some rules source';
106
- * const rulesFile = admin.securityRules().createRulesFileFromSource(
107
- * 'firestore.rules', source);
108
- * ```
109
- *
110
- * @param name Name to assign to the rules file. This is usually a short file name that
111
- * helps identify the file in a ruleset.
112
- * @param source Contents of the rules file.
113
- * @return A new rules file instance.
114
- */
115
- createRulesFileFromSource(name: string, source: string | Buffer): RulesFile;
116
- /**
117
- * Creates a new {@link securityRules.Ruleset `Ruleset`} from the given
118
- * {@link securityRules.RulesFile `RuleFile`}.
119
- *
120
- * @param file Rules file to include in the new `Ruleset`.
121
- * @returns A promise that fulfills with the newly created `Ruleset`.
122
- */
123
- createRuleset(file: RulesFile): Promise<Ruleset>;
124
- /**
125
- * Gets the {@link securityRules.Ruleset `Ruleset`} identified by the given
126
- * name. The input name should be the short name string without the project ID
127
- * prefix. For example, to retrieve the `projects/project-id/rulesets/my-ruleset`,
128
- * pass the short name "my-ruleset". Rejects with a `not-found` error if the
129
- * specified `Ruleset` cannot be found.
130
- *
131
- * @param name Name of the `Ruleset` to retrieve.
132
- * @return A promise that fulfills with the specified `Ruleset`.
133
- */
134
- getRuleset(name: string): Promise<Ruleset>;
135
- /**
136
- * Deletes the {@link securityRules.Ruleset `Ruleset`} identified by the given
137
- * name. The input name should be the short name string without the project ID
138
- * prefix. For example, to delete the `projects/project-id/rulesets/my-ruleset`,
139
- * pass the short name "my-ruleset". Rejects with a `not-found` error if the
140
- * specified `Ruleset` cannot be found.
141
- *
142
- * @param name Name of the `Ruleset` to delete.
143
- * @return A promise that fulfills when the `Ruleset` is deleted.
144
- */
145
- deleteRuleset(name: string): Promise<void>;
146
- /**
147
- * Retrieves a page of ruleset metadata.
148
- *
149
- * @param pageSize The page size, 100 if undefined. This is also the maximum allowed
150
- * limit.
151
- * @param nextPageToken The next page token. If not specified, returns rulesets
152
- * starting without any offset.
153
- * @return A promise that fulfills with a page of rulesets.
154
- */
155
- listRulesetMetadata(pageSize?: number, nextPageToken?: string): Promise<RulesetMetadataList>;
156
- /**
157
- * Gets the {@link securityRules.Ruleset `Ruleset`} currently applied to
158
- * Cloud Firestore. Rejects with a `not-found` error if no ruleset is applied
159
- * on Firestore.
160
- *
161
- * @return A promise that fulfills with the Firestore ruleset.
162
- */
163
- getFirestoreRuleset(): Promise<Ruleset>;
164
- /**
165
- * Creates a new {@link securityRules.Ruleset `Ruleset`} from the given
166
- * source, and applies it to Cloud Firestore.
167
- *
168
- * @param source Rules source to apply.
169
- * @return A promise that fulfills when the ruleset is created and released.
170
- */
171
- releaseFirestoreRulesetFromSource(source: string | Buffer): Promise<Ruleset>;
172
- /**
173
- * Applies the specified {@link securityRules.Ruleset `Ruleset`} ruleset
174
- * to Cloud Firestore.
175
- *
176
- * @param ruleset Name of the ruleset to apply or a `RulesetMetadata` object
177
- * containing the name.
178
- * @return A promise that fulfills when the ruleset is released.
179
- */
180
- releaseFirestoreRuleset(ruleset: string | RulesetMetadata): Promise<void>;
181
- /**
182
- * Gets the {@link securityRules.Ruleset `Ruleset`} currently applied to a
183
- * Cloud Storage bucket. Rejects with a `not-found` error if no ruleset is applied
184
- * on the bucket.
185
- *
186
- * @param bucket Optional name of the Cloud Storage bucket to be retrieved. If not
187
- * specified, retrieves the ruleset applied on the default bucket configured via
188
- * `AppOptions`.
189
- * @return A promise that fulfills with the Cloud Storage ruleset.
190
- */
191
- getStorageRuleset(bucket?: string): Promise<Ruleset>;
192
- /**
193
- * Creates a new {@link securityRules.Ruleset `Ruleset`} from the given
194
- * source, and applies it to a Cloud Storage bucket.
195
- *
196
- * @param source Rules source to apply.
197
- * @param bucket Optional name of the Cloud Storage bucket to apply the rules on. If
198
- * not specified, applies the ruleset on the default bucket configured via
199
- * {@link AppOptions `AppOptions`}.
200
- * @return A promise that fulfills when the ruleset is created and released.
201
- */
202
- releaseStorageRulesetFromSource(source: string | Buffer, bucket?: string): Promise<Ruleset>;
203
- /**
204
- * Applies the specified {@link securityRules.Ruleset `Ruleset`} ruleset
205
- * to a Cloud Storage bucket.
206
- *
207
- * @param ruleset Name of the ruleset to apply or a `RulesetMetadata` object
208
- * containing the name.
209
- * @param bucket Optional name of the Cloud Storage bucket to apply the rules on. If
210
- * not specified, applies the ruleset on the default bucket configured via
211
- * {@link AppOptions `AppOptions`}.
212
- * @return A promise that fulfills when the ruleset is released.
213
- */
214
- releaseStorageRuleset(ruleset: string | RulesetMetadata, bucket?: string): Promise<void>;
215
- }
216
- }
50
+ export declare function getSecurityRules(app?: App): SecurityRules;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.12.0 */
1
+ /*! firebase-admin v10.0.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -16,3 +16,48 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.getSecurityRules = void 0;
20
+ /**
21
+ * Security Rules for Cloud Firestore and Cloud Storage.
22
+ *
23
+ * @packageDocumentation
24
+ */
25
+ var app_1 = require("../app");
26
+ var security_rules_1 = require("./security-rules");
27
+ var security_rules_2 = require("./security-rules");
28
+ Object.defineProperty(exports, "Ruleset", { enumerable: true, get: function () { return security_rules_2.Ruleset; } });
29
+ Object.defineProperty(exports, "RulesetMetadataList", { enumerable: true, get: function () { return security_rules_2.RulesetMetadataList; } });
30
+ Object.defineProperty(exports, "SecurityRules", { enumerable: true, get: function () { return security_rules_2.SecurityRules; } });
31
+ /**
32
+ * Gets the {@link SecurityRules} service for the default app or a given app.
33
+ *
34
+ * `admin.securityRules()` can be called with no arguments to access the
35
+ * default app's `SecurityRules` service, or as `admin.securityRules(app)` to access
36
+ * the `SecurityRules` service associated with a specific app.
37
+ *
38
+ * @example
39
+ * ```javascript
40
+ * // Get the SecurityRules service for the default app
41
+ * const defaultSecurityRules = getSecurityRules();
42
+ * ```
43
+ *
44
+ * @example
45
+ * ```javascript
46
+ * // Get the SecurityRules service for a given app
47
+ * const otherSecurityRules = getSecurityRules(otherApp);
48
+ * ```
49
+ *
50
+ * @param app - Optional app to return the `SecurityRules` service
51
+ * for. If not provided, the default `SecurityRules` service
52
+ * is returned.
53
+ * @returns The default `SecurityRules` service if no app is provided, or the
54
+ * `SecurityRules` service associated with the provided app.
55
+ */
56
+ function getSecurityRules(app) {
57
+ if (typeof app === 'undefined') {
58
+ app = app_1.getApp();
59
+ }
60
+ var firebaseApp = app;
61
+ return firebaseApp.getOrInitService('securityRules', function (app) { return new security_rules_1.SecurityRules(app); });
62
+ }
63
+ exports.getSecurityRules = getSecurityRules;
@@ -0,0 +1,73 @@
1
+ /*! firebase-admin v10.0.1 */
2
+ /*!
3
+ * Copyright 2019 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 '../app';
18
+ export interface Release {
19
+ readonly name: string;
20
+ readonly rulesetName: string;
21
+ readonly createTime?: string;
22
+ readonly updateTime?: string;
23
+ }
24
+ export interface RulesetContent {
25
+ readonly source: {
26
+ readonly files: Array<{
27
+ name: string;
28
+ content: string;
29
+ }>;
30
+ };
31
+ }
32
+ export interface RulesetResponse extends RulesetContent {
33
+ readonly name: string;
34
+ readonly createTime: string;
35
+ }
36
+ export interface ListRulesetsResponse {
37
+ readonly rulesets: Array<{
38
+ name: string;
39
+ createTime: string;
40
+ }>;
41
+ readonly nextPageToken?: string;
42
+ }
43
+ /**
44
+ * Class that facilitates sending requests to the Firebase security rules backend API.
45
+ *
46
+ * @private
47
+ */
48
+ export declare class SecurityRulesApiClient {
49
+ private readonly app;
50
+ private readonly httpClient;
51
+ private projectIdPrefix?;
52
+ constructor(app: App);
53
+ getRuleset(name: string): Promise<RulesetResponse>;
54
+ createRuleset(ruleset: RulesetContent): Promise<RulesetResponse>;
55
+ deleteRuleset(name: string): Promise<void>;
56
+ listRulesets(pageSize?: number, pageToken?: string): Promise<ListRulesetsResponse>;
57
+ getRelease(name: string): Promise<Release>;
58
+ updateRelease(name: string, rulesetName: string): Promise<Release>;
59
+ private getUrl;
60
+ private getProjectIdPrefix;
61
+ /**
62
+ * Gets the specified resource from the rules API. Resource names must be the short names without project
63
+ * ID prefix (e.g. `rulesets/ruleset-name`).
64
+ *
65
+ * @param {string} name Full qualified name of the resource to get.
66
+ * @returns {Promise<T>} A promise that fulfills with the resource.
67
+ */
68
+ private getResource;
69
+ private getReleaseDescription;
70
+ private getRulesetName;
71
+ private sendRequest;
72
+ private toFirebaseError;
73
+ }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.12.0 */
1
+ /*! firebase-admin v10.0.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -0,0 +1,21 @@
1
+ /*! firebase-admin v10.0.1 */
2
+ /*!
3
+ * Copyright 2019 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 { PrefixedFirebaseError } from '../utils/error';
18
+ export declare type SecurityRulesErrorCode = 'already-exists' | 'authentication-error' | 'internal-error' | 'invalid-argument' | 'invalid-server-response' | 'not-found' | 'resource-exhausted' | 'service-unavailable' | 'unknown-error';
19
+ export declare class FirebaseSecurityRulesError extends PrefixedFirebaseError {
20
+ constructor(code: SecurityRulesErrorCode, message: string);
21
+ }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v9.12.0 */
1
+ /*! firebase-admin v10.0.1 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -0,0 +1,69 @@
1
+ /*! firebase-admin v10.0.1 */
2
+ /*!
3
+ * Copyright 2021 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 '../app';
18
+ import { RulesFile as TRulesFile, Ruleset as TRuleset, RulesetMetadata as TRulesetMetadata, RulesetMetadataList as TRulesetMetadataList, SecurityRules as TSecurityRules } from './security-rules';
19
+ /**
20
+ * Gets the {@link firebase-admin.security-rules#SecurityRules} service for the default
21
+ * app or a given app.
22
+ *
23
+ * `admin.securityRules()` can be called with no arguments to access the
24
+ * default app's {@link firebase-admin.security-rules#SecurityRules}
25
+ * service, or as `admin.securityRules(app)` to access
26
+ * the {@link firebase-admin.security-rules#SecurityRules}
27
+ * service associated with a specific app.
28
+ *
29
+ * @example
30
+ * ```javascript
31
+ * // Get the SecurityRules service for the default app
32
+ * var defaultSecurityRules = admin.securityRules();
33
+ * ```
34
+ *
35
+ * @example
36
+ * ```javascript
37
+ * // Get the SecurityRules service for a given app
38
+ * var otherSecurityRules = admin.securityRules(otherApp);
39
+ * ```
40
+ *
41
+ * @param app - Optional app to return the `SecurityRules` service
42
+ * for. If not provided, the default `SecurityRules` service
43
+ * is returned.
44
+ * @returns The default `SecurityRules` service if no app is provided, or the
45
+ * `SecurityRules` service associated with the provided app.
46
+ */
47
+ export declare function securityRules(app?: App): securityRules.SecurityRules;
48
+ export declare namespace securityRules {
49
+ /**
50
+ * Type alias to {@link firebase-admin.security-rules#RulesFile}.
51
+ */
52
+ type RulesFile = TRulesFile;
53
+ /**
54
+ * Type alias to {@link firebase-admin.security-rules#Ruleset}.
55
+ */
56
+ type Ruleset = TRuleset;
57
+ /**
58
+ * Type alias to {@link firebase-admin.security-rules#RulesetMetadata}.
59
+ */
60
+ type RulesetMetadata = TRulesetMetadata;
61
+ /**
62
+ * Type alias to {@link firebase-admin.security-rules#RulesetMetadataList}.
63
+ */
64
+ type RulesetMetadataList = TRulesetMetadataList;
65
+ /**
66
+ * Type alias to {@link firebase-admin.security-rules#SecurityRules}.
67
+ */
68
+ type SecurityRules = TSecurityRules;
69
+ }
@@ -0,0 +1,18 @@
1
+ /*! firebase-admin v10.0.1 */
2
+ "use strict";
3
+ /*!
4
+ * Copyright 2021 Google Inc.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,196 @@
1
+ /*! firebase-admin v10.0.1 */
2
+ /*!
3
+ * Copyright 2019 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
+ /// <reference types="node" />
18
+ import { App } from '../app';
19
+ /**
20
+ * A source file containing some Firebase security rules. The content includes raw
21
+ * source code including text formatting, indentation and comments. Use the
22
+ * {@link SecurityRules.createRulesFileFromSource} method to create new instances of this type.
23
+ */
24
+ export interface RulesFile {
25
+ readonly name: string;
26
+ readonly content: string;
27
+ }
28
+ /**
29
+ * Required metadata associated with a ruleset.
30
+ */
31
+ export interface RulesetMetadata {
32
+ /**
33
+ * Name of the `Ruleset` as a short string. This can be directly passed into APIs
34
+ * like {@link SecurityRules.getRuleset} and {@link SecurityRules.deleteRuleset}.
35
+ */
36
+ readonly name: string;
37
+ /**
38
+ * Creation time of the `Ruleset` as a UTC timestamp string.
39
+ */
40
+ readonly createTime: string;
41
+ }
42
+ /**
43
+ * A page of ruleset metadata.
44
+ */
45
+ export declare class RulesetMetadataList {
46
+ /**
47
+ * A batch of ruleset metadata.
48
+ */
49
+ readonly rulesets: RulesetMetadata[];
50
+ /**
51
+ * The next page token if available. This is needed to retrieve the next batch.
52
+ */
53
+ readonly nextPageToken?: string;
54
+ }
55
+ /**
56
+ * A set of Firebase security rules.
57
+ */
58
+ export declare class Ruleset implements RulesetMetadata {
59
+ /**
60
+ * {@inheritdoc RulesetMetadata.name}
61
+ */
62
+ readonly name: string;
63
+ /**
64
+ * {@inheritdoc RulesetMetadata.createTime}
65
+ */
66
+ readonly createTime: string;
67
+ readonly source: RulesFile[];
68
+ }
69
+ /**
70
+ * The Firebase `SecurityRules` service interface.
71
+ */
72
+ export declare class SecurityRules {
73
+ readonly app: App;
74
+ private static readonly CLOUD_FIRESTORE;
75
+ private static readonly FIREBASE_STORAGE;
76
+ private readonly client;
77
+ /**
78
+ * Gets the {@link Ruleset} identified by the given
79
+ * name. The input name should be the short name string without the project ID
80
+ * prefix. For example, to retrieve the `projects/project-id/rulesets/my-ruleset`,
81
+ * pass the short name "my-ruleset". Rejects with a `not-found` error if the
82
+ * specified `Ruleset` cannot be found.
83
+ *
84
+ * @param name - Name of the `Ruleset` to retrieve.
85
+ * @returns A promise that fulfills with the specified `Ruleset`.
86
+ */
87
+ getRuleset(name: string): Promise<Ruleset>;
88
+ /**
89
+ * Gets the {@link Ruleset} currently applied to
90
+ * Cloud Firestore. Rejects with a `not-found` error if no ruleset is applied
91
+ * on Firestore.
92
+ *
93
+ * @returns A promise that fulfills with the Firestore ruleset.
94
+ */
95
+ getFirestoreRuleset(): Promise<Ruleset>;
96
+ /**
97
+ * Creates a new {@link Ruleset} from the given
98
+ * source, and applies it to Cloud Firestore.
99
+ *
100
+ * @param source - Rules source to apply.
101
+ * @returns A promise that fulfills when the ruleset is created and released.
102
+ */
103
+ releaseFirestoreRulesetFromSource(source: string | Buffer): Promise<Ruleset>;
104
+ /**
105
+ * Applies the specified {@link Ruleset} ruleset
106
+ * to Cloud Firestore.
107
+ *
108
+ * @param ruleset - Name of the ruleset to apply or a `RulesetMetadata` object
109
+ * containing the name.
110
+ * @returns A promise that fulfills when the ruleset is released.
111
+ */
112
+ releaseFirestoreRuleset(ruleset: string | RulesetMetadata): Promise<void>;
113
+ /**
114
+ * Gets the {@link Ruleset} currently applied to a
115
+ * Cloud Storage bucket. Rejects with a `not-found` error if no ruleset is applied
116
+ * on the bucket.
117
+ *
118
+ * @param bucket - Optional name of the Cloud Storage bucket to be retrieved. If not
119
+ * specified, retrieves the ruleset applied on the default bucket configured via
120
+ * `AppOptions`.
121
+ * @returns A promise that fulfills with the Cloud Storage ruleset.
122
+ */
123
+ getStorageRuleset(bucket?: string): Promise<Ruleset>;
124
+ /**
125
+ * Creates a new {@link Ruleset} from the given
126
+ * source, and applies it to a Cloud Storage bucket.
127
+ *
128
+ * @param source - Rules source to apply.
129
+ * @param bucket - Optional name of the Cloud Storage bucket to apply the rules on. If
130
+ * not specified, applies the ruleset on the default bucket configured via
131
+ * {@link firebase-admin.app#AppOptions}.
132
+ * @returns A promise that fulfills when the ruleset is created and released.
133
+ */
134
+ releaseStorageRulesetFromSource(source: string | Buffer, bucket?: string): Promise<Ruleset>;
135
+ /**
136
+ * Applies the specified {@link Ruleset} ruleset
137
+ * to a Cloud Storage bucket.
138
+ *
139
+ * @param ruleset - Name of the ruleset to apply or a `RulesetMetadata` object
140
+ * containing the name.
141
+ * @param bucket - Optional name of the Cloud Storage bucket to apply the rules on. If
142
+ * not specified, applies the ruleset on the default bucket configured via
143
+ * {@link firebase-admin.app#AppOptions}.
144
+ * @returns A promise that fulfills when the ruleset is released.
145
+ */
146
+ releaseStorageRuleset(ruleset: string | RulesetMetadata, bucket?: string): Promise<void>;
147
+ /**
148
+ * Creates a {@link RulesFile} with the given name
149
+ * and source. Throws an error if any of the arguments are invalid. This is a local
150
+ * operation, and does not involve any network API calls.
151
+ *
152
+ * @example
153
+ * ```javascript
154
+ * const source = '// Some rules source';
155
+ * const rulesFile = admin.securityRules().createRulesFileFromSource(
156
+ * 'firestore.rules', source);
157
+ * ```
158
+ *
159
+ * @param name - Name to assign to the rules file. This is usually a short file name that
160
+ * helps identify the file in a ruleset.
161
+ * @param source - Contents of the rules file.
162
+ * @returns A new rules file instance.
163
+ */
164
+ createRulesFileFromSource(name: string, source: string | Buffer): RulesFile;
165
+ /**
166
+ * Creates a new {@link Ruleset} from the given {@link RulesFile}.
167
+ *
168
+ * @param file - Rules file to include in the new `Ruleset`.
169
+ * @returns A promise that fulfills with the newly created `Ruleset`.
170
+ */
171
+ createRuleset(file: RulesFile): Promise<Ruleset>;
172
+ /**
173
+ * Deletes the {@link Ruleset} identified by the given
174
+ * name. The input name should be the short name string without the project ID
175
+ * prefix. For example, to delete the `projects/project-id/rulesets/my-ruleset`,
176
+ * pass the short name "my-ruleset". Rejects with a `not-found` error if the
177
+ * specified `Ruleset` cannot be found.
178
+ *
179
+ * @param name - Name of the `Ruleset` to delete.
180
+ * @returns A promise that fulfills when the `Ruleset` is deleted.
181
+ */
182
+ deleteRuleset(name: string): Promise<void>;
183
+ /**
184
+ * Retrieves a page of ruleset metadata.
185
+ *
186
+ * @param pageSize - The page size, 100 if undefined. This is also the maximum allowed
187
+ * limit.
188
+ * @param nextPageToken - The next page token. If not specified, returns rulesets
189
+ * starting without any offset.
190
+ * @returns A promise that fulfills with a page of rulesets.
191
+ */
192
+ listRulesetMetadata(pageSize?: number, nextPageToken?: string): Promise<RulesetMetadataList>;
193
+ private getRulesetForRelease;
194
+ private releaseRuleset;
195
+ private getBucketName;
196
+ }