firebase-tools 15.35.0 → 15.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/lib/appcheck/debugTokens.js +293 -0
  2. package/lib/appcheck/localConfig.js +191 -0
  3. package/lib/appdistribution/options-parser-util.js +1 -1
  4. package/lib/apphosting/githubConnections.js +1 -1
  5. package/lib/auth.js +8 -2
  6. package/lib/commands/appcheck-debugtokens-create.js +60 -35
  7. package/lib/commands/appcheck-debugtokens-delete.js +21 -7
  8. package/lib/commands/appcheck-debugtokens-list.js +37 -8
  9. package/lib/commands/appcheck-debugtokens-prune.js +59 -0
  10. package/lib/commands/crashlytics-heapdumps-status.js +1 -1
  11. package/lib/commands/deploy.js +1 -3
  12. package/lib/commands/hosting-channel-create.js +1 -3
  13. package/lib/commands/hosting-channel-delete.js +1 -3
  14. package/lib/commands/hosting-channel-deploy.js +1 -3
  15. package/lib/commands/hosting-channel-list.js +1 -3
  16. package/lib/commands/hosting-channel-open.js +1 -3
  17. package/lib/commands/hosting-clone.js +3 -5
  18. package/lib/commands/hosting-disable.js +2 -2
  19. package/lib/commands/hosting-sites-create.js +1 -3
  20. package/lib/commands/hosting-sites-delete.js +1 -3
  21. package/lib/commands/hosting-sites-get.js +1 -3
  22. package/lib/commands/hosting-sites-list.js +1 -3
  23. package/lib/commands/index.js +1 -0
  24. package/lib/crashlytics/events.js +122 -1
  25. package/lib/crashlytics/filters.js +12 -6
  26. package/lib/crashlytics/profilingManager.js +14 -34
  27. package/lib/crashlytics/utils.js +14 -0
  28. package/lib/database/import.js +5 -4
  29. package/lib/dataconnect/names.js +3 -3
  30. package/lib/dataconnect/schemaMigration.js +1 -1
  31. package/lib/deploy/functions/backend.js +0 -10
  32. package/lib/deploy/functions/cel.js +1 -1
  33. package/lib/deploy/functions/release/reporter.js +0 -26
  34. package/lib/deploy/functions/runtimes/discovery/index.js +4 -1
  35. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +1 -1
  36. package/lib/deploy/functions/services/index.js +13 -11
  37. package/lib/deploy/hosting/prepare.js +1 -3
  38. package/lib/deploy/lifecycleHooks.js +1 -1
  39. package/lib/emulator/auth/operations.js +2 -2
  40. package/lib/emulator/auth/server.js +4 -2
  41. package/lib/emulator/auth/widget_ui.js +1 -1
  42. package/lib/emulator/commandUtils.js +4 -1
  43. package/lib/emulator/databaseEmulator.js +16 -11
  44. package/lib/emulator/dataconnect/pgliteServer.js +30 -24
  45. package/lib/emulator/downloadableEmulatorInfo.json +24 -24
  46. package/lib/emulator/downloadableEmulators.js +2 -2
  47. package/lib/emulator/extensions/postinstall.js +6 -6
  48. package/lib/emulator/firestoreEmulator.js +21 -15
  49. package/lib/emulator/functionsEmulator.js +11 -7
  50. package/lib/emulator/functionsEmulatorRuntime.js +7 -2
  51. package/lib/emulator/hub.js +12 -8
  52. package/lib/emulator/shared/express.js +30 -0
  53. package/lib/emulator/storage/apis/firebase.js +11 -10
  54. package/lib/emulator/storage/apis/gcloud.js +21 -20
  55. package/lib/emulator/storage/files.js +1 -1
  56. package/lib/emulator/storage/rules/manager.js +15 -12
  57. package/lib/emulator/storage/server.js +10 -5
  58. package/lib/extensions/extensionsHelper.js +2 -2
  59. package/lib/extensions/paramHelper.js +1 -1
  60. package/lib/extensions/provisioningHelper.js +1 -6
  61. package/lib/firestore/util.js +3 -3
  62. package/lib/frameworks/angular/utils.js +1 -1
  63. package/lib/frameworks/next/utils.js +1 -1
  64. package/lib/functions/kits/install.js +221 -316
  65. package/lib/functions/kits/sources/directory.js +32 -0
  66. package/lib/functions/kits/sources/npm.js +55 -5
  67. package/lib/functionsConfig.js +0 -4
  68. package/lib/functionsShellCommandAction.js +1 -1
  69. package/lib/gcp/cloudfunctionsv2.js +0 -6
  70. package/lib/gcp/devConnect.js +2 -2
  71. package/lib/hosting/api.js +79 -0
  72. package/lib/hosting/proxy.js +4 -1
  73. package/lib/init/features/hosting/github.js +6 -4
  74. package/lib/init/features/hosting/index.js +4 -0
  75. package/lib/mcp/apps/init/mcp-app.js +4 -1
  76. package/lib/mcp/index.js +8 -2
  77. package/lib/mcp/prompts/apptesting/run_test.js +3 -3
  78. package/lib/mcp/prompts/core/deploy.js +3 -3
  79. package/lib/mcp/resources/guides/init_ai.js +10 -10
  80. package/lib/mcp/tools/crashlytics/events.js +18 -93
  81. package/lib/mcp/tools/crashlytics/index.js +2 -0
  82. package/lib/mcp/tools/crashlytics/reports.js +1 -1
  83. package/lib/mcp/tools/crashlytics/setup.js +392 -0
  84. package/lib/tsconfig.compile.tsbuildinfo +1 -1
  85. package/lib/tsconfig.publish.tsbuildinfo +1 -1
  86. package/lib/utils.js +4 -10
  87. package/package.json +1 -1
  88. package/lib/functions/kits/sources/index.js +0 -19
