security.js 795 B

1234567891011121314151617181920212223
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.SecurityClient = void 0;
  4. const guards_1 = require("../guards");
  5. const http_1 = require("./http");
  6. class SecurityClient extends http_1.ResourceClient {
  7. constructor({ client, token }) {
  8. super();
  9. this.client = client;
  10. this.token = token;
  11. }
  12. async load(tag) {
  13. const { req } = await this.client.make('GET', `/security/profiles/${tag}`);
  14. this.applyAuthentication(req, this.token);
  15. req.query({}).send();
  16. const res = await this.client.do(req);
  17. if (!(0, guards_1.isSecurityProfileResponse)(res)) {
  18. throw (0, http_1.createFatalAPIFormat)(req, res);
  19. }
  20. return res.data;
  21. }
  22. }
  23. exports.SecurityClient = SecurityClient;