GSI - Employe Self Service Mobile
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.

29 lines
1.4 KiB

2 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const clc = require("colorette");
  5. const command_1 = require("../command");
  6. const projectUtils_1 = require("../projectUtils");
  7. const apps_1 = require("../management/apps");
  8. const requireAuth_1 = require("../requireAuth");
  9. const utils_1 = require("../utils");
  10. function getCertHashType(shaHash) {
  11. shaHash = shaHash.replace(/:/g, "");
  12. const shaHashCount = shaHash.length;
  13. if (shaHashCount === 40)
  14. return apps_1.ShaCertificateType.SHA_1.toString();
  15. if (shaHashCount === 64)
  16. return apps_1.ShaCertificateType.SHA_256.toString();
  17. return apps_1.ShaCertificateType.SHA_CERTIFICATE_TYPE_UNSPECIFIED.toString();
  18. }
  19. exports.command = new command_1.Command("apps:android:sha:create <appId> <shaHash>")
  20. .description("add a SHA certificate hash for a given app id.")
  21. .before(requireAuth_1.requireAuth)
  22. .action(async (appId = "", shaHash = "", options) => {
  23. const projectId = (0, projectUtils_1.needProjectId)(options);
  24. const shaCertificate = await (0, utils_1.promiseWithSpinner)(async () => await (0, apps_1.createAppAndroidSha)(projectId, appId, {
  25. shaHash: shaHash,
  26. certType: getCertHashType(shaHash),
  27. }), `Creating Android SHA certificate ${clc.bold(options.shaHash)}with Android app Id ${clc.bold(appId)}`);
  28. return shaCertificate;
  29. });