firebase-admin 10.2.0 → 11.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/app/core.d.ts +1 -1
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +1 -1
- package/lib/app/credential-factory.js +8 -8
- package/lib/app/credential-internal.d.ts +7 -1
- package/lib/app/credential-internal.js +120 -106
- package/lib/app/credential.d.ts +1 -1
- package/lib/app/credential.js +1 -1
- package/lib/app/firebase-app.d.ts +1 -1
- package/lib/app/firebase-app.js +76 -91
- package/lib/app/firebase-namespace.d.ts +1 -1
- package/lib/app/firebase-namespace.js +209 -279
- package/lib/app/index.d.ts +1 -1
- package/lib/app/index.js +4 -4
- package/lib/app/lifecycle.d.ts +1 -1
- package/lib/app/lifecycle.js +37 -43
- package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
- package/lib/app-check/app-check-api-client-internal.js +54 -73
- package/lib/app-check/app-check-api.d.ts +1 -1
- package/lib/app-check/app-check-api.js +1 -1
- package/lib/app-check/app-check-namespace.d.ts +1 -1
- package/lib/app-check/app-check-namespace.js +1 -1
- package/lib/app-check/app-check.d.ts +1 -1
- package/lib/app-check/app-check.js +17 -19
- package/lib/app-check/index.d.ts +1 -1
- package/lib/app-check/index.js +7 -7
- package/lib/app-check/token-generator.d.ts +1 -1
- package/lib/app-check/token-generator.js +47 -52
- package/lib/app-check/token-verifier.d.ts +1 -1
- package/lib/app-check/token-verifier.js +46 -50
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +10 -11
- package/lib/auth/auth-api-request.d.ts +1 -1
- package/lib/auth/auth-api-request.js +346 -393
- package/lib/auth/auth-config.d.ts +1 -1
- package/lib/auth/auth-config.js +95 -106
- package/lib/auth/auth-namespace.d.ts +1 -1
- package/lib/auth/auth-namespace.js +1 -1
- package/lib/auth/auth.d.ts +1 -1
- package/lib/auth/auth.js +20 -40
- package/lib/auth/base-auth.d.ts +1 -1
- package/lib/auth/base-auth.js +137 -144
- package/lib/auth/identifier.d.ts +1 -1
- package/lib/auth/identifier.js +2 -2
- package/lib/auth/index.d.ts +1 -1
- package/lib/auth/index.js +7 -7
- package/lib/auth/tenant-manager.d.ts +1 -1
- package/lib/auth/tenant-manager.js +49 -71
- package/lib/auth/tenant.d.ts +1 -1
- package/lib/auth/tenant.js +44 -55
- package/lib/auth/token-generator.d.ts +1 -1
- package/lib/auth/token-generator.js +49 -53
- package/lib/auth/token-verifier.d.ts +1 -1
- package/lib/auth/token-verifier.js +83 -91
- package/lib/auth/user-import-builder.d.ts +1 -1
- package/lib/auth/user-import-builder.js +70 -73
- package/lib/auth/user-record.d.ts +1 -1
- package/lib/auth/user-record.js +62 -84
- package/lib/credential/index.d.ts +1 -1
- package/lib/credential/index.js +2 -2
- package/lib/database/database-namespace.d.ts +1 -1
- package/lib/database/database-namespace.js +1 -1
- package/lib/database/database.d.ts +1 -1
- package/lib/database/database.js +92 -108
- package/lib/database/index.d.ts +1 -1
- package/lib/database/index.js +10 -10
- package/lib/default-namespace.d.ts +1 -1
- package/lib/default-namespace.js +2 -2
- package/lib/eventarc/cloudevent.d.ts +1 -1
- package/lib/eventarc/cloudevent.js +1 -1
- package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
- package/lib/eventarc/eventarc-client-internal.js +63 -129
- package/lib/eventarc/eventarc-utils.d.ts +1 -1
- package/lib/eventarc/eventarc-utils.js +16 -32
- package/lib/eventarc/eventarc.d.ts +1 -1
- package/lib/eventarc/eventarc.js +51 -65
- package/lib/eventarc/index.d.ts +1 -1
- package/lib/eventarc/index.js +7 -7
- package/lib/firebase-namespace-api.d.ts +1 -1
- package/lib/firebase-namespace-api.js +8 -3
- package/lib/firestore/firestore-internal.d.ts +1 -1
- package/lib/firestore/firestore-internal.js +28 -37
- package/lib/firestore/firestore-namespace.d.ts +9 -1
- package/lib/firestore/firestore-namespace.js +2 -2
- package/lib/firestore/index.d.ts +2 -2
- package/lib/firestore/index.js +7 -7
- package/lib/functions/functions-api-client-internal.d.ts +19 -1
- package/lib/functions/functions-api-client-internal.js +83 -103
- package/lib/functions/functions-api.d.ts +1 -1
- package/lib/functions/functions-api.js +1 -1
- package/lib/functions/functions.d.ts +1 -1
- package/lib/functions/functions.js +13 -15
- package/lib/functions/index.d.ts +1 -1
- package/lib/functions/index.js +7 -7
- package/lib/index.d.ts +1 -1
- package/lib/index.js +14 -4
- package/lib/installations/index.d.ts +1 -1
- package/lib/installations/index.js +6 -6
- package/lib/installations/installations-namespace.d.ts +1 -1
- package/lib/installations/installations-namespace.js +1 -1
- package/lib/installations/installations-request-handler.d.ts +1 -1
- package/lib/installations/installations-request-handler.js +33 -36
- package/lib/installations/installations.d.ts +1 -1
- package/lib/installations/installations.js +17 -22
- package/lib/instance-id/index.d.ts +1 -1
- package/lib/instance-id/index.js +6 -6
- package/lib/instance-id/instance-id-namespace.d.ts +1 -1
- package/lib/instance-id/instance-id-namespace.js +1 -1
- package/lib/instance-id/instance-id.d.ts +1 -1
- package/lib/instance-id/instance-id.js +21 -26
- package/lib/machine-learning/index.d.ts +1 -1
- package/lib/machine-learning/index.js +7 -7
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +110 -124
- package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
- package/lib/machine-learning/machine-learning-namespace.js +1 -1
- package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
- package/lib/machine-learning/machine-learning-utils.js +9 -24
- package/lib/machine-learning/machine-learning.d.ts +1 -1
- package/lib/machine-learning/machine-learning.js +146 -207
- package/lib/messaging/batch-request-internal.d.ts +1 -1
- package/lib/messaging/batch-request-internal.js +33 -35
- package/lib/messaging/index.d.ts +1 -1
- package/lib/messaging/index.js +7 -7
- package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
- package/lib/messaging/messaging-api-request-internal.js +38 -40
- package/lib/messaging/messaging-api.d.ts +1 -1
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +1 -1
- package/lib/messaging/messaging-errors-internal.js +12 -13
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +51 -51
- package/lib/messaging/messaging-namespace.d.ts +1 -1
- package/lib/messaging/messaging-namespace.js +1 -1
- package/lib/messaging/messaging.d.ts +1 -1
- package/lib/messaging/messaging.js +184 -208
- package/lib/project-management/android-app.d.ts +1 -1
- package/lib/project-management/android-app.js +41 -43
- package/lib/project-management/app-metadata.d.ts +1 -1
- package/lib/project-management/app-metadata.js +1 -1
- package/lib/project-management/index.d.ts +1 -1
- package/lib/project-management/index.js +7 -7
- package/lib/project-management/ios-app.d.ts +1 -1
- package/lib/project-management/ios-app.js +25 -26
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
- package/lib/project-management/project-management-api-request-internal.js +84 -89
- package/lib/project-management/project-management-namespace.d.ts +1 -1
- package/lib/project-management/project-management-namespace.js +1 -1
- package/lib/project-management/project-management.d.ts +1 -1
- package/lib/project-management/project-management.js +80 -87
- package/lib/remote-config/index.d.ts +1 -1
- package/lib/remote-config/index.js +7 -7
- package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
- package/lib/remote-config/remote-config-api-client-internal.js +116 -154
- package/lib/remote-config/remote-config-api.d.ts +1 -1
- package/lib/remote-config/remote-config-api.js +1 -1
- package/lib/remote-config/remote-config-namespace.d.ts +1 -1
- package/lib/remote-config/remote-config-namespace.js +1 -1
- package/lib/remote-config/remote-config.d.ts +1 -1
- package/lib/remote-config/remote-config.js +51 -59
- package/lib/security-rules/index.d.ts +1 -1
- package/lib/security-rules/index.js +7 -7
- package/lib/security-rules/security-rules-api-client-internal.d.ts +3 -1
- package/lib/security-rules/security-rules-api-client-internal.js +118 -107
- package/lib/security-rules/security-rules-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-internal.js +6 -21
- package/lib/security-rules/security-rules-namespace.d.ts +1 -1
- package/lib/security-rules/security-rules-namespace.js +1 -1
- package/lib/security-rules/security-rules.d.ts +1 -1
- package/lib/security-rules/security-rules.js +83 -92
- package/lib/storage/index.d.ts +1 -1
- package/lib/storage/index.js +7 -7
- package/lib/storage/storage-namespace.d.ts +1 -1
- package/lib/storage/storage-namespace.js +1 -1
- package/lib/storage/storage.d.ts +1 -1
- package/lib/storage/storage.js +25 -30
- package/lib/utils/api-request.d.ts +3 -1
- package/lib/utils/api-request.js +278 -356
- package/lib/utils/crypto-signer.d.ts +1 -1
- package/lib/utils/crypto-signer.js +58 -93
- package/lib/utils/deep-copy.d.ts +1 -1
- package/lib/utils/deep-copy.js +3 -3
- package/lib/utils/error.d.ts +1 -1
- package/lib/utils/error.js +611 -681
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +38 -43
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/jwt.js +97 -123
- package/lib/utils/validator.d.ts +1 -1
- package/lib/utils/validator.js +13 -13
- package/package.json +25 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v11.0.1 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2018 Google Inc.
|
|
@@ -17,30 +17,30 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.ProjectManagementRequestHandler = exports.assertServerResponse = void 0;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const api_request_1 = require("../utils/api-request");
|
|
21
|
+
const error_1 = require("../utils/error");
|
|
22
|
+
const index_1 = require("../utils/index");
|
|
23
|
+
const validator = require("../utils/validator");
|
|
24
24
|
/** Project management backend host and port. */
|
|
25
|
-
|
|
25
|
+
const PROJECT_MANAGEMENT_HOST_AND_PORT = 'firebase.googleapis.com:443';
|
|
26
26
|
/** Project management backend path. */
|
|
27
|
-
|
|
27
|
+
const PROJECT_MANAGEMENT_PATH = '/v1/';
|
|
28
28
|
/** Project management beta backend path. */
|
|
29
|
-
|
|
29
|
+
const PROJECT_MANAGEMENT_BETA_PATH = '/v1beta1/';
|
|
30
30
|
/** Project management request header. */
|
|
31
|
-
|
|
32
|
-
'X-Client-Version':
|
|
31
|
+
const PROJECT_MANAGEMENT_HEADERS = {
|
|
32
|
+
'X-Client-Version': `Node/Admin/${(0, index_1.getSdkVersion)()}`,
|
|
33
33
|
};
|
|
34
34
|
/** Project management request timeout duration in milliseconds. */
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const PROJECT_MANAGEMENT_TIMEOUT_MILLIS = 10000;
|
|
36
|
+
const LIST_APPS_MAX_PAGE_SIZE = 100;
|
|
37
|
+
const CERT_TYPE_API_MAP = {
|
|
38
38
|
sha1: 'SHA_1',
|
|
39
39
|
sha256: 'SHA_256',
|
|
40
40
|
};
|
|
41
41
|
function assertServerResponse(condition, responseData, message) {
|
|
42
42
|
if (!condition) {
|
|
43
|
-
throw new error_1.FirebaseProjectManagementError('invalid-server-response', message
|
|
43
|
+
throw new error_1.FirebaseProjectManagementError('invalid-server-response', `${message} Response data: ${JSON.stringify(responseData, null, 2)}`);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
exports.assertServerResponse = assertServerResponse;
|
|
@@ -50,19 +50,19 @@ exports.assertServerResponse = assertServerResponse;
|
|
|
50
50
|
*
|
|
51
51
|
* @internal
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
class ProjectManagementRequestHandler {
|
|
54
54
|
/**
|
|
55
55
|
* @param app - The app used to fetch access tokens to sign API requests.
|
|
56
56
|
* @constructor
|
|
57
57
|
*/
|
|
58
|
-
|
|
59
|
-
this.baseUrl =
|
|
60
|
-
this.baseBetaUrl =
|
|
58
|
+
constructor(app) {
|
|
59
|
+
this.baseUrl = `https://${PROJECT_MANAGEMENT_HOST_AND_PORT}${PROJECT_MANAGEMENT_PATH}`;
|
|
60
|
+
this.baseBetaUrl = `https://${PROJECT_MANAGEMENT_HOST_AND_PORT}${PROJECT_MANAGEMENT_BETA_PATH}`;
|
|
61
61
|
this.httpClient = new api_request_1.AuthorizedHttpClient(app);
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
static wrapAndRethrowHttpError(errStatusCode, errText) {
|
|
64
|
+
let errorCode;
|
|
65
|
+
let errorMessage;
|
|
66
66
|
switch (errStatusCode) {
|
|
67
67
|
case 400:
|
|
68
68
|
errorCode = 'invalid-argument';
|
|
@@ -99,136 +99,133 @@ var ProjectManagementRequestHandler = /** @class */ (function () {
|
|
|
99
99
|
if (!errText) {
|
|
100
100
|
errText = '<missing>';
|
|
101
101
|
}
|
|
102
|
-
throw new error_1.FirebaseProjectManagementError(errorCode, errorMessage
|
|
103
|
-
}
|
|
102
|
+
throw new error_1.FirebaseProjectManagementError(errorCode, `${errorMessage} Status code: ${errStatusCode}. Raw server response: "${errText}".`);
|
|
103
|
+
}
|
|
104
104
|
/**
|
|
105
105
|
* @param parentResourceName - Fully-qualified resource name of the project whose Android
|
|
106
106
|
* apps you want to list.
|
|
107
107
|
*/
|
|
108
|
-
|
|
109
|
-
return this.invokeRequestHandler('GET', parentResourceName
|
|
108
|
+
listAndroidApps(parentResourceName) {
|
|
109
|
+
return this.invokeRequestHandler('GET', `${parentResourceName}/androidApps?page_size=${LIST_APPS_MAX_PAGE_SIZE}`,
|
|
110
110
|
/* requestData */ null, 'v1beta1');
|
|
111
|
-
}
|
|
111
|
+
}
|
|
112
112
|
/**
|
|
113
113
|
* @param parentResourceName - Fully-qualified resource name of the project whose iOS apps
|
|
114
114
|
* you want to list.
|
|
115
115
|
*/
|
|
116
|
-
|
|
117
|
-
return this.invokeRequestHandler('GET', parentResourceName
|
|
116
|
+
listIosApps(parentResourceName) {
|
|
117
|
+
return this.invokeRequestHandler('GET', `${parentResourceName}/iosApps?page_size=${LIST_APPS_MAX_PAGE_SIZE}`,
|
|
118
118
|
/* requestData */ null, 'v1beta1');
|
|
119
|
-
}
|
|
119
|
+
}
|
|
120
120
|
/**
|
|
121
121
|
* @param parentResourceName - Fully-qualified resource name of the project whose iOS apps
|
|
122
122
|
* you want to list.
|
|
123
123
|
*/
|
|
124
|
-
|
|
125
|
-
return this.invokeRequestHandler('GET', parentResourceName
|
|
124
|
+
listAppMetadata(parentResourceName) {
|
|
125
|
+
return this.invokeRequestHandler('GET', `${parentResourceName}:searchApps?page_size=${LIST_APPS_MAX_PAGE_SIZE}`,
|
|
126
126
|
/* requestData */ null, 'v1beta1');
|
|
127
|
-
}
|
|
127
|
+
}
|
|
128
128
|
/**
|
|
129
129
|
* @param parentResourceName - Fully-qualified resource name of the project that you want
|
|
130
130
|
* to create the Android app within.
|
|
131
131
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
packageName: packageName,
|
|
132
|
+
createAndroidApp(parentResourceName, packageName, displayName) {
|
|
133
|
+
const requestData = {
|
|
134
|
+
packageName,
|
|
136
135
|
};
|
|
137
136
|
if (validator.isNonEmptyString(displayName)) {
|
|
138
137
|
requestData.displayName = displayName;
|
|
139
138
|
}
|
|
140
139
|
return this
|
|
141
|
-
.invokeRequestHandler('POST', parentResourceName
|
|
142
|
-
.then(
|
|
140
|
+
.invokeRequestHandler('POST', `${parentResourceName}/androidApps`, requestData, 'v1beta1')
|
|
141
|
+
.then((responseData) => {
|
|
143
142
|
assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createAndroidApp\'s responseData must be a non-null object.');
|
|
144
143
|
assertServerResponse(validator.isNonEmptyString(responseData.name), responseData, 'createAndroidApp\'s responseData.name must be a non-empty string.');
|
|
145
|
-
return
|
|
144
|
+
return this.pollRemoteOperationWithExponentialBackoff(responseData.name);
|
|
146
145
|
});
|
|
147
|
-
}
|
|
146
|
+
}
|
|
148
147
|
/**
|
|
149
148
|
* @param parentResourceName - Fully-qualified resource name of the project that you want
|
|
150
149
|
* to create the iOS app within.
|
|
151
150
|
*/
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
bundleId: bundleId,
|
|
151
|
+
createIosApp(parentResourceName, bundleId, displayName) {
|
|
152
|
+
const requestData = {
|
|
153
|
+
bundleId,
|
|
156
154
|
};
|
|
157
155
|
if (validator.isNonEmptyString(displayName)) {
|
|
158
156
|
requestData.displayName = displayName;
|
|
159
157
|
}
|
|
160
158
|
return this
|
|
161
|
-
.invokeRequestHandler('POST', parentResourceName
|
|
162
|
-
.then(
|
|
159
|
+
.invokeRequestHandler('POST', `${parentResourceName}/iosApps`, requestData, 'v1beta1')
|
|
160
|
+
.then((responseData) => {
|
|
163
161
|
assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createIosApp\'s responseData must be a non-null object.');
|
|
164
162
|
assertServerResponse(validator.isNonEmptyString(responseData.name), responseData, 'createIosApp\'s responseData.name must be a non-empty string.');
|
|
165
|
-
return
|
|
163
|
+
return this.pollRemoteOperationWithExponentialBackoff(responseData.name);
|
|
166
164
|
});
|
|
167
|
-
}
|
|
165
|
+
}
|
|
168
166
|
/**
|
|
169
167
|
* @param resourceName - Fully-qualified resource name of the entity whose display name you
|
|
170
168
|
* want to set.
|
|
171
169
|
*/
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
setDisplayName(resourceName, newDisplayName) {
|
|
171
|
+
const requestData = {
|
|
174
172
|
displayName: newDisplayName,
|
|
175
173
|
};
|
|
176
174
|
return this
|
|
177
|
-
.invokeRequestHandler('PATCH', resourceName
|
|
178
|
-
.then(
|
|
179
|
-
}
|
|
175
|
+
.invokeRequestHandler('PATCH', `${resourceName}?update_mask=display_name`, requestData, 'v1beta1')
|
|
176
|
+
.then(() => undefined);
|
|
177
|
+
}
|
|
180
178
|
/**
|
|
181
179
|
* @param parentResourceName - Fully-qualified resource name of the Android app whose SHA
|
|
182
180
|
* certificates you want to get.
|
|
183
181
|
*/
|
|
184
|
-
|
|
185
|
-
return this.invokeRequestHandler('GET', parentResourceName
|
|
186
|
-
}
|
|
182
|
+
getAndroidShaCertificates(parentResourceName) {
|
|
183
|
+
return this.invokeRequestHandler('GET', `${parentResourceName}/sha`, /* requestData */ null, 'v1beta1');
|
|
184
|
+
}
|
|
187
185
|
/**
|
|
188
186
|
* @param parentResourceName - Fully-qualified resource name of the Android app that you
|
|
189
187
|
* want to add the given SHA certificate to.
|
|
190
188
|
*/
|
|
191
|
-
|
|
192
|
-
|
|
189
|
+
addAndroidShaCertificate(parentResourceName, certificate) {
|
|
190
|
+
const requestData = {
|
|
193
191
|
shaHash: certificate.shaHash,
|
|
194
192
|
certType: CERT_TYPE_API_MAP[certificate.certType],
|
|
195
193
|
};
|
|
196
194
|
return this
|
|
197
|
-
.invokeRequestHandler('POST', parentResourceName
|
|
198
|
-
.then(
|
|
199
|
-
}
|
|
195
|
+
.invokeRequestHandler('POST', `${parentResourceName}/sha`, requestData, 'v1beta1')
|
|
196
|
+
.then(() => undefined);
|
|
197
|
+
}
|
|
200
198
|
/**
|
|
201
199
|
* @param parentResourceName - Fully-qualified resource name of the app whose config you
|
|
202
200
|
* want to get.
|
|
203
201
|
*/
|
|
204
|
-
|
|
205
|
-
return this.invokeRequestHandler('GET', parentResourceName
|
|
206
|
-
}
|
|
202
|
+
getConfig(parentResourceName) {
|
|
203
|
+
return this.invokeRequestHandler('GET', `${parentResourceName}/config`, /* requestData */ null, 'v1beta1');
|
|
204
|
+
}
|
|
207
205
|
/**
|
|
208
206
|
* @param parentResourceName - Fully-qualified resource name of the entity that you want to
|
|
209
207
|
* get.
|
|
210
208
|
*/
|
|
211
|
-
|
|
209
|
+
getResource(parentResourceName) {
|
|
212
210
|
return this.invokeRequestHandler('GET', parentResourceName, /* requestData */ null, 'v1beta1');
|
|
213
|
-
}
|
|
211
|
+
}
|
|
214
212
|
/**
|
|
215
213
|
* @param resourceName - Fully-qualified resource name of the entity that you want to
|
|
216
214
|
* delete.
|
|
217
215
|
*/
|
|
218
|
-
|
|
216
|
+
deleteResource(resourceName) {
|
|
219
217
|
return this
|
|
220
218
|
.invokeRequestHandler('DELETE', resourceName, /* requestData */ null, 'v1beta1')
|
|
221
|
-
.then(
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
.then(function (responseData) {
|
|
219
|
+
.then(() => undefined);
|
|
220
|
+
}
|
|
221
|
+
pollRemoteOperationWithExponentialBackoff(operationResourceName) {
|
|
222
|
+
const poller = new api_request_1.ExponentialBackoffPoller();
|
|
223
|
+
return poller.poll(() => {
|
|
224
|
+
return this.invokeRequestHandler('GET', operationResourceName, /* requestData */ null)
|
|
225
|
+
.then((responseData) => {
|
|
229
226
|
if (responseData.error) {
|
|
230
|
-
|
|
231
|
-
|
|
227
|
+
const errStatusCode = responseData.error.code || 500;
|
|
228
|
+
const errText = responseData.error.message || JSON.stringify(responseData.error);
|
|
232
229
|
ProjectManagementRequestHandler.wrapAndRethrowHttpError(errStatusCode, errText);
|
|
233
230
|
}
|
|
234
231
|
if (!responseData.done) {
|
|
@@ -239,35 +236,33 @@ var ProjectManagementRequestHandler = /** @class */ (function () {
|
|
|
239
236
|
return responseData.response;
|
|
240
237
|
});
|
|
241
238
|
});
|
|
242
|
-
}
|
|
239
|
+
}
|
|
243
240
|
/**
|
|
244
241
|
* Invokes the request handler with the provided request data.
|
|
245
242
|
*/
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
url: "" + baseUrlToUse + path,
|
|
243
|
+
invokeRequestHandler(method, path, requestData, apiVersion = 'v1') {
|
|
244
|
+
const baseUrlToUse = (apiVersion === 'v1') ? this.baseUrl : this.baseBetaUrl;
|
|
245
|
+
const request = {
|
|
246
|
+
method,
|
|
247
|
+
url: `${baseUrlToUse}${path}`,
|
|
252
248
|
headers: PROJECT_MANAGEMENT_HEADERS,
|
|
253
249
|
data: requestData,
|
|
254
250
|
timeout: PROJECT_MANAGEMENT_TIMEOUT_MILLIS,
|
|
255
251
|
};
|
|
256
252
|
return this.httpClient.send(request)
|
|
257
|
-
.then(
|
|
253
|
+
.then((response) => {
|
|
258
254
|
// Send non-JSON responses to the catch() below, where they will be treated as errors.
|
|
259
255
|
if (!response.isJson()) {
|
|
260
256
|
throw new api_request_1.HttpError(response);
|
|
261
257
|
}
|
|
262
258
|
return response.data;
|
|
263
259
|
})
|
|
264
|
-
.catch(
|
|
260
|
+
.catch((err) => {
|
|
265
261
|
if (err instanceof api_request_1.HttpError) {
|
|
266
262
|
ProjectManagementRequestHandler.wrapAndRethrowHttpError(err.response.status, err.response.text);
|
|
267
263
|
}
|
|
268
264
|
throw err;
|
|
269
265
|
});
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
}());
|
|
266
|
+
}
|
|
267
|
+
}
|
|
273
268
|
exports.ProjectManagementRequestHandler = ProjectManagementRequestHandler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v11.0.1 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2018 Google Inc.
|
|
@@ -17,23 +17,23 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.ProjectManagement = void 0;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const error_1 = require("../utils/error");
|
|
21
|
+
const utils = require("../utils/index");
|
|
22
|
+
const validator = require("../utils/validator");
|
|
23
|
+
const android_app_1 = require("./android-app");
|
|
24
|
+
const ios_app_1 = require("./ios-app");
|
|
25
|
+
const project_management_api_request_internal_1 = require("./project-management-api-request-internal");
|
|
26
|
+
const app_metadata_1 = require("./app-metadata");
|
|
27
27
|
/**
|
|
28
28
|
* The Firebase ProjectManagement service interface.
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
class ProjectManagement {
|
|
31
31
|
/**
|
|
32
32
|
* @param app - The app for this ProjectManagement service.
|
|
33
33
|
* @constructor
|
|
34
34
|
* @internal
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
constructor(app) {
|
|
37
37
|
this.app = app;
|
|
38
38
|
if (!validator.isNonNullObject(app) || !('options' in app)) {
|
|
39
39
|
throw new error_1.FirebaseProjectManagementError('invalid-argument', 'First argument passed to admin.projectManagement() must be a valid Firebase app '
|
|
@@ -46,17 +46,17 @@ var ProjectManagement = /** @class */ (function () {
|
|
|
46
46
|
*
|
|
47
47
|
* @returns The list of Android apps.
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
listAndroidApps() {
|
|
50
50
|
return this.listPlatformApps('android', 'listAndroidApps()');
|
|
51
|
-
}
|
|
51
|
+
}
|
|
52
52
|
/**
|
|
53
53
|
* Lists up to 100 Firebase iOS apps associated with this Firebase project.
|
|
54
54
|
*
|
|
55
55
|
* @returns The list of iOS apps.
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
listIosApps() {
|
|
58
58
|
return this.listPlatformApps('ios', 'listIosApps()');
|
|
59
|
-
}
|
|
59
|
+
}
|
|
60
60
|
/**
|
|
61
61
|
* Creates an `AndroidApp` object, referencing the specified Android app within
|
|
62
62
|
* this Firebase project.
|
|
@@ -67,9 +67,9 @@ var ProjectManagement = /** @class */ (function () {
|
|
|
67
67
|
*
|
|
68
68
|
* @returns An `AndroidApp` object that references the specified Firebase Android app.
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
androidApp(appId) {
|
|
71
71
|
return new android_app_1.AndroidApp(appId, this.requestHandler);
|
|
72
|
-
}
|
|
72
|
+
}
|
|
73
73
|
/**
|
|
74
74
|
* Creates an `iOSApp` object, referencing the specified iOS app within
|
|
75
75
|
* this Firebase project.
|
|
@@ -80,9 +80,9 @@ var ProjectManagement = /** @class */ (function () {
|
|
|
80
80
|
*
|
|
81
81
|
* @returns An `iOSApp` object that references the specified Firebase iOS app.
|
|
82
82
|
*/
|
|
83
|
-
|
|
83
|
+
iosApp(appId) {
|
|
84
84
|
return new ios_app_1.IosApp(appId, this.requestHandler);
|
|
85
|
-
}
|
|
85
|
+
}
|
|
86
86
|
/**
|
|
87
87
|
* Creates a `ShaCertificate` object.
|
|
88
88
|
*
|
|
@@ -92,9 +92,9 @@ var ProjectManagement = /** @class */ (function () {
|
|
|
92
92
|
*
|
|
93
93
|
* @returns A `ShaCertificate` object contains the specified SHA hash.
|
|
94
94
|
*/
|
|
95
|
-
|
|
95
|
+
shaCertificate(shaHash) {
|
|
96
96
|
return new android_app_1.ShaCertificate(shaHash);
|
|
97
|
-
}
|
|
97
|
+
}
|
|
98
98
|
/**
|
|
99
99
|
* Creates a new Firebase Android app associated with this Firebase project.
|
|
100
100
|
*
|
|
@@ -105,18 +105,17 @@ var ProjectManagement = /** @class */ (function () {
|
|
|
105
105
|
*
|
|
106
106
|
* @returns A promise that resolves to the newly created Android app.
|
|
107
107
|
*/
|
|
108
|
-
|
|
109
|
-
var _this = this;
|
|
108
|
+
createAndroidApp(packageName, displayName) {
|
|
110
109
|
return this.getResourceName()
|
|
111
|
-
.then(
|
|
112
|
-
return
|
|
110
|
+
.then((resourceName) => {
|
|
111
|
+
return this.requestHandler.createAndroidApp(resourceName, packageName, displayName);
|
|
113
112
|
})
|
|
114
|
-
.then(
|
|
115
|
-
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createAndroidApp()\'s responseData must be a non-null object.');
|
|
116
|
-
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(responseData.appId), responseData, '"responseData.appId" field must be present in createAndroidApp()\'s response data.');
|
|
117
|
-
return new android_app_1.AndroidApp(responseData.appId,
|
|
113
|
+
.then((responseData) => {
|
|
114
|
+
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonNullObject(responseData), responseData, 'createAndroidApp()\'s responseData must be a non-null object.');
|
|
115
|
+
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonEmptyString(responseData.appId), responseData, '"responseData.appId" field must be present in createAndroidApp()\'s response data.');
|
|
116
|
+
return new android_app_1.AndroidApp(responseData.appId, this.requestHandler);
|
|
118
117
|
});
|
|
119
|
-
}
|
|
118
|
+
}
|
|
120
119
|
/**
|
|
121
120
|
* Creates a new Firebase iOS app associated with this Firebase project.
|
|
122
121
|
*
|
|
@@ -126,36 +125,34 @@ var ProjectManagement = /** @class */ (function () {
|
|
|
126
125
|
*
|
|
127
126
|
* @returns A promise that resolves to the newly created iOS app.
|
|
128
127
|
*/
|
|
129
|
-
|
|
130
|
-
var _this = this;
|
|
128
|
+
createIosApp(bundleId, displayName) {
|
|
131
129
|
return this.getResourceName()
|
|
132
|
-
.then(
|
|
133
|
-
return
|
|
130
|
+
.then((resourceName) => {
|
|
131
|
+
return this.requestHandler.createIosApp(resourceName, bundleId, displayName);
|
|
134
132
|
})
|
|
135
|
-
.then(
|
|
136
|
-
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, 'createIosApp()\'s responseData must be a non-null object.');
|
|
137
|
-
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(responseData.appId), responseData, '"responseData.appId" field must be present in createIosApp()\'s response data.');
|
|
138
|
-
return new ios_app_1.IosApp(responseData.appId,
|
|
133
|
+
.then((responseData) => {
|
|
134
|
+
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonNullObject(responseData), responseData, 'createIosApp()\'s responseData must be a non-null object.');
|
|
135
|
+
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonEmptyString(responseData.appId), responseData, '"responseData.appId" field must be present in createIosApp()\'s response data.');
|
|
136
|
+
return new ios_app_1.IosApp(responseData.appId, this.requestHandler);
|
|
139
137
|
});
|
|
140
|
-
}
|
|
138
|
+
}
|
|
141
139
|
/**
|
|
142
140
|
* Lists up to 100 Firebase apps associated with this Firebase project.
|
|
143
141
|
*
|
|
144
142
|
* @returns A promise that resolves to the metadata list of the apps.
|
|
145
143
|
*/
|
|
146
|
-
|
|
147
|
-
var _this = this;
|
|
144
|
+
listAppMetadata() {
|
|
148
145
|
return this.getResourceName()
|
|
149
|
-
.then(
|
|
150
|
-
return
|
|
146
|
+
.then((resourceName) => {
|
|
147
|
+
return this.requestHandler.listAppMetadata(resourceName);
|
|
151
148
|
})
|
|
152
|
-
.then(
|
|
153
|
-
return
|
|
154
|
-
.then(
|
|
155
|
-
return
|
|
149
|
+
.then((responseData) => {
|
|
150
|
+
return this.getProjectId()
|
|
151
|
+
.then((projectId) => {
|
|
152
|
+
return this.transformResponseToAppMetadata(responseData, projectId);
|
|
156
153
|
});
|
|
157
154
|
});
|
|
158
|
-
}
|
|
155
|
+
}
|
|
159
156
|
/**
|
|
160
157
|
* Update the display name of this Firebase project.
|
|
161
158
|
*
|
|
@@ -163,25 +160,24 @@ var ProjectManagement = /** @class */ (function () {
|
|
|
163
160
|
*
|
|
164
161
|
* @returns A promise that resolves when the project display name has been updated.
|
|
165
162
|
*/
|
|
166
|
-
|
|
167
|
-
var _this = this;
|
|
163
|
+
setDisplayName(newDisplayName) {
|
|
168
164
|
return this.getResourceName()
|
|
169
|
-
.then(
|
|
170
|
-
return
|
|
165
|
+
.then((resourceName) => {
|
|
166
|
+
return this.requestHandler.setDisplayName(resourceName, newDisplayName);
|
|
171
167
|
});
|
|
172
|
-
}
|
|
173
|
-
|
|
168
|
+
}
|
|
169
|
+
transformResponseToAppMetadata(responseData, projectId) {
|
|
174
170
|
this.assertListAppsResponseData(responseData, 'listAppMetadata()');
|
|
175
171
|
if (!responseData.apps) {
|
|
176
172
|
return [];
|
|
177
173
|
}
|
|
178
|
-
return responseData.apps.map(
|
|
179
|
-
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(appJson.appId), responseData, '"apps[].appId" field must be present in the listAppMetadata() response data.');
|
|
180
|
-
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(appJson.platform), responseData, '"apps[].platform" field must be present in the listAppMetadata() response data.');
|
|
181
|
-
|
|
174
|
+
return responseData.apps.map((appJson) => {
|
|
175
|
+
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonEmptyString(appJson.appId), responseData, '"apps[].appId" field must be present in the listAppMetadata() response data.');
|
|
176
|
+
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonEmptyString(appJson.platform), responseData, '"apps[].platform" field must be present in the listAppMetadata() response data.');
|
|
177
|
+
const metadata = {
|
|
182
178
|
appId: appJson.appId,
|
|
183
179
|
platform: app_metadata_1.AppPlatform[appJson.platform] || app_metadata_1.AppPlatform.PLATFORM_UNKNOWN,
|
|
184
|
-
projectId
|
|
180
|
+
projectId,
|
|
185
181
|
resourceName: appJson.name,
|
|
186
182
|
};
|
|
187
183
|
if (appJson.displayName) {
|
|
@@ -189,63 +185,60 @@ var ProjectManagement = /** @class */ (function () {
|
|
|
189
185
|
}
|
|
190
186
|
return metadata;
|
|
191
187
|
});
|
|
192
|
-
}
|
|
193
|
-
|
|
188
|
+
}
|
|
189
|
+
getResourceName() {
|
|
194
190
|
return this.getProjectId()
|
|
195
|
-
.then(
|
|
196
|
-
return
|
|
191
|
+
.then((projectId) => {
|
|
192
|
+
return `projects/${projectId}`;
|
|
197
193
|
});
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
var _this = this;
|
|
194
|
+
}
|
|
195
|
+
getProjectId() {
|
|
201
196
|
if (this.projectId) {
|
|
202
197
|
return Promise.resolve(this.projectId);
|
|
203
198
|
}
|
|
204
199
|
return utils.findProjectId(this.app)
|
|
205
|
-
.then(
|
|
200
|
+
.then((projectId) => {
|
|
206
201
|
// Assert that a specific project ID was provided within the app.
|
|
207
202
|
if (!validator.isNonEmptyString(projectId)) {
|
|
208
203
|
throw new error_1.FirebaseProjectManagementError('invalid-project-id', 'Failed to determine project ID. Initialize the SDK with service account credentials, or '
|
|
209
204
|
+ 'set project ID as an app option. Alternatively, set the GOOGLE_CLOUD_PROJECT '
|
|
210
205
|
+ 'environment variable.');
|
|
211
206
|
}
|
|
212
|
-
|
|
213
|
-
return
|
|
207
|
+
this.projectId = projectId;
|
|
208
|
+
return this.projectId;
|
|
214
209
|
});
|
|
215
|
-
}
|
|
210
|
+
}
|
|
216
211
|
/**
|
|
217
212
|
* Lists up to 100 Firebase apps for a specified platform, associated with this Firebase project.
|
|
218
213
|
*/
|
|
219
|
-
|
|
220
|
-
var _this = this;
|
|
214
|
+
listPlatformApps(platform, callerName) {
|
|
221
215
|
return this.getResourceName()
|
|
222
|
-
.then(
|
|
216
|
+
.then((resourceName) => {
|
|
223
217
|
return (platform === 'android') ?
|
|
224
|
-
|
|
225
|
-
:
|
|
218
|
+
this.requestHandler.listAndroidApps(resourceName)
|
|
219
|
+
: this.requestHandler.listIosApps(resourceName);
|
|
226
220
|
})
|
|
227
|
-
.then(
|
|
228
|
-
|
|
221
|
+
.then((responseData) => {
|
|
222
|
+
this.assertListAppsResponseData(responseData, callerName);
|
|
229
223
|
if (!responseData.apps) {
|
|
230
224
|
return [];
|
|
231
225
|
}
|
|
232
|
-
return responseData.apps.map(
|
|
233
|
-
project_management_api_request_internal_1.assertServerResponse(validator.isNonEmptyString(appJson.appId), responseData, "
|
|
226
|
+
return responseData.apps.map((appJson) => {
|
|
227
|
+
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonEmptyString(appJson.appId), responseData, `"apps[].appId" field must be present in the ${callerName} response data.`);
|
|
234
228
|
if (platform === 'android') {
|
|
235
|
-
return new android_app_1.AndroidApp(appJson.appId,
|
|
229
|
+
return new android_app_1.AndroidApp(appJson.appId, this.requestHandler);
|
|
236
230
|
}
|
|
237
231
|
else {
|
|
238
|
-
return new ios_app_1.IosApp(appJson.appId,
|
|
232
|
+
return new ios_app_1.IosApp(appJson.appId, this.requestHandler);
|
|
239
233
|
}
|
|
240
234
|
});
|
|
241
235
|
});
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
project_management_api_request_internal_1.assertServerResponse(validator.isNonNullObject(responseData), responseData, callerName
|
|
236
|
+
}
|
|
237
|
+
assertListAppsResponseData(responseData, callerName) {
|
|
238
|
+
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isNonNullObject(responseData), responseData, `${callerName}'s responseData must be a non-null object.`);
|
|
245
239
|
if (responseData.apps) {
|
|
246
|
-
project_management_api_request_internal_1.assertServerResponse(validator.isArray(responseData.apps), responseData, "
|
|
240
|
+
(0, project_management_api_request_internal_1.assertServerResponse)(validator.isArray(responseData.apps), responseData, `"apps" field must be present in the ${callerName} response data.`);
|
|
247
241
|
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
}());
|
|
242
|
+
}
|
|
243
|
+
}
|
|
251
244
|
exports.ProjectManagement = ProjectManagement;
|