@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.
Files changed (173) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/LICENSE +201 -0
  3. package/README.md +283 -0
  4. package/dist/app.module.js +55 -0
  5. package/dist/app.module.js.map +1 -0
  6. package/dist/auth.js +151 -0
  7. package/dist/auth.js.map +1 -0
  8. package/dist/chain/cost-models.js +81 -0
  9. package/dist/chain/cost-models.js.map +1 -0
  10. package/dist/chain/provider.js +269 -0
  11. package/dist/chain/provider.js.map +1 -0
  12. package/dist/chain/socket.js +48 -0
  13. package/dist/chain/socket.js.map +1 -0
  14. package/dist/cli/doctor.js +43 -0
  15. package/dist/cli/doctor.js.map +1 -0
  16. package/dist/cli/hexcore.js +435 -0
  17. package/dist/cli/hexcore.js.map +1 -0
  18. package/dist/common/auth.guard.js +66 -0
  19. package/dist/common/auth.guard.js.map +1 -0
  20. package/dist/common/http.js +171 -0
  21. package/dist/common/http.js.map +1 -0
  22. package/dist/common/zod-validation.pipe.js +47 -0
  23. package/dist/common/zod-validation.pipe.js.map +1 -0
  24. package/dist/config.js +354 -0
  25. package/dist/config.js.map +1 -0
  26. package/dist/config.module.js +35 -0
  27. package/dist/config.module.js.map +1 -0
  28. package/dist/controllers/cardano.controller.js +173 -0
  29. package/dist/controllers/cardano.controller.js.map +1 -0
  30. package/dist/controllers/heads.controller.js +225 -0
  31. package/dist/controllers/heads.controller.js.map +1 -0
  32. package/dist/controllers/setup.controller.js +127 -0
  33. package/dist/controllers/setup.controller.js.map +1 -0
  34. package/dist/controllers/system.controller.js +153 -0
  35. package/dist/controllers/system.controller.js.map +1 -0
  36. package/dist/db/database.module.js +73 -0
  37. package/dist/db/database.module.js.map +1 -0
  38. package/dist/db/index.js +135 -0
  39. package/dist/db/index.js.map +1 -0
  40. package/dist/db/repositories.js +220 -0
  41. package/dist/db/repositories.js.map +1 -0
  42. package/dist/docker/container-stats.js +134 -0
  43. package/dist/docker/container-stats.js.map +1 -0
  44. package/dist/docker/docker.service.js +335 -0
  45. package/dist/docker/docker.service.js.map +1 -0
  46. package/dist/hydra/argv.js +172 -0
  47. package/dist/hydra/argv.js.map +1 -0
  48. package/dist/hydra/blockfrost-keys.js +15 -0
  49. package/dist/hydra/blockfrost-keys.js.map +1 -0
  50. package/dist/hydra/boot-progress.js +165 -0
  51. package/dist/hydra/boot-progress.js.map +1 -0
  52. package/dist/hydra/capabilities.js +131 -0
  53. package/dist/hydra/capabilities.js.map +1 -0
  54. package/dist/hydra/head.service.js +1072 -0
  55. package/dist/hydra/head.service.js.map +1 -0
  56. package/dist/hydra/keys.js +301 -0
  57. package/dist/hydra/keys.js.map +1 -0
  58. package/dist/hydra/node-monitor.service.js +265 -0
  59. package/dist/hydra/node-monitor.service.js.map +1 -0
  60. package/dist/hydra/ws-client.js +177 -0
  61. package/dist/hydra/ws-client.js.map +1 -0
  62. package/dist/main.js +106 -0
  63. package/dist/main.js.map +1 -0
  64. package/dist/preflight.js +215 -0
  65. package/dist/preflight.js.map +1 -0
  66. package/dist/settings.js +243 -0
  67. package/dist/settings.js.map +1 -0
  68. package/dist/setup.service.js +257 -0
  69. package/dist/setup.service.js.map +1 -0
  70. package/dist/version.js +46 -0
  71. package/dist/version.js.map +1 -0
  72. package/node_modules/@hexcore/shared/dist/cjs/api.d.ts +730 -0
  73. package/node_modules/@hexcore/shared/dist/cjs/api.d.ts.map +1 -0
  74. package/node_modules/@hexcore/shared/dist/cjs/api.js +358 -0
  75. package/node_modules/@hexcore/shared/dist/cjs/api.js.map +1 -0
  76. package/node_modules/@hexcore/shared/dist/cjs/domain.d.ts +298 -0
  77. package/node_modules/@hexcore/shared/dist/cjs/domain.d.ts.map +1 -0
  78. package/node_modules/@hexcore/shared/dist/cjs/domain.js +49 -0
  79. package/node_modules/@hexcore/shared/dist/cjs/domain.js.map +1 -0
  80. package/node_modules/@hexcore/shared/dist/cjs/hydra-versions.d.ts +279 -0
  81. package/node_modules/@hexcore/shared/dist/cjs/hydra-versions.d.ts.map +1 -0
  82. package/node_modules/@hexcore/shared/dist/cjs/hydra-versions.js +453 -0
  83. package/node_modules/@hexcore/shared/dist/cjs/hydra-versions.js.map +1 -0
  84. package/node_modules/@hexcore/shared/dist/cjs/index.d.ts +7 -0
  85. package/node_modules/@hexcore/shared/dist/cjs/index.d.ts.map +1 -0
  86. package/node_modules/@hexcore/shared/dist/cjs/index.js +23 -0
  87. package/node_modules/@hexcore/shared/dist/cjs/index.js.map +1 -0
  88. package/node_modules/@hexcore/shared/dist/cjs/naming.d.ts +118 -0
  89. package/node_modules/@hexcore/shared/dist/cjs/naming.d.ts.map +1 -0
  90. package/node_modules/@hexcore/shared/dist/cjs/naming.js +103 -0
  91. package/node_modules/@hexcore/shared/dist/cjs/naming.js.map +1 -0
  92. package/node_modules/@hexcore/shared/dist/cjs/offline.d.ts +73 -0
  93. package/node_modules/@hexcore/shared/dist/cjs/offline.d.ts.map +1 -0
  94. package/node_modules/@hexcore/shared/dist/cjs/offline.js +80 -0
  95. package/node_modules/@hexcore/shared/dist/cjs/offline.js.map +1 -0
  96. package/node_modules/@hexcore/shared/dist/cjs/protocol-params.d.ts +79 -0
  97. package/node_modules/@hexcore/shared/dist/cjs/protocol-params.d.ts.map +1 -0
  98. package/node_modules/@hexcore/shared/dist/cjs/protocol-params.js +223 -0
  99. package/node_modules/@hexcore/shared/dist/cjs/protocol-params.js.map +1 -0
  100. package/node_modules/@hexcore/shared/dist/esm/api.js +355 -0
  101. package/node_modules/@hexcore/shared/dist/esm/api.js.map +1 -0
  102. package/node_modules/@hexcore/shared/dist/esm/domain.js +46 -0
  103. package/node_modules/@hexcore/shared/dist/esm/domain.js.map +1 -0
  104. package/node_modules/@hexcore/shared/dist/esm/hydra-versions.js +441 -0
  105. package/node_modules/@hexcore/shared/dist/esm/hydra-versions.js.map +1 -0
  106. package/node_modules/@hexcore/shared/dist/esm/index.js +7 -0
  107. package/node_modules/@hexcore/shared/dist/esm/index.js.map +1 -0
  108. package/node_modules/@hexcore/shared/dist/esm/naming.js +95 -0
  109. package/node_modules/@hexcore/shared/dist/esm/naming.js.map +1 -0
  110. package/node_modules/@hexcore/shared/dist/esm/offline.js +75 -0
  111. package/node_modules/@hexcore/shared/dist/esm/offline.js.map +1 -0
  112. package/node_modules/@hexcore/shared/dist/esm/package.json +3 -0
  113. package/node_modules/@hexcore/shared/dist/esm/protocol-params.js +217 -0
  114. package/node_modules/@hexcore/shared/dist/esm/protocol-params.js.map +1 -0
  115. package/node_modules/@hexcore/shared/package.json +15 -0
  116. package/package.json +67 -0
  117. package/web/200.html +23 -0
  118. package/web/404.html +23 -0
  119. package/web/_nuxt/2MxohCD-.js +1 -0
  120. package/web/_nuxt/4pFXjB_u.js +1 -0
  121. package/web/_nuxt/B-v0dEQX.js +1 -0
  122. package/web/_nuxt/B4yE3U25.js +1 -0
  123. package/web/_nuxt/BFh8Ai0L.js +1 -0
  124. package/web/_nuxt/BgPn4NJH.js +1 -0
  125. package/web/_nuxt/Bj1xviSh.js +1 -0
  126. package/web/_nuxt/BnotlrL7.js +1 -0
  127. package/web/_nuxt/C1YRg2ic.js +1 -0
  128. package/web/_nuxt/CGD7MYQH.js +1 -0
  129. package/web/_nuxt/CQcG7Bu4.js +1 -0
  130. package/web/_nuxt/CS3KqpH_.js +1 -0
  131. package/web/_nuxt/CT-yt694.js +1 -0
  132. package/web/_nuxt/CZK6xUH-.js +1 -0
  133. package/web/_nuxt/CcdyYRYz.js +1 -0
  134. package/web/_nuxt/CePNTU1S.js +1 -0
  135. package/web/_nuxt/CgPLsCeU.js +5 -0
  136. package/web/_nuxt/CkCrahXt.js +1 -0
  137. package/web/_nuxt/CnOqDT9k.js +3 -0
  138. package/web/_nuxt/CqsSss-D.js +1 -0
  139. package/web/_nuxt/Cr8dL64Q.js +1 -0
  140. package/web/_nuxt/D3CwzwU0.js +1 -0
  141. package/web/_nuxt/DDANn6-H.js +1 -0
  142. package/web/_nuxt/DDl9uKIA.js +1 -0
  143. package/web/_nuxt/DL9i0ayn.js +1 -0
  144. package/web/_nuxt/DLNoK9BC.js +1 -0
  145. package/web/_nuxt/DLztFeOQ.js +1 -0
  146. package/web/_nuxt/DPihKXdt.js +1 -0
  147. package/web/_nuxt/DXyr6Naa.js +1 -0
  148. package/web/_nuxt/DeDg5p0D.js +1 -0
  149. package/web/_nuxt/DgDlQiDU.js +1 -0
  150. package/web/_nuxt/DyPI7qJE.js +30 -0
  151. package/web/_nuxt/LGfPBi70.js +1 -0
  152. package/web/_nuxt/Onf26W-r.js +1 -0
  153. package/web/_nuxt/QZNQe_OX.js +1 -0
  154. package/web/_nuxt/Y8IJM-iz.js +1 -0
  155. package/web/_nuxt/YUGC0nt0.js +1 -0
  156. package/web/_nuxt/builds/latest.json +1 -0
  157. package/web/_nuxt/builds/meta/7e461629-93e2-4694-b237-6d5c6a85c97c.json +1 -0
  158. package/web/_nuxt/builds/meta/dev.json +1 -0
  159. package/web/_nuxt/entry.BxsAxZxf.css +1 -0
  160. package/web/_nuxt/error-404.XbtAw-qw.css +1 -0
  161. package/web/_nuxt/error-500.CNHVltWM.css +1 -0
  162. package/web/_nuxt/rS90pPZ_.js +1 -0
  163. package/web/_nuxt/rhEiP908.js +1 -0
  164. package/web/_nuxt/vSj9Ec0g.js +1 -0
  165. package/web/_nuxt/woNjBJMN.js +1 -0
  166. package/web/favicon.svg +28 -0
  167. package/web/heads/index.html +23 -0
  168. package/web/heads/new/index.html +23 -0
  169. package/web/index.html +23 -0
  170. package/web/login/index.html +23 -0
  171. package/web/logo.svg +56 -0
  172. package/web/settings/index.html +23 -0
  173. package/web/setup/index.html +23 -0
