fleet/frontend/services/entities/config.ts
Martavis Parker cfb1474eb8
Auth Redux Removal (#4924)
* all login methods no longer use redux

* removed redux from registration

* redirect user from registration

* removed redux from sso invite

* removed redundant component

* refactored user settings page

* removed redux from logout

* cleaned up unused redux calls

* lint fixes

* removed test

* removed old config interface

* fixed registration bug

* team permission fix

* removed remaining redux references from pages - #4436

* better way to set config
2022-04-07 09:08:00 -07:00

43 lines
1.1 KiB
TypeScript

/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import sendRequest from "services";
import endpoints from "fleet/endpoints";
import { IConfig } from "interfaces/config";
export default {
loadAll: (): Promise<IConfig> => {
const { CONFIG } = endpoints;
const path = `${CONFIG}`;
return sendRequest("GET", path);
},
loadCertificate: () => {
const { CONFIG } = endpoints;
const path = `${CONFIG}/certificate`;
return sendRequest("GET", path).then(({ certificate_chain }) => {
let decodedCertificate;
try {
decodedCertificate = global.window.atob(certificate_chain);
} catch (err) {
return Promise.reject(`Unable to decode certificate: ${err}`);
}
if (!decodedCertificate) {
return Promise.reject("Missing or undefined certificate.");
}
return Promise.resolve(decodedCertificate);
});
},
loadEnrollSecret: () => {
const { GLOBAL_ENROLL_SECRETS } = endpoints;
return sendRequest("GET", GLOBAL_ENROLL_SECRETS);
},
update: (formData: any) => {
const { CONFIG } = endpoints;
return sendRequest("PATCH", CONFIG, formData);
},
};