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,169 @@
|
|
|
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 { Agent } from 'http';
|
|
19
|
+
export interface ServiceAccount {
|
|
20
|
+
projectId?: string;
|
|
21
|
+
clientEmail?: string;
|
|
22
|
+
privateKey?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Interface for Google OAuth 2.0 access tokens.
|
|
26
|
+
*/
|
|
27
|
+
export interface GoogleOAuthAccessToken {
|
|
28
|
+
access_token: string;
|
|
29
|
+
expires_in: number;
|
|
30
|
+
}
|
|
31
|
+
export declare namespace credential {
|
|
32
|
+
/**
|
|
33
|
+
* Interface that provides Google OAuth2 access tokens used to authenticate
|
|
34
|
+
* with Firebase services.
|
|
35
|
+
*
|
|
36
|
+
* In most cases, you will not need to implement this yourself and can instead
|
|
37
|
+
* use the default implementations provided by
|
|
38
|
+
* {@link credential `admin.credential`}.
|
|
39
|
+
*/
|
|
40
|
+
interface Credential {
|
|
41
|
+
/**
|
|
42
|
+
* Returns a Google OAuth2 access token object used to authenticate with
|
|
43
|
+
* Firebase services.
|
|
44
|
+
*
|
|
45
|
+
* This object contains the following properties:
|
|
46
|
+
* * `access_token` (`string`): The actual Google OAuth2 access token.
|
|
47
|
+
* * `expires_in` (`number`): The number of seconds from when the token was
|
|
48
|
+
* issued that it expires.
|
|
49
|
+
*
|
|
50
|
+
* @return A Google OAuth2 access token object.
|
|
51
|
+
*/
|
|
52
|
+
getAccessToken(): Promise<GoogleOAuthAccessToken>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns a credential created from the
|
|
56
|
+
* {@link
|
|
57
|
+
* https://developers.google.com/identity/protocols/application-default-credentials
|
|
58
|
+
* Google Application Default Credentials}
|
|
59
|
+
* that grants admin access to Firebase services. This credential can be used
|
|
60
|
+
* in the call to
|
|
61
|
+
* {@link
|
|
62
|
+
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
63
|
+
* `admin.initializeApp()`}.
|
|
64
|
+
*
|
|
65
|
+
* Google Application Default Credentials are available on any Google
|
|
66
|
+
* infrastructure, such as Google App Engine and Google Compute Engine.
|
|
67
|
+
*
|
|
68
|
+
* See
|
|
69
|
+
* {@link
|
|
70
|
+
* https://firebase.google.com/docs/admin/setup#initialize_the_sdk
|
|
71
|
+
* Initialize the SDK}
|
|
72
|
+
* for more details.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```javascript
|
|
76
|
+
* admin.initializeApp({
|
|
77
|
+
* credential: admin.credential.applicationDefault(),
|
|
78
|
+
* databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @param {!Object=} httpAgent Optional [HTTP Agent](https://nodejs.org/api/http.html#http_class_http_agent)
|
|
83
|
+
* to be used when retrieving access tokens from Google token servers.
|
|
84
|
+
*
|
|
85
|
+
* @return {!admin.credential.Credential} A credential authenticated via Google
|
|
86
|
+
* Application Default Credentials that can be used to initialize an app.
|
|
87
|
+
*/
|
|
88
|
+
function applicationDefault(httpAgent?: Agent): Credential;
|
|
89
|
+
/**
|
|
90
|
+
* Returns a credential created from the provided service account that grants
|
|
91
|
+
* admin access to Firebase services. This credential can be used in the call
|
|
92
|
+
* to
|
|
93
|
+
* {@link
|
|
94
|
+
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
95
|
+
* `admin.initializeApp()`}.
|
|
96
|
+
*
|
|
97
|
+
* See
|
|
98
|
+
* {@link
|
|
99
|
+
* https://firebase.google.com/docs/admin/setup#initialize_the_sdk
|
|
100
|
+
* Initialize the SDK}
|
|
101
|
+
* for more details.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```javascript
|
|
105
|
+
* // Providing a path to a service account key JSON file
|
|
106
|
+
* var serviceAccount = require("path/to/serviceAccountKey.json");
|
|
107
|
+
* admin.initializeApp({
|
|
108
|
+
* credential: admin.credential.cert(serviceAccount),
|
|
109
|
+
* databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```javascript
|
|
115
|
+
* // Providing a service account object inline
|
|
116
|
+
* admin.initializeApp({
|
|
117
|
+
* credential: admin.credential.cert({
|
|
118
|
+
* projectId: "<PROJECT_ID>",
|
|
119
|
+
* clientEmail: "foo@<PROJECT_ID>.iam.gserviceaccount.com",
|
|
120
|
+
* privateKey: "-----BEGIN PRIVATE KEY-----<KEY>-----END PRIVATE KEY-----\n"
|
|
121
|
+
* }),
|
|
122
|
+
* databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @param serviceAccountPathOrObject The path to a service
|
|
127
|
+
* account key JSON file or an object representing a service account key.
|
|
128
|
+
* @param httpAgent Optional [HTTP Agent](https://nodejs.org/api/http.html#http_class_http_agent)
|
|
129
|
+
* to be used when retrieving access tokens from Google token servers.
|
|
130
|
+
*
|
|
131
|
+
* @return A credential authenticated via the
|
|
132
|
+
* provided service account that can be used to initialize an app.
|
|
133
|
+
*/
|
|
134
|
+
function cert(serviceAccountPathOrObject: string | ServiceAccount, httpAgent?: Agent): Credential;
|
|
135
|
+
/**
|
|
136
|
+
* Returns a credential created from the provided refresh token that grants
|
|
137
|
+
* admin access to Firebase services. This credential can be used in the call
|
|
138
|
+
* to
|
|
139
|
+
* {@link
|
|
140
|
+
* https://firebase.google.com/docs/reference/admin/node/admin#.initializeApp
|
|
141
|
+
* `admin.initializeApp()`}.
|
|
142
|
+
*
|
|
143
|
+
* See
|
|
144
|
+
* {@link
|
|
145
|
+
* https://firebase.google.com/docs/admin/setup#initialize_the_sdk
|
|
146
|
+
* Initialize the SDK}
|
|
147
|
+
* for more details.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```javascript
|
|
151
|
+
* // Providing a path to a refresh token JSON file
|
|
152
|
+
* var refreshToken = require("path/to/refreshToken.json");
|
|
153
|
+
* admin.initializeApp({
|
|
154
|
+
* credential: admin.credential.refreshToken(refreshToken),
|
|
155
|
+
* databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
|
|
156
|
+
* });
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* @param refreshTokenPathOrObject The path to a Google
|
|
160
|
+
* OAuth2 refresh token JSON file or an object representing a Google OAuth2
|
|
161
|
+
* refresh token.
|
|
162
|
+
* @param httpAgent Optional [HTTP Agent](https://nodejs.org/api/http.html#http_class_http_agent)
|
|
163
|
+
* to be used when retrieving access tokens from Google token servers.
|
|
164
|
+
*
|
|
165
|
+
* @return A credential authenticated via the
|
|
166
|
+
* provided service account that can be used to initialize an app.
|
|
167
|
+
*/
|
|
168
|
+
function refreshToken(refreshTokenPathOrObject: string | object, httpAgent?: Agent): Credential;
|
|
169
|
+
}
|
package/lib/credential/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,20 +16,8 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
20
|
-
var credentialApi = require("./credential");
|
|
21
|
-
/**
|
|
22
|
-
* Temporarily, admin.credential is used as the namespace name because we
|
|
23
|
-
* cannot barrel re-export the contents from credential.ts, and we want it to
|
|
24
|
-
* match the namespacing in the re-export inside src/index.d.ts
|
|
25
|
-
*/
|
|
19
|
+
exports.credential = void 0;
|
|
26
20
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
27
|
-
var
|
|
28
|
-
(function (
|
|
29
|
-
|
|
30
|
-
(function (credential) {
|
|
31
|
-
credential.applicationDefault = credentialApi.applicationDefault;
|
|
32
|
-
credential.cert = credentialApi.cert;
|
|
33
|
-
credential.refreshToken = credentialApi.refreshToken;
|
|
34
|
-
})(credential = admin.credential || (admin.credential = {}));
|
|
35
|
-
})(admin = exports.admin || (exports.admin = {}));
|
|
21
|
+
var credential;
|
|
22
|
+
(function (credential) {
|
|
23
|
+
})(credential = exports.credential || (exports.credential = {}));
|
|
@@ -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.
|
|
@@ -23,31 +23,9 @@ var error_1 = require("../utils/error");
|
|
|
23
23
|
var validator = require("../utils/validator");
|
|
24
24
|
var api_request_1 = require("../utils/api-request");
|
|
25
25
|
var index_1 = require("../utils/index");
|
|
26
|
-
/**
|
|
27
|
-
* Internals of a Database instance.
|
|
28
|
-
*/
|
|
29
|
-
var DatabaseInternals = /** @class */ (function () {
|
|
30
|
-
function DatabaseInternals() {
|
|
31
|
-
this.databases = {};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Deletes the service and its associated resources.
|
|
35
|
-
*
|
|
36
|
-
* @return {Promise<()>} An empty Promise that will be fulfilled when the service is deleted.
|
|
37
|
-
*/
|
|
38
|
-
DatabaseInternals.prototype.delete = function () {
|
|
39
|
-
for (var _i = 0, _a = Object.keys(this.databases); _i < _a.length; _i++) {
|
|
40
|
-
var dbUrl = _a[_i];
|
|
41
|
-
var db = this.databases[dbUrl];
|
|
42
|
-
db.INTERNAL.delete();
|
|
43
|
-
}
|
|
44
|
-
return Promise.resolve(undefined);
|
|
45
|
-
};
|
|
46
|
-
return DatabaseInternals;
|
|
47
|
-
}());
|
|
48
26
|
var DatabaseService = /** @class */ (function () {
|
|
49
27
|
function DatabaseService(app) {
|
|
50
|
-
this.
|
|
28
|
+
this.databases = {};
|
|
51
29
|
if (!validator.isNonNullObject(app) || !('options' in app)) {
|
|
52
30
|
throw new error_1.FirebaseDatabaseError({
|
|
53
31
|
code: 'invalid-argument',
|
|
@@ -56,6 +34,21 @@ var DatabaseService = /** @class */ (function () {
|
|
|
56
34
|
}
|
|
57
35
|
this.appInternal = app;
|
|
58
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
DatabaseService.prototype.delete = function () {
|
|
41
|
+
var _this = this;
|
|
42
|
+
var promises = [];
|
|
43
|
+
for (var _i = 0, _a = Object.keys(this.databases); _i < _a.length; _i++) {
|
|
44
|
+
var dbUrl = _a[_i];
|
|
45
|
+
var db = this.databases[dbUrl];
|
|
46
|
+
promises.push(db.INTERNAL.delete());
|
|
47
|
+
}
|
|
48
|
+
return Promise.all(promises).then(function () {
|
|
49
|
+
_this.databases = {};
|
|
50
|
+
});
|
|
51
|
+
};
|
|
59
52
|
Object.defineProperty(DatabaseService.prototype, "app", {
|
|
60
53
|
/**
|
|
61
54
|
* Returns the app associated with this DatabaseService instance.
|
|
@@ -76,7 +69,7 @@ var DatabaseService = /** @class */ (function () {
|
|
|
76
69
|
message: 'Database URL must be a valid, non-empty URL string.',
|
|
77
70
|
});
|
|
78
71
|
}
|
|
79
|
-
var db = this.
|
|
72
|
+
var db = this.databases[dbUrl];
|
|
80
73
|
if (typeof db === 'undefined') {
|
|
81
74
|
var rtdb = require('@firebase/database'); // eslint-disable-line @typescript-eslint/no-var-requires
|
|
82
75
|
db = rtdb.initStandalone(this.appInternal, dbUrl, index_1.getSdkVersion()).instance;
|
|
@@ -90,7 +83,7 @@ var DatabaseService = /** @class */ (function () {
|
|
|
90
83
|
db.setRules = function (source) {
|
|
91
84
|
return rulesClient_1.setRules(source);
|
|
92
85
|
};
|
|
93
|
-
this.
|
|
86
|
+
this.databases[dbUrl] = db;
|
|
94
87
|
}
|
|
95
88
|
return db;
|
|
96
89
|
};
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
import * as rtdb from '@firebase/database-types';
|
|
20
|
+
/**
|
|
21
|
+
* Gets the {@link database.Database `Database`} service for the default
|
|
22
|
+
* app or a given app.
|
|
23
|
+
*
|
|
24
|
+
* `admin.database()` can be called with no arguments to access the default
|
|
25
|
+
* app's {@link database.Database `Database`} service or as
|
|
26
|
+
* `admin.database(app)` to access the
|
|
27
|
+
* {@link database.Database `Database`} service associated with a specific
|
|
28
|
+
* app.
|
|
29
|
+
*
|
|
30
|
+
* `admin.database` is also a namespace that can be used to access global
|
|
31
|
+
* constants and methods associated with the `Database` service.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```javascript
|
|
35
|
+
* // Get the Database service for the default app
|
|
36
|
+
* var defaultDatabase = admin.database();
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```javascript
|
|
41
|
+
* // Get the Database service for a specific app
|
|
42
|
+
* var otherDatabase = admin.database(app);
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @param App whose `Database` service to
|
|
46
|
+
* return. If not provided, the default `Database` service will be returned.
|
|
47
|
+
*
|
|
48
|
+
* @return The default `Database` service if no app
|
|
49
|
+
* is provided or the `Database` service associated with the provided app.
|
|
50
|
+
*/
|
|
51
|
+
export declare function database(app?: app.App): database.Database;
|
|
52
|
+
export declare namespace database {
|
|
53
|
+
interface Database extends rtdb.FirebaseDatabase {
|
|
54
|
+
/**
|
|
55
|
+
* Gets the currently applied security rules as a string. The return value consists of
|
|
56
|
+
* the rules source including comments.
|
|
57
|
+
*
|
|
58
|
+
* @return A promise fulfilled with the rules as a raw string.
|
|
59
|
+
*/
|
|
60
|
+
getRules(): Promise<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Gets the currently applied security rules as a parsed JSON object. Any comments in
|
|
63
|
+
* the original source are stripped away.
|
|
64
|
+
*
|
|
65
|
+
* @return A promise fulfilled with the parsed rules object.
|
|
66
|
+
*/
|
|
67
|
+
getRulesJSON(): Promise<object>;
|
|
68
|
+
/**
|
|
69
|
+
* Sets the specified rules on the Firebase Realtime Database instance. If the rules source is
|
|
70
|
+
* specified as a string or a Buffer, it may include comments.
|
|
71
|
+
*
|
|
72
|
+
* @param source Source of the rules to apply. Must not be `null` or empty.
|
|
73
|
+
* @return Resolves when the rules are set on the Realtime Database.
|
|
74
|
+
*/
|
|
75
|
+
setRules(source: string | Buffer | object): Promise<void>;
|
|
76
|
+
}
|
|
77
|
+
export import DataSnapshot = rtdb.DataSnapshot;
|
|
78
|
+
export import EventType = rtdb.EventType;
|
|
79
|
+
export import OnDisconnect = rtdb.OnDisconnect;
|
|
80
|
+
export import Query = rtdb.Query;
|
|
81
|
+
export import Reference = rtdb.Reference;
|
|
82
|
+
export import ThenableReference = rtdb.ThenableReference;
|
|
83
|
+
export import enableLogging = rtdb.enableLogging;
|
|
84
|
+
/**
|
|
85
|
+
* [`ServerValue`](https://firebase.google.com/docs/reference/js/firebase.database.ServerValue)
|
|
86
|
+
* module from the `@firebase/database` package.
|
|
87
|
+
*/
|
|
88
|
+
const ServerValue: rtdb.ServerValue;
|
|
89
|
+
}
|
package/lib/database/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,32 +16,16 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
19
|
+
exports.database = void 0;
|
|
20
20
|
var database_1 = require("@firebase/database");
|
|
21
|
-
var
|
|
22
|
-
var firebaseDbTypesApi = require("@firebase/database-types");
|
|
23
|
-
var firebaseAdmin = require("../index");
|
|
24
|
-
function database(app) {
|
|
25
|
-
if (typeof (app) === 'undefined') {
|
|
26
|
-
app = firebaseAdmin.app();
|
|
27
|
-
}
|
|
28
|
-
return app.database();
|
|
29
|
-
}
|
|
30
|
-
exports.database = database;
|
|
31
|
-
/**
|
|
32
|
-
* We must define a namespace to make the typings work correctly. Otherwise
|
|
33
|
-
* `admin.database()` cannot be called like a function. Temporarily,
|
|
34
|
-
* admin.database is used as the namespace name because we cannot barrel
|
|
35
|
-
* re-export the contents from @firebase/database-types, and we want it to
|
|
36
|
-
* match the namespacing in the re-export inside src/index.d.ts
|
|
37
|
-
*/
|
|
21
|
+
var rtdb = require("@firebase/database-types");
|
|
38
22
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
39
|
-
var
|
|
40
|
-
(function (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})(
|
|
23
|
+
var database;
|
|
24
|
+
(function (database) {
|
|
25
|
+
database.enableLogging = rtdb.enableLogging;
|
|
26
|
+
/**
|
|
27
|
+
* [`ServerValue`](https://firebase.google.com/docs/reference/js/firebase.database.ServerValue)
|
|
28
|
+
* module from the `@firebase/database` package.
|
|
29
|
+
*/
|
|
30
|
+
database.ServerValue = database_1.ServerValue;
|
|
31
|
+
})(database = exports.database || (exports.database = {}));
|
package/lib/default-namespace.js
CHANGED
package/lib/firebase-app.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");
|
|
@@ -180,14 +181,13 @@ exports.FirebaseAppInternals = FirebaseAppInternals;
|
|
|
180
181
|
*/
|
|
181
182
|
var FirebaseApp = /** @class */ (function () {
|
|
182
183
|
function FirebaseApp(options, name, firebaseInternals_) {
|
|
183
|
-
var _this = this;
|
|
184
184
|
this.firebaseInternals_ = firebaseInternals_;
|
|
185
185
|
this.services_ = {};
|
|
186
186
|
this.isDeleted_ = false;
|
|
187
187
|
this.name_ = name;
|
|
188
188
|
this.options_ = deep_copy_1.deepCopy(options);
|
|
189
189
|
if (!validator.isNonNullObject(this.options_)) {
|
|
190
|
-
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS,
|
|
190
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS, 'Invalid Firebase app options passed as the first argument to initializeApp() for the ' +
|
|
191
191
|
("app named \"" + this.name_ + "\". Options must be a non-null object."));
|
|
192
192
|
}
|
|
193
193
|
var hasCredential = ('credential' in this.options_);
|
|
@@ -196,20 +196,16 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
196
196
|
}
|
|
197
197
|
var credential = this.options_.credential;
|
|
198
198
|
if (typeof credential !== 'object' || credential === null || typeof credential.getAccessToken !== 'function') {
|
|
199
|
-
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS,
|
|
199
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS, 'Invalid Firebase app options passed as the first argument to initializeApp() for the ' +
|
|
200
200
|
("app named \"" + this.name_ + "\". The \"credential\" property must be an object which implements ") +
|
|
201
|
-
|
|
201
|
+
'the Credential interface.');
|
|
202
202
|
}
|
|
203
|
-
Object.keys(firebaseInternals_.serviceFactories).forEach(function (serviceName) {
|
|
204
|
-
// Defer calling createService() until the service is accessed
|
|
205
|
-
_this[serviceName] = _this.getService_.bind(_this, serviceName);
|
|
206
|
-
});
|
|
207
203
|
this.INTERNAL = new FirebaseAppInternals(credential);
|
|
208
204
|
}
|
|
209
205
|
/**
|
|
210
206
|
* Returns the Auth service instance associated with this app.
|
|
211
207
|
*
|
|
212
|
-
* @return
|
|
208
|
+
* @return The Auth service instance of this app.
|
|
213
209
|
*/
|
|
214
210
|
FirebaseApp.prototype.auth = function () {
|
|
215
211
|
var _this = this;
|
|
@@ -221,7 +217,7 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
221
217
|
/**
|
|
222
218
|
* Returns the Database service for the specified URL, and the current app.
|
|
223
219
|
*
|
|
224
|
-
* @return
|
|
220
|
+
* @return The Database service instance of this app.
|
|
225
221
|
*/
|
|
226
222
|
FirebaseApp.prototype.database = function (url) {
|
|
227
223
|
var _this = this;
|
|
@@ -234,7 +230,7 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
234
230
|
/**
|
|
235
231
|
* Returns the Messaging service instance associated with this app.
|
|
236
232
|
*
|
|
237
|
-
* @return
|
|
233
|
+
* @return The Messaging service instance of this app.
|
|
238
234
|
*/
|
|
239
235
|
FirebaseApp.prototype.messaging = function () {
|
|
240
236
|
var _this = this;
|
|
@@ -246,7 +242,7 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
246
242
|
/**
|
|
247
243
|
* Returns the Storage service instance associated with this app.
|
|
248
244
|
*
|
|
249
|
-
* @return
|
|
245
|
+
* @return The Storage service instance of this app.
|
|
250
246
|
*/
|
|
251
247
|
FirebaseApp.prototype.storage = function () {
|
|
252
248
|
var _this = this;
|
|
@@ -266,7 +262,7 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
266
262
|
/**
|
|
267
263
|
* Returns the InstanceId service instance associated with this app.
|
|
268
264
|
*
|
|
269
|
-
* @return
|
|
265
|
+
* @return The InstanceId service instance of this app.
|
|
270
266
|
*/
|
|
271
267
|
FirebaseApp.prototype.instanceId = function () {
|
|
272
268
|
var _this = this;
|
|
@@ -278,7 +274,7 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
278
274
|
/**
|
|
279
275
|
* Returns the MachineLearning service instance associated with this app.
|
|
280
276
|
*
|
|
281
|
-
* @return
|
|
277
|
+
* @return The Machine Learning service instance of this app
|
|
282
278
|
*/
|
|
283
279
|
FirebaseApp.prototype.machineLearning = function () {
|
|
284
280
|
var _this = this;
|
|
@@ -290,7 +286,7 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
290
286
|
/**
|
|
291
287
|
* Returns the ProjectManagement service instance associated with this app.
|
|
292
288
|
*
|
|
293
|
-
* @return
|
|
289
|
+
* @return The ProjectManagement service instance of this app.
|
|
294
290
|
*/
|
|
295
291
|
FirebaseApp.prototype.projectManagement = function () {
|
|
296
292
|
var _this = this;
|
|
@@ -302,7 +298,7 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
302
298
|
/**
|
|
303
299
|
* Returns the SecurityRules service instance associated with this app.
|
|
304
300
|
*
|
|
305
|
-
* @return
|
|
301
|
+
* @return The SecurityRules service instance of this app.
|
|
306
302
|
*/
|
|
307
303
|
FirebaseApp.prototype.securityRules = function () {
|
|
308
304
|
var _this = this;
|
|
@@ -314,7 +310,7 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
314
310
|
/**
|
|
315
311
|
* Returns the RemoteConfig service instance associated with this app.
|
|
316
312
|
*
|
|
317
|
-
* @return
|
|
313
|
+
* @return The RemoteConfig service instance of this app.
|
|
318
314
|
*/
|
|
319
315
|
FirebaseApp.prototype.remoteConfig = function () {
|
|
320
316
|
var _this = this;
|
|
@@ -327,7 +323,7 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
327
323
|
/**
|
|
328
324
|
* Returns the name of the FirebaseApp instance.
|
|
329
325
|
*
|
|
330
|
-
* @return
|
|
326
|
+
* @return The name of the FirebaseApp instance.
|
|
331
327
|
*/
|
|
332
328
|
get: function () {
|
|
333
329
|
this.checkDestroyed_();
|
|
@@ -340,7 +336,7 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
340
336
|
/**
|
|
341
337
|
* Returns the options for the FirebaseApp instance.
|
|
342
338
|
*
|
|
343
|
-
* @return
|
|
339
|
+
* @return The options for the FirebaseApp instance.
|
|
344
340
|
*/
|
|
345
341
|
get: function () {
|
|
346
342
|
this.checkDestroyed_();
|
|
@@ -352,7 +348,7 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
352
348
|
/**
|
|
353
349
|
* Deletes the FirebaseApp instance.
|
|
354
350
|
*
|
|
355
|
-
* @return
|
|
351
|
+
* @return An empty Promise fulfilled once the FirebaseApp instance is deleted.
|
|
356
352
|
*/
|
|
357
353
|
FirebaseApp.prototype.delete = function () {
|
|
358
354
|
var _this = this;
|
|
@@ -360,44 +356,23 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
360
356
|
this.firebaseInternals_.removeApp(this.name_);
|
|
361
357
|
this.INTERNAL.delete();
|
|
362
358
|
return Promise.all(Object.keys(this.services_).map(function (serviceName) {
|
|
363
|
-
|
|
359
|
+
var service = _this.services_[serviceName];
|
|
360
|
+
if (isStateful(service)) {
|
|
361
|
+
return service.delete();
|
|
362
|
+
}
|
|
363
|
+
return Promise.resolve();
|
|
364
364
|
})).then(function () {
|
|
365
365
|
_this.services_ = {};
|
|
366
366
|
_this.isDeleted_ = true;
|
|
367
367
|
});
|
|
368
368
|
};
|
|
369
369
|
FirebaseApp.prototype.ensureService_ = function (serviceName, initializer) {
|
|
370
|
-
this.checkDestroyed_();
|
|
371
|
-
var service;
|
|
372
|
-
if (serviceName in this.services_) {
|
|
373
|
-
service = this.services_[serviceName];
|
|
374
|
-
}
|
|
375
|
-
else {
|
|
376
|
-
service = initializer();
|
|
377
|
-
this.services_[serviceName] = service;
|
|
378
|
-
}
|
|
379
|
-
return service;
|
|
380
|
-
};
|
|
381
|
-
/**
|
|
382
|
-
* Returns the service instance associated with this FirebaseApp instance (creating it on demand
|
|
383
|
-
* if needed). This is used for looking up monkeypatched service instances.
|
|
384
|
-
*
|
|
385
|
-
* @param {string} serviceName The name of the service instance to return.
|
|
386
|
-
* @return {FirebaseServiceInterface} The service instance with the provided name.
|
|
387
|
-
*/
|
|
388
|
-
FirebaseApp.prototype.getService_ = function (serviceName) {
|
|
389
370
|
this.checkDestroyed_();
|
|
390
371
|
if (!(serviceName in this.services_)) {
|
|
391
|
-
this.services_[serviceName] =
|
|
372
|
+
this.services_[serviceName] = initializer();
|
|
392
373
|
}
|
|
393
374
|
return this.services_[serviceName];
|
|
394
375
|
};
|
|
395
|
-
/**
|
|
396
|
-
* Callback function used to extend an App instance at the time of service instance creation.
|
|
397
|
-
*/
|
|
398
|
-
FirebaseApp.prototype.extendApp_ = function (props) {
|
|
399
|
-
deep_copy_1.deepExtend(this, props);
|
|
400
|
-
};
|
|
401
376
|
/**
|
|
402
377
|
* Throws an Error if the FirebaseApp instance has already been deleted.
|
|
403
378
|
*/
|
|
@@ -409,3 +384,6 @@ var FirebaseApp = /** @class */ (function () {
|
|
|
409
384
|
return FirebaseApp;
|
|
410
385
|
}());
|
|
411
386
|
exports.FirebaseApp = FirebaseApp;
|
|
387
|
+
function isStateful(service) {
|
|
388
|
+
return typeof service.delete === 'function';
|
|
389
|
+
}
|