firebase-tools 15.34.2 → 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 (126) hide show
  1. package/lib/api.js +2 -4
  2. package/lib/appcheck/debugTokens.js +293 -0
  3. package/lib/appcheck/localConfig.js +191 -0
  4. package/lib/appdistribution/options-parser-util.js +1 -1
  5. package/lib/apphosting/constants.js +1 -4
  6. package/lib/apphosting/githubConnections.js +1 -1
  7. package/lib/apphosting/utils.js +0 -26
  8. package/lib/auth.js +8 -2
  9. package/lib/commands/appcheck-debugtokens-create.js +60 -35
  10. package/lib/commands/appcheck-debugtokens-delete.js +21 -7
  11. package/lib/commands/appcheck-debugtokens-list.js +37 -8
  12. package/lib/commands/appcheck-debugtokens-prune.js +59 -0
  13. package/lib/commands/crashlytics-heapdumps-status.js +1 -1
  14. package/lib/commands/{crashlytics-onboard-web.js → crashlytics-setup.js} +5 -5
  15. package/lib/commands/crashlytics-sourcemap-upload.js +4 -0
  16. package/lib/commands/deploy.js +1 -3
  17. package/lib/commands/emulators-start.js +2 -2
  18. package/lib/commands/hosting-channel-create.js +1 -3
  19. package/lib/commands/hosting-channel-delete.js +1 -3
  20. package/lib/commands/hosting-channel-deploy.js +1 -3
  21. package/lib/commands/hosting-channel-list.js +1 -3
  22. package/lib/commands/hosting-channel-open.js +1 -3
  23. package/lib/commands/hosting-clone.js +3 -5
  24. package/lib/commands/hosting-disable.js +2 -2
  25. package/lib/commands/hosting-sites-create.js +1 -3
  26. package/lib/commands/hosting-sites-delete.js +1 -3
  27. package/lib/commands/hosting-sites-get.js +1 -3
  28. package/lib/commands/hosting-sites-list.js +1 -3
  29. package/lib/commands/index.js +4 -2
  30. package/lib/commands/run-services-get.js +19 -0
  31. package/lib/commands/run-services-list.js +11 -0
  32. package/lib/crashlytics/alerts.js +1 -0
  33. package/lib/crashlytics/events.js +122 -1
  34. package/lib/crashlytics/filters.js +12 -6
  35. package/lib/crashlytics/firebasetelemetry.js +5 -3
  36. package/lib/crashlytics/onboarding.js +8 -7
  37. package/lib/crashlytics/profilingManager.js +14 -34
  38. package/lib/crashlytics/reports.js +46 -17
  39. package/lib/crashlytics/sourcemap.js +19 -5
  40. package/lib/crashlytics/utils.js +14 -0
  41. package/lib/database/import.js +5 -4
  42. package/lib/dataconnect/dataplaneClient.js +0 -10
  43. package/lib/dataconnect/names.js +3 -3
  44. package/lib/dataconnect/schemaMigration.js +1 -1
  45. package/lib/deploy/apphosting/deploy.js +20 -41
  46. package/lib/deploy/apphosting/localBuild.js +49 -0
  47. package/lib/deploy/apphosting/prepare.js +12 -25
  48. package/lib/deploy/apphosting/release.js +1 -1
  49. package/lib/deploy/apphosting/util.js +27 -4
  50. package/lib/deploy/functions/backend.js +0 -10
  51. package/lib/deploy/functions/cel.js +1 -1
  52. package/lib/deploy/functions/containerCleaner.js +1 -142
  53. package/lib/deploy/functions/functionsDeployHelper.js +0 -4
  54. package/lib/deploy/functions/release/reporter.js +0 -26
  55. package/lib/deploy/functions/runtimes/discovery/index.js +4 -1
  56. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +1 -1
  57. package/lib/deploy/functions/services/index.js +13 -11
  58. package/lib/deploy/functions/validate.js +1 -1
  59. package/lib/deploy/hosting/prepare.js +1 -3
  60. package/lib/deploy/lifecycleHooks.js +1 -1
  61. package/lib/deploy/run/deploy.js +26 -43
  62. package/lib/deploy/run/get.js +30 -0
  63. package/lib/deploy/run/list.js +38 -0
  64. package/lib/deploy/run/prereqs.js +0 -3
  65. package/lib/deploy/run/util.js +9 -0
  66. package/lib/emulator/auth/operations.js +2 -2
  67. package/lib/emulator/auth/server.js +4 -2
  68. package/lib/emulator/auth/widget_ui.js +1 -1
  69. package/lib/emulator/commandUtils.js +109 -24
  70. package/lib/emulator/databaseEmulator.js +16 -11
  71. package/lib/emulator/dataconnect/pgliteServer.js +31 -24
  72. package/lib/emulator/downloadableEmulatorInfo.json +24 -24
  73. package/lib/emulator/downloadableEmulators.js +45 -7
  74. package/lib/emulator/extensions/postinstall.js +6 -6
  75. package/lib/emulator/firestoreEmulator.js +21 -15
  76. package/lib/emulator/functionsEmulator.js +11 -7
  77. package/lib/emulator/functionsEmulatorRuntime.js +7 -2
  78. package/lib/emulator/hub.js +12 -8
  79. package/lib/emulator/shared/express.js +30 -0
  80. package/lib/emulator/storage/apis/firebase.js +11 -10
  81. package/lib/emulator/storage/apis/gcloud.js +21 -20
  82. package/lib/emulator/storage/files.js +1 -1
  83. package/lib/emulator/storage/rules/manager.js +15 -12
  84. package/lib/emulator/storage/rules/runtime.js +1 -0
  85. package/lib/emulator/storage/server.js +10 -5
  86. package/lib/extensions/extensionsApi.js +0 -8
  87. package/lib/extensions/extensionsHelper.js +3 -24
  88. package/lib/extensions/paramHelper.js +1 -1
  89. package/lib/extensions/provisioningHelper.js +1 -6
  90. package/lib/extensions/secretsUtils.js +0 -24
  91. package/lib/firestore/util.js +3 -3
  92. package/lib/frameworks/angular/utils.js +1 -1
  93. package/lib/frameworks/next/utils.js +1 -12
  94. package/lib/fsAsync.js +34 -20
  95. package/lib/functions/kits/install.js +233 -628
  96. package/lib/functions/kits/sources/directory.js +91 -0
  97. package/lib/functions/kits/sources/npm.js +324 -0
  98. package/lib/functions/kits/sources/types.js +12 -0
  99. package/lib/functionsConfig.js +0 -4
  100. package/lib/functionsShellCommandAction.js +1 -1
  101. package/lib/gcp/artifactregistry.js +0 -5
  102. package/lib/gcp/cloudfunctionsv2.js +0 -6
  103. package/lib/gcp/devConnect.js +2 -2
  104. package/lib/gcp/iam.js +0 -4
  105. package/lib/gcp/pubsub.js +0 -14
  106. package/lib/gcp/storage.js +2 -1
  107. package/lib/hosting/api.js +79 -0
  108. package/lib/hosting/proxy.js +4 -1
  109. package/lib/init/features/hosting/github.js +6 -4
  110. package/lib/init/features/hosting/index.js +4 -0
  111. package/lib/init/features/run.js +3 -7
  112. package/lib/mcp/apps/init/mcp-app.js +4 -1
  113. package/lib/mcp/index.js +8 -2
  114. package/lib/mcp/prompts/apptesting/run_test.js +3 -3
  115. package/lib/mcp/prompts/core/deploy.js +3 -3
  116. package/lib/mcp/resources/guides/crashlytics_reports.js +33 -71
  117. package/lib/mcp/resources/guides/init_ai.js +10 -10
  118. package/lib/mcp/tools/crashlytics/events.js +18 -93
  119. package/lib/mcp/tools/crashlytics/index.js +2 -0
  120. package/lib/mcp/tools/crashlytics/reports.js +26 -31
  121. package/lib/mcp/tools/crashlytics/setup.js +392 -0
  122. package/lib/tsconfig.compile.tsbuildinfo +1 -1
  123. package/lib/tsconfig.publish.tsbuildinfo +1 -1
  124. package/lib/utils.js +4 -10
  125. package/package.json +1 -2
  126. package/lib/deploy/hosting/args.js +0 -2
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.command = void 0;
4
4
  const clc = require("colorette");
