firebase-tools 15.24.0 → 15.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/lib/api.js +4 -2
  2. package/lib/appcheck/api.js +42 -0
  3. package/lib/appcheck/prompts.js +41 -0
  4. package/lib/appcheck/types.js +2 -0
  5. package/lib/command.js +11 -3
  6. package/lib/commands/ailogic-config-get.js +75 -0
  7. package/lib/commands/ailogic-config-set.js +109 -0
  8. package/lib/commands/ailogic-providers-disable.js +39 -0
  9. package/lib/commands/ailogic-providers-enable.js +28 -0
  10. package/lib/commands/ailogic-providers-list.js +29 -0
  11. package/lib/commands/appcheck-debugtokens-create.js +95 -0
  12. package/lib/commands/appcheck-debugtokens-delete.js +48 -0
  13. package/lib/commands/appcheck-debugtokens-list.js +35 -0
  14. package/lib/commands/apps-sdkconfig.js +2 -23
  15. package/lib/commands/database-get.js +1 -1
  16. package/lib/commands/index.js +15 -0
  17. package/lib/deploy/functions/build.js +93 -3
  18. package/lib/deploy/functions/functionsDeployHelper.js +18 -12
  19. package/lib/deploy/functions/params.js +45 -11
  20. package/lib/deploy/functions/prepare.js +38 -5
  21. package/lib/deploy/functions/release/executor.js +51 -8
  22. package/lib/deploy/functions/release/fabricator.js +34 -5
  23. package/lib/deploy/functions/runtimes/node/index.js +8 -7
  24. package/lib/deploy/functions/runtimes/node/versioning.js +8 -3
  25. package/lib/deploy/functions/validate.js +5 -2
  26. package/lib/deploy/hosting/uploader.js +2 -1
  27. package/lib/emulator/controller.js +34 -15
  28. package/lib/emulator/dataconnect/pgliteServer.js +2 -1
  29. package/lib/emulator/downloadableEmulatorInfo.json +6 -6
  30. package/lib/emulator/downloadableEmulators.js +1 -0
  31. package/lib/emulator/hubExport.js +2 -1
  32. package/lib/emulator/storage/apis/firebase.js +24 -5
  33. package/lib/emulator/storage/apis/gcloud.js +16 -6
  34. package/lib/emulator/storage/rules/runtime.js +45 -33
  35. package/lib/emulator/storage/server.js +2 -5
  36. package/lib/emulator/storage/upload.js +1 -0
  37. package/lib/ensureApiEnabled.js +8 -0
  38. package/lib/experiments.js +22 -0
  39. package/lib/extensions/warnings.js +64 -0
  40. package/lib/functions/env.js +22 -2
  41. package/lib/functions/projectConfig.js +98 -12
  42. package/lib/functions/secrets.js +4 -1
  43. package/lib/gcp/ailogic.js +165 -1
  44. package/lib/gcp/cloudfunctionsv2.js +7 -0
  45. package/lib/gcp/firedata.js +5 -1
  46. package/lib/gcp/serviceusage.js +26 -0
  47. package/lib/init/features/ailogic/index.js +3 -29
  48. package/lib/init/features/database.js +1 -1
  49. package/lib/management/apps.js +16 -5
  50. package/lib/mcp/onemcp/onemcp_server.js +28 -9
  51. package/lib/mcp/tools/core/get_security_rules.js +2 -1
  52. package/lib/profiler.js +1 -1
  53. package/lib/serve/functions.js +25 -7
  54. package/lib/streamUtils.js +3 -0
  55. package/lib/tsconfig.compile.tsbuildinfo +1 -1
  56. package/lib/tsconfig.publish.tsbuildinfo +1 -1
  57. package/package.json +2 -2
  58. package/schema/firebase-config.json +93 -0
@@ -5,6 +5,7 @@ exports.getPlatform = getPlatform;
5
5
  exports.sdkInit = sdkInit;
6
6
  exports.getSdkOutputPath = getSdkOutputPath;
7
7
  exports.checkForApps = checkForApps;
8
+ exports.selectAppInteractively = selectAppInteractively;
8
9
  exports.getSdkConfig = getSdkConfig;
9
10
  exports.getAppPlatform = getAppPlatform;
