firebase-tools 15.35.0 → 15.36.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/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/auth.js +8 -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-heapdumps-status.js +1 -1
- package/lib/commands/deploy.js +1 -3
- 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 +1 -3
- 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 +1 -0
- package/lib/crashlytics/events.js +122 -1
- package/lib/crashlytics/filters.js +12 -6
- package/lib/crashlytics/profilingManager.js +14 -34
- package/lib/crashlytics/utils.js +14 -0
- package/lib/database/import.js +5 -4
- package/lib/dataconnect/names.js +3 -3
- package/lib/dataconnect/schemaMigration.js +1 -1
- package/lib/deploy/functions/backend.js +0 -10
- package/lib/deploy/functions/cel.js +1 -1
- 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/v1alpha1.js +1 -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 +24 -24
- 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 +11 -7
- package/lib/emulator/functionsEmulatorRuntime.js +7 -2
- 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/extensions/extensionsHelper.js +2 -2
- package/lib/extensions/paramHelper.js +1 -1
- package/lib/extensions/provisioningHelper.js +1 -6
- package/lib/firestore/util.js +3 -3
- package/lib/frameworks/angular/utils.js +1 -1
- package/lib/frameworks/next/utils.js +1 -1
- 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/cloudfunctionsv2.js +0 -6
- package/lib/gcp/devConnect.js +2 -2
- package/lib/hosting/api.js +79 -0
- package/lib/hosting/proxy.js +4 -1
- package/lib/init/features/hosting/github.js +6 -4
- package/lib/init/features/hosting/index.js +4 -0
- package/lib/mcp/apps/init/mcp-app.js +4 -1
- package/lib/mcp/index.js +8 -2
- 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 +1 -1
- package/lib/mcp/tools/crashlytics/setup.js +392 -0
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +4 -10
- package/package.json +1 -1
- package/lib/functions/kits/sources/index.js +0 -19
|
@@ -54,36 +54,36 @@
|
|
|
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.26",
|
|
58
|
+
"expectedSize": 35802400,
|
|
59
|
+
"expectedChecksum": "7b412320648e289a5302f92dedaf4924",
|
|
60
|
+
"expectedChecksumSHA256": "f7c131c9158548b40e64a86cf27bb7e8de5cd5601ad7eb0771130053abbabd95",
|
|
61
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.26",
|
|
62
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.26"
|
|
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.26",
|
|
66
|
+
"expectedSize": 33762002,
|
|
67
|
+
"expectedChecksum": "35c444137e843a16db4d4b37afea2b9c",
|
|
68
|
+
"expectedChecksumSHA256": "5e872d05c130efe374b5174a5afffb06cab7b3739bac59d8e660ee168160f895",
|
|
69
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.26",
|
|
70
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.26"
|
|
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.26",
|
|
74
|
+
"expectedSize": 35780608,
|
|
75
|
+
"expectedChecksum": "1a9cdf0db3bc605772798b0cc075834d",
|
|
76
|
+
"expectedChecksumSHA256": "9948f2f65067e4a9fa0a2648228664913c5f196f95ba674aee3ba4dbfed8a384",
|
|
77
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.26",
|
|
78
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.26.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.26",
|
|
82
|
+
"expectedSize": 34803874,
|
|
83
|
+
"expectedChecksum": "ab8ed6eb387f6ba36d1cb3a793adac28",
|
|
84
|
+
"expectedChecksumSHA256": "1c96d378ca7e95f5af3fef90f351d0142809916b0593a6dac39e6d7f276437c9",
|
|
85
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.26",
|
|
86
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.26"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -407,12 +407,12 @@ async function _runBinary(emulator, command, extraEnv) {
|
|
|
407
407
|
emulator.instance.on("error", (err) => {
|
|
408
408
|
void handleEmulatorProcessError(emulator.name, err, command.port);
|
|
409
409
|
});
|
|
410
|
-
emulator.instance.once("exit",
|
|
410
|
+
emulator.instance.once("exit", (code, signal) => {
|
|
411
411
|
if (signal) {
|
|
412
412
|
utils.logWarning(`${description} has exited upon receiving signal: ${signal}`);
|
|
413
413
|
}
|
|
414
414
|
else if (code && code !== 0 && code !== 130) {
|
|
415
|
-
|
|
415
|
+
void _fatal(emulator.name, `${description} has exited with code: ${code}`);
|
|
416
416
|
}
|
|
417
417
|
});
|
|
418
418
|
resolve();
|
|
@@ -9,27 +9,27 @@ function replaceConsoleLinks(postinstall) {
|
|
|
9
9
|
let subbedPostinstall = postinstall;
|
|
10
10
|
const linkReplacements = new Map([
|
|
11
11
|
[
|
|
12
|
-
/(http[s]?:\/\/)?console\.firebase\.google\.com\/(u\/[0-9]\/)?project\/[A-Za-z0-9-]+\/storage[A-Za-z0-9
|
|
12
|
+
/(http[s]?:\/\/)?console\.firebase\.google\.com\/(u\/[0-9]\/)?project\/[A-Za-z0-9-]+\/storage[A-Za-z0-9/-]*(?=[)\]\s])/,
|
|
13
13
|
`${uiUrl}${types_1.Emulators.STORAGE}`,
|
|
14
14
|
],
|
|
15
15
|
[
|
|
16
|
-
/(http[s]?:\/\/)?console\.firebase\.google\.com\/(u\/[0-9]\/)?project\/[A-Za-z0-9-]+\/firestore[A-Za-z0-9
|
|
16
|
+
/(http[s]?:\/\/)?console\.firebase\.google\.com\/(u\/[0-9]\/)?project\/[A-Za-z0-9-]+\/firestore[A-Za-z0-9/-]*(?=[)\]\s])/,
|
|
17
17
|
`${uiUrl}${types_1.Emulators.FIRESTORE}`,
|
|
18
18
|
],
|
|
19
19
|
[
|
|
20
|
-
/(http[s]?:\/\/)?console\.firebase\.google\.com\/(u\/[0-9]\/)?project\/[A-Za-z0-9-]+\/database[A-Za-z0-9
|
|
20
|
+
/(http[s]?:\/\/)?console\.firebase\.google\.com\/(u\/[0-9]\/)?project\/[A-Za-z0-9-]+\/database[A-Za-z0-9/-]*(?=[)\]\s])/,
|
|
21
21
|
`${uiUrl}${types_1.Emulators.DATABASE}`,
|
|
22
22
|
],
|
|
23
23
|
[
|
|
24
|
-
/(http[s]?:\/\/)?console\.firebase\.google\.com\/(u\/[0-9]\/)?project\/[A-Za-z0-9-]+\/authentication[A-Za-z0-9
|
|
24
|
+
/(http[s]?:\/\/)?console\.firebase\.google\.com\/(u\/[0-9]\/)?project\/[A-Za-z0-9-]+\/authentication[A-Za-z0-9/-]*(?=[)\]\s])/,
|
|
25
25
|
`${uiUrl}${types_1.Emulators.AUTH}`,
|
|
26
26
|
],
|
|
27
27
|
[
|
|
28
|
-
/(http[s]?:\/\/)?console\.firebase\.google\.com\/(u\/[0-9]\/)?project\/[A-Za-z0-9-]+\/functions[A-Za-z0-9
|
|
28
|
+
/(http[s]?:\/\/)?console\.firebase\.google\.com\/(u\/[0-9]\/)?project\/[A-Za-z0-9-]+\/functions[A-Za-z0-9/-]*(?=[)\]\s])/,
|
|
29
29
|
`${uiUrl}logs`,
|
|
30
30
|
],
|
|
31
31
|
[
|
|
32
|
-
/(http[s]?:\/\/)?console\.firebase\.google\.com\/(u\/[0-9]\/)?project\/[A-Za-z0-9-]+\/extensions[A-Za-z0-9
|
|
32
|
+
/(http[s]?:\/\/)?console\.firebase\.google\.com\/(u\/[0-9]\/)?project\/[A-Za-z0-9-]+\/extensions[A-Za-z0-9/-]*(?=[)\]\s])/,
|
|
33
33
|
`${uiUrl}${types_1.Emulators.EXTENSIONS}`,
|
|
34
34
|
],
|
|
35
35
|
]);
|
|
@@ -6,6 +6,7 @@ const fs = require("fs");
|
|
|
6
6
|
const clc = require("colorette");
|
|
7
7
|
const path = require("path");
|
|
8
8
|
const utils = require("../utils");
|
|
9
|
+
const error_1 = require("../error");
|
|
9
10
|
const downloadableEmulators = require("./downloadableEmulators");
|
|
10
11
|
const types_1 = require("../emulator/types");
|
|
11
12
|
const registry_1 = require("./registry");
|
|
@@ -26,22 +27,27 @@ class FirestoreEmulator {
|
|
|
26
27
|
utils.logLabeledWarning("firestore", `Could not watch ${rulesPath} for changes, so rules hot reloading is disabled: ${message}. ` +
|
|
27
28
|
"If your environment does not support file watching, set CHOKIDAR_USEPOLLING=1 to fall back to polling.");
|
|
28
29
|
});
|
|
29
|
-
this.rulesWatcher.on("change",
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
this.rulesWatcher.on("change", () => {
|
|
31
|
+
const update = async () => {
|
|
32
|
+
await new Promise((res) => setTimeout(res, 5));
|
|
33
|
+
utils.logLabeledBullet("firestore", "Change detected, updating rules...");
|
|
34
|
+
const newContent = fs.readFileSync(rulesPath, "utf8").toString();
|
|
35
|
+
const issues = await this.updateRules(newContent);
|
|
36
|
+
if (issues) {
|
|
37
|
+
for (const issue of issues) {
|
|
38
|
+
utils.logWarning(this.prettyPrintRulesIssue(rulesPath, issue));
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
41
|
+
if (issues.some((issue) => issue.severity === types_1.Severity.ERROR)) {
|
|
42
|
+
utils.logWarning("Failed to update rules");
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
utils.logLabeledSuccess("firestore", "Rules updated.");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
update().catch((err) => {
|
|
49
|
+
utils.logWarning(`Failed to update rules: ${(0, error_1.getErrMsg)(err)}`);
|
|
50
|
+
});
|
|
45
51
|
});
|
|
46
52
|
}
|
|
47
53
|
return downloadableEmulators.start(types_1.Emulators.FIRESTORE, this.args);
|
|
@@ -68,10 +68,10 @@ class TCPConn {
|
|
|
68
68
|
exports.TCPConn = TCPConn;
|
|
69
69
|
function createIgnoredFilter(ignore) {
|
|
70
70
|
const ignored = [
|
|
71
|
-
/(^|[
|
|
71
|
+
/(^|[/\\])\../,
|
|
72
72
|
/.+\.log/,
|
|
73
|
-
/.+?[
|
|
74
|
-
/.+?[
|
|
73
|
+
/.+?[\\/]node_modules[\\/].+?/,
|
|
74
|
+
/.+?[\\/]venv[\\/].+?/,
|
|
75
75
|
];
|
|
76
76
|
if (ignore) {
|
|
77
77
|
const minimatchInstances = ignore.map((pattern) => {
|
|
@@ -309,7 +309,9 @@ class FunctionsEmulator {
|
|
|
309
309
|
};
|
|
310
310
|
const delegate = await runtimes.getRuntimeDelegate(runtimeDelegateContext);
|
|
311
311
|
this.logger.logLabeled("BULLET", "functions", `Starting build_runner watch for Dart functions...`);
|
|
312
|
-
const debouncedLoadTriggers = (0, utils_1.debounce)(() =>
|
|
312
|
+
const debouncedLoadTriggers = (0, utils_1.debounce)(() => {
|
|
313
|
+
this.loadTriggers(backend).catch((err) => this.logger.logLabeled("WARN", "functions", `Failed to reload triggers: ${(0, error_1.getErrMsg)(err)}`));
|
|
314
|
+
}, 1000);
|
|
313
315
|
const cleanup = await delegate.watch(() => {
|
|
314
316
|
this.logger.log("DEBUG", "build_runner rebuilt, reloading triggers");
|
|
315
317
|
debouncedLoadTriggers();
|
|
@@ -323,10 +325,12 @@ class FunctionsEmulator {
|
|
|
323
325
|
persistent: true,
|
|
324
326
|
});
|
|
325
327
|
this.watchers.push(watcher);
|
|
326
|
-
const debouncedLoadTriggers = (0, utils_1.debounce)(() =>
|
|
328
|
+
const debouncedLoadTriggers = (0, utils_1.debounce)(() => {
|
|
329
|
+
this.loadTriggers(backend).catch((err) => this.logger.logLabeled("WARN", "functions", `Failed to reload triggers: ${(0, error_1.getErrMsg)(err)}`));
|
|
330
|
+
}, 1000);
|
|
327
331
|
watcher.on("change", (filePath) => {
|
|
328
332
|
this.logger.log("DEBUG", `File ${filePath} changed, reloading triggers`);
|
|
329
|
-
|
|
333
|
+
debouncedLoadTriggers();
|
|
330
334
|
});
|
|
331
335
|
}
|
|
332
336
|
}
|
|
@@ -1290,7 +1294,7 @@ class FunctionsEmulator {
|
|
|
1290
1294
|
});
|
|
1291
1295
|
this.logger.log("DEBUG", `[functions] Runtime ready! Sending request!`);
|
|
1292
1296
|
const url = new url_1.URL(`${req.protocol}://${req.hostname}${req.url}`);
|
|
1293
|
-
let path = `${url.pathname}${url.search}`.replace(new RegExp(
|
|
1297
|
+
let path = `${url.pathname}${url.search}`.replace(new RegExp(`/${this.args.projectId}/[^/]*/${req.params.trigger_name}/?`), "/");
|
|
1294
1298
|
if ((0, supported_1.runtimeIsLanguage)(record.backend.runtime, "dart")) {
|
|
1295
1299
|
const isBackgroundRoute = req.url.startsWith("/functions/projects/");
|
|
1296
1300
|
if (isBackgroundRoute || path === "/") {
|
|
@@ -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) {
|