Нема описа
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.requirePermissions = void 0;
  4. const colorette_1 = require("colorette");
  5. const projectUtils_1 = require("./projectUtils");
  6. const requireAuth_1 = require("./requireAuth");
  7. const logger_1 = require("./logger");
  8. const error_1 = require("./error");
  9. const iam_1 = require("./gcp/iam");
  10. const BASE_PERMISSIONS = ["firebase.projects.get"];
  11. async function requirePermissions(options, permissions = []) {
  12. const projectId = (0, projectUtils_1.getProjectId)(options);
  13. if (!projectId) {
  14. return;
  15. }
  16. const requiredPermissions = BASE_PERMISSIONS.concat(permissions).sort();
  17. await (0, requireAuth_1.requireAuth)(options);
  18. logger_1.logger.debug(`[iam] checking project ${projectId} for permissions ${JSON.stringify(requiredPermissions)}`);
  19. try {
  20. const iamResult = await (0, iam_1.testIamPermissions)(projectId, requiredPermissions);
  21. if (!iamResult.passed) {
  22. throw new error_1.FirebaseError(`Authorization failed. This account is missing the following required permissions on project ${(0, colorette_1.bold)(projectId)}:\n\n ${iamResult.missing.join("\n ")}`);
  23. }
  24. }
  25. catch (err) {
  26. logger_1.logger.debug(`[iam] error while checking permissions, command may fail: ${err}`);
  27. return;
  28. }
  29. }
  30. exports.requirePermissions = requirePermissions;