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 ({
24 skipVerificationOfExternalDomains,
28 const ktActivation = await getKTActivation();
29 if (ktActivation === KeyTransparencyActivation.DISABLED) {
32 return verifyPublicKeysAddressAndCatchall({
33 userContext: userContext ?? {
42 skipVerificationOfExternalDomains,
46 ktSentryReportError(error, { context: 'VerifyOutboundPublicKeys' });
51 return verifyOutboundPublicKeys;
54 export default useVerifyOutboundPublicKeys;