@@ -4,19 +4,29 @@ exports.command = void 0;
4
4
  const clc = require("colorette");
5
5
  const command_1 = require("../command");
6
6
  const projectUtils_1 = require("../projectUtils");
7
- const api_1 = require("../appcheck/api");
7
+ const debugTokens_1 = require("../appcheck/debugTokens");
8
+ const localConfig_1 = require("../appcheck/localConfig");
8
9
  const appcheck_prompts_1 = require("./appcheck-prompts");
9
10
  const requireAuth_1 = require("../requireAuth");
10
11
  const utils_1 = require("../utils");
11
12
  const prompt_1 = require("../prompt");
12
13
  const error_1 = require("../error");
14
+ const logger_1 = require("../logger");
13
15
  exports.command = new command_1.Command("appcheck:debugtokens:delete <debugTokenId>")
14
16
  .description("delete a Firebase App Check debug token for an app")
17
+ .help(`deletes a server-registered Firebase App Check debug token for an app (accepting either the short \`<debugTokenId>\` or the full \`projects/<projectNumber>/apps/<appId>/debugTokens/<debugTokenId>\` resource name) and removes the matching entry from ~/.config/configstore/firebase-appcheck.json if present.`)
15
18
  .option("--app <appId>", "the app id of your Firebase app")
