7 verifyAddressIsObsolete,
8 } from '@proton/key-transparency/lib';
10 import type { KeyMigrationKTVerifier } from '../interfaces';
11 import { KeyTransparencyActivation } from '../interfaces';
13 const createKeyMigrationKTVerifier = (ktActivation: KeyTransparencyActivation): KeyMigrationKTVerifier => {
14 return async ({ email, signedKeyList, api }) => {
15 if (ktActivation === KeyTransparencyActivation.DISABLED) {
19 const epoch = await fetchLatestEpoch(api);
20 if (signedKeyList?.ObsolescenceToken) {
21 await verifyAddressIsObsolete(epoch, email, signedKeyList, api);
23 await verifyAddressIsAbsent(epoch, email, api);
25 } catch (error: any) {
26 if (error instanceof KeyTransparencyError) {
27 ktSentryReport('KT error during key migration', { error: error.message });
29 ktSentryReportError(error, { context: 'KeyMigrationKTVerifier' });
35 export default createKeyMigrationKTVerifier;