firebase-tools 15.24.0 → 15.25.1
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/command.js +11 -3
- 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/index.js +15 -0
- package/lib/deploy/functions/build.js +93 -3
- package/lib/deploy/functions/functionsDeployHelper.js +18 -12
- package/lib/deploy/functions/params.js +45 -11
- package/lib/deploy/functions/prepare.js +38 -5
- package/lib/deploy/functions/release/executor.js +51 -8
- package/lib/deploy/functions/release/fabricator.js +34 -5
- 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/uploader.js +2 -1
- package/lib/emulator/controller.js +34 -15
- package/lib/emulator/dataconnect/pgliteServer.js +2 -1
- package/lib/emulator/downloadableEmulatorInfo.json +6 -6
- 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 +22 -0
- package/lib/extensions/warnings.js +64 -0
- package/lib/functions/env.js +22 -2
- package/lib/functions/projectConfig.js +98 -12
- 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/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/serve/functions.js +25 -7
- 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
- package/schema/firebase-config.json +93 -0
|
@@ -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
|
}
|
|
@@ -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
|
}
|
|
@@ -11,7 +11,6 @@ const clc = require("colorette");
|
|
|
11
11
|
const fs = require("fs");
|
|
12
12
|
const path = require("path");
|
|
13
13
|
const fsConfig = require("../firestore/fsConfig");
|
|
14
|
-
const proto = require("../gcp/proto");
|
|
15
14
|
const logger_1 = require("../logger");
|
|
16
15
|
const track_1 = require("../track");
|
|
17
16
|
const utils = require("../utils");
|
|
@@ -346,20 +345,40 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
346
345
|
if (runtime && !(0, supported_1.isRuntime)(runtime)) {
|
|
347
346
|
throw new error_1.FirebaseError(`Cannot load functions from ${functionsDir} because it has invalid runtime ${runtime}`);
|
|
348
347
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
348
|
+
if ((0, projectConfig_1.isKitConfig)(localCfg)) {
|
|
349
|
+
for (const [instanceId, configDir] of Object.entries(localCfg.instances)) {
|
|
350
|
+
const backend = {
|
|
351
|
+
functionsDir,
|
|
352
|
+
runtime,
|
|
353
|
+
codebase: instanceId,
|
|
354
|
+
prefix: (0, projectConfig_1.addKitPrefix)(instanceId),
|
|
355
|
+
configDir: path.join(projectDir, configDir),
|
|
356
|
+
env: {
|
|
357
|
+
...options.extDevEnv,
|
|
358
|
+
},
|
|
359
|
+
secretEnv: [],
|
|
360
|
+
predefinedTriggers: options.extDevTriggers,
|
|
361
|
+
ignore: localCfg.ignore,
|
|
362
|
+
};
|
|
363
|
+
emulatableBackends.push(backend);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
const backend = {
|
|
368
|
+
functionsDir,
|
|
369
|
+
runtime,
|
|
370
|
+
codebase: localCfg.codebase,
|
|
371
|
+
...(localCfg.prefix ? { prefix: localCfg.prefix } : {}),
|
|
372
|
+
...(localCfg.configDir ? { configDir: path.join(projectDir, localCfg.configDir) } : {}),
|
|
373
|
+
env: {
|
|
374
|
+
...options.extDevEnv,
|
|
375
|
+
},
|
|
376
|
+
secretEnv: [],
|
|
377
|
+
predefinedTriggers: options.extDevTriggers,
|
|
378
|
+
ignore: localCfg.ignore,
|
|
379
|
+
};
|
|
380
|
+
emulatableBackends.push(backend);
|
|
381
|
+
}
|
|
363
382
|
}
|
|
364
383
|
}
|
|
365
384
|
if (extensionEmulator) {
|
|
@@ -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",
|
|
@@ -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
|
}
|
|
@@ -66,6 +66,7 @@ class StorageRulesRuntime {
|
|
|
66
66
|
this._requestCount = 0;
|
|
67
67
|
this._requests = {};
|
|
68
68
|
this._alive = false;
|
|
69
|
+
this._stdoutBuffer = "";
|
|
69
70
|
}
|
|
70
71
|
get alive() {
|
|
71
72
|
return this._alive;
|
|
@@ -121,37 +122,46 @@ class StorageRulesRuntime {
|
|
|
121
122
|
}
|
|
122
123
|
});
|
|
123
124
|
this._childprocess.stdout?.on("data", (buf) => {
|
|
124
|
-
|
|
125
|
-
if (serializedRuntimeActionResponse !== "") {
|
|
126
|
-
let rap;
|
|
127
|
-
try {
|
|
128
|
-
rap = JSON.parse(serializedRuntimeActionResponse);
|
|
129
|
-
}
|
|
130
|
-
catch (err) {
|
|
131
|
-
emulatorLogger_1.EmulatorLogger.forEmulator(types_2.Emulators.STORAGE).log("INFO", serializedRuntimeActionResponse);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const id = rap.id ?? rap.server_request_id;
|
|
135
|
-
if (id === undefined) {
|
|
136
|
-
console.log(`Received no ID from server response ${serializedRuntimeActionResponse}`);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const request = this._requests[id];
|
|
140
|
-
if (rap.status !== "ok" && !("action" in rap)) {
|
|
141
|
-
console.warn(`[RULES] ${rap.status}: ${rap.message}`);
|
|
142
|
-
rap.errors.forEach(console.warn.bind(console));
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
if (request) {
|
|
146
|
-
request.handler(rap);
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
console.log(`No handler for event ${serializedRuntimeActionResponse}`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
125
|
+
this.handleRuntimeStdout(buf.toString("utf-8"));
|
|
152
126
|
});
|
|
153
127
|
return startPromise;
|
|
154
128
|
}
|
|
129
|
+
handleRuntimeStdout(chunk) {
|
|
130
|
+
this._stdoutBuffer += chunk;
|
|
131
|
+
const lines = this._stdoutBuffer.split("\n");
|
|
132
|
+
this._stdoutBuffer = lines.pop() ?? "";
|
|
133
|
+
for (const rawLine of lines) {
|
|
134
|
+
const line = rawLine.trim();
|
|
135
|
+
if (line === "") {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
let rap;
|
|
139
|
+
try {
|
|
140
|
+
rap = JSON.parse(line);
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
emulatorLogger_1.EmulatorLogger.forEmulator(types_2.Emulators.STORAGE).log("INFO", line);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const id = rap.id ?? rap.server_request_id;
|
|
147
|
+
if (id === undefined) {
|
|
148
|
+
console.log(`Received no ID from server response ${line}`);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const request = this._requests[id];
|
|
152
|
+
if (rap.status !== "ok" && !("action" in rap)) {
|
|
153
|
+
console.warn(`[RULES] ${rap.status}: ${rap.message}`);
|
|
154
|
+
rap.errors.forEach(console.warn.bind(console));
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (request) {
|
|
158
|
+
request.handler(rap);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
console.log(`No handler for event ${line}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
155
165
|
stop() {
|
|
156
166
|
emulatorLogger_1.EmulatorLogger.forEmulator(types_2.Emulators.STORAGE).log("DEBUG", "Stopping rules runtime.");
|
|
157
167
|
return new Promise((resolve) => {
|
|
@@ -181,16 +191,18 @@ class StorageRulesRuntime {
|
|
|
181
191
|
throw new error_1.FirebaseError("Attempted to send Cloud Storage rules request with stale id");
|
|
182
192
|
}
|
|
183
193
|
return new Promise((resolve) => {
|
|
184
|
-
|
|
194
|
+
const requestId = runtimeActionRequest.id;
|
|
195
|
+
this._requests[requestId] = {
|
|
185
196
|
request: runtimeActionRequest,
|
|
186
|
-
handler:
|
|
197
|
+
handler: (rap) => {
|
|
198
|
+
delete this._requests[requestId];
|
|
199
|
+
resolve(rap);
|
|
200
|
+
},
|
|
187
201
|
};
|
|
188
202
|
const serializedRequest = JSON.stringify(runtimeActionRequest);
|
|
189
203
|
lock.acquire(synchonizationKey, (done) => {
|
|
190
204
|
this._childprocess?.stdin?.write(serializedRequest + "\n");
|
|
191
|
-
|
|
192
|
-
done();
|
|
193
|
-
}, 15);
|
|
205
|
+
done();
|
|
194
206
|
});
|
|
195
207
|
});
|
|
196
208
|
}
|
|
@@ -38,10 +38,7 @@ function createApp(defaultProjectId, emulator) {
|
|
|
38
38
|
}));
|
|
39
39
|
app.use(bodyParser.raw({ limit: "130mb", type: "application/x-www-form-urlencoded" }));
|
|
40
40
|
app.use(bodyParser.raw({ limit: "130mb", type: "multipart/related" }));
|
|
41
|
-
app.
|
|
42
|
-
type: ["application/json"],
|
|
43
|
-
}));
|
|
44
|
-
app.post("/internal/export", async (req, res) => {
|
|
41
|
+
app.post("/internal/export", express.json({ limit: "130mb" }), async (req, res) => {
|
|
45
42
|
const initiatedBy = req.body.initiatedBy || "unknown";
|
|
46
43
|
const path = req.body.path;
|
|
47
44
|
if (!path) {
|
|
@@ -51,7 +48,7 @@ function createApp(defaultProjectId, emulator) {
|
|
|
51
48
|
await storageLayer.export(path, { initiatedBy });
|
|
52
49
|
res.sendStatus(200);
|
|
53
50
|
});
|
|
54
|
-
app.put("/internal/setRules", async (req, res) => {
|
|
51
|
+
app.put("/internal/setRules", express.json({ limit: "130mb" }), async (req, res) => {
|
|
55
52
|
const rulesRaw = req.body.rules;
|
|
56
53
|
if (!(rulesRaw && Array.isArray(rulesRaw.files) && rulesRaw.files.length > 0)) {
|
|
57
54
|
res.status(400).json({
|
|
@@ -38,6 +38,7 @@ class UploadService {
|
|
|
38
38
|
objectId: request.objectId,
|
|
39
39
|
uploadType: UploadType.MEDIA,
|
|
40
40
|
dataRaw: request.dataRaw,
|
|
41
|
+
metadata: request.contentType ? { contentType: request.contentType } : undefined,
|
|
41
42
|
authorization: request.authorization,
|
|
42
43
|
});
|
|
43
44
|
this._persistence.deleteFile(upload.path, true);
|
package/lib/ensureApiEnabled.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.check = check;
|
|
|
5
5
|
exports.ensure = ensure;
|
|
6
6
|
exports.bestEffortEnsure = bestEffortEnsure;
|
|
7
7
|
exports.enableApiURI = enableApiURI;
|
|
8
|
+
exports.uncacheEnabledAPI = uncacheEnabledAPI;
|
|
8
9
|
const colorette_1 = require("colorette");
|
|
9
10
|
const track_1 = require("./track");
|
|
10
11
|
const api_1 = require("./api");
|
|
@@ -140,3 +141,10 @@ function cacheEnabledAPI(projectId, apiName) {
|
|
|
140
141
|
cache[projectId][apiName] = true;
|
|
141
142
|
configstore_1.configstore.set(API_ENABLEMENT_CACHE_KEY, cache);
|
|
142
143
|
}
|
|
144
|
+
function uncacheEnabledAPI(projectId, apiName) {
|
|
145
|
+
const cache = (configstore_1.configstore.get(API_ENABLEMENT_CACHE_KEY) || {});
|
|
146
|
+
if (cache[projectId]) {
|
|
147
|
+
delete cache[projectId][apiName];
|
|
148
|
+
configstore_1.configstore.set(API_ENABLEMENT_CACHE_KEY, cache);
|
|
149
|
+
}
|
|
150
|
+
}
|
package/lib/experiments.js
CHANGED
|
@@ -78,6 +78,12 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
78
78
|
public: true,
|
|
79
79
|
default: false,
|
|
80
80
|
},
|
|
81
|
+
kits: {
|
|
82
|
+
shortDescription: "Enable Functions Kits.",
|
|
83
|
+
fullDescription: "Adds support for Function Kits.",
|
|
84
|
+
public: false,
|
|
85
|
+
default: false,
|
|
86
|
+
},
|
|
81
87
|
emulatoruisnapshot: {
|
|
82
88
|
shortDescription: "Load pre-release versions of the emulator UI",
|
|
83
89
|
},
|
|
@@ -115,6 +121,12 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
115
121
|
"These commands are not meant for public consumption and may break or disappear " +
|
|
116
122
|
"without a notice.",
|
|
117
123
|
},
|
|
124
|
+
ailogic: {
|
|
125
|
+
shortDescription: "Manage Firebase AI Logic from the CLI.",
|
|
126
|
+
fullDescription: "Enables the `firebase ailogic` command surface for managing Firebase AI Logic, " +
|
|
127
|
+
"starting with the Gemini API providers. These commands are in preview and may " +
|
|
128
|
+
"change until the underlying API is finalized.",
|
|
129
|
+
},
|
|
118
130
|
apphosting: {
|
|
119
131
|
shortDescription: "Allow CLI option for Frameworks",
|
|
120
132
|
default: true,
|
|
@@ -186,6 +198,16 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
186
198
|
default: false,
|
|
187
199
|
public: true,
|
|
188
200
|
},
|
|
201
|
+
secretEnvParams: {
|
|
202
|
+
shortDescription: "Enable writing the backing resource binding for a Functions secret param to .env",
|
|
203
|
+
default: false,
|
|
204
|
+
public: false,
|
|
205
|
+
},
|
|
206
|
+
extdeprecationwarnings: {
|
|
207
|
+
shortDescription: "Show deprecation warnings for Firebase Extensions CLI commands.",
|
|
208
|
+
default: true,
|
|
209
|
+
public: true,
|
|
210
|
+
},
|
|
189
211
|
});
|
|
190
212
|
function isValidExperiment(name) {
|
|
191
213
|
return Object.keys(exports.ALL_EXPERIMENTS).includes(name);
|