firebase-tools 15.36.0 → 15.36.1-main.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/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/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/release/fabricator.js +9 -2
- package/lib/deploy/functions/release/planner.js +3 -0
- package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- 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/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 +4 -4
|
@@ -44,46 +44,46 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"pubsub": {
|
|
47
|
-
"version": "0.8.
|
|
48
|
-
"expectedSize":
|
|
49
|
-
"expectedChecksum": "
|
|
50
|
-
"expectedChecksumSHA256": "
|
|
51
|
-
"remoteUrl": "https://storage.googleapis.com/firebase-preview-drop/emulator/pubsub-emulator-0.8.
|
|
52
|
-
"downloadPathRelativeToCacheDir": "pubsub-emulator-0.8.
|
|
53
|
-
"binaryPathRelativeToCacheDir": "pubsub-emulator-0.8.
|
|
47
|
+
"version": "0.8.38",
|
|
48
|
+
"expectedSize": 53069962,
|
|
49
|
+
"expectedChecksum": "8d7d921ade2b88b5bf1c5b2e17394c9b",
|
|
50
|
+
"expectedChecksumSHA256": "1f7e272f9d86431026c4219468a91eea90f0d32fc178da6a96cd1a843517e619",
|
|
51
|
+
"remoteUrl": "https://storage.googleapis.com/firebase-preview-drop/emulator/pubsub-emulator-0.8.38.zip",
|
|
52
|
+
"downloadPathRelativeToCacheDir": "pubsub-emulator-0.8.38.zip",
|
|
53
|
+
"binaryPathRelativeToCacheDir": "pubsub-emulator-0.8.38/pubsub-emulator/bin/cloud-pubsub-emulator"
|
|
54
54
|
},
|
|
55
55
|
"dataconnect": {
|
|
56
56
|
"darwin": {
|
|
57
|
-
"version": "3.4.
|
|
58
|
-
"expectedSize":
|
|
59
|
-
"expectedChecksum": "
|
|
60
|
-
"expectedChecksumSHA256": "
|
|
61
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.
|
|
62
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
57
|
+
"version": "3.4.27",
|
|
58
|
+
"expectedSize": 36296192,
|
|
59
|
+
"expectedChecksum": "25ecf7725974af8dff15b4701150db70",
|
|
60
|
+
"expectedChecksumSHA256": "22dfec97508045679ae1e3b5a1c61229ec6342dd456690c2ce0bf65000c2d2f4",
|
|
61
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.27",
|
|
62
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.27"
|
|
63
63
|
},
|
|
64
64
|
"darwin_arm64": {
|
|
65
|
-
"version": "3.4.
|
|
66
|
-
"expectedSize":
|
|
67
|
-
"expectedChecksum": "
|
|
68
|
-
"expectedChecksumSHA256": "
|
|
69
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.
|
|
70
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
65
|
+
"version": "3.4.27",
|
|
66
|
+
"expectedSize": 34214258,
|
|
67
|
+
"expectedChecksum": "3e8b46da0391f9c925eb613a4a9b597d",
|
|
68
|
+
"expectedChecksumSHA256": "429659c1cf66e98bd90c632862220c745775312bc608201d6146ace52324ee4c",
|
|
69
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.27",
|
|
70
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.27"
|
|
71
71
|
},
|
|
72
72
|
"win32": {
|
|
73
|
-
"version": "3.4.
|
|
74
|
-
"expectedSize":
|
|
75
|
-
"expectedChecksum": "
|
|
76
|
-
"expectedChecksumSHA256": "
|
|
77
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.
|
|
78
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
73
|
+
"version": "3.4.27",
|
|
74
|
+
"expectedSize": 36278272,
|
|
75
|
+
"expectedChecksum": "e0acfcb449846b0797bc67952c8ba101",
|
|
76
|
+
"expectedChecksumSHA256": "6eebcd2cb90aeb51da3b8e0a4c2d59f5969d7d81679c950316e2ca70600c70fb",
|
|
77
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.27",
|
|
78
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.27.exe"
|
|
79
79
|
},
|
|
80
80
|
"linux": {
|
|
81
|
-
"version": "3.4.
|
|
82
|
-
"expectedSize":
|
|
83
|
-
"expectedChecksum": "
|
|
84
|
-
"expectedChecksumSHA256": "
|
|
85
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.
|
|
86
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.
|
|
81
|
+
"version": "3.4.27",
|
|
82
|
+
"expectedSize": 35295394,
|
|
83
|
+
"expectedChecksum": "1540899d3418561b62520aba224943d6",
|
|
84
|
+
"expectedChecksumSHA256": "709e9b7954bd88e070d5e8b667876cabd85f94d2e47ec191c6eadf5500e9fe1b",
|
|
85
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.27",
|
|
86
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.27"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -293,8 +293,8 @@ async function initializeFirebaseAdminStubs() {
|
|
|
293
293
|
new types_1.EmulatorLog("WARN_ONCE", "runtime-status", "The Firebase Authentication emulator is running, but your 'firebase-admin' dependency is below version 9.3.0, so calls to Firebase Authentication will affect production.").log();
|
|
294
294
|
}
|
|
295
295
|
else if ((0, functionsEmulatorUtils_1.compareVersionStrings)(adminResolution.version, "9.4.2") <= 0) {
|
|
296
|
-
const auth = defaultApp.auth();
|
|
297
|
-
if (typeof auth
|
|
296
|
+
const auth = typeof defaultApp.auth === "function" ? defaultApp.auth() : undefined;
|
|
297
|
+
if (typeof auth?.setJwtVerificationEnabled === "function") {
|
|
298
298
|
logDebug("auth.setJwtVerificationEnabled(false)", {});
|
|
299
299
|
auth.setJwtVerificationEnabled(false);
|
|
300
300
|
}
|
package/lib/experiments.js
CHANGED
|
@@ -228,6 +228,11 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
228
228
|
default: false,
|
|
229
229
|
public: false,
|
|
230
230
|
},
|
|
231
|
+
crashlyticscli: {
|
|
232
|
+
shortDescription: "Enable read-only Crashlytics commands for issues, events, and reports.",
|
|
233
|
+
default: false,
|
|
234
|
+
public: false,
|
|
235
|
+
},
|
|
231
236
|
});
|
|
232
237
|
function isValidExperiment(name) {
|
|
233
238
|
return Object.keys(exports.ALL_EXPERIMENTS).includes(name);
|
|
@@ -48,7 +48,7 @@ async function listExtensions(projectId) {
|
|
|
48
48
|
publisher = extension.split("/")[0];
|
|
49
49
|
}
|
|
50
50
|
const instanceId = (0, utils_1.last)(instance.name.split("/")) ?? "";
|
|
51
|
-
const state = instance.state +
|
|
51
|
+
const state = String(instance.state) +
|
|
52
52
|
((instance.config.source.state || "ACTIVE") === "DELETED" ? " (UNPUBLISHED)" : "");
|
|
53
53
|
const version = instance?.config?.source?.spec?.version;
|
|
54
54
|
const updateTime = extensionsUtils.formatTimestamp(instance.updateTime);
|
package/lib/firestore/delete.js
CHANGED
|
@@ -16,7 +16,6 @@ class FirestoreDelete {
|
|
|
16
16
|
this.path = path || "";
|
|
17
17
|
this.recursive = Boolean(options.recursive);
|
|
18
18
|
this.shallow = Boolean(options.shallow);
|
|
19
|
-
this.allCollections = Boolean(options.allCollections);
|
|
20
19
|
this.databaseId = options.databaseId;
|
|
21
20
|
this.urlPrefix = options.urlPrefix ?? (0, api_1.firestoreOriginOrEmulator)();
|
|
22
21
|
this.readBatchSize = 7500;
|
|
@@ -176,7 +175,7 @@ class FirestoreDelete {
|
|
|
176
175
|
return true;
|
|
177
176
|
}
|
|
178
177
|
if (failures.length > 0) {
|
|
179
|
-
logger_1.logger.debug(
|
|
178
|
+
logger_1.logger.debug(`Found ${failures.length} failed operations, failing.`);
|
|
180
179
|
return true;
|
|
181
180
|
}
|
|
182
181
|
if (queue.length <= this.maxQueueSize && pagesRemaining && !pageIncoming) {
|
|
@@ -193,7 +192,7 @@ class FirestoreDelete {
|
|
|
193
192
|
lastDocName = docs[docs.length - 1].name;
|
|
194
193
|
})
|
|
195
194
|
.catch((e) => {
|
|
196
|
-
logger_1.logger.debug(
|
|
195
|
+
logger_1.logger.debug(`Failed to fetch page after ${String(lastDocName)}`, e);
|
|
197
196
|
pageIncoming = false;
|
|
198
197
|
fetchFailures++;
|
|
199
198
|
if (fetchFailures >= 3) {
|
|
@@ -23,42 +23,45 @@ const WEBPACK_LAYERS_NAMES = {
|
|
|
23
23
|
reactServerComponents: "rsc",
|
|
24
24
|
serverSideRendering: "ssr",
|
|
25
25
|
actionBrowser: "action-browser",
|
|
26
|
-
|
|
27
|
-
apiEdge: "api-edge",
|
|
26
|
+
api: "api",
|
|
28
27
|
middleware: "middleware",
|
|
29
|
-
instrument: "instrument",
|
|
30
28
|
edgeAsset: "edge-asset",
|
|
31
29
|
appPagesBrowser: "app-pages-browser",
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
pagesDirNode: "pages-dir-node",
|
|
30
|
+
appMetadataRoute: "app-metadata-route",
|
|
31
|
+
appRouteHandler: "app-route-handler",
|
|
35
32
|
};
|
|
36
33
|
exports.WEBPACK_LAYERS = {
|
|
37
34
|
...WEBPACK_LAYERS_NAMES,
|
|
35
|
+
pagesDirBrowser: "pages-dir-browser",
|
|
36
|
+
pagesDirEdge: "pages-dir-edge",
|
|
37
|
+
pagesDirNode: "pages-dir-node",
|
|
38
|
+
apiNode: "api-node",
|
|
39
|
+
apiEdge: "api-edge",
|
|
40
|
+
instrument: "instrument",
|
|
38
41
|
GROUP: {
|
|
39
42
|
builtinReact: [WEBPACK_LAYERS_NAMES.reactServerComponents, WEBPACK_LAYERS_NAMES.actionBrowser],
|
|
40
43
|
serverOnly: [
|
|
44
|
+
WEBPACK_LAYERS_NAMES.middleware,
|
|
41
45
|
WEBPACK_LAYERS_NAMES.reactServerComponents,
|
|
42
46
|
WEBPACK_LAYERS_NAMES.actionBrowser,
|
|
43
|
-
|
|
44
|
-
WEBPACK_LAYERS_NAMES.middleware,
|
|
47
|
+
"instrument",
|
|
45
48
|
],
|
|
46
|
-
neutralTarget: [
|
|
49
|
+
neutralTarget: ["api-node", "api-edge"],
|
|
47
50
|
clientOnly: [WEBPACK_LAYERS_NAMES.serverSideRendering, WEBPACK_LAYERS_NAMES.appPagesBrowser],
|
|
48
51
|
bundled: [
|
|
52
|
+
WEBPACK_LAYERS_NAMES.shared,
|
|
53
|
+
WEBPACK_LAYERS_NAMES.middleware,
|
|
49
54
|
WEBPACK_LAYERS_NAMES.reactServerComponents,
|
|
50
|
-
WEBPACK_LAYERS_NAMES.actionBrowser,
|
|
51
55
|
WEBPACK_LAYERS_NAMES.serverSideRendering,
|
|
56
|
+
WEBPACK_LAYERS_NAMES.actionBrowser,
|
|
57
|
+
"instrument",
|
|
52
58
|
WEBPACK_LAYERS_NAMES.appPagesBrowser,
|
|
53
|
-
WEBPACK_LAYERS_NAMES.shared,
|
|
54
|
-
WEBPACK_LAYERS_NAMES.instrument,
|
|
55
|
-
WEBPACK_LAYERS_NAMES.middleware,
|
|
56
59
|
],
|
|
57
60
|
appPages: [
|
|
58
61
|
WEBPACK_LAYERS_NAMES.reactServerComponents,
|
|
59
62
|
WEBPACK_LAYERS_NAMES.serverSideRendering,
|
|
60
|
-
WEBPACK_LAYERS_NAMES.appPagesBrowser,
|
|
61
63
|
WEBPACK_LAYERS_NAMES.actionBrowser,
|
|
64
|
+
WEBPACK_LAYERS_NAMES.appPagesBrowser,
|
|
62
65
|
],
|
|
63
66
|
},
|
|
64
67
|
};
|
|
@@ -16,6 +16,7 @@ const url_1 = require("url");
|
|
|
16
16
|
const semver_1 = require("semver");
|
|
17
17
|
const clc = require("colorette");
|
|
18
18
|
const fsutils_1 = require("../../fsutils");
|
|
19
|
+
const streamJson_1 = require("../../streamJson");
|
|
19
20
|
const prompt_1 = require("../../prompt");
|
|
20
21
|
const error_1 = require("../../error");
|
|
21
22
|
const utils_1 = require("../utils");
|
|
@@ -290,11 +291,11 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
|
|
|
290
291
|
{
|
|
291
292
|
srcRoute: null,
|
|
292
293
|
initialRevalidateSeconds: false,
|
|
293
|
-
initialExpireSeconds: undefined,
|
|
294
294
|
dataRoute: "",
|
|
295
295
|
experimentalPPR: false,
|
|
296
|
-
renderingMode: undefined,
|
|
297
296
|
prefetchDataRoute: "",
|
|
297
|
+
initialExpireSeconds: undefined,
|
|
298
|
+
renderingMode: undefined,
|
|
298
299
|
allowHeader: [],
|
|
299
300
|
},
|
|
300
301
|
];
|
|
@@ -394,7 +395,28 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
|
|
|
394
395
|
if (!esbuild) {
|
|
395
396
|
throw new error_1.FirebaseError(`Failed to load esbuild from path: ${esbuildPath}`);
|
|
396
397
|
}
|
|
397
|
-
const
|
|
398
|
+
const { chain, parser, pick, streamObject } = await (0, streamJson_1.loadStreamJson)();
|
|
399
|
+
const productionDeps = await new Promise((resolve) => {
|
|
400
|
+
const dependencies = [];
|
|
401
|
+
const npmLs = (0, cross_spawn_1.spawn)("npm", ["ls", "--omit=dev", "--all", "--json=true"], {
|
|
402
|
+
cwd: sourceDir,
|
|
403
|
+
timeout: constants_1.NPM_COMMAND_TIMEOUT_MILLIES,
|
|
404
|
+
});
|
|
405
|
+
const pipeline = chain([
|
|
406
|
+
npmLs.stdout,
|
|
407
|
+
parser({ packValues: false, packKeys: true, streamValues: false }),
|
|
408
|
+
pick({ filter: "dependencies" }),
|
|
409
|
+
streamObject(),
|
|
410
|
+
({ key, value }) => [
|
|
411
|
+
key,
|
|
412
|
+
...(0, utils_2.allDependencyNames)(value),
|
|
413
|
+
],
|
|
414
|
+
]);
|
|
415
|
+
pipeline.on("data", (it) => dependencies.push(it));
|
|
416
|
+
pipeline.on("end", () => {
|
|
417
|
+
resolve([...new Set(dependencies)]);
|
|
418
|
+
});
|
|
419
|
+
});
|
|
398
420
|
const esbuildArgs = {
|
|
399
421
|
entryPoints: [(0, path_1.join)(sourceDir, configFile)],
|
|
400
422
|
outfile: (0, path_1.join)(destDir, configFile),
|
|
@@ -193,26 +193,24 @@ async function getProductionDependencyNames(sourceDir) {
|
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
195
|
function getMiddlewareMatcherRegexes(middlewareManifest, functionsConfigManifest) {
|
|
196
|
-
const middlewareObjectValues = Object.values(middlewareManifest.middleware);
|
|
197
196
|
const middlewareMatchers = [];
|
|
198
197
|
if (middlewareManifest.version === 1) {
|
|
199
|
-
|
|
198
|
+
const values = Object.values(middlewareManifest.middleware);
|
|
199
|
+
middlewareMatchers.push(...values.map((page) => ({
|
|
200
200
|
regexp: page.regexp,
|
|
201
201
|
})));
|
|
202
202
|
}
|
|
203
203
|
else if (middlewareManifest.version === 2) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
.flat());
|
|
204
|
+
const values = Object.values(middlewareManifest.middleware);
|
|
205
|
+
middlewareMatchers.push(...values.map((page) => page.matchers || []).flat());
|
|
207
206
|
}
|
|
208
207
|
else if (middlewareManifest.version === 3) {
|
|
209
208
|
if (functionsConfigManifest?.functions?.["/_middleware"]) {
|
|
210
209
|
middlewareMatchers.push(...(functionsConfigManifest.functions["/_middleware"].matchers || []));
|
|
211
210
|
}
|
|
212
211
|
else {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
.flat());
|
|
212
|
+
const values = Object.values(middlewareManifest.middleware);
|
|
213
|
+
middlewareMatchers.push(...values.map((page) => page.matchers || []).flat());
|
|
216
214
|
}
|
|
217
215
|
}
|
|
218
216
|
return middlewareMatchers.map((matcher) => new RegExp(matcher.regexp));
|
package/lib/gcp/cloudbilling.js
CHANGED
|
@@ -86,10 +86,10 @@ function logBillingStatus(enabled, projectId, featureName) {
|
|
|
86
86
|
async function openBillingAccount(projectId, url, open, featureName = "Extensions") {
|
|
87
87
|
if (open) {
|
|
88
88
|
try {
|
|
89
|
-
opn(url);
|
|
89
|
+
await opn(url);
|
|
90
90
|
}
|
|
91
91
|
catch (err) {
|
|
92
|
-
logger_1.logger.debug(
|
|
92
|
+
logger_1.logger.debug(`Unable to open billing URL: ${(0, error_1.getErrStack)(err)}`);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
const target = featureName === "Extensions" ? "your extension" : featureName.toLowerCase();
|
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
|
-
}
|
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")}?`);
|