firebase-tools-with-isolate 15.32.0 → 15.34.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/accountImporter.js +6 -3
- package/lib/api.js +3 -3
- package/lib/apphosting/backend.js +1 -1
- package/lib/apphosting/secrets/index.js +7 -2
- package/lib/checkValidTargetFilters.js +1 -0
- package/lib/command.js +31 -24
- package/lib/commands/apps-create.js +34 -3
- package/lib/commands/crashlytics-heapdumps-disable.js +26 -0
- package/lib/commands/crashlytics-heapdumps-enable.js +54 -0
- package/lib/commands/crashlytics-heapdumps-status.js +32 -0
- package/lib/commands/deploy.js +3 -0
- package/lib/commands/functions-kits-uninstall.js +43 -21
- package/lib/commands/functions-lifecycle-list.js +5 -6
- package/lib/commands/hosting-channel-deploy.js +3 -3
- package/lib/commands/hosting-clone.js +102 -31
- package/lib/commands/hosting-disable.js +5 -1
- package/lib/commands/index.js +9 -0
- package/lib/commands/init.js +7 -0
- package/lib/commands/run-services-update.js +16 -0
- package/lib/config.js +1 -0
- package/lib/crashlytics/alerts.js +122 -0
- package/lib/crashlytics/onboarding.js +71 -3
- package/lib/crashlytics/profilingManager.js +195 -0
- package/lib/crashlytics/sourcemap.js +46 -11
- package/lib/crashlytics/types.js +6 -1
- package/lib/deploy/apphosting/prepare.js +1 -0
- package/lib/deploy/auth/deploy.js +1 -1
- package/lib/deploy/auth/prepare.js +6 -7
- package/lib/deploy/firestore/prepare.js +5 -5
- package/lib/deploy/functions/build.js +3 -0
- package/lib/deploy/functions/cel.js +89 -58
- package/lib/deploy/functions/functionsDeployHelper.js +10 -0
- package/lib/deploy/functions/params.js +4 -2
- package/lib/deploy/functions/prepare.js +25 -8
- package/lib/deploy/functions/release/executor.js +7 -3
- package/lib/deploy/functions/release/fabricator.js +42 -14
- package/lib/deploy/functions/release/planner.js +3 -2
- package/lib/deploy/functions/release/sourceTokenScraper.js +1 -1
- package/lib/deploy/functions/validate.js +16 -0
- package/lib/deploy/hosting/prepare.js +1 -1
- package/lib/deploy/hosting/release.js +2 -2
- package/lib/deploy/index.js +5 -0
- package/lib/deploy/run/args.js +2 -0
- package/lib/deploy/run/buildEnv.js +72 -0
- package/lib/deploy/run/deploy.js +214 -0
- package/lib/deploy/run/index.js +23 -0
- package/lib/deploy/run/prepare.js +47 -0
- package/lib/deploy/run/prereqs.js +32 -0
- package/lib/deploy/run/release.js +9 -0
- package/lib/deploy/run/update.js +50 -0
- package/lib/deploy/run/util.js +73 -0
- package/lib/emulator/apphosting/serve.js +1 -1
- package/lib/emulator/auth/operations.js +8 -4
- package/lib/emulator/auth/utils.js +1 -1
- package/lib/emulator/commandUtils.js +7 -3
- package/lib/emulator/databaseEmulator.js +7 -3
- package/lib/emulator/dataconnect/pgliteServer.js +1 -1
- package/lib/emulator/dataconnectEmulator.js +1 -1
- package/lib/emulator/download.js +1 -1
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/downloadableEmulators.js +1 -3
- package/lib/emulator/emulatorLogger.js +2 -1
- package/lib/emulator/eventarcEmulator.js +1 -1
- package/lib/emulator/functionsEmulatorRuntime.js +2 -1
- package/lib/emulator/functionsEmulatorShared.js +1 -41
- package/lib/experiments.js +17 -11
- package/lib/extensions/warnings.js +48 -7
- package/lib/firestore/validator.js +1 -1
- package/lib/frameworks/next/constants.js +20 -12
- package/lib/frameworks/next/index.js +4 -23
- package/lib/frameworks/next/utils.js +28 -0
- package/lib/functions/env.js +4 -2
- package/lib/functions/projectConfig.js +10 -5
- package/lib/gcp/artifactregistry.js +20 -0
- package/lib/gcp/cloudmonitoring.js +80 -3
- package/lib/gcp/cloudsql/permissions.js +21 -32
- package/lib/gcp/cloudsql/permissionsSetup.js +6 -6
- package/lib/gcp/cloudtasks.js +15 -1
- package/lib/gcp/cloudtrace.js +38 -0
- package/lib/gcp/run.js +5 -0
- package/lib/gcp/runv2.js +32 -11
- package/lib/gcp/storage.js +9 -5
- package/lib/hosting/api.js +15 -15
- package/lib/hosting/runTags.js +1 -1
- package/lib/init/features/auth.js +46 -8
- package/lib/init/features/hosting/index.js +4 -2
- package/lib/init/features/index.js +4 -1
- package/lib/init/features/run.js +159 -0
- package/lib/init/index.js +6 -0
- package/lib/management/apps.js +4 -2
- package/lib/mcp/tools/firestore/converter.js +2 -2
- package/lib/mcp/util.js +11 -10
- package/lib/profileReport.js +12 -9
- package/lib/scopes.js +1 -3
- package/lib/streamJson.js +1 -0
- package/lib/throttler/throttler.js +1 -0
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +0 -15
- package/package.json +11 -17
- package/schema/firebase-config.json +41 -0
- package/schema/firebaserc.json +133 -0
- package/lib/mcp/resources/guides/init_data_connect.js +0 -30
- package/lib/mcp/resources/guides/init_rtdb.js +0 -30
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detailedHelp = exports.help = exports.release = exports.deploy = exports.prepare = void 0;
|
|
4
|
+
const prepare_1 = require("./prepare");
|
|
5
|
+
Object.defineProperty(exports, "prepare", { enumerable: true, get: function () { return prepare_1.prepare; } });
|
|
6
|
+
const deploy_1 = require("./deploy");
|
|
7
|
+
Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return deploy_1.deploy; } });
|
|
8
|
+
const release_1 = require("./release");
|
|
9
|
+
Object.defineProperty(exports, "release", { enumerable: true, get: function () { return release_1.release; } });
|
|
10
|
+
exports.help = "Builds and deploys web apps to Cloud Run services listed in firebase.json. Supports filtering:\n" +
|
|
11
|
+
" --only run:serviceId (in every region firebase.json lists it in)\n" +
|
|
12
|
+
" --only run:serviceId:region (in one region)";
|
|
13
|
+
exports.detailedHelp = "Deploys Cloud Run services from local source, or from a local build if localBuild is set.\n\n" +
|
|
14
|
+
"Configuration in firebase.json:\n" +
|
|
15
|
+
"{\n" +
|
|
16
|
+
' "run": {\n' +
|
|
17
|
+
' "serviceId": "my-service",\n' +
|
|
18
|
+
' "region": "us-central1",\n' +
|
|
19
|
+
' "rootDir": "/",\n' +
|
|
20
|
+
' "ignore": ["node_modules", ".git"]\n' +
|
|
21
|
+
" }\n" +
|
|
22
|
+
"}\n\n" +
|
|
23
|
+
"Base images are configured on the service with firebase run:services:update --base-image and are reused on every deploy.";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepare = prepare;
|
|
4
|
+
const error_1 = require("../../error");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const buildEnv_1 = require("./buildEnv");
|
|
7
|
+
const prereqs_1 = require("./prereqs");
|
|
8
|
+
const util_1 = require("./util");
|
|
9
|
+
async function prepare(context, options, payload) {
|
|
10
|
+
const configs = (0, util_1.getServiceConfigs)(options);
|
|
11
|
+
if (!configs.length) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
await (0, prereqs_1.prereqs)(context.projectId);
|
|
15
|
+
payload.run = { services: [] };
|
|
16
|
+
for (const config of configs) {
|
|
17
|
+
payload.run.services.push(await prepareService(context, config));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function prepareService(context, config) {
|
|
21
|
+
const { serviceId, region } = config;
|
|
22
|
+
const existing = await (0, util_1.getExistingService)(context.projectId, region, serviceId);
|
|
23
|
+
let baseImage = (0, util_1.mainContainer)(existing?.template)?.baseImageUri;
|
|
24
|
+
if (context.baseImage !== undefined) {
|
|
25
|
+
baseImage = context.baseImage ?? undefined;
|
|
26
|
+
}
|
|
27
|
+
if (config.localBuild && !baseImage) {
|
|
28
|
+
const fix = existing
|
|
29
|
+
? `firebase run:services:update ${serviceId} --region ${region} --base-image <baseImage>`
|
|
30
|
+
: "firebase init run";
|
|
31
|
+
throw new error_1.FirebaseError(`Local builds require a base image. Set one for service ${serviceId} in ${region} with "${fix}".`);
|
|
32
|
+
}
|
|
33
|
+
const buildEnv = (0, buildEnv_1.getBuildEnv)(existing);
|
|
34
|
+
const secrets = (0, buildEnv_1.secretNames)(buildEnv);
|
|
35
|
+
if (secrets.length && !config.localBuild) {
|
|
36
|
+
throw new error_1.FirebaseError(`Service ${serviceId} in ${region} has build secrets (${secrets.join(", ")}), but only ` +
|
|
37
|
+
`local builds can use secrets: builds on Cloud Build only take plain values. To use ` +
|
|
38
|
+
`them, set "localBuild": true for this service in firebase.json.`);
|
|
39
|
+
}
|
|
40
|
+
const svc = { config, existing, baseImage };
|
|
41
|
+
if (Object.keys(buildEnv).length) {
|
|
42
|
+
(0, utils_1.logLabeledBullet)("run", `Using build environment variables for service ${serviceId} in ${region} from ` +
|
|
43
|
+
`${buildEnv_1.BUILD_ENV_ANNOTATION}: ${Object.keys(buildEnv).join(", ")}`);
|
|
44
|
+
svc.buildEnv = buildEnv;
|
|
45
|
+
}
|
|
46
|
+
return svc;
|
|
47
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RUN_PERMISSIONS = void 0;
|
|
4
|
+
exports.prereqs = prereqs;
|
|
5
|
+
const ensureApiEnabled_1 = require("../../ensureApiEnabled");
|
|
6
|
+
const artifactregistry = require("../../gcp/artifactregistry");
|
|
7
|
+
exports.RUN_PERMISSIONS = [
|
|
8
|
+
"run.services.get",
|
|
9
|
+
"run.services.create",
|
|
10
|
+
"run.services.update",
|
|
11
|
+
"run.services.setIamPolicy",
|
|
12
|
+
"run.operations.get",
|
|
13
|
+
"cloudbuild.builds.create",
|
|
14
|
+
"cloudbuild.builds.get",
|
|
15
|
+
"storage.buckets.get",
|
|
16
|
+
"storage.buckets.list",
|
|
17
|
+
"storage.buckets.create",
|
|
18
|
+
"storage.buckets.update",
|
|
19
|
+
"storage.objects.create",
|
|
20
|
+
"artifactregistry.repositories.get",
|
|
21
|
+
"artifactregistry.repositories.create",
|
|
22
|
+
"artifactregistry.repositories.downloadArtifacts",
|
|
23
|
+
"iam.serviceAccounts.actAs",
|
|
24
|
+
];
|
|
25
|
+
async function prereqs(projectId) {
|
|
26
|
+
await Promise.all([
|
|
27
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "run.googleapis.com", "run", true),
|
|
28
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "cloudbuild.googleapis.com", "cloudbuild", true),
|
|
29
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "storage.googleapis.com", "storage", true),
|
|
30
|
+
artifactregistry.ensureApiEnabled(projectId),
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.release = release;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
async function release(_context, _options, payload) {
|
|
6
|
+
for (const { config, deployed } of payload.run?.services || []) {
|
|
7
|
+
(0, utils_1.logLabeledSuccess)("run", `Deployed service ${config.serviceId} in ${config.region}${deployed?.uri ? ` to ${deployed.uri}` : ""}`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateService = updateService;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const __1 = require("..");
|
|
6
|
+
const error_1 = require("../../error");
|
|
7
|
+
const projectUtils_1 = require("../../projectUtils");
|
|
8
|
+
const util_1 = require("./util");
|
|
9
|
+
async function updateService(serviceId, region, options) {
|
|
10
|
+
const settings = {
|
|
11
|
+
baseImage: readFlagPair(options.baseImage, options.clearBaseImage, "base-image"),
|
|
12
|
+
};
|
|
13
|
+
if (Object.values(settings).every((value) => value === undefined)) {
|
|
14
|
+
throw new error_1.FirebaseError("Specify a setting to update: --base-image <baseImage> or --clear-base-image.");
|
|
15
|
+
}
|
|
16
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
17
|
+
const config = findServiceToUpdate(serviceId, region, options);
|
|
18
|
+
if (settings.baseImage === null && config.localBuild) {
|
|
19
|
+
throw new error_1.FirebaseError(`Cannot clear the base image of ${config.serviceId}: local builds need one.`);
|
|
20
|
+
}
|
|
21
|
+
if (!(await (0, util_1.getExistingService)(projectId, config.region, config.serviceId))) {
|
|
22
|
+
const howToCreate = config.localBuild
|
|
23
|
+
? clc.bold("firebase init run")
|
|
24
|
+
: `${clc.bold("firebase init run")} or ` +
|
|
25
|
+
clc.bold(`firebase deploy --only run:${(0, util_1.fullServiceName)(config)}`);
|
|
26
|
+
throw new error_1.FirebaseError(`Cloud Run service ${config.serviceId} doesn't exist in ${config.region} yet. ` +
|
|
27
|
+
`Create it with ${howToCreate}, then update it.`);
|
|
28
|
+
}
|
|
29
|
+
await (0, __1.deploy)(["run"], { ...options, only: `run:${(0, util_1.fullServiceName)(config)}` }, settings);
|
|
30
|
+
}
|
|
31
|
+
function readFlagPair(value, clear, flag) {
|
|
32
|
+
if (value && clear) {
|
|
33
|
+
throw new error_1.FirebaseError(`Use either --${flag} or --clear-${flag}, not both.`);
|
|
34
|
+
}
|
|
35
|
+
return clear ? null : value;
|
|
36
|
+
}
|
|
37
|
+
function findServiceToUpdate(serviceId, region, options) {
|
|
38
|
+
const matches = (0, util_1.getAllServiceConfigs)(options).filter((c) => c.serviceId === serviceId && (!region || c.region === region));
|
|
39
|
+
if (!matches.length) {
|
|
40
|
+
const service = region ? `${serviceId} in ${region}` : serviceId;
|
|
41
|
+
throw new error_1.FirebaseError(`Cloud Run service ${service} not detected in firebase.json.`);
|
|
42
|
+
}
|
|
43
|
+
if (matches.length > 1) {
|
|
44
|
+
const regions = matches.map((c) => c.region);
|
|
45
|
+
const example = `firebase run:services:update ${serviceId} --region ${regions[0]}`;
|
|
46
|
+
throw new error_1.FirebaseError(`firebase.json lists ${serviceId} in ${regions.length} regions: ${regions.join(", ")}. ` +
|
|
47
|
+
`Pick one with --region, e.g. ${example}`);
|
|
48
|
+
}
|
|
49
|
+
return matches[0];
|
|
50
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllServiceConfigs = getAllServiceConfigs;
|
|
4
|
+
exports.getServiceConfigs = getServiceConfigs;
|
|
5
|
+
exports.findServices = findServices;
|
|
6
|
+
exports.fullServiceName = fullServiceName;
|
|
7
|
+
exports.getExistingService = getExistingService;
|
|
8
|
+
exports.mainContainer = mainContainer;
|
|
9
|
+
const error_1 = require("../../error");
|
|
10
|
+
const runv2 = require("../../gcp/runv2");
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
function getAllServiceConfigs(options) {
|
|
13
|
+
const configs = [options.config?.src?.run ?? []].flat();
|
|
14
|
+
const names = new Set();
|
|
15
|
+
for (const config of configs) {
|
|
16
|
+
if (!config.region) {
|
|
17
|
+
throw new error_1.FirebaseError(`Cloud Run service ${config.serviceId} is missing a region in firebase.json.`);
|
|
18
|
+
}
|
|
19
|
+
const name = fullServiceName(config);
|
|
20
|
+
if (names.has(name)) {
|
|
21
|
+
throw new error_1.FirebaseError(`Cloud Run service ${name} is listed more than once in firebase.json.`);
|
|
22
|
+
}
|
|
23
|
+
names.add(name);
|
|
24
|
+
}
|
|
25
|
+
return configs;
|
|
26
|
+
}
|
|
27
|
+
function getServiceConfigs(options) {
|
|
28
|
+
const configs = getAllServiceConfigs(options);
|
|
29
|
+
const filters = options.only ? options.only.split(",") : ["run"];
|
|
30
|
+
if (filters.includes("run")) {
|
|
31
|
+
return configs;
|
|
32
|
+
}
|
|
33
|
+
const selected = filters
|
|
34
|
+
.filter((f) => f.startsWith("run:"))
|
|
35
|
+
.flatMap((filter) => {
|
|
36
|
+
const name = filter.slice("run:".length);
|
|
37
|
+
const matches = findServices(configs, name);
|
|
38
|
+
if (!matches.length) {
|
|
39
|
+
throw new error_1.FirebaseError(`Cloud Run service ${name} not detected in firebase.json.`);
|
|
40
|
+
}
|
|
41
|
+
if (matches.length > 1) {
|
|
42
|
+
(0, utils_1.logLabeledBullet)("run", `${filter} matches ${matches.length} services in firebase.json: ` +
|
|
43
|
+
`${matches.map(fullServiceName).join(", ")}. Deploying all of them. ` +
|
|
44
|
+
`To deploy just one, use --only ${filter}:<region>.`);
|
|
45
|
+
}
|
|
46
|
+
return matches;
|
|
47
|
+
});
|
|
48
|
+
return configs.filter((c) => selected.includes(c));
|
|
49
|
+
}
|
|
50
|
+
function findServices(configs, name) {
|
|
51
|
+
const [serviceId, region, ...rest] = name.split(":");
|
|
52
|
+
if (!serviceId || region === "" || rest.length) {
|
|
53
|
+
throw new error_1.FirebaseError(`Invalid Cloud Run service "${name}". Use <serviceId> or <serviceId>:<region>.`);
|
|
54
|
+
}
|
|
55
|
+
return configs.filter((c) => c.serviceId === serviceId && (!region || c.region === region));
|
|
56
|
+
}
|
|
57
|
+
function fullServiceName(config) {
|
|
58
|
+
return `${config.serviceId}:${config.region}`;
|
|
59
|
+
}
|
|
60
|
+
async function getExistingService(projectId, region, serviceId) {
|
|
61
|
+
try {
|
|
62
|
+
return await runv2.getService(projectId, region, serviceId);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
if ((0, error_1.getErrStatus)(err) === 404) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function mainContainer(template) {
|
|
72
|
+
return template?.containers?.[0];
|
|
73
|
+
}
|
|
@@ -107,7 +107,7 @@ async function tripFirebasePostinstall(rootDirectory, env) {
|
|
|
107
107
|
for (const dependency of dependenciesToSearch) {
|
|
108
108
|
if (dependency.name === "@firebase/util" &&
|
|
109
109
|
(0, semver_1.gte)(dependency.version, "1.11.0") &&
|
|
110
|
-
firebaseUtilPaths.
|
|
110
|
+
!firebaseUtilPaths.includes(dependency.path)) {
|
|
111
111
|
firebaseUtilPaths.push(dependency.path);
|
|
112
112
|
}
|
|
113
113
|
if (dependency.dependencies) {
|
|
@@ -660,7 +660,7 @@ function sendOobCode(state, reqBody, ctx) {
|
|
|
660
660
|
(0, errors_1.assert)(reqBody.email, "MISSING_EMAIL");
|
|
661
661
|
email = (0, utils_1.canonicalizeEmailAddress)(reqBody.email);
|
|
662
662
|
break;
|
|
663
|
-
case "PASSWORD_RESET":
|
|
663
|
+
case "PASSWORD_RESET": {
|
|
664
664
|
mode = "resetPassword";
|
|
665
665
|
(0, errors_1.assert)(reqBody.email, "MISSING_EMAIL");
|
|
666
666
|
email = (0, utils_1.canonicalizeEmailAddress)(reqBody.email);
|
|
@@ -673,6 +673,7 @@ function sendOobCode(state, reqBody, ctx) {
|
|
|
673
673
|
}
|
|
674
674
|
(0, errors_1.assert)(maybeUser, "EMAIL_NOT_FOUND");
|
|
675
675
|
break;
|
|
676
|
+
}
|
|
676
677
|
case "VERIFY_EMAIL":
|
|
677
678
|
mode = "verifyEmail";
|
|
678
679
|
if (reqBody.returnOobLink && !reqBody.idToken) {
|
|
@@ -798,7 +799,7 @@ function setAccountInfoImpl(state, reqBody, { privileged = false, emulatorUrl =
|
|
|
798
799
|
}
|
|
799
800
|
break;
|
|
800
801
|
}
|
|
801
|
-
case "VERIFY_AND_CHANGE_EMAIL":
|
|
802
|
+
case "VERIFY_AND_CHANGE_EMAIL": {
|
|
802
803
|
state.deleteOobCode(reqBody.oobCode);
|
|
803
804
|
const maybeUser = state.getUserByEmail(oob.email);
|
|
804
805
|
(0, errors_1.assert)(maybeUser, "INVALID_OOB_CODE");
|
|
@@ -811,6 +812,7 @@ function setAccountInfoImpl(state, reqBody, { privileged = false, emulatorUrl =
|
|
|
811
812
|
newEmail = oob.newEmail;
|
|
812
813
|
}
|
|
813
814
|
break;
|
|
815
|
+
}
|
|
814
816
|
case "RECOVER_EMAIL": {
|
|
815
817
|
state.deleteOobCode(reqBody.oobCode);
|
|
816
818
|
const maybeUser = state.getUserByInitialEmail(oob.email);
|
|
@@ -1954,12 +1956,13 @@ function fakeFetchUserInfoFromIdp(providerId, claims, samlResponse) {
|
|
|
1954
1956
|
});
|
|
1955
1957
|
break;
|
|
1956
1958
|
}
|
|
1957
|
-
case /^saml\./.exec(providerId)?.input:
|
|
1959
|
+
case /^saml\./.exec(providerId)?.input: {
|
|
1958
1960
|
const nameId = samlResponse?.assertion?.subject?.nameId;
|
|
1959
1961
|
response.email = nameId && (0, utils_1.isValidEmailAddress)(nameId) ? nameId : response.email;
|
|
1960
1962
|
response.emailVerified = true;
|
|
1961
1963
|
response.rawUserInfo = JSON.stringify(samlResponse?.assertion?.attributeStatements);
|
|
1962
1964
|
break;
|
|
1965
|
+
}
|
|
1963
1966
|
case /^oidc\./.exec(providerId)?.input:
|
|
1964
1967
|
default:
|
|
1965
1968
|
response.rawUserInfo = JSON.stringify(claims);
|
|
@@ -2256,11 +2259,12 @@ function processBlockingFunctionResponse(event, response) {
|
|
|
2256
2259
|
case "emailVerified":
|
|
2257
2260
|
updates[field] = !!userRecord[field];
|
|
2258
2261
|
break;
|
|
2259
|
-
case "customClaims":
|
|
2262
|
+
case "customClaims": {
|
|
2260
2263
|
const customClaims = JSON.stringify(userRecord.customClaims);
|
|
2261
2264
|
validateSerializedCustomClaims(customClaims);
|
|
2262
2265
|
updates.customAttributes = customClaims;
|
|
2263
2266
|
break;
|
|
2267
|
+
}
|
|
2264
2268
|
case "sessionClaims":
|
|
2265
2269
|
if (event !== state_1.BlockingFunctionEvents.BEFORE_SIGN_IN) {
|
|
2266
2270
|
break;
|
|
@@ -19,7 +19,7 @@ function isValidEmailAddress(email) {
|
|
|
19
19
|
return /^[^@]+@[^@]+$/.test(email);
|
|
20
20
|
}
|
|
21
21
|
function isValidPhoneNumber(phoneNumber) {
|
|
22
|
-
return
|
|
22
|
+
return phoneNumber.startsWith("+");
|
|
23
23
|
}
|
|
24
24
|
function canonicalizeEmailAddress(email) {
|
|
25
25
|
return email.toLowerCase();
|
|
@@ -214,7 +214,7 @@ function processKillSignal(signal, res, rej, options) {
|
|
|
214
214
|
}
|
|
215
215
|
catch (e) {
|
|
216
216
|
logger_1.logger.debug(e);
|
|
217
|
-
rej();
|
|
217
|
+
rej((0, error_2.getError)(e));
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
220
|
}
|
|
@@ -251,13 +251,17 @@ async function runScript(script, extraEnv) {
|
|
|
251
251
|
return new Promise((resolve, reject) => {
|
|
252
252
|
proc.on("error", (err) => {
|
|
253
253
|
utils.logWarning(`There was an error running the script: ${JSON.stringify(err)}`);
|
|
254
|
-
reject(
|
|
254
|
+
reject(new error_1.FirebaseError("There was an error running the script.", {
|
|
255
|
+
original: err instanceof Error ? err : undefined,
|
|
256
|
+
}));
|
|
255
257
|
});
|
|
256
258
|
const exitDelayMs = 500;
|
|
257
259
|
proc.once("exit", (code, signal) => {
|
|
258
260
|
if (signal) {
|
|
259
261
|
utils.logWarning(`Script exited with signal: ${signal}`);
|
|
260
|
-
setTimeout(
|
|
262
|
+
setTimeout(() => {
|
|
263
|
+
reject(new error_1.FirebaseError(`Script exited with signal: ${signal}`));
|
|
264
|
+
}, exitDelayMs);
|
|
261
265
|
return;
|
|
262
266
|
}
|
|
263
267
|
const exitCode = code || 0;
|
|
@@ -17,6 +17,7 @@ class DatabaseEmulator {
|
|
|
17
17
|
constructor(args) {
|
|
18
18
|
this.args = args;
|
|
19
19
|
this.importedNamespaces = [];
|
|
20
|
+
this.rulesWatchers = [];
|
|
20
21
|
this.logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.DATABASE);
|
|
21
22
|
}
|
|
22
23
|
async start() {
|
|
@@ -32,8 +33,9 @@ class DatabaseEmulator {
|
|
|
32
33
|
this.logger.logLabeled("WARN_ONCE", "database", "Could not determine your Realtime Database instance name, so rules hot reloading is disabled.");
|
|
33
34
|
continue;
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
this.
|
|
36
|
+
const watcher = chokidar.watch(c.rules, { persistent: true, ignoreInitial: true });
|
|
37
|
+
this.rulesWatchers.push(watcher);
|
|
38
|
+
watcher.on("change", async () => {
|
|
37
39
|
await new Promise((res) => setTimeout(res, 5));
|
|
38
40
|
this.logger.logLabeled("BULLET", "database", `Change detected, updating rules for ${c.instance}...`);
|
|
39
41
|
try {
|
|
@@ -67,7 +69,9 @@ class DatabaseEmulator {
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
|
-
stop() {
|
|
72
|
+
async stop() {
|
|
73
|
+
await Promise.allSettled(this.rulesWatchers.map((w) => w.close()));
|
|
74
|
+
this.rulesWatchers = [];
|
|
71
75
|
return downloadableEmulators.stop(types_1.Emulators.DATABASE);
|
|
72
76
|
}
|
|
73
77
|
getInfo() {
|
|
@@ -165,7 +165,7 @@ class PostgresServer {
|
|
|
165
165
|
return db;
|
|
166
166
|
}
|
|
167
167
|
catch (err) {
|
|
168
|
-
if (pg17Dir && (0, error_1.hasMessage)(err) &&
|
|
168
|
+
if (pg17Dir && (0, error_1.hasMessage)(err) && err.message.includes("Database already exists")) {
|
|
169
169
|
fs.rmSync(pg17Dir, { force: true, recursive: true });
|
|
170
170
|
const db = new pglite_1.PGlite({ ...baseArgs, dataDir: pg17Dir });
|
|
171
171
|
await db.waitReady;
|
|
@@ -105,7 +105,7 @@ class DataConnectEmulator {
|
|
|
105
105
|
const emuInfo = await this.emulatorClient.getInfo();
|
|
106
106
|
if (!emuInfo) {
|
|
107
107
|
this.logger.logLabeled("ERROR", "dataconnect", "Could not connect to SQL Connect emulator. Check dataconnect-debug.log for more details.");
|
|
108
|
-
return Promise.reject();
|
|
108
|
+
return Promise.reject(new error_1.FirebaseError("Could not connect to SQL Connect emulator. Check dataconnect-debug.log for more details."));
|
|
109
109
|
}
|
|
110
110
|
return Promise.resolve();
|
|
111
111
|
}
|
package/lib/emulator/download.js
CHANGED
|
@@ -71,7 +71,7 @@ function removeOldFiles(name, emulator, removeAllVersions = false) {
|
|
|
71
71
|
const files = fs.readdirSync(emulator.opts.cacheDir);
|
|
72
72
|
for (const file of files) {
|
|
73
73
|
const fullFilePath = path.join(emulator.opts.cacheDir, file);
|
|
74
|
-
if (file.
|
|
74
|
+
if (!file.includes(emulator.opts.namePrefix)) {
|
|
75
75
|
continue;
|
|
76
76
|
}
|
|
77
77
|
if ((fullFilePath !== currentLocalPath && fullFilePath !== currentUnzipPath) ||
|
|
@@ -44,46 +44,46 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"pubsub": {
|
|
47
|
-
"version": "0.8.
|
|
48
|
-
"expectedSize":
|
|
49
|
-
"expectedChecksum": "
|
|
50
|
-
"expectedChecksumSHA256": "
|
|
51
|
-
"remoteUrl": "https://storage.googleapis.com/firebase-preview-drop/emulator/pubsub-emulator-0.8.
|
|
52
|
-
"downloadPathRelativeToCacheDir": "pubsub-emulator-0.8.
|
|
53
|
-
"binaryPathRelativeToCacheDir": "pubsub-emulator-0.8.
|
|
47
|
+
"version": "0.8.37",
|
|
48
|
+
"expectedSize": 53029797,
|
|
49
|
+
"expectedChecksum": "62cc150027ebea586c2c53c48c2cbb25",
|
|
50
|
+
"expectedChecksumSHA256": "c83383e0c71633e58abad6fdc9c0312c7d0f6a5a34236c42e3f92eb24ded1c26",
|
|
51
|
+
"remoteUrl": "https://storage.googleapis.com/firebase-preview-drop/emulator/pubsub-emulator-0.8.37.zip",
|
|
52
|
+
"downloadPathRelativeToCacheDir": "pubsub-emulator-0.8.37.zip",
|
|
53
|
+
"binaryPathRelativeToCacheDir": "pubsub-emulator-0.8.37/pubsub-emulator/bin/cloud-pubsub-emulator"
|
|
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.23",
|
|
58
|
+
"expectedSize": 33978064,
|
|
59
|
+
"expectedChecksum": "98d206c1a991b9a92609659d0533c9fd",
|
|
60
|
+
"expectedChecksumSHA256": "b88f852a34fbaad55c565d09aa758b7614ffba2da73a15218df5f078d8673d61",
|
|
61
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-amd64-v3.4.23",
|
|
62
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.23"
|
|
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.23",
|
|
66
|
+
"expectedSize": 31927234,
|
|
67
|
+
"expectedChecksum": "c232606e8a5d8fbe2be2f090afea32ad",
|
|
68
|
+
"expectedChecksumSHA256": "a58ded5bcaf5a6cfb3156add51c08c3a126a3f921b10c7426c9e9fb31aa2d0e5",
|
|
69
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-arm64-v3.4.23",
|
|
70
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.23"
|
|
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.23",
|
|
74
|
+
"expectedSize": 33988608,
|
|
75
|
+
"expectedChecksum": "962fbd2e1ba814f68df68971c44554d8",
|
|
76
|
+
"expectedChecksumSHA256": "ecccb3bb3df107b5792975e7cdf281476630042483b5fe3c334606fcc3770156",
|
|
77
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-amd64-v3.4.23",
|
|
78
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.23.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.23",
|
|
82
|
+
"expectedSize": 33058978,
|
|
83
|
+
"expectedChecksum": "b1e424fbcf1e6a17bb9220e15fd8fee2",
|
|
84
|
+
"expectedChecksumSHA256": "337ec8a195d6198e83bdeb070b12a64cecbf7aa1ba2c190b6611f78cd128a21a",
|
|
85
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-amd64-v3.4.23",
|
|
86
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-3.4.23"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -459,9 +459,7 @@ async function start(targetName, args, extraEnv = {}) {
|
|
|
459
459
|
return _runBinary(emulator, command, extraEnv);
|
|
460
460
|
}
|
|
461
461
|
function isIncomaptibleArchError(err) {
|
|
462
|
-
return ((0, error_1.hasMessage)(err) &&
|
|
463
|
-
/Unknown system error/.test(err.message ?? "") &&
|
|
464
|
-
process.platform === "darwin");
|
|
462
|
+
return ((0, error_1.hasMessage)(err) && err.message.includes("Unknown system error") && process.platform === "darwin");
|
|
465
463
|
}
|
|
466
464
|
function emulatorVersionOverride(emulator) {
|
|
467
465
|
return process.env[`${emulator.toUpperCase()}_EMULATOR_VERSION`];
|
|
@@ -181,7 +181,7 @@ You can probably fix this by running "npm install ${systemLog.data.name}@latest"
|
|
|
181
181
|
case "missing-package-json":
|
|
182
182
|
this.log("WARN", `The Cloud Functions directory you specified does not have a "package.json" file, so we can't load it.`);
|
|
183
183
|
break;
|
|
184
|
-
case "function-code-resolution-failed":
|
|
184
|
+
case "function-code-resolution-failed": {
|
|
185
185
|
this.log("WARN", systemLog.data.error);
|
|
186
186
|
const helper = ["We were unable to load your functions code. (see above)"];
|
|
187
187
|
if (systemLog.data.isPotentially.wrong_directory) {
|
|
@@ -195,6 +195,7 @@ You can probably fix this by running "npm install ${systemLog.data.name}@latest"
|
|
|
195
195
|
}
|
|
196
196
|
utils.logWarning(helper.join("\n"), "warn", this.data);
|
|
197
197
|
break;
|
|
198
|
+
}
|
|
198
199
|
case "function-runtimeconfig-json-invalid":
|
|
199
200
|
this.log("WARN", "Found .runtimeconfig.json but the JSON format is invalid.");
|
|
200
201
|
break;
|
|
@@ -125,7 +125,7 @@ class EventarcEmulator {
|
|
|
125
125
|
async triggerEventFunction(channel, event) {
|
|
126
126
|
if (!registry_1.EmulatorRegistry.isRunning(types_1.Emulators.FUNCTIONS)) {
|
|
127
127
|
this.logger.log("INFO", "Functions emulator not found. This should not happen.");
|
|
128
|
-
return Promise.reject();
|
|
128
|
+
return Promise.reject(new error_1.FirebaseError("Functions emulator not found. This should not happen."));
|
|
129
129
|
}
|
|
130
130
|
const key = `${event.type}-${channel}`;
|
|
131
131
|
const triggers = this.events[key] || [];
|
|
@@ -575,7 +575,7 @@ async function main() {
|
|
|
575
575
|
}
|
|
576
576
|
switch (FUNCTION_SIGNATURE) {
|
|
577
577
|
case "event":
|
|
578
|
-
case "cloudevent":
|
|
578
|
+
case "cloudevent": {
|
|
579
579
|
let reqBody;
|
|
580
580
|
const rawBody = req.rawBody;
|
|
581
581
|
if (types_2.EventUtils.isBinaryCloudEvent(req)) {
|
|
@@ -588,6 +588,7 @@ async function main() {
|
|
|
588
588
|
await processBackground(trigger, reqBody, FUNCTION_SIGNATURE);
|
|
589
589
|
res.send({ status: "acknowledged" });
|
|
590
590
|
break;
|
|
591
|
+
}
|
|
591
592
|
case "http":
|
|
592
593
|
await runHTTPS(trigger, [req, res]);
|
|
593
594
|
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.EVENTARC_SOURCE_ENV = void 0;
|
|
4
4
|
exports.getEventTenantId = getEventTenantId;
|
|
5
5
|
exports.eventServiceImplemented = eventServiceImplemented;
|
|
6
6
|
exports.prepareEndpoints = prepareEndpoints;
|
|
7
7
|
exports.emulatedFunctionsFromEndpoints = emulatedFunctionsFromEndpoints;
|
|
8
8
|
exports.emulatedFunctionsByRegion = emulatedFunctionsByRegion;
|
|
9
|
-
exports.getEmulatedTriggersFromDefinitions = getEmulatedTriggersFromDefinitions;
|
|
10
9
|
exports.getTemporarySocketPath = getTemporarySocketPath;
|
|
11
10
|
exports.getFunctionService = getFunctionService;
|
|
12
11
|
exports.getServiceFromEventType = getServiceFromEventType;
|
|
13
|
-
exports.waitForBody = waitForBody;
|
|
14
12
|
exports.findModuleRoot = findModuleRoot;
|
|
15
13
|
exports.formatHost = formatHost;
|
|
16
14
|
exports.getSignatureType = getSignatureType;
|
|
@@ -20,7 +18,6 @@ const os = require("os");
|
|
|
20
18
|
const path = require("path");
|
|
21
19
|
const fs = require("fs");
|
|
22
20
|
const crypto_1 = require("crypto");
|
|
23
|
-
const _ = require("lodash");
|
|
24
21
|
const backend = require("../deploy/functions/backend");
|
|
25
22
|
const build = require("../deploy/functions/build");
|
|
26
23
|
const constants_1 = require("./constants");
|
|
@@ -49,26 +46,6 @@ function getEventTenantId(eventPayload) {
|
|
|
49
46
|
return undefined;
|
|
50
47
|
}
|
|
51
48
|
exports.EVENTARC_SOURCE_ENV = "EVENTARC_CLOUD_EVENT_SOURCE";
|
|
52
|
-
class EmulatedTrigger {
|
|
53
|
-
constructor(definition, module) {
|
|
54
|
-
this.definition = definition;
|
|
55
|
-
this.module = module;
|
|
56
|
-
}
|
|
57
|
-
get memoryLimitBytes() {
|
|
58
|
-
return (this.definition.availableMemoryMb || 128) * 1024 * 1024;
|
|
59
|
-
}
|
|
60
|
-
get timeoutMs() {
|
|
61
|
-
return (this.definition.timeoutSeconds || 60) * 1000;
|
|
62
|
-
}
|
|
63
|
-
getRawFunction() {
|
|
64
|
-
if (!this.module) {
|
|
65
|
-
throw new Error("EmulatedTrigger has not been provided a module.");
|
|
66
|
-
}
|
|
67
|
-
const func = _.get(this.module, this.definition.entryPoint);
|
|
68
|
-
return func.__emulator_func || func;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.EmulatedTrigger = EmulatedTrigger;
|
|
72
49
|
function eventServiceImplemented(eventType) {
|
|
73
50
|
return V2_EVENTS.includes(eventType);
|
|
74
51
|
}
|
|
@@ -191,12 +168,6 @@ function emulatedFunctionsByRegion(definitions, secretEnvVariables = []) {
|
|
|
191
168
|
}
|
|
192
169
|
return regionDefinitions;
|
|
193
170
|
}
|
|
194
|
-
function getEmulatedTriggersFromDefinitions(definitions, module) {
|
|
195
|
-
return definitions.reduce((obj, definition) => {
|
|
196
|
-
obj[definition.id] = new EmulatedTrigger(definition, module);
|
|
197
|
-
return obj;
|
|
198
|
-
}, {});
|
|
199
|
-
}
|
|
200
171
|
function getTemporarySocketPath() {
|
|
201
172
|
const rand = (0, crypto_1.randomBytes)(8).toString("hex");
|
|
202
173
|
if (process.platform === "win32") {
|
|
@@ -257,17 +228,6 @@ function getServiceFromEventType(eventType) {
|
|
|
257
228
|
}
|
|
258
229
|
return "";
|
|
259
230
|
}
|
|
260
|
-
function waitForBody(req) {
|
|
261
|
-
let data = "";
|
|
262
|
-
return new Promise((resolve) => {
|
|
263
|
-
req.on("data", (chunk) => {
|
|
264
|
-
data += chunk;
|
|
265
|
-
});
|
|
266
|
-
req.on("end", () => {
|
|
267
|
-
resolve(data);
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
231
|
function findModuleRoot(moduleName, filepath) {
|
|
272
232
|
const hierarchy = filepath.split(path.sep);
|
|
273
233
|
for (let i = 0; i < hierarchy.length; i++) {
|