Няма описание
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.

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getTrustedPublishers = exports.getExtensionRegistry = void 0;
  4. const logger_1 = require("../logger");
  5. const apiv2_1 = require("../apiv2");
  6. const api_1 = require("../api");
  7. const EXTENSIONS_REGISTRY_ENDPOINT = "/extensions.json";
  8. async function getExtensionRegistry(onlyFeatured = false) {
  9. var _a;
  10. const client = new apiv2_1.Client({ urlPrefix: api_1.firebaseExtensionsRegistryOrigin });
  11. const res = await client.get(EXTENSIONS_REGISTRY_ENDPOINT);
  12. const extensions = res.body.mods || {};
  13. if (onlyFeatured) {
  14. const featuredList = new Set(((_a = res.body.featured) === null || _a === void 0 ? void 0 : _a.discover) || []);
  15. const filteredExtensions = {};
  16. for (const [name, extension] of Object.entries(extensions)) {
  17. if (featuredList.has(name)) {
  18. filteredExtensions[name] = extension;
  19. }
  20. }
  21. return filteredExtensions;
  22. }
  23. return extensions;
  24. }
  25. exports.getExtensionRegistry = getExtensionRegistry;
  26. async function getTrustedPublishers() {
  27. let registry;
  28. try {
  29. registry = await getExtensionRegistry();
  30. }
  31. catch (err) {
  32. logger_1.logger.debug("Couldn't get extensions registry, assuming no trusted publishers except Firebase.");
  33. return ["firebase"];
  34. }
  35. const publisherIds = new Set();
  36. for (const entry in registry) {
  37. publisherIds.add(registry[entry].publisher);
  38. }
  39. return Array.from(publisherIds);
  40. }
  41. exports.getTrustedPublishers = getTrustedPublishers;