@rcpooley/concord 0.1.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.
- package/LICENSE +21 -0
- package/README.md +318 -0
- package/bin/concord.service +69 -0
- package/dist/age.d.ts +20 -0
- package/dist/age.d.ts.map +1 -0
- package/dist/age.js +58 -0
- package/dist/age.js.map +1 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +301 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/daemon.d.ts +4 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +394 -0
- package/dist/daemon.js.map +1 -0
- package/dist/eval-config.d.ts +2 -0
- package/dist/eval-config.d.ts.map +1 -0
- package/dist/eval-config.js +45 -0
- package/dist/eval-config.js.map +1 -0
- package/dist/exec.d.ts +168 -0
- package/dist/exec.d.ts.map +1 -0
- package/dist/exec.js +313 -0
- package/dist/exec.js.map +1 -0
- package/dist/git.d.ts +59 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +265 -0
- package/dist/git.js.map +1 -0
- package/dist/hook.d.ts +37 -0
- package/dist/hook.d.ts.map +1 -0
- package/dist/hook.js +89 -0
- package/dist/hook.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +76 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +236 -0
- package/dist/init.js.map +1 -0
- package/dist/loader.d.ts +35 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +230 -0
- package/dist/loader.js.map +1 -0
- package/dist/module.d.ts +116 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +100 -0
- package/dist/module.js.map +1 -0
- package/dist/modules/apt/index.d.ts +45 -0
- package/dist/modules/apt/index.d.ts.map +1 -0
- package/dist/modules/apt/index.js +249 -0
- package/dist/modules/apt/index.js.map +1 -0
- package/dist/modules/apt/schema.d.ts +63 -0
- package/dist/modules/apt/schema.d.ts.map +1 -0
- package/dist/modules/apt/schema.js +75 -0
- package/dist/modules/apt/schema.js.map +1 -0
- package/dist/modules/checkout/index.d.ts +88 -0
- package/dist/modules/checkout/index.d.ts.map +1 -0
- package/dist/modules/checkout/index.js +382 -0
- package/dist/modules/checkout/index.js.map +1 -0
- package/dist/modules/checkout/schema.d.ts +52 -0
- package/dist/modules/checkout/schema.d.ts.map +1 -0
- package/dist/modules/checkout/schema.js +132 -0
- package/dist/modules/checkout/schema.js.map +1 -0
- package/dist/modules/cloudflare/api.d.ts +64 -0
- package/dist/modules/cloudflare/api.d.ts.map +1 -0
- package/dist/modules/cloudflare/api.js +98 -0
- package/dist/modules/cloudflare/api.js.map +1 -0
- package/dist/modules/cloudflare/index.d.ts +74 -0
- package/dist/modules/cloudflare/index.d.ts.map +1 -0
- package/dist/modules/cloudflare/index.js +374 -0
- package/dist/modules/cloudflare/index.js.map +1 -0
- package/dist/modules/cloudflare/schema.d.ts +62 -0
- package/dist/modules/cloudflare/schema.d.ts.map +1 -0
- package/dist/modules/cloudflare/schema.js +85 -0
- package/dist/modules/cloudflare/schema.js.map +1 -0
- package/dist/modules/docker/index.d.ts +83 -0
- package/dist/modules/docker/index.d.ts.map +1 -0
- package/dist/modules/docker/index.js +470 -0
- package/dist/modules/docker/index.js.map +1 -0
- package/dist/modules/docker/registry.d.ts +35 -0
- package/dist/modules/docker/registry.d.ts.map +1 -0
- package/dist/modules/docker/registry.js +95 -0
- package/dist/modules/docker/registry.js.map +1 -0
- package/dist/modules/docker/render.d.ts +45 -0
- package/dist/modules/docker/render.d.ts.map +1 -0
- package/dist/modules/docker/render.js +162 -0
- package/dist/modules/docker/render.js.map +1 -0
- package/dist/modules/docker/schema.d.ts +231 -0
- package/dist/modules/docker/schema.d.ts.map +1 -0
- package/dist/modules/docker/schema.js +335 -0
- package/dist/modules/docker/schema.js.map +1 -0
- package/dist/modules/docker/sweeper.d.ts +64 -0
- package/dist/modules/docker/sweeper.d.ts.map +1 -0
- package/dist/modules/docker/sweeper.js +94 -0
- package/dist/modules/docker/sweeper.js.map +1 -0
- package/dist/modules/file/index.d.ts +79 -0
- package/dist/modules/file/index.d.ts.map +1 -0
- package/dist/modules/file/index.js +305 -0
- package/dist/modules/file/index.js.map +1 -0
- package/dist/modules/file/schema.d.ts +45 -0
- package/dist/modules/file/schema.d.ts.map +1 -0
- package/dist/modules/file/schema.js +114 -0
- package/dist/modules/file/schema.js.map +1 -0
- package/dist/modules/index.d.ts +20 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +11 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/porkbun/api.d.ts +36 -0
- package/dist/modules/porkbun/api.d.ts.map +1 -0
- package/dist/modules/porkbun/api.js +62 -0
- package/dist/modules/porkbun/api.js.map +1 -0
- package/dist/modules/porkbun/index.d.ts +50 -0
- package/dist/modules/porkbun/index.d.ts.map +1 -0
- package/dist/modules/porkbun/index.js +236 -0
- package/dist/modules/porkbun/index.js.map +1 -0
- package/dist/modules/porkbun/schema.d.ts +38 -0
- package/dist/modules/porkbun/schema.d.ts.map +1 -0
- package/dist/modules/porkbun/schema.js +39 -0
- package/dist/modules/porkbun/schema.js.map +1 -0
- package/dist/modules/script/index.d.ts +43 -0
- package/dist/modules/script/index.d.ts.map +1 -0
- package/dist/modules/script/index.js +116 -0
- package/dist/modules/script/index.js.map +1 -0
- package/dist/modules/script/schema.d.ts +25 -0
- package/dist/modules/script/schema.d.ts.map +1 -0
- package/dist/modules/script/schema.js +63 -0
- package/dist/modules/script/schema.js.map +1 -0
- package/dist/modules/systemd/index.d.ts +93 -0
- package/dist/modules/systemd/index.d.ts.map +1 -0
- package/dist/modules/systemd/index.js +394 -0
- package/dist/modules/systemd/index.js.map +1 -0
- package/dist/modules/systemd/render.d.ts +41 -0
- package/dist/modules/systemd/render.d.ts.map +1 -0
- package/dist/modules/systemd/render.js +252 -0
- package/dist/modules/systemd/render.js.map +1 -0
- package/dist/modules/systemd/schema.d.ts +293 -0
- package/dist/modules/systemd/schema.d.ts.map +1 -0
- package/dist/modules/systemd/schema.js +302 -0
- package/dist/modules/systemd/schema.js.map +1 -0
- package/dist/modules/systemd/sweeper.d.ts +31 -0
- package/dist/modules/systemd/sweeper.d.ts.map +1 -0
- package/dist/modules/systemd/sweeper.js +77 -0
- package/dist/modules/systemd/sweeper.js.map +1 -0
- package/dist/plans.d.ts +132 -0
- package/dist/plans.d.ts.map +1 -0
- package/dist/plans.js +315 -0
- package/dist/plans.js.map +1 -0
- package/dist/records.d.ts +37 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +100 -0
- package/dist/records.js.map +1 -0
- package/dist/registry.d.ts +38 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +31 -0
- package/dist/registry.js.map +1 -0
- package/dist/runner.d.ts +48 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +150 -0
- package/dist/runner.js.map +1 -0
- package/dist/scheduler.d.ts +36 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +77 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/schema.d.ts +762 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +185 -0
- package/dist/schema.js.map +1 -0
- package/dist/secret.d.ts +24 -0
- package/dist/secret.d.ts.map +1 -0
- package/dist/secret.js +3 -0
- package/dist/secret.js.map +1 -0
- package/dist/ui.d.ts +62 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +288 -0
- package/dist/ui.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { relative, resolve } from 'node:path';
|
|
4
|
+
import { Module } from '../../module.js';
|
|
5
|
+
const sha256 = (s) => createHash('sha256').update(s).digest('hex');
|
|
6
|
+
// ------------------------------------------------------------ resolution ----
|
|
7
|
+
/**
|
|
8
|
+
* POSIX-ish user/group name. Anything else is rejected rather than passed to a
|
|
9
|
+
* shell — the config repo is trusted, but a name is not a place to accept
|
|
10
|
+
* arbitrary text that ends up in a command.
|
|
11
|
+
*/
|
|
12
|
+
const NAME_RE = /^[a-z_][a-z0-9_-]*\$?$/i;
|
|
13
|
+
/** Apply `${NAME}` substitutions with already-decrypted values. */
|
|
14
|
+
export function substitute(content, values) {
|
|
15
|
+
return content.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (whole, name) => name in values ? values[name] : whole);
|
|
16
|
+
}
|
|
17
|
+
// --------------------------------------------------------------- module ----
|
|
18
|
+
export class FileModule extends Module {
|
|
19
|
+
config;
|
|
20
|
+
kind = 'file';
|
|
21
|
+
constructor(config) {
|
|
22
|
+
super(config.id, config.host);
|
|
23
|
+
this.config = config;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Names already resolved this run. Ids do not change under a running
|
|
27
|
+
* reconcile, and a module is rebuilt from the config each run, so there is
|
|
28
|
+
* nothing to invalidate.
|
|
29
|
+
*/
|
|
30
|
+
idCache = new Map();
|
|
31
|
+
/**
|
|
32
|
+
* Resolve an owner/group to its NUMERIC id.
|
|
33
|
+
*
|
|
34
|
+
* `read()` reports `stat -c %u`, which is always numeric, so a declared
|
|
35
|
+
* *name* has to be resolved before the two can be compared at all. Without
|
|
36
|
+
* this, `owner: 'root'` never equals the `"0"` read back: the path is
|
|
37
|
+
* reported as drifted and re-chowned on every single reconcile, forever,
|
|
38
|
+
* while the run still reports `converged — no changes`. The chown succeeds
|
|
39
|
+
* every time, so there is no symptom to notice — which is precisely what
|
|
40
|
+
* makes it worth fixing rather than documenting.
|
|
41
|
+
*
|
|
42
|
+
* The reverse mapping is NOT an option: a uid may have no passwd entry at all
|
|
43
|
+
* (a container's volume is often owned by a uid like 9999), and several names can share
|
|
44
|
+
* one id. Numeric is the canonical form; names resolve toward it.
|
|
45
|
+
*
|
|
46
|
+
* Resolution runs on the TARGET host, because ids are per-host — `root` is 0
|
|
47
|
+
* by near-universal convention, but nothing else is.
|
|
48
|
+
*/
|
|
49
|
+
resolveId(kind, v) {
|
|
50
|
+
if (v === undefined)
|
|
51
|
+
return undefined;
|
|
52
|
+
const s = String(v);
|
|
53
|
+
if (/^\d+$/.test(s))
|
|
54
|
+
return s;
|
|
55
|
+
const key = `${kind}:${s}`;
|
|
56
|
+
const cached = this.idCache.get(key);
|
|
57
|
+
if (cached !== undefined)
|
|
58
|
+
return cached;
|
|
59
|
+
if (!NAME_RE.test(s)) {
|
|
60
|
+
throw new Error(`${this.kind}:${this.id}: "${s}" is not a valid ${kind} name or numeric id`);
|
|
61
|
+
}
|
|
62
|
+
const cmd = kind === 'owner' ? `id -u '${s}'` : `getent group '${s}' | cut -d: -f3`;
|
|
63
|
+
const r = this.exec.runScript(cmd);
|
|
64
|
+
const id = r.output.trim();
|
|
65
|
+
// Fails CLOSED. An unresolvable name means chown would fail anyway, and
|
|
66
|
+
// treating it as "no opinion" would silently stop managing ownership.
|
|
67
|
+
if (r.status !== 0 || !/^\d+$/.test(id)) {
|
|
68
|
+
throw new Error(`${this.kind}:${this.id}: no such ${kind} "${s}" on this host — ` +
|
|
69
|
+
`declare a numeric id if it has no passwd/group entry`);
|
|
70
|
+
}
|
|
71
|
+
this.idCache.set(key, id);
|
|
72
|
+
return id;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Resolve a `source` path against the config repo.
|
|
76
|
+
*
|
|
77
|
+
* Rejects traversal outside the repo — a config repo should never be able to
|
|
78
|
+
* make the reconciler read `/etc/shadow` and write it somewhere.
|
|
79
|
+
*/
|
|
80
|
+
resolveSource(source) {
|
|
81
|
+
const root = resolve(this.configDir);
|
|
82
|
+
const full = resolve(root, source);
|
|
83
|
+
const rel = relative(root, full);
|
|
84
|
+
if (rel.startsWith('..') || resolve(rel) === rel) {
|
|
85
|
+
throw new Error(`${this.kind}:${this.id}: source "${source}" resolves outside the config repo`);
|
|
86
|
+
}
|
|
87
|
+
if (!existsSync(full)) {
|
|
88
|
+
throw new Error(`${this.kind}:${this.id}: source "${source}" not found in the config repo`);
|
|
89
|
+
}
|
|
90
|
+
return full;
|
|
91
|
+
}
|
|
92
|
+
/** The exact bytes that should be on disk. Undefined for url-pinned files. */
|
|
93
|
+
async resolveContent(f) {
|
|
94
|
+
let raw;
|
|
95
|
+
if (f.content !== undefined)
|
|
96
|
+
raw = f.content;
|
|
97
|
+
else if (f.source !== undefined)
|
|
98
|
+
raw = readFileSync(this.resolveSource(f.source), 'utf8');
|
|
99
|
+
else
|
|
100
|
+
return undefined; // url: pinned by sha256, content only materialised on apply
|
|
101
|
+
if (!f.substitutions)
|
|
102
|
+
return raw;
|
|
103
|
+
const values = {};
|
|
104
|
+
for (const [name, ref] of Object.entries(f.substitutions)) {
|
|
105
|
+
values[name] = await this.secret(ref);
|
|
106
|
+
}
|
|
107
|
+
return substitute(raw, values);
|
|
108
|
+
}
|
|
109
|
+
async desired() {
|
|
110
|
+
const seen = new Set();
|
|
111
|
+
const files = [];
|
|
112
|
+
for (const f of this.config.files ?? []) {
|
|
113
|
+
if (seen.has(f.path)) {
|
|
114
|
+
throw new Error(`${this.kind}:${this.id}: "${f.path}" declared twice`);
|
|
115
|
+
}
|
|
116
|
+
seen.add(f.path);
|
|
117
|
+
const content = await this.resolveContent(f);
|
|
118
|
+
files.push({
|
|
119
|
+
path: f.path,
|
|
120
|
+
exists: true,
|
|
121
|
+
hash: content === undefined ? f.sha256 : sha256(content),
|
|
122
|
+
uid: this.resolveId('owner', f.owner),
|
|
123
|
+
gid: this.resolveId('group', f.group),
|
|
124
|
+
mode: f.mode,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
for (const p of this.config.absent ?? []) {
|
|
128
|
+
if (seen.has(p)) {
|
|
129
|
+
throw new Error(`${this.kind}:${this.id}: "${p}" declared both as a file and absent — pick one.`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
directories: (this.config.directories ?? []).map((d) => ({
|
|
134
|
+
path: d.path,
|
|
135
|
+
exists: true,
|
|
136
|
+
isDir: true,
|
|
137
|
+
uid: this.resolveId('owner', d.owner),
|
|
138
|
+
gid: this.resolveId('group', d.group),
|
|
139
|
+
mode: d.mode,
|
|
140
|
+
})),
|
|
141
|
+
files,
|
|
142
|
+
absent: (this.config.absent ?? []).map((p) => ({ path: p, exists: false })),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
async read() {
|
|
146
|
+
const readPath = (path, wantContent) => {
|
|
147
|
+
const st = this.exec.statMaybe(path);
|
|
148
|
+
if (!st)
|
|
149
|
+
return { path, exists: false };
|
|
150
|
+
return {
|
|
151
|
+
path,
|
|
152
|
+
exists: true,
|
|
153
|
+
uid: st.uid,
|
|
154
|
+
gid: st.gid,
|
|
155
|
+
mode: st.mode,
|
|
156
|
+
isDir: st.type === 'directory',
|
|
157
|
+
// Privileged read: some managed paths are 0700 or owned by uid 9999, and
|
|
158
|
+
// an unprivileged read would look like "absent" and rewrite every run.
|
|
159
|
+
...(wantContent ? { hash: sha256(this.exec.sudoReadFileMaybe(path)) } : {}),
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
directories: (this.config.directories ?? []).map((d) => readPath(d.path, false)),
|
|
164
|
+
files: (this.config.files ?? []).map((f) => readPath(f.path, true)),
|
|
165
|
+
absent: (this.config.absent ?? []).map((p) => readPath(p, false)),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
diff(actual, desired) {
|
|
169
|
+
const ops = [];
|
|
170
|
+
const byPath = (list) => new Map(list.map((s) => [s.path, s]));
|
|
171
|
+
const actualDirs = byPath(actual.directories);
|
|
172
|
+
for (const [i, want] of desired.directories.entries()) {
|
|
173
|
+
const have = actualDirs.get(want.path);
|
|
174
|
+
const attrs = this.attrDrift(have, want);
|
|
175
|
+
if (!have?.exists) {
|
|
176
|
+
ops.push({
|
|
177
|
+
kind: 'create',
|
|
178
|
+
entity: 'directory',
|
|
179
|
+
id: `dir/${want.path}`,
|
|
180
|
+
summary: `create directory ${want.path}`,
|
|
181
|
+
path: want.path,
|
|
182
|
+
directory: this.config.directories[i],
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
else if (attrs.length) {
|
|
186
|
+
ops.push({
|
|
187
|
+
kind: 'update',
|
|
188
|
+
entity: 'directory',
|
|
189
|
+
id: `dir/${want.path}`,
|
|
190
|
+
summary: `update directory ${want.path} (${attrs.join(', ')})`,
|
|
191
|
+
path: want.path,
|
|
192
|
+
directory: this.config.directories[i],
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const actualFiles = byPath(actual.files);
|
|
197
|
+
for (const [i, want] of desired.files.entries()) {
|
|
198
|
+
const entry = this.config.files[i];
|
|
199
|
+
const have = actualFiles.get(want.path);
|
|
200
|
+
if (!have?.exists) {
|
|
201
|
+
ops.push({
|
|
202
|
+
kind: 'create',
|
|
203
|
+
entity: 'file',
|
|
204
|
+
id: `file/${want.path}`,
|
|
205
|
+
summary: `create ${want.path}`,
|
|
206
|
+
path: want.path,
|
|
207
|
+
file: entry,
|
|
208
|
+
});
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
const changes = [];
|
|
212
|
+
// Content is compared by hash and NEVER printed — a managed file may hold
|
|
213
|
+
// anything, so redaction is the default rather than conditional.
|
|
214
|
+
if (have.hash !== want.hash)
|
|
215
|
+
changes.push('content differs');
|
|
216
|
+
changes.push(...this.attrDrift(have, want));
|
|
217
|
+
if (changes.length) {
|
|
218
|
+
ops.push({
|
|
219
|
+
kind: 'update',
|
|
220
|
+
entity: 'file',
|
|
221
|
+
id: `file/${want.path}`,
|
|
222
|
+
summary: `update ${want.path} (${changes.join(', ')})`,
|
|
223
|
+
path: want.path,
|
|
224
|
+
file: entry,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
for (const want of desired.absent) {
|
|
229
|
+
const have = actual.absent.find((a) => a.path === want.path);
|
|
230
|
+
if (have?.exists) {
|
|
231
|
+
ops.push({
|
|
232
|
+
kind: 'delete',
|
|
233
|
+
entity: have.isDir ? 'directory' : 'file',
|
|
234
|
+
id: `absent/${want.path}`,
|
|
235
|
+
summary: `remove ${want.path}`,
|
|
236
|
+
path: want.path,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return ops;
|
|
241
|
+
}
|
|
242
|
+
attrDrift(have, want) {
|
|
243
|
+
const out = [];
|
|
244
|
+
if (!have)
|
|
245
|
+
return out;
|
|
246
|
+
if (want.uid !== undefined && have.uid !== want.uid) {
|
|
247
|
+
out.push(`owner ${have.uid} -> ${want.uid}`);
|
|
248
|
+
}
|
|
249
|
+
if (want.gid !== undefined && have.gid !== want.gid) {
|
|
250
|
+
out.push(`group ${have.gid} -> ${want.gid}`);
|
|
251
|
+
}
|
|
252
|
+
if (want.mode !== undefined && have.mode !== want.mode) {
|
|
253
|
+
out.push(`mode ${have.mode} -> ${want.mode}`);
|
|
254
|
+
}
|
|
255
|
+
return out;
|
|
256
|
+
}
|
|
257
|
+
applyAttrs(path, e) {
|
|
258
|
+
// Resolved, not raw: chown would accept the name, but then the value the
|
|
259
|
+
// plan compared and the value apply wrote would come from two different
|
|
260
|
+
// code paths. One path, one answer.
|
|
261
|
+
const owner = this.resolveId('owner', e.owner);
|
|
262
|
+
const group = this.resolveId('group', e.group);
|
|
263
|
+
if (owner !== undefined || group !== undefined) {
|
|
264
|
+
this.exec.sudo(['chown', `${owner ?? ''}:${group ?? ''}`, path]);
|
|
265
|
+
}
|
|
266
|
+
if (e.mode)
|
|
267
|
+
this.exec.sudo(['chmod', e.mode, path]);
|
|
268
|
+
}
|
|
269
|
+
async apply(ops) {
|
|
270
|
+
// Directories first — a file may live inside one this run is creating, and
|
|
271
|
+
// implicit mkdir -p cannot express uid 9999 / mode 0700.
|
|
272
|
+
for (const op of ops.filter((o) => o.entity === 'directory' && o.kind !== 'delete')) {
|
|
273
|
+
const d = op.directory;
|
|
274
|
+
this.exec.sudo(['mkdir', '-p', d.path]);
|
|
275
|
+
this.applyAttrs(d.path, d);
|
|
276
|
+
this.log(` ✓ ${op.kind}: ${op.summary}`);
|
|
277
|
+
}
|
|
278
|
+
for (const op of ops.filter((o) => o.entity === 'file' && o.kind !== 'delete')) {
|
|
279
|
+
const f = op.file;
|
|
280
|
+
let content = await this.resolveContent(f);
|
|
281
|
+
if (content === undefined) {
|
|
282
|
+
// url-pinned: fetch, then verify against the declared hash BEFORE it
|
|
283
|
+
// touches the disk. A changed upstream is a loud failure, not drift.
|
|
284
|
+
const res = await fetch(f.url);
|
|
285
|
+
if (!res.ok) {
|
|
286
|
+
throw new Error(`fetching ${f.url} failed: HTTP ${res.status}`);
|
|
287
|
+
}
|
|
288
|
+
content = await res.text();
|
|
289
|
+
const got = sha256(content);
|
|
290
|
+
if (got !== f.sha256) {
|
|
291
|
+
throw new Error(`checksum mismatch for ${f.url}\n declared ${f.sha256}\n fetched ${got}\n` +
|
|
292
|
+
`Refusing to write. Review the upstream change, then update sha256.`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
this.exec.writeFileAsRoot(f.path, content, f.mode ?? '0644');
|
|
296
|
+
this.applyAttrs(f.path, f);
|
|
297
|
+
this.log(` ✓ ${op.kind}: ${op.summary}`);
|
|
298
|
+
}
|
|
299
|
+
for (const op of ops.filter((o) => o.kind === 'delete')) {
|
|
300
|
+
this.exec.sudo(['rm', '-rf', op.path]);
|
|
301
|
+
this.log(` ✓ delete: ${op.summary}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE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eAAe,EAAE,CAAC,OAAO,EAAE,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const DirectorySchema: z.ZodObject<{
|
|
3
|
+
path: z.ZodString;
|
|
4
|
+
owner: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
5
|
+
group: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
6
|
+
mode: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
export declare const FileSchema: z.ZodObject<{
|
|
9
|
+
path: z.ZodString;
|
|
10
|
+
owner: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
11
|
+
group: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
12
|
+
mode: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
13
|
+
content: z.ZodOptional<z.ZodString>;
|
|
14
|
+
source: z.ZodOptional<z.ZodString>;
|
|
15
|
+
url: z.ZodOptional<z.ZodString>;
|
|
16
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
17
|
+
substitutions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<import("../../secret.js").Secret, import("../../secret.js").Secret>>>;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
export declare const FileConfigSchema: z.ZodObject<{
|
|
20
|
+
type: z.ZodLiteral<"file">;
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
host: z.ZodString;
|
|
23
|
+
directories: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
24
|
+
path: z.ZodString;
|
|
25
|
+
owner: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
26
|
+
group: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
27
|
+
mode: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
28
|
+
}, z.core.$strict>>>;
|
|
29
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
30
|
+
path: z.ZodString;
|
|
31
|
+
owner: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
32
|
+
group: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
33
|
+
mode: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
34
|
+
content: z.ZodOptional<z.ZodString>;
|
|
35
|
+
source: z.ZodOptional<z.ZodString>;
|
|
36
|
+
url: z.ZodOptional<z.ZodString>;
|
|
37
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
38
|
+
substitutions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<import("../../secret.js").Secret, import("../../secret.js").Secret>>>;
|
|
39
|
+
}, z.core.$strict>>>;
|
|
40
|
+
absent: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
export type FileEntry = z.output<typeof FileSchema>;
|
|
43
|
+
export type DirectoryEntry = z.output<typeof DirectorySchema>;
|
|
44
|
+
export type FileModuleConfig = z.output<typeof FileConfigSchema>;
|
|
45
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/file/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAmBvB,eAAO,MAAM,eAAe;;;;;kBAOjB,CAAA;AAEX,eAAO,MAAM,UAAU;;;;;;;;;;kBAqEnB,CAAA;AAEJ,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;kBA4BlB,CAAA;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAA;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAA;AAC7D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SecretSchema } from '../../secret.js';
|
|
3
|
+
/**
|
|
4
|
+
* `root`, or a bare uid/gid — some paths are owned by uid 9999, which has no
|
|
5
|
+
* passwd entry at all.
|
|
6
|
+
*
|
|
7
|
+
* A NAME costs one `id -u` / `getent group` on the target host per reconcile
|
|
8
|
+
* (cached per run) because ownership is compared numerically: `stat` only ever
|
|
9
|
+
* reports ids. Prefer the numeric form for paths owned by root — it is the same
|
|
10
|
+
* declaration with no lookup.
|
|
11
|
+
*/
|
|
12
|
+
const Owner = z.union([z.string().min(1), z.number().int().nonnegative()]);
|
|
13
|
+
const Mode = z
|
|
14
|
+
.string()
|
|
15
|
+
.regex(/^0?[0-7]{3}$/, 'must be an octal mode like "0644"')
|
|
16
|
+
.transform((m) => m.padStart(4, '0'));
|
|
17
|
+
export const DirectorySchema = z
|
|
18
|
+
.object({
|
|
19
|
+
path: z.string().startsWith('/', 'must be an absolute path'),
|
|
20
|
+
owner: Owner.optional(),
|
|
21
|
+
group: Owner.optional(),
|
|
22
|
+
mode: Mode.optional(),
|
|
23
|
+
})
|
|
24
|
+
.strict();
|
|
25
|
+
export const FileSchema = z
|
|
26
|
+
.object({
|
|
27
|
+
path: z.string().startsWith('/', 'must be an absolute path'),
|
|
28
|
+
owner: Owner.optional(),
|
|
29
|
+
group: Owner.optional(),
|
|
30
|
+
mode: Mode.optional(),
|
|
31
|
+
// ---- exactly one content source ----
|
|
32
|
+
/** Literal content, written as-is (after `substitutions`). */
|
|
33
|
+
content: z.string().optional(),
|
|
34
|
+
/**
|
|
35
|
+
* A path **relative to the config repo root**, for content too large or too
|
|
36
|
+
* awkward to inline. Git already versions it, so no checksum is needed.
|
|
37
|
+
* Path traversal outside the repo is rejected.
|
|
38
|
+
*/
|
|
39
|
+
source: z.string().min(1).optional(),
|
|
40
|
+
/**
|
|
41
|
+
* Fetched content, pinned by checksum.
|
|
42
|
+
*
|
|
43
|
+
* The hash **is** the version pin — you declare the bytes you actually
|
|
44
|
+
* reviewed, not a version string. An upstream change then surfaces as a
|
|
45
|
+
* failed checksum rather than silent drift, and `read()` never touches the
|
|
46
|
+
* network: it compares the on-disk hash to this one.
|
|
47
|
+
*/
|
|
48
|
+
url: z.string().url().optional(),
|
|
49
|
+
sha256: z.string().regex(/^[0-9a-f]{64}$/, 'must be a lowercase hex sha256').optional(),
|
|
50
|
+
/**
|
|
51
|
+
* `${NAME}` placeholders in `content`/`source` replaced with DECRYPTED
|
|
52
|
+
* secret values.
|
|
53
|
+
*
|
|
54
|
+
* This exists because `secrets['x']` is age *ciphertext* at author time — a
|
|
55
|
+
* plain template literal would embed the ciphertext in the file. Naming the
|
|
56
|
+
* secrets separately is what lets the module decrypt them.
|
|
57
|
+
*
|
|
58
|
+
* Not allowed with `url`: substituting would change the bytes and break the
|
|
59
|
+
* checksum that pins them.
|
|
60
|
+
*/
|
|
61
|
+
substitutions: z.record(z.string().min(1), SecretSchema).optional(),
|
|
62
|
+
})
|
|
63
|
+
.strict()
|
|
64
|
+
.superRefine((f, ctx) => {
|
|
65
|
+
const sources = [f.content !== undefined, f.source !== undefined, f.url !== undefined];
|
|
66
|
+
const n = sources.filter(Boolean).length;
|
|
67
|
+
if (n !== 1) {
|
|
68
|
+
ctx.addIssue({
|
|
69
|
+
code: 'custom',
|
|
70
|
+
message: n === 0
|
|
71
|
+
? 'needs exactly one content source: content, source, or url'
|
|
72
|
+
: 'content, source and url are mutually exclusive — pick one',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (f.url && !f.sha256) {
|
|
76
|
+
ctx.addIssue({ code: 'custom', message: 'url requires sha256 to pin the content' });
|
|
77
|
+
}
|
|
78
|
+
if (f.sha256 && !f.url) {
|
|
79
|
+
ctx.addIssue({ code: 'custom', message: 'sha256 only applies to url' });
|
|
80
|
+
}
|
|
81
|
+
if (f.url && f.substitutions) {
|
|
82
|
+
ctx.addIssue({
|
|
83
|
+
code: 'custom',
|
|
84
|
+
message: 'substitutions cannot be used with url — they would change the bytes the sha256 pins',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
export const FileConfigSchema = z
|
|
89
|
+
.object({
|
|
90
|
+
type: z.literal('file'),
|
|
91
|
+
id: z
|
|
92
|
+
.string()
|
|
93
|
+
.regex(/^[a-z0-9][a-z0-9-]*$/, 'must be kebab-case, starting alphanumeric'),
|
|
94
|
+
/**
|
|
95
|
+
* Which host this runs on — a key of the config's `hosts` registry.
|
|
96
|
+
*
|
|
97
|
+
* REQUIRED, with no default. A silently-defaulting host is a way to run
|
|
98
|
+
* something on the wrong machine, and "wherever Concord happens to be
|
|
99
|
+
* running" is not a property a config should depend on.
|
|
100
|
+
*/
|
|
101
|
+
host: z.string().min(1),
|
|
102
|
+
directories: z.array(DirectorySchema).optional(),
|
|
103
|
+
files: z.array(FileSchema).optional(),
|
|
104
|
+
/**
|
|
105
|
+
* Paths to delete.
|
|
106
|
+
*
|
|
107
|
+
* Like `apt`, this module is ADDITIVE — a filesystem has hundreds of
|
|
108
|
+
* thousands of paths, so undeclared ones are never touched and removal must
|
|
109
|
+
* be explicit.
|
|
110
|
+
*/
|
|
111
|
+
absent: z.array(z.string().startsWith('/')).optional(),
|
|
112
|
+
})
|
|
113
|
+
.strict();
|
|
114
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/modules/file/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM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,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAA;IACzE,CAAC;IACD,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;QAC7B,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,OAAO,EACL,qFAAqF;SACxF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC;KAC9B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,EAAE,EAAE,CAAC;SACF,MAAM,EAAE;SACR,KAAK,CAAC,sBAAsB,EAAE,2CAA2C,CAAC;IAG7E;;;;;;OAMG;IACH,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE;IAChD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE;IAErC;;;;;;OAMG;IACH,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE;CACvD,CAAC;KACD,MAAM,EAAE,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { PorkbunModule, orderOps } from './porkbun/index.js';
|
|
2
|
+
export type { PorkbunConfig, PorkbunState, PorkbunOp, DnsRecord, ZoneConfig, } from './porkbun/index.js';
|
|
3
|
+
export { CloudflareModule, planBatches, marker, isOwned } from './cloudflare/index.js';
|
|
4
|
+
export type { CloudflareConfig, CloudflareState, CloudflareOp, ZoneState, } from './cloudflare/index.js';
|
|
5
|
+
export { AptModule, renderSources, sourcesPath, keyPath } from './apt/index.js';
|
|
6
|
+
export type { AptState, AptOp, AptConfig } from './apt/index.js';
|
|
7
|
+
export { FileModule, substitute } from './file/index.js';
|
|
8
|
+
export type { FileState, FileOp, FileModuleConfig } from './file/index.js';
|
|
9
|
+
export { SystemdModule, renderUnit, parseUnit, unitsEquivalent, parseShow, unitPath, selfUnit } from './systemd/index.js';
|
|
10
|
+
export type { SystemdState, SystemdOp, SystemdConfig, UnitState } from './systemd/index.js';
|
|
11
|
+
export { SystemdSweeper } from './systemd/sweeper.js';
|
|
12
|
+
export { CheckoutModule } from './checkout/index.js';
|
|
13
|
+
export type { CheckoutConfig, CheckoutEntry, CheckoutState, CheckoutRecord, CheckoutOp, } from './checkout/index.js';
|
|
14
|
+
export { ScriptModule } from './script/index.js';
|
|
15
|
+
export type { ScriptModuleState, ScriptOp, ScriptConfig } from './script/index.js';
|
|
16
|
+
export { DockerModule, parseContainers, render, serialize, imageTag, resolveRefs, cloneUrl, githubSlug, } from './docker/index.js';
|
|
17
|
+
export type { ContainerState, DockerState, DockerOp, DockerConfig } from './docker/index.js';
|
|
18
|
+
export { DockerSweeper, parseUnowned } from './docker/sweeper.js';
|
|
19
|
+
export type { UnownedContainer, DockerSweepState } from './docker/sweeper.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC5D,YAAY,EACV,aAAa,EACb,YAAY,EACZ,SAAS,EACT,SAAS,EACT,UAAU,GACX,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACtF,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,SAAS,GACV,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,SAAS,EAAE,aAAa,EA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|
+
export { CloudflareModule, planBatches, marker, isOwned } from './cloudflare/index.js';
|
|
3
|
+
export { AptModule, renderSources, sourcesPath, keyPath } from './apt/index.js';
|
|
4
|
+
export { FileModule, substitute } from './file/index.js';
|
|
5
|
+
export { SystemdModule, renderUnit, parseUnit, unitsEquivalent, parseShow, unitPath, selfUnit } from './systemd/index.js';
|
|
6
|
+
export { SystemdSweeper } from './systemd/sweeper.js';
|
|
7
|
+
export { CheckoutModule } from './checkout/index.js';
|
|
8
|
+
export { ScriptModule } from './script/index.js';
|
|
9
|
+
export { DockerModule, parseContainers, render, serialize, imageTag, resolveRefs, cloneUrl, githubSlug, } from './docker/index.js';
|
|
10
|
+
export { DockerSweeper, parseUnowned } from './docker/sweeper.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAS5D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAQtF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAG/E,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAGxD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAEzH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAGrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AASpD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGhD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,MAAM,EACN,SAAS,EACT,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,UAAU,GACX,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal Porkbun API v3 client.
|
|
3
|
+
*
|
|
4
|
+
* Uses the api-ipv4 host deliberately: a host can advertise IPv6 routes (a VPN
|
|
5
|
+
* exit node, say) while having NO IPv6 egress, so a dual-stack hostname can stall on the AAAA
|
|
6
|
+
* attempt before falling back. Pinning IPv4 avoids the whole class of problem.
|
|
7
|
+
*/
|
|
8
|
+
export interface PorkbunCreds {
|
|
9
|
+
apikey: string;
|
|
10
|
+
secretapikey: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RawRecord {
|
|
13
|
+
id: string;
|
|
14
|
+
/** FQDN as returned by the API, e.g. "www.example.com" */
|
|
15
|
+
name: string;
|
|
16
|
+
type: string;
|
|
17
|
+
content: string;
|
|
18
|
+
ttl: string | number;
|
|
19
|
+
prio: string | number | null;
|
|
20
|
+
notes?: string | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function ping(creds: PorkbunCreds): Promise<string>;
|
|
23
|
+
export declare function listDomains(creds: PorkbunCreds): Promise<string[]>;
|
|
24
|
+
export declare function retrieveRecords(creds: PorkbunCreds, domain: string): Promise<RawRecord[]>;
|
|
25
|
+
export interface WriteRecord {
|
|
26
|
+
/** Subdomain relative to the zone. Empty string = apex. */
|
|
27
|
+
name: string;
|
|
28
|
+
type: string;
|
|
29
|
+
content: string;
|
|
30
|
+
ttl: number;
|
|
31
|
+
prio?: number | null;
|
|
32
|
+
}
|
|
33
|
+
export declare function createRecord(creds: PorkbunCreds, domain: string, rec: WriteRecord): Promise<string>;
|
|
34
|
+
export declare function editRecord(creds: PorkbunCreds, domain: string, id: string, rec: WriteRecord): Promise<void>;
|
|
35
|
+
export declare function deleteRecord(creds: PorkbunCreds, domain: string, id: string): Promise<void>;
|
|
36
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/modules/porkbun/api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AA+BD,wBAAsB,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAG/D;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAGxE;AAED,wBAAsB,eAAe,CACnC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,SAAS,EAAE,CAAC,CAGtB;AAED,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,wBAAsB,YAAY,CAChC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,wBAAsB,UAAU,CAC9B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,IAAI,CAAC,CAQf;AAED,wBAAsB,YAAY,CAChC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal Porkbun API v3 client.
|
|
3
|
+
*
|
|
4
|
+
* Uses the api-ipv4 host deliberately: a host can advertise IPv6 routes (a VPN
|
|
5
|
+
* exit node, say) while having NO IPv6 egress, so a dual-stack hostname can stall on the AAAA
|
|
6
|
+
* attempt before falling back. Pinning IPv4 avoids the whole class of problem.
|
|
7
|
+
*/
|
|
8
|
+
const BASE = 'https://api-ipv4.porkbun.com/api/json/v3';
|
|
9
|
+
async function call(creds, path, body = {}) {
|
|
10
|
+
const res = await fetch(`${BASE}/${path}`, {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
headers: { 'Content-Type': 'application/json' },
|
|
13
|
+
body: JSON.stringify({ ...creds, ...body }),
|
|
14
|
+
});
|
|
15
|
+
const text = await res.text();
|
|
16
|
+
let parsed;
|
|
17
|
+
try {
|
|
18
|
+
parsed = JSON.parse(text);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
throw new Error(`Porkbun ${path}: non-JSON response (HTTP ${res.status}): ${text.slice(0, 200)}`);
|
|
22
|
+
}
|
|
23
|
+
if (!res.ok || parsed?.status !== 'SUCCESS') {
|
|
24
|
+
throw new Error(`Porkbun ${path} failed (HTTP ${res.status}): ${parsed?.message ?? text.slice(0, 200)}`);
|
|
25
|
+
}
|
|
26
|
+
return parsed;
|
|
27
|
+
}
|
|
28
|
+
export async function ping(creds) {
|
|
29
|
+
const r = await call(creds, 'ping');
|
|
30
|
+
return r.yourIp;
|
|
31
|
+
}
|
|
32
|
+
export async function listDomains(creds) {
|
|
33
|
+
const r = await call(creds, 'domain/listAll');
|
|
34
|
+
return r.domains.map((d) => d.domain);
|
|
35
|
+
}
|
|
36
|
+
export async function retrieveRecords(creds, domain) {
|
|
37
|
+
const r = await call(creds, `dns/retrieve/${domain}`);
|
|
38
|
+
return r.records ?? [];
|
|
39
|
+
}
|
|
40
|
+
export async function createRecord(creds, domain, rec) {
|
|
41
|
+
const r = await call(creds, `dns/create/${domain}`, {
|
|
42
|
+
name: rec.name,
|
|
43
|
+
type: rec.type,
|
|
44
|
+
content: rec.content,
|
|
45
|
+
ttl: String(rec.ttl),
|
|
46
|
+
...(rec.prio != null ? { prio: String(rec.prio) } : {}),
|
|
47
|
+
});
|
|
48
|
+
return String(r.id);
|
|
49
|
+
}
|
|
50
|
+
export async function editRecord(creds, domain, id, rec) {
|
|
51
|
+
await call(creds, `dns/edit/${domain}/${id}`, {
|
|
52
|
+
name: rec.name,
|
|
53
|
+
type: rec.type,
|
|
54
|
+
content: rec.content,
|
|
55
|
+
ttl: String(rec.ttl),
|
|
56
|
+
...(rec.prio != null ? { prio: String(rec.prio) } : {}),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export async function deleteRecord(creds, domain, id) {
|
|
60
|
+
await call(creds, `dns/delete/${domain}/${id}`);
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=api.js.map
|