Skip to content

Commit

Permalink
fix: worker DNS check for SPF
Browse files Browse the repository at this point in the history
  • Loading branch information
BlankParticle committed Aug 26, 2024
1 parent 2dde482 commit e7c669e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/worker/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { z } from 'zod';

export const env = createEnv({
server: {
PRIMARY_DOMAIN: z.string(),
PLATFORM_URL: z.string().url(),
DB_REDIS_CONNECTION_STRING: z.string().min(1),
WORKER_ACCESS_KEY: z.string().min(32),
Expand Down
2 changes: 1 addition & 1 deletion apps/worker/functions/check-dns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function checkDns(publicId: TypeId<'domains'>) {
value: domainInfo.verificationToken
},
spf: {
includes: `_spf.${domainInfo.postalHost}`
includes: [`_spf.${env.PRIMARY_DOMAIN}`]
},
dkim: {
key: domainInfo.dkimKey,
Expand Down
5 changes: 3 additions & 2 deletions packages/utils/dns/verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ExpectedDnsRecords = {
priority: number;
};
spf: {
includes: string;
includes: string[];
};
dkim: {
key: string | null;
Expand Down Expand Up @@ -72,7 +72,8 @@ export async function dnsVerifier({ rootDomain, expected }: DnsVerifierInput) {
spfTxtRecords.data.find((_) => _.startsWith('v=spf1')) ?? ''
);
results.spf.valid =
!!spfRecords && spfRecords.includes.includes(expected.spf.includes);
!!spfRecords &&
expected.spf.includes.some((_) => spfRecords.includes.includes(_));
results.spf.current = spfRecords;
}

Expand Down

0 comments on commit e7c669e

Please sign in to comment.