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,349 @@
|
|
|
1
|
+
/*! firebase-admin v9.12.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2017 Google Inc.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.FirebaseApp = exports.FirebaseAppInternals = void 0;
|
|
21
|
+
var credential_internal_1 = require("./credential/credential-internal");
|
|
22
|
+
var validator = require("./utils/validator");
|
|
23
|
+
var deep_copy_1 = require("./utils/deep-copy");
|
|
24
|
+
var error_1 = require("./utils/error");
|
|
25
|
+
var TOKEN_EXPIRY_THRESHOLD_MILLIS = 5 * 60 * 1000;
|
|
26
|
+
/**
|
|
27
|
+
* Internals of a FirebaseApp instance.
|
|
28
|
+
*/
|
|
29
|
+
var FirebaseAppInternals = /** @class */ (function () {
|
|
30
|
+
function FirebaseAppInternals(credential_) {
|
|
31
|
+
this.credential_ = credential_;
|
|
32
|
+
this.tokenListeners_ = [];
|
|
33
|
+
}
|
|
34
|
+
FirebaseAppInternals.prototype.getToken = function (forceRefresh) {
|
|
35
|
+
if (forceRefresh === void 0) { forceRefresh = false; }
|
|
36
|
+
if (forceRefresh || this.shouldRefresh()) {
|
|
37
|
+
return this.refreshToken();
|
|
38
|
+
}
|
|
39
|
+
return Promise.resolve(this.cachedToken_);
|
|
40
|
+
};
|
|
41
|
+
FirebaseAppInternals.prototype.getCachedToken = function () {
|
|
42
|
+
return this.cachedToken_ || null;
|
|
43
|
+
};
|
|
44
|
+
FirebaseAppInternals.prototype.refreshToken = function () {
|
|
45
|
+
var _this = this;
|
|
46
|
+
return Promise.resolve(this.credential_.getAccessToken())
|
|
47
|
+
.then(function (result) {
|
|
48
|
+
// Since the developer can provide the credential implementation, we want to weakly verify
|
|
49
|
+
// the return type until the type is properly exported.
|
|
50
|
+
if (!validator.isNonNullObject(result) ||
|
|
51
|
+
typeof result.expires_in !== 'number' ||
|
|
52
|
+
typeof result.access_token !== 'string') {
|
|
53
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, "Invalid access token generated: \"" + JSON.stringify(result) + "\". Valid access " +
|
|
54
|
+
'tokens must be an object with the "expires_in" (number) and "access_token" ' +
|
|
55
|
+
'(string) properties.');
|
|
56
|
+
}
|
|
57
|
+
var token = {
|
|
58
|
+
accessToken: result.access_token,
|
|
59
|
+
expirationTime: Date.now() + (result.expires_in * 1000),
|
|
60
|
+
};
|
|
61
|
+
if (!_this.cachedToken_
|
|
62
|
+
|| _this.cachedToken_.accessToken !== token.accessToken
|
|
63
|
+
|| _this.cachedToken_.expirationTime !== token.expirationTime) {
|
|
64
|
+
// Update the cache before firing listeners. Listeners may directly query the
|
|
65
|
+
// cached token state.
|
|
66
|
+
_this.cachedToken_ = token;
|
|
67
|
+
_this.tokenListeners_.forEach(function (listener) {
|
|
68
|
+
listener(token.accessToken);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return token;
|
|
72
|
+
})
|
|
73
|
+
.catch(function (error) {
|
|
74
|
+
var errorMessage = (typeof error === 'string') ? error : error.message;
|
|
75
|
+
errorMessage = 'Credential implementation provided to initializeApp() via the ' +
|
|
76
|
+
'"credential" property failed to fetch a valid Google OAuth2 access token with the ' +
|
|
77
|
+
("following error: \"" + errorMessage + "\".");
|
|
78
|
+
if (errorMessage.indexOf('invalid_grant') !== -1) {
|
|
79
|
+
errorMessage += ' There are two likely causes: (1) your server time is not properly ' +
|
|
80
|
+
'synced or (2) your certificate key file has been revoked. To solve (1), re-sync the ' +
|
|
81
|
+
'time on your server. To solve (2), make sure the key ID for your key file is still ' +
|
|
82
|
+
'present at https://console.firebase.google.com/iam-admin/serviceaccounts/project. If ' +
|
|
83
|
+
'not, generate a new key file at ' +
|
|
84
|
+
'https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk.';
|
|
85
|
+
}
|
|
86
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, errorMessage);
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
FirebaseAppInternals.prototype.shouldRefresh = function () {
|
|
90
|
+
return !this.cachedToken_ || (this.cachedToken_.expirationTime - Date.now()) <= TOKEN_EXPIRY_THRESHOLD_MILLIS;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Adds a listener that is called each time a token changes.
|
|
94
|
+
*
|
|
95
|
+
* @param listener The listener that will be called with each new token.
|
|
96
|
+
*/
|
|
97
|
+
FirebaseAppInternals.prototype.addAuthTokenListener = function (listener) {
|
|
98
|
+
this.tokenListeners_.push(listener);
|
|
99
|
+
if (this.cachedToken_) {
|
|
100
|
+
listener(this.cachedToken_.accessToken);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Removes a token listener.
|
|
105
|
+
*
|
|
106
|
+
* @param listener The listener to remove.
|
|
107
|
+
*/
|
|
108
|
+
FirebaseAppInternals.prototype.removeAuthTokenListener = function (listener) {
|
|
109
|
+
this.tokenListeners_ = this.tokenListeners_.filter(function (other) { return other !== listener; });
|
|
110
|
+
};
|
|
111
|
+
return FirebaseAppInternals;
|
|
112
|
+
}());
|
|
113
|
+
exports.FirebaseAppInternals = FirebaseAppInternals;
|
|
114
|
+
/**
|
|
115
|
+
* Global context object for a collection of services using a shared authentication state.
|
|
116
|
+
*/
|
|
117
|
+
var FirebaseApp = /** @class */ (function () {
|
|
118
|
+
function FirebaseApp(options, name, firebaseInternals_) {
|
|
119
|
+
this.firebaseInternals_ = firebaseInternals_;
|
|
120
|
+
this.services_ = {};
|
|
121
|
+
this.isDeleted_ = false;
|
|
122
|
+
this.name_ = name;
|
|
123
|
+
this.options_ = deep_copy_1.deepCopy(options);
|
|
124
|
+
if (!validator.isNonNullObject(this.options_)) {
|
|
125
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS, 'Invalid Firebase app options passed as the first argument to initializeApp() for the ' +
|
|
126
|
+
("app named \"" + this.name_ + "\". Options must be a non-null object."));
|
|
127
|
+
}
|
|
128
|
+
var hasCredential = ('credential' in this.options_);
|
|
129
|
+
if (!hasCredential) {
|
|
130
|
+
this.options_.credential = credential_internal_1.getApplicationDefault(this.options_.httpAgent);
|
|
131
|
+
}
|
|
132
|
+
var credential = this.options_.credential;
|
|
133
|
+
if (typeof credential !== 'object' || credential === null || typeof credential.getAccessToken !== 'function') {
|
|
134
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS, 'Invalid Firebase app options passed as the first argument to initializeApp() for the ' +
|
|
135
|
+
("app named \"" + this.name_ + "\". The \"credential\" property must be an object which implements ") +
|
|
136
|
+
'the Credential interface.');
|
|
137
|
+
}
|
|
138
|
+
this.INTERNAL = new FirebaseAppInternals(credential);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Returns the Auth service instance associated with this app.
|
|
142
|
+
*
|
|
143
|
+
* @return The Auth service instance of this app.
|
|
144
|
+
*/
|
|
145
|
+
FirebaseApp.prototype.auth = function () {
|
|
146
|
+
var _this = this;
|
|
147
|
+
return this.ensureService_('auth', function () {
|
|
148
|
+
var authService = require('./auth/auth').Auth;
|
|
149
|
+
return new authService(_this);
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Returns the Database service for the specified URL, and the current app.
|
|
154
|
+
*
|
|
155
|
+
* @return The Database service instance of this app.
|
|
156
|
+
*/
|
|
157
|
+
FirebaseApp.prototype.database = function (url) {
|
|
158
|
+
var _this = this;
|
|
159
|
+
var service = this.ensureService_('database', function () {
|
|
160
|
+
var dbService = require('./database/database-internal').DatabaseService;
|
|
161
|
+
return new dbService(_this);
|
|
162
|
+
});
|
|
163
|
+
return service.getDatabase(url);
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Returns the Messaging service instance associated with this app.
|
|
167
|
+
*
|
|
168
|
+
* @return The Messaging service instance of this app.
|
|
169
|
+
*/
|
|
170
|
+
FirebaseApp.prototype.messaging = function () {
|
|
171
|
+
var _this = this;
|
|
172
|
+
return this.ensureService_('messaging', function () {
|
|
173
|
+
var messagingService = require('./messaging/messaging').Messaging;
|
|
174
|
+
return new messagingService(_this);
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Returns the Storage service instance associated with this app.
|
|
179
|
+
*
|
|
180
|
+
* @return The Storage service instance of this app.
|
|
181
|
+
*/
|
|
182
|
+
FirebaseApp.prototype.storage = function () {
|
|
183
|
+
var _this = this;
|
|
184
|
+
return this.ensureService_('storage', function () {
|
|
185
|
+
var storageService = require('./storage/storage').Storage;
|
|
186
|
+
return new storageService(_this);
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
FirebaseApp.prototype.firestore = function () {
|
|
190
|
+
var _this = this;
|
|
191
|
+
var service = this.ensureService_('firestore', function () {
|
|
192
|
+
var firestoreService = require('./firestore/firestore-internal').FirestoreService;
|
|
193
|
+
return new firestoreService(_this);
|
|
194
|
+
});
|
|
195
|
+
return service.client;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Returns the `Installations` service instance associated with this app.
|
|
199
|
+
*
|
|
200
|
+
* @return The `Installations` service instance of this app.
|
|
201
|
+
*/
|
|
202
|
+
FirebaseApp.prototype.installations = function () {
|
|
203
|
+
var _this = this;
|
|
204
|
+
return this.ensureService_('installations', function () {
|
|
205
|
+
var fisService = require('./installations/installations').Installations;
|
|
206
|
+
return new fisService(_this);
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Returns the InstanceId service instance associated with this app.
|
|
211
|
+
*
|
|
212
|
+
* This API is deprecated. Use the `installations()` API instead.
|
|
213
|
+
*
|
|
214
|
+
* @return The InstanceId service instance of this app.
|
|
215
|
+
*/
|
|
216
|
+
FirebaseApp.prototype.instanceId = function () {
|
|
217
|
+
var _this = this;
|
|
218
|
+
return this.ensureService_('iid', function () {
|
|
219
|
+
var iidService = require('./instance-id/instance-id').InstanceId;
|
|
220
|
+
return new iidService(_this);
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Returns the MachineLearning service instance associated with this app.
|
|
225
|
+
*
|
|
226
|
+
* @return The Machine Learning service instance of this app
|
|
227
|
+
*/
|
|
228
|
+
FirebaseApp.prototype.machineLearning = function () {
|
|
229
|
+
var _this = this;
|
|
230
|
+
return this.ensureService_('machine-learning', function () {
|
|
231
|
+
var machineLearningService = require('./machine-learning/machine-learning').MachineLearning;
|
|
232
|
+
return new machineLearningService(_this);
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Returns the ProjectManagement service instance associated with this app.
|
|
237
|
+
*
|
|
238
|
+
* @return The ProjectManagement service instance of this app.
|
|
239
|
+
*/
|
|
240
|
+
FirebaseApp.prototype.projectManagement = function () {
|
|
241
|
+
var _this = this;
|
|
242
|
+
return this.ensureService_('project-management', function () {
|
|
243
|
+
var projectManagementService = require('./project-management/project-management').ProjectManagement;
|
|
244
|
+
return new projectManagementService(_this);
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Returns the SecurityRules service instance associated with this app.
|
|
249
|
+
*
|
|
250
|
+
* @return The SecurityRules service instance of this app.
|
|
251
|
+
*/
|
|
252
|
+
FirebaseApp.prototype.securityRules = function () {
|
|
253
|
+
var _this = this;
|
|
254
|
+
return this.ensureService_('security-rules', function () {
|
|
255
|
+
var securityRulesService = require('./security-rules/security-rules').SecurityRules;
|
|
256
|
+
return new securityRulesService(_this);
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* Returns the RemoteConfig service instance associated with this app.
|
|
261
|
+
*
|
|
262
|
+
* @return The RemoteConfig service instance of this app.
|
|
263
|
+
*/
|
|
264
|
+
FirebaseApp.prototype.remoteConfig = function () {
|
|
265
|
+
var _this = this;
|
|
266
|
+
return this.ensureService_('remoteConfig', function () {
|
|
267
|
+
var remoteConfigService = require('./remote-config/remote-config').RemoteConfig;
|
|
268
|
+
return new remoteConfigService(_this);
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* Returns the AppCheck service instance associated with this app.
|
|
273
|
+
*
|
|
274
|
+
* @return The AppCheck service instance of this app.
|
|
275
|
+
*/
|
|
276
|
+
FirebaseApp.prototype.appCheck = function () {
|
|
277
|
+
var _this = this;
|
|
278
|
+
return this.ensureService_('appCheck', function () {
|
|
279
|
+
var appCheckService = require('./app-check/app-check').AppCheck;
|
|
280
|
+
return new appCheckService(_this);
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
Object.defineProperty(FirebaseApp.prototype, "name", {
|
|
284
|
+
/**
|
|
285
|
+
* Returns the name of the FirebaseApp instance.
|
|
286
|
+
*
|
|
287
|
+
* @return The name of the FirebaseApp instance.
|
|
288
|
+
*/
|
|
289
|
+
get: function () {
|
|
290
|
+
this.checkDestroyed_();
|
|
291
|
+
return this.name_;
|
|
292
|
+
},
|
|
293
|
+
enumerable: false,
|
|
294
|
+
configurable: true
|
|
295
|
+
});
|
|
296
|
+
Object.defineProperty(FirebaseApp.prototype, "options", {
|
|
297
|
+
/**
|
|
298
|
+
* Returns the options for the FirebaseApp instance.
|
|
299
|
+
*
|
|
300
|
+
* @return The options for the FirebaseApp instance.
|
|
301
|
+
*/
|
|
302
|
+
get: function () {
|
|
303
|
+
this.checkDestroyed_();
|
|
304
|
+
return deep_copy_1.deepCopy(this.options_);
|
|
305
|
+
},
|
|
306
|
+
enumerable: false,
|
|
307
|
+
configurable: true
|
|
308
|
+
});
|
|
309
|
+
/**
|
|
310
|
+
* Deletes the FirebaseApp instance.
|
|
311
|
+
*
|
|
312
|
+
* @return An empty Promise fulfilled once the FirebaseApp instance is deleted.
|
|
313
|
+
*/
|
|
314
|
+
FirebaseApp.prototype.delete = function () {
|
|
315
|
+
var _this = this;
|
|
316
|
+
this.checkDestroyed_();
|
|
317
|
+
this.firebaseInternals_.removeApp(this.name_);
|
|
318
|
+
return Promise.all(Object.keys(this.services_).map(function (serviceName) {
|
|
319
|
+
var service = _this.services_[serviceName];
|
|
320
|
+
if (isStateful(service)) {
|
|
321
|
+
return service.delete();
|
|
322
|
+
}
|
|
323
|
+
return Promise.resolve();
|
|
324
|
+
})).then(function () {
|
|
325
|
+
_this.services_ = {};
|
|
326
|
+
_this.isDeleted_ = true;
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
FirebaseApp.prototype.ensureService_ = function (serviceName, initializer) {
|
|
330
|
+
this.checkDestroyed_();
|
|
331
|
+
if (!(serviceName in this.services_)) {
|
|
332
|
+
this.services_[serviceName] = initializer();
|
|
333
|
+
}
|
|
334
|
+
return this.services_[serviceName];
|
|
335
|
+
};
|
|
336
|
+
/**
|
|
337
|
+
* Throws an Error if the FirebaseApp instance has already been deleted.
|
|
338
|
+
*/
|
|
339
|
+
FirebaseApp.prototype.checkDestroyed_ = function () {
|
|
340
|
+
if (this.isDeleted_) {
|
|
341
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.APP_DELETED, "Firebase app named \"" + this.name_ + "\" has already been deleted.");
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
return FirebaseApp;
|
|
345
|
+
}());
|
|
346
|
+
exports.FirebaseApp = FirebaseApp;
|
|
347
|
+
function isStateful(service) {
|
|
348
|
+
return typeof service.delete === 'function';
|
|
349
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
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 { Agent } from 'http';
|
|
19
|
+
import { appCheck } from './app-check/index';
|
|
20
|
+
import { auth } from './auth/index';
|
|
21
|
+
import { credential } from './credential/index';
|
|
22
|
+
import { database } from './database/index';
|
|
23
|
+
import { firestore } from './firestore/index';
|
|
24
|
+
import { installations } from './installations/index';
|
|
25
|
+
import { instanceId } from './instance-id/index';
|
|
26
|
+
import { machineLearning } from './machine-learning/index';
|
|
27
|
+
import { messaging } from './messaging/index';
|
|
28
|
+
import { projectManagement } from './project-management/index';
|
|
29
|
+
import { remoteConfig } from './remote-config/index';
|
|
30
|
+
import { securityRules } from './security-rules/index';
|
|
31
|
+
import { storage } from './storage/index';
|
|
32
|
+
/**
|
|
33
|
+
* `FirebaseError` is a subclass of the standard JavaScript `Error` object. In
|
|
34
|
+
* addition to a message string and stack trace, it contains a string code.
|
|
35
|
+
*/
|
|
36
|
+
export interface FirebaseError {
|
|
37
|
+
/**
|
|
38
|
+
* Error codes are strings using the following format: `"service/string-code"`.
|
|
39
|
+
* Some examples include `"auth/invalid-uid"` and
|
|
40
|
+
* `"messaging/invalid-recipient"`.
|
|
41
|
+
*
|
|
42
|
+
* While the message for a given error can change, the code will remain the same
|
|
43
|
+
* between backward-compatible versions of the Firebase SDK.
|
|
44
|
+
*/
|
|
45
|
+
code: string;
|
|
46
|
+
/**
|
|
47
|
+
* An explanatory message for the error that just occurred.
|
|
48
|
+
*
|
|
49
|
+
* This message is designed to be helpful to you, the developer. Because
|
|
50
|
+
* it generally does not convey meaningful information to end users,
|
|
51
|
+
* this message should not be displayed in your application.
|
|
52
|
+
*/
|
|
53
|
+
message: string;
|
|
54
|
+
/**
|
|
55
|
+
* A string value containing the execution backtrace when the error originally
|
|
56
|
+
* occurred.
|
|
57
|
+
*
|
|
58
|
+
* This information can be useful to you and can be sent to
|
|
59
|
+
* {@link https://firebase.google.com/support/ Firebase Support} to help
|
|
60
|
+
* explain the cause of an error.
|
|
61
|
+
*/
|
|
62
|
+
stack?: string;
|
|
63
|
+
/**
|
|
64
|
+
* @return A JSON-serializable representation of this object.
|
|
65
|
+
*/
|
|
66
|
+
toJSON(): object;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Composite type which includes both a `FirebaseError` object and an index
|
|
70
|
+
* which can be used to get the errored item.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```javascript
|
|
74
|
+
* var registrationTokens = [token1, token2, token3];
|
|
75
|
+
* admin.messaging().subscribeToTopic(registrationTokens, 'topic-name')
|
|
76
|
+
* .then(function(response) {
|
|
77
|
+
* if (response.failureCount > 0) {
|
|
78
|
+
* console.log("Following devices unsucessfully subscribed to topic:");
|
|
79
|
+
* response.errors.forEach(function(error) {
|
|
80
|
+
* var invalidToken = registrationTokens[error.index];
|
|
81
|
+
* console.log(invalidToken, error.error);
|
|
82
|
+
* });
|
|
83
|
+
* } else {
|
|
84
|
+
* console.log("All devices successfully subscribed to topic:", response);
|
|
85
|
+
* }
|
|
86
|
+
* })
|
|
87
|
+
* .catch(function(error) {
|
|
88
|
+
* console.log("Error subscribing to topic:", error);
|
|
89
|
+
* });
|
|
90
|
+
*```
|
|
91
|
+
*/
|
|
92
|
+
export interface FirebaseArrayIndexError {
|
|
93
|
+
/**
|
|
94
|
+
* The index of the errored item within the original array passed as part of the
|
|
95
|
+
* called API method.
|
|
96
|
+
*/
|
|
97
|
+
index: number;
|
|
98
|
+
/**
|
|
99
|
+
* The error object.
|
|
100
|
+
*/
|
|
101
|
+
error: FirebaseError;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Available options to pass to [`initializeApp()`](admin#.initializeApp).
|
|
105
|
+
*/
|
|
106
|
+
export interface AppOptions {
|
|
107
|
+
/**
|
|
108
|
+
* A {@link credential.Credential `Credential`} object used to
|
|
109
|
+
* authenticate the Admin SDK.
|
|
110
|
+
*
|
|
111
|
+
* See [Initialize the SDK](/docs/admin/setup#initialize_the_sdk) for detailed
|
|
112
|
+
* documentation and code samples.
|
|
113
|
+
*/
|
|
114
|
+
credential?: credential.Credential;
|
|
115
|
+
/**
|
|
116
|
+
* The object to use as the [`auth`](/docs/reference/security/database/#auth)
|
|
117
|
+
* variable in your Realtime Database Rules when the Admin SDK reads from or
|
|
118
|
+
* writes to the Realtime Database. This allows you to downscope the Admin SDK
|
|
119
|
+
* from its default full read and write privileges.
|
|
120
|
+
*
|
|
121
|
+
* You can pass `null` to act as an unauthenticated client.
|
|
122
|
+
*
|
|
123
|
+
* See
|
|
124
|
+
* [Authenticate with limited privileges](/docs/database/admin/start#authenticate-with-limited-privileges)
|
|
125
|
+
* for detailed documentation and code samples.
|
|
126
|
+
*/
|
|
127
|
+
databaseAuthVariableOverride?: object | null;
|
|
128
|
+
/**
|
|
129
|
+
* The URL of the Realtime Database from which to read and write data.
|
|
130
|
+
*/
|
|
131
|
+
databaseURL?: string;
|
|
132
|
+
/**
|
|
133
|
+
* The ID of the service account to be used for signing custom tokens. This
|
|
134
|
+
* can be found in the `client_email` field of a service account JSON file.
|
|
135
|
+
*/
|
|
136
|
+
serviceAccountId?: string;
|
|
137
|
+
/**
|
|
138
|
+
* The name of the Google Cloud Storage bucket used for storing application data.
|
|
139
|
+
* Use only the bucket name without any prefixes or additions (do *not* prefix
|
|
140
|
+
* the name with "gs://").
|
|
141
|
+
*/
|
|
142
|
+
storageBucket?: string;
|
|
143
|
+
/**
|
|
144
|
+
* The ID of the Google Cloud project associated with the App.
|
|
145
|
+
*/
|
|
146
|
+
projectId?: string;
|
|
147
|
+
/**
|
|
148
|
+
* An [HTTP Agent](https://nodejs.org/api/http.html#http_class_http_agent)
|
|
149
|
+
* to be used when making outgoing HTTP calls. This Agent instance is used
|
|
150
|
+
* by all services that make REST calls (e.g. `auth`, `messaging`,
|
|
151
|
+
* `projectManagement`).
|
|
152
|
+
*
|
|
153
|
+
* Realtime Database and Firestore use other means of communicating with
|
|
154
|
+
* the backend servers, so they do not use this HTTP Agent. `Credential`
|
|
155
|
+
* instances also do not use this HTTP Agent, but instead support
|
|
156
|
+
* specifying an HTTP Agent in the corresponding factory methods.
|
|
157
|
+
*/
|
|
158
|
+
httpAgent?: Agent;
|
|
159
|
+
}
|
|
160
|
+
export declare namespace app {
|
|
161
|
+
/**
|
|
162
|
+
* A Firebase app holds the initialization information for a collection of
|
|
163
|
+
* services.
|
|
164
|
+
*
|
|
165
|
+
* Do not call this constructor directly. Instead, use
|
|
166
|
+
* {@link
|
|
167
|
+
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
168
|
+
* `admin.initializeApp()`}
|
|
169
|
+
* to create an app.
|
|
170
|
+
*/
|
|
171
|
+
interface App {
|
|
172
|
+
/**
|
|
173
|
+
* The (read-only) name for this app.
|
|
174
|
+
*
|
|
175
|
+
* The default app's name is `"[DEFAULT]"`.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```javascript
|
|
179
|
+
* // The default app's name is "[DEFAULT]"
|
|
180
|
+
* admin.initializeApp(defaultAppConfig);
|
|
181
|
+
* console.log(admin.app().name); // "[DEFAULT]"
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```javascript
|
|
186
|
+
* // A named app's name is what you provide to initializeApp()
|
|
187
|
+
* var otherApp = admin.initializeApp(otherAppConfig, "other");
|
|
188
|
+
* console.log(otherApp.name); // "other"
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
name: string;
|
|
192
|
+
/**
|
|
193
|
+
* The (read-only) configuration options for this app. These are the original
|
|
194
|
+
* parameters given in
|
|
195
|
+
* {@link
|
|
196
|
+
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
197
|
+
* `admin.initializeApp()`}.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```javascript
|
|
201
|
+
* var app = admin.initializeApp(config);
|
|
202
|
+
* console.log(app.options.credential === config.credential); // true
|
|
203
|
+
* console.log(app.options.databaseURL === config.databaseURL); // true
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
options: AppOptions;
|
|
207
|
+
appCheck(): appCheck.AppCheck;
|
|
208
|
+
auth(): auth.Auth;
|
|
209
|
+
database(url?: string): database.Database;
|
|
210
|
+
firestore(): firestore.Firestore;
|
|
211
|
+
installations(): installations.Installations;
|
|
212
|
+
/** @deprecated */
|
|
213
|
+
instanceId(): instanceId.InstanceId;
|
|
214
|
+
machineLearning(): machineLearning.MachineLearning;
|
|
215
|
+
messaging(): messaging.Messaging;
|
|
216
|
+
projectManagement(): projectManagement.ProjectManagement;
|
|
217
|
+
remoteConfig(): remoteConfig.RemoteConfig;
|
|
218
|
+
securityRules(): securityRules.SecurityRules;
|
|
219
|
+
storage(): storage.Storage;
|
|
220
|
+
/**
|
|
221
|
+
* Renders this local `FirebaseApp` unusable and frees the resources of
|
|
222
|
+
* all associated services (though it does *not* clean up any backend
|
|
223
|
+
* resources). When running the SDK locally, this method
|
|
224
|
+
* must be called to ensure graceful termination of the process.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```javascript
|
|
228
|
+
* app.delete()
|
|
229
|
+
* .then(function() {
|
|
230
|
+
* console.log("App deleted successfully");
|
|
231
|
+
* })
|
|
232
|
+
* .catch(function(error) {
|
|
233
|
+
* console.log("Error deleting app:", error);
|
|
234
|
+
* });
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
delete(): Promise<void>;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
export declare const SDK_VERSION: string;
|
|
241
|
+
export declare const apps: (app.App | null)[];
|
|
242
|
+
export declare function app(name?: string): app.App;
|
|
243
|
+
export declare function initializeApp(options?: AppOptions, name?: string): app.App;
|
|
@@ -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 });
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
|
|
18
|
+
export * from './credential/index';
|
|
19
|
+
export * from './firebase-namespace-api';
|
|
20
|
+
export * from './app-check/index';
|
|
21
|
+
export * from './auth/index';
|
|
22
|
+
export * from './database/index';
|
|
23
|
+
export * from './firestore/index';
|
|
24
|
+
export * from './installations/index';
|
|
25
|
+
export * from './instance-id/index';
|
|
26
|
+
export * from './machine-learning/index';
|
|
27
|
+
export * from './messaging/index';
|
|
28
|
+
export * from './project-management/index';
|
|
29
|
+
export * from './remote-config/index';
|
|
30
|
+
export * from './security-rules/index';
|
|
31
|
+
export * from './storage/index';
|