misc: updated est configuration to be binded to certificate template

This commit is contained in:
Sheen Capadngan
2024-08-19 19:26:20 +08:00
parent 3a4f8c2e54
commit 692bdc060c
26 changed files with 508 additions and 493 deletions
+2 -11
View File
@@ -1,20 +1,11 @@
export { CaRenewalType, CaStatus, CaType } from "./enums";
export {
useCreateCa,
useCreateCaEstConfig,
useCreateCertificate,
useDeleteCa,
useImportCaCertificate,
useRenewCa,
useSignIntermediate,
useUpdateCa,
useUpdateCaEstConfig
useUpdateCa
} from "./mutations";
export {
useGetCaById,
useGetCaCert,
useGetCaCerts,
useGetCaCrl,
useGetCaCsr,
useGetCaEstConfig
} from "./queries";
export { useGetCaById, useGetCaCert, useGetCaCerts, useGetCaCrl, useGetCaCsr } from "./queries";
+1 -29
View File
@@ -7,7 +7,6 @@ import { caKeys } from "./queries";
import {
TCertificateAuthority,
TCreateCaDTO,
TCreateCaEstConfigDTO,
TCreateCertificateDTO,
TCreateCertificateResponse,
TDeleteCaDTO,
@@ -17,8 +16,7 @@ import {
TRenewCaResponse,
TSignIntermediateDTO,
TSignIntermediateResponse,
TUpdateCaDTO,
TUpdateCaEstConfigDTO
TUpdateCaDTO
} from "./types";
export const useCreateCa = () => {
@@ -134,29 +132,3 @@ export const useRenewCa = () => {
}
});
};
export const useCreateCaEstConfig = () => {
const queryClient = useQueryClient();
return useMutation<{}, {}, TCreateCaEstConfigDTO>({
mutationFn: async (body) => {
const { data } = await apiRequest.post(`/api/v1/pki/ca/${body.caId}/est-config`, body);
return data;
},
onSuccess: (_, { caId }) => {
queryClient.invalidateQueries(caKeys.getCaEstConfig(caId));
}
});
};
export const useUpdateCaEstConfig = () => {
const queryClient = useQueryClient();
return useMutation<{}, {}, TUpdateCaEstConfigDTO>({
mutationFn: async (body) => {
const { data } = await apiRequest.patch(`/api/v1/pki/ca/${body.caId}/est-config`, body);
return data;
},
onSuccess: (_, { caId }) => {
queryClient.invalidateQueries(caKeys.getCaEstConfig(caId));
}
});
};
+1 -17
View File
@@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { TCaEstConfig, TCertificateAuthority } from "./types";
import { TCertificateAuthority } from "./types";
export const caKeys = {
getCaById: (caId: string) => [{ caId }, "ca"],
@@ -88,19 +88,3 @@ export const useGetCaCrl = (caId: string) => {
enabled: Boolean(caId)
});
};
export const useGetCaEstConfig = (caId: string) => {
return useQuery({
queryKey: caKeys.getCaEstConfig(caId),
queryFn: async () => {
const {
data: { caEstConfig }
} = await apiRequest.get<{
caEstConfig: TCaEstConfig;
}>(`/api/v1/pki/ca/${caId}/est-config`);
return caEstConfig;
},
enabled: Boolean(caId)
});
};
-20
View File
@@ -110,23 +110,3 @@ export type TRenewCaResponse = {
certificateChain: string;
serialNumber: string;
};
export type TCaEstConfig = {
caId: string;
caChain: string;
isEnabled: false;
};
export type TCreateCaEstConfigDTO = {
caId: string;
caChain: string;
passphrase: string;
isEnabled: boolean;
};
export type TUpdateCaEstConfigDTO = {
caId: string;
caChain?: string;
passphrase?: string;
isEnabled?: boolean;
};