mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 01:52:22 +00:00
misc: addressed comments
This commit is contained in:
@@ -4,10 +4,12 @@ export {
|
||||
useCreateCertificate,
|
||||
useCreateUnifiedCa,
|
||||
useDeleteCa,
|
||||
useDeleteUnifiedCa,
|
||||
useImportCaCertificate,
|
||||
useRenewCa,
|
||||
useSignIntermediate,
|
||||
useUpdateCa
|
||||
useUpdateCa,
|
||||
useUpdateUnifiedCa
|
||||
} from "./mutations";
|
||||
export {
|
||||
useGetCaById,
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
TCreateCertificateResponse,
|
||||
TCreateUnifiedCertificateAuthorityDTO,
|
||||
TDeleteCaDTO,
|
||||
TDeleteUnifiedCertificateAuthorityDTO,
|
||||
TImportCaCertificateDTO,
|
||||
TImportCaCertificateResponse,
|
||||
TRenewCaDTO,
|
||||
@@ -18,9 +19,31 @@ import {
|
||||
TSignIntermediateDTO,
|
||||
TSignIntermediateResponse,
|
||||
TUnifiedCertificateAuthority,
|
||||
TUpdateCaDTO
|
||||
TUpdateCaDTO,
|
||||
TUpdateUnifiedCertificateAuthorityDTO
|
||||
} from "./types";
|
||||
|
||||
export const useUpdateUnifiedCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TUnifiedCertificateAuthority, object, TUpdateUnifiedCertificateAuthorityDTO>({
|
||||
mutationFn: async ({ id, ...body }) => {
|
||||
const {
|
||||
data: { certificateAuthority }
|
||||
} = await apiRequest.patch<{ certificateAuthority: TUnifiedCertificateAuthority }>(
|
||||
`/api/v1/pki/ca/${body.type}/${id}`,
|
||||
body
|
||||
);
|
||||
|
||||
return certificateAuthority;
|
||||
},
|
||||
onSuccess: ({ projectId, type }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: caKeys.listCasByTypeAndProjectId(type, projectId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useCreateUnifiedCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TUnifiedCertificateAuthority, object, TCreateUnifiedCertificateAuthorityDTO>({
|
||||
@@ -39,6 +62,25 @@ export const useCreateUnifiedCa = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteUnifiedCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TUnifiedCertificateAuthority, object, TDeleteUnifiedCertificateAuthorityDTO>({
|
||||
mutationFn: async ({ caId, type }) => {
|
||||
const {
|
||||
data: { certificateAuthority }
|
||||
} = await apiRequest.delete<{ certificateAuthority: TUnifiedCertificateAuthority }>(
|
||||
`/api/v1/pki/ca/${type}/${caId}`
|
||||
);
|
||||
return certificateAuthority;
|
||||
},
|
||||
onSuccess: (_, { type, projectId }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: caKeys.listCasByTypeAndProjectId(type, projectId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useCreateCa = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TCertificateAuthority, object, TCreateCaDTO>({
|
||||
|
||||
@@ -10,7 +10,10 @@ export type TAcmeCertificateAuthority = {
|
||||
disableDirectIssuance: boolean;
|
||||
configuration: {
|
||||
dnsAppConnectionId: string;
|
||||
dnsProvider: AcmeDnsProvider;
|
||||
dnsProviderConfig: {
|
||||
provider: AcmeDnsProvider.ROUTE53;
|
||||
hostedZoneId: string;
|
||||
};
|
||||
directoryUrl: string;
|
||||
accountEmail: string;
|
||||
};
|
||||
@@ -48,6 +51,16 @@ export type TUnifiedCertificateAuthority =
|
||||
| TInternalCertificateAuthority;
|
||||
|
||||
export type TCreateUnifiedCertificateAuthorityDTO = Omit<TUnifiedCertificateAuthority, "id">;
|
||||
export type TUpdateUnifiedCertificateAuthorityDTO = Partial<TUnifiedCertificateAuthority> & {
|
||||
id: string;
|
||||
type: CaType;
|
||||
};
|
||||
|
||||
export type TDeleteUnifiedCertificateAuthorityDTO = {
|
||||
caId: string;
|
||||
type: CaType;
|
||||
projectId: string;
|
||||
};
|
||||
|
||||
export type TCertificateAuthority = {
|
||||
id: string;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { TReactQueryOptions } from "@app/types/reactQuery";
|
||||
|
||||
import { TCertificate } from "../certificates/types";
|
||||
import { TPkiSubscriber } from "./types";
|
||||
@@ -62,17 +63,20 @@ export const useGetPkiSubscriber = ({
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetPkiSubscriberCertificates = ({
|
||||
subscriberName,
|
||||
projectId,
|
||||
offset,
|
||||
limit
|
||||
}: {
|
||||
subscriberName: string;
|
||||
projectId: string;
|
||||
offset: number;
|
||||
limit: number;
|
||||
}) => {
|
||||
export const useGetPkiSubscriberCertificates = (
|
||||
{
|
||||
subscriberName,
|
||||
projectId,
|
||||
offset,
|
||||
limit
|
||||
}: {
|
||||
subscriberName: string;
|
||||
projectId: string;
|
||||
offset: number;
|
||||
limit: number;
|
||||
},
|
||||
options?: TReactQueryOptions["options"]
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: pkiSubscriberKeys.specificPkiSubscriberCertificates({
|
||||
subscriberName,
|
||||
@@ -97,6 +101,7 @@ export const useGetPkiSubscriberCertificates = ({
|
||||
);
|
||||
return { certificates, totalCount };
|
||||
},
|
||||
enabled: Boolean(subscriberName) && Boolean(projectId)
|
||||
enabled: Boolean(subscriberName) && Boolean(projectId),
|
||||
...options
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user