caa 11.0.2 → 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 +6 -4
- package/dist/index.js +11 -12
- package/package.json +9 -10
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
|
|
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
|
|
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.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
|
|
@@ -1465,7 +1465,7 @@ const knownTags = /* @__PURE__ */ new Set([
|
|
|
1465
1465
|
"validationmethods"
|
|
1466
1466
|
]);
|
|
1467
1467
|
const okRcodes = /* @__PURE__ */ new Set(["NXDOMAIN", "NOERROR"]);
|
|
1468
|
-
const isTLD = (name) => tldSet.has(name);
|
|
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 (
|
|
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,11 +1514,14 @@ 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)
|
|
1525
|
-
|
|
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
|
+
}
|
|
1526
1525
|
const names = wildcard && issueWildNames.length ? issueWildNames : issueNames;
|
|
1527
1526
|
return !names.length || names.includes(ca);
|
|
1528
1527
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caa",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.3",
|
|
4
4
|
"description": "rfc8659-conform CAA record lookup and validation",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"repository": {
|
|
@@ -23,20 +23,19 @@
|
|
|
23
23
|
"dns-socket": "^4.2.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/node": "26.6.
|
|
26
|
+
"@types/node": "26.6.3",
|
|
27
27
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
28
28
|
"eslint": "10.11.0",
|
|
29
|
-
"eslint-config-silverwind": "151.0.
|
|
30
|
-
"jest-extended": "7.0.0",
|
|
29
|
+
"eslint-config-silverwind": "151.0.1",
|
|
31
30
|
"tlds": "1.261.0",
|
|
32
31
|
"tsdown": "0.23.0",
|
|
33
|
-
"tsdown-config-silverwind": "4.1.
|
|
32
|
+
"tsdown-config-silverwind": "4.1.2",
|
|
34
33
|
"typescript": "6.0.3",
|
|
35
|
-
"typescript-config-silverwind": "21.0.
|
|
36
|
-
"updates": "19.0.
|
|
37
|
-
"updates-config-silverwind": "4.0.
|
|
38
|
-
"versions": "15.5.
|
|
34
|
+
"typescript-config-silverwind": "21.0.1",
|
|
35
|
+
"updates": "19.0.2",
|
|
36
|
+
"updates-config-silverwind": "4.0.7",
|
|
37
|
+
"versions": "15.5.1",
|
|
39
38
|
"vitest": "5.0.2",
|
|
40
|
-
"vitest-config-silverwind": "12.0.
|
|
39
|
+
"vitest-config-silverwind": "12.0.5"
|
|
41
40
|
}
|
|
42
41
|
}
|