From 94cb7eaa3350bb9dfd6c94f2a9a2be0cae24f2dc Mon Sep 17 00:00:00 2001 From: Alireza Hassani Date: Fri, 18 Sep 2026 14:45:09 +0330 Subject: [PATCH] Accept bare DKIM public-key pastes without v=DKIM1 prefix. Co-authored-by: Cursor --- src/mail-dns/mail-dns.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mail-dns/mail-dns.ts b/src/mail-dns/mail-dns.ts index 32a72de..d3913b9 100644 --- a/src/mail-dns/mail-dns.ts +++ b/src/mail-dns/mail-dns.ts @@ -44,9 +44,18 @@ export function parseDkimPaste( let text = (txtMatch ? txtMatch[0] : blob).trim(); text = text.replace(/^"+|"+$/g, '').replace(/\s+/g, ' ').replace(/[.\s]+$/g, '').trim(); if (!/^v=DKIM1/i.test(text)) { - throw new Error( - `Could not find a v=DKIM1 value in the ${expectedKind} field. Paste the TXT value or Stalwart zone line.`, - ); + // Stalwart sometimes copies only the public key / p=… body. + const bare = text.replace(/^p=/i, '').replace(/\s+/g, ''); + if (/^[A-Za-z0-9+/=]+$/.test(bare) && bare.length >= 20) { + text = + expectedKind === 'ed25519' + ? `v=DKIM1; k=ed25519; h=sha256; p=${bare}` + : `v=DKIM1; k=rsa; h=sha256; p=${bare}`; + } else { + throw new Error( + `Could not find a v=DKIM1 value in the ${expectedKind} field. Paste the TXT value or Stalwart zone line.`, + ); + } } const kind = /k=ed25519/i.test(text)