firebase-tools 15.36.0 → 15.37.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/accountExporter.js +1 -1
- package/lib/accountImporter.js +7 -6
- package/lib/apiv2.js +0 -1
- package/lib/apptesting/parseTestFiles.js +1 -1
- package/lib/auth.js +1 -1
- package/lib/bin/progressiveHelp.js +1 -1
- package/lib/command.js +1 -2
- package/lib/commands/crashlytics-events-get.js +48 -0
- package/lib/commands/crashlytics-events-list.js +70 -0
- package/lib/commands/crashlytics-heapdumps-enable.js +3 -4
- package/lib/commands/crashlytics-heapdumps-status.js +5 -3
- package/lib/commands/crashlytics-issues-get.js +61 -0
- package/lib/commands/crashlytics-reports-get.js +179 -0
- package/lib/commands/crashlytics-reports-list.js +42 -0
- package/lib/commands/dataconnect-services-list.js +8 -2
- package/lib/commands/ext-dev-init.js +1 -1
- package/lib/commands/hosting-channel-open.js +4 -1
- package/lib/commands/index.js +10 -0
- package/lib/commands/open.js +3 -1
- package/lib/commands/serve.js +1 -1
- package/lib/commands/use.js +1 -1
- package/lib/config.js +1 -1
- package/lib/crashlytics/commandUtils.js +194 -0
- package/lib/crashlytics/events.js +8 -8
- package/lib/crashlytics/filters.js +1 -1
- package/lib/crashlytics/profilingManager.js +63 -16
- package/lib/crashlytics/reports.js +5 -1
- package/lib/dataconnect/client.js +14 -8
- package/lib/deploy/dataconnect/release.js +2 -2
- package/lib/deploy/firestore/prepare.js +21 -3
- package/lib/deploy/functions/cel.js +1 -1
- package/lib/deploy/functions/deploy.js +2 -1
- package/lib/deploy/functions/prepare.js +28 -0
- package/lib/deploy/functions/release/fabricator.js +27 -3
- package/lib/deploy/functions/release/planner.js +3 -0
- package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
- package/lib/deploy/functions/runtimes/supported/index.js +10 -4
- package/lib/deploy/functions/runtimes/supported/types.js +7 -1
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/functionsEmulator.js +73 -1
- package/lib/emulator/functionsEmulatorRuntime.js +2 -2
- package/lib/experiments.js +5 -0
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/firestore/delete.js +2 -3
- package/lib/frameworks/next/constants.js +17 -14
- package/lib/frameworks/next/index.js +25 -3
- package/lib/frameworks/next/utils.js +6 -8
- package/lib/gcp/cloudbilling.js +2 -2
- package/lib/gcp/cloudbuild.js +0 -77
- package/lib/gcp/cloudscheduler.js +12 -0
- package/lib/gcp/cloudtasks.js +0 -4
- package/lib/gcp/devConnect.js +0 -6
- package/lib/gcp/iam.js +15 -1
- package/lib/gcp/resourceManager.js +1 -14
- package/lib/gcp/storage.js +87 -4
- package/lib/hosting/api.js +0 -7
- package/lib/hosting/implicitInit.js +1 -1
- package/lib/hosting/proxy.js +1 -1
- package/lib/init/features/firestore/rules.js +1 -1
- package/lib/init/features/functions/index.js +2 -2
- package/lib/init/features/functions/npm-dependencies.js +1 -1
- package/lib/init/features/storage/rules.js +1 -1
- package/lib/localFunction.js +3 -3
- package/lib/management/database.js +1 -1
- package/lib/mcp/apps/init/mcp-app.js +1 -1
- package/lib/mcp/apps/update_environment/mcp-app.js +1 -1
- package/lib/mcp/index.js +6 -2
- package/lib/mcp/tools/crashlytics/reports.js +2 -2
- package/lib/mcp/util/dataconnect/converter.js +1 -1
- package/lib/profileReport.js +1 -1
- package/lib/profiler.js +1 -1
- package/lib/rulesDeploy.js +0 -1
- package/lib/throttler/throttler.js +1 -1
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +1 -1
- package/package.json +8 -7
- package/schema/firebase-config.json +3 -0
package/lib/gcp/cloudbuild.js
CHANGED
|
@@ -1,83 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createConnection = createConnection;
|
|
4
|
-
exports.getConnection = getConnection;
|
|
5
|
-
exports.listConnections = listConnections;
|
|
6
|
-
exports.deleteConnection = deleteConnection;
|
|
7
|
-
exports.fetchLinkableRepositories = fetchLinkableRepositories;
|
|
8
|
-
exports.createRepository = createRepository;
|
|
9
|
-
exports.getRepository = getRepository;
|
|
10
|
-
exports.deleteRepository = deleteRepository;
|
|
11
3
|
exports.getDefaultServiceAccount = getDefaultServiceAccount;
|
|
12
|
-
exports.getDefaultServiceAgent = getDefaultServiceAgent;
|
|
13
|
-
const apiv2_1 = require("../apiv2");
|
|
14
|
-
const api_1 = require("../api");
|
|
15
|
-
const PAGE_SIZE_MAX = 100;
|
|
16
|
-
const client = new apiv2_1.Client({
|
|
17
|
-
urlPrefix: (0, api_1.cloudbuildOrigin)(),
|
|
18
|
-
auth: true,
|
|
19
|
-
apiVersion: "v2",
|
|
20
|
-
});
|
|
21
|
-
async function createConnection(projectId, location, connectionId, githubConfig = {}) {
|
|
22
|
-
const res = await client.post(`projects/${projectId}/locations/${location}/connections`, { githubConfig }, { queryParams: { connectionId } });
|
|
23
|
-
return res.body;
|
|
24
|
-
}
|
|
25
|
-
async function getConnection(projectId, location, connectionId) {
|
|
26
|
-
const name = `projects/${projectId}/locations/${location}/connections/${connectionId}`;
|
|
27
|
-
const res = await client.get(name);
|
|
28
|
-
return res.body;
|
|
29
|
-
}
|
|
30
|
-
async function listConnections(projectId, location) {
|
|
31
|
-
const conns = [];
|
|
32
|
-
const getNextPage = async (pageToken = "") => {
|
|
33
|
-
const res = await client.get(`/projects/${projectId}/locations/${location}/connections`, {
|
|
34
|
-
queryParams: {
|
|
35
|
-
pageSize: PAGE_SIZE_MAX,
|
|
36
|
-
pageToken,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
if (Array.isArray(res.body.connections)) {
|
|
40
|
-
conns.push(...res.body.connections);
|
|
41
|
-
}
|
|
42
|
-
if (res.body.nextPageToken) {
|
|
43
|
-
await getNextPage(res.body.nextPageToken);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
await getNextPage();
|
|
47
|
-
return conns;
|
|
48
|
-
}
|
|
49
|
-
async function deleteConnection(projectId, location, connectionId) {
|
|
50
|
-
const name = `projects/${projectId}/locations/${location}/connections/${connectionId}`;
|
|
51
|
-
const res = await client.delete(name);
|
|
52
|
-
return res.body;
|
|
53
|
-
}
|
|
54
|
-
async function fetchLinkableRepositories(projectId, location, connectionId, pageToken = "", pageSize = 1000) {
|
|
55
|
-
const name = `projects/${projectId}/locations/${location}/connections/${connectionId}:fetchLinkableRepositories`;
|
|
56
|
-
const res = await client.get(name, {
|
|
57
|
-
queryParams: {
|
|
58
|
-
pageSize,
|
|
59
|
-
pageToken,
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
return res.body;
|
|
63
|
-
}
|
|
64
|
-
async function createRepository(projectId, location, connectionId, repositoryId, remoteUri) {
|
|
65
|
-
const res = await client.post(`projects/${projectId}/locations/${location}/connections/${connectionId}/repositories`, { remoteUri }, { queryParams: { repositoryId } });
|
|
66
|
-
return res.body;
|
|
67
|
-
}
|
|
68
|
-
async function getRepository(projectId, location, connectionId, repositoryId) {
|
|
69
|
-
const name = `projects/${projectId}/locations/${location}/connections/${connectionId}/repositories/${repositoryId}`;
|
|
70
|
-
const res = await client.get(name);
|
|
71
|
-
return res.body;
|
|
72
|
-
}
|
|
73
|
-
async function deleteRepository(projectId, location, connectionId, repositoryId) {
|
|
74
|
-
const name = `projects/${projectId}/locations/${location}/connections/${connectionId}/repositories/${repositoryId}`;
|
|
75
|
-
const res = await client.delete(name);
|
|
76
|
-
return res.body;
|
|
77
|
-
}
|
|
78
4
|
function getDefaultServiceAccount(projectNumber) {
|
|
79
5
|
return `${projectNumber}@cloudbuild.gserviceaccount.com`;
|
|
80
6
|
}
|
|
81
|
-
function getDefaultServiceAgent(projectNumber) {
|
|
82
|
-
return `service-${projectNumber}@gcp-sa-cloudbuild.iam.gserviceaccount.com`;
|
|
83
|
-
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deleteJob = deleteJob;
|
|
4
4
|
exports.getJob = getJob;
|
|
5
|
+
exports.listLocations = listLocations;
|
|
5
6
|
exports.createOrReplaceJob = createOrReplaceJob;
|
|
6
7
|
exports.jobNameForEndpoint = jobNameForEndpoint;
|
|
7
8
|
exports.topicNameForEndpoint = topicNameForEndpoint;
|
|
@@ -35,6 +36,17 @@ function getJob(name) {
|
|
|
35
36
|
resolveOnHTTPError: true,
|
|
36
37
|
});
|
|
37
38
|
}
|
|
39
|
+
async function listLocations(projectId) {
|
|
40
|
+
const locations = [];
|
|
41
|
+
let pageToken;
|
|
42
|
+
do {
|
|
43
|
+
const queryParams = pageToken ? { pageToken } : {};
|
|
44
|
+
const res = await apiClient.get(`/projects/${projectId}/locations`, { queryParams });
|
|
45
|
+
locations.push(...(res.body?.locations?.map((l) => l.locationId) ?? []));
|
|
46
|
+
pageToken = res.body?.nextPageToken;
|
|
47
|
+
} while (pageToken);
|
|
48
|
+
return locations;
|
|
49
|
+
}
|
|
38
50
|
function updateJob(job) {
|
|
39
51
|
let fieldMasks;
|
|
40
52
|
let json;
|
package/lib/gcp/cloudtasks.js
CHANGED
|
@@ -7,7 +7,6 @@ exports.updateQueue = updateQueue;
|
|
|
7
7
|
exports.upsertQueue = upsertQueue;
|
|
8
8
|
exports.disableQueue = disableQueue;
|
|
9
9
|
exports.purgeQueue = purgeQueue;
|
|
10
|
-
exports.deleteQueue = deleteQueue;
|
|
11
10
|
exports.enqueueTask = enqueueTask;
|
|
12
11
|
exports.setIamPolicy = setIamPolicy;
|
|
13
12
|
exports.getIamPolicy = getIamPolicy;
|
|
@@ -89,9 +88,6 @@ async function disableQueue(name) {
|
|
|
89
88
|
async function purgeQueue(name) {
|
|
90
89
|
await client.post(`${name}:purge`);
|
|
91
90
|
}
|
|
92
|
-
async function deleteQueue(name) {
|
|
93
|
-
await client.delete(name);
|
|
94
|
-
}
|
|
95
91
|
async function enqueueTask(queueName, task) {
|
|
96
92
|
await client.post(`${queueName}/tasks`, { task });
|
|
97
93
|
}
|
package/lib/gcp/devConnect.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.client = void 0;
|
|
4
4
|
exports.createConnection = createConnection;
|
|
5
|
-
exports.deleteConnection = deleteConnection;
|
|
6
5
|
exports.getConnection = getConnection;
|
|
7
6
|
exports.listAllConnections = listAllConnections;
|
|
8
7
|
exports.listAllLinkableGitRepositories = listAllLinkableGitRepositories;
|
|
@@ -39,11 +38,6 @@ async function createConnection(projectId, location, connectionId, githubConfig
|
|
|
39
38
|
}, { queryParams: { connectionId } });
|
|
40
39
|
return res.body;
|
|
41
40
|
}
|
|
42
|
-
async function deleteConnection(projectId, location, connectionId) {
|
|
43
|
-
const name = `projects/${projectId}/locations/${LOCATION_OVERRIDE ?? location}/connections/${connectionId}`;
|
|
44
|
-
const res = await exports.client.delete(name, { queryParams: { force: "true" } });
|
|
45
|
-
return res.body;
|
|
46
|
-
}
|
|
47
41
|
async function getConnection(projectId, location, connectionId) {
|
|
48
42
|
const name = `projects/${projectId}/locations/${LOCATION_OVERRIDE ?? location}/connections/${connectionId}`;
|
|
49
43
|
const res = await exports.client.get(name);
|
package/lib/gcp/iam.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.listServiceAccountKeys = listServiceAccountKeys;
|
|
|
8
8
|
exports.getRole = getRole;
|
|
9
9
|
exports.testResourceIamPermissions = testResourceIamPermissions;
|
|
10
10
|
exports.testIamPermissions = testIamPermissions;
|
|
11
|
+
exports.isRetryableIamError = isRetryableIamError;
|
|
11
12
|
exports.mergeBindings = mergeBindings;
|
|
12
13
|
exports.printManualIamConfig = printManualIamConfig;
|
|
13
14
|
exports.getRoleName = getRoleName;
|
|
@@ -88,10 +89,23 @@ async function testResourceIamPermissions(origin, apiVersion, resourceName, perm
|
|
|
88
89
|
async function testIamPermissions(projectId, permissions) {
|
|
89
90
|
return testResourceIamPermissions((0, api_1.resourceManagerOrigin)(), "v1", `projects/${projectId}`, permissions, `${projectId}`);
|
|
90
91
|
}
|
|
92
|
+
function isRetryableIamError(err) {
|
|
93
|
+
const status = (0, error_1.getErrStatus)(err);
|
|
94
|
+
if (status === 409) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
const msg = (0, error_1.getErrMsg)(err).toLowerCase();
|
|
98
|
+
const hasSa = msg.includes("service account") || msg.includes("serviceaccount");
|
|
99
|
+
if (status === 400 && hasSa && msg.includes("does not exist")) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
91
104
|
function mergeBindings(policy, requiredBindings) {
|
|
92
105
|
let updated = false;
|
|
106
|
+
policy.bindings = policy.bindings || [];
|
|
93
107
|
for (const requiredBinding of requiredBindings) {
|
|
94
|
-
const match = policy.bindings.find((b) => b.role === requiredBinding.role);
|
|
108
|
+
const match = policy.bindings.find((b) => b.role === requiredBinding.role && !b.condition && !requiredBinding.condition);
|
|
95
109
|
if (!match) {
|
|
96
110
|
updated = true;
|
|
97
111
|
policy.bindings.push(requiredBinding);
|
|
@@ -9,7 +9,6 @@ exports.removeServiceAccountRoles = removeServiceAccountRoles;
|
|
|
9
9
|
exports.getServiceAccountRoles = getServiceAccountRoles;
|
|
10
10
|
const api_1 = require("../api");
|
|
11
11
|
const apiv2_1 = require("../apiv2");
|
|
12
|
-
const error_1 = require("../error");
|
|
13
12
|
const utils = require("../utils");
|
|
14
13
|
const iam_1 = require("./iam");
|
|
15
14
|
const API_VERSION = "v1";
|
|
@@ -33,18 +32,6 @@ async function setIamPolicy(projectIdOrNumber, newPolicy, updateMask = "") {
|
|
|
33
32
|
});
|
|
34
33
|
return response.body;
|
|
35
34
|
}
|
|
36
|
-
function isRetryableIamError(err) {
|
|
37
|
-
const status = (0, error_1.getErrStatus)(err);
|
|
38
|
-
if (status === 409) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
const msg = (0, error_1.getErrMsg)(err).toLowerCase();
|
|
42
|
-
const hasSa = msg.includes("service account") || msg.includes("serviceaccount");
|
|
43
|
-
if (status === 400 && hasSa && msg.includes("does not exist")) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
35
|
async function addServiceAccountToRoles(projectId, serviceAccountName, roles, skipAccountLookup = false) {
|
|
49
36
|
const { name: fullServiceAccountName } = skipAccountLookup
|
|
50
37
|
? { name: serviceAccountName }
|
|
@@ -63,7 +50,7 @@ async function addServiceAccountToRoles(projectId, serviceAccountName, roles, sk
|
|
|
63
50
|
retries: 7,
|
|
64
51
|
delay: 1000,
|
|
65
52
|
maxDelay: 5000,
|
|
66
|
-
retryPredicate: isRetryableIamError,
|
|
53
|
+
retryPredicate: iam_1.isRetryableIamError,
|
|
67
54
|
});
|
|
68
55
|
}
|
|
69
56
|
async function serviceAccountHasRoles(projectId, serviceAccountName, roles, skipAccountLookup = false) {
|
package/lib/gcp/storage.js
CHANGED
|
@@ -14,6 +14,9 @@ exports.upsertBucket = upsertBucket;
|
|
|
14
14
|
exports.listBuckets = listBuckets;
|
|
15
15
|
exports.getServiceAccount = getServiceAccount;
|
|
16
16
|
exports.getDownloadUrl = getDownloadUrl;
|
|
17
|
+
exports.getBucketIamPolicy = getBucketIamPolicy;
|
|
18
|
+
exports.setBucketIamPolicy = setBucketIamPolicy;
|
|
19
|
+
exports.addServiceAccountToBucketRoles = addServiceAccountToBucketRoles;
|
|
17
20
|
const path = require("path");
|
|
18
21
|
const clc = require("colorette");
|
|
19
22
|
const crypto_1 = require("crypto");
|
|
@@ -24,6 +27,11 @@ const logger_1 = require("../logger");
|
|
|
24
27
|
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
25
28
|
const utils = require("../utils");
|
|
26
29
|
const proto_1 = require("./proto");
|
|
30
|
+
const iam_1 = require("./iam");
|
|
31
|
+
const BUCKET_IAM_POLICY_VERSION = "3";
|
|
32
|
+
const IAM_RETRY_COUNT = 7;
|
|
33
|
+
const IAM_RETRY_INITIAL_DELAY_MS = 1000;
|
|
34
|
+
const IAM_RETRY_MAX_DELAY_MS = 5000;
|
|
27
35
|
var ContentType;
|
|
28
36
|
(function (ContentType) {
|
|
29
37
|
ContentType["ZIP"] = "ZIP";
|
|
@@ -126,11 +134,27 @@ async function getBucket(bucketName) {
|
|
|
126
134
|
});
|
|
127
135
|
}
|
|
128
136
|
}
|
|
137
|
+
function extractApiErrorMessage(err) {
|
|
138
|
+
if (!(0, error_1.isObject)(err) || !(0, error_1.isObject)(err.context) || !(0, error_1.isObject)(err.context.body)) {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
const apiError = err.context.body.error;
|
|
142
|
+
if (typeof apiError === "string" && apiError.trim()) {
|
|
143
|
+
return apiError.trim();
|
|
144
|
+
}
|
|
145
|
+
if ((0, error_1.isObject)(apiError) &&
|
|
146
|
+
typeof apiError.message === "string" &&
|
|
147
|
+
apiError.message.trim() &&
|
|
148
|
+
apiError.message !== "Unknown Error") {
|
|
149
|
+
return apiError.message.trim();
|
|
150
|
+
}
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
129
153
|
async function createBucket(projectId, req, projectPrivate) {
|
|
130
154
|
const queryParams = {
|
|
131
155
|
project: projectId,
|
|
132
156
|
};
|
|
133
|
-
if (projectPrivate) {
|
|
157
|
+
if (projectPrivate && !req.iamConfiguration?.uniformBucketLevelAccess?.enabled) {
|
|
134
158
|
queryParams["predefinedAcl"] = "projectPrivate";
|
|
135
159
|
queryParams["predefinedDefaultObjectAcl"] = "projectPrivate";
|
|
136
160
|
}
|
|
@@ -140,9 +164,14 @@ async function createBucket(projectId, req, projectPrivate) {
|
|
|
140
164
|
return result.body;
|
|
141
165
|
}
|
|
142
166
|
catch (err) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
167
|
+
const error = (0, error_1.getError)(err);
|
|
168
|
+
logger_1.logger.debug(error);
|
|
169
|
+
const detail = extractApiErrorMessage(err) || error.message;
|
|
170
|
+
throw new error_1.FirebaseError(detail
|
|
171
|
+
? `Failed to create the storage bucket: ${detail}`
|
|
172
|
+
: "Failed to create the storage bucket", {
|
|
173
|
+
original: error,
|
|
174
|
+
status: (0, error_1.getErrStatus)(err),
|
|
146
175
|
});
|
|
147
176
|
}
|
|
148
177
|
}
|
|
@@ -270,3 +299,57 @@ async function getDownloadUrl(bucketName, objectPath, emulatorUrl) {
|
|
|
270
299
|
});
|
|
271
300
|
}
|
|
272
301
|
}
|
|
302
|
+
async function getBucketIamPolicy(bucketName) {
|
|
303
|
+
try {
|
|
304
|
+
const localAPIClient = new apiv2_1.Client({ urlPrefix: (0, api_1.storageOrigin)() });
|
|
305
|
+
const response = await localAPIClient.get(`/storage/v1/b/${bucketName}/iam`, {
|
|
306
|
+
queryParams: { optionsRequestedPolicyVersion: BUCKET_IAM_POLICY_VERSION },
|
|
307
|
+
});
|
|
308
|
+
return response.body;
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
const error = (0, error_1.getError)(err);
|
|
312
|
+
logger_1.logger.debug(error);
|
|
313
|
+
throw new error_1.FirebaseError("Failed to get the storage bucket IAM policy", {
|
|
314
|
+
original: error,
|
|
315
|
+
status: (0, error_1.getErrStatus)(err),
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
async function setBucketIamPolicy(bucketName, policy) {
|
|
320
|
+
try {
|
|
321
|
+
const localAPIClient = new apiv2_1.Client({ urlPrefix: (0, api_1.storageOrigin)() });
|
|
322
|
+
const response = await localAPIClient.put(`/storage/v1/b/${bucketName}/iam`, policy);
|
|
323
|
+
return response.body;
|
|
324
|
+
}
|
|
325
|
+
catch (err) {
|
|
326
|
+
const error = (0, error_1.getError)(err);
|
|
327
|
+
logger_1.logger.debug(error);
|
|
328
|
+
throw new error_1.FirebaseError("Failed to set the storage bucket IAM policy", {
|
|
329
|
+
original: error,
|
|
330
|
+
status: (0, error_1.getErrStatus)(err),
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
async function addServiceAccountToBucketRoles(bucketName, serviceAccountEmail, roles) {
|
|
335
|
+
const email = serviceAccountEmail.split("/").pop() || serviceAccountEmail;
|
|
336
|
+
const memberName = `serviceAccount:${email}`;
|
|
337
|
+
return await utils.retryWithBackoff(async () => {
|
|
338
|
+
const policy = await dynamicDispatch.getBucketIamPolicy(bucketName);
|
|
339
|
+
policy.bindings = policy.bindings || [];
|
|
340
|
+
const requiredBindings = roles.map((role) => ({
|
|
341
|
+
role,
|
|
342
|
+
members: [memberName],
|
|
343
|
+
}));
|
|
344
|
+
const updated = (0, iam_1.mergeBindings)(policy, requiredBindings);
|
|
345
|
+
if (!updated) {
|
|
346
|
+
return policy;
|
|
347
|
+
}
|
|
348
|
+
return await dynamicDispatch.setBucketIamPolicy(bucketName, policy);
|
|
349
|
+
}, {
|
|
350
|
+
retries: IAM_RETRY_COUNT,
|
|
351
|
+
delay: IAM_RETRY_INITIAL_DELAY_MS,
|
|
352
|
+
maxDelay: IAM_RETRY_MAX_DELAY_MS,
|
|
353
|
+
retryPredicate: iam_1.isRetryableIamError,
|
|
354
|
+
});
|
|
355
|
+
}
|
package/lib/hosting/api.js
CHANGED
|
@@ -16,7 +16,6 @@ exports.listSites = listSites;
|
|
|
16
16
|
exports.listDemoSites = listDemoSites;
|
|
17
17
|
exports.getSite = getSite;
|
|
18
18
|
exports.createSite = createSite;
|
|
19
|
-
exports.updateSite = updateSite;
|
|
20
19
|
exports.deleteSite = deleteSite;
|
|
21
20
|
exports.addAuthDomains = addAuthDomains;
|
|
22
21
|
exports.removeAuthDomain = removeAuthDomain;
|
|
@@ -208,12 +207,6 @@ async function createSite(project, site, appId = "", validateOnly = false) {
|
|
|
208
207
|
const res = await apiClient.post(`/projects/${project}/sites`, { appId: appId }, { queryParams });
|
|
209
208
|
return res.body;
|
|
210
209
|
}
|
|
211
|
-
async function updateSite(project, site, fields) {
|
|
212
|
-
const res = await apiClient.patch(`/projects/${project}/sites/${site.name}`, site, {
|
|
213
|
-
queryParams: { updateMask: fields.join(",") },
|
|
214
|
-
});
|
|
215
|
-
return res.body;
|
|
216
|
-
}
|
|
217
210
|
async function deleteSite(project, site) {
|
|
218
211
|
await apiClient.delete(`/projects/${project}/sites/${site}`);
|
|
219
212
|
}
|
|
@@ -15,7 +15,7 @@ async function implicitInit(options) {
|
|
|
15
15
|
config = await (0, fetchWebSetup_1.fetchWebSetup)(options);
|
|
16
16
|
}
|
|
17
17
|
catch (e) {
|
|
18
|
-
logger_1.logger.debug(
|
|
18
|
+
logger_1.logger.debug(`fetchWebSetup error: ${String(e)}`);
|
|
19
19
|
const statusCode = _.get(e, "context.response.statusCode");
|
|
20
20
|
if (statusCode === 403) {
|
|
21
21
|
utils.logLabeledWarning("hosting", `Authentication error when trying to fetch your current web app configuration, have you run ${clc.bold("firebase login")}?`);
|
package/lib/hosting/proxy.js
CHANGED
|
@@ -33,7 +33,7 @@ function proxyRequestHandler(url, rewriteIdentifier, options = {}) {
|
|
|
33
33
|
const sessionCookie = cookie.split(/; ?/).find((c) => {
|
|
34
34
|
return c.trim().startsWith("__session=");
|
|
35
35
|
});
|
|
36
|
-
const u = new url_1.URL(url
|
|
36
|
+
const u = new url_1.URL(`${url}${req.url ?? ""}`);
|
|
37
37
|
const c = new apiv2_1.Client({ urlPrefix: u.origin, auth: false });
|
|
38
38
|
let body;
|
|
39
39
|
let passThrough;
|
|
@@ -49,7 +49,7 @@ async function getRulesFromConsole(projectId) {
|
|
|
49
49
|
return utils.reject("Ruleset has no files", { exit: 1 });
|
|
50
50
|
}
|
|
51
51
|
if (rules.length > 1) {
|
|
52
|
-
return utils.reject(
|
|
52
|
+
return utils.reject(`Ruleset has too many files: ${rules.length}`, { exit: 1 });
|
|
53
53
|
}
|
|
54
54
|
return rules[0].content;
|
|
55
55
|
}
|
|
@@ -195,7 +195,7 @@ async function languageSetup(setup) {
|
|
|
195
195
|
}
|
|
196
196
|
async function actuate(setup, config) {
|
|
197
197
|
if (setup.languageOverride) {
|
|
198
|
-
return require(
|
|
198
|
+
return require(`./${String(setup.languageOverride)}`).setup(setup, config);
|
|
199
199
|
}
|
|
200
|
-
return require(
|
|
200
|
+
return require(`./${String(setup.functions.languageChoice)}`).setup(setup, config);
|
|
201
201
|
}
|
|
@@ -11,7 +11,7 @@ async function askInstallDependencies(setup, config) {
|
|
|
11
11
|
});
|
|
12
12
|
if (setup.npm) {
|
|
13
13
|
try {
|
|
14
|
-
await (0, spawn_1.wrapSpawn)("npm", ["install"], config.projectDir
|
|
14
|
+
await (0, spawn_1.wrapSpawn)("npm", ["install"], `${String(config.projectDir)}/${setup.source}`);
|
|
15
15
|
}
|
|
16
16
|
catch (e) {
|
|
17
17
|
logger_1.logger.info();
|
|
@@ -15,7 +15,7 @@ async function getRulesFromConsole(projectId) {
|
|
|
15
15
|
return utils.reject("Ruleset has no files", { exit: 1 });
|
|
16
16
|
}
|
|
17
17
|
if (rules.length > 1) {
|
|
18
|
-
return utils.reject(
|
|
18
|
+
return utils.reject(`Ruleset has too many files: ${rules.length}`, { exit: 1 });
|
|
19
19
|
}
|
|
20
20
|
return rules[0].content;
|
|
21
21
|
}
|
package/lib/localFunction.js
CHANGED
|
@@ -20,7 +20,7 @@ class LocalFunction {
|
|
|
20
20
|
return resource.replace(this.paramWildcardRegex, (wildcard) => {
|
|
21
21
|
const wildcardNoBraces = wildcard.slice(1, -1);
|
|
22
22
|
const sub = params?.[wildcardNoBraces];
|
|
23
|
-
return sub || wildcardNoBraces
|
|
23
|
+
return sub || `${wildcardNoBraces}${utils.randomInt(1, 9)}`;
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
constructCallableFunc(data, opts) {
|
|
@@ -156,9 +156,9 @@ class LocalFunction {
|
|
|
156
156
|
}
|
|
157
157
|
requestCallBack(err, response, body) {
|
|
158
158
|
if (err) {
|
|
159
|
-
return console.warn(
|
|
159
|
+
return console.warn(`\nERROR SENDING REQUEST: ${String(err)}`);
|
|
160
160
|
}
|
|
161
|
-
const status = response ? response.status
|
|
161
|
+
const status = response ? `${response.status}, ` : "";
|
|
162
162
|
let bodyString = body;
|
|
163
163
|
if (typeof bodyString === "string") {
|
|
164
164
|
try {
|
|
@@ -104,7 +104,7 @@ async function checkInstanceNameAvailable(projectId, instanceName, databaseType,
|
|
|
104
104
|
return { available: true };
|
|
105
105
|
}
|
|
106
106
|
catch (err) {
|
|
107
|
-
logger_1.logger.debug(`Invalid Realtime Database instance name: ${instanceName}.${err.message ?
|
|
107
|
+
logger_1.logger.debug(`Invalid Realtime Database instance name: ${instanceName}.${err.message ? ` ${String(err.message)}` : ""}`);
|
|
108
108
|
const errBody = err.context.body.error;
|
|
109
109
|
if (errBody?.details?.[0]?.metadata?.suggested_database_ids) {
|
|
110
110
|
return {
|
|
@@ -174,7 +174,7 @@ app.onhostcontextchanged = (ctx) => {
|
|
|
174
174
|
document.body.style.padding = `${top}px ${right}px ${bottom}px ${left}px`;
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
|
-
(async () => {
|
|
177
|
+
void (async () => {
|
|
178
178
|
const envDirEl = document.getElementById("env-dir");
|
|
179
179
|
try {
|
|
180
180
|
await app.connect();
|
package/lib/mcp/index.js
CHANGED
|
@@ -493,12 +493,16 @@ class FirebaseMcpServer {
|
|
|
493
493
|
const message = this._pendingMessages.shift();
|
|
494
494
|
if (!message)
|
|
495
495
|
continue;
|
|
496
|
-
this.server
|
|
496
|
+
this.server
|
|
497
|
+
.sendLoggingMessage({
|
|
497
498
|
level: message.level,
|
|
498
499
|
data: message.data,
|
|
500
|
+
})
|
|
501
|
+
.catch(() => {
|
|
499
502
|
});
|
|
500
503
|
}
|
|
501
|
-
|
|
504
|
+
this.server.sendLoggingMessage({ level, data }).catch(() => {
|
|
505
|
+
});
|
|
502
506
|
}
|
|
503
507
|
else {
|
|
504
508
|
this._pendingMessages.push({ level, data });
|
|
@@ -33,7 +33,7 @@ exports.get_report = (0, tool_1.tool)("crashlytics", {
|
|
|
33
33
|
_meta: {
|
|
34
34
|
requiresAuth: true,
|
|
35
35
|
},
|
|
36
|
-
}, async ({ appId, report, pageSize, filter, granularity }) => {
|
|
36
|
+
}, async ({ appId, report, pageSize, filter, filterExpression, granularity }) => {
|
|
37
37
|
const result = { content: [] };
|
|
38
38
|
if (!appId) {
|
|
39
39
|
result.isError = true;
|
|
@@ -52,7 +52,7 @@ exports.get_report = (0, tool_1.tool)("crashlytics", {
|
|
|
52
52
|
return result;
|
|
53
53
|
}
|
|
54
54
|
try {
|
|
55
|
-
const reportResponse = (0, reports_1.simplifyReport)(await (0, reports_1.getReport)(report, appId, filter, pageSize, granularity));
|
|
55
|
+
const reportResponse = (0, reports_1.simplifyReport)(await (0, reports_1.getReport)(report, appId, filter, pageSize, granularity, filterExpression));
|
|
56
56
|
reportResponse.usage =
|
|
57
57
|
reportResponse.groups && reportResponse.groups.length
|
|
58
58
|
? reportResponse.usage || ""
|
|
@@ -23,7 +23,7 @@ function parseVariables(unparsedVariables) {
|
|
|
23
23
|
obj = JSON.parse(unparsedVariables || "{}");
|
|
24
24
|
}
|
|
25
25
|
catch (e) {
|
|
26
|
-
throw new Error(
|
|
26
|
+
throw new Error(`Provided variables string \`${String(unparsedVariables)}\` is not valid JSON.`);
|
|
27
27
|
}
|
|
28
28
|
if (typeof obj !== "object" || obj == null)
|
|
29
29
|
throw new Error("not an object");
|
package/lib/profileReport.js
CHANGED
|
@@ -50,7 +50,7 @@ function formatNumber(num) {
|
|
|
50
50
|
function formatBytes(bytes) {
|
|
51
51
|
const threshold = 1000;
|
|
52
52
|
if (Math.round(bytes) < threshold) {
|
|
53
|
-
return bytes
|
|
53
|
+
return `${bytes} B`;
|
|
54
54
|
}
|
|
55
55
|
const units = ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
56
56
|
let u = -1;
|
package/lib/profiler.js
CHANGED
package/lib/rulesDeploy.js
CHANGED