fix(meta): type improvements

This commit is contained in:
2025-03-15 13:52:48 +00:00
parent 2b207833ce
commit c084de9c78
6 changed files with 243 additions and 120 deletions

View File

@ -16,7 +16,7 @@ export interface IKeyPaths {
export class DKIMCreator {
private keysDir: string;
constructor(metaRef: MtaService, keysDir = paths.keysDir) {
constructor(private metaRef: MtaService, keysDir = paths.keysDir) {
this.keysDir = keysDir;
}
@ -60,8 +60,8 @@ export class DKIMCreator {
return { privateKey, publicKey };
}
// Create a DKIM key pair
private async createDKIMKeys(): Promise<{ privateKey: string; publicKey: string }> {
// Create a DKIM key pair - changed to public for API access
public async createDKIMKeys(): Promise<{ privateKey: string; publicKey: string }> {
const { privateKey, publicKey } = await generateKeyPair('rsa', {
modulusLength: 2048,
publicKeyEncoding: { type: 'spki', format: 'pem' },
@ -71,8 +71,8 @@ export class DKIMCreator {
return { privateKey, publicKey };
}
// Store a DKIM key pair to disk
private async storeDKIMKeys(
// Store a DKIM key pair to disk - changed to public for API access
public async storeDKIMKeys(
privateKey: string,
publicKey: string,
privateKeyPath: string,
@ -81,8 +81,8 @@ export class DKIMCreator {
await Promise.all([writeFile(privateKeyPath, privateKey), writeFile(publicKeyPath, publicKey)]);
}
// Create a DKIM key pair and store it to disk
private async createAndStoreDKIMKeys(domain: string): Promise<void> {
// Create a DKIM key pair and store it to disk - changed to public for API access
public async createAndStoreDKIMKeys(domain: string): Promise<void> {
const { privateKey, publicKey } = await this.createDKIMKeys();
const keyPaths = await this.getKeyPathsForDomain(domain);
await this.storeDKIMKeys(
@ -94,7 +94,8 @@ export class DKIMCreator {
console.log(`DKIM keys for ${domain} created and stored.`);
}
private async getDNSRecordForDomain(domainArg: string): Promise<plugins.tsclass.network.IDnsRecord> {
// Changed to public for API access
public async getDNSRecordForDomain(domainArg: string): Promise<plugins.tsclass.network.IDnsRecord> {
await this.handleDKIMKeysForDomain(domainArg);
const keys = await this.readDKIMKeys(domainArg);
@ -116,4 +117,4 @@ export class DKIMCreator {
value: dnsRecordValue,
};
}
}
}