firebase-tools-with-isolate 15.35.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/appcheck/debugTokens.js +293 -0
- package/lib/appcheck/localConfig.js +191 -0
- package/lib/appdistribution/options-parser-util.js +1 -1
- package/lib/apphosting/githubConnections.js +1 -1
- package/lib/apptesting/parseTestFiles.js +1 -1
- package/lib/auth.js +9 -3
- package/lib/bin/progressiveHelp.js +1 -1
- package/lib/command.js +1 -2
- package/lib/commands/appcheck-debugtokens-create.js +60 -35
- package/lib/commands/appcheck-debugtokens-delete.js +21 -7
- package/lib/commands/appcheck-debugtokens-list.js +37 -8
- package/lib/commands/appcheck-debugtokens-prune.js +59 -0
- 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/deploy.js +1 -3
- package/lib/commands/ext-dev-init.js +1 -1
- package/lib/commands/hosting-channel-create.js +1 -3
- package/lib/commands/hosting-channel-delete.js +1 -3
- package/lib/commands/hosting-channel-deploy.js +1 -3
- package/lib/commands/hosting-channel-list.js +1 -3
- package/lib/commands/hosting-channel-open.js +5 -4
- package/lib/commands/hosting-clone.js +3 -5
- package/lib/commands/hosting-disable.js +2 -2
- package/lib/commands/hosting-sites-create.js +1 -3
- package/lib/commands/hosting-sites-delete.js +1 -3
- package/lib/commands/hosting-sites-get.js +1 -3
- package/lib/commands/hosting-sites-list.js +1 -3
- package/lib/commands/index.js +11 -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 +122 -1
- package/lib/crashlytics/filters.js +12 -6
- package/lib/crashlytics/profilingManager.js +77 -50
- package/lib/crashlytics/reports.js +5 -1
- package/lib/crashlytics/utils.js +14 -0
- package/lib/database/import.js +5 -4
- package/lib/dataconnect/client.js +14 -8
- package/lib/dataconnect/names.js +3 -3
- package/lib/dataconnect/schemaMigration.js +1 -1
- package/lib/deploy/dataconnect/release.js +2 -2
- package/lib/deploy/firestore/prepare.js +21 -3
- package/lib/deploy/functions/backend.js +0 -10
- package/lib/deploy/functions/cel.js +2 -2
- 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/release/reporter.js +0 -26
- package/lib/deploy/functions/runtimes/discovery/index.js +4 -1
- package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.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/deploy/functions/services/index.js +13 -11
- package/lib/deploy/hosting/prepare.js +1 -3
- package/lib/deploy/lifecycleHooks.js +1 -1
- package/lib/emulator/auth/operations.js +2 -2
- package/lib/emulator/auth/server.js +4 -2
- package/lib/emulator/auth/widget_ui.js +1 -1
- package/lib/emulator/commandUtils.js +4 -1
- package/lib/emulator/databaseEmulator.js +16 -11
- package/lib/emulator/dataconnect/pgliteServer.js +30 -24
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/downloadableEmulators.js +2 -2
- package/lib/emulator/extensions/postinstall.js +6 -6
- package/lib/emulator/firestoreEmulator.js +21 -15
- package/lib/emulator/functionsEmulator.js +84 -8
- package/lib/emulator/functionsEmulatorRuntime.js +9 -4
- package/lib/emulator/hub.js +12 -8
- package/lib/emulator/shared/express.js +30 -0
- package/lib/emulator/storage/apis/firebase.js +11 -10
- package/lib/emulator/storage/apis/gcloud.js +21 -20
- package/lib/emulator/storage/files.js +1 -1
- package/lib/emulator/storage/rules/manager.js +15 -12
- package/lib/emulator/storage/server.js +10 -5
- package/lib/experiments.js +5 -0
- package/lib/extensions/extensionsHelper.js +2 -2
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/paramHelper.js +1 -1
- package/lib/extensions/provisioningHelper.js +1 -6
- package/lib/firestore/delete.js +2 -3
- package/lib/firestore/util.js +3 -3
- package/lib/frameworks/angular/utils.js +1 -1
- package/lib/frameworks/next/constants.js +17 -14
- package/lib/frameworks/next/index.js +25 -3
- package/lib/frameworks/next/utils.js +7 -9
- package/lib/functions/kits/install.js +221 -316
- package/lib/functions/kits/sources/directory.js +32 -0
- package/lib/functions/kits/sources/npm.js +55 -5
- package/lib/functionsConfig.js +0 -4
- package/lib/functionsShellCommandAction.js +1 -1
- package/lib/gcp/cloudbilling.js +2 -2
- package/lib/gcp/cloudbuild.js +0 -77
- package/lib/gcp/cloudfunctionsv2.js +0 -6
- package/lib/gcp/cloudscheduler.js +12 -0
- package/lib/gcp/cloudtasks.js +0 -4
- package/lib/gcp/devConnect.js +2 -8
- 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 +79 -7
- package/lib/hosting/implicitInit.js +1 -1
- package/lib/hosting/proxy.js +5 -2
- 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/hosting/github.js +6 -4
- package/lib/init/features/hosting/index.js +4 -0
- 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 +5 -2
- package/lib/mcp/apps/update_environment/mcp-app.js +1 -1
- package/lib/mcp/index.js +14 -4
- package/lib/mcp/prompts/apptesting/run_test.js +3 -3
- package/lib/mcp/prompts/core/deploy.js +3 -3
- package/lib/mcp/resources/guides/init_ai.js +10 -10
- package/lib/mcp/tools/crashlytics/events.js +18 -93
- package/lib/mcp/tools/crashlytics/index.js +2 -0
- package/lib/mcp/tools/crashlytics/reports.js +3 -3
- package/lib/mcp/tools/crashlytics/setup.js +392 -0
- 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.publish.tsbuildinfo +1 -1
- package/lib/utils.js +5 -11
- package/package.json +16 -14
- package/schema/firebase-config.json +3 -0
- package/lib/functions/kits/sources/index.js +0 -19
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FunctionsEmulator = exports.TCPConn = exports.IPCConn = void 0;
|
|
4
4
|
exports.createIgnoredFilter = createIgnoredFilter;
|
|
5
|
+
exports.getAllowedEmulatorUIOrigins = getAllowedEmulatorUIOrigins;
|
|
5
6
|
const fs = require("fs");
|
|
6
7
|
const path = require("path");
|
|
7
8
|
const express = require("express");
|
|
@@ -14,6 +15,7 @@ const events_1 = require("events");
|
|
|
14
15
|
const logger_1 = require("../logger");
|
|
15
16
|
const track_1 = require("../track");
|
|
16
17
|
const constants_1 = require("./constants");
|
|
18
|
+
const dns_1 = require("./dns");
|
|
17
19
|
const types_1 = require("./types");
|
|
18
20
|
const chokidar = require("chokidar");
|
|
19
21
|
const minimatch = require("minimatch");
|
|
@@ -68,10 +70,10 @@ class TCPConn {
|
|
|
68
70
|
exports.TCPConn = TCPConn;
|
|
69
71
|
function createIgnoredFilter(ignore) {
|
|
70
72
|
const ignored = [
|
|
71
|
-
/(^|[
|
|
73
|
+
/(^|[/\\])\../,
|
|
72
74
|
/.+\.log/,
|
|
73
|
-
/.+?[
|
|
74
|
-
/.+?[
|
|
75
|
+
/.+?[\\/]node_modules[\\/].+?/,
|
|
76
|
+
/.+?[\\/]venv[\\/].+?/,
|
|
75
77
|
];
|
|
76
78
|
if (ignore) {
|
|
77
79
|
const minimatchInstances = ignore.map((pattern) => {
|
|
@@ -85,6 +87,60 @@ function createIgnoredFilter(ignore) {
|
|
|
85
87
|
}
|
|
86
88
|
return ignored;
|
|
87
89
|
}
|
|
90
|
+
const LOOPBACK_AND_WILDCARD_HOSTS = [
|
|
91
|
+
"localhost",
|
|
92
|
+
dns_1.IPV4_LOOPBACK.address,
|
|
93
|
+
dns_1.IPV6_LOOPBACK.address,
|
|
94
|
+
dns_1.IPV4_UNSPECIFIED.address,
|
|
95
|
+
dns_1.IPV6_UNSPECIFIED.address,
|
|
96
|
+
];
|
|
97
|
+
function addOrigin(origins, options) {
|
|
98
|
+
const { protocol, host, port } = options;
|
|
99
|
+
const formattedHost = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
|
|
100
|
+
const portSuffix = port !== undefined ? `:${port}` : "";
|
|
101
|
+
try {
|
|
102
|
+
origins.add(new url_1.URL(`${protocol}://${formattedHost}${portSuffix}`).origin);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function getAllowedEmulatorUIOrigins() {
|
|
108
|
+
const uiInfo = registry_1.EmulatorRegistry.getInfo(types_1.Emulators.UI);
|
|
109
|
+
if (!uiInfo) {
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
const origins = new Set();
|
|
113
|
+
const specs = uiInfo.listen?.length
|
|
114
|
+
? uiInfo.listen
|
|
115
|
+
: [
|
|
116
|
+
{
|
|
117
|
+
address: uiInfo.host,
|
|
118
|
+
port: uiInfo.port,
|
|
119
|
+
family: uiInfo.host.includes(":") ? "IPv6" : "IPv4",
|
|
120
|
+
},
|
|
121
|
+
];
|
|
122
|
+
for (const spec of specs) {
|
|
123
|
+
const { address, port } = spec;
|
|
124
|
+
if (LOOPBACK_AND_WILDCARD_HOSTS.includes(address)) {
|
|
125
|
+
addOrigin(origins, { protocol: "http", host: "localhost", port });
|
|
126
|
+
addOrigin(origins, { protocol: "http", host: dns_1.IPV4_LOOPBACK.address, port });
|
|
127
|
+
addOrigin(origins, { protocol: "http", host: dns_1.IPV6_LOOPBACK.address, port });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
addOrigin(origins, { protocol: "http", host: address, port });
|
|
131
|
+
}
|
|
132
|
+
if (process.env.WEB_HOST) {
|
|
133
|
+
addOrigin(origins, { protocol: "https", host: `${port}-${process.env.WEB_HOST}` });
|
|
134
|
+
}
|
|
135
|
+
if (process.env.CODESPACE_NAME && process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN) {
|
|
136
|
+
addOrigin(origins, {
|
|
137
|
+
protocol: "https",
|
|
138
|
+
host: `${process.env.CODESPACE_NAME}-${port}.${process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}`,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return Array.from(origins);
|
|
143
|
+
}
|
|
88
144
|
class FunctionsEmulator {
|
|
89
145
|
static getHttpFunctionUrl(projectId, name, region, info) {
|
|
90
146
|
let url;
|
|
@@ -223,10 +279,26 @@ class FunctionsEmulator {
|
|
|
223
279
|
}
|
|
224
280
|
res.json({ status: "multicast_acknowledged" });
|
|
225
281
|
};
|
|
282
|
+
const rejectDisallowedBackendsOrigin = (req, res, next) => {
|
|
283
|
+
const origin = req.headers.origin;
|
|
284
|
+
if (origin && !getAllowedEmulatorUIOrigins().includes(origin)) {
|
|
285
|
+
res.status(403).json({
|
|
286
|
+
message: `/backends cannot be accessed by external callers.`,
|
|
287
|
+
});
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
next();
|
|
291
|
+
};
|
|
292
|
+
const listBackendsCors = cors({
|
|
293
|
+
origin: (origin, callback) => {
|
|
294
|
+
callback(null, Boolean(origin));
|
|
295
|
+
},
|
|
296
|
+
});
|
|
226
297
|
const listBackendsHandler = (req, res) => {
|
|
227
298
|
res.json({ backends: this.getBackendInfo() });
|
|
228
299
|
};
|
|
229
|
-
hub.
|
|
300
|
+
hub.options(listBackendsRoute, rejectDisallowedBackendsOrigin, listBackendsCors);
|
|
301
|
+
hub.get(listBackendsRoute, rejectDisallowedBackendsOrigin, listBackendsCors, listBackendsHandler);
|
|
230
302
|
hub.post(backgroundFunctionRoute, dataMiddleware, httpsHandler);
|
|
231
303
|
hub.post(multicastFunctionRoute, dataMiddleware, multicastHandler);
|
|
232
304
|
hub.all(httpsFunctionRoutes, dataMiddleware, httpsHandler);
|
|
@@ -309,7 +381,9 @@ class FunctionsEmulator {
|
|
|
309
381
|
};
|
|
310
382
|
const delegate = await runtimes.getRuntimeDelegate(runtimeDelegateContext);
|
|
311
383
|
this.logger.logLabeled("BULLET", "functions", `Starting build_runner watch for Dart functions...`);
|
|
312
|
-
const debouncedLoadTriggers = (0, utils_1.debounce)(() =>
|
|
384
|
+
const debouncedLoadTriggers = (0, utils_1.debounce)(() => {
|
|
385
|
+
this.loadTriggers(backend).catch((err) => this.logger.logLabeled("WARN", "functions", `Failed to reload triggers: ${(0, error_1.getErrMsg)(err)}`));
|
|
386
|
+
}, 1000);
|
|
313
387
|
const cleanup = await delegate.watch(() => {
|
|
314
388
|
this.logger.log("DEBUG", "build_runner rebuilt, reloading triggers");
|
|
315
389
|
debouncedLoadTriggers();
|
|
@@ -323,10 +397,12 @@ class FunctionsEmulator {
|
|
|
323
397
|
persistent: true,
|
|
324
398
|
});
|
|
325
399
|
this.watchers.push(watcher);
|
|
326
|
-
const debouncedLoadTriggers = (0, utils_1.debounce)(() =>
|
|
400
|
+
const debouncedLoadTriggers = (0, utils_1.debounce)(() => {
|
|
401
|
+
this.loadTriggers(backend).catch((err) => this.logger.logLabeled("WARN", "functions", `Failed to reload triggers: ${(0, error_1.getErrMsg)(err)}`));
|
|
402
|
+
}, 1000);
|
|
327
403
|
watcher.on("change", (filePath) => {
|
|
328
404
|
this.logger.log("DEBUG", `File ${filePath} changed, reloading triggers`);
|
|
329
|
-
|
|
405
|
+
debouncedLoadTriggers();
|
|
330
406
|
});
|
|
331
407
|
}
|
|
332
408
|
}
|
|
@@ -1290,7 +1366,7 @@ class FunctionsEmulator {
|
|
|
1290
1366
|
});
|
|
1291
1367
|
this.logger.log("DEBUG", `[functions] Runtime ready! Sending request!`);
|
|
1292
1368
|
const url = new url_1.URL(`${req.protocol}://${req.hostname}${req.url}`);
|
|
1293
|
-
let path = `${url.pathname}${url.search}`.replace(new RegExp(
|
|
1369
|
+
let path = `${url.pathname}${url.search}`.replace(new RegExp(`/${this.args.projectId}/[^/]*/${req.params.trigger_name}/?`), "/");
|
|
1294
1370
|
if ((0, supported_1.runtimeIsLanguage)(record.backend.runtime, "dart")) {
|
|
1295
1371
|
const isBackgroundRoute = req.url.startsWith("/functions/projects/");
|
|
1296
1372
|
if (isBackgroundRoute || path === "/") {
|
|
@@ -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
|
}
|
|
@@ -565,7 +565,7 @@ async function main() {
|
|
|
565
565
|
app.all("/favicon.ico|/robots.txt", (req, res) => {
|
|
566
566
|
res.status(404).send();
|
|
567
567
|
});
|
|
568
|
-
|
|
568
|
+
async function handleRequest(req, res) {
|
|
569
569
|
try {
|
|
570
570
|
const trigger = FUNCTION_TARGET_NAME.split(".").reduce((mod, functionTargetPart) => {
|
|
571
571
|
return mod?.[functionTargetPart];
|
|
@@ -595,8 +595,13 @@ async function main() {
|
|
|
595
595
|
}
|
|
596
596
|
catch (err) {
|
|
597
597
|
new types_1.EmulatorLog("FATAL", "runtime-error", (0, error_1.getErrStack)(err)).log();
|
|
598
|
-
res.
|
|
598
|
+
if (!res.headersSent) {
|
|
599
|
+
res.status(500).send((0, error_1.getErrMsg)(err));
|
|
600
|
+
}
|
|
599
601
|
}
|
|
602
|
+
}
|
|
603
|
+
app.all(`/*`, (req, res) => {
|
|
604
|
+
void handleRequest(req, res);
|
|
600
605
|
});
|
|
601
606
|
app.listen(process.env.PORT, () => {
|
|
602
607
|
logDebug(`Listening to port: ${process.env.PORT}`);
|
package/lib/emulator/hub.js
CHANGED
|
@@ -10,6 +10,7 @@ const types_1 = require("./types");
|
|
|
10
10
|
const hubExport_1 = require("./hubExport");
|
|
11
11
|
const registry_1 = require("./registry");
|
|
12
12
|
const ExpressBasedEmulator_1 = require("./ExpressBasedEmulator");
|
|
13
|
+
const express_1 = require("./shared/express");
|
|
13
14
|
const pkg = require("../../package.json");
|
|
14
15
|
class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
15
16
|
static readLocatorFile(projectId) {
|
|
@@ -63,11 +64,12 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
63
64
|
app.get(EmulatorHub.PATH_EMULATORS, (req, res) => {
|
|
64
65
|
res.json(this.getRunningEmulatorsMapping());
|
|
65
66
|
});
|
|
66
|
-
app.post(EmulatorHub.PATH_EXPORT, async (req, res) => {
|
|
67
|
+
app.post(EmulatorHub.PATH_EXPORT, (0, express_1.asyncHandler)(async (req, res) => {
|
|
67
68
|
if (req.headers.origin) {
|
|
68
69
|
res.status(403).json({
|
|
69
70
|
message: `Export cannot be triggered by external callers.`,
|
|
70
71
|
});
|
|
72
|
+
return;
|
|
71
73
|
}
|
|
72
74
|
const path = req.body.path;
|
|
73
75
|
const initiatedBy = req.body.initiatedBy || "unknown";
|
|
@@ -91,8 +93,8 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
91
93
|
message: errorString,
|
|
92
94
|
});
|
|
93
95
|
}
|
|
94
|
-
});
|
|
95
|
-
app.put(EmulatorHub.PATH_DISABLE_FUNCTIONS, async (req, res) => {
|
|
96
|
+
}));
|
|
97
|
+
app.put(EmulatorHub.PATH_DISABLE_FUNCTIONS, (0, express_1.asyncHandler)(async (req, res) => {
|
|
96
98
|
utils.logLabeledBullet("emulators", `Disabling Cloud Functions triggers, non-HTTP functions will not execute.`);
|
|
97
99
|
const instance = registry_1.EmulatorRegistry.get(types_1.Emulators.FUNCTIONS);
|
|
98
100
|
if (!instance) {
|
|
@@ -102,8 +104,8 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
102
104
|
const emu = instance;
|
|
103
105
|
await emu.disableBackgroundTriggers();
|
|
104
106
|
res.status(200).json({ enabled: false });
|
|
105
|
-
});
|
|
106
|
-
app.put(EmulatorHub.PATH_ENABLE_FUNCTIONS, async (req, res) => {
|
|
107
|
+
}));
|
|
108
|
+
app.put(EmulatorHub.PATH_ENABLE_FUNCTIONS, (0, express_1.asyncHandler)(async (req, res) => {
|
|
107
109
|
utils.logLabeledBullet("emulators", `Enabling Cloud Functions triggers, non-HTTP functions will execute.`);
|
|
108
110
|
const instance = registry_1.EmulatorRegistry.get(types_1.Emulators.FUNCTIONS);
|
|
109
111
|
if (!instance) {
|
|
@@ -113,12 +115,13 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
113
115
|
const emu = instance;
|
|
114
116
|
await emu.reloadTriggers();
|
|
115
117
|
res.status(200).json({ enabled: true });
|
|
116
|
-
});
|
|
117
|
-
app.post(EmulatorHub.PATH_CLEAR_DATA_CONNECT, async (req, res) => {
|
|
118
|
+
}));
|
|
119
|
+
app.post(EmulatorHub.PATH_CLEAR_DATA_CONNECT, (0, express_1.asyncHandler)(async (req, res) => {
|
|
118
120
|
if (req.headers.origin) {
|
|
119
121
|
res.status(403).json({
|
|
120
122
|
message: `Clear SQL Connect cannot be triggered by external callers.`,
|
|
121
123
|
});
|
|
124
|
+
return;
|
|
122
125
|
}
|
|
123
126
|
utils.logLabeledBullet("emulators", `Clearing data from SQL Connect data sources.`);
|
|
124
127
|
const instance = registry_1.EmulatorRegistry.get(types_1.Emulators.DATACONNECT);
|
|
@@ -128,7 +131,8 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
128
131
|
}
|
|
129
132
|
await instance.clearData();
|
|
130
133
|
res.status(200).json({ success: true });
|
|
131
|
-
});
|
|
134
|
+
}));
|
|
135
|
+
app.use((0, express_1.jsonErrorHandler)(types_1.Emulators.HUB));
|
|
132
136
|
return app;
|
|
133
137
|
}
|
|
134
138
|
async stop() {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asyncHandler = asyncHandler;
|
|
4
|
+
exports.jsonErrorHandler = jsonErrorHandler;
|
|
5
|
+
const error_1 = require("../../error");
|
|
6
|
+
const emulatorLogger_1 = require("../emulatorLogger");
|
|
7
|
+
function asyncHandler(fn) {
|
|
8
|
+
return (req, res, next) => {
|
|
9
|
+
void fn(req, res, next).catch((err) => {
|
|
10
|
+
next(err ?? new Error("Async route handler rejected without a reason"));
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function jsonErrorHandler(emulator) {
|
|
15
|
+
return (err, req, res, next) => {
|
|
16
|
+
if (res.headersSent) {
|
|
17
|
+
next(err);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const e = err;
|
|
21
|
+
const status = e?.status ?? e?.statusCode;
|
|
22
|
+
const code = typeof status === "number" && status >= 400 && status < 600 ? status : 500;
|
|
23
|
+
if (code >= 500) {
|
|
24
|
+
emulatorLogger_1.EmulatorLogger.forEmulator(emulator).log("WARN", `${req.method} ${req.path} failed: ${(0, error_1.getErrStack)(err)}`);
|
|
25
|
+
}
|
|
26
|
+
res
|
|
27
|
+
.status(code)
|
|
28
|
+
.json({ error: { code, message: code < 500 ? (0, error_1.getErrMsg)(err) : "Internal error" } });
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -13,6 +13,7 @@ const multipart_1 = require("../multipart");
|
|
|
13
13
|
const errors_1 = require("../errors");
|
|
14
14
|
const upload_1 = require("../upload");
|
|
15
15
|
const request_1 = require("../../shared/request");
|
|
16
|
+
const express_2 = require("../../shared/express");
|
|
16
17
|
function createFirebaseEndpoints(emulator) {
|
|
17
18
|
const firebaseStorageAPI = (0, express_1.Router)();
|
|
18
19
|
const { storageLayer, uploadService } = emulator;
|
|
@@ -86,7 +87,7 @@ function createFirebaseEndpoints(emulator) {
|
|
|
86
87
|
}
|
|
87
88
|
next();
|
|
88
89
|
});
|
|
89
|
-
firebaseStorageAPI.get("/b/:bucketId/o/:objectId", async (req, res) => {
|
|
90
|
+
firebaseStorageAPI.get("/b/:bucketId/o/:objectId", (0, express_2.asyncHandler)(async (req, res) => {
|
|
90
91
|
let metadata;
|
|
91
92
|
let data;
|
|
92
93
|
try {
|
|
@@ -118,8 +119,8 @@ function createFirebaseEndpoints(emulator) {
|
|
|
118
119
|
return (0, shared_1.sendFileBytes)(metadata, data, req, res);
|
|
119
120
|
}
|
|
120
121
|
return res.json(new metadata_1.OutgoingFirebaseMetadata(metadata));
|
|
121
|
-
});
|
|
122
|
-
firebaseStorageAPI.get("/b/:bucketId/o", async (req, res) => {
|
|
122
|
+
}));
|
|
123
|
+
firebaseStorageAPI.get("/b/:bucketId/o", (0, express_2.asyncHandler)(async (req, res) => {
|
|
123
124
|
const maxResults = req.query.maxResults?.toString();
|
|
124
125
|
let listResponse;
|
|
125
126
|
let prefix = "";
|
|
@@ -164,7 +165,7 @@ function createFirebaseEndpoints(emulator) {
|
|
|
164
165
|
return { name: item.name, bucket: item.bucket };
|
|
165
166
|
}),
|
|
166
167
|
});
|
|
167
|
-
});
|
|
168
|
+
}));
|
|
168
169
|
const handleUpload = async (req, res) => {
|
|
169
170
|
const bucketId = req.params.bucketId;
|
|
170
171
|
const objectId = req.params.objectId
|
|
@@ -440,17 +441,17 @@ function createFirebaseEndpoints(emulator) {
|
|
|
440
441
|
setObjectHeaders(res, metadata);
|
|
441
442
|
return res.json(new metadata_1.OutgoingFirebaseMetadata(metadata));
|
|
442
443
|
};
|
|
443
|
-
firebaseStorageAPI.patch("/b/:bucketId/o/:objectId", (0, express_1.json)({ limit: "130mb" }), handleMetadataUpdate);
|
|
444
|
-
firebaseStorageAPI.put("/b/:bucketId/o/:objectId?", firebasePostUploadMiddleware, async (req, res) => {
|
|
444
|
+
firebaseStorageAPI.patch("/b/:bucketId/o/:objectId", (0, express_1.json)({ limit: "130mb" }), (0, express_2.asyncHandler)(handleMetadataUpdate));
|
|
445
|
+
firebaseStorageAPI.put("/b/:bucketId/o/:objectId?", firebasePostUploadMiddleware, (0, express_2.asyncHandler)(async (req, res) => {
|
|
445
446
|
switch (req.header("x-http-method-override")?.toLowerCase()) {
|
|
446
447
|
case "patch":
|
|
447
448
|
return handleMetadataUpdate(req, res);
|
|
448
449
|
default:
|
|
449
450
|
return handleObjectPostRequest(req, res);
|
|
450
451
|
}
|
|
451
|
-
});
|
|
452
|
-
firebaseStorageAPI.post("/b/:bucketId/o/:objectId?", firebasePostUploadMiddleware, handleObjectPostRequest);
|
|
453
|
-
firebaseStorageAPI.delete("/b/:bucketId/o/:objectId", async (req, res) => {
|
|
452
|
+
}));
|
|
453
|
+
firebaseStorageAPI.post("/b/:bucketId/o/:objectId?", firebasePostUploadMiddleware, (0, express_2.asyncHandler)(handleObjectPostRequest));
|
|
454
|
+
firebaseStorageAPI.delete("/b/:bucketId/o/:objectId", (0, express_2.asyncHandler)(async (req, res) => {
|
|
454
455
|
try {
|
|
455
456
|
await storageLayer.deleteObject({
|
|
456
457
|
bucketId: req.params.bucketId,
|
|
@@ -473,7 +474,7 @@ function createFirebaseEndpoints(emulator) {
|
|
|
473
474
|
throw err;
|
|
474
475
|
}
|
|
475
476
|
res.sendStatus(204);
|
|
476
|
-
});
|
|
477
|
+
}));
|
|
477
478
|
firebaseStorageAPI.get("/", (req, res) => {
|
|
478
479
|
res.json({ emulator: "storage" });
|
|
479
480
|
});
|
|
@@ -12,6 +12,7 @@ const multipart_1 = require("../multipart");
|
|
|
12
12
|
const upload_1 = require("../upload");
|
|
13
13
|
const errors_1 = require("../errors");
|
|
14
14
|
const request_1 = require("../../shared/request");
|
|
15
|
+
const express_2 = require("../../shared/express");
|
|
15
16
|
function createCloudEndpoints(emulator) {
|
|
16
17
|
const gcloudStorageAPI = (0, express_1.Router)();
|
|
17
18
|
const { adminStorageLayer, uploadService } = emulator;
|
|
@@ -66,17 +67,17 @@ function createCloudEndpoints(emulator) {
|
|
|
66
67
|
adminStorageLayer.createBucket(req.params[0]);
|
|
67
68
|
next();
|
|
68
69
|
});
|
|
69
|
-
gcloudStorageAPI.get("/b", async (req, res) => {
|
|
70
|
+
gcloudStorageAPI.get("/b", (0, express_2.asyncHandler)(async (req, res) => {
|
|
70
71
|
res.json({
|
|
71
72
|
kind: "storage#buckets",
|
|
72
73
|
items: await adminStorageLayer.listBuckets(),
|
|
73
74
|
});
|
|
74
|
-
});
|
|
75
|
+
}));
|
|
75
76
|
gcloudStorageAPI.get([
|
|
76
77
|
"/b/:bucketId/o/:objectId",
|
|
77
78
|
"/download/storage/v1/b/:bucketId/o/:objectId",
|
|
78
79
|
"/storage/v1/b/:bucketId/o/:objectId",
|
|
79
|
-
], async (req, res) => {
|
|
80
|
+
], (0, express_2.asyncHandler)(async (req, res) => {
|
|
80
81
|
let getObjectResponse;
|
|
81
82
|
try {
|
|
82
83
|
getObjectResponse = await adminStorageLayer.getObject({
|
|
@@ -97,8 +98,8 @@ function createCloudEndpoints(emulator) {
|
|
|
97
98
|
return (0, shared_1.sendFileBytes)(getObjectResponse.metadata, getObjectResponse.data, req, res);
|
|
98
99
|
}
|
|
99
100
|
return res.json(new metadata_1.CloudStorageObjectMetadata(getObjectResponse.metadata));
|
|
100
|
-
});
|
|
101
|
-
gcloudStorageAPI.patch("/b/:bucketId/o/:objectId", (0, express_1.json)({ limit: "130mb" }), async (req, res) => {
|
|
101
|
+
}));
|
|
102
|
+
gcloudStorageAPI.patch("/b/:bucketId/o/:objectId", (0, express_1.json)({ limit: "130mb" }), (0, express_2.asyncHandler)(async (req, res) => {
|
|
102
103
|
let updatedMetadata;
|
|
103
104
|
try {
|
|
104
105
|
updatedMetadata = await adminStorageLayer.updateObjectMetadata({
|
|
@@ -117,8 +118,8 @@ function createCloudEndpoints(emulator) {
|
|
|
117
118
|
throw err;
|
|
118
119
|
}
|
|
119
120
|
return res.json(new metadata_1.CloudStorageObjectMetadata(updatedMetadata));
|
|
120
|
-
});
|
|
121
|
-
gcloudStorageAPI.get(["/b/:bucketId/o", "/storage/v1/b/:bucketId/o"], async (req, res) => {
|
|
121
|
+
}));
|
|
122
|
+
gcloudStorageAPI.get(["/b/:bucketId/o", "/storage/v1/b/:bucketId/o"], (0, express_2.asyncHandler)(async (req, res) => {
|
|
122
123
|
let listResponse;
|
|
123
124
|
try {
|
|
124
125
|
listResponse = await adminStorageLayer.listObjects({
|
|
@@ -142,8 +143,8 @@ function createCloudEndpoints(emulator) {
|
|
|
142
143
|
prefixes: listResponse.prefixes,
|
|
143
144
|
items: listResponse.items?.map((item) => new metadata_1.CloudStorageObjectMetadata(item)),
|
|
144
145
|
});
|
|
145
|
-
});
|
|
146
|
-
gcloudStorageAPI.delete(["/b/:bucketId/o/:objectId", "/storage/v1/b/:bucketId/o/:objectId"], async (req, res) => {
|
|
146
|
+
}));
|
|
147
|
+
gcloudStorageAPI.delete(["/b/:bucketId/o/:objectId", "/storage/v1/b/:bucketId/o/:objectId"], (0, express_2.asyncHandler)(async (req, res) => {
|
|
147
148
|
try {
|
|
148
149
|
await adminStorageLayer.deleteObject({
|
|
149
150
|
bucketId: req.params.bucketId,
|
|
@@ -160,8 +161,8 @@ function createCloudEndpoints(emulator) {
|
|
|
160
161
|
throw err;
|
|
161
162
|
}
|
|
162
163
|
return res.sendStatus(204);
|
|
163
|
-
});
|
|
164
|
-
gcloudStorageAPI.put("/upload/storage/v1/b/:bucketId/o", bodyParser.raw({ type: "*/*", limit: "130mb" }), async (req, res) => {
|
|
164
|
+
}));
|
|
165
|
+
gcloudStorageAPI.put("/upload/storage/v1/b/:bucketId/o", bodyParser.raw({ type: "*/*", limit: "130mb" }), (0, express_2.asyncHandler)(async (req, res) => {
|
|
165
166
|
if (!req.query.upload_id) {
|
|
166
167
|
res.sendStatus(400);
|
|
167
168
|
return;
|
|
@@ -192,8 +193,8 @@ function createCloudEndpoints(emulator) {
|
|
|
192
193
|
throw err;
|
|
193
194
|
}
|
|
194
195
|
return res.json(new metadata_1.CloudStorageObjectMetadata(metadata));
|
|
195
|
-
});
|
|
196
|
-
gcloudStorageAPI.post("/b/:bucketId/o/:objectId/acl", (0, express_1.json)({ limit: "130mb" }), async (req, res) => {
|
|
196
|
+
}));
|
|
197
|
+
gcloudStorageAPI.post("/b/:bucketId/o/:objectId/acl", (0, express_1.json)({ limit: "130mb" }), (0, express_2.asyncHandler)(async (req, res) => {
|
|
197
198
|
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.STORAGE).log("WARN_ONCE", "Cloud Storage ACLs are not supported in the Storage Emulator. All related methods will succeed, but have no effect.");
|
|
198
199
|
let getObjectResponse;
|
|
199
200
|
try {
|
|
@@ -226,8 +227,8 @@ function createCloudEndpoints(emulator) {
|
|
|
226
227
|
etag: "someEtag",
|
|
227
228
|
generation: metadata.generation.toString(),
|
|
228
229
|
});
|
|
229
|
-
});
|
|
230
|
-
gcloudStorageAPI.post("/upload/storage/v1/b/:bucketId/o", postUploadMiddleware, async (req, res) => {
|
|
230
|
+
}));
|
|
231
|
+
gcloudStorageAPI.post("/upload/storage/v1/b/:bucketId/o", postUploadMiddleware, (0, express_2.asyncHandler)(async (req, res) => {
|
|
231
232
|
const uploadType = req.query.uploadType || req.header("X-Goog-Upload-Protocol");
|
|
232
233
|
if (uploadType === "resumable") {
|
|
233
234
|
const name = getIncomingFileNameFromRequest(req.query, req.body);
|
|
@@ -310,8 +311,8 @@ function createCloudEndpoints(emulator) {
|
|
|
310
311
|
authorization: req.header("authorization"),
|
|
311
312
|
});
|
|
312
313
|
return await finalizeOneShotUpload(upload);
|
|
313
|
-
});
|
|
314
|
-
gcloudStorageAPI.get("/:bucketId/:objectId(**)", async (req, res) => {
|
|
314
|
+
}));
|
|
315
|
+
gcloudStorageAPI.get("/:bucketId/:objectId(**)", (0, express_2.asyncHandler)(async (req, res) => {
|
|
315
316
|
let getObjectResponse;
|
|
316
317
|
try {
|
|
317
318
|
getObjectResponse = await adminStorageLayer.getObject({
|
|
@@ -329,11 +330,11 @@ function createCloudEndpoints(emulator) {
|
|
|
329
330
|
throw err;
|
|
330
331
|
}
|
|
331
332
|
return (0, shared_1.sendFileBytes)(getObjectResponse.metadata, getObjectResponse.data, req, res);
|
|
332
|
-
});
|
|
333
|
+
}));
|
|
333
334
|
gcloudStorageAPI.post("/:bucketId", (req, res, next) => {
|
|
334
335
|
adminStorageLayer.createBucket(req.params.bucketId);
|
|
335
336
|
next();
|
|
336
|
-
}, async (req, res) => {
|
|
337
|
+
}, (0, express_2.asyncHandler)(async (req, res) => {
|
|
337
338
|
const contentTypeHeader = req.header("content-type");
|
|
338
339
|
if (!contentTypeHeader?.includes("multipart/form-data")) {
|
|
339
340
|
return res.status(400).send("Content-Type must be multipart/form-data");
|
|
@@ -390,7 +391,7 @@ function createCloudEndpoints(emulator) {
|
|
|
390
391
|
}
|
|
391
392
|
throw err;
|
|
392
393
|
}
|
|
393
|
-
});
|
|
394
|
+
}));
|
|
394
395
|
gcloudStorageAPI.post("/b/:bucketId/o/:objectId/:method(rewriteTo|copyTo)/b/:destBucketId/o/:destObjectId", (0, express_1.json)({ limit: "130mb" }), (req, res, next) => {
|
|
395
396
|
if (req.params.method === "rewriteTo" && req.query.rewriteToken) {
|
|
396
397
|
return next();
|
|
@@ -382,6 +382,6 @@ class StorageLayer {
|
|
|
382
382
|
}
|
|
383
383
|
exports.StorageLayer = StorageLayer;
|
|
384
384
|
function getPathSep(decodedPath) {
|
|
385
|
-
const firstSepIndex = decodedPath.search(/[
|
|
385
|
+
const firstSepIndex = decodedPath.search(/[/|\\\\]/g);
|
|
386
386
|
return decodedPath[firstSepIndex];
|
|
387
387
|
}
|
|
@@ -32,6 +32,19 @@ class DefaultStorageRulesManager {
|
|
|
32
32
|
await this._watcher.close();
|
|
33
33
|
}
|
|
34
34
|
updateWatcher(rulesFile) {
|
|
35
|
+
const handleFileChange = async () => {
|
|
36
|
+
await new Promise((res) => setTimeout(res, WATCHER_CHANGE_DELAY_MS));
|
|
37
|
+
try {
|
|
38
|
+
const content = (0, fsutils_1.readFile)(rulesFile);
|
|
39
|
+
this._rules.content = content;
|
|
40
|
+
this._logger.logLabeled("BULLET", "storage", "Change detected, updating rules for Cloud Storage...");
|
|
41
|
+
await this.loadRuleset();
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
45
|
+
this._logger.logLabeled("DEBUG", "storage", `A rule file change was detected, but there was an error reading it: ${message}`);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
35
48
|
return new Promise((resolve) => {
|
|
36
49
|
const timer = setTimeout(resolve, WATCHER_READY_TIMEOUT_MS);
|
|
37
50
|
timer.unref?.();
|
|
@@ -47,18 +60,8 @@ class DefaultStorageRulesManager {
|
|
|
47
60
|
this._logger.logLabeled("DEBUG", "storage", `A storage rules file watcher error occurred: ${message}`);
|
|
48
61
|
resolve();
|
|
49
62
|
})
|
|
50
|
-
.on("change",
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
const content = (0, fsutils_1.readFile)(rulesFile);
|
|
54
|
-
this._rules.content = content;
|
|
55
|
-
this._logger.logLabeled("BULLET", "storage", "Change detected, updating rules for Cloud Storage...");
|
|
56
|
-
await this.loadRuleset();
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
60
|
-
this._logger.logLabeled("DEBUG", "storage", `A rule file change was detected, but there was an error reading it: ${message}`);
|
|
61
|
-
}
|
|
63
|
+
.on("change", () => {
|
|
64
|
+
void handleFileChange();
|
|
62
65
|
});
|
|
63
66
|
});
|
|
64
67
|
}
|
|
@@ -9,6 +9,7 @@ const bodyParser = require("body-parser");
|
|
|
9
9
|
const gcloud_1 = require("./apis/gcloud");
|
|
10
10
|
const firebase_1 = require("./apis/firebase");
|
|
11
11
|
const errors_1 = require("../auth/errors");
|
|
12
|
+
const express_1 = require("../shared/express");
|
|
12
13
|
function createApp(defaultProjectId, emulator) {
|
|
13
14
|
const { storageLayer } = emulator;
|
|
14
15
|
const app = express();
|
|
@@ -38,7 +39,7 @@ function createApp(defaultProjectId, emulator) {
|
|
|
38
39
|
}));
|
|
39
40
|
app.use(bodyParser.raw({ limit: "130mb", type: "application/x-www-form-urlencoded" }));
|
|
40
41
|
app.use(bodyParser.raw({ limit: "130mb", type: "multipart/related" }));
|
|
41
|
-
app.post("/internal/export", express.json({ limit: "130mb" }), async (req, res) => {
|
|
42
|
+
app.post("/internal/export", express.json({ limit: "130mb" }), (0, express_1.asyncHandler)(async (req, res) => {
|
|
42
43
|
const initiatedBy = req.body.initiatedBy || "unknown";
|
|
43
44
|
const path = req.body.path;
|
|
44
45
|
if (!path) {
|
|
@@ -47,8 +48,8 @@ function createApp(defaultProjectId, emulator) {
|
|
|
47
48
|
}
|
|
48
49
|
await storageLayer.export(path, { initiatedBy });
|
|
49
50
|
res.sendStatus(200);
|
|
50
|
-
});
|
|
51
|
-
app.put("/internal/setRules", express.json({ limit: "130mb" }), async (req, res) => {
|
|
51
|
+
}));
|
|
52
|
+
app.put("/internal/setRules", express.json({ limit: "130mb" }), (0, express_1.asyncHandler)(async (req, res) => {
|
|
52
53
|
const rulesRaw = req.body.rules;
|
|
53
54
|
if (!(rulesRaw && Array.isArray(rulesRaw.files) && rulesRaw.files.length > 0)) {
|
|
54
55
|
res.status(400).json({
|
|
@@ -70,7 +71,10 @@ function createApp(defaultProjectId, emulator) {
|
|
|
70
71
|
if (!isRulesFile(file) || !file.resource) {
|
|
71
72
|
throw new errors_1.InvalidArgumentError("Each member of 'rules.files' array must contain 'name', 'content', and 'resource'");
|
|
72
73
|
}
|
|
73
|
-
rules.push({
|
|
74
|
+
rules.push({
|
|
75
|
+
resource: file.resource,
|
|
76
|
+
rules: { name: file.name, content: file.content },
|
|
77
|
+
});
|
|
74
78
|
}
|
|
75
79
|
return rules;
|
|
76
80
|
}
|
|
@@ -95,13 +99,14 @@ function createApp(defaultProjectId, emulator) {
|
|
|
95
99
|
res.status(200).json({
|
|
96
100
|
message: "Rules updated successfully",
|
|
97
101
|
});
|
|
98
|
-
});
|
|
102
|
+
}));
|
|
99
103
|
app.post("/internal/reset", (req, res) => {
|
|
100
104
|
emulator.reset();
|
|
101
105
|
res.sendStatus(200);
|
|
102
106
|
});
|
|
103
107
|
app.use("/v0", (0, firebase_1.createFirebaseEndpoints)(emulator));
|
|
104
108
|
app.use("/", (0, gcloud_1.createCloudEndpoints)(emulator));
|
|
109
|
+
app.use((0, express_1.jsonErrorHandler)(types_1.Emulators.STORAGE));
|
|
105
110
|
return Promise.resolve(app);
|
|
106
111
|
}
|
|
107
112
|
function isRulesFile(file) {
|
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);
|
|
@@ -86,7 +86,7 @@ exports.AUTOPOPULATED_PARAM_PLACEHOLDERS = {
|
|
|
86
86
|
exports.resourceTypeToNiceName = {
|
|
87
87
|
"firebaseextensions.v1beta.function": "Cloud Function",
|
|
88
88
|
};
|
|
89
|
-
const repoRegex = new RegExp(`^https
|
|
89
|
+
const repoRegex = new RegExp(`^https://github.com/[^/]+/[^/]+$`);
|
|
90
90
|
const stageOptions = ["rc", "alpha", "beta", "stable"];
|
|
91
91
|
function getDBInstanceFromURL(databaseUrl = "") {
|
|
92
92
|
const instanceRegex = new RegExp("(?:https://)(.*)(?:.firebaseio.com)");
|
|
@@ -268,7 +268,7 @@ function validateSpec(spec) {
|
|
|
268
268
|
async function promptForValidInstanceId(instanceId) {
|
|
269
269
|
let instanceIdIsValid = false;
|
|
270
270
|
let newInstanceId = "";
|
|
271
|
-
const instanceIdRegex = /^[a-z][a-z\d
|
|
271
|
+
const instanceIdRegex = /^[a-z][a-z\d-]*[a-z\d]$/;
|
|
272
272
|
while (!instanceIdIsValid) {
|
|
273
273
|
newInstanceId = await (0, prompt_1.input)({
|
|
274
274
|
default: instanceId,
|
|
@@ -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);
|
|
@@ -181,7 +181,7 @@ function readEnvFile(envPath) {
|
|
|
181
181
|
return result.envs;
|
|
182
182
|
}
|
|
183
183
|
function isSystemParam(paramName) {
|
|
184
|
-
const regex = /^firebaseextensions\.[a-zA-Z0-9
|
|
184
|
+
const regex = /^firebaseextensions\.[a-zA-Z0-9.]*\//;
|
|
185
185
|
return regex.test(paramName);
|
|
186
186
|
}
|
|
187
187
|
function partitionParams(params) {
|