Preliminary scaffolding for CA structures

This commit is contained in:
Tuan Dang
2024-05-22 21:33:06 -07:00
parent 303edadb1e
commit 26ea949a4e
41 changed files with 1656 additions and 8 deletions
+6
View File
@@ -0,0 +1,6 @@
import { CertificateAuthorityType } from "./enums";
export const caTypeToNameMap: { [K in CertificateAuthorityType]: string } = {
[CertificateAuthorityType.ROOT]: "Root",
[CertificateAuthorityType.INTERMEDIATE]: "Intermediate"
};
+4
View File
@@ -0,0 +1,4 @@
export enum CertificateAuthorityType {
ROOT = "root",
INTERMEDIATE = "intermediate"
}
+2
View File
@@ -0,0 +1,2 @@
export { CertificateAuthorityType } from "./enums";
export { useCreateCa } from "./mutations";
+23
View File
@@ -0,0 +1,23 @@
import {
useMutation
// useQueryClient
} from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { TCertificateAuthority, TCreateCaDTO } from "./types";
export const useCreateCa = () => {
// const queryClient = useQueryClient();
return useMutation<TCertificateAuthority, {}, TCreateCaDTO>({
mutationFn: async (body) => {
const {
data: { identity }
} = await apiRequest.post("/api/v1/ca/", body);
return identity;
},
onSuccess: () => {
// queryClient.invalidateQueries(organizationKeys.getOrgIdentityMemberships(organizationId));
}
});
};
+23
View File
@@ -0,0 +1,23 @@
import { CertificateAuthorityType } from "./enums";
export type TCertificateAuthority = {
id: string;
parentCaId?: string;
projectId: string;
type: CertificateAuthorityType;
dn: string;
commonName: string;
createdAt: string;
updatedAt: string;
};
export type TCreateCaDTO = {
projectSlug: string;
type: string;
organization: string;
ou: string;
country: string;
province: string;
locality: string;
commonName: string;
};