@geekmidas/edge 0.0.0-stage → 10.0.0-alpha.181
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 +14 -2
- package/dist/certificates/local.cjs +393 -0
- package/dist/certificates/local.cjs.map +1 -0
- package/dist/certificates/local.d.cts +92 -0
- package/dist/certificates/local.d.cts.map +1 -0
- package/dist/certificates/local.d.mts +92 -0
- package/dist/certificates/local.d.mts.map +1 -0
- package/dist/certificates/local.mjs +361 -0
- package/dist/certificates/local.mjs.map +1 -0
- package/dist/dns/godaddy/index.cjs +448 -0
- package/dist/dns/godaddy/index.cjs.map +1 -0
- package/dist/dns/godaddy/index.d.cts +164 -0
- package/dist/dns/godaddy/index.d.cts.map +1 -0
- package/dist/dns/godaddy/index.d.mts +164 -0
- package/dist/dns/godaddy/index.d.mts.map +1 -0
- package/dist/dns/godaddy/index.mjs +435 -0
- package/dist/dns/godaddy/index.mjs.map +1 -0
- package/dist/dns/hostinger/index.cjs +252 -0
- package/dist/dns/hostinger/index.cjs.map +1 -0
- package/dist/dns/hostinger/index.d.cts +143 -0
- package/dist/dns/hostinger/index.d.cts.map +1 -0
- package/dist/dns/hostinger/index.d.mts +143 -0
- package/dist/dns/hostinger/index.d.mts.map +1 -0
- package/dist/dns/hostinger/index.mjs +249 -0
- package/dist/dns/hostinger/index.mjs.map +1 -0
- package/dist/dns/index.cjs +76 -0
- package/dist/dns/index.cjs.map +1 -0
- package/dist/dns/index.d.cts +144 -0
- package/dist/dns/index.d.cts.map +1 -0
- package/dist/dns/index.d.mts +144 -0
- package/dist/dns/index.d.mts.map +1 -0
- package/dist/dns/index.mjs +71 -0
- package/dist/dns/index.mjs.map +1 -0
- package/dist/dns/route53.cjs +210 -0
- package/dist/dns/route53.cjs.map +1 -0
- package/dist/dns/route53.d.cts +45 -0
- package/dist/dns/route53.d.cts.map +1 -0
- package/dist/dns/route53.d.mts +45 -0
- package/dist/dns/route53.d.mts.map +1 -0
- package/dist/dns/route53.mjs +209 -0
- package/dist/dns/route53.mjs.map +1 -0
- package/dist/errors-CO33_TDV.mjs +16 -0
- package/dist/errors-CO33_TDV.mjs.map +1 -0
- package/dist/errors-DBZfelEN.d.cts +13 -0
- package/dist/errors-DBZfelEN.d.cts.map +1 -0
- package/dist/errors-DBZfelEN.d.mts +13 -0
- package/dist/errors-DBZfelEN.d.mts.map +1 -0
- package/dist/errors-DlRLQOyZ.cjs +27 -0
- package/dist/errors-DlRLQOyZ.cjs.map +1 -0
- package/dist/index.cjs +4 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2 -0
- package/dist/proxy/caddy.cjs +167 -0
- package/dist/proxy/caddy.cjs.map +1 -0
- package/dist/proxy/caddy.d.cts +35 -0
- package/dist/proxy/caddy.d.cts.map +1 -0
- package/dist/proxy/caddy.d.mts +35 -0
- package/dist/proxy/caddy.d.mts.map +1 -0
- package/dist/proxy/caddy.mjs +164 -0
- package/dist/proxy/caddy.mjs.map +1 -0
- package/dist/proxy/traefik.cjs +459 -0
- package/dist/proxy/traefik.cjs.map +1 -0
- package/dist/proxy/traefik.d.cts +129 -0
- package/dist/proxy/traefik.d.cts.map +1 -0
- package/dist/proxy/traefik.d.mts +129 -0
- package/dist/proxy/traefik.d.mts.map +1 -0
- package/dist/proxy/traefik.mjs +436 -0
- package/dist/proxy/traefik.mjs.map +1 -0
- package/dist/routes/index.cjs +49 -0
- package/dist/routes/index.cjs.map +1 -0
- package/dist/routes/index.d.cts +205 -0
- package/dist/routes/index.d.cts.map +1 -0
- package/dist/routes/index.d.mts +205 -0
- package/dist/routes/index.d.mts.map +1 -0
- package/dist/routes/index.mjs +44 -0
- package/dist/routes/index.mjs.map +1 -0
- package/package.json +131 -3
package/README.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @geekmidas/edge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Optional peers
|
|
4
|
+
|
|
5
|
+
<!-- optional-peers:start -->
|
|
6
|
+
|
|
7
|
+
<!-- Generated by `node scripts/check-optional-peers.mjs --write-docs`; CI fails when it drifts. -->
|
|
8
|
+
|
|
9
|
+
Each of these entries imports an optional peer when it loads, so using it means installing that peer:
|
|
10
|
+
|
|
11
|
+
| Entry | Install |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| `@geekmidas/edge/dns/route53` | `@aws-sdk/client-route-53`, `@aws-sdk/credential-providers` |
|
|
14
|
+
|
|
15
|
+
<!-- optional-peers:end -->
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
const require_errors = require("../errors-DlRLQOyZ.cjs");
|
|
25
|
+
let node_crypto = require("node:crypto");
|
|
26
|
+
let node_fs = require("node:fs");
|
|
27
|
+
let node_fs_promises = require("node:fs/promises");
|
|
28
|
+
let node_os = require("node:os");
|
|
29
|
+
let node_path = require("node:path");
|
|
30
|
+
let node_forge = require("node-forge");
|
|
31
|
+
node_forge = __toESM(node_forge, 1);
|
|
32
|
+
//#region src/certificates/local.ts
|
|
33
|
+
/**
|
|
34
|
+
* gkm's local certificate authority: one per machine, and every local edge's
|
|
35
|
+
* certificate is issued from it.
|
|
36
|
+
*
|
|
37
|
+
* `gkm dev`'s Caddy, a local `gkm compose` stack's Caddy — and anything else
|
|
38
|
+
* that serves the local stage's `*.localhost` names — serves a certificate
|
|
39
|
+
* this module issued, the way a deployed stage's edge serves the files
|
|
40
|
+
* `deploy.compose.tls` names. So there is one root to trust (`gkm trust`), it
|
|
41
|
+
* exists before any container starts, and a container that calls the stage's
|
|
42
|
+
* public hosts can be handed it (`NODE_EXTRA_CA_CERTS`) without first copying
|
|
43
|
+
* it out of a proxy.
|
|
44
|
+
*
|
|
45
|
+
* The root lives in the home it is given — the CLI's (`GKM_HOME`, else
|
|
46
|
+
* `~/.gkm`) — outside every project. Its key never leaves that directory: only certificates it signed —
|
|
47
|
+
* and their own keys — are written to a workspace or handed to a container.
|
|
48
|
+
*/
|
|
49
|
+
/** How long the root is good for: ten years, so it is trusted once. */
|
|
50
|
+
const AUTHORITY_DAYS = 3650;
|
|
51
|
+
/**
|
|
52
|
+
* How long an issued certificate is good for. Under Apple's 825-day limit
|
|
53
|
+
* for a root a user added, and renewed long before it ends.
|
|
54
|
+
*/
|
|
55
|
+
const CERTIFICATE_DAYS = 365;
|
|
56
|
+
/** An issued certificate this close to its end is issued again. */
|
|
57
|
+
const RENEW_WITHIN_DAYS = 30;
|
|
58
|
+
const DAY = 864e5;
|
|
59
|
+
/** The authority's files, under the CLI's home. */
|
|
60
|
+
function localAuthorityPaths(home) {
|
|
61
|
+
const dir = (0, node_path.join)(home, "ca");
|
|
62
|
+
return {
|
|
63
|
+
dir,
|
|
64
|
+
certFile: (0, node_path.join)(dir, "root.pem"),
|
|
65
|
+
keyFile: (0, node_path.join)(dir, "root-key.pem")
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** The authority's directory is there, and its root or key is not readable. */
|
|
69
|
+
var LocalAuthorityDamaged = class extends require_errors.EdgeError {
|
|
70
|
+
dir;
|
|
71
|
+
reason;
|
|
72
|
+
constructor(dir, reason) {
|
|
73
|
+
super(`gkm's local certificate authority in ${dir} cannot be used: ${reason}. Delete the directory and run "gkm trust" to make a new one — a browser that trusted the old root has to trust the new one.`);
|
|
74
|
+
this.dir = dir;
|
|
75
|
+
this.reason = reason;
|
|
76
|
+
this.name = "LocalAuthorityDamaged";
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
/** A certificate asked for with no names to put on it. */
|
|
80
|
+
var LocalCertificateWithoutNames = class extends require_errors.EdgeError {
|
|
81
|
+
constructor() {
|
|
82
|
+
super("A local certificate needs at least one host name. Pass the hosts the edge serves — localCertificateNames(project, hosts) lists them.");
|
|
83
|
+
this.name = "LocalCertificateWithoutNames";
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Load the authority, creating it the first time.
|
|
88
|
+
*
|
|
89
|
+
* Created whole or not at all: generated into a directory of its own and
|
|
90
|
+
* renamed into place, so two commands starting at once — `gkm dev` for two
|
|
91
|
+
* apps — end with one root between them, never one's certificate and the
|
|
92
|
+
* other's key.
|
|
93
|
+
*
|
|
94
|
+
* @throws {LocalAuthorityDamaged} when its directory holds no usable root.
|
|
95
|
+
*/
|
|
96
|
+
async function ensureLocalAuthority(paths) {
|
|
97
|
+
if (!(0, node_fs.existsSync)(paths.dir)) await createAuthority(paths);
|
|
98
|
+
return readLocalAuthority(paths);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Load an authority that exists.
|
|
102
|
+
*
|
|
103
|
+
* @throws {LocalAuthorityDamaged} when its root or key is missing or unreadable.
|
|
104
|
+
*/
|
|
105
|
+
async function readLocalAuthority(paths) {
|
|
106
|
+
let cert;
|
|
107
|
+
let key;
|
|
108
|
+
try {
|
|
109
|
+
[cert, key] = await Promise.all([(0, node_fs_promises.readFile)(paths.certFile, "utf-8"), (0, node_fs_promises.readFile)(paths.keyFile, "utf-8")]);
|
|
110
|
+
} catch {
|
|
111
|
+
throw new LocalAuthorityDamaged(paths.dir, "its root certificate or key is missing");
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const root = node_forge.default.pki.certificateFromPem(cert);
|
|
115
|
+
const signer = node_forge.default.pki.privateKeyFromPem(key);
|
|
116
|
+
if (!root.publicKey.n.equals(signer.n)) throw new LocalAuthorityDamaged(paths.dir, "its key is not the root certificate’s");
|
|
117
|
+
} catch (error) {
|
|
118
|
+
if (error instanceof LocalAuthorityDamaged) throw error;
|
|
119
|
+
throw new LocalAuthorityDamaged(paths.dir, "its files are not PEM");
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
certFile: paths.certFile,
|
|
123
|
+
cert,
|
|
124
|
+
key
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
async function createAuthority(paths) {
|
|
128
|
+
const { cert, key } = selfSigned();
|
|
129
|
+
const staging = `${paths.dir}.${process.pid}.${(0, node_crypto.randomBytes)(4).toString("hex")}`;
|
|
130
|
+
await (0, node_fs_promises.mkdir)(staging, {
|
|
131
|
+
recursive: true,
|
|
132
|
+
mode: 448
|
|
133
|
+
});
|
|
134
|
+
try {
|
|
135
|
+
await (0, node_fs_promises.writeFile)((0, node_path.join)(staging, "root.pem"), cert, { mode: 420 });
|
|
136
|
+
await (0, node_fs_promises.writeFile)((0, node_path.join)(staging, "root-key.pem"), key, { mode: 384 });
|
|
137
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(paths.dir), { recursive: true });
|
|
138
|
+
await (0, node_fs_promises.rename)(staging, paths.dir).catch((error) => {
|
|
139
|
+
if (error.code !== "EEXIST" && error.code !== "ENOTEMPTY") throw error;
|
|
140
|
+
});
|
|
141
|
+
} finally {
|
|
142
|
+
await (0, node_fs_promises.rm)(staging, {
|
|
143
|
+
recursive: true,
|
|
144
|
+
force: true
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/** A new root: who made it, on which machine, so a keychain says whose it is. */
|
|
149
|
+
function selfSigned() {
|
|
150
|
+
const { privateKey, publicKey } = keyPair();
|
|
151
|
+
const cert = node_forge.default.pki.createCertificate();
|
|
152
|
+
cert.publicKey = publicKey;
|
|
153
|
+
cert.serialNumber = serialNumber();
|
|
154
|
+
const now = Date.now();
|
|
155
|
+
cert.validity.notBefore = /* @__PURE__ */ new Date(now - DAY);
|
|
156
|
+
cert.validity.notAfter = new Date(now + AUTHORITY_DAYS * DAY);
|
|
157
|
+
const subject = utf8([
|
|
158
|
+
{
|
|
159
|
+
name: "organizationName",
|
|
160
|
+
value: "gkm local CA"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: "organizationalUnitName",
|
|
164
|
+
value: owner()
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "commonName",
|
|
168
|
+
value: `gkm local CA ${owner()}`
|
|
169
|
+
}
|
|
170
|
+
]);
|
|
171
|
+
cert.setSubject(subject);
|
|
172
|
+
cert.setIssuer(subject);
|
|
173
|
+
cert.setExtensions([
|
|
174
|
+
{
|
|
175
|
+
name: "basicConstraints",
|
|
176
|
+
cA: true,
|
|
177
|
+
pathLenConstraint: 0,
|
|
178
|
+
critical: true
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "keyUsage",
|
|
182
|
+
keyCertSign: true,
|
|
183
|
+
cRLSign: true,
|
|
184
|
+
critical: true
|
|
185
|
+
},
|
|
186
|
+
{ name: "subjectKeyIdentifier" }
|
|
187
|
+
]);
|
|
188
|
+
cert.sign(privateKey, node_forge.default.md.sha256.create());
|
|
189
|
+
return {
|
|
190
|
+
cert: node_forge.default.pki.certificateToPem(cert),
|
|
191
|
+
key: node_forge.default.pki.privateKeyToPem(privateKey)
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The names a project's local certificate carries: its bare host and every
|
|
196
|
+
* label under it — `shop.localhost`, `*.shop.localhost` — and any host the
|
|
197
|
+
* edge serves that those do not cover, a stage's own wildcard among them.
|
|
198
|
+
* Without a project, the hosts alone: `*.localhost` is nobody's to claim.
|
|
199
|
+
*/
|
|
200
|
+
function localCertificateNames(project, hosts) {
|
|
201
|
+
const names = [...project ? [`${project}.localhost`, `*.${project}.localhost`] : []];
|
|
202
|
+
for (const host of hosts) {
|
|
203
|
+
const name = host.toLowerCase();
|
|
204
|
+
if (!names.some((covering) => covers(covering, name))) names.push(name);
|
|
205
|
+
}
|
|
206
|
+
return names;
|
|
207
|
+
}
|
|
208
|
+
/** Whether a certificate name answers for a host, by the one-label wildcard rule. */
|
|
209
|
+
function covers(name, host) {
|
|
210
|
+
if (name === host) return true;
|
|
211
|
+
if (!name.startsWith("*.") || host.startsWith("*.")) return false;
|
|
212
|
+
const suffix = name.slice(1);
|
|
213
|
+
return host.endsWith(suffix) && !host.slice(0, -suffix.length).includes(".");
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* A certificate for `names`, signed by the authority. Each call makes a new
|
|
217
|
+
* key; {@link ensureLocalCertificate} is what keeps one across runs.
|
|
218
|
+
*
|
|
219
|
+
* @throws {LocalCertificateWithoutNames} for an empty list.
|
|
220
|
+
*/
|
|
221
|
+
function issueLocalCertificate(authority, names, options = {}) {
|
|
222
|
+
if (names.length === 0) throw new LocalCertificateWithoutNames();
|
|
223
|
+
const root = node_forge.default.pki.certificateFromPem(authority.cert);
|
|
224
|
+
const signer = node_forge.default.pki.privateKeyFromPem(authority.key);
|
|
225
|
+
const { privateKey, publicKey } = keyPair();
|
|
226
|
+
const now = (options.now ?? /* @__PURE__ */ new Date()).getTime();
|
|
227
|
+
const cert = node_forge.default.pki.createCertificate();
|
|
228
|
+
cert.publicKey = publicKey;
|
|
229
|
+
cert.serialNumber = serialNumber();
|
|
230
|
+
cert.validity.notBefore = /* @__PURE__ */ new Date(now - 36e5);
|
|
231
|
+
cert.validity.notAfter = new Date(now + (options.days ?? 365) * DAY);
|
|
232
|
+
cert.setSubject(utf8([{
|
|
233
|
+
name: "organizationName",
|
|
234
|
+
value: "gkm local certificate"
|
|
235
|
+
}, {
|
|
236
|
+
name: "commonName",
|
|
237
|
+
value: names[0]
|
|
238
|
+
}]));
|
|
239
|
+
cert.setIssuer(root.subject.attributes);
|
|
240
|
+
cert.setExtensions([
|
|
241
|
+
{
|
|
242
|
+
name: "basicConstraints",
|
|
243
|
+
cA: false,
|
|
244
|
+
critical: true
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: "keyUsage",
|
|
248
|
+
digitalSignature: true,
|
|
249
|
+
keyEncipherment: true,
|
|
250
|
+
critical: true
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
name: "extKeyUsage",
|
|
254
|
+
serverAuth: true
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: "subjectAltName",
|
|
258
|
+
altNames: names.map((value) => ({
|
|
259
|
+
type: 2,
|
|
260
|
+
value
|
|
261
|
+
}))
|
|
262
|
+
},
|
|
263
|
+
{ name: "subjectKeyIdentifier" },
|
|
264
|
+
{
|
|
265
|
+
name: "authorityKeyIdentifier",
|
|
266
|
+
keyIdentifier: root.generateSubjectKeyIdentifier().getBytes()
|
|
267
|
+
}
|
|
268
|
+
]);
|
|
269
|
+
cert.sign(signer, node_forge.default.md.sha256.create());
|
|
270
|
+
return {
|
|
271
|
+
cert: node_forge.default.pki.certificateToPem(cert),
|
|
272
|
+
key: node_forge.default.pki.privateKeyToPem(privateKey)
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The certificate for `names` kept in `file` — certificate then key, one PEM
|
|
277
|
+
* file, which is what a proxy given the same path for both reads — issued
|
|
278
|
+
* again only when the one there is not the authority's, does not cover every
|
|
279
|
+
* name, or is near its end.
|
|
280
|
+
*
|
|
281
|
+
* One file written by rename, so two commands issuing at once leave a pair
|
|
282
|
+
* that matches, never one's certificate beside the other's key.
|
|
283
|
+
*
|
|
284
|
+
* @throws {LocalCertificateWithoutNames} for an empty list.
|
|
285
|
+
*/
|
|
286
|
+
async function ensureLocalCertificate(authority, names, file, options = {}) {
|
|
287
|
+
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
288
|
+
const existing = await (0, node_fs_promises.readFile)(file, "utf-8").catch(() => void 0);
|
|
289
|
+
const kept = existing ? splitPem(existing) : void 0;
|
|
290
|
+
if (kept && stillGood(authority, kept, names, now)) return {
|
|
291
|
+
...kept,
|
|
292
|
+
issued: false
|
|
293
|
+
};
|
|
294
|
+
const issued = issueLocalCertificate(authority, names, { now });
|
|
295
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(file), {
|
|
296
|
+
recursive: true,
|
|
297
|
+
mode: 448
|
|
298
|
+
});
|
|
299
|
+
const staging = `${file}.${process.pid}.${(0, node_crypto.randomBytes)(4).toString("hex")}`;
|
|
300
|
+
await (0, node_fs_promises.writeFile)(staging, `${issued.cert}${issued.key}`, { mode: 384 });
|
|
301
|
+
await (0, node_fs_promises.rename)(staging, file);
|
|
302
|
+
return {
|
|
303
|
+
...issued,
|
|
304
|
+
issued: true
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
/** A combined PEM file's certificate and key. */
|
|
308
|
+
function splitPem(pem) {
|
|
309
|
+
const cert = pem.match(/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----\r?\n?/)?.[0];
|
|
310
|
+
const key = pem.match(/-----BEGIN (?:RSA )?PRIVATE KEY-----[\s\S]+?-----END (?:RSA )?PRIVATE KEY-----\r?\n?/)?.[0];
|
|
311
|
+
return cert && key ? {
|
|
312
|
+
cert,
|
|
313
|
+
key
|
|
314
|
+
} : void 0;
|
|
315
|
+
}
|
|
316
|
+
/** Whether a kept certificate still serves: the authority's, every name, in date. */
|
|
317
|
+
function stillGood(authority, kept, names, now) {
|
|
318
|
+
try {
|
|
319
|
+
const root = node_forge.default.pki.certificateFromPem(authority.cert);
|
|
320
|
+
const cert = node_forge.default.pki.certificateFromPem(kept.cert);
|
|
321
|
+
if (!root.verify(cert)) return false;
|
|
322
|
+
if (cert.validity.notAfter.getTime() - now.getTime() < RENEW_WITHIN_DAYS * DAY) return false;
|
|
323
|
+
const certKey = (0, node_crypto.createPublicKey)(kept.cert).export({
|
|
324
|
+
type: "spki",
|
|
325
|
+
format: "der"
|
|
326
|
+
});
|
|
327
|
+
const ownKey = (0, node_crypto.createPublicKey)((0, node_crypto.createPrivateKey)(kept.key)).export({
|
|
328
|
+
type: "spki",
|
|
329
|
+
format: "der"
|
|
330
|
+
});
|
|
331
|
+
if (!certKey.equals(ownKey)) return false;
|
|
332
|
+
const san = cert.getExtension("subjectAltName");
|
|
333
|
+
const dns = new Set((san?.altNames ?? []).filter((n) => n.type === 2).map((n) => n.value));
|
|
334
|
+
return names.every((name) => dns.has(name));
|
|
335
|
+
} catch {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/** An RSA key pair, made natively — forge's own generation is slow. */
|
|
340
|
+
function keyPair() {
|
|
341
|
+
const { privateKey: pem } = (0, node_crypto.generateKeyPairSync)("rsa", {
|
|
342
|
+
modulusLength: 2048,
|
|
343
|
+
publicKeyEncoding: {
|
|
344
|
+
type: "spki",
|
|
345
|
+
format: "pem"
|
|
346
|
+
},
|
|
347
|
+
privateKeyEncoding: {
|
|
348
|
+
type: "pkcs8",
|
|
349
|
+
format: "pem"
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
const privateKey = node_forge.default.pki.privateKeyFromPem(pem);
|
|
353
|
+
return {
|
|
354
|
+
privateKey,
|
|
355
|
+
publicKey: node_forge.default.pki.setRsaPublicKey(privateKey.n, privateKey.e)
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Attributes as UTF8String. forge writes PrintableString otherwise, which
|
|
360
|
+
* has no `@` or `*` — and a TLS stack rejects the certificate outright.
|
|
361
|
+
*/
|
|
362
|
+
function utf8(attributes) {
|
|
363
|
+
return attributes.map((attribute) => ({
|
|
364
|
+
...attribute,
|
|
365
|
+
valueTagClass: node_forge.default.asn1.Type.UTF8
|
|
366
|
+
}));
|
|
367
|
+
}
|
|
368
|
+
/** A random, positive serial: sixteen bytes, its high bit clear. */
|
|
369
|
+
function serialNumber() {
|
|
370
|
+
const bytes = (0, node_crypto.randomBytes)(16);
|
|
371
|
+
bytes[0] = bytes[0] & 127;
|
|
372
|
+
return bytes.toString("hex");
|
|
373
|
+
}
|
|
374
|
+
/** `user@host`, as far as the machine will say. */
|
|
375
|
+
function owner() {
|
|
376
|
+
let user = "gkm";
|
|
377
|
+
try {
|
|
378
|
+
user = (0, node_os.userInfo)().username;
|
|
379
|
+
} catch {}
|
|
380
|
+
return `${user}@${(0, node_os.hostname)()}`;
|
|
381
|
+
}
|
|
382
|
+
//#endregion
|
|
383
|
+
exports.CERTIFICATE_DAYS = CERTIFICATE_DAYS;
|
|
384
|
+
exports.LocalAuthorityDamaged = LocalAuthorityDamaged;
|
|
385
|
+
exports.LocalCertificateWithoutNames = LocalCertificateWithoutNames;
|
|
386
|
+
exports.ensureLocalAuthority = ensureLocalAuthority;
|
|
387
|
+
exports.ensureLocalCertificate = ensureLocalCertificate;
|
|
388
|
+
exports.issueLocalCertificate = issueLocalCertificate;
|
|
389
|
+
exports.localAuthorityPaths = localAuthorityPaths;
|
|
390
|
+
exports.localCertificateNames = localCertificateNames;
|
|
391
|
+
exports.readLocalAuthority = readLocalAuthority;
|
|
392
|
+
|
|
393
|
+
//# sourceMappingURL=local.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.cjs","names":["join","EdgeError","existsSync","readFile","forge","randomBytes","mkdir","writeFile","dirname","rename","rm","createPublicKey","createPrivateKey","generateKeyPairSync","userInfo","hostname"],"sources":["../../src/certificates/local.ts"],"sourcesContent":["/**\n * gkm's local certificate authority: one per machine, and every local edge's\n * certificate is issued from it.\n *\n * `gkm dev`'s Caddy, a local `gkm compose` stack's Caddy — and anything else\n * that serves the local stage's `*.localhost` names — serves a certificate\n * this module issued, the way a deployed stage's edge serves the files\n * `deploy.compose.tls` names. So there is one root to trust (`gkm trust`), it\n * exists before any container starts, and a container that calls the stage's\n * public hosts can be handed it (`NODE_EXTRA_CA_CERTS`) without first copying\n * it out of a proxy.\n *\n * The root lives in the home it is given — the CLI's (`GKM_HOME`, else\n * `~/.gkm`) — outside every project. Its key never leaves that directory: only certificates it signed —\n * and their own keys — are written to a workspace or handed to a container.\n */\n\nimport {\n\tcreatePrivateKey,\n\tcreatePublicKey,\n\tgenerateKeyPairSync,\n\trandomBytes,\n} from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';\nimport { hostname, userInfo } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport forge from 'node-forge';\nimport { EdgeError } from '../errors';\n\n/** Where the authority's files are. */\nexport interface LocalAuthorityPaths {\n\tdir: string;\n\t/** The root certificate, PEM — the only file anything else is handed. */\n\tcertFile: string;\n\t/** The root's private key, PEM. Owner-only, and never copied anywhere. */\n\tkeyFile: string;\n}\n\n/** The authority, loaded: its root certificate and the key it signs with. */\nexport interface LocalAuthority {\n\tcertFile: string;\n\t/** The root certificate, PEM. */\n\tcert: string;\n\t/** The root's private key, PEM. */\n\tkey: string;\n}\n\n/** A certificate the authority issued, and its key, both PEM. */\nexport interface LocalCertificate {\n\tcert: string;\n\tkey: string;\n}\n\n/** How long the root is good for: ten years, so it is trusted once. */\nconst AUTHORITY_DAYS = 3650;\n\n/**\n * How long an issued certificate is good for. Under Apple's 825-day limit\n * for a root a user added, and renewed long before it ends.\n */\nexport const CERTIFICATE_DAYS = 365;\n\n/** An issued certificate this close to its end is issued again. */\nconst RENEW_WITHIN_DAYS = 30;\n\nconst DAY = 24 * 60 * 60 * 1000;\n\n/** The authority's files, under the CLI's home. */\nexport function localAuthorityPaths(home: string): LocalAuthorityPaths {\n\tconst dir = join(home, 'ca');\n\treturn {\n\t\tdir,\n\t\tcertFile: join(dir, 'root.pem'),\n\t\tkeyFile: join(dir, 'root-key.pem'),\n\t};\n}\n\n/** The authority's directory is there, and its root or key is not readable. */\nexport class LocalAuthorityDamaged extends EdgeError {\n\tconstructor(\n\t\treadonly dir: string,\n\t\treadonly reason: string,\n\t) {\n\t\tsuper(\n\t\t\t`gkm's local certificate authority in ${dir} cannot be used: ${reason}. ` +\n\t\t\t\t`Delete the directory and run \"gkm trust\" to make a new one — ` +\n\t\t\t\t`a browser that trusted the old root has to trust the new one.`,\n\t\t);\n\t\tthis.name = 'LocalAuthorityDamaged';\n\t}\n}\n\n/** A certificate asked for with no names to put on it. */\nexport class LocalCertificateWithoutNames extends EdgeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t'A local certificate needs at least one host name. Pass the hosts the ' +\n\t\t\t\t'edge serves — localCertificateNames(project, hosts) lists them.',\n\t\t);\n\t\tthis.name = 'LocalCertificateWithoutNames';\n\t}\n}\n\n/**\n * Load the authority, creating it the first time.\n *\n * Created whole or not at all: generated into a directory of its own and\n * renamed into place, so two commands starting at once — `gkm dev` for two\n * apps — end with one root between them, never one's certificate and the\n * other's key.\n *\n * @throws {LocalAuthorityDamaged} when its directory holds no usable root.\n */\nexport async function ensureLocalAuthority(\n\tpaths: LocalAuthorityPaths,\n): Promise<LocalAuthority> {\n\tif (!existsSync(paths.dir)) await createAuthority(paths);\n\treturn readLocalAuthority(paths);\n}\n\n/**\n * Load an authority that exists.\n *\n * @throws {LocalAuthorityDamaged} when its root or key is missing or unreadable.\n */\nexport async function readLocalAuthority(\n\tpaths: LocalAuthorityPaths,\n): Promise<LocalAuthority> {\n\tlet cert: string;\n\tlet key: string;\n\ttry {\n\t\t[cert, key] = await Promise.all([\n\t\t\treadFile(paths.certFile, 'utf-8'),\n\t\t\treadFile(paths.keyFile, 'utf-8'),\n\t\t]);\n\t} catch {\n\t\tthrow new LocalAuthorityDamaged(\n\t\t\tpaths.dir,\n\t\t\t'its root certificate or key is missing',\n\t\t);\n\t}\n\ttry {\n\t\tconst root = forge.pki.certificateFromPem(cert);\n\t\tconst signer = forge.pki.privateKeyFromPem(key) as forge.pki.rsa.PrivateKey;\n\t\tconst publicKey = root.publicKey as forge.pki.rsa.PublicKey;\n\t\tif (!publicKey.n.equals(signer.n)) {\n\t\t\tthrow new LocalAuthorityDamaged(\n\t\t\t\tpaths.dir,\n\t\t\t\t'its key is not the root certificate’s',\n\t\t\t);\n\t\t}\n\t} catch (error) {\n\t\tif (error instanceof LocalAuthorityDamaged) throw error;\n\t\tthrow new LocalAuthorityDamaged(paths.dir, 'its files are not PEM');\n\t}\n\treturn { certFile: paths.certFile, cert, key };\n}\n\nasync function createAuthority(paths: LocalAuthorityPaths): Promise<void> {\n\tconst { cert, key } = selfSigned();\n\tconst staging = `${paths.dir}.${process.pid}.${randomBytes(4).toString('hex')}`;\n\tawait mkdir(staging, { recursive: true, mode: 0o700 });\n\ttry {\n\t\tawait writeFile(join(staging, 'root.pem'), cert, { mode: 0o644 });\n\t\tawait writeFile(join(staging, 'root-key.pem'), key, { mode: 0o600 });\n\t\tawait mkdir(dirname(paths.dir), { recursive: true });\n\t\tawait rename(staging, paths.dir).catch((error: NodeJS.ErrnoException) => {\n\t\t\t// Another command made it first: theirs is the machine's root.\n\t\t\tif (error.code !== 'EEXIST' && error.code !== 'ENOTEMPTY') throw error;\n\t\t});\n\t} finally {\n\t\tawait rm(staging, { recursive: true, force: true });\n\t}\n}\n\n/** A new root: who made it, on which machine, so a keychain says whose it is. */\nfunction selfSigned(): LocalCertificate {\n\tconst { privateKey, publicKey } = keyPair();\n\tconst cert = forge.pki.createCertificate();\n\tcert.publicKey = publicKey;\n\tcert.serialNumber = serialNumber();\n\tconst now = Date.now();\n\tcert.validity.notBefore = new Date(now - DAY);\n\tcert.validity.notAfter = new Date(now + AUTHORITY_DAYS * DAY);\n\tconst subject = utf8([\n\t\t{ name: 'organizationName', value: 'gkm local CA' },\n\t\t{ name: 'organizationalUnitName', value: owner() },\n\t\t{ name: 'commonName', value: `gkm local CA ${owner()}` },\n\t]);\n\tcert.setSubject(subject);\n\tcert.setIssuer(subject);\n\tcert.setExtensions([\n\t\t{\n\t\t\tname: 'basicConstraints',\n\t\t\tcA: true,\n\t\t\tpathLenConstraint: 0,\n\t\t\tcritical: true,\n\t\t},\n\t\t{ name: 'keyUsage', keyCertSign: true, cRLSign: true, critical: true },\n\t\t{ name: 'subjectKeyIdentifier' },\n\t]);\n\tcert.sign(privateKey, forge.md.sha256.create());\n\treturn {\n\t\tcert: forge.pki.certificateToPem(cert),\n\t\tkey: forge.pki.privateKeyToPem(privateKey),\n\t};\n}\n\n/**\n * The names a project's local certificate carries: its bare host and every\n * label under it — `shop.localhost`, `*.shop.localhost` — and any host the\n * edge serves that those do not cover, a stage's own wildcard among them.\n * Without a project, the hosts alone: `*.localhost` is nobody's to claim.\n */\nexport function localCertificateNames(\n\tproject: string,\n\thosts: readonly string[],\n): string[] {\n\tconst base = project\n\t\t? [`${project}.localhost`, `*.${project}.localhost`]\n\t\t: [];\n\tconst names = [...base];\n\tfor (const host of hosts) {\n\t\tconst name = host.toLowerCase();\n\t\tif (!names.some((covering) => covers(covering, name))) names.push(name);\n\t}\n\treturn names;\n}\n\n/** Whether a certificate name answers for a host, by the one-label wildcard rule. */\nfunction covers(name: string, host: string): boolean {\n\tif (name === host) return true;\n\tif (!name.startsWith('*.') || host.startsWith('*.')) return false;\n\tconst suffix = name.slice(1);\n\treturn host.endsWith(suffix) && !host.slice(0, -suffix.length).includes('.');\n}\n\n/**\n * A certificate for `names`, signed by the authority. Each call makes a new\n * key; {@link ensureLocalCertificate} is what keeps one across runs.\n *\n * @throws {LocalCertificateWithoutNames} for an empty list.\n */\nexport function issueLocalCertificate(\n\tauthority: LocalAuthority,\n\tnames: readonly string[],\n\toptions: { now?: Date; days?: number } = {},\n): LocalCertificate {\n\tif (names.length === 0) throw new LocalCertificateWithoutNames();\n\tconst root = forge.pki.certificateFromPem(authority.cert);\n\tconst signer = forge.pki.privateKeyFromPem(authority.key);\n\tconst { privateKey, publicKey } = keyPair();\n\tconst now = (options.now ?? new Date()).getTime();\n\n\tconst cert = forge.pki.createCertificate();\n\tcert.publicKey = publicKey;\n\tcert.serialNumber = serialNumber();\n\tcert.validity.notBefore = new Date(now - 60 * 60 * 1000);\n\tcert.validity.notAfter = new Date(\n\t\tnow + (options.days ?? CERTIFICATE_DAYS) * DAY,\n\t);\n\tcert.setSubject(\n\t\tutf8([\n\t\t\t{ name: 'organizationName', value: 'gkm local certificate' },\n\t\t\t{ name: 'commonName', value: names[0]! },\n\t\t]),\n\t);\n\tcert.setIssuer(root.subject.attributes);\n\tcert.setExtensions([\n\t\t{ name: 'basicConstraints', cA: false, critical: true },\n\t\t{\n\t\t\tname: 'keyUsage',\n\t\t\tdigitalSignature: true,\n\t\t\tkeyEncipherment: true,\n\t\t\tcritical: true,\n\t\t},\n\t\t{ name: 'extKeyUsage', serverAuth: true },\n\t\t{\n\t\t\tname: 'subjectAltName',\n\t\t\taltNames: names.map((value) => ({ type: 2, value })),\n\t\t},\n\t\t{ name: 'subjectKeyIdentifier' },\n\t\t{\n\t\t\tname: 'authorityKeyIdentifier',\n\t\t\tkeyIdentifier: root.generateSubjectKeyIdentifier().getBytes(),\n\t\t},\n\t]);\n\tcert.sign(signer, forge.md.sha256.create());\n\treturn {\n\t\tcert: forge.pki.certificateToPem(cert),\n\t\tkey: forge.pki.privateKeyToPem(privateKey),\n\t};\n}\n\n/**\n * The certificate for `names` kept in `file` — certificate then key, one PEM\n * file, which is what a proxy given the same path for both reads — issued\n * again only when the one there is not the authority's, does not cover every\n * name, or is near its end.\n *\n * One file written by rename, so two commands issuing at once leave a pair\n * that matches, never one's certificate beside the other's key.\n *\n * @throws {LocalCertificateWithoutNames} for an empty list.\n */\nexport async function ensureLocalCertificate(\n\tauthority: LocalAuthority,\n\tnames: readonly string[],\n\tfile: string,\n\toptions: { now?: Date } = {},\n): Promise<LocalCertificate & { issued: boolean }> {\n\tconst now = options.now ?? new Date();\n\tconst existing = await readFile(file, 'utf-8').catch(() => undefined);\n\tconst kept = existing ? splitPem(existing) : undefined;\n\tif (kept && stillGood(authority, kept, names, now)) {\n\t\treturn { ...kept, issued: false };\n\t}\n\n\tconst issued = issueLocalCertificate(authority, names, { now });\n\tawait mkdir(dirname(file), { recursive: true, mode: 0o700 });\n\tconst staging = `${file}.${process.pid}.${randomBytes(4).toString('hex')}`;\n\tawait writeFile(staging, `${issued.cert}${issued.key}`, { mode: 0o600 });\n\tawait rename(staging, file);\n\treturn { ...issued, issued: true };\n}\n\n/** A combined PEM file's certificate and key. */\nfunction splitPem(pem: string): LocalCertificate | undefined {\n\tconst cert = pem.match(\n\t\t/-----BEGIN CERTIFICATE-----[\\s\\S]+?-----END CERTIFICATE-----\\r?\\n?/,\n\t)?.[0];\n\tconst key = pem.match(\n\t\t/-----BEGIN (?:RSA )?PRIVATE KEY-----[\\s\\S]+?-----END (?:RSA )?PRIVATE KEY-----\\r?\\n?/,\n\t)?.[0];\n\treturn cert && key ? { cert, key } : undefined;\n}\n\n/** Whether a kept certificate still serves: the authority's, every name, in date. */\nfunction stillGood(\n\tauthority: LocalAuthority,\n\tkept: LocalCertificate,\n\tnames: readonly string[],\n\tnow: Date,\n): boolean {\n\ttry {\n\t\tconst root = forge.pki.certificateFromPem(authority.cert);\n\t\tconst cert = forge.pki.certificateFromPem(kept.cert);\n\t\tif (!root.verify(cert)) return false;\n\t\tif (\n\t\t\tcert.validity.notAfter.getTime() - now.getTime() <\n\t\t\tRENEW_WITHIN_DAYS * DAY\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\t// The key is the certificate's: a half-written pair is issued again.\n\t\tconst certKey = createPublicKey(kept.cert).export({\n\t\t\ttype: 'spki',\n\t\t\tformat: 'der',\n\t\t});\n\t\tconst ownKey = createPublicKey(createPrivateKey(kept.key)).export({\n\t\t\ttype: 'spki',\n\t\t\tformat: 'der',\n\t\t});\n\t\tif (!certKey.equals(ownKey)) return false;\n\t\tconst san = cert.getExtension('subjectAltName') as\n\t\t\t| { altNames?: { type: number; value: string }[] }\n\t\t\t| undefined;\n\t\tconst dns = new Set(\n\t\t\t(san?.altNames ?? []).filter((n) => n.type === 2).map((n) => n.value),\n\t\t);\n\t\treturn names.every((name) => dns.has(name));\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** An RSA key pair, made natively — forge's own generation is slow. */\nfunction keyPair(): {\n\tprivateKey: forge.pki.rsa.PrivateKey;\n\tpublicKey: forge.pki.rsa.PublicKey;\n} {\n\tconst { privateKey: pem } = generateKeyPairSync('rsa', {\n\t\tmodulusLength: 2048,\n\t\tpublicKeyEncoding: { type: 'spki', format: 'pem' },\n\t\tprivateKeyEncoding: { type: 'pkcs8', format: 'pem' },\n\t});\n\tconst privateKey = forge.pki.privateKeyFromPem(\n\t\tpem,\n\t) as forge.pki.rsa.PrivateKey;\n\treturn {\n\t\tprivateKey,\n\t\tpublicKey: forge.pki.setRsaPublicKey(privateKey.n, privateKey.e),\n\t};\n}\n\n/**\n * Attributes as UTF8String. forge writes PrintableString otherwise, which\n * has no `@` or `*` — and a TLS stack rejects the certificate outright.\n */\nfunction utf8(\n\tattributes: { name: string; value: string }[],\n): forge.pki.CertificateField[] {\n\treturn attributes.map((attribute) => ({\n\t\t...attribute,\n\t\tvalueTagClass: forge.asn1.Type.UTF8 as never,\n\t}));\n}\n\n/** A random, positive serial: sixteen bytes, its high bit clear. */\nfunction serialNumber(): string {\n\tconst bytes = randomBytes(16);\n\tbytes[0] = bytes[0]! & 0x7f;\n\treturn bytes.toString('hex');\n}\n\n/** `user@host`, as far as the machine will say. */\nfunction owner(): string {\n\tlet user = 'gkm';\n\ttry {\n\t\tuser = userInfo().username;\n\t} catch {\n\t\t// No passwd entry — a container's arbitrary uid.\n\t}\n\treturn `${user}@${hostname()}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAM,iBAAiB;;;;;AAMvB,MAAa,mBAAmB;;AAGhC,MAAM,oBAAoB;AAE1B,MAAM,MAAM;;AAGZ,SAAgB,oBAAoB,MAAmC;CACtE,MAAM,OAAA,GAAMA,UAAAA,KAAAA,CAAK,MAAM,IAAI;CAC3B,OAAO;EACN;EACA,WAAA,GAAUA,UAAAA,KAAAA,CAAK,KAAK,UAAU;EAC9B,UAAA,GAASA,UAAAA,KAAAA,CAAK,KAAK,cAAc;CAClC;AACD;;AAGA,IAAa,wBAAb,cAA2CC,eAAAA,UAAU;CAE1C;CACA;CAFV,YACC,KACA,QACC;EACD,MACC,wCAAwC,IAAI,mBAAmB,OAAO,6HAGvE;EAPS,KAAA,MAAA;EACA,KAAA,SAAA;EAOT,KAAK,OAAO;CACb;AACD;;AAGA,IAAa,+BAAb,cAAkDA,eAAAA,UAAU;CAC3D,cAAc;EACb,MACC,sIAED;EACA,KAAK,OAAO;CACb;AACD;;;;;;;;;;;AAYA,eAAsB,qBACrB,OAC0B;CAC1B,IAAI,EAAA,GAACC,QAAAA,WAAAA,CAAW,MAAM,GAAG,GAAG,MAAM,gBAAgB,KAAK;CACvD,OAAO,mBAAmB,KAAK;AAChC;;;;;;AAOA,eAAsB,mBACrB,OAC0B;CAC1B,IAAI;CACJ,IAAI;CACJ,IAAI;EACH,CAAC,MAAM,OAAO,MAAM,QAAQ,IAAI,EAAA,GAC/BC,iBAAAA,SAAAA,CAAS,MAAM,UAAU,OAAO,IAAA,GAChCA,iBAAAA,SAAAA,CAAS,MAAM,SAAS,OAAO,CAChC,CAAC;CAC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,gBAAgB,WAAW,GAAG,WAAW,CAAC;CAChE;AACD;;;;;AAMA,SAAS,KACR,YAC+B;CAC/B,OAAO,WAAW,KAAK,eAAe;EACrC,GAAG;EACH,eAAeA,WAAAA,QAAM,KAAK,KAAK;CAChC,EAAE;AACH;;AAGA,SAAS,eAAuB;CAC/B,MAAM,SAAA,GAAQC,YAAAA,YAAAA,CAAY,EAAE;CAC5B,MAAM,KAAK,MAAM,KAAM;CACvB,OAAO,MAAM,SAAS,KAAK;AAC5B;;AAGA,SAAS,QAAgB;CACxB,IAAI,OAAO;CACX,IAAI;EACH,QAAA,GAAOS,QAAAA,SAAAA,CAAS,CAAC,CAAC;CACnB,QAAQ,CAER;CACA,OAAO,GAAG,KAAK,IAAA,GAAGC,QAAAA,SAAAA,CAAS;AAC5B"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { t as EdgeError } from "../errors-DBZfelEN.cjs";
|
|
2
|
+
//#region src/certificates/local.d.ts
|
|
3
|
+
/** Where the authority's files are. */
|
|
4
|
+
export interface LocalAuthorityPaths {
|
|
5
|
+
dir: string;
|
|
6
|
+
/** The root certificate, PEM — the only file anything else is handed. */
|
|
7
|
+
certFile: string;
|
|
8
|
+
/** The root's private key, PEM. Owner-only, and never copied anywhere. */
|
|
9
|
+
keyFile: string;
|
|
10
|
+
}
|
|
11
|
+
/** The authority, loaded: its root certificate and the key it signs with. */
|
|
12
|
+
export interface LocalAuthority {
|
|
13
|
+
certFile: string;
|
|
14
|
+
/** The root certificate, PEM. */
|
|
15
|
+
cert: string;
|
|
16
|
+
/** The root's private key, PEM. */
|
|
17
|
+
key: string;
|
|
18
|
+
}
|
|
19
|
+
/** A certificate the authority issued, and its key, both PEM. */
|
|
20
|
+
export interface LocalCertificate {
|
|
21
|
+
cert: string;
|
|
22
|
+
key: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* How long an issued certificate is good for. Under Apple's 825-day limit
|
|
26
|
+
* for a root a user added, and renewed long before it ends.
|
|
27
|
+
*/
|
|
28
|
+
export declare const CERTIFICATE_DAYS = 365;
|
|
29
|
+
/** The authority's files, under the CLI's home. */
|
|
30
|
+
export declare function localAuthorityPaths(home: string): LocalAuthorityPaths;
|
|
31
|
+
/** The authority's directory is there, and its root or key is not readable. */
|
|
32
|
+
export declare class LocalAuthorityDamaged extends EdgeError {
|
|
33
|
+
readonly dir: string;
|
|
34
|
+
readonly reason: string;
|
|
35
|
+
constructor(dir: string, reason: string);
|
|
36
|
+
}
|
|
37
|
+
/** A certificate asked for with no names to put on it. */
|
|
38
|
+
export declare class LocalCertificateWithoutNames extends EdgeError {
|
|
39
|
+
constructor();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Load the authority, creating it the first time.
|
|
43
|
+
*
|
|
44
|
+
* Created whole or not at all: generated into a directory of its own and
|
|
45
|
+
* renamed into place, so two commands starting at once — `gkm dev` for two
|
|
46
|
+
* apps — end with one root between them, never one's certificate and the
|
|
47
|
+
* other's key.
|
|
48
|
+
*
|
|
49
|
+
* @throws {LocalAuthorityDamaged} when its directory holds no usable root.
|
|
50
|
+
*/
|
|
51
|
+
export declare function ensureLocalAuthority(paths: LocalAuthorityPaths): Promise<LocalAuthority>;
|
|
52
|
+
/**
|
|
53
|
+
* Load an authority that exists.
|
|
54
|
+
*
|
|
55
|
+
* @throws {LocalAuthorityDamaged} when its root or key is missing or unreadable.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readLocalAuthority(paths: LocalAuthorityPaths): Promise<LocalAuthority>;
|
|
58
|
+
/**
|
|
59
|
+
* The names a project's local certificate carries: its bare host and every
|
|
60
|
+
* label under it — `shop.localhost`, `*.shop.localhost` — and any host the
|
|
61
|
+
* edge serves that those do not cover, a stage's own wildcard among them.
|
|
62
|
+
* Without a project, the hosts alone: `*.localhost` is nobody's to claim.
|
|
63
|
+
*/
|
|
64
|
+
export declare function localCertificateNames(project: string, hosts: readonly string[]): string[];
|
|
65
|
+
/**
|
|
66
|
+
* A certificate for `names`, signed by the authority. Each call makes a new
|
|
67
|
+
* key; {@link ensureLocalCertificate} is what keeps one across runs.
|
|
68
|
+
*
|
|
69
|
+
* @throws {LocalCertificateWithoutNames} for an empty list.
|
|
70
|
+
*/
|
|
71
|
+
export declare function issueLocalCertificate(authority: LocalAuthority, names: readonly string[], options?: {
|
|
72
|
+
now?: Date;
|
|
73
|
+
days?: number;
|
|
74
|
+
}): LocalCertificate;
|
|
75
|
+
/**
|
|
76
|
+
* The certificate for `names` kept in `file` — certificate then key, one PEM
|
|
77
|
+
* file, which is what a proxy given the same path for both reads — issued
|
|
78
|
+
* again only when the one there is not the authority's, does not cover every
|
|
79
|
+
* name, or is near its end.
|
|
80
|
+
*
|
|
81
|
+
* One file written by rename, so two commands issuing at once leave a pair
|
|
82
|
+
* that matches, never one's certificate beside the other's key.
|
|
83
|
+
*
|
|
84
|
+
* @throws {LocalCertificateWithoutNames} for an empty list.
|
|
85
|
+
*/
|
|
86
|
+
export declare function ensureLocalCertificate(authority: LocalAuthority, names: readonly string[], file: string, options?: {
|
|
87
|
+
now?: Date;
|
|
88
|
+
}): Promise<LocalCertificate & {
|
|
89
|
+
issued: boolean;
|
|
90
|
+
}>;
|
|
91
|
+
//#endregion
|
|
92
|
+
//# sourceMappingURL=local.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.d.cts","names":[],"sources":["../../src/certificates/local.ts"],"mappings":";;;iBA+BiB;EAChB;;EAEA;;EAEA;;;iBAIgB;EAChB;;EAEA;;EAEA;;;iBAIgB;EAChB;EACA;;;;;;qBAUY;;wBAQG,oBAAoB,eAAe;;qBAUtC,8BAA8B;WAEhC;WACA;EAFV,YACU,aACA;;;qBAYE,qCAAqC;EACjD;;;;;;;;;;;;wBAmBqB,qBACrB,OAAO,sBACL,QAAQ;;;;;;wBAUW,mBACrB,OAAO,sBACL,QAAQ;;;;;;;wBAuFK,sBACf,iBACA;;;;;;;wBA2Be,sBACf,WAAW,gBACX,0BACA;EAAW,MAAM;EAAM;IACrB;;;;;;;;;;;;wBA0DmB,uBACrB,WAAW,gBACX,0BACA,cACA;EAAW,MAAM;IACf,QAAQ;EAAqB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { t as EdgeError } from "../errors-DBZfelEN.mjs";
|
|
2
|
+
//#region src/certificates/local.d.ts
|
|
3
|
+
/** Where the authority's files are. */
|
|
4
|
+
export interface LocalAuthorityPaths {
|
|
5
|
+
dir: string;
|
|
6
|
+
/** The root certificate, PEM — the only file anything else is handed. */
|
|
7
|
+
certFile: string;
|
|
8
|
+
/** The root's private key, PEM. Owner-only, and never copied anywhere. */
|
|
9
|
+
keyFile: string;
|
|
10
|
+
}
|
|
11
|
+
/** The authority, loaded: its root certificate and the key it signs with. */
|
|
12
|
+
export interface LocalAuthority {
|
|
13
|
+
certFile: string;
|
|
14
|
+
/** The root certificate, PEM. */
|
|
15
|
+
cert: string;
|
|
16
|
+
/** The root's private key, PEM. */
|
|
17
|
+
key: string;
|
|
18
|
+
}
|
|
19
|
+
/** A certificate the authority issued, and its key, both PEM. */
|
|
20
|
+
export interface LocalCertificate {
|
|
21
|
+
cert: string;
|
|
22
|
+
key: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* How long an issued certificate is good for. Under Apple's 825-day limit
|
|
26
|
+
* for a root a user added, and renewed long before it ends.
|
|
27
|
+
*/
|
|
28
|
+
export declare const CERTIFICATE_DAYS = 365;
|
|
29
|
+
/** The authority's files, under the CLI's home. */
|
|
30
|
+
export declare function localAuthorityPaths(home: string): LocalAuthorityPaths;
|
|
31
|
+
/** The authority's directory is there, and its root or key is not readable. */
|
|
32
|
+
export declare class LocalAuthorityDamaged extends EdgeError {
|
|
33
|
+
readonly dir: string;
|
|
34
|
+
readonly reason: string;
|
|
35
|
+
constructor(dir: string, reason: string);
|
|
36
|
+
}
|
|
37
|
+
/** A certificate asked for with no names to put on it. */
|
|
38
|
+
export declare class LocalCertificateWithoutNames extends EdgeError {
|
|
39
|
+
constructor();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Load the authority, creating it the first time.
|
|
43
|
+
*
|
|
44
|
+
* Created whole or not at all: generated into a directory of its own and
|
|
45
|
+
* renamed into place, so two commands starting at once — `gkm dev` for two
|
|
46
|
+
* apps — end with one root between them, never one's certificate and the
|
|
47
|
+
* other's key.
|
|
48
|
+
*
|
|
49
|
+
* @throws {LocalAuthorityDamaged} when its directory holds no usable root.
|
|
50
|
+
*/
|
|
51
|
+
export declare function ensureLocalAuthority(paths: LocalAuthorityPaths): Promise<LocalAuthority>;
|
|
52
|
+
/**
|
|
53
|
+
* Load an authority that exists.
|
|
54
|
+
*
|
|
55
|
+
* @throws {LocalAuthorityDamaged} when its root or key is missing or unreadable.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readLocalAuthority(paths: LocalAuthorityPaths): Promise<LocalAuthority>;
|
|
58
|
+
/**
|
|
59
|
+
* The names a project's local certificate carries: its bare host and every
|
|
60
|
+
* label under it — `shop.localhost`, `*.shop.localhost` — and any host the
|
|
61
|
+
* edge serves that those do not cover, a stage's own wildcard among them.
|
|
62
|
+
* Without a project, the hosts alone: `*.localhost` is nobody's to claim.
|
|
63
|
+
*/
|
|
64
|
+
export declare function localCertificateNames(project: string, hosts: readonly string[]): string[];
|
|
65
|
+
/**
|
|
66
|
+
* A certificate for `names`, signed by the authority. Each call makes a new
|
|
67
|
+
* key; {@link ensureLocalCertificate} is what keeps one across runs.
|
|
68
|
+
*
|
|
69
|
+
* @throws {LocalCertificateWithoutNames} for an empty list.
|
|
70
|
+
*/
|
|
71
|
+
export declare function issueLocalCertificate(authority: LocalAuthority, names: readonly string[], options?: {
|
|
72
|
+
now?: Date;
|
|
73
|
+
days?: number;
|
|
74
|
+
}): LocalCertificate;
|
|
75
|
+
/**
|
|
76
|
+
* The certificate for `names` kept in `file` — certificate then key, one PEM
|
|
77
|
+
* file, which is what a proxy given the same path for both reads — issued
|
|
78
|
+
* again only when the one there is not the authority's, does not cover every
|
|
79
|
+
* name, or is near its end.
|
|
80
|
+
*
|
|
81
|
+
* One file written by rename, so two commands issuing at once leave a pair
|
|
82
|
+
* that matches, never one's certificate beside the other's key.
|
|
83
|
+
*
|
|
84
|
+
* @throws {LocalCertificateWithoutNames} for an empty list.
|
|
85
|
+
*/
|
|
86
|
+
export declare function ensureLocalCertificate(authority: LocalAuthority, names: readonly string[], file: string, options?: {
|
|
87
|
+
now?: Date;
|
|
88
|
+
}): Promise<LocalCertificate & {
|
|
89
|
+
issued: boolean;
|
|
90
|
+
}>;
|
|
91
|
+
//#endregion
|
|
92
|
+
//# sourceMappingURL=local.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.d.mts","names":[],"sources":["../../src/certificates/local.ts"],"mappings":";;;iBA+BiB;EAChB;;EAEA;;EAEA;;;iBAIgB;EAChB;;EAEA;;EAEA;;;iBAIgB;EAChB;EACA;;;;;;qBAUY;;wBAQG,oBAAoB,eAAe;;qBAUtC,8BAA8B;WAEhC;WACA;EAFV,YACU,aACA;;;qBAYE,qCAAqC;EACjD;;;;;;;;;;;;wBAmBqB,qBACrB,OAAO,sBACL,QAAQ;;;;;;wBAUW,mBACrB,OAAO,sBACL,QAAQ;;;;;;;wBAuFK,sBACf,iBACA;;;;;;;wBA2Be,sBACf,WAAW,gBACX,0BACA;EAAW,MAAM;EAAM;IACrB;;;;;;;;;;;;wBA0DmB,uBACrB,WAAW,gBACX,0BACA,cACA;EAAW,MAAM;IACf,QAAQ;EAAqB"}
|