caa 11.0.1 → 11.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,6 +5,10 @@
5
5
 
6
6
  ## Usage
7
7
 
8
+ ```sh
9
+ pnpm add caa
10
+ ```
11
+
8
12
  ```js
9
13
  import {caa, caaMatches} from "caa";
10
14
 
@@ -18,7 +22,7 @@ await caaMatches("example.com", "letsencrypt.org");
18
22
  ## API
19
23
  ### `caa(name, [options])`
20
24
 
21
- Retrieve the CAA records which apply to `name`. Returns a [`CAA` object](https://github.com/mafintosh/dns-packet/#caa).
25
+ Retrieve the CAA records which apply to `name`. Returns an array of [`CAA` objects](https://github.com/mafintosh/dns-packet/#caa).
22
26
 
23
27
  ### `caaMatches(name, ca, [options])`
24
28
 
@@ -29,10 +33,8 @@ Test if the CAA record for `name` matches for certificate authority `ca`.
29
33
  - `servers`: The DNS servers to use. Defaults to the system resolvers or `['8.8.8.8', '8.8.4.4']` if none are configured.
30
34
  - `port`: The port on the DNS server to use. Default `53`.
31
35
  - `recursions`: How many recursions to follow. Default `50`.
32
- - `retries`: How many retries to attempt. Default `12`.
36
+ - `retries`: How many failed queries the whole lookup may make, shared across all names it queries. Each failure retries on the next server, and once exhausted the lookup resolves to no records. Default `12`.
33
37
  - `ignoreTLDs`: Don't query top level domains like `com` in `example.com`. Default: `false`.
34
38
  - `dnsSocket`: A [dns-socket instance](https://github.com/mafintosh/dns-socket#var-socket--dnsoptions), useful when doing a large amount of queries to re-use a single socket. Default: `undefined`.
35
39
 
36
- ## License
37
-
38
40
  © [silverwind](https://github.com/silverwind), distributed under BSD licence
package/dist/index.d.ts CHANGED
@@ -7,13 +7,12 @@ type CaaOpts = {
7
7
  servers?: Array<string>;
8
8
  dnsSocket?: any;
9
9
  };
10
- type CaaRecord = {
10
+ export type CaaRecord = {
11
11
  flags: number;
12
12
  tag: string;
13
13
  value: string;
14
14
  issuerCritical: boolean;
15
15
  };
16
- declare function caa(name: string, opts?: CaaOpts): Promise<Array<CaaRecord>>;
17
- declare function caaMatches(name: string, ca: string, opts?: CaaOpts): Promise<boolean>;
18
- //#endregion
19
- export { CaaRecord, caa, caaMatches };
16
+ export declare function caa(name: string, opts?: CaaOpts): Promise<Array<CaaRecord>>;
17
+ export declare function caaMatches(name: string, ca: string, opts?: CaaOpts): Promise<boolean>;
18
+ //#endregion
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { getServers } from "node:dns";
2
2
  import { promisify } from "node:util";
3
- import { domainToASCII } from "node:url";
3
+ import { domainToASCII, domainToUnicode } from "node:url";
4
4
  import dnsSocket from "dns-socket";
5
5
 
6
6
  //#region node_modules/.pnpm/tlds@1.261.0/node_modules/tlds/index.json
@@ -1455,7 +1455,7 @@ const defaults = {
1455
1455
  servers: ["8.8.8.8", "8.8.4.4"]
1456
1456
  };
1457
1457
  const tldSet = new Set(tlds_default);
1458
- const knownTags = new Set([
1458
+ const knownTags = /* @__PURE__ */ new Set([
1459
1459
  "issue",
1460
1460
  "issuewild",
1461
1461
  "iodef",
@@ -1464,8 +1464,8 @@ const knownTags = new Set([
1464
1464
  "accounturi",
1465
1465
  "validationmethods"
1466
1466
  ]);
1467
- const okRcodes = new Set(["NXDOMAIN", "NOERROR"]);
1468
- const isTLD = (name) => tldSet.has(name);
1467
+ const okRcodes = /* @__PURE__ */ new Set(["NXDOMAIN", "NOERROR"]);
1468
+ const isTLD = (name) => tldSet.has(name.startsWith("xn--") ? domainToUnicode(name) : name);
1469
1469
  const isWildcard = (name) => name.startsWith("*.");
1470
1470
  const parent = (name) => name.split(".").slice(1).join(".");
1471
1471
  function normalizeName(name = "") {
@@ -1480,12 +1480,8 @@ async function caa(name, opts = {}) {
1480
1480
  const recursions = opts.recursions ?? defaults.recursions;
1481
1481
  const retries = opts.retries ?? defaults.retries;
1482
1482
  const port = opts.port ?? defaults.port;
1483
- let servers;
1484
- if (opts.servers?.length) servers = opts.servers;
1485
- else {
1486
- const sys = getServers();
1487
- servers = sys.length ? sys : defaults.servers;
1488
- }
1483
+ let servers = opts.servers?.length ? opts.servers : getServers();
1484
+ if (!servers.length) servers = defaults.servers;
1489
1485
  const socket = opts.dnsSocket || dnsSocket();
1490
1486
  const query = promisify(socket.query.bind(socket));
1491
1487
  const climb = async (name, recursionsLeft, retriesLeft) => {
@@ -1502,7 +1498,7 @@ async function caa(name, opts = {}) {
1502
1498
  } catch {
1503
1499
  res = null;
1504
1500
  }
1505
- if (!res || !res.answers && !okRcodes.has(res.rcode)) return climb(name, recursionsLeft, retriesLeft - 1);
1501
+ if (!res || !res.answers?.length && !okRcodes.has(res.rcode)) return climb(name, recursionsLeft, retriesLeft - 1);
1506
1502
  const caas = [];
1507
1503
  for (const ans of res.answers || []) if (ans?.type === "CAA" && ans.data) caas.push(ans.data);
1508
1504
  if (caas.length) return caas;
@@ -1518,12 +1514,15 @@ async function caaMatches(name, ca, opts = {}) {
1518
1514
  ca = normalizeName(ca);
1519
1515
  const records = await caa(name, opts);
1520
1516
  if (!records.length) return true;
1521
- if (records.some((r) => r.issuerCritical && !knownTags.has(r.tag))) return false;
1517
+ if (records.some((r) => r.issuerCritical && !knownTags.has(r.tag.toLowerCase()))) return false;
1522
1518
  const issueNames = [];
1523
1519
  const issueWildNames = [];
1524
- for (const r of records) if (r.tag === "issue") issueNames.push(normalizeName(r.value.split(";")[0].trim()));
1525
- else if (r.tag === "issuewild") issueWildNames.push(normalizeName(r.value.split(";")[0].trim()));
1526
- const names = wildcard ? issueWildNames.length ? issueWildNames : issueNames : issueNames;
1520
+ for (const r of records) {
1521
+ const tag = r.tag.toLowerCase();
1522
+ if (tag === "issue") issueNames.push(normalizeName(r.value.split(";")[0].trim()));
1523
+ else if (tag === "issuewild") issueWildNames.push(normalizeName(r.value.split(";")[0].trim()));
1524
+ }
1525
+ const names = wildcard && issueWildNames.length ? issueWildNames : issueNames;
1527
1526
  return !names.length || names.includes(ca);
1528
1527
  }
1529
1528
 
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "caa",
3
- "version": "11.0.1",
3
+ "version": "11.0.3",
4
4
  "description": "rfc8659-conform CAA record lookup and validation",
5
5
  "author": "silverwind <me@silverwind.io>",
6
- "repository": "silverwind/caa",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/silverwind/caa.git"
9
+ },
7
10
  "license": "BSD-2-Clause",
8
11
  "type": "module",
9
12
  "sideEffects": false,
@@ -20,20 +23,19 @@
20
23
  "dns-socket": "^4.2.2"
21
24
  },
22
25
  "devDependencies": {
23
- "@types/node": "25.7.0",
24
- "@typescript/native-preview": "7.0.0-dev.20260512.1",
25
- "eslint": "10.3.0",
26
- "eslint-config-silverwind": "133.0.1",
27
- "jest-extended": "7.0.0",
26
+ "@types/node": "26.6.3",
27
+ "@typescript/native-preview": "7.0.0-dev.20260707.2",
28
+ "eslint": "10.11.0",
29
+ "eslint-config-silverwind": "151.0.1",
28
30
  "tlds": "1.261.0",
29
- "tsdown": "0.22.0",
30
- "tsdown-config-silverwind": "3.0.1",
31
+ "tsdown": "0.23.0",
32
+ "tsdown-config-silverwind": "4.1.2",
31
33
  "typescript": "6.0.3",
32
- "typescript-config-silverwind": "18.0.0",
33
- "updates": "17.16.10",
34
- "updates-config-silverwind": "3.0.2",
35
- "versions": "15.0.3",
36
- "vitest": "4.1.6",
37
- "vitest-config-silverwind": "11.3.4"
34
+ "typescript-config-silverwind": "21.0.1",
35
+ "updates": "19.0.2",
36
+ "updates-config-silverwind": "4.0.7",
37
+ "versions": "15.5.1",
38
+ "vitest": "5.0.2",
39
+ "vitest-config-silverwind": "12.0.5"
38
40
  }
39
41
  }