platformservice/ts/mta/mta.classes.dkimverifier.ts
2024-02-16 13:41:04 +01:00

35 lines
932 B
TypeScript

import * as plugins from '../plugins.js';
import { MTA } from './mta.classes.mta.js';
class DKIMVerifier {
public mtaRef: MTA;
constructor(mtaRefArg: MTA) {
this.mtaRef = mtaRefArg;
}
async verify(email: string): Promise<boolean> {
console.log('Trying to verify DKIM now...');
try {
const verification = await plugins.mailauth.authenticate(email, {
/* resolver: (...args) => {
console.log(args);
} */
});
console.log(verification);
if (verification && verification.dkim.results[0].status.result === 'pass') {
console.log('DKIM Verification result: pass');
return true;
} else {
console.error('DKIM Verification failed:', verification?.error || 'Unknown error');
return false;
}
} catch (error) {
console.error('DKIM Verification failed:', error);
return false;
}
}
}
export { DKIMVerifier };