5
5
  const node_crypto_1 = require("node:crypto");
6
- const os = require("os");
7
6
  const command_1 = require("../command");
8
7
  const projectUtils_1 = require("../projectUtils");
9
8
  const api_1 = require("../appcheck/api");
9
+ const debugTokens_1 = require("../appcheck/debugTokens");
10
+ const localConfig_1 = require("../appcheck/localConfig");
10
11
  const appcheck_prompts_1 = require("./appcheck-prompts");
11
12
  const requireAuth_1 = require("../requireAuth");
12
13
  const utils_1 = require("../utils");
@@ -15,16 +16,23 @@ const prompt_1 = require("../prompt");
15
16
  const logger_1 = require("../logger");
16
17
  exports.command = new command_1.Command("appcheck:debugtokens:create [debugToken]")
17
18
  .description("generate and register an App Check debug token for an app")
19
+ .help(`generates or registers a Firebase App Check debug token for an app and saves it to the local machine configuration (~/.config/configstore/firebase-appcheck.json) so local SDKs can discover it automatically.
20
+
21
+ Pass an optional \`[debugToken]\` UUID v4 to register a specific token, or omit it to generate a new UUID v4 token. Use \`--no-save-local\` when provisioning tokens for remote CI environments to avoid modifying the local config file.`)
18
22
  .option("--app <appId>", "the app id of your Firebase app")