10
11
  exports.createIosApp = createIosApp;
@@ -186,18 +187,28 @@ function checkForApps(apps, appPlatform) {
186
187
  "You can create an app for this project with 'firebase apps:create'");
187
188
  }
188
189
  }
189
- async function selectAppInteractively(apps, appPlatform) {
190
+ async function selectAppInteractively(apps, appPlatform = AppPlatform.ANY, options) {
190
191
  checkForApps(apps, appPlatform);
191
192
  const choices = apps.map((app) => {
193
+ let displayText = app.displayName || app.appId;
194
+ if (!app.displayName) {
195
+ if (app.platform === AppPlatform.IOS && "bundleId" in app) {
196
+ displayText = app.bundleId;
197
+ }
198
+ else if (app.platform === AppPlatform.ANDROID && "packageName" in app) {
199
+ displayText = app.packageName;
200
+ }
201
+ }
192
202
  return {
193
- name: `${app.displayName || app.bundleId || app.packageName}` +
194
- ` - ${app.appId} (${app.platform})`,
203
+ name: `${displayText} - ${app.appId} (${app.platform})`,
195
204
  value: app,
196
205
  };
197
206
  });
207
+ const message = options?.message ??
208
+ `Select the ${appPlatform === AppPlatform.ANY ? "" : appPlatform + " "}` +
209
+ "app to get the configuration data:";
198
210
  return await (0, prompt_1.select)({
199
- message: `Select the ${appPlatform === AppPlatform.ANY ? "" : appPlatform + " "}` +
200
- "app to get the configuration data:",
211
+ message,
201
212
  choices,
202
213
  });
203
214
  }
@@ -6,10 +6,11 @@ const apiv2_1 = require("../../apiv2");
6
6
  const error_1 = require("../../error");
7
7
  const ensureApiEnabled_1 = require("../../ensureApiEnabled");
8
8
  class OneMcpServer {
9
- constructor(feature, serverUrl, meta) {
9
+ constructor(feature, serverUrl, meta, options = {}) {
10
10
  this.feature = feature;
11
11
  this.serverUrl = serverUrl;
12
12
  this.meta = meta;
13
+ this.options = options;
13
14
  this.listClient = new apiv2_1.Client({
14
15
  urlPrefix: this.serverUrl,
15
16
  auth: false,
@@ -25,9 +26,21 @@ class OneMcpServer {
25
26
  method: "tools/list",
26
27
  jsonrpc: "2.0",
27
28
  id: 1,
29
+ }, {
30
+ headers: {
31
+ "MCP-Protocol-Version": types_js_1.LATEST_PROTOCOL_VERSION,
32
+ "Mcp-Method": "tools/list",
33
+ },
28
34
  });
29
35
  const parsed = types_js_1.ListToolsResultSchema.parse(res.body.result);
30
- return parsed.tools.map((mcpTool) => ({
36
+ const tools = parsed.tools.filter((mcpTool) => {
37
+ if (!this.options.allowedTools?.length) {
38
+ return true;
39
+ }
40
+ return (this.options.allowedTools.includes(mcpTool.name) ||
41
+ this.options.allowedTools.includes(`${this.feature}_${mcpTool.name}`));
42
+ });
43
+ return tools.map((mcpTool) => ({
31
44
  mcp: {
32
45
  ...mcpTool,
33
46
  name: `${this.feature}_${mcpTool.name}`,
@@ -42,6 +55,11 @@ class OneMcpServer {
42
55
  }
43
56
  }
44
57
  async callTool(toolName, args, ctx) {
58
+ if (this.options.allowedTools?.length &&
59
+ !this.options.allowedTools.includes(toolName) &&
60
+ !this.options.allowedTools.includes(`${this.feature}_${toolName}`)) {
61
+ throw new error_1.FirebaseError(`Tool '${toolName}' is not allowed on remote server for feature '${this.feature}'.`);
62
+ }
45
63
  await (0, ensureApiEnabled_1.ensure)(ctx.projectId, this.serverUrl, this.feature, true);
46
64
  try {
47
65
  const res = await this.callClient.post("/mcp", {
@@ -52,13 +70,14 @@ class OneMcpServer {
52
70
  },
53
71
  jsonrpc: "2.0",
54
72
  id: 1,
55
- }, ctx.projectId
56
- ? {
57
- headers: {
58
- "x-goog-user-project": ctx.projectId,
59
- },
60
- }
61
- : {});
73
+ }, {
74
+ headers: {
75
+ "MCP-Protocol-Version": types_js_1.LATEST_PROTOCOL_VERSION,
76
+ "Mcp-Method": "tools/call",
77
+ "Mcp-Name": toolName,
78
+ ...(ctx.projectId ? { "x-goog-user-project": ctx.projectId } : {}),
79
+ },
80
+ });
62
81
  return types_js_1.CallToolResultSchema.parse(res.body.result);
63
82
  }
64
83
  catch (error) {
@@ -7,6 +7,7 @@ const tool_1 = require("../../tool");
7
7
  const util_1 = require("../../util");
8
8
  const rules_1 = require("../../../gcp/rules");
9
9
  const getDefaultDatabaseInstance_1 = require("../../../getDefaultDatabaseInstance");
10
+ const streamUtils_1 = require("../../../streamUtils");
10
11
  exports.get_security_rules = (0, tool_1.tool)("core", {
11
12
  name: "get_security_rules",
12
13
  description: "Use this to retrieve the security rules for a specified Firebase service. " +
@@ -38,7 +39,7 @@ exports.get_security_rules = (0, tool_1.tool)("core", {
38
39
  if (response.status !== 200) {
39
40
  return (0, util_1.mcpError)(`Failed to fetch current rules. Code: ${response.status}`);
40
41
  }
41
- const rules = await response.response.text();
42
+ const rules = await (0, streamUtils_1.streamToString)(response.body);
42
43
  return (0, util_1.toContent)(rules);
43
44
  }
44
45
  const serviceInfo = {
package/lib/profiler.js CHANGED
@@ -55,7 +55,7 @@ async function profiler(options) {
55
55
  signal: controller.signal,
56
56
  });
57
57
  if (res.response.status >= 400) {
58
- throw (0, responseToError_1.responseToError)(res.response, await res.response.text());
58
+ throw (0, responseToError_1.responseToError)(res.response, await utils.streamToString(res.body));
59
59
  }
60
60
  if (!options.duration) {
61
61
  spinner.start();
@@ -23,13 +23,31 @@ class FunctionsServer {
23
23
  for (const cfg of config) {
24
24
  const localCfg = projectConfig.requireLocal(cfg, "Remote sources are not supported in the Functions emulator.");
25
25
  const functionsDir = path.join(options.config.projectDir, localCfg.source);
26
- backends.push({
27
- functionsDir,
28
- codebase: localCfg.codebase,
29
- runtime: localCfg.runtime,
30
- env: {},
31
- secretEnv: [],
32
- });
26
+ if (projectConfig.isKitConfig(localCfg)) {
27
+ for (const [instanceId, configDir] of Object.entries(localCfg.instances)) {
28
+ backends.push({
29
+ functionsDir,
30
+ codebase: instanceId,
31
+ prefix: projectConfig.addKitPrefix(instanceId),
32
+ configDir: path.join(options.config.projectDir, configDir),
33
+ runtime: localCfg.runtime,
34
+ env: {},
35
+ secretEnv: [],
36
+ });
37
+ }
38
+ }
39
+ else {
40
+ backends.push({
41
+ functionsDir,
42
+ codebase: localCfg.codebase,
43
+ ...(localCfg.configDir
44
+ ? { configDir: path.join(options.config.projectDir, localCfg.configDir) }
45
+ : {}),
46
+ runtime: localCfg.runtime,
47
+ env: {},
48
+ secretEnv: [],
49
+ });
50
+ }
33
51
  }
34
52
  this.backends = backends;
35
53
  const account = (0, auth_1.getProjectDefaultAccount)(options.config.projectDir);
@@ -13,6 +13,9 @@ function stringToStream(text) {
13
13
  return s;
14
14
  }
15
15
  function streamToString(s) {
16
+ if (!s) {
17
+ return Promise.resolve("");
18
+ }
16
19
  return new Promise((resolve, reject) => {
17
20
  let b = "";
18
21
  s.on("error", reject);