16
- .option("--force", "attempt to delete debug token without prompting for confirmation")
17
- .before(requireAuth_1.requireAuth)
19
+ .withForce("attempt to delete debug token without prompting for confirmation")
20
+ .before((options) => (0, requireAuth_1.requireAuth)(options))
18
21
  .action(async (debugTokenId, options) => {
19
- const { appId } = await (0, appcheck_prompts_1.getOrPromptProjectAndAppId)(options, "Select the app to delete a debug token from:");
22
+ let inferredAppId;
23
+ if (debugTokenId.startsWith("projects/")) {
24
+ const match = /^projects\/[^/]+\/apps\/([^/]+)\/debugTokens\/[^/]+$/.exec(debugTokenId);
25
+ if (match) {
26
+ inferredAppId = match[1];
27
+ }
28
+ }
29
+ const { appId } = await (0, appcheck_prompts_1.getOrPromptProjectAndAppId)({ ...options, app: options.app || inferredAppId }, "Select the app to delete a debug token from:");
20
30
  const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
21
31
  let debugTokenName = debugTokenId;
22
32
  if (!debugTokenName.startsWith("projects/")) {
@@ -25,7 +35,8 @@ exports.command = new command_1.Command("appcheck:debugtokens:delete <debugToken
25
35
  else {
26
36
  const expectedPrefix = `projects/${projectNumber}/apps/${appId}/debugTokens/`;
27
37
  if (!debugTokenName.startsWith(expectedPrefix)) {
28
- throw new error_1.FirebaseError(`Debug token ${debugTokenId} does not belong to app ${appId} in project ${projectNumber}`, { exit: 1 });
38
+ throw new error_1.FirebaseError(`Debug token ${debugTokenId} does not belong to app ${appId} in project ${projectNumber}. ` +
39
+ `Pass --app <appId> for the matching app or run "firebase appcheck:debugtokens:list" to view valid debug tokens.`, { exit: 1 });
29
40
  }
30
41
  }
31
42
  if (!options.force) {
@@ -40,9 +51,12 @@ exports.command = new command_1.Command("appcheck:debugtokens:delete <debugToken
40
51
  default: false,
41
52
  });
42
53
  if (!consent) {
43
- throw new error_1.FirebaseError("Delete App Check debug token canceled.");
54
+ throw new error_1.FirebaseError("Delete App Check debug token canceled.", { exit: 1 });
44
55
  }
45
56
  }
46
- await (0, utils_1.promiseWithSpinner)(async () => await (0, api_1.deleteDebugToken)(debugTokenName), `Deleting App Check debug token ${clc.bold(debugTokenName)}`);
57
+ const removedLocal = await (0, utils_1.promiseWithSpinner)(() => (0, debugTokens_1.deleteDebugTokenAndCleanLocal)({ appId, debugTokenName }), `Deleting App Check debug token ${clc.bold(debugTokenName)}`);
47
58
  (0, utils_1.logSuccess)(`Successfully deleted App Check debug token ${clc.bold(debugTokenName)}`);
59
+ if (removedLocal) {
60
+ logger_1.logger.info(`Removed matching debug token from local config: ${clc.bold((0, localConfig_1.getLocalConfigPath)())}`);
61
+ }
48
62
  });
@@ -6,30 +6,59 @@ const Table = require("cli-table3");
6
6
  const command_1 = require("../command");
7
7
  const projectUtils_1 = require("../projectUtils");
8
8
  const api_1 = require("../appcheck/api");
9
+ const debugTokens_1 = require("../appcheck/debugTokens");
9
10
  const appcheck_prompts_1 = require("./appcheck-prompts");
10
11
  const requireAuth_1 = require("../requireAuth");
11
12
  const logger_1 = require("../logger");
12
13
  const utils_1 = require("../utils");
13
- function logDebugTokensList(debugTokens) {
14
+ function logServerDebugTokensList(debugTokens) {
14
15
  if (debugTokens.length === 0) {
15
16
  logger_1.logger.info(clc.bold("No App Check debug tokens found."));
16
17
  return;
17
18
  }
18
- const tableHead = ["Display Name", "Resource Name", "Update Time"];
19
- const table = new Table({ head: tableHead, style: { head: ["green"] } });
20
- debugTokens.forEach(({ displayName, name, updateTime }) => {
19
+ const table = new Table({
20
+ head: ["Display Name", "Resource Name", "Update Time"],
21
+ style: { head: ["green"] },
22
+ });
23
+ for (const { displayName, name, updateTime } of debugTokens) {
21
24
  table.push([displayName, name, updateTime || "N/A"]);
25
+ }
26
+ logger_1.logger.info(table.toString());
27
+ }
28
+ function logLocalDebugTokensList(entries) {
29
+ if (entries.length === 0) {
30
+ logger_1.logger.info(clc.bold("No local App Check debug tokens found."));
31
+ return;
32
+ }
33
+ const table = new Table({
34
+ head: ["App ID", "Token Prefix", "Server Status"],
35
+ style: { head: ["green"] },
22
36
  });
37
+ for (const entry of entries) {
38
+ table.push([entry.appId, entry.tokenPrefix, (0, debugTokens_1.formatLocalTokenStatus)(entry.status)]);
39
+ }
23
40
  logger_1.logger.info(table.toString());
24
41
  }
25
42
  exports.command = new command_1.Command("appcheck:debugtokens:list")
26
- .description("list all Firebase App Check debug tokens for an app")
43
+ .description("list Firebase App Check debug tokens for an app or stored locally on this machine")
44
+ .help(`lists server-registered Firebase App Check debug tokens for an app, or passes \`--local\` to inspect debug tokens saved in ~/.config/configstore/firebase-appcheck.json on this machine (optionally filtered by \`--app\`).`)
27
45
  .option("--app <appId>", "the app id of your Firebase app")
28
- .before(requireAuth_1.requireAuth)
46
+ .option("--local", "list debug tokens stored locally on this machine instead of querying all server tokens for an app")
47
+ .before((options) => {
48
+ if (options.local) {
49
+ return;
50
+ }
51
+ return (0, requireAuth_1.requireAuth)(options);
52
+ })
29
53
  .action(async (options) => {
54
+ if (options.local) {
55
+ const localEntries = await (0, debugTokens_1.inspectLocalDebugTokens)(options);
56
+ logLocalDebugTokensList(localEntries);
57
+ return localEntries;
58
+ }
30
59
  const { appId } = await (0, appcheck_prompts_1.getOrPromptProjectAndAppId)(options, "Select the app to list debug tokens for:");
31
60
  const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
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
- logDebugTokensList(debugTokens);
61
+ const debugTokens = await (0, utils_1.promiseWithSpinner)(() => (0, api_1.listDebugTokens)(projectNumber, appId), `Listing App Check debug tokens for app ${clc.bold(appId)}`);
62
+ logServerDebugTokensList(debugTokens);
34
63
  return debugTokens;
35
64
  });
@@ -0,0 +1,59 @@
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 debugTokens_1 = require("../appcheck/debugTokens");
7
+ const localConfig_1 = require("../appcheck/localConfig");
8
+ const error_1 = require("../error");
9
+ const logger_1 = require("../logger");
10
+ const projectUtils_1 = require("../projectUtils");
11
+ const prompt_1 = require("../prompt");
12
+ const requireAuth_1 = require("../requireAuth");
13
+ const utils_1 = require("../utils");
14
+ function logServerTokensUntouchedNote() {
15
+ logger_1.logger.info(`Server-registered debug tokens are untouched. Manage server tokens with ${clc.bold("firebase appcheck:debugtokens:list")} and ${clc.bold("firebase appcheck:debugtokens:delete")}.`);
16
+ }
17
+ exports.command = new command_1.Command("appcheck:debugtokens:prune")
18
+ .description("remove stale App Check debug tokens from the local machine config")
19
+ .help(`removes stale App Check debug token entries from ~/.config/configstore/firebase-appcheck.json (and $XDG_CONFIG_HOME/configstore/firebase-appcheck.json when $XDG_CONFIG_HOME is set) on this machine whose Firebase app has been deleted from the active project or whose debug token has been revoked on the server.
20
+
21
+ This command only modifies the local machine config (~/.config/configstore/firebase-appcheck.json and any $XDG_CONFIG_HOME mirror); server-registered debug tokens are untouched and can be managed via \`firebase appcheck:debugtokens:list\` and \`firebase appcheck:debugtokens:delete\`.`)
22
+ .withForce("remove stale local debug tokens without prompting")
23
+ .before((options) => (0, requireAuth_1.requireAuth)(options))
24
+ .action(async (options) => {
25
+ const projectId = (0, projectUtils_1.needProjectId)(options);
26
+ const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
27
+ if (Object.keys((0, localConfig_1.getAllLocalTokens)()).length === 0) {
28
+ logger_1.logger.info(clc.bold("No local App Check debug tokens found."));
29
+ logServerTokensUntouchedNote();
30
+ return { prunedAppIds: [] };
31
+ }
32
+ const staleEntries = await (0, utils_1.promiseWithSpinner)(() => (0, debugTokens_1.findStaleLocalDebugTokens)({ projectId, projectNumber }), `Checking local App Check debug tokens against project ${clc.bold(projectId)}`);
33
+ if (staleEntries.length === 0) {
34
+ logger_1.logger.info(clc.bold(`No stale local App Check debug tokens found for project ${projectId}.`));
35
+ logServerTokensUntouchedNote();
36
+ return { prunedAppIds: [] };
37
+ }
38
+ logger_1.logger.info(`Found ${staleEntries.length} stale local debug token(s) in ${clc.bold((0, localConfig_1.getLocalConfigPath)())}:`);
39
+ for (const entry of staleEntries) {
40
+ logger_1.logger.info(` - ${clc.bold(entry.appId)} (${entry.tokenPrefix}): ${(0, debugTokens_1.formatLocalTokenStatus)(entry.status)}`);
41
+ }
42
+ logServerTokensUntouchedNote();
43
+ if (!options.force) {
44
+ if (options.nonInteractive) {
45
+ throw new error_1.FirebaseError("Must pass --force to prune stale local debug tokens in non-interactive mode.", { exit: 1 });
46
+ }
47
+ const consent = await (0, prompt_1.confirm)({
48
+ message: `Remove ${staleEntries.length} stale local debug token(s) from ${(0, localConfig_1.getLocalConfigPath)()}?`,
49
+ default: false,
50
+ });
51
+ if (!consent) {
52
+ throw new error_1.FirebaseError("Prune local App Check debug tokens canceled.", { exit: 1 });
53
+ }
54
+ }
55
+ const prunedAppIds = staleEntries.map((entry) => entry.appId);
56
+ (0, localConfig_1.removeLocalTokens)(prunedAppIds);
57
+ (0, utils_1.logSuccess)(`Pruned ${prunedAppIds.length} stale local App Check debug token(s) from ${clc.bold((0, localConfig_1.getLocalConfigPath)())}: ${prunedAppIds.join(", ")}`);
58
+ return { prunedAppIds };
59
+ });
@@ -21,7 +21,7 @@ exports.command = new command_1.Command("crashlytics:heapdumps:status")
21
21
  table.push([
22
22
  appId,
23
23
  config.heapDumpCollectionEnabled ? clc.green("Enabled") : clc.red("Disabled"),
24
- config.gcsBucket || clc.yellow("(none)"),
24
+ config.bucket || clc.yellow("(none)"),
25
25
  ]);
26
26
  logger_1.logger.info("");
27
27
  logger_1.logger.info(table.toString());
@@ -16,8 +16,6 @@ const colorette_1 = require("colorette");
16
16
  const interactive_1 = require("../hosting/interactive");
17
17
  const utils_1 = require("../utils");
18
18
  const api_1 = require("../hosting/api");
19
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
20
- const api_2 = require("../api");
21
19
  const projectUtils_1 = require("../projectUtils");
22
20
  const experiments = require("../experiments");
23
21
  const clc = require("colorette");
@@ -88,7 +86,7 @@ exports.command
88
86
  await (0, requireDatabaseInstance_1.requireDatabaseInstance)(options);
89
87
  }
90
88
  if (options.filteredTargets.includes("hosting")) {
91
- await (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true);
89
+ await (0, api_1.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options));
92
90
  let shouldCreateSite = false;
93
91
  try {
94
92
  await (0, requireHostingSite_1.requireHostingSite)(options);
@@ -15,8 +15,6 @@ const requireConfig_1 = require("../requireConfig");
15
15
  const marked_1 = require("marked");
16
16
  const requireHostingSite_1 = require("../requireHostingSite");
17
17
  const getDefaultHostingSite_1 = require("../getDefaultHostingSite");
18
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
19
- const api_2 = require("../api");
20
18
  const LOG_TAG = "hosting:channel";
21
19
  exports.command = new command_1.Command("hosting:channel:create [channelId]")
22
20
  .description("create a Firebase Hosting channel")
@@ -24,7 +22,7 @@ exports.command = new command_1.Command("hosting:channel:create [channelId]")
24
22
  .option("--site <siteId>", "site for which to create the channel")
25
23
  .before(requireConfig_1.requireConfig)
26
24
  .before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
27
- .before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
25
+ .before((options) => (0, api_1.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options)))
28
26
  .before(async (options) => {
29
27
  try {
30
28
  await (0, requireHostingSite_1.requireHostingSite)(options);
@@ -12,15 +12,13 @@ const requirePermissions_1 = require("../requirePermissions");
12
12
  const projectUtils_1 = require("../projectUtils");
13
13
  const requireConfig_1 = require("../requireConfig");
14
14
  const logger_1 = require("../logger");
15
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
16
- const api_2 = require("../api");
17
15
  exports.command = new command_1.Command("hosting:channel:delete <channelId>")
18
16
  .description("delete a Firebase Hosting channel")
19
17
  .withForce()
20
18
  .option("--site <siteId>", "site in which the channel exists")
21
19
  .before(requireConfig_1.requireConfig)
22
20
  .before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
23
- .before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
21
+ .before((options) => (0, api_1.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options)))
24
22
  .before(requireHostingSite_1.requireHostingSite)
25
23
  .action(async (channelId, options) => {
26
24
  const projectId = (0, projectUtils_1.needProjectId)(options);
@@ -16,8 +16,6 @@ const utils_1 = require("../utils");
16
16
  const config_1 = require("../hosting/config");
17
17
  const marked_1 = require("marked");
18
18
  const requireHostingSite_1 = require("../requireHostingSite");
19
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
20
- const api_2 = require("../api");
21
19
  const LOG_TAG = "hosting:channel";
22
20
  exports.command = new command_1.Command("hosting:channel:deploy [channelId]")
23
21
  .description("deploy to a specific Firebase Hosting channel")
@@ -27,7 +25,7 @@ exports.command = new command_1.Command("hosting:channel:deploy [channelId]")
27
25
  .option("--no-authorized-domains", "do not sync channel domains with Firebase Auth")
28
26
  .before(requireConfig_1.requireConfig)
29
27
  .before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
30
- .before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
28
+ .before((options) => (0, api_1.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options)))
31
29
  .before(requireHostingSite_1.requireHostingSite)
32
30
  .action(hostingChannelDeployAction);
33
31
  async function hostingChannelDeployAction(channelId, options) {
@@ -11,15 +11,13 @@ const logger_1 = require("../logger");
11
11
  const requireConfig_1 = require("../requireConfig");
12
12
  const utils_1 = require("../utils");
13
13
  const requireHostingSite_1 = require("../requireHostingSite");
14
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
15
- const api_2 = require("../api");
16
14
  const TABLE_HEAD = ["Channel ID", "Last Release Time", "URL", "Expire Time"];
17
15
  exports.command = new command_1.Command("hosting:channel:list")
18
16
  .description("list all Firebase Hosting channels for your project")
19
17
  .option("--site <siteName>", "list channels for the specified site")
20
18
  .before(requireConfig_1.requireConfig)
21
19
  .before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
22
- .before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
20
+ .before((options) => (0, api_1.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options)))
23
21
  .before(requireHostingSite_1.requireHostingSite)
24
22
  .action(async (options) => {
25
23
  const projectId = (0, projectUtils_1.needProjectId)(options);
@@ -13,15 +13,13 @@ const requireConfig_1 = require("../requireConfig");
13
13
  const utils_1 = require("../utils");
14
14
  const requireHostingSite_1 = require("../requireHostingSite");
15
15
  const prompt_1 = require("../prompt");
16
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
17
- const api_2 = require("../api");
18
16
  exports.command = new command_1.Command("hosting:channel:open [channelId]")
19
17
  .description("opens the URL for a Firebase Hosting channel")
20
18
  .help("if unable to open the URL in a browser, it will be displayed in the output")
21
19
  .option("--site <siteId>", "the site to which the channel belongs")
22
20
  .before(requireConfig_1.requireConfig)
23
21
  .before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.get"])
24
- .before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
22
+ .before((options) => (0, api_1.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options)))
25
23
  .before(requireHostingSite_1.requireHostingSite)
26
24
  .action(async (channelId, options) => {
27
25
  const projectId = (0, projectUtils_1.needProjectId)(options);
@@ -10,8 +10,6 @@ const utils = require("../utils");
10
10
  const requireAuth_1 = require("../requireAuth");
11
11
  const logger_1 = require("../logger");
12
12
  const projectUtils_1 = require("../projectUtils");
13
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
14
- const api_2 = require("../api");
15
13
  exports.command = new command_1.Command("hosting:clone <source> <targetChannel>")
16
14
  .description("clone a version from one site to another")
17
15
  .help(`<source> and <targetChannel> accept the following formats:
@@ -74,7 +72,7 @@ To clone across different Firebase projects:
74
72
  }
75
73
  const defaultProjectId = !sourceProjectId || !targetProjectId ? (0, projectUtils_1.getProjectId)(options) : undefined;
76
74
  if (defaultProjectId) {
77
- await (0, ensureApiEnabled_1.ensure)(defaultProjectId, (0, api_2.hostingApiOrigin)(), "hosting", true);
75
+ await (0, api_1.ensureApiEnabled)(defaultProjectId);
78
76
  }
79
77
  [sourceProjectId, targetProjectId] = await Promise.all([
80
78
  resolveProjectId(sourceSiteId, sourceProjectId, options),
@@ -82,10 +80,10 @@ To clone across different Firebase projects:
82
80
  ]);
83
81
  const ensurePromises = [];
84
82
  if (sourceProjectId !== defaultProjectId) {
85
- ensurePromises.push((0, ensureApiEnabled_1.ensure)(sourceProjectId, (0, api_2.hostingApiOrigin)(), "hosting", true));
83
+ ensurePromises.push((0, api_1.ensureApiEnabled)(sourceProjectId));
86
84
  }
87
85
  if (targetProjectId !== defaultProjectId && targetProjectId !== sourceProjectId) {
88
- ensurePromises.push((0, ensureApiEnabled_1.ensure)(targetProjectId, (0, api_2.hostingApiOrigin)(), "hosting", true));
86
+ ensurePromises.push((0, api_1.ensureApiEnabled)(targetProjectId));
89
87
  }
90
88
  await Promise.all(ensurePromises);
91
89
  targetChannelId = (0, api_1.normalizeName)(targetChannelId);
@@ -5,18 +5,18 @@ const clc = require("colorette");
5
5
  const apiv2_1 = require("../apiv2");
6
6
  const command_1 = require("../command");
7
7
  const api_1 = require("../api");
8
+ const api_2 = require("../hosting/api");
8
9
  const prompt_1 = require("../prompt");
9
10
  const requireHostingSite_1 = require("../requireHostingSite");
10
11
  const requirePermissions_1 = require("../requirePermissions");
11
12
  const projectUtils_1 = require("../projectUtils");
12
13
  const utils = require("../utils");
13
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
14
14
  exports.command = new command_1.Command("hosting:disable")
15
15
  .description("stop serving web traffic to your Firebase Hosting site")
16
16
  .option("-f, --force", "skip confirmation")
17
17
  .option("-s, --site <siteName>", "the site to disable")
18
18
  .before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
19
- .before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_1.hostingApiOrigin)(), "hosting", true))
19
+ .before((options) => (0, api_2.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options)))
20
20
  .before(requireHostingSite_1.requireHostingSite)
21
21
  .action(async (options) => {
22
22
  const projectId = (0, projectUtils_1.needProjectId)(options);
@@ -10,14 +10,12 @@ const projectUtils_1 = require("../projectUtils");
10
10
  const requirePermissions_1 = require("../requirePermissions");
11
11
  const api_1 = require("../hosting/api");
12
12
  const error_1 = require("../error");
13
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
14
- const api_2 = require("../api");
15
13
  const LOG_TAG = "hosting:sites";
16
14
  exports.command = new command_1.Command("hosting:sites:create [siteId]")
17
15
  .description("create a Firebase Hosting site")
18
16
  .option("--app <appId>", "specify an existing Firebase Web App ID")
19
17
  .before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.update"])
20
- .before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
18
+ .before((options) => (0, api_1.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options)))
21
19
  .action(async (siteId, options) => {
22
20
  const projectId = (0, projectUtils_1.needProjectId)(options);
23
21
  const appId = options.app;
@@ -11,15 +11,13 @@ const requirePermissions_1 = require("../requirePermissions");
11
11
  const projectUtils_1 = require("../projectUtils");
12
12
  const requireConfig_1 = require("../requireConfig");
13
13
  const logger_1 = require("../logger");
14
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
15
- const api_2 = require("../api");
16
14
  const LOG_TAG = "hosting:sites";
17
15
  exports.command = new command_1.Command("hosting:sites:delete <siteId>")
18
16
  .description("delete a Firebase Hosting site")
19
17
  .withForce()
20
18
  .before(requireConfig_1.requireConfig)
21
19
  .before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.delete"])
22
- .before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
20
+ .before((options) => (0, api_1.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options)))
23
21
  .action(async (siteId, options) => {
24
22
  const projectId = (0, projectUtils_1.needProjectId)(options);
25
23
  if (!siteId) {
@@ -8,12 +8,10 @@ const requirePermissions_1 = require("../requirePermissions");
8
8
  const projectUtils_1 = require("../projectUtils");
9
9
  const logger_1 = require("../logger");
10
10
  const error_1 = require("../error");
11
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
12
- const api_2 = require("../api");
13
11
  exports.command = new command_1.Command("hosting:sites:get <siteId>")
14
12
  .description("print info about a Firebase Hosting site")
15
13
  .before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.get"])
16
- .before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
14
+ .before((options) => (0, api_1.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options)))
17
15
  .action(async (siteId, options) => {
18
16
  const projectId = (0, projectUtils_1.needProjectId)(options);
19
17
  if (!siteId) {
@@ -8,13 +8,11 @@ const api_1 = require("../hosting/api");
8
8
  const requirePermissions_1 = require("../requirePermissions");
9
9
  const projectUtils_1 = require("../projectUtils");
10
10
  const logger_1 = require("../logger");
11
- const ensureApiEnabled_1 = require("../ensureApiEnabled");
12
- const api_2 = require("../api");
13
11
  const TABLE_HEAD = ["Site ID", "Default URL", "App ID (if set)"];
14
12
  exports.command = new command_1.Command("hosting:sites:list")
15
13
  .description("list Firebase Hosting sites")
16
14
  .before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.get"])
17
- .before((options) => (0, ensureApiEnabled_1.ensure)((0, projectUtils_1.needProjectId)(options), (0, api_2.hostingApiOrigin)(), "hosting", true))
15
+ .before((options) => (0, api_1.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options)))
18
16
  .action(async (options) => {
19
17
  const projectId = (0, projectUtils_1.needProjectId)(options);
20
18
  const sites = await (0, api_1.listSites)(projectId);
@@ -23,6 +23,7 @@ function load(client) {
23
23
  client.appcheck.debugtokens = {};
24
24
  client.appcheck.debugtokens.create = loadCommand("appcheck-debugtokens-create");
25
25
  client.appcheck.debugtokens.list = loadCommand("appcheck-debugtokens-list");
26
+ client.appcheck.debugtokens.prune = loadCommand("appcheck-debugtokens-prune");
26
27
  client.appcheck.debugtokens.delete = loadCommand("appcheck-debugtokens-delete");
27
28
  if (experiments.isEnabled("appcheckadmin")) {
28
29
  client.appcheck.services = {};
@@ -1,16 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_MAX_FRAMES = exports.EVENT_DUMP_OPTIONS = void 0;
3
4
  exports.listEvents = listEvents;
5
+ exports.normalizeEventResourceName = normalizeEventResourceName;
4
6
  exports.batchGetEvents = batchGetEvents;
7
+ exports.formatFrames = formatFrames;
8
+ exports.toText = toText;
9
+ const js_yaml_1 = require("js-yaml");
5
10
  const logger_1 = require("../logger");
6
11
  const error_1 = require("../error");
7
12
  const utils_1 = require("./utils");
13
+ const types_1 = require("./types");
8
14
  const filters_1 = require("./filters");
9
- async function listEvents(appId, filter, pageSize = 1) {
15
+ exports.EVENT_DUMP_OPTIONS = { lineWidth: 200 };
16
+ exports.DEFAULT_MAX_FRAMES = 20;
17
+ const DEFAULT_MAX_LOGS = 100;
18
+ const DEFAULT_MAX_BREADCRUMBS = 10;
19
+ async function listEvents(appId, filter, pageSize = 1, filterExpression) {
10
20
  var _a;
11
21
  const requestProjectNumber = (0, utils_1.parseProjectNumber)(appId);
12
22
  const queryParams = (0, filters_1.filterToUrlSearchParams)(filter);
13
23
  queryParams.set("page_size", `${pageSize}`);
24
+ if (filterExpression) {
25
+ queryParams.set("filter_expression", filterExpression);
26
+ }
14
27
  logger_1.logger.debug(`[crashlytics] listEvents called with appId: ${appId}, filter: ${queryParams.toString()}, pageSize: ${pageSize}`);
15
28
  const response = await utils_1.CRASHLYTICS_API_CLIENT.request({
16
29
  method: "GET",
@@ -24,6 +37,24 @@ async function listEvents(appId, filter, pageSize = 1) {
24
37
  (_a = response.body).events ?? (_a.events = []);
25
38
  return response.body;
26
39
  }
40
+ function normalizeEventResourceName(appId, eventIdOrName) {
41
+ const trimmed = eventIdOrName.trim();
42
+ if (!trimmed) {
43
+ throw new error_1.FirebaseError("Event ID cannot be empty.");
44
+ }
45
+ const requestProjectNumber = (0, utils_1.parseProjectNumber)(appId);
46
+ const expectedPrefix = `projects/${requestProjectNumber}/apps/${appId}/events/`;
47
+ if (trimmed.startsWith(expectedPrefix)) {
48
+ const eventId = trimmed.slice(expectedPrefix.length);
49
+ if (eventId && !eventId.includes("/")) {
50
+ return trimmed;
51
+ }
52
+ }
53
+ if (trimmed.includes("/")) {
54
+ throw new error_1.FirebaseError(`Invalid event resource name '${trimmed}'. Expected an event ID or '${expectedPrefix}{event_id}'.`);
55
+ }
56
+ return `${expectedPrefix}${trimmed}`;
57
+ }
27
58
  async function batchGetEvents(appId, eventNames) {
28
59
  var _a;
29
60
  const requestProjectNumber = (0, utils_1.parseProjectNumber)(appId);
@@ -46,3 +77,93 @@ async function batchGetEvents(appId, eventNames) {
46
77
  (_a = response.body).events ?? (_a.events = []);
47
78
  return response.body;
48
79
  }
80
+ function formatFrames(origFrames, maxFrames = exports.DEFAULT_MAX_FRAMES) {
81
+ const frames = origFrames || [];
82
+ const shouldTruncate = frames.length > maxFrames;
83
+ const sliceCount = maxFrames > 1 ? maxFrames - 1 : 1;
84
+ const framesToFormat = shouldTruncate ? frames.slice(0, sliceCount) : frames;
85
+ const formatted = framesToFormat.map((frame) => {
86
+ let line = `at`;
87
+ if (frame.symbol) {
88
+ line += ` ${frame.symbol}`;
89
+ }
90
+ if (frame.file) {
91
+ line += ` (${frame.file}`;
92
+ if (frame.line) {
93
+ line += `:${frame.line}`;
94
+ }
95
+ line += ")";
96
+ }
97
+ return line;
98
+ });
99
+ if (shouldTruncate) {
100
+ formatted.push("... frames omitted ...");
101
+ }
102
+ return formatted;
103
+ }
104
+ function toText(event, options = {}) {
105
+ if (!event) {
106
+ return {};
107
+ }
108
+ const { maxFrames = exports.DEFAULT_MAX_FRAMES, full = false } = options;
109
+ const effectiveMaxFrames = full ? Infinity : maxFrames;
110
+ const result = {};
111
+ for (const [key, value] of Object.entries(event)) {
112
+ if (key === "logs") {
113
+ const logs = value || [];
114
+ const slicedLogs = !full && logs.length > DEFAULT_MAX_LOGS ? logs.slice(logs.length - DEFAULT_MAX_LOGS) : logs;
115
+ const logLines = slicedLogs.map((log) => `[${log.logTime}] ${log.message}`);
116
+ result["logs"] = logLines.join("\n");
117
+ }
118
+ else if (key === "breadcrumbs") {
119
+ const breadcrumbs = value || [];
120
+ const slicedBreadcrumbs = !full && breadcrumbs.length > DEFAULT_MAX_BREADCRUMBS
121
+ ? breadcrumbs.slice(-DEFAULT_MAX_BREADCRUMBS)
122
+ : breadcrumbs;
123
+ const breadcrumbLines = slicedBreadcrumbs.map((b) => {
124
+ const paramString = Object.entries(b.params || {})
125
+ .map(([k, v]) => `${k}: ${v}`)
126
+ .join(", ");
127
+ const params = paramString ? ` { ${paramString} }` : "";
128
+ return `[${b.eventTime}] ${b.title}${params}`;
129
+ });
130
+ result["breadcrumbs"] = breadcrumbLines.join("\n");
131
+ }
132
+ else if (key === "threads") {
133
+ let threads = value || [];
134
+ if (!full &&
135
+ (event.issue?.errorType === types_1.ErrorType.FATAL || event.issue?.errorType === types_1.ErrorType.ANR)) {
136
+ threads = threads.filter((t) => t.crashed || t.blamed);
137
+ }
138
+ const threadStrings = threads.map((thread) => {
139
+ const header = `Thread: ${thread.name || thread.threadId || ""}${thread.crashed ? " (crashed)" : ""}`;
140
+ const frameStrings = formatFrames(thread.frames || [], effectiveMaxFrames);
141
+ return [header, ...frameStrings].join("\n");
142
+ });
143
+ result["threads"] = threadStrings.join("\n\n");
144
+ }
145
+ else if (key === "exceptions") {
146
+ const exceptions = value || [];
147
+ const exceptionStrings = exceptions.map((exception) => {
148
+ const header = exception.nested ? "Caused by: " : "";
149
+ const exceptionHeader = `${header}${exception.type || ""}: ${exception.exceptionMessage || ""}`;
150
+ const frameStrings = formatFrames(exception.frames || [], effectiveMaxFrames);
151
+ return [exceptionHeader, ...frameStrings].join("\n");
152
+ });
153
+ result["exceptions"] = exceptionStrings.join("\n\n");
154
+ }
155
+ else if (key === "errors") {
156
+ const errors = value || [];
157
+ const errorStrings = errors.map((error) => {
158
+ const header = `Error: ${error.title || "error"}`;
159
+ const frameStrings = formatFrames(error.frames || [], effectiveMaxFrames);
160
+ return [header, ...frameStrings].join("\n");
161
+ });
162
+ result["errors"] = errorStrings.join("\n\n");
163
+ }
164
+ else {
165
+ result[key] = (0, js_yaml_1.dump)(value, exports.EVENT_DUMP_OPTIONS);
166
+ }
167
+ }
168
+ return result;
169
+ }
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EventFilterSchema = exports.IssueIdSchema = exports.ApplicationIdSchema = void 0;
3
+ exports.FilterExpressionSchema = exports.EventFilterSchema = exports.IssueIdSchema = exports.ApplicationIdSchema = void 0;
4
4
  exports.filterToUrlSearchParams = filterToUrlSearchParams;
5
5
  exports.validateEventFilters = validateEventFilters;
6
6
  const zod_1 = require("zod");
7
7
  const error_1 = require("../error");
8
+ const apps_1 = require("../management/apps");
9
+ const utils_1 = require("./utils");
8
10
  exports.ApplicationIdSchema = zod_1.z
9
11
  .string()
10
12
  .describe("Firebase App Id. Strictly required for all API calls.");
@@ -56,6 +58,10 @@ exports.EventFilterSchema = zod_1.z
56
58
  .optional()
57
59
  .describe(`Only events matching the given filters will be counted. All filters are optional.
58
60
  If setting a time interval, set both intervalStartTime and intervalEndTime.`);
61
+ exports.FilterExpressionSchema = zod_1.z
62
+ .string()
63
+ .optional()
64
+ .describe(`An AIP-160 filter expression for custom keys (e.g. 'custom_keys.env = "prod"', 'custom_keys.experiment_id:*', or combined with 'AND' across different keys and 'OR' across values of one key).`);
59
65
  const toolToParamMap = {
60
66
  intervalStartTime: "filter.interval.start_time",
61
67
  intervalEndTime: "filter.interval.end_time",
@@ -88,7 +94,7 @@ function filterToUrlSearchParams(filter) {
88
94
  return params;
89
95
  }
90
96
  const displayNamePattern = /^[^()]+\s+\([^()]+\)$/;
91
- function validateEventFilters(filter = {}) {
97
+ function validateEventFilters(filter = {}, appId) {
92
98
  if (!!filter.intervalStartTime && !filter.intervalEndTime) {
93
99
  filter.intervalEndTime = new Date().toISOString();
94
100
  }
@@ -110,12 +116,12 @@ function validateEventFilters(filter = {}) {
110
116
  }
111
117
  });
112
118
  }
113
- if (filter.versionDisplayNames) {
114
- filter.versionDisplayNames.forEach((dn) => {
119
+ if (filter.versionDisplayNames && (0, utils_1.parseAppPlatform)(appId) !== apps_1.AppPlatform.WEB) {
120
+ for (const dn of filter.versionDisplayNames) {
115
121
  if (!displayNamePattern.test(dn)) {
116
- throw new error_1.FirebaseError("versionDisplayNames must match pattern 'version (build)'");
122
+ throw new error_1.FirebaseError(`versionDisplayNames must match pattern 'version (build)' (e.g., "2.4.0 (240)"). Use the displayName values returned by the topVersions report.`);
117
123
  }
118
- });
124
+ }
119
125
  }
120
126
  return filter;
121
127
  }