firebase-tools 15.25.0 → 15.26.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/ailogic/templates.js +124 -0
- package/lib/api.js +6 -2
- package/lib/appcheck/api.js +33 -0
- package/lib/appcheck/prompts.js +2 -2
- package/lib/appcheck/services.js +135 -0
- package/lib/auth.js +33 -15
- package/lib/checkValidTargetFilters.js +1 -0
- package/lib/command.js +4 -1
- package/lib/commands/ailogic-templates-delete.js +53 -0
- package/lib/commands/ailogic-templates-get.js +33 -0
- package/lib/commands/ailogic-templates-list.js +49 -0
- package/lib/commands/ailogic-templates-lock.js +30 -0
- package/lib/commands/ailogic-templates-unlock.js +30 -0
- package/lib/commands/appcheck-debugtokens-delete.js +1 -1
- package/lib/commands/appcheck-debugtokens-list.js +1 -1
- package/lib/commands/appcheck-services-get.js +40 -0
- package/lib/commands/appcheck-services-list.js +52 -0
- package/lib/commands/appcheck-services-set.js +90 -0
- package/lib/commands/crashlytics-onboard-web.js +56 -0
- package/lib/commands/deploy.js +3 -0
- package/lib/commands/firestore-locations.js +3 -1
- package/lib/commands/index.js +14 -0
- package/lib/commands/login.js +53 -6
- package/lib/config.js +1 -0
- package/lib/crashlytics/firebasetelemetry.js +36 -0
- package/lib/crashlytics/onboarding.js +41 -0
- package/lib/crashlytics/sourcemap.js +102 -12
- package/lib/deploy/ailogic/index.js +19 -0
- package/lib/deploy/ailogic/prepare.js +78 -0
- package/lib/deploy/ailogic/release.js +60 -0
- package/lib/deploy/functions/build.js +1 -1
- package/lib/deploy/functions/functionsDeployHelper.js +18 -12
- package/lib/deploy/functions/prepare.js +16 -3
- package/lib/deploy/functions/release/executor.js +51 -8
- package/lib/deploy/functions/release/fabricator.js +34 -5
- package/lib/deploy/index.js +9 -0
- package/lib/emulator/controller.js +34 -15
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/experiments.js +13 -0
- package/lib/extensions/checkProjectBilling.js +3 -73
- package/lib/functions/projectConfig.js +98 -12
- package/lib/gcp/ailogic.js +70 -1
- package/lib/gcp/cloudbilling.js +74 -0
- package/lib/gcp/cloudlogging.js +54 -0
- package/lib/management/apps.js +1 -2
- package/lib/prompt.js +10 -1
- package/lib/requirePermissions.js +1 -1
- package/lib/serve/functions.js +25 -7
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/schema/firebase-config.json +132 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const ailogic = require("../gcp/ailogic");
|
|
8
|
+
const clc = require("colorette");
|
|
9
|
+
const utils = require("../utils");
|
|
10
|
+
exports.command = new command_1.Command("ailogic:templates:unlock <templateId>")
|
|
11
|
+
.description("unlock a template")
|
|
12
|
+
.help(`unlocks one deployed server prompt template so it can be updated or deleted again.
|
|
13
|
+
|
|
14
|
+
<templateId> is the template's id, as shown in \`ailogic:templates:list\`.
|
|
15
|
+
|
|
16
|
+
For example:
|
|
17
|
+
|
|
18
|
+
\`firebase ailogic:templates:unlock my-template\``)
|
|
19
|
+
.before(requirePermissions_1.requirePermissions, [
|
|
20
|
+
"firebasevertexai.templates.update",
|
|
21
|
+
"serviceusage.services.get",
|
|
22
|
+
])
|
|
23
|
+
.action(async (templateId, options) => {
|
|
24
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
25
|
+
ailogic.assertValidTemplateId(templateId);
|
|
26
|
+
await ailogic.ensureAILogicApiEnabled(projectId, options);
|
|
27
|
+
await ailogic.withTemplate404(templateId, () => ailogic.setTemplateLocked(projectId, templateId, false));
|
|
28
|
+
utils.logSuccess(`Unlocked template: ${clc.bold(templateId)}`);
|
|
29
|
+
return { templateId, locked: false };
|
|
30
|
+
});
|
|
@@ -16,7 +16,7 @@ exports.command = new command_1.Command("appcheck:debugtokens:delete <debugToken
|
|
|
16
16
|
.option("--force", "attempt to delete debug token without prompting for confirmation")
|
|
17
17
|
.before(requireAuth_1.requireAuth)
|
|
18
18
|
.action(async (debugTokenId, options) => {
|
|
19
|
-
const { appId } = await (0, prompts_1.getOrPromptProjectAndAppId)(options);
|
|
19
|
+
const { appId } = await (0, prompts_1.getOrPromptProjectAndAppId)(options, "Select the app to delete a debug token from:");
|
|
20
20
|
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
21
21
|
let debugTokenName = debugTokenId;
|
|
22
22
|
if (!debugTokenName.startsWith("projects/")) {
|
|
@@ -27,7 +27,7 @@ exports.command = new command_1.Command("appcheck:debugtokens:list")
|
|
|
27
27
|
.option("--app <appId>", "the app id of your Firebase app")
|
|
28
28
|
.before(requireAuth_1.requireAuth)
|
|
29
29
|
.action(async (options) => {
|
|
30
|
-
const { appId } = await (0, prompts_1.getOrPromptProjectAndAppId)(options);
|
|
30
|
+
const { appId } = await (0, prompts_1.getOrPromptProjectAndAppId)(options, "Select the app to list debug tokens for:");
|
|
31
31
|
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
32
32
|
const debugTokens = await (0, utils_1.promiseWithSpinner)(async () => await (0, api_1.listDebugTokens)(projectNumber, appId), `Listing App Check debug tokens for app ${clc.bold(appId)}`);
|
|
33
33
|
logDebugTokensList(debugTokens);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const requireAuth_1 = require("../requireAuth");
|
|
8
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
9
|
+
const logger_1 = require("../logger");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const api_1 = require("../appcheck/api");
|
|
12
|
+
const services_1 = require("../appcheck/services");
|
|
13
|
+
exports.command = new command_1.Command("appcheck:services:get <service>")
|
|
14
|
+
.description("show App Check enforcement for one service")
|
|
15
|
+
.help(`shows the App Check enforcement settings for one service.
|
|
16
|
+
|
|
17
|
+
<service> is one of:
|
|
18
|
+
|
|
19
|
+
${(0, services_1.serviceAliasHelp)()}
|
|
20
|
+
|
|
21
|
+
App Check also protects some Google services that are not Firebase products, such as the Maps JavaScript API and Google Identity for iOS. Those have no short name; pass their App Check service id if you need them.
|
|
22
|
+
|
|
23
|
+
For example:
|
|
24
|
+
|
|
25
|
+
\`firebase appcheck:services:get firestore\``)
|
|
26
|
+
.before(requireAuth_1.requireAuth)
|
|
27
|
+
.before(requirePermissions_1.requirePermissions, ["firebaseappcheck.services.get"])
|
|
28
|
+
.action(async (service, options) => {
|
|
29
|
+
const serviceId = (0, services_1.resolveServiceId)(service);
|
|
30
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
31
|
+
const result = await (0, api_1.getService)(projectNumber, serviceId);
|
|
32
|
+
logger_1.logger.info(`Service: ${clc.bold((0, services_1.aliasForServiceId)(serviceId))} (${(0, services_1.displayNameForServiceId)(serviceId)})`);
|
|
33
|
+
logger_1.logger.info(`Enforcement: ${(0, services_1.formatEnforcementMode)(result.enforcementMode)}`);
|
|
34
|
+
logger_1.logger.info(`Replay protection: ${(0, services_1.formatEnforcementMode)(result.replayProtection)}`);
|
|
35
|
+
logger_1.logger.info(`Last updated: ${(0, services_1.formatUpdateTime)(result.updateTime)}`);
|
|
36
|
+
if ((0, services_1.isMandatoryFrom)(serviceId) && result.enforcementMode !== "ENFORCED") {
|
|
37
|
+
(0, utils_1.logWarning)(`Starting ${services_1.AI_LOGIC_ENFORCEMENT_DATE}, Firebase will automatically enforce App Check for all Gemini API requests via Firebase AI Logic, and App Check cannot be un-enforced for AI Logic. Implement App Check before this date to avoid service interruptions: ${services_1.AI_LOGIC_APP_CHECK_DOCS}`);
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const Table = require("cli-table3");
|
|
6
|
+
const command_1 = require("../command");
|
|
7
|
+
const projectUtils_1 = require("../projectUtils");
|
|
8
|
+
const requireAuth_1 = require("../requireAuth");
|
|
9
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
10
|
+
const logger_1 = require("../logger");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
const api_1 = require("../appcheck/api");
|
|
13
|
+
const services_1 = require("../appcheck/services");
|
|
14
|
+
exports.command = new command_1.Command("appcheck:services:list")
|
|
15
|
+
.description("list App Check enforcement for each service")
|
|
16
|
+
.help(`shows whether App Check is enforced for each service in the active project.
|
|
17
|
+
|
|
18
|
+
Enforcement can be:
|
|
19
|
+
|
|
20
|
+
Enforced requests without a valid App Check token are rejected
|
|
21
|
+
Unenforced requests are allowed, but counted in the App Check metrics
|
|
22
|
+
Off App Check is not applied
|
|
23
|
+
|
|
24
|
+
A service that was never configured also reads as off, with "never" in the Updated column.
|
|
25
|
+
|
|
26
|
+
Use \`appcheck:services:set <service> <mode>\` to change one.`)
|
|
27
|
+
.before(requireAuth_1.requireAuth)
|
|
28
|
+
.before(requirePermissions_1.requirePermissions, ["firebaseappcheck.services.get"])
|
|
29
|
+
.action(async (options) => {
|
|
30
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
31
|
+
const services = await (0, utils_1.promiseWithSpinner)(() => (0, api_1.listServices)(projectNumber), "Reading App Check services");
|
|
32
|
+
const rows = (0, services_1.buildServiceRows)(services);
|
|
33
|
+
const table = new Table({
|
|
34
|
+
head: ["Service", "Service API", "Enforcement", "Replay Protection", "Updated"],
|
|
35
|
+
style: { head: ["green"] },
|
|
36
|
+
});
|
|
37
|
+
for (const row of rows) {
|
|
38
|
+
table.push([
|
|
39
|
+
clc.bold(row.alias),
|
|
40
|
+
(0, services_1.displayNameForServiceId)(row.serviceId),
|
|
41
|
+
(0, services_1.formatEnforcementMode)(row.enforcementMode ?? undefined),
|
|
42
|
+
(0, services_1.formatEnforcementMode)(row.replayProtection ?? undefined),
|
|
43
|
+
(0, services_1.formatUpdateTime)(row.updateTime ?? undefined),
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
logger_1.logger.info(table.toString());
|
|
47
|
+
const aiLogic = rows.find((row) => (0, services_1.isMandatoryFrom)(row.serviceId));
|
|
48
|
+
if (aiLogic && aiLogic.enforcementMode !== "ENFORCED") {
|
|
49
|
+
(0, utils_1.logWarning)(`App Check is not enforced for ${aiLogic.alias}. Starting ${services_1.AI_LOGIC_ENFORCEMENT_DATE}, Firebase will automatically enforce App Check for all Gemini API requests via Firebase AI Logic. Requests without a valid App Check token will be rejected. Implement App Check before this date to avoid service interruptions: ${services_1.AI_LOGIC_APP_CHECK_DOCS}`);
|
|
50
|
+
}
|
|
51
|
+
return rows;
|
|
52
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const clc = require("colorette");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const requireAuth_1 = require("../requireAuth");
|
|
8
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
9
|
+
const prompt_1 = require("../prompt");
|
|
10
|
+
const error_1 = require("../error");
|
|
11
|
+
const logger_1 = require("../logger");
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
const api_1 = require("../appcheck/api");
|
|
14
|
+
const services_1 = require("../appcheck/services");
|
|
15
|
+
exports.command = new command_1.Command("appcheck:services:set <service> <mode>")
|
|
16
|
+
.description("set App Check enforcement for one service")
|
|
17
|
+
.help(`sets the App Check enforcement mode for one service.
|
|
18
|
+
|
|
19
|
+
<service> is one of:
|
|
20
|
+
|
|
21
|
+
${(0, services_1.serviceAliasHelp)()}
|
|
22
|
+
|
|
23
|
+
<mode> is one of:
|
|
24
|
+
|
|
25
|
+
off App Check is not applied
|
|
26
|
+
unenforced requests are allowed, but counted in the App Check metrics
|
|
27
|
+
enforced requests without a valid App Check token are rejected
|
|
28
|
+
|
|
29
|
+
For most services the usual rollout is unenforced first, then check the metrics in the console, then enforced.
|
|
30
|
+
|
|
31
|
+
Firebase AI Logic works differently. It is enforced by default and enforcement becomes mandatory, so there is no monitoring phase: keep it enforced, use a debug token while you develop (\`appcheck:debugtokens:create\`), and register a real attestation provider before you ship (\`appcheck:providers:set\`).
|
|
32
|
+
|
|
33
|
+
--replay-protection sets the replay protection level, which cannot be stronger than <mode>. Not every service supports it.
|
|
34
|
+
|
|
35
|
+
For example:
|
|
36
|
+
|
|
37
|
+
\`firebase appcheck:services:set firestore unenforced\`
|
|
38
|
+
\`firebase appcheck:services:set firestore enforced\``)
|
|
39
|
+
.option("--replay-protection <mode>", "replay protection level: off, unenforced, or enforced. Cannot be stronger than <mode>, and not every service supports it")
|
|
40
|
+
.option("-f, --force", "bypass confirmation prompt")
|
|
41
|
+
.before(requireAuth_1.requireAuth)
|
|
42
|
+
.before(requirePermissions_1.requirePermissions, ["firebaseappcheck.services.get", "firebaseappcheck.services.update"])
|
|
43
|
+
.action(async (service, mode, options) => {
|
|
44
|
+
const serviceId = (0, services_1.resolveServiceId)(service);
|
|
45
|
+
const alias = (0, services_1.aliasForServiceId)(serviceId);
|
|
46
|
+
const enforcementMode = (0, services_1.parseEnforcementMode)(mode);
|
|
47
|
+
const replayProtection = options.replayProtection
|
|
48
|
+
? (0, services_1.parseEnforcementMode)(options.replayProtection)
|
|
49
|
+
: undefined;
|
|
50
|
+
if (replayProtection) {
|
|
51
|
+
(0, services_1.assertReplayProtectionAllowed)(enforcementMode, replayProtection);
|
|
52
|
+
}
|
|
53
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
54
|
+
const current = await (0, api_1.getService)(projectNumber, serviceId);
|
|
55
|
+
const question = (0, services_1.confirmationForModeChange)(serviceId, alias, current.enforcementMode, enforcementMode);
|
|
56
|
+
if (question) {
|
|
57
|
+
const confirmed = await (0, prompt_1.confirm)({
|
|
58
|
+
message: question,
|
|
59
|
+
force: options.force,
|
|
60
|
+
nonInteractive: options.nonInteractive,
|
|
61
|
+
});
|
|
62
|
+
if (!confirmed) {
|
|
63
|
+
throw new error_1.FirebaseError("Command aborted.", { exit: 1 });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let result;
|
|
67
|
+
try {
|
|
68
|
+
result = await (0, api_1.updateService)(projectNumber, serviceId, {
|
|
69
|
+
enforcementMode,
|
|
70
|
+
replayProtection,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
if (replayProtection && (0, error_1.getErrStatus)(err) === 400) {
|
|
75
|
+
throw new error_1.FirebaseError(`The API rejected replay protection for ${clc.bold(alias)}. Not every service supports it.\n\nRun the command again without --replay-protection to set enforcement on its own.`, { original: err instanceof Error ? err : undefined });
|
|
76
|
+
}
|
|
77
|
+
throw err;
|
|
78
|
+
}
|
|
79
|
+
const replayText = replayProtection
|
|
80
|
+
? `, replay protection ${replayProtection.toLowerCase()}`
|
|
81
|
+
: "";
|
|
82
|
+
(0, utils_1.logSuccess)(`App Check for ${clc.bold(alias)} is now ${enforcementMode.toLowerCase()}${replayText}.`);
|
|
83
|
+
if (enforcementMode === "UNENFORCED") {
|
|
84
|
+
logger_1.logger.info(`Requests without a valid token are allowed and counted in the metrics.`);
|
|
85
|
+
}
|
|
86
|
+
if ((0, services_1.isMandatoryFrom)(serviceId) && enforcementMode !== "ENFORCED") {
|
|
87
|
+
(0, utils_1.logWarning)(`Starting ${services_1.AI_LOGIC_ENFORCEMENT_DATE}, Firebase will automatically enforce App Check for all Gemini API requests via Firebase AI Logic, and App Check cannot be un-enforced for AI Logic. Implement App Check before this date to avoid service interruptions: ${services_1.AI_LOGIC_APP_CHECK_DOCS}`);
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const error_1 = require("../error");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
7
|
+
const apps_1 = require("../management/apps");
|
|
8
|
+
const projectUtils_1 = require("../projectUtils");
|
|
9
|
+
const requireAuth_1 = require("../requireAuth");
|
|
10
|
+
const onboarding_1 = require("../crashlytics/onboarding");
|
|
11
|
+
exports.command = new command_1.Command("crashlytics:onboard:web [appId]")
|
|
12
|
+
.description("onboard a Firebase web app to Crashlytics")
|
|
13
|
+
.option("--app <appID>", "the app id of your Firebase app")
|
|
14
|
+
.before(requireAuth_1.requireAuth)
|
|
15
|
+
.action(async (appIdInput = "", options) => {
|
|
16
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
17
|
+
let appId = appIdInput ?? options.app ?? "";
|
|
18
|
+
let appPlatform = apps_1.AppPlatform.ANY;
|
|
19
|
+
if (!appId) {
|
|
20
|
+
const apps = await (0, apps_1.listFirebaseApps)(projectId, apps_1.AppPlatform.ANY);
|
|
21
|
+
(0, apps_1.checkForApps)(apps, apps_1.AppPlatform.ANY);
|
|
22
|
+
if (apps.length === 1) {
|
|
23
|
+
appId = apps[0].appId;
|
|
24
|
+
appPlatform = apps[0].platform;
|
|
25
|
+
}
|
|
26
|
+
else if (options.nonInteractive) {
|
|
27
|
+
throw new error_1.FirebaseError(`Project ${projectId} has multiple apps, must specify an app id.`);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const appMetadata = await (0, apps_1.selectAppInteractively)(apps, apps_1.AppPlatform.ANY);
|
|
31
|
+
appId = appMetadata.appId;
|
|
32
|
+
appPlatform = appMetadata.platform;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const apps = await (0, apps_1.listFirebaseApps)(projectId, apps_1.AppPlatform.ANY);
|
|
37
|
+
const matchedApp = apps.find((a) => a.appId === appId);
|
|
38
|
+
if (matchedApp) {
|
|
39
|
+
appPlatform = matchedApp.platform;
|
|
40
|
+
}
|
|
41
|
+
else if (appId.includes(":web:")) {
|
|
42
|
+
appPlatform = apps_1.AppPlatform.WEB;
|
|
43
|
+
}
|
|
44
|
+
else if (appId.includes(":android:")) {
|
|
45
|
+
appPlatform = apps_1.AppPlatform.ANDROID;
|
|
46
|
+
}
|
|
47
|
+
else if (appId.includes(":ios:")) {
|
|
48
|
+
appPlatform = apps_1.AppPlatform.IOS;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (appPlatform !== apps_1.AppPlatform.WEB && !appId.includes(":web:")) {
|
|
52
|
+
logger_1.logger.info(`Crashlytics onboarding via the CLI is currently only supported for Web apps. No onboarding steps needed for non-Web app: ${appId}`);
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
return await (0, onboarding_1.onboardCrashlyticsWeb)(projectId, appId, options);
|
|
56
|
+
});
|
package/lib/commands/deploy.js
CHANGED
|
@@ -64,6 +64,9 @@ exports.command
|
|
|
64
64
|
.before(requireConfig_1.requireConfig)
|
|
65
65
|
.before((options) => {
|
|
66
66
|
options.filteredTargets = (0, filterTargets_1.filterTargets)(options, [...deploy_1.VALID_DEPLOY_TARGETS]);
|
|
67
|
+
if (options.filteredTargets.includes("ailogic")) {
|
|
68
|
+
experiments.assertEnabled("ailogic", "deploy AI Logic resources");
|
|
69
|
+
}
|
|
67
70
|
const permissions = options.filteredTargets.reduce((perms, target) => {
|
|
68
71
|
return perms.concat(deploy_1.TARGET_PERMISSIONS[target]);
|
|
69
72
|
}, []);
|
|
@@ -7,14 +7,16 @@ const requirePermissions_1 = require("../requirePermissions");
|
|
|
7
7
|
const types_1 = require("../emulator/types");
|
|
8
8
|
const commandUtils_1 = require("../emulator/commandUtils");
|
|
9
9
|
const pretty_print_1 = require("../firestore/pretty-print");
|
|
10
|
+
const projectUtils_1 = require("../projectUtils");
|
|
10
11
|
exports.command = new command_1.Command("firestore:locations")
|
|
11
12
|
.description("list possible locations for your Cloud Firestore database")
|
|
12
13
|
.before(requirePermissions_1.requirePermissions, ["datastore.locations.list"])
|
|
13
14
|
.before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.FIRESTORE)
|
|
14
15
|
.action(async (options) => {
|
|
16
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
15
17
|
const api = new fsi.FirestoreApi();
|
|
16
18
|
const printer = new pretty_print_1.PrettyPrint();
|
|
17
|
-
const locations = await api.locations(
|
|
19
|
+
const locations = await api.locations(projectId);
|
|
18
20
|
printer.prettyPrintLocations(locations);
|
|
19
21
|
return locations;
|
|
20
22
|
});
|
package/lib/commands/index.js
CHANGED
|
@@ -24,6 +24,12 @@ function load(client) {
|
|
|
24
24
|
client.appcheck.debugtokens.create = loadCommand("appcheck-debugtokens-create");
|
|
25
25
|
client.appcheck.debugtokens.list = loadCommand("appcheck-debugtokens-list");
|
|
26
26
|
client.appcheck.debugtokens.delete = loadCommand("appcheck-debugtokens-delete");
|
|
27
|
+
if (experiments.isEnabled("appcheckadmin")) {
|
|
28
|
+
client.appcheck.services = {};
|
|
29
|
+
client.appcheck.services.list = loadCommand("appcheck-services-list");
|
|
30
|
+
client.appcheck.services.get = loadCommand("appcheck-services-get");
|
|
31
|
+
client.appcheck.services.set = loadCommand("appcheck-services-set");
|
|
32
|
+
}
|
|
27
33
|
client.appdistribution = {};
|
|
28
34
|
client.appdistribution.distribute = loadCommand("appdistribution-distribute");
|
|
29
35
|
client.appdistribution.testers = {};
|
|
@@ -57,6 +63,8 @@ function load(client) {
|
|
|
57
63
|
client.auth.export = loadCommand("auth-export");
|
|
58
64
|
client.auth.import = loadCommand("auth-import");
|
|
59
65
|
client.crashlytics = {};
|
|
66
|
+
client.crashlytics.onboard = {};
|
|
67
|
+
client.crashlytics.onboard.web = loadCommand("crashlytics-onboard-web");
|
|
60
68
|
client.crashlytics.symbols = {};
|
|
61
69
|
client.crashlytics.symbols.upload = loadCommand("crashlytics-symbols-upload");
|
|
62
70
|
client.crashlytics.mappingfile = {};
|
|
@@ -228,6 +236,12 @@ function load(client) {
|
|
|
228
236
|
client.ailogic.config = {};
|
|
229
237
|
client.ailogic.config.get = loadCommand("ailogic-config-get");
|
|
230
238
|
client.ailogic.config.set = loadCommand("ailogic-config-set");
|
|
239
|
+
client.ailogic.templates = {};
|
|
240
|
+
client.ailogic.templates.list = loadCommand("ailogic-templates-list");
|
|
241
|
+
client.ailogic.templates.get = loadCommand("ailogic-templates-get");
|
|
242
|
+
client.ailogic.templates.delete = loadCommand("ailogic-templates-delete");
|
|
243
|
+
client.ailogic.templates.lock = loadCommand("ailogic-templates-lock");
|
|
244
|
+
client.ailogic.templates.unlock = loadCommand("ailogic-templates-unlock");
|
|
231
245
|
}
|
|
232
246
|
client.login = loadCommand("login");
|
|
233
247
|
client.login.add = loadCommand("login-add");
|
package/lib/commands/login.js
CHANGED
|
@@ -10,15 +10,62 @@ const error_1 = require("../error");
|
|
|
10
10
|
const prompt_1 = require("../prompt");
|
|
11
11
|
const auth = require("../auth");
|
|
12
12
|
const utils_1 = require("../utils");
|
|
13
|
-
|
|
13
|
+
const TEMP_LOGIN_STATE_KEY = "tempLoginState";
|
|
14
|
+
exports.command = new command_1.Command("login [auth_code]")
|
|
14
15
|
.description("log the CLI into Firebase")
|
|
15
16
|
.option("--no-localhost", "login from a device without an accessible localhost")
|
|
16
17
|
.option("--reauth", "force reauthentication even if already logged in")
|
|
17
|
-
.action(async (options) => {
|
|
18
|
+
.action(async (authCode, options) => {
|
|
19
|
+
if (authCode) {
|
|
20
|
+
const state = configstore_1.configstore.get(TEMP_LOGIN_STATE_KEY);
|
|
21
|
+
if (!state || !state.codeVerifier) {
|
|
22
|
+
throw new error_1.FirebaseError("No pending login session found. Run " +
|
|
23
|
+
clc.bold("firebase login") +
|
|
24
|
+
" first to generate a login URL.", { exit: 1 });
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const result = await auth.loginRemotelyComplete(authCode, state.codeVerifier);
|
|
28
|
+
auth.recordCredentials(result);
|
|
29
|
+
configstore_1.configstore.delete(TEMP_LOGIN_STATE_KEY);
|
|
30
|
+
if (typeof result.user === "object" && result.user?.email) {
|
|
31
|
+
utils.logSuccess("Success! Logged in as " + clc.bold(result.user.email));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
utils.logSuccess("Success! Logged in");
|
|
35
|
+
}
|
|
36
|
+
return auth;
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
configstore_1.configstore.delete(TEMP_LOGIN_STATE_KEY);
|
|
40
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
41
|
+
throw new error_1.FirebaseError(`Login failed: ${message}`, { exit: 1 });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
18
44
|
if (options.nonInteractive && !options.prototyperLogin) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
45
|
+
try {
|
|
46
|
+
const { sessionId, sessionIdPrefix, loginUrl, codeVerifier } = await auth.loginRemotelyStart();
|
|
47
|
+
configstore_1.configstore.set(TEMP_LOGIN_STATE_KEY, { sessionId, codeVerifier });
|
|
48
|
+
logger_1.logger.info();
|
|
49
|
+
logger_1.logger.info("To sign in to the Firebase CLI:");
|
|
50
|
+
logger_1.logger.info();
|
|
51
|
+
logger_1.logger.info("1. Take note of your session ID:");
|
|
52
|
+
logger_1.logger.info();
|
|
53
|
+
logger_1.logger.info(` ${clc.bold(sessionIdPrefix)}`);
|
|
54
|
+
logger_1.logger.info();
|
|
55
|
+
logger_1.logger.info("2. Visit the URL below on any device and follow the instructions to get your code:");
|
|
56
|
+
logger_1.logger.info();
|
|
57
|
+
logger_1.logger.info(` ${loginUrl}`);
|
|
58
|
+
logger_1.logger.info();
|
|
59
|
+
logger_1.logger.info("3. Complete the login by running:");
|
|
60
|
+
logger_1.logger.info();
|
|
61
|
+
logger_1.logger.info(` ${clc.bold(`firebase login <authorizationCode>`)}`);
|
|
62
|
+
logger_1.logger.info();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
67
|
+
throw new error_1.FirebaseError(`Failed to start login: ${message}`, { exit: 1 });
|
|
68
|
+
}
|
|
22
69
|
}
|
|
23
70
|
const user = options.user;
|
|
24
71
|
const tokens = options.tokens;
|
|
@@ -51,7 +98,7 @@ exports.command = new command_1.Command("login")
|
|
|
51
98
|
const result = await auth.loginGoogle(useLocalhost, user?.email);
|
|
52
99
|
auth.recordCredentials(result);
|
|
53
100
|
logger_1.logger.info();
|
|
54
|
-
if (typeof result.user
|
|
101
|
+
if (typeof result.user === "object" && result.user?.email) {
|
|
55
102
|
utils.logSuccess("Success! Logged in as " + clc.bold(result.user.email));
|
|
56
103
|
}
|
|
57
104
|
else {
|
package/lib/config.js
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createOrUpdateTelemetryConfig = createOrUpdateTelemetryConfig;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const apiv2_1 = require("../apiv2");
|
|
6
|
+
const error_1 = require("../error");
|
|
7
|
+
const API_VERSION = "v1alpha";
|
|
8
|
+
async function createOrUpdateTelemetryConfig(projectId, appId, logBucket, samplingRate = 1) {
|
|
9
|
+
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseTelemetryAdminOrigin)(), apiVersion: API_VERSION });
|
|
10
|
+
const configId = appId.replace(/[:.]/g, "-");
|
|
11
|
+
const configName = `projects/${projectId}/locations/global/configs/${configId}`;
|
|
12
|
+
const configBody = {
|
|
13
|
+
name: configName,
|
|
14
|
+
appId,
|
|
15
|
+
logBucket,
|
|
16
|
+
samplingRate,
|
|
17
|
+
};
|
|
18
|
+
try {
|
|
19
|
+
const res = await client.post(`/projects/${projectId}/locations/global/configs?configId=${configId}`, configBody);
|
|
20
|
+
return res.body;
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
if (err.status === 409) {
|
|
24
|
+
try {
|
|
25
|
+
const patchRes = await client.patch(`/projects/${projectId}/locations/global/configs/${configId}?updateMask=logBucket,samplingRate`, configBody);
|
|
26
|
+
return patchRes.body;
|
|
27
|
+
}
|
|
28
|
+
catch (patchErr) {
|
|
29
|
+
const msg = patchErr.message || JSON.stringify(patchErr.body) || patchErr;
|
|
30
|
+
throw new error_1.FirebaseError(`Failed to patch telemetry config for web app ${appId} (status ${patchErr.status}): ${msg}`, { original: patchErr });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const msg = err.message || JSON.stringify(err.body) || err;
|
|
34
|
+
throw new error_1.FirebaseError(`Failed to configure telemetry for web app ${appId} (status ${err.status}): ${msg}`, { original: err });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CRASHLYTICS_TELEMETRY_RESOURCE_TYPE = exports.CRASHLYTICS_TELEMETRY_SINK_ID = exports.CRASHLYTICS_TELEMETRY_BUCKET_ID = void 0;
|
|
4
|
+
exports.onboardCrashlyticsWeb = onboardCrashlyticsWeb;
|
|
5
|
+
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
6
|
+
const error_1 = require("../error");
|
|
7
|
+
const cloudbilling_1 = require("../gcp/cloudbilling");
|
|
8
|
+
const cloudlogging_1 = require("../gcp/cloudlogging");
|
|
9
|
+
const firebasetelemetry_1 = require("./firebasetelemetry");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
exports.CRASHLYTICS_TELEMETRY_BUCKET_ID = "firebase-telemetry";
|
|
12
|
+
exports.CRASHLYTICS_TELEMETRY_SINK_ID = "firebase-telemetry-routing";
|
|
13
|
+
exports.CRASHLYTICS_TELEMETRY_RESOURCE_TYPE = "firebasetelemetry.googleapis.com/App";
|
|
14
|
+
async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
15
|
+
const billingEnabled = await (0, cloudbilling_1.checkBillingEnabled)(projectId);
|
|
16
|
+
if (!billingEnabled && options.nonInteractive) {
|
|
17
|
+
throw new error_1.FirebaseError(`Crashlytics requires the Blaze plan, but project ${projectId} is not on the Blaze plan. ` +
|
|
18
|
+
`Please visit https://console.cloud.google.com/billing/linkedaccount?project=${projectId} to upgrade your project.`);
|
|
19
|
+
}
|
|
20
|
+
else if (!billingEnabled) {
|
|
21
|
+
await (0, cloudbilling_1.enableBilling)(projectId, "Crashlytics");
|
|
22
|
+
}
|
|
23
|
+
(0, utils_1.logLabeledBullet)("crashlytics", "Enabling required telemetry APIs...");
|
|
24
|
+
await Promise.all([
|
|
25
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "firebasetelemetry.googleapis.com", "crashlytics", false),
|
|
26
|
+
(0, ensureApiEnabled_1.ensure)(projectId, "firebasetelemetryadmin.googleapis.com", "crashlytics", false),
|
|
27
|
+
]);
|
|
28
|
+
(0, utils_1.logLabeledSuccess)("crashlytics", "Telemetry APIs enabled.");
|
|
29
|
+
(0, utils_1.logLabeledBullet)("crashlytics", `Setting up Cloud Logging bucket '${exports.CRASHLYTICS_TELEMETRY_BUCKET_ID}'...`);
|
|
30
|
+
const bucket = await (0, cloudlogging_1.createOrUpdateLogBucket)(projectId, exports.CRASHLYTICS_TELEMETRY_BUCKET_ID, "global", true);
|
|
31
|
+
(0, utils_1.logLabeledSuccess)("crashlytics", "Cloud Logging bucket configured.");
|
|
32
|
+
const destination = `logging.googleapis.com/projects/${projectId}/locations/global/buckets/${exports.CRASHLYTICS_TELEMETRY_BUCKET_ID}`;
|
|
33
|
+
const filter = `resource.type="${exports.CRASHLYTICS_TELEMETRY_RESOURCE_TYPE}"`;
|
|
34
|
+
(0, utils_1.logLabeledBullet)("crashlytics", `Setting up Cloud Logging routing sink '${exports.CRASHLYTICS_TELEMETRY_SINK_ID}'...`);
|
|
35
|
+
const sink = await (0, cloudlogging_1.createOrUpdateLogSink)(projectId, exports.CRASHLYTICS_TELEMETRY_SINK_ID, destination, filter);
|
|
36
|
+
(0, utils_1.logLabeledSuccess)("crashlytics", "Cloud Logging routing sink configured.");
|
|
37
|
+
(0, utils_1.logLabeledBullet)("crashlytics", "Configuring Crashlytics telemetry for web app...");
|
|
38
|
+
const config = await (0, firebasetelemetry_1.createOrUpdateTelemetryConfig)(projectId, appId, `projects/${projectId}/locations/global/buckets/${exports.CRASHLYTICS_TELEMETRY_BUCKET_ID}`, 1);
|
|
39
|
+
(0, utils_1.logLabeledSuccess)("crashlytics", "Crashlytics telemetry configured successfully.");
|
|
40
|
+
return { bucket, sink, config };
|
|
41
|
+
}
|