No Description
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.

identityPlatform.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.updateConfig = exports.setBlockingFunctionsConfig = exports.getConfig = exports.getBlockingFunctionsConfig = void 0;
  4. const proto = require("./proto");
  5. const api_1 = require("../api");
  6. const apiv2_1 = require("../apiv2");
  7. const API_VERSION = "v2";
  8. const adminApiClient = new apiv2_1.Client({
  9. urlPrefix: api_1.identityOrigin + "/admin",
  10. apiVersion: API_VERSION,
  11. });
  12. async function getBlockingFunctionsConfig(project) {
  13. const config = (await getConfig(project)) || {};
  14. if (!config.blockingFunctions) {
  15. config.blockingFunctions = {};
  16. }
  17. return config.blockingFunctions;
  18. }
  19. exports.getBlockingFunctionsConfig = getBlockingFunctionsConfig;
  20. async function getConfig(project) {
  21. const response = await adminApiClient.get(`projects/${project}/config`);
  22. return response.body;
  23. }
  24. exports.getConfig = getConfig;
  25. async function setBlockingFunctionsConfig(project, blockingConfig) {
  26. const config = (await updateConfig(project, { blockingFunctions: blockingConfig }, "blockingFunctions")) || {};
  27. if (!config.blockingFunctions) {
  28. config.blockingFunctions = {};
  29. }
  30. return config.blockingFunctions;
  31. }
  32. exports.setBlockingFunctionsConfig = setBlockingFunctionsConfig;
  33. async function updateConfig(project, config, updateMask) {
  34. if (!updateMask) {
  35. updateMask = proto.fieldMasks(config).join(",");
  36. }
  37. const response = await adminApiClient.patch(`projects/${project}/config`, config, {
  38. queryParams: {
  39. updateMask,
  40. },
  41. });
  42. return response.body;
  43. }
  44. exports.updateConfig = updateConfig;