Remove payments API routing initialization
[ProtonMail-WebClient.git] / packages / components / containers / keyTransparency / useVerifyOutboundPublicKeys.ts
blob8bdf91e89bcf29bb8bb72b0cb0d232dbd595bd7c
1 import { useGetAddressKeys } from '@proton/account/addressKeys/hooks';
2 import { useGetUser } from '@proton/account/user/hooks';
3 import { useGetUserKeys } from '@proton/account/userKeys/hooks';
4 import { useGetKTActivation } from '@proton/components/containers/keyTransparency/useKTActivation';
5 import useConfig from '@proton/components/hooks/useConfig';
6 import { ktSentryReportError, verifyPublicKeysAddressAndCatchall } from '@proton/key-transparency/lib';
7 import type { VerifyOutboundPublicKeys } from '@proton/shared/lib/interfaces';
8 import { KeyTransparencyActivation } from '@proton/shared/lib/interfaces';
10 import useGetLatestEpoch from './useGetLatestEpoch';
12 const useVerifyOutboundPublicKeys = () => {
13     const getKTActivation = useGetKTActivation();
14     const getLatestEpoch = useGetLatestEpoch();
15     const getUserKeys = useGetUserKeys();
16     const getUser = useGetUser();
17     const getAddressKeys = useGetAddressKeys();
18     const { APP_NAME } = useConfig();
20     const verifyOutboundPublicKeys: VerifyOutboundPublicKeys = async ({
21         userContext,
22         api,
23         email,
24         skipVerificationOfExternalDomains,
25         address,
26         catchAll,
27     }) => {
28         const ktActivation = await getKTActivation();
29         if (ktActivation === KeyTransparencyActivation.DISABLED) {
30             return {};
31         }
32         return verifyPublicKeysAddressAndCatchall({
33             userContext: userContext ?? {
34                 appName: APP_NAME,
35                 getUserKeys,
36                 getAddressKeys,
37                 getUser,
38             },
39             api,
40             getLatestEpoch,
41             email,
42             skipVerificationOfExternalDomains,
43             address,
44             catchAll,
45         }).catch((error) => {
46             ktSentryReportError(error, { context: 'VerifyOutboundPublicKeys' });
47             return {};
48         });
49     };
51     return verifyOutboundPublicKeys;
54 export default useVerifyOutboundPublicKeys;