firebase-admin 9.3.0 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/auth/action-code-settings-builder.js +1 -1
- package/lib/auth/auth-api-request.js +98 -25
- package/lib/auth/auth-config.js +15 -15
- package/lib/auth/auth.js +82 -61
- package/lib/auth/identifier.js +3 -2
- package/lib/auth/index.d.ts +1868 -0
- package/lib/{credential/credential-interfaces.js → auth/index.js} +1 -1
- package/lib/auth/tenant-manager.js +1 -1
- package/lib/auth/tenant.js +7 -1
- package/lib/auth/token-generator.js +6 -4
- package/lib/auth/token-verifier.js +32 -36
- package/lib/auth/user-import-builder.js +18 -15
- package/lib/auth/user-record.js +4 -4
- package/lib/credential/credential-internal.js +1 -2
- package/lib/credential/credential.js +8 -122
- package/lib/credential/index.d.ts +169 -0
- package/lib/credential/index.js +5 -17
- package/lib/database/database-internal.js +19 -26
- package/lib/database/index.d.ts +89 -0
- package/lib/database/index.js +12 -28
- package/lib/default-namespace.js +2 -1
- package/lib/firebase-app.js +26 -48
- package/lib/firebase-namespace-api.d.ts +238 -0
- package/lib/{firebase-service.js → firebase-namespace-api.js} +2 -2
- package/lib/{database/database.js → firebase-namespace.d.ts} +14 -7
- package/lib/firebase-namespace.js +22 -92
- package/lib/firestore/firestore-internal.js +2 -19
- package/lib/firestore/index.d.ts +50 -0
- package/lib/firestore/index.js +28 -43
- package/lib/index.d.ts +3 -932
- package/lib/index.js +2 -1
- package/lib/instance-id/index.d.ts +81 -0
- package/lib/instance-id/index.js +1 -10
- package/lib/instance-id/instance-id-request-internal.js +2 -1
- package/lib/instance-id/instance-id.js +1 -19
- package/lib/machine-learning/index.d.ts +249 -0
- package/lib/{messaging/messaging-types.js → machine-learning/index.js} +2 -2
- package/lib/machine-learning/machine-learning-api-client.js +1 -1
- package/lib/machine-learning/machine-learning-utils.js +1 -1
- package/lib/machine-learning/machine-learning.js +3 -22
- package/lib/messaging/batch-request-internal.js +1 -1
- package/lib/messaging/index.d.ts +1174 -0
- package/lib/messaging/index.js +1 -24
- package/lib/messaging/messaging-api-request-internal.js +2 -1
- package/lib/messaging/messaging-errors-internal.js +1 -1
- package/lib/messaging/messaging-internal.js +1 -1
- package/lib/messaging/messaging.js +21 -25
- package/lib/project-management/android-app.js +7 -6
- package/lib/project-management/index.d.ts +363 -0
- package/lib/project-management/index.js +23 -25
- package/lib/project-management/ios-app.js +5 -4
- package/lib/project-management/project-management-api-request-internal.js +5 -5
- package/lib/project-management/project-management.js +9 -26
- package/lib/remote-config/index.d.ts +359 -0
- package/lib/remote-config/index.js +1 -26
- package/lib/remote-config/remote-config-api-client-internal.js +3 -3
- package/lib/remote-config/remote-config.js +15 -32
- package/lib/security-rules/index.d.ts +216 -0
- package/lib/security-rules/index.js +1 -24
- package/lib/security-rules/security-rules-api-client-internal.js +1 -1
- package/lib/security-rules/security-rules-internal.js +1 -1
- package/lib/security-rules/security-rules.js +6 -15
- package/lib/storage/index.d.ts +60 -0
- package/lib/storage/index.js +1 -10
- package/lib/storage/storage.js +2 -19
- package/lib/utils/api-request.js +10 -3
- package/lib/utils/deep-copy.js +2 -1
- package/lib/utils/error.js +2 -1
- package/lib/utils/index.js +6 -5
- package/lib/utils/validator.js +2 -1
- package/package.json +15 -12
- package/lib/auth.d.ts +0 -2016
- package/lib/credential.d.ts +0 -150
- package/lib/database.d.ts +0 -1663
- package/lib/instance-id.d.ts +0 -37
- package/lib/messaging.d.ts +0 -1341
- package/lib/project-management/app-metadata.js +0 -37
- package/lib/project-management.d.ts +0 -361
- package/lib/remote-config/remote-config-api-client.js +0 -36
- package/lib/remote-config.d.ts +0 -350
- package/lib/security-rules.d.ts +0 -192
- package/lib/storage.d.ts +0 -40
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2020 Google Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/// <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
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v9.
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2020 Google Inc.
|
|
@@ -16,26 +16,3 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.admin = exports.securityRules = void 0;
|
|
20
|
-
var firebaseAdmin = require("../index");
|
|
21
|
-
function securityRules(app) {
|
|
22
|
-
if (typeof (app) === 'undefined') {
|
|
23
|
-
app = firebaseAdmin.app();
|
|
24
|
-
}
|
|
25
|
-
return app.securityRules();
|
|
26
|
-
}
|
|
27
|
-
exports.securityRules = securityRules;
|
|
28
|
-
/**
|
|
29
|
-
* We must define a namespace to make the typings work correctly. Otherwise
|
|
30
|
-
* `admin.securityRules()` cannot be called like a function. Temporarily,
|
|
31
|
-
* admin.securityRules is used as the namespace name because we cannot barrel
|
|
32
|
-
* re-export the contents from security-rules, and we want it to
|
|
33
|
-
* match the namespacing in the re-export inside src/index.d.ts
|
|
34
|
-
*/
|
|
35
|
-
/* eslint-disable @typescript-eslint/no-namespace */
|
|
36
|
-
var admin;
|
|
37
|
-
(function (admin) {
|
|
38
|
-
var securityRules;
|
|
39
|
-
(function (securityRules) {
|
|
40
|
-
})(securityRules = admin.securityRules || (admin.securityRules = {}));
|
|
41
|
-
})(admin = exports.admin || (exports.admin = {}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v9.
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2019 Google Inc.
|
|
@@ -59,7 +59,7 @@ exports.Ruleset = Ruleset;
|
|
|
59
59
|
* The Firebase `SecurityRules` service interface.
|
|
60
60
|
*
|
|
61
61
|
* Do not call this constructor directly. Instead, use
|
|
62
|
-
* [`admin.securityRules()`](
|
|
62
|
+
* [`admin.securityRules()`](securityRules#securityRules).
|
|
63
63
|
*/
|
|
64
64
|
var SecurityRules = /** @class */ (function () {
|
|
65
65
|
/**
|
|
@@ -68,7 +68,6 @@ var SecurityRules = /** @class */ (function () {
|
|
|
68
68
|
*/
|
|
69
69
|
function SecurityRules(app) {
|
|
70
70
|
this.app = app;
|
|
71
|
-
this.INTERNAL = new SecurityRulesInternals();
|
|
72
71
|
this.client = new security_rules_api_client_internal_1.SecurityRulesApiClient(app);
|
|
73
72
|
}
|
|
74
73
|
/**
|
|
@@ -187,7 +186,7 @@ var SecurityRules = /** @class */ (function () {
|
|
|
187
186
|
});
|
|
188
187
|
};
|
|
189
188
|
/**
|
|
190
|
-
* Creates a {@link
|
|
189
|
+
* Creates a {@link securityRules.RulesFile `RuleFile`} with the given name
|
|
191
190
|
* and source. Throws an error if any of the arguments are invalid. This is a local
|
|
192
191
|
* operation, and does not involve any network API calls.
|
|
193
192
|
*
|
|
@@ -223,8 +222,8 @@ var SecurityRules = /** @class */ (function () {
|
|
|
223
222
|
};
|
|
224
223
|
};
|
|
225
224
|
/**
|
|
226
|
-
* Creates a new {@link
|
|
227
|
-
* {@link
|
|
225
|
+
* Creates a new {@link securityRules.Ruleset `Ruleset`} from the given
|
|
226
|
+
* {@link securityRules.RulesFile `RuleFile`}.
|
|
228
227
|
*
|
|
229
228
|
* @param file Rules file to include in the new `Ruleset`.
|
|
230
229
|
* @returns A promise that fulfills with the newly created `Ruleset`.
|
|
@@ -241,7 +240,7 @@ var SecurityRules = /** @class */ (function () {
|
|
|
241
240
|
});
|
|
242
241
|
};
|
|
243
242
|
/**
|
|
244
|
-
* Deletes the {@link
|
|
243
|
+
* Deletes the {@link securityRules.Ruleset `Ruleset`} identified by the given
|
|
245
244
|
* name. The input name should be the short name string without the project ID
|
|
246
245
|
* prefix. For example, to delete the `projects/project-id/rulesets/my-ruleset`,
|
|
247
246
|
* pass the short name "my-ruleset". Rejects with a `not-found` error if the
|
|
@@ -306,14 +305,6 @@ var SecurityRules = /** @class */ (function () {
|
|
|
306
305
|
return SecurityRules;
|
|
307
306
|
}());
|
|
308
307
|
exports.SecurityRules = SecurityRules;
|
|
309
|
-
var SecurityRulesInternals = /** @class */ (function () {
|
|
310
|
-
function SecurityRulesInternals() {
|
|
311
|
-
}
|
|
312
|
-
SecurityRulesInternals.prototype.delete = function () {
|
|
313
|
-
return Promise.resolve();
|
|
314
|
-
};
|
|
315
|
-
return SecurityRulesInternals;
|
|
316
|
-
}());
|
|
317
308
|
function stripProjectIdPrefix(name) {
|
|
318
309
|
return name.split('/').pop();
|
|
319
310
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2020 Google Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { Bucket } from '@google-cloud/storage';
|
|
18
|
+
import { app } from '../firebase-namespace-api';
|
|
19
|
+
/**
|
|
20
|
+
* Gets the {@link storage.Storage `Storage`} service for the
|
|
21
|
+
* default app or a given app.
|
|
22
|
+
*
|
|
23
|
+
* `admin.storage()` can be called with no arguments to access the default
|
|
24
|
+
* app's {@link storage.Storage `Storage`} service or as
|
|
25
|
+
* `admin.storage(app)` to access the
|
|
26
|
+
* {@link storage.Storage `Storage`} service associated with a
|
|
27
|
+
* specific app.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```javascript
|
|
31
|
+
* // Get the Storage service for the default app
|
|
32
|
+
* var defaultStorage = admin.storage();
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```javascript
|
|
37
|
+
* // Get the Storage service for a given app
|
|
38
|
+
* var otherStorage = admin.storage(otherApp);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function storage(app?: app.App): storage.Storage;
|
|
42
|
+
export declare namespace storage {
|
|
43
|
+
/**
|
|
44
|
+
* The default `Storage` service if no
|
|
45
|
+
* app is provided or the `Storage` service associated with the provided
|
|
46
|
+
* app.
|
|
47
|
+
*/
|
|
48
|
+
interface Storage {
|
|
49
|
+
/**
|
|
50
|
+
* Optional app whose `Storage` service to
|
|
51
|
+
* return. If not provided, the default `Storage` service will be returned.
|
|
52
|
+
*/
|
|
53
|
+
app: app.App;
|
|
54
|
+
/**
|
|
55
|
+
* @returns A [Bucket](https://cloud.google.com/nodejs/docs/reference/storage/latest/Bucket)
|
|
56
|
+
* instance as defined in the `@google-cloud/storage` package.
|
|
57
|
+
*/
|
|
58
|
+
bucket(name?: string): Bucket;
|
|
59
|
+
}
|
|
60
|
+
}
|
package/lib/storage/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v9.
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2020 Google Inc.
|
|
@@ -16,12 +16,3 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.storage = void 0;
|
|
20
|
-
var firebaseAdmin = require("../index");
|
|
21
|
-
function storage(app) {
|
|
22
|
-
if (typeof (app) === 'undefined') {
|
|
23
|
-
app = firebaseAdmin.app();
|
|
24
|
-
}
|
|
25
|
-
return app.storage();
|
|
26
|
-
}
|
|
27
|
-
exports.storage = storage;
|
package/lib/storage/storage.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/*! firebase-admin v9.
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
|
+
* @license
|
|
4
5
|
* Copyright 2017 Google Inc.
|
|
5
6
|
*
|
|
6
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -21,23 +22,6 @@ var error_1 = require("../utils/error");
|
|
|
21
22
|
var credential_internal_1 = require("../credential/credential-internal");
|
|
22
23
|
var utils = require("../utils/index");
|
|
23
24
|
var validator = require("../utils/validator");
|
|
24
|
-
/**
|
|
25
|
-
* Internals of a Storage instance.
|
|
26
|
-
*/
|
|
27
|
-
var StorageInternals = /** @class */ (function () {
|
|
28
|
-
function StorageInternals() {
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Deletes the service and its associated resources.
|
|
32
|
-
*
|
|
33
|
-
* @return {Promise<()>} An empty Promise that will be fulfilled when the service is deleted.
|
|
34
|
-
*/
|
|
35
|
-
StorageInternals.prototype.delete = function () {
|
|
36
|
-
// There are no resources to clean up.
|
|
37
|
-
return Promise.resolve();
|
|
38
|
-
};
|
|
39
|
-
return StorageInternals;
|
|
40
|
-
}());
|
|
41
25
|
/**
|
|
42
26
|
* The default `Storage` service if no
|
|
43
27
|
* app is provided or the `Storage` service associated with the provided
|
|
@@ -50,7 +34,6 @@ var Storage = /** @class */ (function () {
|
|
|
50
34
|
* @internal
|
|
51
35
|
*/
|
|
52
36
|
function Storage(app) {
|
|
53
|
-
this.INTERNAL = new StorageInternals();
|
|
54
37
|
if (!validator.isNonNullObject(app) || !('options' in app)) {
|
|
55
38
|
throw new error_1.FirebaseError({
|
|
56
39
|
code: 'storage/invalid-argument',
|
package/lib/utils/api-request.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/*! firebase-admin v9.
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
|
+
* @license
|
|
4
5
|
* Copyright 2017 Google Inc.
|
|
5
6
|
*
|
|
6
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -663,17 +664,23 @@ var AuthorizedHttpClient = /** @class */ (function (_super) {
|
|
|
663
664
|
}
|
|
664
665
|
AuthorizedHttpClient.prototype.send = function (request) {
|
|
665
666
|
var _this = this;
|
|
666
|
-
return this.
|
|
667
|
+
return this.getToken().then(function (token) {
|
|
667
668
|
var requestCopy = Object.assign({}, request);
|
|
668
669
|
requestCopy.headers = Object.assign({}, request.headers);
|
|
669
670
|
var authHeader = 'Authorization';
|
|
670
|
-
requestCopy.headers[authHeader] = "Bearer " +
|
|
671
|
+
requestCopy.headers[authHeader] = "Bearer " + token;
|
|
671
672
|
if (!requestCopy.httpAgent && _this.app.options.httpAgent) {
|
|
672
673
|
requestCopy.httpAgent = _this.app.options.httpAgent;
|
|
673
674
|
}
|
|
674
675
|
return _super.prototype.send.call(_this, requestCopy);
|
|
675
676
|
});
|
|
676
677
|
};
|
|
678
|
+
AuthorizedHttpClient.prototype.getToken = function () {
|
|
679
|
+
return this.app.INTERNAL.getToken()
|
|
680
|
+
.then(function (accessTokenObj) {
|
|
681
|
+
return accessTokenObj.accessToken;
|
|
682
|
+
});
|
|
683
|
+
};
|
|
677
684
|
return AuthorizedHttpClient;
|
|
678
685
|
}(HttpClient));
|
|
679
686
|
exports.AuthorizedHttpClient = AuthorizedHttpClient;
|
package/lib/utils/deep-copy.js
CHANGED
package/lib/utils/error.js
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/*! firebase-admin v9.
|
|
1
|
+
/*! firebase-admin v9.5.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
|
+
* @license
|
|
4
5
|
* Copyright 2017 Google Inc.
|
|
5
6
|
*
|
|
6
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -69,9 +70,9 @@ exports.addReadonlyGetter = addReadonlyGetter;
|
|
|
69
70
|
* specified in either the Firebase app options, credentials or the local environment.
|
|
70
71
|
* Otherwise returns null.
|
|
71
72
|
*
|
|
72
|
-
* @param
|
|
73
|
+
* @param app A Firebase app to get the project ID from.
|
|
73
74
|
*
|
|
74
|
-
* @return
|
|
75
|
+
* @return A project ID string or null.
|
|
75
76
|
*/
|
|
76
77
|
function getExplicitProjectId(app) {
|
|
77
78
|
var options = app.options;
|
|
@@ -96,9 +97,9 @@ exports.getExplicitProjectId = getExplicitProjectId;
|
|
|
96
97
|
* configured, but the SDK has been initialized with ComputeEngineCredentials, this
|
|
97
98
|
* method attempts to discover the project ID from the local metadata service.
|
|
98
99
|
*
|
|
99
|
-
* @param
|
|
100
|
+
* @param app A Firebase app to get the project ID from.
|
|
100
101
|
*
|
|
101
|
-
* @return
|
|
102
|
+
* @return A project ID string or null.
|
|
102
103
|
*/
|
|
103
104
|
function findProjectId(app) {
|
|
104
105
|
var projectId = getExplicitProjectId(app);
|
package/lib/utils/validator.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-admin",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.5.0",
|
|
4
4
|
"description": "Firebase admin SDK for Node.js",
|
|
5
5
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
"test:coverage": "nyc npm run test:unit",
|
|
21
21
|
"lint:src": "eslint src/ --ext .ts",
|
|
22
22
|
"lint:test": "eslint test/ --ext .ts",
|
|
23
|
-
"apidocs": "node docgen/generate-docs.js --api node"
|
|
23
|
+
"apidocs": "node docgen/generate-docs.js --api node",
|
|
24
|
+
"api-extractor": "api-extractor run",
|
|
25
|
+
"api-extractor:local": "api-extractor run --local"
|
|
24
26
|
},
|
|
25
27
|
"nyc": {
|
|
26
28
|
"extension": [
|
|
@@ -54,21 +56,22 @@
|
|
|
54
56
|
],
|
|
55
57
|
"types": "./lib/index.d.ts",
|
|
56
58
|
"dependencies": {
|
|
57
|
-
"@firebase/database": "^0.
|
|
58
|
-
"@firebase/database-types": "^0.
|
|
59
|
+
"@firebase/database": "^0.8.1",
|
|
60
|
+
"@firebase/database-types": "^0.6.1",
|
|
59
61
|
"@types/node": "^10.10.0",
|
|
60
62
|
"dicer": "^0.3.0",
|
|
61
63
|
"jsonwebtoken": "^8.5.1",
|
|
62
64
|
"node-forge": "^0.10.0"
|
|
63
65
|
},
|
|
64
66
|
"optionalDependencies": {
|
|
65
|
-
"@google-cloud/firestore": "^4.
|
|
67
|
+
"@google-cloud/firestore": "^4.5.0",
|
|
66
68
|
"@google-cloud/storage": "^5.3.0"
|
|
67
69
|
},
|
|
68
70
|
"devDependencies": {
|
|
69
|
-
"@firebase/app": "^0.6.
|
|
70
|
-
"@firebase/auth": "^0.
|
|
71
|
+
"@firebase/app": "^0.6.13",
|
|
72
|
+
"@firebase/auth": "^0.16.2",
|
|
71
73
|
"@firebase/auth-types": "^0.10.1",
|
|
74
|
+
"@microsoft/api-extractor": "^7.11.2",
|
|
72
75
|
"@types/bcrypt": "^2.0.0",
|
|
73
76
|
"@types/chai": "^4.0.0",
|
|
74
77
|
"@types/chai-as-promised": "^7.1.0",
|
|
@@ -101,9 +104,9 @@
|
|
|
101
104
|
"jsdom": "^15.0.0",
|
|
102
105
|
"lodash": "^4.17.15",
|
|
103
106
|
"minimist": "^1.2.0",
|
|
104
|
-
"mocha": "^
|
|
107
|
+
"mocha": "^8.0.0",
|
|
105
108
|
"mz": "^2.7.0",
|
|
106
|
-
"nock": "^
|
|
109
|
+
"nock": "^13.0.0",
|
|
107
110
|
"npm-run-all": "^4.1.5",
|
|
108
111
|
"nyc": "^14.1.0",
|
|
109
112
|
"request": "^2.75.0",
|
|
@@ -111,9 +114,9 @@
|
|
|
111
114
|
"run-sequence": "^1.1.5",
|
|
112
115
|
"sinon": "^9.0.0",
|
|
113
116
|
"sinon-chai": "^3.0.0",
|
|
114
|
-
"ts-node": "^
|
|
115
|
-
"typedoc": "^0.
|
|
117
|
+
"ts-node": "^9.0.0",
|
|
118
|
+
"typedoc": "^0.19.2",
|
|
116
119
|
"typescript": "^3.7.3",
|
|
117
|
-
"yargs": "^
|
|
120
|
+
"yargs": "^16.0.0"
|
|
118
121
|
}
|
|
119
122
|
}
|