@vlayer/sdk 0.1.0-nightly-20241125-3bf0279 → 0.1.0-nightly-20241125-736efe7

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,5 +2,12 @@ import DnsResolver from "dns-over-http-resolver";
2
2
  export async function resolveDkimDns(domain, selector) {
3
3
  const resolver = new DnsResolver();
4
4
  const address = await resolver.resolveTxt(`${selector}._domainkey.${domain}`);
5
- return address.flat()[0];
5
+ let record = address.flat().at(-1);
6
+ if (!record) {
7
+ throw new Error("No DKIM DNS record found");
8
+ }
9
+ if (record?.startsWith("p=")) {
10
+ record = ["v=DKIM1", "k=rsa", record].join("; ");
11
+ }
12
+ return record;
6
13
  }
@@ -6,6 +6,11 @@ describe("resolveDkimDns Integration", () => {
6
6
  const expected = "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3gWcOhCm99qzN+h7/2+LeP3CLsJkQQ4EP/2mrceXle5pKq8uZmBl1U4d2Vxn4w+pWFANDLmcHolLboESLFqEL5N6ae7u9b236dW4zn9AFkXAGenTzQEeif9VUFtLAZ0Qh2eV7OQgz/vPj5IaNqJ7h9hpM9gO031fe4v+J0DLCE8Rgo7hXbNgJavctc0983DaCDQaznHZ44LZ6TtZv9TBs+QFvsy4+UCTfsuOtHzoEqOOuXsVXZKLP6B882XbEnBpXEF8QzV4J26HiAJFUbO3mAqZL2UeKC0hhzoIZqZXNG0BfuzOF0VLpDa18GYMUiu+LhEJPJO9D8zhzvQIHNrpGwIDAQAB";
7
7
  expect(resolved).toBe(expected);
8
8
  });
9
+ test("resolves delegated dns", async () => {
10
+ const resolved = await resolveDkimDns("bolt.eu", "el7njvpsjxbr7wk7l7dss5ejzvijzoeu");
11
+ const expected = "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQxwOEYMZS2rPORBB94iL47Ute8zb1SUNl7K0zCQMk+M83AJHcwKjnJVhA4F0rLbSxY7cxJgl57lN4Vp5k10HHOil00oIn1S0ChBKHiFCQAMHCNonwDOdJa6mXwe2VwEM7hnVpRc/Eo0F0acpNMeYJxyLcTcOuZBNzcPm6t+4uTwIDAQAB";
12
+ expect(resolved).toBe(expected);
13
+ });
9
14
  test("throws error if dns not found", async () => {
10
15
  await expect(resolveDkimDns("not-a-domain.com", "abcd")).rejects.toThrow();
11
16
  });
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "types": "./dist/config/index.d.ts"
16
16
  }
17
17
  },
18
- "version": "0.1.0-nightly-20241125-3bf0279",
18
+ "version": "0.1.0-nightly-20241125-736efe7",
19
19
  "scripts": {
20
20
  "build": "bun tsc && bun tsc-alias",
21
21
  "test:unit": "vitest --run",