caa 6.0.5 → 8.0.0

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.
Files changed (3) hide show
  1. package/README.md +4 -4
  2. package/index.js +10 -11
  3. package/package.json +11 -16
package/README.md CHANGED
@@ -9,12 +9,12 @@
9
9
  npm i caa
10
10
  ```
11
11
  ```js
12
- const caa = require('caa');
12
+ import {caa, caaMatches} from "caa";
13
13
 
14
- await caa('subdomain.example.com');
14
+ await caa("subdomain.example.com");
15
15
  // => [{flags: 0, tag: 'issue', value: 'letsencrypt.org', issuerCritical: false}]
16
16
 
17
- await caa.matches('subdomain.example.com', 'letsencrypt.org');
17
+ await caa.matches("subdomain.example.com", "letsencrypt.org");
18
18
  // => true
19
19
 
20
20
  ```
@@ -24,7 +24,7 @@ await caa.matches('subdomain.example.com', 'letsencrypt.org');
24
24
 
25
25
  Retrieve the CAA records which apply to `name`. Returns a [`CAA` object](https://github.com/mafintosh/dns-packet/#caa).
26
26
 
27
- ### `caa.matches(name, ca, [options])`
27
+ ### `caaMatches(name, ca, [options])`
28
28
 
29
29
  Test if the CAA record for `name` matches for certificate authority `ca`.
30
30
 
package/index.js CHANGED
@@ -1,8 +1,7 @@
1
- "use strict";
2
-
3
- const dnsSocket = require("dns-socket");
4
- const tlds = require("tlds");
5
- const {promisify} = require("util");
1
+ import {getServers} from "node:dns";
2
+ import {promisify} from "node:util";
3
+ import dnsSocket from "dns-socket";
4
+ import tlds from "tlds";
6
5
 
7
6
  const defaults = {
8
7
  ignoreTLDs: false,
@@ -89,16 +88,16 @@ const resolve = async ({name, query, servers, port, recursions, retries, tries,
89
88
  }
90
89
  };
91
90
 
92
- const caa = module.exports = async (name, opts = {}) => {
91
+ export async function caa(name, opts = {}) {
93
92
  if (typeof name !== "string") throw new Error(`Expected a string for 'name', got ${name}`);
94
93
  name = normalizeName(name);
95
94
 
96
95
  if (!opts.servers) {
97
- const systemServers = require("dns").getServers();
96
+ const systemServers = getServers();
98
97
  opts.servers = (systemServers && systemServers.length) ? systemServers : defaults.servers;
99
98
  }
100
99
 
101
- opts = Object.assign({}, defaults, opts);
100
+ opts = {...defaults, ...opts};
102
101
 
103
102
  const socket = opts.dnsSocket || dnsSocket();
104
103
  const query = promisify(socket.query.bind(socket));
@@ -115,9 +114,9 @@ const caa = module.exports = async (name, opts = {}) => {
115
114
 
116
115
  if (!opts.dnsSocket) socket.destroy();
117
116
  return caa || [];
118
- };
117
+ }
119
118
 
120
- caa.matches = async (name, ca, opts = {}) => {
119
+ export async function caaMatches(name, ca, opts = {}) {
121
120
  if (typeof name !== "string") throw new Error(`Expected a string for 'name', got ${name}`);
122
121
  if (typeof ca !== "string") throw new Error(`Expected a string for 'ca', got ${ca}`);
123
122
 
@@ -138,4 +137,4 @@ caa.matches = async (name, ca, opts = {}) => {
138
137
 
139
138
  if (names.includes(";")) return false;
140
139
  return !names.length || names.includes(ca);
141
- };
140
+ }
package/package.json CHANGED
@@ -1,15 +1,14 @@
1
1
  {
2
2
  "name": "caa",
3
- "version": "6.0.5",
3
+ "version": "8.0.0",
4
4
  "description": "rfc6844-conform CAA record lookup and validation",
5
5
  "author": "silverwind <me@silverwind.io>",
6
6
  "repository": "silverwind/caa",
7
7
  "license": "BSD-2-Clause",
8
- "scripts": {
9
- "test": "make test"
10
- },
8
+ "type": "module",
9
+ "exports": "./index.js",
11
10
  "engines": {
12
- "node": ">=10"
11
+ "node": ">=14"
13
12
  },
14
13
  "files": [
15
14
  "index.js"
@@ -21,18 +20,14 @@
21
20
  "certificate authority"
22
21
  ],
23
22
  "dependencies": {
24
- "dns-socket": "^4.2.1",
25
- "tlds": "^1.218.0"
23
+ "dns-socket": "^4.2.2",
24
+ "tlds": "^1.236.0"
26
25
  },
27
26
  "devDependencies": {
28
- "eslint": "7.21.0",
29
- "eslint-config-silverwind": "29.0.0",
30
- "jest": "26.6.3",
31
- "updates": "11.4.3",
32
- "versions": "8.4.5"
33
- },
34
- "jest": {
35
- "verbose": false,
36
- "testTimeout": 10000
27
+ "eslint": "8.34.0",
28
+ "eslint-config-silverwind": "65.1.0",
29
+ "updates": "13.2.8",
30
+ "versions": "10.4.1",
31
+ "vitest": "0.28.4"
37
32
  }
38
33
  }