mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 05:13:43 +00:00
114 lines
3.6 KiB
TypeScript
114 lines
3.6 KiB
TypeScript
import { useQuery } from "@tanstack/react-query";
|
|
|
|
import { apiRequest } from "@app/config/request";
|
|
|
|
import {
|
|
ClientSecretData,
|
|
IdentityAwsAuth,
|
|
IdentityAzureAuth,
|
|
IdentityGcpAuth,
|
|
IdentityKubernetesAuth,
|
|
IdentityUniversalAuth} from "./types";
|
|
|
|
export const identitiesKeys = {
|
|
getIdentityUniversalAuth: (identityId: string) =>
|
|
[{ identityId }, "identity-universal-auth"] as const,
|
|
getIdentityUniversalAuthClientSecrets: (identityId: string) =>
|
|
[{ identityId }, "identity-universal-auth-client-secrets"] as const,
|
|
getIdentityKubernetesAuth: (identityId: string) =>
|
|
[{ identityId }, "identity-kubernetes-auth"] as const,
|
|
getIdentityGcpAuth: (identityId: string) => [{ identityId }, "identity-gcp-auth"] as const,
|
|
getIdentityAwsAuth: (identityId: string) => [{ identityId }, "identity-aws-auth"] as const,
|
|
getIdentityAzureAuth: (identityId: string) => [{ identityId }, "identity-azure-auth"] as const
|
|
};
|
|
|
|
export const useGetIdentityUniversalAuth = (identityId: string) => {
|
|
return useQuery({
|
|
enabled: Boolean(identityId),
|
|
queryKey: identitiesKeys.getIdentityUniversalAuth(identityId),
|
|
queryFn: async () => {
|
|
const {
|
|
data: { identityUniversalAuth }
|
|
} = await apiRequest.get<{ identityUniversalAuth: IdentityUniversalAuth }>(
|
|
`/api/v1/auth/universal-auth/identities/${identityId}`
|
|
);
|
|
return identityUniversalAuth;
|
|
}
|
|
});
|
|
};
|
|
|
|
export const useGetIdentityUniversalAuthClientSecrets = (identityId: string) => {
|
|
return useQuery({
|
|
enabled: Boolean(identityId),
|
|
queryKey: identitiesKeys.getIdentityUniversalAuthClientSecrets(identityId),
|
|
queryFn: async () => {
|
|
const {
|
|
data: { clientSecretData }
|
|
} = await apiRequest.get<{ clientSecretData: ClientSecretData[] }>(
|
|
`/api/v1/auth/universal-auth/identities/${identityId}/client-secrets`
|
|
);
|
|
return clientSecretData;
|
|
}
|
|
});
|
|
};
|
|
|
|
export const useGetIdentityGcpAuth = (identityId: string) => {
|
|
return useQuery({
|
|
enabled: Boolean(identityId),
|
|
queryKey: identitiesKeys.getIdentityGcpAuth(identityId),
|
|
queryFn: async () => {
|
|
const {
|
|
data: { identityGcpAuth }
|
|
} = await apiRequest.get<{ identityGcpAuth: IdentityGcpAuth }>(
|
|
`/api/v1/auth/gcp-auth/identities/${identityId}`
|
|
);
|
|
return identityGcpAuth;
|
|
}
|
|
});
|
|
};
|
|
|
|
export const useGetIdentityAwsAuth = (identityId: string) => {
|
|
return useQuery({
|
|
enabled: Boolean(identityId),
|
|
queryKey: identitiesKeys.getIdentityAwsAuth(identityId),
|
|
queryFn: async () => {
|
|
const {
|
|
data: { identityAwsAuth }
|
|
} = await apiRequest.get<{ identityAwsAuth: IdentityAwsAuth }>(
|
|
`/api/v1/auth/aws-auth/identities/${identityId}`
|
|
);
|
|
return identityAwsAuth;
|
|
}
|
|
});
|
|
};
|
|
|
|
export const useGetIdentityAzureAuth = (identityId: string) => {
|
|
return useQuery({
|
|
enabled: Boolean(identityId),
|
|
queryKey: identitiesKeys.getIdentityAzureAuth(identityId),
|
|
queryFn: async () => {
|
|
const {
|
|
data: { identityAzureAuth }
|
|
} = await apiRequest.get<{ identityAzureAuth: IdentityAzureAuth }>(
|
|
`/api/v1/auth/azure-auth/identities/${identityId}`
|
|
);
|
|
return identityAzureAuth;
|
|
}
|
|
});
|
|
};
|
|
|
|
export const useGetIdentityKubernetesAuth = (identityId: string) => {
|
|
return useQuery({
|
|
enabled: Boolean(identityId),
|
|
queryKey: identitiesKeys.getIdentityKubernetesAuth(identityId),
|
|
queryFn: async () => {
|
|
const {
|
|
data: { identityKubernetesAuth }
|
|
} = await apiRequest.get<{ identityKubernetesAuth: IdentityKubernetesAuth }>(
|
|
`/api/v1/auth/kubernetes-auth/identities/${identityId}`
|
|
);
|
|
return identityKubernetesAuth;
|
|
}
|
|
});
|
|
};
|