@gusnips/one-click-dns 0.1.2 → 0.1.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
@@ -141,6 +141,8 @@ console.log(templateFileName(template)); // "example.com.custom-domain.json"
141
141
 
142
142
  There are presets for a CNAME, DMARC, SPF, DKIM, MX and a verification TXT.
143
143
 
144
+ Two of them change how a domain's email works. The MX preset replaces the MX records the domain has, so its mail goes somewhere else. The SPF preset adds a sender to the domain's SPF record. Ask the person for consent in your own screen before you offer either link, and say what changes in the template's `description`, which the DNS host shows when they approve.
145
+
144
146
  A template belongs to the company that files it. It names your key domain, and the host checks every link against the key published there. So you cannot use someone else's template, and nobody can use yours. The customer's domain is not in the template: it comes with each link, so one template serves every customer.
145
147
 
146
148
  To file a template: test it in the [online editor](https://domainconnect.paulonet.eu/dc/free/templateedit), run `dc-template-linter -merge-or-fail` on it, open a pull request, then ask each DNS host to switch it on.
package/dist/index.cjs CHANGED
@@ -663,21 +663,24 @@ function spfTemplate(identity, options = {}) {
663
663
  );
664
664
  }
665
665
  function dkimTemplate(identity, options = {}) {
666
- const keys = options.keys ?? 2;
666
+ const { selectors } = options;
667
+ const keys = selectors?.length ?? options.keys ?? 2;
667
668
  const numbers = Array.from({ length: keys }, (_, index) => index + 1);
669
+ const hostOf = (n) => selectors ? `${selectors[n - 1]}._domainkey` : `%selector${n}%._domainkey`;
670
+ const describe = (n) => selectors ? `%target${n}%: where ${selectors[n - 1]}._domainkey points` : `%selector${n}%: the key name, ${n} of ${keys}; %target${n}%: where it points`;
668
671
  return template(
669
672
  identity,
670
673
  "dkim",
671
674
  {
672
675
  serviceName: "Sign your email with our key",
673
676
  description: "Adds the CNAME records that let us sign email sent from your domain.",
674
- variableDescription: numbers.map((n) => `%selector${n}%: the key name, ${n} of ${keys}; %target${n}%: where it points`).join("; ")
677
+ variableDescription: options.variableDescription ?? numbers.map(describe).join("; ")
675
678
  },
676
679
  options,
677
680
  numbers.map((n) => ({
678
681
  type: "CNAME",
679
- host: `%selector${n}%._domainkey`,
680
- pointsTo: `%target${n}%`,
682
+ host: hostOf(n),
683
+ pointsTo: options.pointsTo?.(n) ?? `%target${n}%`,
681
684
  ttl: TTL
682
685
  }))
683
686
  );
package/dist/index.d.cts CHANGED
@@ -99,12 +99,24 @@ declare function dmarcTemplate(identity: TemplateIdentity, options?: Wording & {
99
99
  /** Adds one `include:` to the domain's SPF record. `SPFM` merges it into the one record the
100
100
  * name may have; a TXT would make a second one and break SPF. The link carries `%include%`. */
101
101
  declare function spfTemplate(identity: TemplateIdentity, options?: Wording): DomainConnectTemplate;
102
- /** DKIM as CNAMEs, for services that publish the key on their side. The link carries
103
- * `%selector1%` and `%target1%`, then the same pair numbered up to `keys`. */
102
+ /**
103
+ * DKIM as CNAMEs, for services that publish the key on their side.
104
+ *
105
+ * By default the link carries `%selector1%` and `%target1%`, then the same pair numbered up to
106
+ * `keys`. When your key names never change, fix them: `selectors: ["cd1", "cd2"]` writes
107
+ * `cd1._domainkey` and `cd2._domainkey` into the template, which the repository prefers to a
108
+ * variable. `pointsTo` then names where each CNAME goes (`(n) => "%dkim" + n + "%.example.net"`),
109
+ * and `variableDescription` says what its variables mean.
110
+ */
104
111
  declare function dkimTemplate(identity: TemplateIdentity, options?: Wording & {
105
112
  keys?: number;
113
+ selectors?: readonly string[];
114
+ pointsTo?: (n: number) => string;
115
+ variableDescription?: string;
106
116
  }): DomainConnectTemplate;
107
- /** The MX record that sends the domain's mail to you. */
117
+ /** The MX record that sends the domain's mail to you. It changes where the domain's email is
118
+ * delivered and replaces the MX records it has, so ask the person for consent before you offer
119
+ * the link; say so in `description` too. */
108
120
  declare function mxTemplate(identity: TemplateIdentity, options: Wording & {
109
121
  pointsTo: string;
110
122
  priority?: number;
package/dist/index.d.ts CHANGED
@@ -99,12 +99,24 @@ declare function dmarcTemplate(identity: TemplateIdentity, options?: Wording & {
99
99
  /** Adds one `include:` to the domain's SPF record. `SPFM` merges it into the one record the
100
100
  * name may have; a TXT would make a second one and break SPF. The link carries `%include%`. */
101
101
  declare function spfTemplate(identity: TemplateIdentity, options?: Wording): DomainConnectTemplate;
102
- /** DKIM as CNAMEs, for services that publish the key on their side. The link carries
103
- * `%selector1%` and `%target1%`, then the same pair numbered up to `keys`. */
102
+ /**
103
+ * DKIM as CNAMEs, for services that publish the key on their side.
104
+ *
105
+ * By default the link carries `%selector1%` and `%target1%`, then the same pair numbered up to
106
+ * `keys`. When your key names never change, fix them: `selectors: ["cd1", "cd2"]` writes
107
+ * `cd1._domainkey` and `cd2._domainkey` into the template, which the repository prefers to a
108
+ * variable. `pointsTo` then names where each CNAME goes (`(n) => "%dkim" + n + "%.example.net"`),
109
+ * and `variableDescription` says what its variables mean.
110
+ */
104
111
  declare function dkimTemplate(identity: TemplateIdentity, options?: Wording & {
105
112
  keys?: number;
113
+ selectors?: readonly string[];
114
+ pointsTo?: (n: number) => string;
115
+ variableDescription?: string;
106
116
  }): DomainConnectTemplate;
107
- /** The MX record that sends the domain's mail to you. */
117
+ /** The MX record that sends the domain's mail to you. It changes where the domain's email is
118
+ * delivered and replaces the MX records it has, so ask the person for consent before you offer
119
+ * the link; say so in `description` too. */
108
120
  declare function mxTemplate(identity: TemplateIdentity, options: Wording & {
109
121
  pointsTo: string;
110
122
  priority?: number;
package/dist/index.js CHANGED
@@ -117,21 +117,24 @@ function spfTemplate(identity, options = {}) {
117
117
  );
118
118
  }
119
119
  function dkimTemplate(identity, options = {}) {
120
- const keys = options.keys ?? 2;
120
+ const { selectors } = options;
121
+ const keys = selectors?.length ?? options.keys ?? 2;
121
122
  const numbers = Array.from({ length: keys }, (_, index) => index + 1);
123
+ const hostOf = (n) => selectors ? `${selectors[n - 1]}._domainkey` : `%selector${n}%._domainkey`;
124
+ const describe = (n) => selectors ? `%target${n}%: where ${selectors[n - 1]}._domainkey points` : `%selector${n}%: the key name, ${n} of ${keys}; %target${n}%: where it points`;
122
125
  return template(
123
126
  identity,
124
127
  "dkim",
125
128
  {
126
129
  serviceName: "Sign your email with our key",
127
130
  description: "Adds the CNAME records that let us sign email sent from your domain.",
128
- variableDescription: numbers.map((n) => `%selector${n}%: the key name, ${n} of ${keys}; %target${n}%: where it points`).join("; ")
131
+ variableDescription: options.variableDescription ?? numbers.map(describe).join("; ")
129
132
  },
130
133
  options,
131
134
  numbers.map((n) => ({
132
135
  type: "CNAME",
133
- host: `%selector${n}%._domainkey`,
134
- pointsTo: `%target${n}%`,
136
+ host: hostOf(n),
137
+ pointsTo: options.pointsTo?.(n) ?? `%target${n}%`,
135
138
  ttl: TTL
136
139
  }))
137
140
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gusnips/one-click-dns",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "packageManager": "bun@1.4.2",
5
5
  "description": "Put DNS records in a customer's zone: find their DNS host, send them to a signed Domain Connect link, write with an API token, or show the steps for that host",
6
6
  "type": "module",