firebase-admin 9.12.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.
- package/LICENSE +201 -0
- package/README.md +90 -0
- package/lib/app-check/app-check-api-client-internal.js +197 -0
- package/lib/app-check/app-check.js +79 -0
- package/lib/app-check/index.d.ts +160 -0
- package/lib/app-check/index.js +19 -0
- package/lib/app-check/token-generator.js +161 -0
- package/lib/app-check/token-verifier.js +152 -0
- package/lib/auth/action-code-settings-builder.js +118 -0
- package/lib/auth/auth-api-request.js +1856 -0
- package/lib/auth/auth-config.js +636 -0
- package/lib/auth/auth.js +836 -0
- package/lib/auth/identifier.js +40 -0
- package/lib/auth/index.d.ts +1927 -0
- package/lib/auth/index.js +18 -0
- package/lib/auth/tenant-manager.js +140 -0
- package/lib/auth/tenant.js +171 -0
- package/lib/auth/token-generator.js +200 -0
- package/lib/auth/token-verifier.js +259 -0
- package/lib/auth/user-import-builder.js +387 -0
- package/lib/auth/user-record.js +346 -0
- package/lib/credential/credential-internal.js +391 -0
- package/lib/credential/credential.js +44 -0
- package/lib/credential/index.d.ts +169 -0
- package/lib/credential/index.js +23 -0
- package/lib/database/database-internal.js +266 -0
- package/lib/database/index.d.ts +89 -0
- package/lib/database/index.js +31 -0
- package/lib/default-namespace.js +31 -0
- package/lib/firebase-app.js +349 -0
- package/lib/firebase-namespace-api.d.ts +243 -0
- package/lib/firebase-namespace-api.js +18 -0
- package/lib/firebase-namespace.d.ts +31 -0
- package/lib/firebase-namespace.js +417 -0
- package/lib/firestore/firestore-internal.js +105 -0
- package/lib/firestore/index.d.ts +50 -0
- package/lib/firestore/index.js +47 -0
- package/lib/index.d.ts +24 -0
- package/lib/index.js +27 -0
- package/lib/installations/index.d.ts +81 -0
- package/lib/installations/index.js +18 -0
- package/lib/installations/installations-request-handler.js +117 -0
- package/lib/installations/installations.js +62 -0
- package/lib/instance-id/index.d.ts +83 -0
- package/lib/instance-id/index.js +18 -0
- package/lib/instance-id/instance-id.js +87 -0
- package/lib/machine-learning/index.d.ts +249 -0
- package/lib/machine-learning/index.js +18 -0
- package/lib/machine-learning/machine-learning-api-client.js +304 -0
- package/lib/machine-learning/machine-learning-utils.js +62 -0
- package/lib/machine-learning/machine-learning.js +364 -0
- package/lib/messaging/batch-request-internal.js +129 -0
- package/lib/messaging/index.d.ts +1174 -0
- package/lib/messaging/index.js +18 -0
- package/lib/messaging/messaging-api-request-internal.js +128 -0
- package/lib/messaging/messaging-errors-internal.js +106 -0
- package/lib/messaging/messaging-internal.js +484 -0
- package/lib/messaging/messaging.js +846 -0
- package/lib/project-management/android-app.js +176 -0
- package/lib/project-management/index.d.ts +363 -0
- package/lib/project-management/index.js +41 -0
- package/lib/project-management/ios-app.js +88 -0
- package/lib/project-management/project-management-api-request-internal.js +273 -0
- package/lib/project-management/project-management.js +254 -0
- package/lib/remote-config/index.d.ts +369 -0
- package/lib/remote-config/index.js +18 -0
- package/lib/remote-config/remote-config-api-client-internal.js +407 -0
- package/lib/remote-config/remote-config.js +304 -0
- package/lib/security-rules/index.d.ts +216 -0
- package/lib/security-rules/index.js +18 -0
- package/lib/security-rules/security-rules-api-client-internal.js +237 -0
- package/lib/security-rules/security-rules-internal.js +41 -0
- package/lib/security-rules/security-rules.js +310 -0
- package/lib/storage/index.d.ts +60 -0
- package/lib/storage/index.js +18 -0
- package/lib/storage/storage.js +123 -0
- package/lib/utils/api-request.js +845 -0
- package/lib/utils/crypto-signer.js +237 -0
- package/lib/utils/deep-copy.js +78 -0
- package/lib/utils/error.js +1063 -0
- package/lib/utils/index.js +217 -0
- package/lib/utils/jwt.js +355 -0
- package/lib/utils/validator.js +271 -0
- package/package.json +122 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright 2020 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 });
|
|
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");
|
|
22
|
+
/**
|
|
23
|
+
* Remote Config service bound to the provided app.
|
|
24
|
+
*/
|
|
25
|
+
var RemoteConfig = /** @class */ (function () {
|
|
26
|
+
/**
|
|
27
|
+
* @param app The app for this RemoteConfig service.
|
|
28
|
+
* @constructor
|
|
29
|
+
*/
|
|
30
|
+
function RemoteConfig(app) {
|
|
31
|
+
this.app = app;
|
|
32
|
+
this.client = new remote_config_api_client_internal_1.RemoteConfigApiClient(app);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Gets the current active version of the {@link remoteConfig.RemoteConfigTemplate
|
|
36
|
+
* `RemoteConfigTemplate`} of the project.
|
|
37
|
+
*
|
|
38
|
+
* @return A promise that fulfills with a `RemoteConfigTemplate`.
|
|
39
|
+
*/
|
|
40
|
+
RemoteConfig.prototype.getTemplate = function () {
|
|
41
|
+
return this.client.getTemplate()
|
|
42
|
+
.then(function (templateResponse) {
|
|
43
|
+
return new RemoteConfigTemplateImpl(templateResponse);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Gets the requested version of the {@link remoteConfig.RemoteConfigTemplate
|
|
48
|
+
* `RemoteConfigTemplate`} of the project.
|
|
49
|
+
*
|
|
50
|
+
* @param versionNumber Version number of the Remote Config template to look up.
|
|
51
|
+
*
|
|
52
|
+
* @return A promise that fulfills with a `RemoteConfigTemplate`.
|
|
53
|
+
*/
|
|
54
|
+
RemoteConfig.prototype.getTemplateAtVersion = function (versionNumber) {
|
|
55
|
+
return this.client.getTemplateAtVersion(versionNumber)
|
|
56
|
+
.then(function (templateResponse) {
|
|
57
|
+
return new RemoteConfigTemplateImpl(templateResponse);
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Validates a {@link remoteConfig.RemoteConfigTemplate `RemoteConfigTemplate`}.
|
|
62
|
+
*
|
|
63
|
+
* @param template The Remote Config template to be validated.
|
|
64
|
+
* @returns A promise that fulfills with the validated `RemoteConfigTemplate`.
|
|
65
|
+
*/
|
|
66
|
+
RemoteConfig.prototype.validateTemplate = function (template) {
|
|
67
|
+
return this.client.validateTemplate(template)
|
|
68
|
+
.then(function (templateResponse) {
|
|
69
|
+
return new RemoteConfigTemplateImpl(templateResponse);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Publishes a Remote Config template.
|
|
74
|
+
*
|
|
75
|
+
* @param template The Remote Config template to be published.
|
|
76
|
+
* @param options Optional options object when publishing a Remote Config template:
|
|
77
|
+
* - {boolean} `force` Setting this to `true` forces the Remote Config template to
|
|
78
|
+
* be updated and circumvent the ETag. This approach is not recommended
|
|
79
|
+
* because it risks causing the loss of updates to your Remote Config
|
|
80
|
+
* template if multiple clients are updating the Remote Config template.
|
|
81
|
+
* See {@link https://firebase.google.com/docs/remote-config/use-config-rest#etag_usage_and_forced_updates
|
|
82
|
+
* ETag usage and forced updates}.
|
|
83
|
+
*
|
|
84
|
+
* @return A Promise that fulfills with the published `RemoteConfigTemplate`.
|
|
85
|
+
*/
|
|
86
|
+
RemoteConfig.prototype.publishTemplate = function (template, options) {
|
|
87
|
+
return this.client.publishTemplate(template, options)
|
|
88
|
+
.then(function (templateResponse) {
|
|
89
|
+
return new RemoteConfigTemplateImpl(templateResponse);
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Rolls back a project's published Remote Config template to the specified version.
|
|
94
|
+
* A rollback is equivalent to getting a previously published Remote Config
|
|
95
|
+
* template and re-publishing it using a force update.
|
|
96
|
+
*
|
|
97
|
+
* @param versionNumber The version number of the Remote Config template to roll back to.
|
|
98
|
+
* The specified version number must be lower than the current version number, and not have
|
|
99
|
+
* been deleted due to staleness. Only the last 300 versions are stored.
|
|
100
|
+
* All versions that correspond to non-active Remote Config templates (that is, all except the
|
|
101
|
+
* template that is being fetched by clients) are also deleted if they are more than 90 days old.
|
|
102
|
+
* @return A promise that fulfills with the published `RemoteConfigTemplate`.
|
|
103
|
+
*/
|
|
104
|
+
RemoteConfig.prototype.rollback = function (versionNumber) {
|
|
105
|
+
return this.client.rollback(versionNumber)
|
|
106
|
+
.then(function (templateResponse) {
|
|
107
|
+
return new RemoteConfigTemplateImpl(templateResponse);
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Gets a list of Remote Config template versions that have been published, sorted in reverse
|
|
112
|
+
* chronological order. Only the last 300 versions are stored.
|
|
113
|
+
* All versions that correspond to non-active Remote Config templates (i.e., all except the
|
|
114
|
+
* template that is being fetched by clients) are also deleted if they are older than 90 days.
|
|
115
|
+
*
|
|
116
|
+
* @param options Optional options object for getting a list of versions.
|
|
117
|
+
* @return A promise that fulfills with a `ListVersionsResult`.
|
|
118
|
+
*/
|
|
119
|
+
RemoteConfig.prototype.listVersions = function (options) {
|
|
120
|
+
return this.client.listVersions(options)
|
|
121
|
+
.then(function (listVersionsResponse) {
|
|
122
|
+
var _a, _b;
|
|
123
|
+
return {
|
|
124
|
+
versions: (_b = (_a = listVersionsResponse.versions) === null || _a === void 0 ? void 0 : _a.map(function (version) { return new VersionImpl(version); })) !== null && _b !== void 0 ? _b : [],
|
|
125
|
+
nextPageToken: listVersionsResponse.nextPageToken,
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Creates and returns a new Remote Config template from a JSON string.
|
|
131
|
+
*
|
|
132
|
+
* @param json The JSON string to populate a Remote Config template.
|
|
133
|
+
*
|
|
134
|
+
* @return A new template instance.
|
|
135
|
+
*/
|
|
136
|
+
RemoteConfig.prototype.createTemplateFromJSON = function (json) {
|
|
137
|
+
if (!validator.isNonEmptyString(json)) {
|
|
138
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'JSON string must be a valid non-empty string');
|
|
139
|
+
}
|
|
140
|
+
var template;
|
|
141
|
+
try {
|
|
142
|
+
template = JSON.parse(json);
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', "Failed to parse the JSON string: " + json + ". " + e);
|
|
146
|
+
}
|
|
147
|
+
return new RemoteConfigTemplateImpl(template);
|
|
148
|
+
};
|
|
149
|
+
return RemoteConfig;
|
|
150
|
+
}());
|
|
151
|
+
exports.RemoteConfig = RemoteConfig;
|
|
152
|
+
/**
|
|
153
|
+
* Remote Config template internal implementation.
|
|
154
|
+
*/
|
|
155
|
+
var RemoteConfigTemplateImpl = /** @class */ (function () {
|
|
156
|
+
function RemoteConfigTemplateImpl(config) {
|
|
157
|
+
if (!validator.isNonNullObject(config) ||
|
|
158
|
+
!validator.isNonEmptyString(config.etag)) {
|
|
159
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', "Invalid Remote Config template: " + JSON.stringify(config));
|
|
160
|
+
}
|
|
161
|
+
this.etagInternal = config.etag;
|
|
162
|
+
if (typeof config.parameters !== 'undefined') {
|
|
163
|
+
if (!validator.isNonNullObject(config.parameters)) {
|
|
164
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameters must be a non-null object');
|
|
165
|
+
}
|
|
166
|
+
this.parameters = config.parameters;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
this.parameters = {};
|
|
170
|
+
}
|
|
171
|
+
if (typeof config.parameterGroups !== 'undefined') {
|
|
172
|
+
if (!validator.isNonNullObject(config.parameterGroups)) {
|
|
173
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameter groups must be a non-null object');
|
|
174
|
+
}
|
|
175
|
+
this.parameterGroups = config.parameterGroups;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
this.parameterGroups = {};
|
|
179
|
+
}
|
|
180
|
+
if (typeof config.conditions !== 'undefined') {
|
|
181
|
+
if (!validator.isArray(config.conditions)) {
|
|
182
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config conditions must be an array');
|
|
183
|
+
}
|
|
184
|
+
this.conditions = config.conditions;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
this.conditions = [];
|
|
188
|
+
}
|
|
189
|
+
if (typeof config.version !== 'undefined') {
|
|
190
|
+
this.version = new VersionImpl(config.version);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
Object.defineProperty(RemoteConfigTemplateImpl.prototype, "etag", {
|
|
194
|
+
/**
|
|
195
|
+
* Gets the ETag of the template.
|
|
196
|
+
*
|
|
197
|
+
* @return {string} The ETag of the Remote Config template.
|
|
198
|
+
*/
|
|
199
|
+
get: function () {
|
|
200
|
+
return this.etagInternal;
|
|
201
|
+
},
|
|
202
|
+
enumerable: false,
|
|
203
|
+
configurable: true
|
|
204
|
+
});
|
|
205
|
+
/**
|
|
206
|
+
* @return {RemoteConfigTemplate} A JSON-serializable representation of this object.
|
|
207
|
+
*/
|
|
208
|
+
RemoteConfigTemplateImpl.prototype.toJSON = function () {
|
|
209
|
+
return {
|
|
210
|
+
conditions: this.conditions,
|
|
211
|
+
parameters: this.parameters,
|
|
212
|
+
parameterGroups: this.parameterGroups,
|
|
213
|
+
etag: this.etag,
|
|
214
|
+
version: this.version,
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
return RemoteConfigTemplateImpl;
|
|
218
|
+
}());
|
|
219
|
+
/**
|
|
220
|
+
* Remote Config Version internal implementation.
|
|
221
|
+
*/
|
|
222
|
+
var VersionImpl = /** @class */ (function () {
|
|
223
|
+
function VersionImpl(version) {
|
|
224
|
+
if (!validator.isNonNullObject(version)) {
|
|
225
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', "Invalid Remote Config version instance: " + JSON.stringify(version));
|
|
226
|
+
}
|
|
227
|
+
if (typeof version.versionNumber !== 'undefined') {
|
|
228
|
+
if (!validator.isNonEmptyString(version.versionNumber) &&
|
|
229
|
+
!validator.isNumber(version.versionNumber)) {
|
|
230
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version number must be a non-empty string in int64 format or a number');
|
|
231
|
+
}
|
|
232
|
+
if (!Number.isInteger(Number(version.versionNumber))) {
|
|
233
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version number must be an integer or a string in int64 format');
|
|
234
|
+
}
|
|
235
|
+
this.versionNumber = version.versionNumber;
|
|
236
|
+
}
|
|
237
|
+
if (typeof version.updateOrigin !== 'undefined') {
|
|
238
|
+
if (!validator.isNonEmptyString(version.updateOrigin)) {
|
|
239
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update origin must be a non-empty string');
|
|
240
|
+
}
|
|
241
|
+
this.updateOrigin = version.updateOrigin;
|
|
242
|
+
}
|
|
243
|
+
if (typeof version.updateType !== 'undefined') {
|
|
244
|
+
if (!validator.isNonEmptyString(version.updateType)) {
|
|
245
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update type must be a non-empty string');
|
|
246
|
+
}
|
|
247
|
+
this.updateType = version.updateType;
|
|
248
|
+
}
|
|
249
|
+
if (typeof version.updateUser !== 'undefined') {
|
|
250
|
+
if (!validator.isNonNullObject(version.updateUser)) {
|
|
251
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update user must be a non-null object');
|
|
252
|
+
}
|
|
253
|
+
this.updateUser = version.updateUser;
|
|
254
|
+
}
|
|
255
|
+
if (typeof version.description !== 'undefined') {
|
|
256
|
+
if (!validator.isNonEmptyString(version.description)) {
|
|
257
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version description must be a non-empty string');
|
|
258
|
+
}
|
|
259
|
+
this.description = version.description;
|
|
260
|
+
}
|
|
261
|
+
if (typeof version.rollbackSource !== 'undefined') {
|
|
262
|
+
if (!validator.isNonEmptyString(version.rollbackSource)) {
|
|
263
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version rollback source must be a non-empty string');
|
|
264
|
+
}
|
|
265
|
+
this.rollbackSource = version.rollbackSource;
|
|
266
|
+
}
|
|
267
|
+
if (typeof version.isLegacy !== 'undefined') {
|
|
268
|
+
if (!validator.isBoolean(version.isLegacy)) {
|
|
269
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version.isLegacy must be a boolean');
|
|
270
|
+
}
|
|
271
|
+
this.isLegacy = version.isLegacy;
|
|
272
|
+
}
|
|
273
|
+
// The backend API provides timestamps in ISO date strings. The Admin SDK exposes timestamps
|
|
274
|
+
// in UTC date strings. If a developer uses a previously obtained template with UTC timestamps
|
|
275
|
+
// we could still validate it below.
|
|
276
|
+
if (typeof version.updateTime !== 'undefined') {
|
|
277
|
+
if (!this.isValidTimestamp(version.updateTime)) {
|
|
278
|
+
throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update time must be a valid date string');
|
|
279
|
+
}
|
|
280
|
+
this.updateTime = new Date(version.updateTime).toUTCString();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* @return {Version} A JSON-serializable representation of this object.
|
|
285
|
+
*/
|
|
286
|
+
VersionImpl.prototype.toJSON = function () {
|
|
287
|
+
return {
|
|
288
|
+
versionNumber: this.versionNumber,
|
|
289
|
+
updateOrigin: this.updateOrigin,
|
|
290
|
+
updateType: this.updateType,
|
|
291
|
+
updateUser: this.updateUser,
|
|
292
|
+
description: this.description,
|
|
293
|
+
rollbackSource: this.rollbackSource,
|
|
294
|
+
isLegacy: this.isLegacy,
|
|
295
|
+
updateTime: this.updateTime,
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
VersionImpl.prototype.isValidTimestamp = function (timestamp) {
|
|
299
|
+
// This validation fails for timestamps earlier than January 1, 1970 and considers strings
|
|
300
|
+
// such as "1.2" as valid timestamps.
|
|
301
|
+
return validator.isNonEmptyString(timestamp) && (new Date(timestamp)).getTime() > 0;
|
|
302
|
+
};
|
|
303
|
+
return VersionImpl;
|
|
304
|
+
}());
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.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
|
+
/// <reference types="node" />
|
|
18
|
+
import { app } from '../firebase-namespace-api';
|
|
19
|
+
/**
|
|
20
|
+
* Gets the {@link securityRules.SecurityRules
|
|
21
|
+
* `SecurityRules`} service for the default app or a given app.
|
|
22
|
+
*
|
|
23
|
+
* `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.
|
|
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
|
+
* @return 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.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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright 2020 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 });
|