firebase-tools 15.23.0 → 15.25.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/api.js +4 -2
- package/lib/appcheck/api.js +42 -0
- package/lib/appcheck/prompts.js +41 -0
- package/lib/appcheck/types.js +2 -0
- package/lib/bin/cli.js +9 -2
- package/lib/bin/progressiveHelp.js +126 -0
- package/lib/checkValidTargetFilters.js +1 -1
- package/lib/command.js +11 -10
- package/lib/commands/ailogic-config-get.js +75 -0
- package/lib/commands/ailogic-config-set.js +109 -0
- package/lib/commands/ailogic-providers-disable.js +39 -0
- package/lib/commands/ailogic-providers-enable.js +28 -0
- package/lib/commands/ailogic-providers-list.js +29 -0
- package/lib/commands/appcheck-debugtokens-create.js +95 -0
- package/lib/commands/appcheck-debugtokens-delete.js +48 -0
- package/lib/commands/appcheck-debugtokens-list.js +35 -0
- package/lib/commands/apps-sdkconfig.js +2 -23
- package/lib/commands/database-get.js +1 -1
- package/lib/commands/dataconnect-execute.js +1 -1
- package/lib/commands/deploy.js +27 -64
- package/lib/commands/index.js +15 -0
- 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/build.js +93 -3
- package/lib/deploy/functions/index.js +33 -1
- package/lib/deploy/functions/params.js +68 -26
- package/lib/deploy/functions/prepare.js +34 -8
- package/lib/deploy/functions/prompts.js +19 -0
- package/lib/deploy/functions/release/index.js +19 -12
- package/lib/deploy/functions/release/lifecycle.js +38 -5
- package/lib/deploy/functions/release/planner.js +3 -1
- package/lib/deploy/functions/runtimes/node/index.js +8 -7
- package/lib/deploy/functions/runtimes/node/versioning.js +8 -3
- package/lib/deploy/functions/validate.js +5 -2
- package/lib/deploy/hosting/index.js +30 -1
- package/lib/deploy/hosting/uploader.js +2 -1
- 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/emulator/dataconnect/pgliteServer.js +2 -1
- package/lib/emulator/downloadableEmulatorInfo.json +30 -30
- package/lib/emulator/downloadableEmulators.js +1 -0
- package/lib/emulator/hubExport.js +2 -1
- package/lib/emulator/storage/apis/firebase.js +24 -5
- package/lib/emulator/storage/apis/gcloud.js +16 -6
- package/lib/emulator/storage/rules/runtime.js +45 -33
- package/lib/emulator/storage/server.js +2 -5
- package/lib/emulator/storage/upload.js +1 -0
- package/lib/ensureApiEnabled.js +8 -0
- package/lib/experiments.js +16 -0
- package/lib/extensions/warnings.js +64 -0
- package/lib/frameworks/utils.js +50 -1
- package/lib/functions/env.js +22 -2
- package/lib/functions/secrets.js +4 -1
- package/lib/gcp/ailogic.js +165 -1
- package/lib/gcp/cloudfunctionsv2.js +7 -0
- package/lib/gcp/firedata.js +5 -1
- package/lib/gcp/serviceusage.js +26 -0
- package/lib/hosting/proxy.js +15 -3
- package/lib/index.js +0 -1
- package/lib/init/features/ailogic/index.js +3 -29
- package/lib/init/features/database.js +1 -1
- package/lib/management/apps.js +16 -5
- package/lib/mcp/onemcp/onemcp_server.js +28 -9
- package/lib/mcp/tools/core/get_security_rules.js +2 -1
- package/lib/profiler.js +1 -1
- package/lib/streamUtils.js +3 -0
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -83,7 +83,9 @@ async function createDeploymentPlan(args) {
|
|
|
83
83
|
let rolesToRemove;
|
|
84
84
|
let serviceAccountToCreate;
|
|
85
85
|
let serviceAccountToDelete;
|
|
86
|
-
const isFiltered = !!(filters &&
|
|
86
|
+
const isFiltered = !!(filters &&
|
|
87
|
+
filters.some((f) => f.idChunks && f.idChunks.length > 0) &&
|
|
88
|
+
!deleteAll);
|
|
87
89
|
if (requiredRoles) {
|
|
88
90
|
rolesToAdd = requiredRoles.filter((r) => !roles.includes(r));
|
|
89
91
|
rolesToRemove = roles.filter((r) => !requiredRoles.includes(r));
|
|
@@ -17,8 +17,6 @@ const supported = require("../supported");
|
|
|
17
17
|
const validate = require("./validate");
|
|
18
18
|
const versioning = require("./versioning");
|
|
19
19
|
const fsutils_1 = require("../../../../fsutils");
|
|
20
|
-
const MIN_FUNCTIONS_SDK_VERSION = "3.20.0";
|
|
21
|
-
const MIN_FUNCTIONS_SDK_VERSION_FOR_EXTENSIONS_FEATURES = "5.1.0";
|
|
22
20
|
async function tryCreateDelegate(context) {
|
|
23
21
|
const packageJsonPath = path.join(context.sourceDir, "package.json");
|
|
24
22
|
try {
|
|
@@ -169,14 +167,17 @@ class Delegate {
|
|
|
169
167
|
});
|
|
170
168
|
}
|
|
171
169
|
async discoverBuild(config, env) {
|
|
172
|
-
if (
|
|
173
|
-
|
|
170
|
+
if (this.sdkVersion === versioning.FUNCTIONS_SDK_DEV_VERSION) {
|
|
171
|
+
logger_1.logger.debug("Skipping check for MIN_FUNCTIONS_SDK_VERSION for local development version.");
|
|
172
|
+
}
|
|
173
|
+
else if (semver.valid(this.sdkVersion)) {
|
|
174
|
+
if (semver.lt(this.sdkVersion, versioning.MIN_FUNCTIONS_SDK_VERSION)) {
|
|
174
175
|
throw new error_1.FirebaseError(`You are using an old version of firebase-functions SDK (${this.sdkVersion}). ` +
|
|
175
|
-
`Please update firebase-functions SDK to >=${MIN_FUNCTIONS_SDK_VERSION}`);
|
|
176
|
+
`Please update firebase-functions SDK to >=${versioning.MIN_FUNCTIONS_SDK_VERSION}`);
|
|
176
177
|
}
|
|
177
|
-
if (semver.lt(this.sdkVersion, MIN_FUNCTIONS_SDK_VERSION_FOR_EXTENSIONS_FEATURES)) {
|
|
178
|
+
if (semver.lt(this.sdkVersion, versioning.MIN_FUNCTIONS_SDK_VERSION_FOR_EXTENSIONS_FEATURES)) {
|
|
178
179
|
(0, utils_1.logLabeledBullet)("functions", `You are using a version of firebase-functions SDK (${this.sdkVersion}) that does not have support for the newest Firebase Extensions features. ` +
|
|
179
|
-
`Please update firebase-functions SDK to >=${MIN_FUNCTIONS_SDK_VERSION_FOR_EXTENSIONS_FEATURES} to use them correctly`);
|
|
180
|
+
`Please update firebase-functions SDK to >=${versioning.MIN_FUNCTIONS_SDK_VERSION_FOR_EXTENSIONS_FEATURES} to use them correctly`);
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FUNCTIONS_SDK_VERSION_TOO_OLD_WARNING = void 0;
|
|
3
|
+
exports.FUNCTIONS_SDK_VERSION_TOO_OLD_WARNING = exports.MIN_FUNCTIONS_SDK_VERSION_FOR_EXTENSIONS_FEATURES = exports.MIN_FUNCTIONS_SDK_VERSION = exports.FUNCTIONS_SDK_DEV_VERSION = void 0;
|
|
4
4
|
exports.findModuleVersion = findModuleVersion;
|
|
5
5
|
exports.getFunctionsSDKVersion = getFunctionsSDKVersion;
|
|
6
6
|
exports.getLatestSDKVersion = getLatestSDKVersion;
|
|
@@ -12,7 +12,9 @@ const spawn = require("cross-spawn");
|
|
|
12
12
|
const semver = require("semver");
|
|
13
13
|
const logger_1 = require("../../../../logger");
|
|
14
14
|
const utils = require("../../../../utils");
|
|
15
|
-
|
|
15
|
+
exports.FUNCTIONS_SDK_DEV_VERSION = "0.0.0-development";
|
|
16
|
+
exports.MIN_FUNCTIONS_SDK_VERSION = "3.20.0";
|
|
17
|
+
exports.MIN_FUNCTIONS_SDK_VERSION_FOR_EXTENSIONS_FEATURES = "5.1.0";
|
|
16
18
|
const NPM_COMMAND_TIMEOUT_MILLIES = 10000;
|
|
17
19
|
exports.FUNCTIONS_SDK_VERSION_TOO_OLD_WARNING = clc.bold(clc.yellow("functions: ")) +
|
|
18
20
|
"You must have a " +
|
|
@@ -67,8 +69,11 @@ function getLatestSDKVersion() {
|
|
|
67
69
|
return output["dist-tags"]?.["latest"];
|
|
68
70
|
}
|
|
69
71
|
function checkFunctionsSDKVersion(currentVersion) {
|
|
72
|
+
if (currentVersion === exports.FUNCTIONS_SDK_DEV_VERSION) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
70
75
|
try {
|
|
71
|
-
if (semver.lt(currentVersion,
|
|
76
|
+
if (semver.lt(currentVersion, exports.MIN_FUNCTIONS_SDK_VERSION)) {
|
|
72
77
|
utils.logWarning(exports.FUNCTIONS_SDK_VERSION_TOO_OLD_WARNING);
|
|
73
78
|
}
|
|
74
79
|
const latest = exports.getLatestSDKVersion();
|
|
@@ -240,7 +240,7 @@ async function validateSecretVersions(projectId, endpoints) {
|
|
|
240
240
|
}
|
|
241
241
|
const results = await utils.allSettled(Array.from(toResolve).map(async (secret) => {
|
|
242
242
|
const sv = await (0, secretManager_1.getSecretVersion)(projectId, secret, "latest");
|
|
243
|
-
logger_1.logger.debug(`Resolved secret version of ${clc.bold(secret)} to ${clc.bold(sv.versionId)}.`);
|
|
243
|
+
logger_1.logger.debug(`Resolved latest secret version of ${clc.bold(secret)} to ${clc.bold(sv.versionId)}.`);
|
|
244
244
|
return sv;
|
|
245
245
|
}));
|
|
246
246
|
const secretVersions = {};
|
|
@@ -261,7 +261,10 @@ async function validateSecretVersions(projectId, endpoints) {
|
|
|
261
261
|
throw new error_1.FirebaseError("Failed to validate secret versions", { children: errs });
|
|
262
262
|
}
|
|
263
263
|
for (const s of secrets.of(endpoints)) {
|
|
264
|
-
s.version
|
|
264
|
+
if (!s.version || !s.allowVersionPinning) {
|
|
265
|
+
s.version = secretVersions[s.secret].versionId;
|
|
266
|
+
}
|
|
267
|
+
delete s.allowVersionPinning;
|
|
265
268
|
if (!s.version) {
|
|
266
269
|
throw new error_1.FirebaseError("Secret version is unexpectedly undefined. This should never happen.");
|
|
267
270
|
}
|
|
@@ -1,9 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.release = exports.deploy = exports.prepare = void 0;
|
|
3
|
+
exports.detailedHelp = exports.help = exports.release = exports.deploy = exports.prepare = void 0;
|
|
4
4
|
var prepare_1 = require("./prepare");
|
|
5
5
|
Object.defineProperty(exports, "prepare", { enumerable: true, get: function () { return prepare_1.prepare; } });
|
|
6
6
|
var deploy_1 = require("./deploy");
|
|
7
7
|
Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return deploy_1.deploy; } });
|
|
8
8
|
var release_1 = require("./release");
|
|
9
9
|
Object.defineProperty(exports, "release", { enumerable: true, get: function () { return release_1.release; } });
|
|
10
|
+
exports.help = "Deploys static web apps to Firebase Hosting, including assets, redirects, rewrites and headers.";
|
|
11
|
+
exports.detailedHelp = "Firebase Hosting deploys web assets, redirects, rewrites, and header configurations.\n\n" +
|
|
12
|
+
"Single site configuration in firebase.json:\n" +
|
|
13
|
+
"{\n" +
|
|
14
|
+
' "hosting": {\n' +
|
|
15
|
+
' "public": "public",\n' +
|
|
16
|
+
' "ignore": [\n' +
|
|
17
|
+
' "firebase.json",\n' +
|
|
18
|
+
' "**/.*",\n' +
|
|
19
|
+
' "**/node_modules/**"\n' +
|
|
20
|
+
" ],\n" +
|
|
21
|
+
' "rewrites": [\n' +
|
|
22
|
+
' { "source": "**", "destination": "/index.html" }\n' +
|
|
23
|
+
" ]\n" +
|
|
24
|
+
" }\n" +
|
|
25
|
+
"}\n\n" +
|
|
26
|
+
"Multiple sites configuration (by site ID or deploy target):\n" +
|
|
27
|
+
"{\n" +
|
|
28
|
+
' "hosting": [\n' +
|
|
29
|
+
" {\n" +
|
|
30
|
+
' "site": "my-site-id",\n' +
|
|
31
|
+
' "public": "dist"\n' +
|
|
32
|
+
" },\n" +
|
|
33
|
+
" {\n" +
|
|
34
|
+
' "target": "my-site-target",\n' +
|
|
35
|
+
' "public": "build"\n' +
|
|
36
|
+
" }\n" +
|
|
37
|
+
" ]\n" +
|
|
38
|
+
"}";
|
|
@@ -13,6 +13,7 @@ const api_1 = require("../../api");
|
|
|
13
13
|
const hashcache_1 = require("./hashcache");
|
|
14
14
|
const logger_1 = require("../../logger");
|
|
15
15
|
const error_1 = require("../../error");
|
|
16
|
+
const streamUtils_1 = require("../../streamUtils");
|
|
16
17
|
const MIN_UPLOAD_TIMEOUT = 30000;
|
|
17
18
|
const MAX_UPLOAD_TIMEOUT = 7200000;
|
|
18
19
|
function progressMessage(message, current, total) {
|
|
@@ -188,7 +189,7 @@ class Uploader {
|
|
|
188
189
|
logger_1.logger.debug("[hosting][upload]", this.uploadQueue.stats());
|
|
189
190
|
}
|
|
190
191
|
if (res.status !== 200) {
|
|
191
|
-
const errorMessage = await res.
|
|
192
|
+
const errorMessage = await (0, streamUtils_1.streamToString)(res.body);
|
|
192
193
|
logger_1.logger.debug(`[hosting][upload] ${this.hashMap[toUpload]} (${toUpload}) HTTP ERROR ${res.status}: headers=${JSON.stringify(Object.fromEntries(res.response.headers.entries()))} ${errorMessage}`);
|
|
193
194
|
throw new Error(`Unexpected error while uploading file: ${errorMessage}`);
|
|
194
195
|
}
|
package/lib/deploy/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deploy = exports.isDeployingWebFramework = void 0;
|
|
3
|
+
exports.deploy = exports.isDeployingWebFramework = exports.TARGETS = exports.TARGET_PERMISSIONS = exports.VALID_DEPLOY_TARGETS = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const api_1 = require("../api");
|
|
@@ -24,11 +24,71 @@ const AppHostingTarget = require("./apphosting");
|
|
|
24
24
|
const AuthTarget = require("./auth");
|
|
25
25
|
const frameworks_1 = require("../frameworks");
|
|
26
26
|
const prepare_1 = require("./hosting/prepare");
|
|
27
|
-
const utils_2 = require("../utils");
|
|
28
|
-
const deploy_1 = require("../commands/deploy");
|
|
29
27
|
const requirePermissions_1 = require("../requirePermissions");
|
|
30
28
|
const context_1 = require("./dataconnect/context");
|
|
31
|
-
|
|
29
|
+
exports.VALID_DEPLOY_TARGETS = [
|
|
30
|
+
"database",
|
|
31
|
+
"storage",
|
|
32
|
+
"firestore",
|
|
33
|
+
"functions",
|
|
34
|
+
"hosting",
|
|
35
|
+
"remoteconfig",
|
|
36
|
+
"extensions",
|
|
37
|
+
"dataconnect",
|
|
38
|
+
"apphosting",
|
|
39
|
+
"auth",
|
|
40
|
+
];
|
|
41
|
+
exports.TARGET_PERMISSIONS = {
|
|
42
|
+
database: ["firebasedatabase.instances.update"],
|
|
43
|
+
hosting: ["firebasehosting.sites.update"],
|
|
44
|
+
functions: [
|
|
45
|
+
"cloudfunctions.functions.list",
|
|
46
|
+
"cloudfunctions.functions.create",
|
|
47
|
+
"cloudfunctions.functions.get",
|
|
48
|
+
"cloudfunctions.functions.update",
|
|
49
|
+
"cloudfunctions.functions.delete",
|
|
50
|
+
"cloudfunctions.operations.get",
|
|
51
|
+
],
|
|
52
|
+
firestore: [
|
|
53
|
+
"datastore.indexes.list",
|
|
54
|
+
"datastore.indexes.create",
|
|
55
|
+
"datastore.indexes.update",
|
|
56
|
+
"datastore.indexes.delete",
|
|
57
|
+
],
|
|
58
|
+
storage: [
|
|
59
|
+
"firebaserules.releases.create",
|
|
60
|
+
"firebaserules.rulesets.create",
|
|
61
|
+
"firebaserules.releases.update",
|
|
62
|
+
],
|
|
63
|
+
remoteconfig: ["cloudconfig.configs.get", "cloudconfig.configs.update"],
|
|
64
|
+
dataconnect: [
|
|
65
|
+
"cloudsql.databases.create",
|
|
66
|
+
"cloudsql.databases.update",
|
|
67
|
+
"cloudsql.instances.connect",
|
|
68
|
+
"cloudsql.instances.create",
|
|
69
|
+
"cloudsql.instances.get",
|
|
70
|
+
"cloudsql.instances.list",
|
|
71
|
+
"cloudsql.instances.update",
|
|
72
|
+
"cloudsql.users.create",
|
|
73
|
+
"firebasedataconnect.connectors.create",
|
|
74
|
+
"firebasedataconnect.connectors.delete",
|
|
75
|
+
"firebasedataconnect.connectors.list",
|
|
76
|
+
"firebasedataconnect.connectors.update",
|
|
77
|
+
"firebasedataconnect.operations.get",
|
|
78
|
+
"firebasedataconnect.services.create",
|
|
79
|
+
"firebasedataconnect.services.delete",
|
|
80
|
+
"firebasedataconnect.services.update",
|
|
81
|
+
"firebasedataconnect.services.list",
|
|
82
|
+
"firebasedataconnect.schemas.create",
|
|
83
|
+
"firebasedataconnect.schemas.delete",
|
|
84
|
+
"firebasedataconnect.schemas.list",
|
|
85
|
+
"firebasedataconnect.schemas.update",
|
|
86
|
+
],
|
|
87
|
+
apphosting: [],
|
|
88
|
+
extensions: [],
|
|
89
|
+
auth: ["firebase.projects.update", "firebaseauth.configs.update"],
|
|
90
|
+
};
|
|
91
|
+
exports.TARGETS = {
|
|
32
92
|
hosting: HostingTarget,
|
|
33
93
|
database: DatabaseTarget,
|
|
34
94
|
firestore: FirestoreTarget,
|
|
@@ -84,10 +144,10 @@ const deploy = async function (targetNames, options, customContext = {}) {
|
|
|
84
144
|
if (!targetNames.includes("functions")) {
|
|
85
145
|
targetNames.unshift("functions");
|
|
86
146
|
try {
|
|
87
|
-
await (0, requirePermissions_1.requirePermissions)(options,
|
|
147
|
+
await (0, requirePermissions_1.requirePermissions)(options, exports.TARGET_PERMISSIONS["functions"]);
|
|
88
148
|
}
|
|
89
149
|
catch (e) {
|
|
90
|
-
if ((0,
|
|
150
|
+
if ((0, utils_1.isRunningInGithubAction)()) {
|
|
91
151
|
throw new error_1.FirebaseError("It looks like you are deploying a Hosting site along with Cloud Functions " +
|
|
92
152
|
"using a GitHub action version that did not include Cloud Functions " +
|
|
93
153
|
"permissions. Please reinstall the GitHub action with" +
|
|
@@ -101,7 +161,7 @@ const deploy = async function (targetNames, options, customContext = {}) {
|
|
|
101
161
|
await (0, prepare_1.addPinnedFunctionsToOnlyString)(context, options);
|
|
102
162
|
}
|
|
103
163
|
for (const targetName of targetNames) {
|
|
104
|
-
const target = TARGETS[targetName];
|
|
164
|
+
const target = exports.TARGETS[targetName];
|
|
105
165
|
if (!target) {
|
|
106
166
|
return Promise.reject(new error_1.FirebaseError(`${(0, colorette_1.bold)(targetName)} is not a valid deploy target`));
|
|
107
167
|
}
|
|
@@ -138,7 +198,7 @@ const deploy = async function (targetNames, options, customContext = {}) {
|
|
|
138
198
|
};
|
|
139
199
|
const duration = Date.now() - startTime;
|
|
140
200
|
const params = Object.assign({}, baseParams);
|
|
141
|
-
Object.keys(TARGETS).reduce((accum, t) => {
|
|
201
|
+
Object.keys(exports.TARGETS).reduce((accum, t) => {
|
|
142
202
|
accum[t] = "false";
|
|
143
203
|
return accum;
|
|
144
204
|
}, params);
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deploy = exports.release = exports.prepare = void 0;
|
|
3
|
+
exports.detailedHelp = exports.help = exports.deploy = exports.release = exports.prepare = void 0;
|
|
4
4
|
const prepare_1 = require("./prepare");
|
|
5
5
|
exports.prepare = prepare_1.default;
|
|
6
6
|
const release_1 = require("./release");
|
|
7
7
|
exports.release = release_1.default;
|
|
8
8
|
const deploy_1 = require("./deploy");
|
|
9
9
|
exports.deploy = deploy_1.default;
|
|
10
|
+
exports.help = "Deploys Remote Config templates defined in your project's firebase.json.";
|
|
11
|
+
exports.detailedHelp = "Firebase Remote Config deploys client-facing templates and configurations.\n\n" +
|
|
12
|
+
"Configuration format in firebase.json:\n" +
|
|
13
|
+
"{\n" +
|
|
14
|
+
' "remoteconfig": {\n' +
|
|
15
|
+
' "template": "remoteconfig.template.json"\n' +
|
|
16
|
+
" }\n" +
|
|
17
|
+
"}";
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.release = exports.deploy = exports.prepare = void 0;
|
|
3
|
+
exports.detailedHelp = exports.help = exports.release = exports.deploy = exports.prepare = void 0;
|
|
4
4
|
const prepare_1 = require("./prepare");
|
|
5
5
|
exports.prepare = prepare_1.default;
|
|
6
6
|
const deploy_1 = require("./deploy");
|
|
7
7
|
exports.deploy = deploy_1.default;
|
|
8
8
|
const release_1 = require("./release");
|
|
9
9
|
exports.release = release_1.default;
|
|
10
|
+
exports.help = "Deploys security rules for Cloud Storage buckets defined in your project's firebase.json.";
|
|
11
|
+
exports.detailedHelp = "Cloud Storage deploys security rules to Storage buckets.\n\n" +
|
|
12
|
+
"Single bucket configuration in firebase.json:\n" +
|
|
13
|
+
"{\n" +
|
|
14
|
+
' "storage": {\n' +
|
|
15
|
+
' "rules": "storage.rules"\n' +
|
|
16
|
+
" }\n" +
|
|
17
|
+
"}\n\n" +
|
|
18
|
+
"Multiple buckets configuration (requires bucket name and rules file):\n" +
|
|
19
|
+
"{\n" +
|
|
20
|
+
' "storage": [\n' +
|
|
21
|
+
' { "bucket": "my-app-bucket-1", "rules": "storage-1.rules" },\n' +
|
|
22
|
+
' { "bucket": "my-app-bucket-2", "rules": "storage-2.rules", "target": "my-storage-target" }\n' +
|
|
23
|
+
" ]\n" +
|
|
24
|
+
"}";
|
|
@@ -52,7 +52,8 @@ class PostgresServer {
|
|
|
52
52
|
logger_1.logger.debug("Postgres client disconnected");
|
|
53
53
|
});
|
|
54
54
|
socket.on("error", (err) => {
|
|
55
|
-
|
|
55
|
+
logger_1.logger.debug("Postgres client socket error (if this happened during request cancellation, it is expected and harmless):", err);
|
|
56
|
+
socket.destroy();
|
|
56
57
|
});
|
|
57
58
|
});
|
|
58
59
|
this.server = server;
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"downloadPathRelativeToCacheDir": "firebase-database-emulator-v4.11.2.jar"
|
|
9
9
|
},
|
|
10
10
|
"firestore": {
|
|
11
|
-
"version": "1.
|
|
12
|
-
"expectedSize":
|
|
13
|
-
"expectedChecksum": "
|
|
14
|
-
"expectedChecksumSHA256": "
|
|
15
|
-
"remoteUrl": "https://storage.googleapis.com/firebase-preview-drop/emulator/cloud-firestore-emulator-v1.
|
|
16
|
-
"downloadPathRelativeToCacheDir": "cloud-firestore-emulator-v1.
|
|
11
|
+
"version": "1.22.0",
|
|
12
|
+
"expectedSize": 136707194,
|
|
13
|
+
"expectedChecksum": "5d74cc6bee9e18560d2eae2c6440fd13",
|
|
14
|
+
"expectedChecksumSHA256": "9b6498b7f62714d67f48f59b3818883cd682dbcd46b9f59511de81c97bb5166c",
|
|
15
|
+
"remoteUrl": "https://storage.googleapis.com/firebase-preview-drop/emulator/cloud-firestore-emulator-v1.22.0.jar",
|
|
16
|
+
"downloadPathRelativeToCacheDir": "cloud-firestore-emulator-v1.22.0.jar"
|
|
17
17
|
},
|
|
18
18
|
"storage": {
|
|
19
19
|
"version": "1.1.3",
|
|
@@ -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.16",
|
|
58
|
+
"expectedSize": 32877328,
|
|
59
|
+
"expectedChecksum": "48d472d8a9b009153d127bb0af9c0c77",
|
|
60
|
+
"expectedChecksumSHA256": "c4764168d79977047a8891ef52a450a4843b36d6d506e35a2147abeee01d7dd0",
|
|
61
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.16",
|
|
62
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.16"
|
|
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.16",
|
|
66
|
+
"expectedSize": 30995666,
|
|
67
|
+
"expectedChecksum": "71055082dbcf0a95451ac63839463a13",
|
|
68
|
+
"expectedChecksumSHA256": "b31dc5e60046474c66033209ac93105b91195fffa0a4a50bba73fda2cbb14ba7",
|
|
69
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.16",
|
|
70
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.16"
|
|
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.16",
|
|
74
|
+
"expectedSize": 32919040,
|
|
75
|
+
"expectedChecksum": "d53acc32d9a996d99f8a8ac0abc82b04",
|
|
76
|
+
"expectedChecksumSHA256": "962f6cbc62d39da102d49c463f225846ce64438bc95bdc28ee8f35b92b7bd6ef",
|
|
77
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.16",
|
|
78
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.16.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.16",
|
|
82
|
+
"expectedSize": 32030904,
|
|
83
|
+
"expectedChecksum": "240d642c408929e609d75eeeefe22689",
|
|
84
|
+
"expectedChecksumSHA256": "9963b3f1f011bf236a2a9908ebd7a282b79cd44405e77bdf8a566fd1c00dc4c7",
|
|
85
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.16",
|
|
86
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.16"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -14,6 +14,7 @@ const downloadableEmulators_1 = require("./downloadableEmulators");
|
|
|
14
14
|
const node_fs_1 = require("node:fs");
|
|
15
15
|
const track_1 = require("../track");
|
|
16
16
|
const api_1 = require("../api");
|
|
17
|
+
const streamUtils_1 = require("../streamUtils");
|
|
17
18
|
class HubExport {
|
|
18
19
|
constructor(projectId, options) {
|
|
19
20
|
this.projectId = projectId;
|
|
@@ -217,7 +218,7 @@ class HubExport {
|
|
|
217
218
|
resolveOnHTTPError: true,
|
|
218
219
|
});
|
|
219
220
|
if (res.status >= 400) {
|
|
220
|
-
throw new error_1.FirebaseError(`Failed to export storage: ${await res.
|
|
221
|
+
throw new error_1.FirebaseError(`Failed to export storage: ${await (0, streamUtils_1.streamToString)(res.body)}`);
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
224
|
async exportDataConnect(metadata) {
|
|
@@ -6,6 +6,7 @@ const types_1 = require("../../types");
|
|
|
6
6
|
const crypto_1 = require("crypto");
|
|
7
7
|
const metadata_1 = require("../metadata");
|
|
8
8
|
const express_1 = require("express");
|
|
9
|
+
const bodyParser = require("body-parser");
|
|
9
10
|
const shared_1 = require("./shared");
|
|
10
11
|
const registry_1 = require("../../registry");
|
|
11
12
|
const multipart_1 = require("../multipart");
|
|
@@ -15,6 +16,23 @@ const request_1 = require("../../shared/request");
|
|
|
15
16
|
function createFirebaseEndpoints(emulator) {
|
|
16
17
|
const firebaseStorageAPI = (0, express_1.Router)();
|
|
17
18
|
const { storageLayer, uploadService } = emulator;
|
|
19
|
+
const firebasePostUploadMiddleware = (req, res, next) => {
|
|
20
|
+
if (req.method === "PUT" && req.header("x-http-method-override")?.toLowerCase() === "patch") {
|
|
21
|
+
(0, express_1.json)({ limit: "130mb" })(req, res, next);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const uploadType = req.header("x-goog-upload-protocol");
|
|
25
|
+
const uploadCommand = req.header("x-goog-upload-command");
|
|
26
|
+
if (uploadCommand === "start") {
|
|
27
|
+
(0, express_1.json)({ limit: "130mb" })(req, res, next);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (uploadType === "multipart") {
|
|
31
|
+
next();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
bodyParser.raw({ type: "*/*", limit: "130mb" })(req, res, next);
|
|
35
|
+
};
|
|
18
36
|
if (process.env.STORAGE_EMULATOR_DEBUG) {
|
|
19
37
|
firebaseStorageAPI.use((req, res, next) => {
|
|
20
38
|
console.log("--------------INCOMING FIREBASE REQUEST--------------");
|
|
@@ -54,7 +72,7 @@ function createFirebaseEndpoints(emulator) {
|
|
|
54
72
|
next();
|
|
55
73
|
});
|
|
56
74
|
}
|
|
57
|
-
firebaseStorageAPI.use(/.*\/b\/(.+?)
|
|
75
|
+
firebaseStorageAPI.use(/.*\/b\/(.+?)\/.*/i, (req, res, next) => {
|
|
58
76
|
const bucketId = req.params[0];
|
|
59
77
|
storageLayer.createBucket(bucketId);
|
|
60
78
|
if (!emulator.rulesManager.getRuleset(bucketId)) {
|
|
@@ -107,7 +125,7 @@ function createFirebaseEndpoints(emulator) {
|
|
|
107
125
|
let prefix = "";
|
|
108
126
|
if (req.query.prefix) {
|
|
109
127
|
prefix = req.query.prefix.toString();
|
|
110
|
-
if (prefix.
|
|
128
|
+
if (!prefix.endsWith("/")) {
|
|
111
129
|
return res.status(400).json({
|
|
112
130
|
error: {
|
|
113
131
|
code: 400,
|
|
@@ -323,6 +341,7 @@ function createFirebaseEndpoints(emulator) {
|
|
|
323
341
|
bucketId: req.params.bucketId,
|
|
324
342
|
objectId: objectId,
|
|
325
343
|
dataRaw: await (0, request_1.reqBodyToBuffer)(req),
|
|
344
|
+
contentType: req.header("content-type"),
|
|
326
345
|
authorization: req.header("authorization"),
|
|
327
346
|
});
|
|
328
347
|
return await finalizeOneShotUpload(upload);
|
|
@@ -421,8 +440,8 @@ function createFirebaseEndpoints(emulator) {
|
|
|
421
440
|
setObjectHeaders(res, metadata);
|
|
422
441
|
return res.json(new metadata_1.OutgoingFirebaseMetadata(metadata));
|
|
423
442
|
};
|
|
424
|
-
firebaseStorageAPI.patch("/b/:bucketId/o/:objectId", handleMetadataUpdate);
|
|
425
|
-
firebaseStorageAPI.put("/b/:bucketId/o/:objectId?", async (req, res) => {
|
|
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) => {
|
|
426
445
|
switch (req.header("x-http-method-override")?.toLowerCase()) {
|
|
427
446
|
case "patch":
|
|
428
447
|
return handleMetadataUpdate(req, res);
|
|
@@ -430,7 +449,7 @@ function createFirebaseEndpoints(emulator) {
|
|
|
430
449
|
return handleObjectPostRequest(req, res);
|
|
431
450
|
}
|
|
432
451
|
});
|
|
433
|
-
firebaseStorageAPI.post("/b/:bucketId/o/:objectId?", handleObjectPostRequest);
|
|
452
|
+
firebaseStorageAPI.post("/b/:bucketId/o/:objectId?", firebasePostUploadMiddleware, handleObjectPostRequest);
|
|
434
453
|
firebaseStorageAPI.delete("/b/:bucketId/o/:objectId", async (req, res) => {
|
|
435
454
|
try {
|
|
436
455
|
await storageLayer.deleteObject({
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createCloudEndpoints = createCloudEndpoints;
|
|
4
4
|
const express_1 = require("express");
|
|
5
|
+
const bodyParser = require("body-parser");
|
|
5
6
|
const types_1 = require("../../types");
|
|
6
7
|
const metadata_1 = require("../metadata");
|
|
7
8
|
const shared_1 = require("./shared");
|
|
@@ -14,6 +15,14 @@ const request_1 = require("../../shared/request");
|
|
|
14
15
|
function createCloudEndpoints(emulator) {
|
|
15
16
|
const gcloudStorageAPI = (0, express_1.Router)();
|
|
16
17
|
const { adminStorageLayer, uploadService } = emulator;
|
|
18
|
+
const postUploadMiddleware = (req, res, next) => {
|
|
19
|
+
const uploadType = req.query.uploadType || req.header("X-Goog-Upload-Protocol");
|
|
20
|
+
if (uploadType === "resumable" && !req.query.upload_id) {
|
|
21
|
+
(0, express_1.json)({ limit: "130mb" })(req, res, next);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
bodyParser.raw({ type: "*/*", limit: "130mb" })(req, res, next);
|
|
25
|
+
};
|
|
17
26
|
if (process.env.STORAGE_EMULATOR_DEBUG) {
|
|
18
27
|
gcloudStorageAPI.use((req, res, next) => {
|
|
19
28
|
console.log("--------------INCOMING GCS REQUEST--------------");
|
|
@@ -53,7 +62,7 @@ function createCloudEndpoints(emulator) {
|
|
|
53
62
|
next();
|
|
54
63
|
});
|
|
55
64
|
}
|
|
56
|
-
gcloudStorageAPI.use(/.*\/b\/(.+?)
|
|
65
|
+
gcloudStorageAPI.use(/.*\/b\/(.+?)\/.*/i, (req, res, next) => {
|
|
57
66
|
adminStorageLayer.createBucket(req.params[0]);
|
|
58
67
|
next();
|
|
59
68
|
});
|
|
@@ -89,7 +98,7 @@ function createCloudEndpoints(emulator) {
|
|
|
89
98
|
}
|
|
90
99
|
return res.json(new metadata_1.CloudStorageObjectMetadata(getObjectResponse.metadata));
|
|
91
100
|
});
|
|
92
|
-
gcloudStorageAPI.patch("/b/:bucketId/o/:objectId", async (req, res) => {
|
|
101
|
+
gcloudStorageAPI.patch("/b/:bucketId/o/:objectId", (0, express_1.json)({ limit: "130mb" }), async (req, res) => {
|
|
93
102
|
let updatedMetadata;
|
|
94
103
|
try {
|
|
95
104
|
updatedMetadata = await adminStorageLayer.updateObjectMetadata({
|
|
@@ -152,7 +161,7 @@ function createCloudEndpoints(emulator) {
|
|
|
152
161
|
}
|
|
153
162
|
return res.sendStatus(204);
|
|
154
163
|
});
|
|
155
|
-
gcloudStorageAPI.put("/upload/storage/v1/b/:bucketId/o", async (req, res) => {
|
|
164
|
+
gcloudStorageAPI.put("/upload/storage/v1/b/:bucketId/o", bodyParser.raw({ type: "*/*", limit: "130mb" }), async (req, res) => {
|
|
156
165
|
if (!req.query.upload_id) {
|
|
157
166
|
res.sendStatus(400);
|
|
158
167
|
return;
|
|
@@ -184,7 +193,7 @@ function createCloudEndpoints(emulator) {
|
|
|
184
193
|
}
|
|
185
194
|
return res.json(new metadata_1.CloudStorageObjectMetadata(metadata));
|
|
186
195
|
});
|
|
187
|
-
gcloudStorageAPI.post("/b/:bucketId/o/:objectId/acl", async (req, res) => {
|
|
196
|
+
gcloudStorageAPI.post("/b/:bucketId/o/:objectId/acl", (0, express_1.json)({ limit: "130mb" }), async (req, res) => {
|
|
188
197
|
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.");
|
|
189
198
|
let getObjectResponse;
|
|
190
199
|
try {
|
|
@@ -218,7 +227,7 @@ function createCloudEndpoints(emulator) {
|
|
|
218
227
|
generation: metadata.generation.toString(),
|
|
219
228
|
});
|
|
220
229
|
});
|
|
221
|
-
gcloudStorageAPI.post("/upload/storage/v1/b/:bucketId/o", async (req, res) => {
|
|
230
|
+
gcloudStorageAPI.post("/upload/storage/v1/b/:bucketId/o", postUploadMiddleware, async (req, res) => {
|
|
222
231
|
const uploadType = req.query.uploadType || req.header("X-Goog-Upload-Protocol");
|
|
223
232
|
if (uploadType === "resumable") {
|
|
224
233
|
const name = getIncomingFileNameFromRequest(req.query, req.body);
|
|
@@ -297,6 +306,7 @@ function createCloudEndpoints(emulator) {
|
|
|
297
306
|
bucketId: req.params.bucketId,
|
|
298
307
|
objectId: name.toString(),
|
|
299
308
|
dataRaw: await (0, request_1.reqBodyToBuffer)(req),
|
|
309
|
+
contentType: req.header("content-type"),
|
|
300
310
|
authorization: req.header("authorization"),
|
|
301
311
|
});
|
|
302
312
|
return await finalizeOneShotUpload(upload);
|
|
@@ -381,7 +391,7 @@ function createCloudEndpoints(emulator) {
|
|
|
381
391
|
throw err;
|
|
382
392
|
}
|
|
383
393
|
});
|
|
384
|
-
gcloudStorageAPI.post("/b/:bucketId/o/:objectId/:method(rewriteTo|copyTo)/b/:destBucketId/o/:destObjectId", (req, res, next) => {
|
|
394
|
+
gcloudStorageAPI.post("/b/:bucketId/o/:objectId/:method(rewriteTo|copyTo)/b/:destBucketId/o/:destObjectId", (0, express_1.json)({ limit: "130mb" }), (req, res, next) => {
|
|
385
395
|
if (req.params.method === "rewriteTo" && req.query.rewriteToken) {
|
|
386
396
|
return next();
|
|
387
397
|
}
|