19
- .option("--display-name <displayName>", "display name for the debug token")
20
- .option("--force", "overwrite existing debug token if it has the same display name without prompting")
21
- .before(requireAuth_1.requireAuth)
23
+ .option("--display-name <displayName>", "display name for the debug token (max 50 characters)")
24
+ .option("--no-save-local", "do not save the debug token to the local machine config")
25
+ .withForce("accept default prompts and overwrite any existing debug token with the same display name")
26
+ .before((options) => (0, requireAuth_1.requireAuth)(options))
22
27
  .action(async (debugToken, options) => {
28
+ const validatedTokenArg = debugToken !== undefined ? (0, debugTokens_1.validateDebugTokenUuid)(debugToken) : undefined;
29
+ const validatedDisplayNameOpt = options.displayName !== undefined ? (0, debugTokens_1.validateDisplayName)(options.displayName) : undefined;
30
+ const saveLocal = options.saveLocal !== false;
23
31
  const { appId } = await (0, appcheck_prompts_1.getOrPromptProjectAndAppId)(options);
24
32
  const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
25
- let token = debugToken;
33
+ let token = validatedTokenArg;
26
34
  if (!token) {
27
- if (!options.nonInteractive) {
35
+ if (!options.nonInteractive && !options.force) {
28
36
  const action = await (0, prompt_1.select)({
29
37
  message: "Would you like to register a token generated by the SDK, or create a new one?",
30
38
  choices: [
@@ -33,10 +41,11 @@ exports.command = new command_1.Command("appcheck:debugtokens:create [debugToken
33
41
  ],
34
42
  });
35
43
  if (action === "sdk") {
36
- token = await (0, prompt_1.password)({
44
+ const entered = await (0, prompt_1.password)({
37
45
  message: "Enter the debug token generated by the SDK:",
38
- validate: (val) => (val.trim().length > 0 ? true : "Debug token cannot be empty."),
46
+ validate: (val) => (0, debugTokens_1.getDebugTokenValidationError)(val) ?? true,
39
47
  });
48
+ token = (0, debugTokens_1.validateDebugTokenUuid)(entered);
40
49
  }
41
50
  else {
42
51
  token = (0, node_crypto_1.randomUUID)();
@@ -46,14 +55,16 @@ exports.command = new command_1.Command("appcheck:debugtokens:create [debugToken
46
55
  token = (0, node_crypto_1.randomUUID)();
47
56
  }
48
57
  }
49
- let displayName = options.displayName;
50
- const defaultName = `CLI Debug Token (${os.hostname() || "Unknown Host"})`;
58
+ let displayName = validatedDisplayNameOpt;
51
59
  if (!displayName) {
52
- if (!options.nonInteractive) {
53
- displayName = await (0, prompt_1.input)({
60
+ const defaultName = (0, debugTokens_1.getDefaultDisplayName)(saveLocal);
61
+ if (!options.nonInteractive && !options.force) {
62
+ const entered = await (0, prompt_1.input)({
54
63
  message: "What would you like to call this debug token?",
55
64
  default: defaultName,
65
+ validate: (val) => (0, debugTokens_1.getDisplayNameValidationError)(val) ?? true,
56
66
  });
67
+ displayName = (0, debugTokens_1.validateDisplayName)(entered);
57
68
  }
58
69
  else {
59
70
  displayName = defaultName;
@@ -61,35 +72,49 @@ exports.command = new command_1.Command("appcheck:debugtokens:create [debugToken
61
72
  }
62
73
  const existingTokens = await (0, api_1.listDebugTokens)(projectNumber, appId);
63
74
  const matchingTokens = existingTokens.filter((t) => t.displayName === displayName);
64
- if (matchingTokens.length > 0) {
65
- let shouldOverwrite = options.force;
66
- if (!shouldOverwrite) {
67
- if (options.nonInteractive) {
68
- throw new error_1.FirebaseError(`A token with the display name "${displayName}" already exists. Must pass --force to overwrite in non-interactive mode.`, { exit: 1 });
69
- }
70
- shouldOverwrite = await (0, prompt_1.confirm)({
71
- message: `A token with the display name "${displayName}" already exists. Delete the old token(s)?`,
72
- default: true,
73
- });
74
- }
75
- if (shouldOverwrite) {
76
- for (const t of matchingTokens) {
77
- await (0, api_1.deleteDebugToken)(t.name);
78
- }
75
+ (0, debugTokens_1.ensureCanCreateOrOverwriteDebugToken)({ appId, existingTokens, matchingTokens });
76
+ if (matchingTokens.length > 0 && !options.force) {
77
+ if (options.nonInteractive) {
78
+ throw new error_1.FirebaseError(`A token with the display name "${displayName}" already exists. Must pass --force to overwrite in non-interactive mode.`, { exit: 1 });
79
79
  }
80
- else {
80
+ const shouldOverwrite = await (0, prompt_1.confirm)({
81
+ message: `A token with the display name "${displayName}" already exists. Replace the existing token(s)?`,
82
+ default: true,
83
+ });
84
+ if (!shouldOverwrite) {
81
85
  throw new error_1.FirebaseError("Registration canceled.", { exit: 1 });
82
86
  }
83
87
  }
84
- const result = await (0, utils_1.promiseWithSpinner)(async () => await (0, api_1.createDebugToken)(projectNumber, appId, displayName, token), `Registering App Check debug token with Firebase for app ${clc.bold(appId)}`);
88
+ const result = await (0, utils_1.promiseWithSpinner)(() => (0, debugTokens_1.provisionDebugToken)({
89
+ projectNumber,
90
+ appId,
91
+ displayName,
92
+ token,
93
+ existingTokens,
94
+ matchingTokens,
95
+ saveLocal,
96
+ }), `Registering App Check debug token with Firebase for app ${clc.bold(appId)}`);
97
+ const finalToken = result.token || token;
85
98
  (0, utils_1.logSuccess)(`Successfully registered App Check debug token:
86
99
  - Display Name: ${clc.bold(result.displayName)}
87
- - Resource Name: ${clc.cyan(result.name)}`);
88
- if (!options.json) {
89
- console.log(` - Token: ${clc.bold(clc.green(token))}\n`);
100
+ - Resource Name: ${clc.cyan(result.name)}
101
+ - Token: ${clc.bold(clc.green(finalToken))}`);
102
+ if (saveLocal) {
103
+ logger_1.logger.info(`Saved debug token to local config: ${clc.bold((0, localConfig_1.getLocalConfigPath)())}`);
104
+ }
105
+ if ((0, debugTokens_1.isWebAppId)(appId)) {
106
+ logger_1.logger.info(`\nWeb Framework Instructions:\n` +
107
+ `Copy and paste the relevant variable into your local environment file (${clc.bold(".env.local")}), or export the debug token as a shell environment variable:\n` +
108
+ ` # Vite\n` +
109
+ ` VITE_FIREBASE_APPCHECK_DEBUG_TOKEN=${finalToken}\n` +
110
+ ` # Next.js\n` +
111
+ ` NEXT_PUBLIC_FIREBASE_APPCHECK_DEBUG_TOKEN=${finalToken}\n` +
112
+ ` # Create React App\n` +
113
+ ` REACT_APP_FIREBASE_APPCHECK_DEBUG_TOKEN=${finalToken}\n` +
114
+ `Assign this variable to ${clc.bold("self.FIREBASE_APPCHECK_DEBUG_TOKEN")} in your app initialization code before initializing App Check.\n` +
115
+ `Ensure ${clc.bold(".env.local")} is in your ${clc.bold(".gitignore")} so debug tokens are never committed.`);
90
116
  }
91
117
  logger_1.logger.info(clc.yellow(clc.bold("Warning: ") +
92
- "This debug token is a secret and should not be shared or uploaded to source code."));
93
- logger_1.logger.info(clc.yellow("TODO: Remember to delete this token once your testing has finished."));
94
- return result;
118
+ "App Check debug tokens grant access to backend resources and are secrets. Do NOT commit debug tokens or .env.local to source repositories. Revoke unused tokens with 'firebase appcheck:debugtokens:delete'."));
119
+ return finalToken;
95
120
  });
@@ -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());
@@ -8,13 +8,13 @@ const apps_1 = require("../management/apps");
8
8
  const projectUtils_1 = require("../projectUtils");
9
9
  const requireAuth_1 = require("../requireAuth");
10
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")
11
+ exports.command = new command_1.Command("crashlytics:setup [appId]")
12
+ .description("set up a Firebase web app for Crashlytics")
13
13
  .option("--app <appID>", "the app id of your Firebase app")
14
14
  .before(requireAuth_1.requireAuth)
15
15
  .action(async (appIdInput = "", options) => {
16
16
  const projectId = (0, projectUtils_1.needProjectId)(options);
17
- let appId = appIdInput ?? options.app ?? "";
17
+ let appId = appIdInput || options.app || "";
18
18
  let appPlatform = apps_1.AppPlatform.ANY;
19
19
  if (!appId) {
20
20
  const apps = await (0, apps_1.listFirebaseApps)(projectId, apps_1.AppPlatform.ANY);
@@ -49,8 +49,8 @@ exports.command = new command_1.Command("crashlytics:onboard:web [appId]")
49
49
  }
50
50
  }
51
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}`);
52
+ logger_1.logger.info(`Crashlytics setup via the CLI is currently only supported for Web apps. No setup steps needed for non-Web app: ${appId}`);
53
53
  return undefined;
54
54
  }
55
- return await (0, onboarding_1.onboardCrashlyticsWeb)(projectId, appId, options);
55
+ return await (0, onboarding_1.setupCrashlyticsWeb)(projectId, appId, options);
56
56
  });
@@ -16,6 +16,7 @@ exports.command = new command_1.Command("crashlytics:sourcemap:upload [mappingFi
16
16
  .option("--app <appID>", "the app id of your Firebase app")
17
17
  .option("--bucket-location <bucketLocation>", 'the location of the Google Cloud Storage bucket (default: "US-CENTRAL1"')
18
18
  .option("--app-version <appVersion>", "the version of your Firebase app (defaults to Git commit hash, if available)")
19
+ .option("--clean", "delete source map (.js.map) files after successful upload")
19
20
  .before(requireAuth_1.requireAuth)
20
21
  .action(async (mappingFiles, options) => {
21
22
  (0, sourcemap_1.checkGoogleAppID)(options);
@@ -56,6 +57,9 @@ exports.command = new command_1.Command("crashlytics:sourcemap:upload [mappingFi
56
57
  throw new error_1.FirebaseError("provide a valid directory to mapping file(s), e.g. app/build/outputs");
57
58
  }
58
59
  (0, utils_1.logLabeledBullet)("crashlytics", `Uploaded ${successCount} (${failedFiles.length} failed) mapping files to ${bucketName}`);
60
+ if (options.clean && successCount > 0) {
61
+ (0, utils_1.logLabeledBullet)("crashlytics", `Deleted ${successCount} uploaded mapping files`);
62
+ }
59
63
  if (failedFiles.length > 0) {
60
64
  (0, utils_1.logLabeledBullet)("crashlytics", `Could not upload the following files:\n${failedFiles.join("\n")}`);
61
65
  }
@@ -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);
@@ -67,7 +67,7 @@ function printEmulatorOverview(options) {
67
67
  const successMessageTable = new Table();
68
68
  let successMsg = `${clc.green("✔")} ${clc.bold("All emulators ready! It is now safe to connect your app.")}`;
69
69
  if (uiRunning) {
70
- successMsg += `\n${clc.cyan("i")} View Emulator UI at ${stylizeLink(registry_1.EmulatorRegistry.url(types_1.Emulators.UI).toString())}`;
70
+ successMsg += `\n${clc.cyan("i")} View Emulator UI at ${stylizeLink(registry_1.EmulatorRegistry.url(types_1.Emulators.UI).toString())}${commandUtils.getListenSuffix(types_1.Emulators.UI)}`;
71
71
  }
72
72
  successMessageTable.push([successMsg]);
73
73
  const emulatorsTable = new Table({
@@ -109,7 +109,7 @@ function printEmulatorOverview(options) {
109
109
 
110
110
  ${emulatorsTable}
111
111
  ${hubInfo
112
- ? clc.blackBright(` Emulator Hub host: ${hubInfo.host} port: ${hubInfo.port}`)
112
+ ? clc.blackBright(` Emulator Hub host: ${hubInfo.host} port: ${hubInfo.port}${commandUtils.getListenSuffix(types_1.Emulators.HUB)}`)
113
113
  : clc.blackBright(" Emulator Hub not running.")}
114
114
  ${clc.blackBright(" Other reserved ports:")} ${reservedPortsString}
115
115
  ${extensionsTable}
@@ -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) {