firebase-tools 15.22.4 → 15.24.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/apiv2.js +91 -32
- package/lib/apphosting/backend.js +11 -4
- package/lib/bin/cli.js +9 -2
- package/lib/bin/progressiveHelp.js +126 -0
- package/lib/checkValidTargetFilters.js +1 -1
- package/lib/command.js +0 -7
- package/lib/commands/dataconnect-execute.js +1 -1
- package/lib/commands/deploy.js +27 -64
- package/lib/commands/functions-delete.js +5 -3
- package/lib/commands/functions-lifecycle-list.js +94 -0
- package/lib/commands/functions-lifecycle-run.js +29 -0
- package/lib/commands/index.js +3 -0
- package/lib/database/import.js +3 -3
- package/lib/dataconnect/webhook.js +1 -2
- package/lib/deploy/apphosting/index.js +26 -1
- package/lib/deploy/auth/index.js +18 -1
- package/lib/deploy/database/index.js +16 -1
- package/lib/deploy/dataconnect/index.js +19 -1
- package/lib/deploy/extensions/index.js +9 -1
- package/lib/deploy/firestore/index.js +20 -1
- package/lib/deploy/functions/backend.js +9 -0
- package/lib/deploy/functions/build.js +3 -0
- package/lib/deploy/functions/index.js +33 -1
- package/lib/deploy/functions/params.js +23 -15
- package/lib/deploy/functions/prepare.js +96 -1
- package/lib/deploy/functions/prompts.js +81 -0
- package/lib/deploy/functions/release/fabricator.js +79 -4
- package/lib/deploy/functions/release/index.js +45 -23
- package/lib/deploy/functions/release/lifecycle.js +79 -53
- package/lib/deploy/functions/release/planner.js +43 -5
- package/lib/deploy/functions/runtimes/discovery/index.js +4 -3
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +18 -1
- package/lib/deploy/functions/runtimes/node/index.js +1 -2
- package/lib/deploy/functions/runtimes/python/index.js +1 -2
- package/lib/deploy/hosting/index.js +30 -1
- package/lib/deploy/hosting/uploader.js +2 -3
- package/lib/deploy/index.js +68 -8
- package/lib/deploy/remoteconfig/index.js +9 -1
- package/lib/deploy/storage/index.js +16 -1
- package/lib/downloadUtils.js +3 -1
- package/lib/emulator/auth/operations.js +18 -8
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/storage/apis/gcloud.js +61 -0
- package/lib/emulator/storage/multipart.js +82 -2
- package/lib/emulator/taskQueue.js +3 -11
- package/lib/extensions/extensionsHelper.js +6 -4
- package/lib/frameworks/utils.js +50 -1
- package/lib/gcp/iam.js +68 -2
- package/lib/gcp/knownRoles.json +99 -0
- package/lib/gcp/resourceManager.js +42 -1
- package/lib/gemini/fdcExperience.js +2 -2
- package/lib/hosting/initMiddleware.js +1 -1
- package/lib/hosting/proxy.js +57 -23
- package/lib/index.js +0 -1
- package/lib/management/apps.js +4 -2
- package/lib/profiler.js +1 -2
- package/lib/streamUtils.js +24 -0
- package/lib/track.js +1 -2
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +4 -21
- package/package.json +2 -4
package/lib/hosting/proxy.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.proxyRequestHandler = proxyRequestHandler;
|
|
4
4
|
exports.errorRequestHandler = errorRequestHandler;
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
|
-
const node_fetch_1 = require("node-fetch");
|
|
7
6
|
const stream_1 = require("stream");
|
|
8
7
|
const url_1 = require("url");
|
|
9
8
|
const apiv2_1 = require("../apiv2");
|
|
@@ -36,12 +35,20 @@ function proxyRequestHandler(url, rewriteIdentifier, options = {}) {
|
|
|
36
35
|
});
|
|
37
36
|
const u = new url_1.URL(url + req.url);
|
|
38
37
|
const c = new apiv2_1.Client({ urlPrefix: u.origin, auth: false });
|
|
38
|
+
let body;
|
|
39
39
|
let passThrough;
|
|
40
40
|
if (req.method && !["GET", "HEAD"].includes(req.method)) {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
const rawBody = req.rawBody;
|
|
42
|
+
if (rawBody !== undefined) {
|
|
43
|
+
body = rawBody;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
passThrough = new stream_1.PassThrough();
|
|
47
|
+
req.pipe(passThrough);
|
|
48
|
+
body = passThrough;
|
|
49
|
+
}
|
|
43
50
|
}
|
|
44
|
-
const headers = new
|
|
51
|
+
const headers = new Headers({
|
|
45
52
|
"X-Forwarded-Host": req.headers.host || "",
|
|
46
53
|
"X-Original-Url": req.url || "",
|
|
47
54
|
Pragma: "no-cache",
|
|
@@ -49,6 +56,10 @@ function proxyRequestHandler(url, rewriteIdentifier, options = {}) {
|
|
|
49
56
|
Cookie: sessionCookie || "",
|
|
50
57
|
});
|
|
51
58
|
const headersToSkip = new Set(["host"]);
|
|
59
|
+
if (Buffer.isBuffer(body)) {
|
|
60
|
+
headersToSkip.add("content-length");
|
|
61
|
+
headersToSkip.add("transfer-encoding");
|
|
62
|
+
}
|
|
52
63
|
for (const key of Object.keys(req.headers)) {
|
|
53
64
|
if (headersToSkip.has(key)) {
|
|
54
65
|
continue;
|
|
@@ -77,19 +88,20 @@ function proxyRequestHandler(url, rewriteIdentifier, options = {}) {
|
|
|
77
88
|
resolveOnHTTPError: true,
|
|
78
89
|
responseType: "stream",
|
|
79
90
|
redirect: "manual",
|
|
80
|
-
body
|
|
91
|
+
body,
|
|
81
92
|
timeout: 60000,
|
|
82
93
|
compress: false,
|
|
83
94
|
});
|
|
84
95
|
}
|
|
85
96
|
catch (err) {
|
|
97
|
+
logger_1.logger.error("[PROXY ERROR]", err);
|
|
86
98
|
const isAbortError = err instanceof error_1.FirebaseError && err.original?.name.includes("AbortError");
|
|
87
99
|
const isTimeoutError = err instanceof error_1.FirebaseError &&
|
|
88
|
-
err.original
|
|
89
|
-
|
|
100
|
+
(err.original?.code === "ETIMEDOUT" ||
|
|
101
|
+
err.original?.cause?.code === "ETIMEDOUT");
|
|
90
102
|
const isSocketTimeoutError = err instanceof error_1.FirebaseError &&
|
|
91
|
-
err.original
|
|
92
|
-
|
|
103
|
+
(err.original?.code === "ESOCKETTIMEDOUT" ||
|
|
104
|
+
err.original?.cause?.code === "ESOCKETTIMEDOUT");
|
|
93
105
|
if (isAbortError || isTimeoutError || isSocketTimeoutError) {
|
|
94
106
|
res.statusCode = 504;
|
|
95
107
|
return res.end("Timed out waiting for function to respond.\n");
|
|
@@ -97,38 +109,60 @@ function proxyRequestHandler(url, rewriteIdentifier, options = {}) {
|
|
|
97
109
|
res.statusCode = 500;
|
|
98
110
|
return res.end(`An internal error occurred while proxying for ${rewriteIdentifier}\n`);
|
|
99
111
|
}
|
|
112
|
+
finally {
|
|
113
|
+
if (passThrough) {
|
|
114
|
+
passThrough.resume();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const resHeaders = {};
|
|
118
|
+
for (const [key, value] of proxyRes.response.headers.entries()) {
|
|
119
|
+
resHeaders[key.toLowerCase()] = value;
|
|
120
|
+
}
|
|
100
121
|
if (proxyRes.status === 404) {
|
|
101
|
-
const cascade =
|
|
102
|
-
if (options.forceCascade ||
|
|
122
|
+
const cascade = resHeaders["x-cascade"];
|
|
123
|
+
if (options.forceCascade ||
|
|
124
|
+
(typeof cascade === "string" && cascade.toUpperCase() === "PASS")) {
|
|
103
125
|
return next();
|
|
104
126
|
}
|
|
105
127
|
}
|
|
106
|
-
if (!
|
|
107
|
-
|
|
128
|
+
if (!resHeaders["cache-control"]) {
|
|
129
|
+
resHeaders["cache-control"] = "private";
|
|
108
130
|
}
|
|
109
|
-
const cc =
|
|
110
|
-
if (cc && !cc.includes("private")) {
|
|
111
|
-
|
|
131
|
+
const cc = resHeaders["cache-control"];
|
|
132
|
+
if (typeof cc === "string" && !cc.includes("private")) {
|
|
133
|
+
delete resHeaders["set-cookie"];
|
|
112
134
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
135
|
+
const vary = resHeaders["vary"];
|
|
136
|
+
resHeaders["vary"] = makeVary(typeof vary === "string" ? vary : null);
|
|
137
|
+
const location = resHeaders["location"];
|
|
138
|
+
if (typeof location === "string" && location) {
|
|
116
139
|
try {
|
|
117
140
|
const locationURL = new url_1.URL(location);
|
|
118
141
|
if (locationURL.origin === u.origin) {
|
|
119
142
|
const unborkedLocation = location.replace(locationURL.origin, "");
|
|
120
|
-
|
|
143
|
+
resHeaders["location"] = unborkedLocation;
|
|
121
144
|
}
|
|
122
145
|
}
|
|
123
146
|
catch (e) {
|
|
124
147
|
logger_1.logger.debug(`[hosting] had trouble parsing location header, but this may be okay: "${location}"`);
|
|
125
148
|
}
|
|
126
149
|
}
|
|
127
|
-
for (const
|
|
128
|
-
|
|
150
|
+
for (const key of Object.keys(resHeaders)) {
|
|
151
|
+
const value = resHeaders[key];
|
|
152
|
+
if (key === "set-cookie") {
|
|
153
|
+
if (typeof proxyRes.response.headers.getSetCookie === "function") {
|
|
154
|
+
res.setHeader(key, proxyRes.response.headers.getSetCookie());
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
res.setHeader(key, value);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
res.setHeader(key, value);
|
|
162
|
+
}
|
|
129
163
|
}
|
|
130
164
|
res.statusCode = proxyRes.status;
|
|
131
|
-
proxyRes.
|
|
165
|
+
proxyRes.body.pipe(res);
|
|
132
166
|
};
|
|
133
167
|
}
|
|
134
168
|
function errorRequestHandler(error) {
|
package/lib/index.js
CHANGED
|
@@ -97,7 +97,6 @@ program.action((_, args) => {
|
|
|
97
97
|
client.cli.parse(process.argv);
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
-
(0, logger_1.useConsoleLoggers)();
|
|
101
100
|
logger_1.logger.error(clc.bold(clc.red("Error:")), clc.bold(cmd), "is not a Firebase command");
|
|
102
101
|
if (RENAMED_COMMANDS[cmd]) {
|
|
103
102
|
logger_1.logger.error();
|
package/lib/management/apps.js
CHANGED
|
@@ -84,9 +84,11 @@ https://firebase.google.com/docs/flutter/setup
|
|
|
84
84
|
async function initiateIosAppCreation(options) {
|
|
85
85
|
if (!options.nonInteractive) {
|
|
86
86
|
options.displayName = options.displayName || (await getDisplayName());
|
|
87
|
+
const promptAppStoreId = !options.bundleId;
|
|
87
88
|
options.bundleId = options.bundleId || (await (0, prompt_1.input)("Please specify your iOS app bundle ID:"));
|
|
88
|
-
options.appStoreId
|
|
89
|
-
options.appStoreId
|
|
89
|
+
if (promptAppStoreId && !options.appStoreId) {
|
|
90
|
+
options.appStoreId = await (0, prompt_1.input)("Please specify your iOS app App Store ID:");
|
|
91
|
+
}
|
|
90
92
|
}
|
|
91
93
|
if (!options.bundleId) {
|
|
92
94
|
throw new error_1.FirebaseError("Bundle ID for iOS app cannot be empty");
|
package/lib/profiler.js
CHANGED
|
@@ -5,7 +5,6 @@ const fs = require("fs");
|
|
|
5
5
|
const ora = require("ora");
|
|
6
6
|
const readline = require("readline");
|
|
7
7
|
const tmp = require("tmp");
|
|
8
|
-
const abort_controller_1 = require("abort-controller");
|
|
9
8
|
const apiv2_1 = require("./apiv2");
|
|
10
9
|
const api_1 = require("./database/api");
|
|
11
10
|
const logger_1 = require("./logger");
|
|
@@ -26,7 +25,7 @@ async function profiler(options) {
|
|
|
26
25
|
color: "yellow",
|
|
27
26
|
});
|
|
28
27
|
const outputFormat = options.raw ? "RAW" : options.parent.json ? "JSON" : "TXT";
|
|
29
|
-
const controller = new
|
|
28
|
+
const controller = new AbortController();
|
|
30
29
|
const generateReport = () => {
|
|
31
30
|
rl.close();
|
|
32
31
|
spinner.stop();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringToStream = stringToStream;
|
|
4
|
+
exports.streamToString = streamToString;
|
|
5
|
+
const stream_1 = require("stream");
|
|
6
|
+
function stringToStream(text) {
|
|
7
|
+
if (!text) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const s = new stream_1.Readable();
|
|
11
|
+
s.push(text);
|
|
12
|
+
s.push(null);
|
|
13
|
+
return s;
|
|
14
|
+
}
|
|
15
|
+
function streamToString(s) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
let b = "";
|
|
18
|
+
s.on("error", reject);
|
|
19
|
+
s.on("data", (d) => {
|
|
20
|
+
b += d.toString();
|
|
21
|
+
});
|
|
22
|
+
s.once("end", () => resolve(b));
|
|
23
|
+
});
|
|
24
|
+
}
|
package/lib/track.js
CHANGED
|
@@ -8,7 +8,6 @@ exports.trackVSCode = trackVSCode;
|
|
|
8
8
|
exports.emulatorSession = emulatorSession;
|
|
9
9
|
exports.vscodeSession = vscodeSession;
|
|
10
10
|
exports.cliSession = cliSession;
|
|
11
|
-
const node_fetch_1 = require("node-fetch");
|
|
12
11
|
const crypto_1 = require("crypto");
|
|
13
12
|
const auth_1 = require("./auth");
|
|
14
13
|
const configstore_1 = require("./configstore");
|
|
@@ -134,7 +133,7 @@ async function _ga4Track(args) {
|
|
|
134
133
|
logger_1.logger.info(`Sending Analytics for event ${eventName} to property ${session.measurementId}`, params, body);
|
|
135
134
|
}
|
|
136
135
|
try {
|
|
137
|
-
const response = await (
|
|
136
|
+
const response = await fetch(url, {
|
|
138
137
|
method: "POST",
|
|
139
138
|
headers: {
|
|
140
139
|
"content-type": "application/json;charset=UTF-8",
|