firebase-tools-with-isolate 15.36.0 → 15.38.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 +15 -10
- package/lib/apiv2.js +66 -12
- package/lib/appUtils.js +103 -40
- package/lib/appdistribution/client.js +5 -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/appdistribution-distribute.js +5 -3
- package/lib/commands/crashlytics-events-get.js +46 -0
- package/lib/commands/crashlytics-events-list.js +68 -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 +65 -0
- package/lib/commands/crashlytics-reports-get.js +267 -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 +227 -0
- package/lib/crashlytics/events.js +71 -73
- 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 +23 -17
- 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/python/index.js +3 -0
- package/lib/deploy/functions/runtimes/supported/index.js +10 -4
- package/lib/deploy/functions/runtimes/supported/types.js +13 -1
- package/lib/deploy/run/deploy.js +40 -35
- package/lib/deploy/run/prereqs.js +0 -3
- package/lib/downloadUtils.js +2 -1
- package/lib/emulator/download.js +1 -0
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/downloadableEmulators.js +14 -2
- package/lib/emulator/events/types.js +0 -6
- package/lib/emulator/functionsEmulator.js +73 -1
- package/lib/emulator/functionsEmulatorRuntime.js +2 -2
- package/lib/emulator/storage/cloudFunctions.js +0 -1
- package/lib/emulator/storage/rules/runtime.js +0 -3
- package/lib/emulator/taskQueue.js +0 -12
- package/lib/experiments.js +10 -0
- package/lib/extensions/extensionsHelper.js +1 -4
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/replacements.json +2 -1
- package/lib/firestore/delete.js +2 -3
- package/lib/firestore/fsConfig.js +100 -41
- package/lib/frameworks/next/constants.js +17 -14
- package/lib/frameworks/next/index.js +2 -2
- 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/runv2.js +0 -27
- package/lib/gcp/secretManager.js +2 -2
- package/lib/gcp/storage.js +87 -4
- package/lib/hosting/api.js +29 -23
- package/lib/hosting/implicitInit.js +1 -1
- package/lib/hosting/proxy.js +1 -1
- package/lib/init/features/dataconnect/sdk.js +15 -5
- 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/apps.js +7 -0
- 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 +10 -4
- package/lib/mcp/tools/core/get_environment.js +1 -1
- package/lib/mcp/tools/crashlytics/events.js +2 -5
- package/lib/mcp/tools/crashlytics/reports.js +5 -14
- package/lib/mcp/util/apptesting/availability.js +3 -2
- package/lib/mcp/util/crashlytics/availability.js +59 -12
- package/lib/mcp/util/dataconnect/converter.js +1 -1
- package/lib/mcp/util.js +4 -0
- package/lib/profileReport.js +1 -1
- package/lib/profiler.js +1 -1
- package/lib/requireAuth.js +11 -7
- package/lib/rulesDeploy.js +0 -1
- package/lib/throttler/throttler.js +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +1 -1
- package/package.json +15 -12
- package/schema/firebase-config.json +9 -3
- package/standalone/package.json +6 -1
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/runv2.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FIREBASE_FUNCTION_METADTA_ANNOTATION = exports.FUNCTION_SIGNATURE_TYPE_ENV = exports.FUNCTION_TARGET_ENV = exports.FUNCTION_ID_ANNOTATION = exports.FUNCTION_TARGET_ANNOTATION = exports.TRIGGER_TYPE_ANNOTATION = exports.CLIENT_NAME_LABEL = exports.RUNTIME_LABEL = exports.API_VERSION = void 0;
|
|
4
|
-
exports.submitBuild = submitBuild;
|
|
5
4
|
exports.updateService = updateService;
|
|
6
5
|
exports.createService = createService;
|
|
7
6
|
exports.deleteService = deleteService;
|
|
@@ -28,32 +27,6 @@ const client = new apiv2_1.Client({
|
|
|
28
27
|
apiVersion: exports.API_VERSION,
|
|
29
28
|
});
|
|
30
29
|
(0, metaprogramming_1.assertImplements)();
|
|
31
|
-
const PENDING_BUILD_STATUSES = ["STATUS_UNKNOWN", "PENDING", "QUEUED", "WORKING"];
|
|
32
|
-
async function submitBuild(projectId, location, build) {
|
|
33
|
-
const res = await client.post(`/projects/${projectId}/locations/${location}/builds:submit`, build);
|
|
34
|
-
if (res.body?.baseImageWarning) {
|
|
35
|
-
logger_1.logger.warn(res.body.baseImageWarning);
|
|
36
|
-
}
|
|
37
|
-
const cloudBuild = res.body?.buildOperation?.metadata?.build;
|
|
38
|
-
if (!cloudBuild) {
|
|
39
|
-
throw new error_1.FirebaseError("Failed to submit build: no build was returned.");
|
|
40
|
-
}
|
|
41
|
-
let status;
|
|
42
|
-
await (0, operation_poller_1.pollOperation)({
|
|
43
|
-
apiOrigin: (0, api_1.cloudbuildOrigin)(),
|
|
44
|
-
apiVersion: "v1",
|
|
45
|
-
operationResourceName: cloudBuild.name,
|
|
46
|
-
masterTimeout: 30 * 60 * 1000,
|
|
47
|
-
maxBackoff: 10000,
|
|
48
|
-
doneFn: (b) => {
|
|
49
|
-
status = b?.status;
|
|
50
|
-
return !b?.status || !PENDING_BUILD_STATUSES.includes(b.status);
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
if (status !== "SUCCESS") {
|
|
54
|
-
throw new error_1.FirebaseError(`Cloud Build failed with status ${status ?? "UNKNOWN"}. View the build logs at ${cloudBuild.logUrl ?? ""}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
30
|
async function updateService(service, opts = {}) {
|
|
58
31
|
let updateMask = opts.updateMask;
|
|
59
32
|
if (!updateMask) {
|
package/lib/gcp/secretManager.js
CHANGED
|
@@ -116,7 +116,7 @@ async function getSecretVersion(projectId, name, version) {
|
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
async function accessSecretVersion(projectId, name, version) {
|
|
119
|
-
const res = await client.get(`projects/${projectId}/secrets/${name}/versions/${version}:access
|
|
119
|
+
const res = await client.get(`projects/${projectId}/secrets/${name}/versions/${version}:access`, { skipLog: { resBody: true } });
|
|
120
120
|
return Buffer.from(res.body.payload.data, "base64").toString();
|
|
121
121
|
}
|
|
122
122
|
async function destroySecretVersion(projectId, name, version) {
|
|
@@ -214,7 +214,7 @@ async function addVersion(projectId, name, payloadData) {
|
|
|
214
214
|
payload: {
|
|
215
215
|
data: Buffer.from(payloadData).toString("base64"),
|
|
216
216
|
},
|
|
217
|
-
});
|
|
217
|
+
}, { skipLog: { body: true } });
|
|
218
218
|
return {
|
|
219
219
|
...parseSecretVersionResourceName(res.body.name),
|
|
220
220
|
state: res.body.state,
|
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,13 +16,12 @@ 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;
|
|
23
22
|
exports.getCleanDomains = getCleanDomains;
|
|
24
23
|
exports.cleanAuthState = cleanAuthState;
|
|
25
|
-
exports.
|
|
24
|
+
exports.listCustomDomains = listCustomDomains;
|
|
26
25
|
exports.getAllSiteDomains = getAllSiteDomains;
|
|
27
26
|
exports.getDeploymentDomain = getDeploymentDomain;
|
|
28
27
|
exports.resetEnsureApiEnabledCacheForTests = resetEnsureApiEnabledCacheForTests;
|
|
@@ -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
|
}
|
|
@@ -273,28 +266,41 @@ async function cleanAuthState(project, sites) {
|
|
|
273
266
|
}
|
|
274
267
|
return siteDomainMap;
|
|
275
268
|
}
|
|
276
|
-
async function
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
throw new error_1.FirebaseError(`could not find site "${site}" for project "${project}"`, {
|
|
284
|
-
original: e,
|
|
285
|
-
});
|
|
269
|
+
async function listCustomDomains(project, site) {
|
|
270
|
+
const customDomains = [];
|
|
271
|
+
let pageToken;
|
|
272
|
+
do {
|
|
273
|
+
const queryParams = {};
|
|
274
|
+
if (pageToken) {
|
|
275
|
+
queryParams.pageToken = pageToken;
|
|
286
276
|
}
|
|
287
|
-
|
|
288
|
-
|
|
277
|
+
try {
|
|
278
|
+
const res = await apiClient.get(`/projects/${project}/sites/${site}/customDomains`, { queryParams });
|
|
279
|
+
customDomains.push(...(res.body.customDomains ?? []));
|
|
280
|
+
pageToken = res.body.nextPageToken;
|
|
281
|
+
}
|
|
282
|
+
catch (e) {
|
|
283
|
+
if (e instanceof error_1.FirebaseError && e.status === 404) {
|
|
284
|
+
throw new error_1.FirebaseError(`could not find site "${site}" for project "${project}"`, {
|
|
285
|
+
original: e,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
throw e;
|
|
289
|
+
}
|
|
290
|
+
} while (pageToken);
|
|
291
|
+
return customDomains;
|
|
289
292
|
}
|
|
290
293
|
async function getAllSiteDomains(projectId, siteId) {
|
|
291
|
-
const [
|
|
292
|
-
|
|
294
|
+
const [customDomains, defaultDomain] = await Promise.all([
|
|
295
|
+
listCustomDomains(projectId, siteId),
|
|
293
296
|
getSite(projectId, siteId),
|
|
294
297
|
]);
|
|
295
298
|
const defaultDomainWithoutHttp = defaultDomain.defaultUrl.replace(/^https?:\/\//, "");
|
|
299
|
+
const customDomainNames = customDomains
|
|
300
|
+
.map(({ name }) => name?.split("/").pop())
|
|
301
|
+
.filter((domain) => Boolean(domain));
|
|
296
302
|
const allSiteDomains = new Set([
|
|
297
|
-
...
|
|
303
|
+
...customDomainNames,
|
|
298
304
|
defaultDomainWithoutHttp,
|
|
299
305
|
`${siteId}.web.app`,
|
|
300
306
|
`${siteId}.firebaseapp.com`,
|
|
@@ -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;
|
|
@@ -26,6 +26,13 @@ const cloudbilling_1 = require("../../../gcp/cloudbilling");
|
|
|
26
26
|
exports.FDC_APP_FOLDER = "FDC_APP_FOLDER";
|
|
27
27
|
exports.FDC_SDK_FRAMEWORKS_ENV = "FDC_SDK_FRAMEWORKS";
|
|
28
28
|
exports.FDC_SDK_PLATFORM_ENV = "FDC_SDK_PLATFORM";
|
|
29
|
+
const SUPPORTED_SQL_CONNECT_PLATFORMS = [
|
|
30
|
+
appUtils_1.Platform.ANDROID,
|
|
31
|
+
appUtils_1.Platform.IOS,
|
|
32
|
+
appUtils_1.Platform.WEB,
|
|
33
|
+
appUtils_1.Platform.FLUTTER,
|
|
34
|
+
appUtils_1.Platform.ADMIN_NODE,
|
|
35
|
+
];
|
|
29
36
|
async function askQuestions(setup, config, options) {
|
|
30
37
|
const info = {
|
|
31
38
|
apps: [],
|
|
@@ -187,12 +194,12 @@ function initAppCounters(info) {
|
|
|
187
194
|
async function actuateWithInfo(setup, config, info) {
|
|
188
195
|
if (!info.apps.length) {
|
|
189
196
|
info.apps = await (0, appUtils_1.detectApps)(cwd);
|
|
190
|
-
if (!info.apps.length) {
|
|
191
|
-
(0, utils_1.logLabeledBullet)("dataconnect", "No apps to setup SQL Connect Generated SDKs");
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
197
|
}
|
|
195
198
|
const apps = dedupeAppsByPlatformAndDirectory(info.apps);
|
|
199
|
+
if (!apps.length) {
|
|
200
|
+
(0, utils_1.logLabeledBullet)("dataconnect", "No apps to setup SQL Connect Generated SDKs");
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
196
203
|
const connectorInfo = await chooseExistingConnector(setup, config);
|
|
197
204
|
const connectorYaml = JSON.parse(JSON.stringify(connectorInfo.connectorYaml));
|
|
198
205
|
for (const app of apps) {
|
|
@@ -351,12 +358,15 @@ function addSdkGenerateToConnectorYaml(connectorInfo, connectorYaml, app) {
|
|
|
351
358
|
break;
|
|
352
359
|
}
|
|
353
360
|
default:
|
|
354
|
-
throw new error_1.FirebaseError(`Unsupported platform ${app.platform} for SQL Connect SDK generation. Supported platforms are: ${
|
|
361
|
+
throw new error_1.FirebaseError(`Unsupported platform ${app.platform} for SQL Connect SDK generation. Supported platforms are: ${SUPPORTED_SQL_CONNECT_PLATFORMS.join(", ")}\n${JSON.stringify(app)}`);
|
|
355
362
|
}
|
|
356
363
|
}
|
|
357
364
|
function dedupeAppsByPlatformAndDirectory(apps) {
|
|
358
365
|
const uniqueApps = new Map();
|
|
359
366
|
for (const app of apps) {
|
|
367
|
+
if (!SUPPORTED_SQL_CONNECT_PLATFORMS.includes(app.platform)) {
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
360
370
|
const frameworkKey = app.frameworks ? [...app.frameworks].sort().join(",") : "";
|
|
361
371
|
const key = `${app.platform}:${app.directory}:${frameworkKey}`;
|
|
362
372
|
if (!uniqueApps.has(key)) {
|
|
@@ -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 {
|
package/lib/management/apps.js
CHANGED
|
@@ -75,6 +75,13 @@ async function getPlatform(appDir, config) {
|
|
|
75
75
|
throw new error_1.FirebaseError(`Flutter is not supported by apps:configure.
|
|
76
76
|
Please follow the link below to set up firebase for your Flutter app:
|
|
77
77
|
https://firebase.google.com/docs/flutter/setup
|
|
78
|
+
`);
|
|
79
|
+
}
|
|
80
|
+
else if (targetPlatform === appUtils_1.Platform.UNITY) {
|
|
81
|
+
(0, utils_1.logWarning)(`Detected ${targetPlatform} app in directory ${appDir}`);
|
|
82
|
+
throw new error_1.FirebaseError(`Unity is not supported by apps:configure.
|
|
83
|
+
Please follow the link below to set up firebase for your Unity app:
|
|
84
|
+
https://firebase.google.com/docs/unity/setup
|
|
78
85
|
`);
|
|
79
86
|
}
|
|
80
87
|
else {
|
|
@@ -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();
|