@@ -0,0 +1,173 @@
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.CardanoController = void 0;
16
+ /**
17
+ * Checking key material before it is committed to a head.
18
+ *
19
+ * Pasting a signing key is the one step of head creation with no feedback: the
20
+ * address it produces only becomes visible once the head exists, and by then a
21
+ * wrong key means deleting the head and starting over. This answers both
22
+ * questions while the form is still open — what address is this, and does it
23
+ * hold anything.
24
+ */
25
+ const common_1 = require("@nestjs/common");
26
+ const swagger_1 = require("@nestjs/swagger");
27
+ const shared_1 = require("@hexcore/shared");
28
+ const zod_validation_pipe_1 = require("../common/zod-validation.pipe");
29
+ const config_module_1 = require("../config.module");
30
+ const provider_1 = require("../chain/provider");
31
+ const socket_1 = require("../chain/socket");
32
+ const keys_1 = require("../hydra/keys");
33
+ const head_service_1 = require("../hydra/head.service");
34
+ let CardanoController = class CardanoController {
35
+ config;
36
+ constructor(config) {
37
+ this.config = config;
38
+ }
39
+ async verifyKey(body) {
40
+ const network = body.network ?? this.config.network;
41
+ let address;
42
+ try {
43
+ address = (0, keys_1.validateCardanoKeyInput)({ signingKey: body.signingKey, verificationKey: body.verificationKey }, network);
44
+ }
45
+ catch (err) {
46
+ // Surfaced on the field, in the same envelope as a zod failure —
47
+ // whether the key is malformed or simply not the vkey's partner.
48
+ if (err instanceof keys_1.KeyImportError) {
49
+ throw new head_service_1.HeadValidationError('signingKey', err.message);
50
+ }
51
+ throw err;
52
+ }
53
+ const result = {
54
+ address,
55
+ network,
56
+ balance: null,
57
+ ...(body.verificationKey ? { verificationKeyMatches: true } : {}),
58
+ };
59
+ /**
60
+ * Balance is best-effort: the address is the answer that matters, and a
61
+ * chain lookup that fails must not make a perfectly good key look
62
+ * invalid. Every failure below leaves `address` intact and explains
63
+ * itself in `balanceUnavailable`.
64
+ */
65
+ const projectId = body.blockfrostProjectId || this.config.blockfrostProjectId;
66
+ if (!projectId) {
67
+ const socket = await (0, socket_1.checkNodeSocket)(this.config.cardanoNodeSocket);
68
+ result.balanceUnavailable = socket.available
69
+ ? 'Balance lookup goes through Blockfrost, which needs a project id — the ' +
70
+ 'cardano-node socket cannot answer it without cardano-cli.'
71
+ : 'No Blockfrost project id and no cardano-node socket, so there is nothing to ask.';
72
+ return result;
73
+ }
74
+ /**
75
+ * The address is network-scoped and so is the key: a preprod key cannot
76
+ * answer for a mainnet address. Saying so beats a 403 from Blockfrost
77
+ * that reads as "your key is bad".
78
+ */
79
+ if (!projectId.startsWith(network)) {
80
+ result.balanceUnavailable = `The Blockfrost key is not for ${network}, so the balance was not looked up.`;
81
+ return result;
82
+ }
83
+ try {
84
+ const provider = new provider_1.BlockfrostProvider(projectId, this.baseUrlFor(network));
85
+ result.balance = await provider.addressBalance(address);
86
+ }
87
+ catch (err) {
88
+ result.balanceUnavailable = err.message;
89
+ }
90
+ return result;
91
+ }
92
+ /**
93
+ * The protocol parameters a head created right now would boot with.
94
+ *
95
+ * The create form needs this before it can offer to edit them: overrides
96
+ * merge at the TOP level, so the only safe way to change one field is to
97
+ * start from the whole current value and diff against it. Doing that in the
98
+ * browser would mean shipping a Blockfrost key there; doing it here does
99
+ * not.
100
+ *
101
+ * A lookup failure is not an error — the static baseline is a perfectly
102
+ * good thing to edit, and it is what a head with no key boots with anyway.
103
+ */
104
+ async protocolParameters(body) {
105
+ const network = body.network ?? this.config.network;
106
+ const projectId = body.blockfrostProjectId || this.config.blockfrostProjectId;
107
+ let parameters = (0, provider_1.defaultProtocolParameters)();
108
+ let source = 'defaults';
109
+ let note;
110
+ if (!projectId) {
111
+ note = 'No Blockfrost project id, so these are the built-in baseline values.';
112
+ }
113
+ else if (!projectId.startsWith(network)) {
114
+ note = `The Blockfrost key is not for ${network}, so the built-in baseline is shown instead.`;
115
+ }
116
+ else {
117
+ try {
118
+ const provider = new provider_1.BlockfrostProvider(projectId, this.baseUrlFor(network));
119
+ parameters = (0, provider_1.blockfrostToCliParams)(await provider.latestEpochParameters());
120
+ source = 'blockfrost';
121
+ }
122
+ catch (err) {
123
+ note = `Could not read live parameters (${err.message}); showing the built-in baseline.`;
124
+ }
125
+ }
126
+ // Zeroed by default, because that is what a head actually boots with —
127
+ // editing a fee the head would not charge is a trap otherwise.
128
+ if (body.zeroFees !== false)
129
+ parameters = (0, provider_1.applyL2Defaults)(parameters);
130
+ return { parameters, source, ...(note ? { note } : {}) };
131
+ }
132
+ /**
133
+ * The configured base URL follows CARDANO_NETWORK, so a request that names
134
+ * another network has to be pointed at that network's host instead.
135
+ */
136
+ baseUrlFor(network) {
137
+ if (network === this.config.network)
138
+ return this.config.blockfrostBaseUrl;
139
+ return network === 'mainnet'
140
+ ? 'https://cardano-mainnet.blockfrost.io/api/v0'
141
+ : `https://cardano-${network}.blockfrost.io/api/v0`;
142
+ }
143
+ };
144
+ exports.CardanoController = CardanoController;
145
+ __decorate([
146
+ (0, common_1.Post)('verify-key'),
147
+ (0, common_1.HttpCode)(200),
148
+ (0, swagger_1.ApiOperation)({
149
+ summary: 'Derive the address for a Cardano signing key, and its balance when reachable',
150
+ }),
151
+ (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(shared_1.verifyCardanoKeySchema)),
152
+ __param(0, (0, common_1.Body)()),
153
+ __metadata("design:type", Function),
154
+ __metadata("design:paramtypes", [Object]),
155
+ __metadata("design:returntype", Promise)
156
+ ], CardanoController.prototype, "verifyKey", null);
157
+ __decorate([
158
+ (0, common_1.Post)('protocol-parameters'),
159
+ (0, common_1.HttpCode)(200),
160
+ (0, swagger_1.ApiOperation)({ summary: 'Effective L2 protocol parameters, as a head would boot with them' }),
161
+ (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(shared_1.protocolParametersQuerySchema)),
162
+ __param(0, (0, common_1.Body)()),
163
+ __metadata("design:type", Function),
164
+ __metadata("design:paramtypes", [Object]),
165
+ __metadata("design:returntype", Promise)
166
+ ], CardanoController.prototype, "protocolParameters", null);
167
+ exports.CardanoController = CardanoController = __decorate([
168
+ (0, swagger_1.ApiTags)('cardano'),
169
+ (0, common_1.Controller)('api/cardano'),
170
+ __param(0, (0, common_1.Inject)(config_module_1.APP_CONFIG)),
171
+ __metadata("design:paramtypes", [Object])
172
+ ], CardanoController);
173
+ //# sourceMappingURL=cardano.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cardano.controller.js","sourceRoot":"","sources":["../../src/controllers/cardano.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;GAQG;AACH,2CAAoF;AACpF,6CAAwD;AACxD,4CAOyB;AACzB,uEAAkE;AAClE,oDAA8C;AAE9C,gDAK2B;AAC3B,4CAAkD;AAClD,wCAAwE;AACxE,wDAA4D;AAIrD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IACuB;IAAjD,YAAiD,MAAiB;QAAjB,WAAM,GAAN,MAAM,CAAW;IAAG,CAAC;IAQhE,AAAN,KAAK,CAAC,SAAS,CAAS,IAA2B;QAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QAEpD,IAAI,OAAe,CAAC;QACpB,IAAI,CAAC;YACD,OAAO,GAAG,IAAA,8BAAuB,EAC7B,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,eAAe,EAAE,IAAI,CAAC,eAAe,EAAE,EACtE,OAAO,CACV,CAAC;QACN,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,iEAAiE;YACjE,iEAAiE;YACjE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,CAAC,EAAE,CAAC,EAAE,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACK,UAAU,CAAC,OAAe;QAC9B,IAAI,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;QAC1E,OAAO,OAAO,KAAK,SAAS;YACxB,CAAC,CAAC,8CAA8C;YAChD,CAAC,CAAC,mBAAmB,OAAO,uBAAuB,CAAC;IAC5D,CAAC;CACJ,CAAA;AA3HY,8CAAiB;AASpB;IANL,IAAA,aAAI,EAAC,YAAY,CAAC;IAClB,IAAA,iBAAQ,EAAC,GAAG,CAAC;IACb,IAAA,sBAAY,EAAC;QACV,OAAO,EAAE,8EAA8E;KAC1F,CAAC;IACD,IAAA,iBAAQ,EAAC,IAAI,uCAAiB,CAAC,+BAAsB,CAAC,CAAC;IACvC,WAAA,IAAA,aAAI,GAAE,CAAA;;;;kDA0DtB;AAkBK;IAJL,IAAA,aAAI,EAAC,qBAAqB,CAAC;IAC3B,IAAA,iBAAQ,EAAC,GAAG,CAAC;IACb,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,kEAAkE,EAAE,CAAC;IAC7F,IAAA,iBAAQ,EAAC,IAAI,uCAAiB,CAAC,sCAA6B,CAAC,CAAC;IACrC,WAAA,IAAA,aAAI,GAAE,CAAA;;;;2DA0B/B;4BA/GQ,iBAAiB;IAF7B,IAAA,iBAAO,EAAC,SAAS,CAAC;IAClB,IAAA,mBAAU,EAAC,aAAa,CAAC;IAET,WAAA,IAAA,eAAM,EAAC,0BAAU,CAAC,CAAA;;GADtB,iBAAiB,CA2H7B"}
@@ -0,0 +1,225 @@
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.HeadsController = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const swagger_1 = require("@nestjs/swagger");
18
+ const shared_1 = require("@hexcore/shared");
19
+ const head_service_1 = require("../hydra/head.service");
20
+ const zod_validation_pipe_1 = require("../common/zod-validation.pipe");
21
+ let HeadsController = class HeadsController {
22
+ heads;
23
+ constructor(heads) {
24
+ this.heads = heads;
25
+ }
26
+ list() {
27
+ return this.heads.list();
28
+ }
29
+ get(id) {
30
+ return this.heads.get(id);
31
+ }
32
+ create(body) {
33
+ return this.heads.create(body);
34
+ }
35
+ update(id, body) {
36
+ return this.heads.update(id, body);
37
+ }
38
+ start(id) {
39
+ return this.heads.start(id);
40
+ }
41
+ stop(id) {
42
+ return this.heads.stop(id);
43
+ }
44
+ restart(id) {
45
+ return this.heads.restart(id);
46
+ }
47
+ reset(id, body) {
48
+ return this.heads.reset(id, body.includeKeys);
49
+ }
50
+ async remove(id) {
51
+ await this.heads.delete(id);
52
+ return { deleted: true };
53
+ }
54
+ liveStatus(id) {
55
+ return this.heads.liveStatus(id);
56
+ }
57
+ bootProgress(id) {
58
+ return this.heads.bootProgress(id);
59
+ }
60
+ resources(id) {
61
+ return this.heads.resourceUsage(id);
62
+ }
63
+ async logs(id, index, tail) {
64
+ const lines = Math.min(Math.max(Number(tail) || 200, 1), 5000);
65
+ return { logs: await this.heads.nodeLogs(id, index, lines) };
66
+ }
67
+ events(id, limit) {
68
+ return this.heads.recentEvents(id, Math.min(Math.max(Number(limit) || 100, 1), 500));
69
+ }
70
+ };
71
+ exports.HeadsController = HeadsController;
72
+ __decorate([
73
+ (0, common_1.Get)(),
74
+ (0, swagger_1.ApiOperation)({ summary: 'List every head with its nodes' }),
75
+ __metadata("design:type", Function),
76
+ __metadata("design:paramtypes", []),
77
+ __metadata("design:returntype", void 0)
78
+ ], HeadsController.prototype, "list", null);
79
+ __decorate([
80
+ (0, common_1.Get)(':id'),
81
+ (0, swagger_1.ApiOperation)({ summary: 'Fetch one head' }),
82
+ (0, swagger_1.ApiParam)({ name: 'id', type: Number }),
83
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
84
+ __metadata("design:type", Function),
85
+ __metadata("design:paramtypes", [Number]),
86
+ __metadata("design:returntype", void 0)
87
+ ], HeadsController.prototype, "get", null);
88
+ __decorate([
89
+ (0, common_1.Post)(),
90
+ (0, swagger_1.ApiOperation)({
91
+ summary: 'Create a head',
92
+ description: 'Generates Hydra and Cardano key pairs for every node and returns the fundable ' +
93
+ 'addresses. No external key generation is required — this is the main difference from v1.',
94
+ }),
95
+ (0, common_1.UsePipes)(new zod_validation_pipe_1.ZodValidationPipe(shared_1.createHeadSchema)),
96
+ __param(0, (0, common_1.Body)()),
97
+ __metadata("design:type", Function),
98
+ __metadata("design:paramtypes", [Object]),
99
+ __metadata("design:returntype", void 0)
100
+ ], HeadsController.prototype, "create", null);
101
+ __decorate([
102
+ (0, common_1.Patch)(':id'),
103
+ (0, swagger_1.ApiOperation)({ summary: 'Update mutable head settings (applied on next start)' }),
104
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
105
+ __param(1, (0, common_1.Body)(new zod_validation_pipe_1.ZodValidationPipe(shared_1.updateHeadSchema))),
106
+ __metadata("design:type", Function),
107
+ __metadata("design:paramtypes", [Number, Object]),
108
+ __metadata("design:returntype", void 0)
109
+ ], HeadsController.prototype, "update", null);
110
+ __decorate([
111
+ (0, common_1.Post)(':id/start'),
112
+ (0, common_1.HttpCode)(200),
113
+ (0, swagger_1.ApiOperation)({
114
+ summary: 'Boot every node of the head',
115
+ description: 'Pulls the image if needed, writes protocol parameters, creates one container per node ' +
116
+ 'wired as peers, and waits until every node answers on its API port. Rolls back on failure.',
117
+ }),
118
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
119
+ __metadata("design:type", Function),
120
+ __metadata("design:paramtypes", [Number]),
121
+ __metadata("design:returntype", void 0)
122
+ ], HeadsController.prototype, "start", null);
123
+ __decorate([
124
+ (0, common_1.Post)(':id/stop'),
125
+ (0, common_1.HttpCode)(200),
126
+ (0, swagger_1.ApiOperation)({ summary: 'Remove the head containers, keeping keys and persistence' }),
127
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
128
+ __metadata("design:type", Function),
129
+ __metadata("design:paramtypes", [Number]),
130
+ __metadata("design:returntype", void 0)
131
+ ], HeadsController.prototype, "stop", null);
132
+ __decorate([
133
+ (0, common_1.Post)(':id/restart'),
134
+ (0, common_1.HttpCode)(200),
135
+ (0, swagger_1.ApiOperation)({ summary: 'Stop then start the head' }),
136
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
137
+ __metadata("design:type", Function),
138
+ __metadata("design:paramtypes", [Number]),
139
+ __metadata("design:returntype", void 0)
140
+ ], HeadsController.prototype, "restart", null);
141
+ __decorate([
142
+ (0, common_1.Post)(':id/reset'),
143
+ (0, common_1.HttpCode)(200),
144
+ (0, swagger_1.ApiOperation)({
145
+ summary: 'Wipe persistence so the next start begins from a clean Hydra state',
146
+ description: 'Pass includeKeys=true to also regenerate key material (produces new addresses).',
147
+ }),
148
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
149
+ __param(1, (0, common_1.Body)(new zod_validation_pipe_1.ZodValidationPipe(shared_1.resetHeadSchema))),
150
+ __metadata("design:type", Function),
151
+ __metadata("design:paramtypes", [Number, Object]),
152
+ __metadata("design:returntype", void 0)
153
+ ], HeadsController.prototype, "reset", null);
154
+ __decorate([
155
+ (0, common_1.Delete)(':id'),
156
+ (0, swagger_1.ApiOperation)({ summary: 'Delete the head, its containers and its state directory' }),
157
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
158
+ __metadata("design:type", Function),
159
+ __metadata("design:paramtypes", [Number]),
160
+ __metadata("design:returntype", Promise)
161
+ ], HeadsController.prototype, "remove", null);
162
+ __decorate([
163
+ (0, common_1.Get)(':id/status'),
164
+ (0, swagger_1.ApiOperation)({
165
+ summary: 'Live status probed from the nodes themselves',
166
+ description: 'Opens a short-lived WebSocket to each node and reports the real Hydra state.',
167
+ }),
168
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
169
+ __metadata("design:type", Function),
170
+ __metadata("design:paramtypes", [Number]),
171
+ __metadata("design:returntype", void 0)
172
+ ], HeadsController.prototype, "liveStatus", null);
173
+ __decorate([
174
+ (0, common_1.Get)(':id/boot'),
175
+ (0, swagger_1.ApiOperation)({
176
+ summary: 'Progress of the current or last boot',
177
+ description: 'The phases `start` walks, with the control-plane and container output interleaved. ' +
178
+ 'Polled by the UI while the start request is still in flight. Null when this head has ' +
179
+ 'not been started since the control-plane came up.',
180
+ }),
181
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
182
+ __metadata("design:type", Function),
183
+ __metadata("design:paramtypes", [Number]),
184
+ __metadata("design:returntype", void 0)
185
+ ], HeadsController.prototype, "bootProgress", null);
186
+ __decorate([
187
+ (0, common_1.Get)(':id/resources'),
188
+ (0, swagger_1.ApiOperation)({
189
+ summary: 'CPU and memory each node container is using right now',
190
+ description: 'One `docker stats` sample per node, plus the head total. Sampling costs about a ' +
191
+ 'second inside the Docker daemon — Docker takes two readings so a CPU percentage ' +
192
+ 'exists at all — so this is a request the operator makes, not part of status polling.',
193
+ }),
194
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
195
+ __metadata("design:type", Function),
196
+ __metadata("design:paramtypes", [Number]),
197
+ __metadata("design:returntype", void 0)
198
+ ], HeadsController.prototype, "resources", null);
199
+ __decorate([
200
+ (0, common_1.Get)(':id/nodes/:index/logs'),
201
+ (0, swagger_1.ApiOperation)({ summary: 'Tail a node container log' }),
202
+ (0, swagger_1.ApiQuery)({ name: 'tail', required: false, type: Number }),
203
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
204
+ __param(1, (0, common_1.Param)('index', common_1.ParseIntPipe)),
205
+ __param(2, (0, common_1.Query)('tail')),
206
+ __metadata("design:type", Function),
207
+ __metadata("design:paramtypes", [Number, Number, String]),
208
+ __metadata("design:returntype", Promise)
209
+ ], HeadsController.prototype, "logs", null);
210
+ __decorate([
211
+ (0, common_1.Get)(':id/events'),
212
+ (0, swagger_1.ApiOperation)({ summary: 'Recent lifecycle events for this head' }),
213
+ __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
214
+ __param(1, (0, common_1.Query)('limit')),
215
+ __metadata("design:type", Function),
216
+ __metadata("design:paramtypes", [Number, String]),
217
+ __metadata("design:returntype", void 0)
218
+ ], HeadsController.prototype, "events", null);
219
+ exports.HeadsController = HeadsController = __decorate([
220
+ (0, swagger_1.ApiTags)('heads'),
221
+ (0, swagger_1.ApiBearerAuth)(),
222
+ (0, common_1.Controller)('api/heads'),
223
+ __metadata("design:paramtypes", [head_service_1.HeadService])
224
+ ], HeadsController);
225
+ //# sourceMappingURL=heads.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heads.controller.js","sourceRoot":"","sources":["../../src/controllers/heads.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAYwB;AACxB,6CAA2F;AAC3F,4CAOyB;AACzB,wDAAoD;AACpD,uEAAkE;AAK3D,IAAM,eAAe,GAArB,MAAM,eAAe;IACK;IAA7B,YAA6B,KAAkB;QAAlB,UAAK,GAAL,KAAK,CAAa;IAAG,CAAC;IAInD,IAAI;QACA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,E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AAA,IAAA,cAAK,EAAC,OAAO,EAAE,qBAAY,CAAC,CAAA;IAC5B,WAAA,IAAA,cAAK,EAAC,MAAM,CAAC,CAAA;;;;2CAIjB;AAID;IAFC,IAAA,YAAG,EAAC,YAAY,CAAC;IACjB,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,uCAAuC,EAAE,CAAC;IAC3D,WAAA,IAAA,cAAK,EAAC,IAAI,EAAE,qBAAY,CAAC,CAAA;IAAc,WAAA,IAAA,cAAK,EAAC,OAAO,CAAC,CAAA;;;;6CAE5D;0BAjIQ,eAAe;IAH3B,IAAA,iBAAO,EAAC,OAAO,CAAC;IAChB,IAAA,uBAAa,GAAE;IACf,IAAA,mBAAU,EAAC,WAAW,CAAC;qCAEgB,0BAAW;GADtC,eAAe,CAkI3B"}
@@ -0,0 +1,127 @@
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.SetupController = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const swagger_1 = require("@nestjs/swagger");
18
+ const shared_1 = require("@hexcore/shared");
19
+ const setup_service_1 = require("../setup.service");
20
+ const auth_guard_1 = require("../common/auth.guard");
21
+ const zod_validation_pipe_1 = require("../common/zod-validation.pipe");
22
+ const config_1 = require("../config");
23
+ let SetupController = class SetupController {
24
+ setup;
25
+ constructor(setup) {
26
+ this.setup = setup;
27
+ }
28
+ /**
29
+ * Public because it is read before there is anyone to authenticate.
30
+ *
31
+ * The UI asks this on every load to decide whether to show the wizard, and
32
+ * it has to answer for a browser that holds no token at all. It carries no
33
+ * secret — the Blockfrost default is returned blank, never the stored key.
34
+ */
35
+ status() {
36
+ return this.setup.status();
37
+ }
38
+ /**
39
+ * Public, and guarded by three things instead: setup must still be due, the
40
+ * request must carry the token printed at boot, and the whole endpoint
41
+ * stops answering the moment it succeeds. See SetupService.
42
+ */
43
+ complete(body) {
44
+ return this.setup.complete(body);
45
+ }
46
+ read() {
47
+ return {
48
+ settings: this.setup.status().defaults,
49
+ provenance: (0, config_1.describeProvenance)(),
50
+ confirmationPhrase: this.setup.confirmationPhrase(),
51
+ };
52
+ }
53
+ save(body) {
54
+ this.setup.saveSettings(body);
55
+ return this.setup.status();
56
+ }
57
+ /**
58
+ * Wipe, bounded.
59
+ *
60
+ * `everything` is not accepted here — the schema does not admit it. It
61
+ * deletes the signing keys behind funded addresses and the database this
62
+ * request is being served from; `hexcore clean --all` does it offline.
63
+ */
64
+ clean(body) {
65
+ return this.setup.clean(body.scope, body.confirm);
66
+ }
67
+ };
68
+ exports.SetupController = SetupController;
69
+ __decorate([
70
+ (0, auth_guard_1.Public)(),
71
+ (0, common_1.Get)('setup'),
72
+ (0, swagger_1.ApiOperation)({ summary: 'Whether this installation still needs configuring' }),
73
+ __metadata("design:type", Function),
74
+ __metadata("design:paramtypes", []),
75
+ __metadata("design:returntype", void 0)
76
+ ], SetupController.prototype, "status", null);
77
+ __decorate([
78
+ (0, auth_guard_1.Public)(),
79
+ (0, common_1.Post)('setup'),
80
+ (0, common_1.HttpCode)(200),
81
+ (0, swagger_1.ApiOperation)({
82
+ summary: 'Complete first-run setup',
83
+ description: 'Writes the settings file, sets the admin password and applies both to the running ' +
84
+ 'process. Refused once setup is done — change settings from PATCH /api/settings.',
85
+ }),
86
+ __param(0, (0, common_1.Body)(new zod_validation_pipe_1.ZodValidationPipe(shared_1.completeSetupSchema))),
87
+ __metadata("design:type", Function),
88
+ __metadata("design:paramtypes", [Object]),
89
+ __metadata("design:returntype", void 0)
90
+ ], SetupController.prototype, "complete", null);
91
+ __decorate([
92
+ (0, swagger_1.ApiBearerAuth)(),
93
+ (0, common_1.Get)('settings'),
94
+ (0, swagger_1.ApiOperation)({
95
+ summary: 'Current settings, and which layer each value came from',
96
+ description: 'Provenance is the point: with four layers — environment, .env, settings file, ' +
97
+ 'defaults — the question that gets asked is not what a value is but why.',
98
+ }),
99
+ __metadata("design:type", Function),
100
+ __metadata("design:paramtypes", []),
101
+ __metadata("design:returntype", void 0)
102
+ ], SetupController.prototype, "read", null);
103
+ __decorate([
104
+ (0, swagger_1.ApiBearerAuth)(),
105
+ (0, common_1.Patch)('settings'),
106
+ (0, swagger_1.ApiOperation)({ summary: 'Change settings; applied to the running process' }),
107
+ __param(0, (0, common_1.Body)(new zod_validation_pipe_1.ZodValidationPipe(shared_1.settingsSchema))),
108
+ __metadata("design:type", Function),
109
+ __metadata("design:paramtypes", [Object]),
110
+ __metadata("design:returntype", void 0)
111
+ ], SetupController.prototype, "save", null);
112
+ __decorate([
113
+ (0, swagger_1.ApiBearerAuth)(),
114
+ (0, common_1.Post)('settings/clean'),
115
+ (0, common_1.HttpCode)(200),
116
+ (0, swagger_1.ApiOperation)({ summary: 'Reset configuration, or delete every head' }),
117
+ __param(0, (0, common_1.Body)(new zod_validation_pipe_1.ZodValidationPipe(shared_1.cleanSchema))),
118
+ __metadata("design:type", Function),
119
+ __metadata("design:paramtypes", [Object]),
120
+ __metadata("design:returntype", void 0)
121
+ ], SetupController.prototype, "clean", null);
122
+ exports.SetupController = SetupController = __decorate([
123
+ (0, swagger_1.ApiTags)('setup'),
124
+ (0, common_1.Controller)('api'),
125
+ __metadata("design:paramtypes", [setup_service_1.SetupService])
126
+ ], SetupController);
127
+ //# sourceMappingURL=setup.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.controller.js","sourceRoot":"","sources":["../../src/controllers/setup.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA8E;AAC9E,6CAAuE;AACvE,4CAOyB;AACzB,oDAAgD;AAChD,qDAA8C;AAC9C,uEAAkE;AAClE,sCAA+C;AAIxC,IAAM,eAAe,GAArB,MAAM,eAAe;IACK;IAA7B,YAA6B,KAAmB;QAAnB,UAAK,GAAL,KAAK,CAAc;IAAG,CAAC;IAEpD;;;;;;OAMG;IAIH,MAAM;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IAUH,QAAQ,CAAmD,IAAwB;QAC/E,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAUD,IAAI;QACA,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,QAAQ;YACtC,UAAU,EAAE,IAAA,2BAAkB,GAAE;YAChC,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAAC,kBAAkB,EAAE;SACtD,CAAC;IACN,CAAC;IAKD,IAAI,CAA8C,IAAmB;QACjE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IAKH,KAAK,CAA2C,IAAgB;QAC5D,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;CACJ,CAAA;AAzEY,0CAAe;AAaxB;IAHC,IAAA,mBAAM,GAAE;IACR,IAAA,YAAG,EAAC,OAAO,CAAC;IACZ,IAAA,sBAAY,E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