@vtechcom/hexcore 2.0.0-beta.1
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/CHANGELOG.md +127 -0
- package/LICENSE +201 -0
- package/README.md +283 -0
- package/dist/app.module.js +55 -0
- package/dist/app.module.js.map +1 -0
- package/dist/auth.js +151 -0
- package/dist/auth.js.map +1 -0
- package/dist/chain/cost-models.js +81 -0
- package/dist/chain/cost-models.js.map +1 -0
- package/dist/chain/provider.js +269 -0
- package/dist/chain/provider.js.map +1 -0
- package/dist/chain/socket.js +48 -0
- package/dist/chain/socket.js.map +1 -0
- package/dist/cli/doctor.js +43 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/hexcore.js +435 -0
- package/dist/cli/hexcore.js.map +1 -0
- package/dist/common/auth.guard.js +66 -0
- package/dist/common/auth.guard.js.map +1 -0
- package/dist/common/http.js +171 -0
- package/dist/common/http.js.map +1 -0
- package/dist/common/zod-validation.pipe.js +47 -0
- package/dist/common/zod-validation.pipe.js.map +1 -0
- package/dist/config.js +354 -0
- package/dist/config.js.map +1 -0
- package/dist/config.module.js +35 -0
- package/dist/config.module.js.map +1 -0
- package/dist/controllers/cardano.controller.js +173 -0
- package/dist/controllers/cardano.controller.js.map +1 -0
- package/dist/controllers/heads.controller.js +225 -0
- package/dist/controllers/heads.controller.js.map +1 -0
- package/dist/controllers/setup.controller.js +127 -0
- package/dist/controllers/setup.controller.js.map +1 -0
- package/dist/controllers/system.controller.js +153 -0
- package/dist/controllers/system.controller.js.map +1 -0
- package/dist/db/database.module.js +73 -0
- package/dist/db/database.module.js.map +1 -0
- package/dist/db/index.js +135 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/repositories.js +220 -0
- package/dist/db/repositories.js.map +1 -0
- package/dist/docker/container-stats.js +134 -0
- package/dist/docker/container-stats.js.map +1 -0
- package/dist/docker/docker.service.js +335 -0
- package/dist/docker/docker.service.js.map +1 -0
- package/dist/hydra/argv.js +172 -0
- package/dist/hydra/argv.js.map +1 -0
- package/dist/hydra/blockfrost-keys.js +15 -0
- package/dist/hydra/blockfrost-keys.js.map +1 -0
- package/dist/hydra/boot-progress.js +165 -0
- package/dist/hydra/boot-progress.js.map +1 -0
- package/dist/hydra/capabilities.js +131 -0
- package/dist/hydra/capabilities.js.map +1 -0
- package/dist/hydra/head.service.js +1072 -0
- package/dist/hydra/head.service.js.map +1 -0
- package/dist/hydra/keys.js +301 -0
- package/dist/hydra/keys.js.map +1 -0
- package/dist/hydra/node-monitor.service.js +265 -0
- package/dist/hydra/node-monitor.service.js.map +1 -0
- package/dist/hydra/ws-client.js +177 -0
- package/dist/hydra/ws-client.js.map +1 -0
- package/dist/main.js +106 -0
- package/dist/main.js.map +1 -0
- package/dist/preflight.js +215 -0
- package/dist/preflight.js.map +1 -0
- package/dist/settings.js +243 -0
- package/dist/settings.js.map +1 -0
- package/dist/setup.service.js +257 -0
- package/dist/setup.service.js.map +1 -0
- package/dist/version.js +46 -0
- package/dist/version.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/api.d.ts +730 -0
- package/node_modules/@hexcore/shared/dist/cjs/api.d.ts.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/api.js +358 -0
- package/node_modules/@hexcore/shared/dist/cjs/api.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/domain.d.ts +298 -0
- package/node_modules/@hexcore/shared/dist/cjs/domain.d.ts.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/domain.js +49 -0
- package/node_modules/@hexcore/shared/dist/cjs/domain.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/hydra-versions.d.ts +279 -0
- package/node_modules/@hexcore/shared/dist/cjs/hydra-versions.d.ts.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/hydra-versions.js +453 -0
- package/node_modules/@hexcore/shared/dist/cjs/hydra-versions.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/index.d.ts +7 -0
- package/node_modules/@hexcore/shared/dist/cjs/index.d.ts.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/index.js +23 -0
- package/node_modules/@hexcore/shared/dist/cjs/index.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/naming.d.ts +118 -0
- package/node_modules/@hexcore/shared/dist/cjs/naming.d.ts.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/naming.js +103 -0
- package/node_modules/@hexcore/shared/dist/cjs/naming.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/offline.d.ts +73 -0
- package/node_modules/@hexcore/shared/dist/cjs/offline.d.ts.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/offline.js +80 -0
- package/node_modules/@hexcore/shared/dist/cjs/offline.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/protocol-params.d.ts +79 -0
- package/node_modules/@hexcore/shared/dist/cjs/protocol-params.d.ts.map +1 -0
- package/node_modules/@hexcore/shared/dist/cjs/protocol-params.js +223 -0
- package/node_modules/@hexcore/shared/dist/cjs/protocol-params.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/esm/api.js +355 -0
- package/node_modules/@hexcore/shared/dist/esm/api.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/esm/domain.js +46 -0
- package/node_modules/@hexcore/shared/dist/esm/domain.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/esm/hydra-versions.js +441 -0
- package/node_modules/@hexcore/shared/dist/esm/hydra-versions.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/esm/index.js +7 -0
- package/node_modules/@hexcore/shared/dist/esm/index.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/esm/naming.js +95 -0
- package/node_modules/@hexcore/shared/dist/esm/naming.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/esm/offline.js +75 -0
- package/node_modules/@hexcore/shared/dist/esm/offline.js.map +1 -0
- package/node_modules/@hexcore/shared/dist/esm/package.json +3 -0
- package/node_modules/@hexcore/shared/dist/esm/protocol-params.js +217 -0
- package/node_modules/@hexcore/shared/dist/esm/protocol-params.js.map +1 -0
- package/node_modules/@hexcore/shared/package.json +15 -0
- package/package.json +67 -0
- package/web/200.html +23 -0
- package/web/404.html +23 -0
- package/web/_nuxt/2MxohCD-.js +1 -0
- package/web/_nuxt/4pFXjB_u.js +1 -0
- package/web/_nuxt/B-v0dEQX.js +1 -0
- package/web/_nuxt/B4yE3U25.js +1 -0
- package/web/_nuxt/BFh8Ai0L.js +1 -0
- package/web/_nuxt/BgPn4NJH.js +1 -0
- package/web/_nuxt/Bj1xviSh.js +1 -0
- package/web/_nuxt/BnotlrL7.js +1 -0
- package/web/_nuxt/C1YRg2ic.js +1 -0
- package/web/_nuxt/CGD7MYQH.js +1 -0
- package/web/_nuxt/CQcG7Bu4.js +1 -0
- package/web/_nuxt/CS3KqpH_.js +1 -0
- package/web/_nuxt/CT-yt694.js +1 -0
- package/web/_nuxt/CZK6xUH-.js +1 -0
- package/web/_nuxt/CcdyYRYz.js +1 -0
- package/web/_nuxt/CePNTU1S.js +1 -0
- package/web/_nuxt/CgPLsCeU.js +5 -0
- package/web/_nuxt/CkCrahXt.js +1 -0
- package/web/_nuxt/CnOqDT9k.js +3 -0
- package/web/_nuxt/CqsSss-D.js +1 -0
- package/web/_nuxt/Cr8dL64Q.js +1 -0
- package/web/_nuxt/D3CwzwU0.js +1 -0
- package/web/_nuxt/DDANn6-H.js +1 -0
- package/web/_nuxt/DDl9uKIA.js +1 -0
- package/web/_nuxt/DL9i0ayn.js +1 -0
- package/web/_nuxt/DLNoK9BC.js +1 -0
- package/web/_nuxt/DLztFeOQ.js +1 -0
- package/web/_nuxt/DPihKXdt.js +1 -0
- package/web/_nuxt/DXyr6Naa.js +1 -0
- package/web/_nuxt/DeDg5p0D.js +1 -0
- package/web/_nuxt/DgDlQiDU.js +1 -0
- package/web/_nuxt/DyPI7qJE.js +30 -0
- package/web/_nuxt/LGfPBi70.js +1 -0
- package/web/_nuxt/Onf26W-r.js +1 -0
- package/web/_nuxt/QZNQe_OX.js +1 -0
- package/web/_nuxt/Y8IJM-iz.js +1 -0
- package/web/_nuxt/YUGC0nt0.js +1 -0
- package/web/_nuxt/builds/latest.json +1 -0
- package/web/_nuxt/builds/meta/7e461629-93e2-4694-b237-6d5c6a85c97c.json +1 -0
- package/web/_nuxt/builds/meta/dev.json +1 -0
- package/web/_nuxt/entry.BxsAxZxf.css +1 -0
- package/web/_nuxt/error-404.XbtAw-qw.css +1 -0
- package/web/_nuxt/error-500.CNHVltWM.css +1 -0
- package/web/_nuxt/rS90pPZ_.js +1 -0
- package/web/_nuxt/rhEiP908.js +1 -0
- package/web/_nuxt/vSj9Ec0g.js +1 -0
- package/web/_nuxt/woNjBJMN.js +1 -0
- package/web/favicon.svg +28 -0
- package/web/heads/index.html +23 -0
- package/web/heads/new/index.html +23 -0
- package/web/index.html +23 -0
- package/web/login/index.html +23 -0
- package/web/logo.svg +56 -0
- package/web/settings/index.html +23 -0
- package/web/setup/index.html +23 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":";;;AACA;;GAEG;AACH,sCAAoD;AACpD,4CAA0D;AAE1D,KAAK,UAAU,IAAI;IACf,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACD,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,IAAI,GAAG,YAAY,oBAAW,EAAE,CAAC;YAC7B,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;QACD,MAAM,GAAG,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAY,EAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,IAAA,wBAAY,EAAC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|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
/**
|
|
5
|
+
* `hexcore` — the whole product as one command.
|
|
6
|
+
*
|
|
7
|
+
* The shape this exists to make possible is `npm i -g hexcore && hexcore`: one
|
|
8
|
+
* process serving the API and the UI, configured from a browser, with nothing
|
|
9
|
+
* to edit by hand. Everything it needs was already true — the web app builds to
|
|
10
|
+
* static files and `SERVE_WEB` has always been able to serve them — but the
|
|
11
|
+
* pieces were assembled by a person following a README.
|
|
12
|
+
*
|
|
13
|
+
* Two things had to change for a *global* command, and both are about `.env`
|
|
14
|
+
* being read from the current directory:
|
|
15
|
+
*
|
|
16
|
+
* - configuration now also comes from `<home>/config.json` (see settings.ts),
|
|
17
|
+
* so `hexcore` behaves the same wherever it is run from;
|
|
18
|
+
* - `STATE_DIR` no longer defaults to `./.hexcore`, which would have made
|
|
19
|
+
* `cd` somewhere else look like every head had disappeared.
|
|
20
|
+
*
|
|
21
|
+
* Commands that only touch files — init, config, reset, clean — deliberately do
|
|
22
|
+
* NOT import the Nest application. They have to work when the server cannot
|
|
23
|
+
* start, which is exactly when someone reaches for them.
|
|
24
|
+
*/
|
|
25
|
+
const node_fs_1 = require("node:fs");
|
|
26
|
+
const promises_1 = require("node:readline/promises");
|
|
27
|
+
const node_process_1 = require("node:process");
|
|
28
|
+
const node_os_1 = require("node:os");
|
|
29
|
+
const promises_2 = require("node:fs/promises");
|
|
30
|
+
const settings_1 = require("../settings");
|
|
31
|
+
/**
|
|
32
|
+
* `config.ts` is imported lazily, never at the top of this file.
|
|
33
|
+
*
|
|
34
|
+
* It snapshots `process.env` in its module body — that snapshot is what lets
|
|
35
|
+
* `hexcore config` distinguish an exported variable from a `.env` one — so
|
|
36
|
+
* importing it here would freeze the environment before `start()` has set
|
|
37
|
+
* SERVE_WEB. The symptom was precise and confusing: the server came up, served
|
|
38
|
+
* the API, and 404'd the UI it had shipped with.
|
|
39
|
+
*/
|
|
40
|
+
const config = () => import('../config.js');
|
|
41
|
+
const c = {
|
|
42
|
+
bold: (s) => `\x1b[1m${s}\x1b[0m`,
|
|
43
|
+
dim: (s) => `\x1b[2m${s}\x1b[0m`,
|
|
44
|
+
red: (s) => `\x1b[31m${s}\x1b[0m`,
|
|
45
|
+
green: (s) => `\x1b[32m${s}\x1b[0m`,
|
|
46
|
+
yellow: (s) => `\x1b[33m${s}\x1b[0m`,
|
|
47
|
+
cyan: (s) => `\x1b[36m${s}\x1b[0m`,
|
|
48
|
+
};
|
|
49
|
+
const USAGE = `
|
|
50
|
+
${c.bold('hexcore')} — boot and operate Hydra Heads on Cardano
|
|
51
|
+
|
|
52
|
+
${c.cyan('hexcore')} start the control-plane and the web UI
|
|
53
|
+
${c.cyan('hexcore start')} the same, said explicitly
|
|
54
|
+
${c.cyan('hexcore init')} configure from the terminal instead of the browser
|
|
55
|
+
${c.cyan('hexcore config')} show every setting and which layer it came from
|
|
56
|
+
${c.cyan('hexcore doctor')} check Docker, chain access and permissions
|
|
57
|
+
${c.cyan('hexcore reset')} forget the configuration; heads and keys are kept
|
|
58
|
+
${c.cyan('hexcore clean')} delete every head and its containers; keys are kept
|
|
59
|
+
${c.cyan('hexcore clean --all')} delete everything, including keys
|
|
60
|
+
|
|
61
|
+
${c.bold('Options')}
|
|
62
|
+
--port <n> listen on this port (default 4000)
|
|
63
|
+
--host <addr> bind to this address (default 0.0.0.0)
|
|
64
|
+
--no-web serve the API only
|
|
65
|
+
--yes skip the confirmation prompt on clean
|
|
66
|
+
--version, --help
|
|
67
|
+
|
|
68
|
+
${c.dim(`Configuration lives in ${(0, settings_1.settingsPath)()}, and an environment variable or a`)}
|
|
69
|
+
${c.dim('.env in the current directory still wins over it. `hexcore config` says which.')}
|
|
70
|
+
`;
|
|
71
|
+
async function main() {
|
|
72
|
+
const argv = process.argv.slice(2);
|
|
73
|
+
const flags = new Set(argv.filter(a => a.startsWith('-')));
|
|
74
|
+
const command = argv.find(a => !a.startsWith('-')) ?? 'start';
|
|
75
|
+
if (flags.has('--help') || flags.has('-h') || command === 'help') {
|
|
76
|
+
console.log(USAGE);
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
if (flags.has('--version') || flags.has('-v')) {
|
|
80
|
+
console.log(version());
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
switch (command) {
|
|
84
|
+
case 'start':
|
|
85
|
+
return start(argv, flags);
|
|
86
|
+
case 'init':
|
|
87
|
+
return init();
|
|
88
|
+
case 'config':
|
|
89
|
+
return showConfig();
|
|
90
|
+
case 'doctor':
|
|
91
|
+
return doctor();
|
|
92
|
+
case 'reset':
|
|
93
|
+
return reset(flags);
|
|
94
|
+
case 'clean':
|
|
95
|
+
return clean(flags);
|
|
96
|
+
default:
|
|
97
|
+
console.error(`Unknown command "${command}".\n${USAGE}`);
|
|
98
|
+
return 1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// ------------------------------------------------------------------- start
|
|
102
|
+
async function start(argv, flags) {
|
|
103
|
+
/**
|
|
104
|
+
* Defaults applied BEFORE the app module is loaded, since config.ts reads
|
|
105
|
+
* the environment at import time. They are written only when the operator
|
|
106
|
+
* has not already said otherwise — an explicit SERVE_WEB=false must win
|
|
107
|
+
* over the CLI's preference for serving the UI.
|
|
108
|
+
*/
|
|
109
|
+
if (process.env.SERVE_WEB === undefined) {
|
|
110
|
+
process.env.SERVE_WEB = flags.has('--no-web') ? 'false' : 'true';
|
|
111
|
+
}
|
|
112
|
+
const port = valueOf(argv, '--port');
|
|
113
|
+
if (port)
|
|
114
|
+
process.env.PORT = port;
|
|
115
|
+
const host = valueOf(argv, '--host');
|
|
116
|
+
if (host)
|
|
117
|
+
process.env.HOST = host;
|
|
118
|
+
const { bootstrap } = (await import('../main.js'));
|
|
119
|
+
await bootstrap();
|
|
120
|
+
// Resolve nothing: the server owns the process from here.
|
|
121
|
+
return new Promise(() => undefined);
|
|
122
|
+
}
|
|
123
|
+
function valueOf(argv, flag) {
|
|
124
|
+
const index = argv.indexOf(flag);
|
|
125
|
+
if (index >= 0 && argv[index + 1] && !argv[index + 1].startsWith('-'))
|
|
126
|
+
return argv[index + 1];
|
|
127
|
+
const inline = argv.find(a => a.startsWith(`${flag}=`));
|
|
128
|
+
return inline?.slice(flag.length + 1);
|
|
129
|
+
}
|
|
130
|
+
// -------------------------------------------------------------------- init
|
|
131
|
+
/**
|
|
132
|
+
* The terminal path through setup.
|
|
133
|
+
*
|
|
134
|
+
* The browser wizard is the one most people should use — docs/PRODUCT.md names
|
|
135
|
+
* non-technical operators as a first-class audience and they should not have to
|
|
136
|
+
* answer questions in a shell. This exists for the machine with no browser
|
|
137
|
+
* pointed at it: a server, a CI job, a container build.
|
|
138
|
+
*/
|
|
139
|
+
async function init() {
|
|
140
|
+
console.log(`\n${c.bold('Hexcore setup')}\n${'─'.repeat(40)}\n`);
|
|
141
|
+
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stdout });
|
|
142
|
+
try {
|
|
143
|
+
const existing = (0, settings_1.readSettings)();
|
|
144
|
+
if (existing.setupCompletedAt) {
|
|
145
|
+
const answer = (await rl.question(`${c.yellow('Already configured.')} Reconfigure? [y/N] `)).trim();
|
|
146
|
+
if (answer.toLowerCase() !== 'y') {
|
|
147
|
+
console.log('\nLeft as it was.\n');
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const network = (await rl.question(`Cardano network — preprod, preview, mainnet ${c.dim('[preprod]')}: `))
|
|
152
|
+
.trim()
|
|
153
|
+
.toLowerCase() || 'preprod';
|
|
154
|
+
if (!['preprod', 'preview', 'mainnet'].includes(network)) {
|
|
155
|
+
console.error(c.red(`\n"${network}" is not a Cardano network.\n`));
|
|
156
|
+
return 1;
|
|
157
|
+
}
|
|
158
|
+
console.log(c.dim('\n offline needs nothing; the head simulates its own layer 1'));
|
|
159
|
+
console.log(c.dim(' blockfrost needs a free API key from blockfrost.io'));
|
|
160
|
+
console.log(c.dim(' cardano-node needs a socket from a node you already run\n'));
|
|
161
|
+
const backend = (await rl.question(`Chain backend ${c.dim('[offline]')}: `)).trim().toLowerCase() || 'offline';
|
|
162
|
+
if (!['offline', 'blockfrost', 'cardano-node'].includes(backend)) {
|
|
163
|
+
console.error(c.red(`\n"${backend}" is not a chain backend.\n`));
|
|
164
|
+
return 1;
|
|
165
|
+
}
|
|
166
|
+
const env = {
|
|
167
|
+
CARDANO_NETWORK: network,
|
|
168
|
+
CHAIN_BACKEND: backend,
|
|
169
|
+
};
|
|
170
|
+
if (backend === 'blockfrost') {
|
|
171
|
+
const key = (await rl.question(`Blockfrost project id ${c.dim(`(starts with "${network}")`)}: `)).trim();
|
|
172
|
+
// Checked here rather than left to the server: a mismatched key
|
|
173
|
+
// does not fail loudly, it produces a head that never observes its
|
|
174
|
+
// own init transaction.
|
|
175
|
+
if (!key.startsWith(network)) {
|
|
176
|
+
console.error(c.red(`\nThat key is not for ${network} — it must start with "${network}".\n`));
|
|
177
|
+
return 1;
|
|
178
|
+
}
|
|
179
|
+
env.BLOCKFROST_PROJECT_ID = key;
|
|
180
|
+
}
|
|
181
|
+
if (backend === 'cardano-node') {
|
|
182
|
+
const socket = (await rl.question('Path to the cardano-node socket: ')).trim();
|
|
183
|
+
if (!socket) {
|
|
184
|
+
console.error(c.red('\nThe cardano-node backend needs a socket path.\n'));
|
|
185
|
+
return 1;
|
|
186
|
+
}
|
|
187
|
+
env.CARDANO_NODE_SOCKET = socket;
|
|
188
|
+
}
|
|
189
|
+
const username = (await rl.question(`Admin username ${c.dim('[admin]')}: `)).trim() || 'admin';
|
|
190
|
+
env.ADMIN_USERNAME = username;
|
|
191
|
+
const password = (await rl.question(`Admin password ${c.dim('[generate one]')}: `)).trim();
|
|
192
|
+
(0, settings_1.writeSettings)({ version: 1, setupCompletedAt: new Date().toISOString(), env });
|
|
193
|
+
if (password) {
|
|
194
|
+
// Imported lazily: this pulls in the Nest decorators, and every
|
|
195
|
+
// other path through init has no use for them.
|
|
196
|
+
const { hashPassword } = await import('../auth.js');
|
|
197
|
+
await writeAdminSecret(username, hashPassword(password));
|
|
198
|
+
}
|
|
199
|
+
console.log(`\n${c.green('✔')} Wrote ${(0, settings_1.settingsPath)()}`);
|
|
200
|
+
console.log(`\n${c.bold('Next:')} ${c.cyan('hexcore')}\n`);
|
|
201
|
+
if (!password)
|
|
202
|
+
console.log(c.dim('A password will be generated and printed once on first start.\n'));
|
|
203
|
+
return 0;
|
|
204
|
+
}
|
|
205
|
+
finally {
|
|
206
|
+
rl.close();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Write the admin hash into secrets.json without booting the app.
|
|
211
|
+
*
|
|
212
|
+
* Deliberately merges rather than overwrites: the file also holds the JWT
|
|
213
|
+
* secret, and replacing it would sign every existing session out — including,
|
|
214
|
+
* on a reconfigure, the operator running this.
|
|
215
|
+
*/
|
|
216
|
+
async function writeAdminSecret(username, passwordHash) {
|
|
217
|
+
const { mkdirSync, readFileSync, writeFileSync } = await import('node:fs');
|
|
218
|
+
const { dirname } = await import('node:path');
|
|
219
|
+
const { loadConfig } = await config();
|
|
220
|
+
const path = loadConfig().secretsPath;
|
|
221
|
+
let secrets = {};
|
|
222
|
+
if ((0, node_fs_1.existsSync)(path)) {
|
|
223
|
+
try {
|
|
224
|
+
secrets = JSON.parse(readFileSync(path, 'utf8'));
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
secrets = {};
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (!secrets.jwtSecret) {
|
|
231
|
+
const { randomBytes } = await import('node:crypto');
|
|
232
|
+
secrets.jwtSecret = randomBytes(32).toString('hex');
|
|
233
|
+
}
|
|
234
|
+
secrets.adminUsername = username;
|
|
235
|
+
secrets.adminPasswordHash = passwordHash;
|
|
236
|
+
delete secrets.generatedPassword;
|
|
237
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
238
|
+
writeFileSync(path, JSON.stringify(secrets, null, 2), { encoding: 'utf8', mode: 0o600 });
|
|
239
|
+
}
|
|
240
|
+
// ------------------------------------------------------------------ config
|
|
241
|
+
/**
|
|
242
|
+
* Every setting and the layer it came from.
|
|
243
|
+
*
|
|
244
|
+
* The failure mode of layered configuration is not a wrong value, it is a value
|
|
245
|
+
* nobody can explain — "I set that in config.json and it is not taking effect"
|
|
246
|
+
* has exactly one useful answer, which is "an environment variable is shadowing
|
|
247
|
+
* it". This prints that answer.
|
|
248
|
+
*/
|
|
249
|
+
async function showConfig() {
|
|
250
|
+
const { describeProvenance, loadConfig, ConfigError } = await config();
|
|
251
|
+
let resolved;
|
|
252
|
+
try {
|
|
253
|
+
resolved = loadConfig();
|
|
254
|
+
}
|
|
255
|
+
catch (err) {
|
|
256
|
+
if (err instanceof ConfigError) {
|
|
257
|
+
console.error(`\n${c.red(err.message)}\n`);
|
|
258
|
+
return 1;
|
|
259
|
+
}
|
|
260
|
+
throw err;
|
|
261
|
+
}
|
|
262
|
+
console.log(`\n${c.bold('Where things are')}`);
|
|
263
|
+
console.log(` ${'home'.padEnd(16)} ${(0, settings_1.hexcoreHome)()}`);
|
|
264
|
+
console.log(` ${'settings'.padEnd(16)} ${(0, node_fs_1.existsSync)((0, settings_1.settingsPath)()) ? (0, settings_1.settingsPath)() : c.dim('(none yet)')}`);
|
|
265
|
+
console.log(` ${'state'.padEnd(16)} ${resolved.stateDir}`);
|
|
266
|
+
console.log(` ${'database'.padEnd(16)} ${resolved.dbPath}`);
|
|
267
|
+
console.log(`\n${c.bold('Settings')} ${c.dim('value ← where it came from')}`);
|
|
268
|
+
for (const entry of describeProvenance()) {
|
|
269
|
+
// A credential's value is never printed, here or over the API. Whether
|
|
270
|
+
// one is set is the useful part and is not a secret.
|
|
271
|
+
const plain = entry.secret ? (entry.value ? '(set)' : '(not set)') : (entry.value ?? '—');
|
|
272
|
+
// Padded before colouring: escape codes are characters to padEnd and
|
|
273
|
+
// nothing to a terminal, so colouring first shreds the column.
|
|
274
|
+
const padded = plain.padEnd(46);
|
|
275
|
+
const shown = entry.secret || entry.value === null ? c.dim(padded) : padded;
|
|
276
|
+
const source = entry.source === 'default' ? c.dim(entry.source) : c.cyan(entry.source);
|
|
277
|
+
console.log(` ${entry.key.padEnd(24)} ${shown} ← ${source}`);
|
|
278
|
+
}
|
|
279
|
+
console.log(`\n${c.dim('environment > .env in this directory > settings file > built-in default')}\n`);
|
|
280
|
+
return 0;
|
|
281
|
+
}
|
|
282
|
+
// ------------------------------------------------------------------ doctor
|
|
283
|
+
async function doctor() {
|
|
284
|
+
const { formatReport, runPreflight } = await import('../preflight.js');
|
|
285
|
+
const { loadConfig, ConfigError } = await config();
|
|
286
|
+
let resolved;
|
|
287
|
+
try {
|
|
288
|
+
resolved = loadConfig();
|
|
289
|
+
}
|
|
290
|
+
catch (err) {
|
|
291
|
+
if (err instanceof ConfigError) {
|
|
292
|
+
console.error(`\n${c.red(err.message)}\n`);
|
|
293
|
+
return 1;
|
|
294
|
+
}
|
|
295
|
+
throw err;
|
|
296
|
+
}
|
|
297
|
+
const report = await runPreflight(resolved);
|
|
298
|
+
console.log(formatReport(report));
|
|
299
|
+
return report.some((r) => r.status === 'fail' && r.fatal) ? 1 : 0;
|
|
300
|
+
}
|
|
301
|
+
// ------------------------------------------------------------- reset/clean
|
|
302
|
+
async function reset(flags) {
|
|
303
|
+
if (!flags.has('--yes')) {
|
|
304
|
+
const ok = await confirm(`This forgets the configuration in ${(0, settings_1.settingsPath)()}.\n` +
|
|
305
|
+
`Heads, keys and persistence are ${c.bold('kept')}. Continue?`);
|
|
306
|
+
if (!ok)
|
|
307
|
+
return 1;
|
|
308
|
+
}
|
|
309
|
+
(0, settings_1.clearSettings)();
|
|
310
|
+
console.log(`\n${c.green('✔')} Configuration cleared. Run ${c.cyan('hexcore')} to set it up again.\n`);
|
|
311
|
+
return 0;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Delete heads, and optionally everything.
|
|
315
|
+
*
|
|
316
|
+
* The two scopes are far apart on purpose. Without `--all` this removes
|
|
317
|
+
* containers and head state and leaves the key material alone, which is the
|
|
318
|
+
* "my test heads are a mess" case. With it, the Cardano signing keys go too —
|
|
319
|
+
* and those control addresses that may hold funds and exist nowhere else, so no
|
|
320
|
+
* amount of care afterwards gets them back.
|
|
321
|
+
*/
|
|
322
|
+
async function clean(flags) {
|
|
323
|
+
const all = flags.has('--all');
|
|
324
|
+
const { loadConfig } = await config();
|
|
325
|
+
const resolved = loadConfig();
|
|
326
|
+
const home = (0, settings_1.hexcoreHome)();
|
|
327
|
+
if (!flags.has('--yes')) {
|
|
328
|
+
const what = all
|
|
329
|
+
? `${c.red('EVERYTHING')}:\n` +
|
|
330
|
+
` • every head and its containers\n` +
|
|
331
|
+
` • ${c.red('the Cardano signing keys')} — any address holding funds becomes unreachable\n` +
|
|
332
|
+
` • ${resolved.stateDir}\n` +
|
|
333
|
+
` • ${home}`
|
|
334
|
+
: `every head, its containers and its persistence.\n` +
|
|
335
|
+
` Keys are ${c.bold('kept')}, so funded addresses survive.`;
|
|
336
|
+
console.log(`\nThis deletes ${what}\n`);
|
|
337
|
+
const ok = await confirm(all ? `Type the machine name (${c.bold((0, node_os_1.hostname)())}) to confirm` : 'Continue?', {
|
|
338
|
+
phrase: all ? (0, node_os_1.hostname)() : undefined,
|
|
339
|
+
});
|
|
340
|
+
if (!ok)
|
|
341
|
+
return 1;
|
|
342
|
+
}
|
|
343
|
+
const removed = await removeManagedContainers();
|
|
344
|
+
console.log(` removed ${removed} container(s)`);
|
|
345
|
+
if (all) {
|
|
346
|
+
await (0, promises_2.rm)(resolved.stateDir, { recursive: true, force: true });
|
|
347
|
+
await (0, promises_2.rm)(home, { recursive: true, force: true });
|
|
348
|
+
console.log(`\n${c.green('✔')} Hexcore is gone. Run ${c.cyan('hexcore')} to start over.\n`);
|
|
349
|
+
return 0;
|
|
350
|
+
}
|
|
351
|
+
// Heads live in the database and under the state dir; the keys sit beside
|
|
352
|
+
// them, so the two are removed separately rather than by dropping the root.
|
|
353
|
+
const { rmSync } = await import('node:fs');
|
|
354
|
+
rmSync(resolved.headsDir, { recursive: true, force: true });
|
|
355
|
+
rmSync(resolved.dbPath, { force: true });
|
|
356
|
+
rmSync(`${resolved.dbPath}-wal`, { force: true });
|
|
357
|
+
rmSync(`${resolved.dbPath}-shm`, { force: true });
|
|
358
|
+
console.log(`\n${c.green('✔')} Heads cleared. Settings and the admin login are unchanged.\n`);
|
|
359
|
+
return 0;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Remove the containers belonging to THIS installation.
|
|
363
|
+
*
|
|
364
|
+
* By label rather than by database row, because the point of `clean` is to
|
|
365
|
+
* recover from a state where the two disagree — a container whose row is
|
|
366
|
+
* already gone is exactly what gets left behind otherwise.
|
|
367
|
+
*
|
|
368
|
+
* But by `LABEL_INSTALL` and not just `LABEL_MANAGED`. More than one Hexcore on
|
|
369
|
+
* a machine is normal: a checkout being worked on and a globally installed
|
|
370
|
+
* `hexcore` share one Docker daemon, and `LABEL_MANAGED` is true of both. This
|
|
371
|
+
* function once matched on that alone, and a `clean` in a throwaway
|
|
372
|
+
* installation removed the running containers of a head in a different one.
|
|
373
|
+
*
|
|
374
|
+
* The consequence of the narrower filter is that containers created before this
|
|
375
|
+
* label existed are not matched, and `clean` leaves them alone. That is the
|
|
376
|
+
* right direction to be wrong in: they are removable by name or by the head's
|
|
377
|
+
* own Delete, and no amount of convenience is worth reaching into an
|
|
378
|
+
* installation the operator did not name.
|
|
379
|
+
*/
|
|
380
|
+
async function removeManagedContainers() {
|
|
381
|
+
try {
|
|
382
|
+
const { default: Docker } = await import('dockerode');
|
|
383
|
+
const { LABEL_INSTALL, LABEL_MANAGED } = await import('@hexcore/shared');
|
|
384
|
+
const { loadConfig } = await config();
|
|
385
|
+
const { installId } = await import('../settings.js');
|
|
386
|
+
const resolved = loadConfig();
|
|
387
|
+
const docker = new Docker({ socketPath: resolved.dockerSocket });
|
|
388
|
+
const containers = await docker.listContainers({
|
|
389
|
+
all: true,
|
|
390
|
+
filters: { label: [`${LABEL_MANAGED}=true`, `${LABEL_INSTALL}=${installId(resolved.stateDir)}`] },
|
|
391
|
+
});
|
|
392
|
+
for (const info of containers) {
|
|
393
|
+
await docker.getContainer(info.Id).remove({ force: true });
|
|
394
|
+
}
|
|
395
|
+
return containers.length;
|
|
396
|
+
}
|
|
397
|
+
catch (err) {
|
|
398
|
+
// Docker being unreachable must not stop the file-system half of the
|
|
399
|
+
// wipe; say so and carry on.
|
|
400
|
+
console.log(c.yellow(` could not reach Docker (${err.message}) — containers left alone`));
|
|
401
|
+
return 0;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
async function confirm(question, options = {}) {
|
|
405
|
+
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stdout });
|
|
406
|
+
try {
|
|
407
|
+
const answer = (await rl.question(`${question} ${options.phrase ? '' : '[y/N] '}`)).trim();
|
|
408
|
+
if (options.phrase) {
|
|
409
|
+
if (answer === options.phrase)
|
|
410
|
+
return true;
|
|
411
|
+
console.log(c.yellow('\nThat did not match. Nothing was deleted.\n'));
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
if (answer.toLowerCase() === 'y')
|
|
415
|
+
return true;
|
|
416
|
+
console.log(c.yellow('\nCancelled. Nothing was deleted.\n'));
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
finally {
|
|
420
|
+
rl.close();
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function version() {
|
|
424
|
+
// Shared with the health payload and the Swagger document, so `hexcore
|
|
425
|
+
// --version` and what the server reports can never disagree.
|
|
426
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
427
|
+
return require('../version.js').VERSION;
|
|
428
|
+
}
|
|
429
|
+
main()
|
|
430
|
+
.then(code => process.exit(code))
|
|
431
|
+
.catch((err) => {
|
|
432
|
+
console.error(c.red(`\n${err.message}\n`));
|
|
433
|
+
process.exit(1);
|
|
434
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CAAC;AACrE,CAAC;AAED,IAAI,EAAE;KACD,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KAChC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IACpB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAM,GAAa,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;IACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AuthGuard = exports.Public = exports.IS_PUBLIC = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const core_1 = require("@nestjs/core");
|
|
18
|
+
const common_2 = require("@nestjs/common");
|
|
19
|
+
const config_module_1 = require("../config.module");
|
|
20
|
+
const auth_1 = require("../auth");
|
|
21
|
+
exports.IS_PUBLIC = 'isPublic';
|
|
22
|
+
/** Mark a route as reachable without a bearer token. */
|
|
23
|
+
const Public = () => (0, common_2.SetMetadata)(exports.IS_PUBLIC, true);
|
|
24
|
+
exports.Public = Public;
|
|
25
|
+
/**
|
|
26
|
+
* Global guard: everything requires a bearer token unless marked @Public().
|
|
27
|
+
* Defaulting to "protected" is the inverse of v1, where each controller had to
|
|
28
|
+
* remember @UseGuards(AdminAuthGuard) and a few endpoints silently did not.
|
|
29
|
+
*/
|
|
30
|
+
let AuthGuard = class AuthGuard {
|
|
31
|
+
reflector;
|
|
32
|
+
auth;
|
|
33
|
+
config;
|
|
34
|
+
constructor(reflector, auth, config) {
|
|
35
|
+
this.reflector = reflector;
|
|
36
|
+
this.auth = auth;
|
|
37
|
+
this.config = config;
|
|
38
|
+
}
|
|
39
|
+
canActivate(context) {
|
|
40
|
+
const isPublic = this.reflector.getAllAndOverride(exports.IS_PUBLIC, [
|
|
41
|
+
context.getHandler(),
|
|
42
|
+
context.getClass(),
|
|
43
|
+
]);
|
|
44
|
+
if (isPublic || !this.config.authEnabled)
|
|
45
|
+
return true;
|
|
46
|
+
const req = context.switchToHttp().getRequest();
|
|
47
|
+
const header = req.headers.authorization;
|
|
48
|
+
const token = header?.startsWith('Bearer ') ? header.slice(7) : null;
|
|
49
|
+
if (!token)
|
|
50
|
+
throw new common_1.UnauthorizedException({ code: 'UNAUTHORIZED', message: 'Missing bearer token' });
|
|
51
|
+
const payload = this.auth.verify(token);
|
|
52
|
+
if (!payload) {
|
|
53
|
+
throw new common_1.UnauthorizedException({ code: 'UNAUTHORIZED', message: 'Invalid or expired token' });
|
|
54
|
+
}
|
|
55
|
+
req.user = payload;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.AuthGuard = AuthGuard;
|
|
60
|
+
exports.AuthGuard = AuthGuard = __decorate([
|
|
61
|
+
(0, common_1.Injectable)(),
|
|
62
|
+
__param(2, (0, common_1.Inject)(config_module_1.APP_CONFIG)),
|
|
63
|
+
__metadata("design:paramtypes", [core_1.Reflector,
|
|
64
|
+
auth_1.AuthService, Object])
|
|
65
|
+
], AuthGuard);
|
|
66
|
+
//# sourceMappingURL=auth.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../../src/common/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0G;AAC1G,uCAAyC;AACzC,2CAA6C;AAE7C,oDAA8C;AAE9C,kCAAsC;AAEzB,QAAA,SAAS,GAAG,UAAU,CAAC;AAEpC,wDAAwD;AACjD,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAW,EAAC,iBAAS,EAAE,IAAI,CAAC,CAAC;AAA5C,QAAA,MAAM,UAAsC;AAEzD;;;;GAIG;AAEI,IAAM,SAAS,GAAf,MAAM,SAAS;IAEG;IACA;IACoB;IAHzC,YACqB,SAAoB,EACpB,IAAiB,EACG,MAAiB;QAFrC,cAAS,GAAT,SAAS,CAAW;QACpB,SAAI,GAAJ,IAAI,CAAa;QACG,WAAM,GAAN,MAAM,CAAW;IACvD,CAAC;IAEJ,WAAW,CAAC,OAAyB;QACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,iBAAS,EAAE;YAClE,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACrB,CAAC,CAAC;QACH,IAAI,QAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW;YAAE,OAAO,IAAI,CAAC;QAEtD,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAkB,CAAC;QAChE,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC;QACzC,MAAM,KAAK,GAAG,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CA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