@nervur.org/installer-node 0.0.0-stage → 0.37.2

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 (364) hide show
  1. package/LICENSE +105 -0
  2. package/README.md +159 -2
  3. package/SECURITY.md +8 -0
  4. package/bin/nervur.js +5 -0
  5. package/cargo/emscripten-module.wasm +0 -0
  6. package/cargo/manifest.json +1 -0
  7. package/cargo/sqlite3.wasm +0 -0
  8. package/cargo/table-i-i.wasm +0 -0
  9. package/cargo/table-i-ii.wasm +0 -0
  10. package/cargo/table-i-iii.wasm +0 -0
  11. package/cargo/table-i-iiii.wasm +0 -0
  12. package/cargo/table-i-iiiii.wasm +0 -0
  13. package/cargo/table-i-iiij.wasm +0 -0
  14. package/cargo/table-i-ij.wasm +0 -0
  15. package/cargo/table-v-ii.wasm +0 -0
  16. package/cargo/table-v-iii.wasm +0 -0
  17. package/cargo/worker.js +30808 -0
  18. package/organs/console/node/guard.d.ts +10 -0
  19. package/organs/console/node/guard.js +52 -0
  20. package/organs/console/node/index.d.ts +4 -0
  21. package/organs/console/node/index.js +5 -0
  22. package/organs/console/node/line.d.ts +16 -0
  23. package/organs/console/node/line.js +150 -0
  24. package/organs/console/node/main.js +51 -0
  25. package/organs/console/node/program.d.ts +1 -0
  26. package/organs/console/node/program.js +5 -0
  27. package/organs/console/node/proof.d.ts +15 -0
  28. package/organs/console/node/proof.js +84 -0
  29. package/organs/console/node/socket.d.ts +15 -0
  30. package/organs/console/node/socket.js +99 -0
  31. package/organs/disk/index.d.ts +1 -0
  32. package/organs/disk/index.js +2 -0
  33. package/organs/disk/node/files.js +162 -0
  34. package/organs/disk/node/main.js +20 -0
  35. package/organs/disk/node/program.d.ts +1 -0
  36. package/organs/disk/node/program.js +5 -0
  37. package/organs/disk/organ.d.ts +5 -0
  38. package/organs/disk/organ.js +69 -0
  39. package/organs/network/node/fill.d.ts +21 -0
  40. package/organs/network/node/fill.js +195 -0
  41. package/organs/network/node/flows.js +66 -0
  42. package/organs/network/node/half.js +260 -0
  43. package/organs/network/node/lines.d.ts +29 -0
  44. package/organs/network/node/lines.js +236 -0
  45. package/organs/network/node/link.d.ts +24 -0
  46. package/organs/network/node/link.js +215 -0
  47. package/organs/network/node/main.js +41 -0
  48. package/organs/network/node/moved.d.ts +2 -0
  49. package/organs/network/node/moved.js +20 -0
  50. package/organs/network/node/near.d.ts +63 -0
  51. package/organs/network/node/near.js +263 -0
  52. package/organs/network/node/program.d.ts +1 -0
  53. package/organs/network/node/program.js +5 -0
  54. package/organs/network/node/schemes.d.ts +1 -0
  55. package/organs/network/node/schemes.js +2 -0
  56. package/organs/network/node/sent.d.ts +13 -0
  57. package/organs/network/node/sent.js +101 -0
  58. package/organs/network/node/served.d.ts +19 -0
  59. package/organs/network/node/served.js +237 -0
  60. package/organs/screen/node/client.js +3 -0
  61. package/organs/screen/node/follow.js +266 -0
  62. package/organs/screen/node/frames.js +26 -0
  63. package/organs/screen/node/held.js +27 -0
  64. package/organs/screen/node/http.js +179 -0
  65. package/organs/screen/node/lay.js +116 -0
  66. package/organs/screen/node/leave.js +27 -0
  67. package/organs/screen/node/linked.js +69 -0
  68. package/organs/screen/node/listen.js +61 -0
  69. package/organs/screen/node/look.js +121 -0
  70. package/organs/screen/node/loop.js +154 -0
  71. package/organs/screen/node/main.js +74 -0
  72. package/organs/screen/node/mirror.js +112 -0
  73. package/organs/screen/node/notice.js +44 -0
  74. package/organs/screen/node/presser.js +11 -0
  75. package/organs/screen/node/presses.js +108 -0
  76. package/organs/screen/node/program.d.ts +1 -0
  77. package/organs/screen/node/program.js +5 -0
  78. package/organs/screen/node/shown.js +205 -0
  79. package/organs/screen/node/standing.js +29 -0
  80. package/organs/screen/node/state.js +80 -0
  81. package/organs/screen/node/tell.js +47 -0
  82. package/organs/screen/node/uid.js +65 -0
  83. package/organs/screen/node/worn.js +23 -0
  84. package/organs/shell/index.d.ts +1 -0
  85. package/organs/shell/index.js +2 -0
  86. package/organs/shell/node/main.js +26 -0
  87. package/organs/shell/node/output.js +70 -0
  88. package/organs/shell/node/pressure.js +14 -0
  89. package/organs/shell/node/program.d.ts +1 -0
  90. package/organs/shell/node/program.js +5 -0
  91. package/organs/shell/node/runs.js +220 -0
  92. package/organs/shell/node/told.js +70 -0
  93. package/organs/shell/organ.d.ts +5 -0
  94. package/organs/shell/organ.js +59 -0
  95. package/package.json +43 -4
  96. package/src/command/act.d.ts +31 -0
  97. package/src/command/act.js +261 -0
  98. package/src/command/answers.d.ts +3 -0
  99. package/src/command/answers.js +232 -0
  100. package/src/command/args.d.ts +14 -0
  101. package/src/command/args.js +220 -0
  102. package/src/command/arrive.d.ts +2 -0
  103. package/src/command/arrive.js +21 -0
  104. package/src/command/asked.d.ts +18 -0
  105. package/src/command/asked.js +49 -0
  106. package/src/command/backup.d.ts +18 -0
  107. package/src/command/backup.js +261 -0
  108. package/src/command/before.d.ts +40 -0
  109. package/src/command/before.js +249 -0
  110. package/src/command/born.d.ts +27 -0
  111. package/src/command/born.js +103 -0
  112. package/src/command/bridge.d.ts +19 -0
  113. package/src/command/bridge.js +152 -0
  114. package/src/command/chain.d.ts +9 -0
  115. package/src/command/chain.js +48 -0
  116. package/src/command/channel.d.ts +29 -0
  117. package/src/command/channel.js +263 -0
  118. package/src/command/choices.d.ts +35 -0
  119. package/src/command/choices.js +173 -0
  120. package/src/command/claim.d.ts +12 -0
  121. package/src/command/claim.js +46 -0
  122. package/src/command/commands.d.ts +16 -0
  123. package/src/command/commands.js +257 -0
  124. package/src/command/ends.d.ts +16 -0
  125. package/src/command/ends.js +78 -0
  126. package/src/command/follow.d.ts +12 -0
  127. package/src/command/follow.js +66 -0
  128. package/src/command/given.d.ts +39 -0
  129. package/src/command/given.js +53 -0
  130. package/src/command/held.d.ts +15 -0
  131. package/src/command/held.js +56 -0
  132. package/src/command/index.d.ts +1 -0
  133. package/src/command/index.js +203 -0
  134. package/src/command/jailer.d.ts +28 -0
  135. package/src/command/jailer.js +135 -0
  136. package/src/command/laid.d.ts +6 -0
  137. package/src/command/laid.js +31 -0
  138. package/src/command/left.d.ts +9 -0
  139. package/src/command/left.js +34 -0
  140. package/src/command/line.d.ts +7 -0
  141. package/src/command/line.js +39 -0
  142. package/src/command/link.d.ts +30 -0
  143. package/src/command/link.js +123 -0
  144. package/src/command/lobes.d.ts +1 -0
  145. package/src/command/lobes.js +10 -0
  146. package/src/command/locks.d.ts +17 -0
  147. package/src/command/locks.js +76 -0
  148. package/src/command/mcp/calls.d.ts +27 -0
  149. package/src/command/mcp/calls.js +155 -0
  150. package/src/command/mcp/notices.d.ts +22 -0
  151. package/src/command/mcp/notices.js +203 -0
  152. package/src/command/mcp/resources.d.ts +31 -0
  153. package/src/command/mcp/resources.js +108 -0
  154. package/src/command/mcp/server.d.ts +19 -0
  155. package/src/command/mcp/server.js +149 -0
  156. package/src/command/mcp/tools.d.ts +39 -0
  157. package/src/command/mcp/tools.js +131 -0
  158. package/src/command/mcp.d.ts +8 -0
  159. package/src/command/mcp.js +39 -0
  160. package/src/command/noticed.d.ts +11 -0
  161. package/src/command/noticed.js +55 -0
  162. package/src/command/older.d.ts +11 -0
  163. package/src/command/older.js +45 -0
  164. package/src/command/open.d.ts +24 -0
  165. package/src/command/open.js +107 -0
  166. package/src/command/passphrase.d.ts +6 -0
  167. package/src/command/passphrase.js +82 -0
  168. package/src/command/reclaim.d.ts +7 -0
  169. package/src/command/reclaim.js +47 -0
  170. package/src/command/refused.d.ts +4 -0
  171. package/src/command/refused.js +27 -0
  172. package/src/command/release.d.ts +27 -0
  173. package/src/command/release.js +153 -0
  174. package/src/command/repo.d.ts +31 -0
  175. package/src/command/repo.js +133 -0
  176. package/src/command/rewrap.d.ts +16 -0
  177. package/src/command/rewrap.js +175 -0
  178. package/src/command/runtime.d.ts +25 -0
  179. package/src/command/runtime.js +175 -0
  180. package/src/command/salvage.d.ts +4 -0
  181. package/src/command/salvage.js +42 -0
  182. package/src/command/screen.d.ts +14 -0
  183. package/src/command/screen.js +62 -0
  184. package/src/command/spawn.d.ts +23 -0
  185. package/src/command/spawn.js +213 -0
  186. package/src/command/start.d.ts +34 -0
  187. package/src/command/start.js +246 -0
  188. package/src/command/state.d.ts +5 -0
  189. package/src/command/state.js +39 -0
  190. package/src/command/token.d.ts +1 -0
  191. package/src/command/token.js +9 -0
  192. package/src/command/trial.d.ts +18 -0
  193. package/src/command/trial.js +108 -0
  194. package/src/command/undone.d.ts +3 -0
  195. package/src/command/undone.js +21 -0
  196. package/src/command/vouch.d.ts +1 -0
  197. package/src/command/vouch.js +15 -0
  198. package/src/command/windows-processes.d.ts +2 -0
  199. package/src/command/windows-processes.js +22 -0
  200. package/src/command/wipe.d.ts +9 -0
  201. package/src/command/wipe.js +105 -0
  202. package/src/command/words.d.ts +5 -0
  203. package/src/command/words.js +53 -0
  204. package/src/door/claim.d.ts +5 -0
  205. package/src/door/claim.js +21 -0
  206. package/src/door/claimed.d.ts +7 -0
  207. package/src/door/claimed.js +110 -0
  208. package/src/door/configuration.d.ts +40 -0
  209. package/src/door/configuration.js +206 -0
  210. package/src/door/design.d.ts +13 -0
  211. package/src/door/design.js +71 -0
  212. package/src/door/digests.d.ts +7 -0
  213. package/src/door/digests.js +36 -0
  214. package/src/door/distribution.d.ts +25 -0
  215. package/src/door/distribution.js +88 -0
  216. package/src/door/door.d.ts +41 -0
  217. package/src/door/door.js +219 -0
  218. package/src/door/dressed.d.ts +34 -0
  219. package/src/door/dressed.js +182 -0
  220. package/src/door/faculties.d.ts +29 -0
  221. package/src/door/faculties.js +88 -0
  222. package/src/door/longest.d.ts +6 -0
  223. package/src/door/longest.js +25 -0
  224. package/src/fills/account-only.d.ts +3 -0
  225. package/src/fills/account-only.js +24 -0
  226. package/src/fills/boot-key.d.ts +21 -0
  227. package/src/fills/boot-key.js +70 -0
  228. package/src/fills/boot-move.d.ts +25 -0
  229. package/src/fills/boot-move.js +86 -0
  230. package/src/fills/bridge.d.ts +13 -0
  231. package/src/fills/bridge.js +86 -0
  232. package/src/fills/chance.d.ts +2 -0
  233. package/src/fills/chance.js +7 -0
  234. package/src/fills/crypto.d.ts +2 -0
  235. package/src/fills/crypto.js +94 -0
  236. package/src/fills/flushed.d.ts +9 -0
  237. package/src/fills/flushed.js +80 -0
  238. package/src/fills/hardware.d.ts +18 -0
  239. package/src/fills/hardware.js +70 -0
  240. package/src/fills/held.d.ts +31 -0
  241. package/src/fills/held.js +171 -0
  242. package/src/fills/keepers.d.ts +23 -0
  243. package/src/fills/keepers.js +151 -0
  244. package/src/fills/keyring.d.ts +19 -0
  245. package/src/fills/keyring.js +131 -0
  246. package/src/fills/pages.d.ts +3 -0
  247. package/src/fills/pages.js +260 -0
  248. package/src/fills/reserve.d.ts +11 -0
  249. package/src/fills/reserve.js +72 -0
  250. package/src/fills/time.d.ts +2 -0
  251. package/src/fills/time.js +29 -0
  252. package/src/fills/unlocker.d.ts +6 -0
  253. package/src/fills/unlocker.js +26 -0
  254. package/src/fills/vitals.d.ts +8 -0
  255. package/src/fills/vitals.js +100 -0
  256. package/src/fills/windows-start.d.ts +2 -0
  257. package/src/fills/windows-start.js +21 -0
  258. package/src/halves/build.d.ts +10 -0
  259. package/src/halves/build.js +219 -0
  260. package/src/halves/end.d.ts +17 -0
  261. package/src/halves/end.js +157 -0
  262. package/src/halves/genome.d.ts +3 -0
  263. package/src/halves/genome.js +21 -0
  264. package/src/halves/handler.d.ts +8 -0
  265. package/src/halves/handler.js +40 -0
  266. package/src/halves/index.d.ts +5 -0
  267. package/src/halves/index.js +6 -0
  268. package/src/halves/laid.d.ts +12 -0
  269. package/src/halves/laid.js +103 -0
  270. package/src/halves/lent.d.ts +6 -0
  271. package/src/halves/lent.js +147 -0
  272. package/src/halves/native.d.ts +12 -0
  273. package/src/halves/native.js +53 -0
  274. package/src/halves/statements.d.ts +23 -0
  275. package/src/halves/statements.js +165 -0
  276. package/src/halves/tokens.d.ts +22 -0
  277. package/src/halves/tokens.js +135 -0
  278. package/src/link/link.d.ts +4 -0
  279. package/src/link/link.js +4 -0
  280. package/src/link/placeholder.d.ts +1 -0
  281. package/src/link/placeholder.js +21 -0
  282. package/src/link/steps.d.ts +52 -0
  283. package/src/link/steps.js +118 -0
  284. package/src/lobes/calls.d.ts +76 -0
  285. package/src/lobes/calls.js +61 -0
  286. package/src/lobes/channel.d.ts +76 -0
  287. package/src/lobes/channel.js +202 -0
  288. package/src/lobes/index.d.ts +1 -0
  289. package/src/lobes/index.js +2 -0
  290. package/src/lobes/lobes.d.ts +15 -0
  291. package/src/lobes/lobes.js +244 -0
  292. package/src/lobes/main.js +107 -0
  293. package/src/lobes/thread.d.ts +22 -0
  294. package/src/lobes/thread.js +270 -0
  295. package/src/organism/act.d.ts +8 -0
  296. package/src/organism/act.js +63 -0
  297. package/src/organism/beat.d.ts +5 -0
  298. package/src/organism/beat.js +45 -0
  299. package/src/organism/compiled.d.ts +2 -0
  300. package/src/organism/compiled.js +24 -0
  301. package/src/organism/folder.d.ts +88 -0
  302. package/src/organism/folder.js +259 -0
  303. package/src/organism/main.d.ts +1 -0
  304. package/src/organism/main.js +11 -0
  305. package/src/organism/organism.d.ts +1 -0
  306. package/src/organism/organism.js +220 -0
  307. package/src/organism/said.d.ts +12 -0
  308. package/src/organism/said.js +30 -0
  309. package/src/organism/told.d.ts +5 -0
  310. package/src/organism/told.js +110 -0
  311. package/src/organism/unlock.d.ts +8 -0
  312. package/src/organism/unlock.js +95 -0
  313. package/src/organism/upgrade.d.ts +24 -0
  314. package/src/organism/upgrade.js +145 -0
  315. package/src/organism/via.d.ts +7 -0
  316. package/src/organism/via.js +20 -0
  317. package/src/service/body.d.ts +8 -0
  318. package/src/service/body.js +34 -0
  319. package/src/service/handler.d.ts +20 -0
  320. package/src/service/handler.js +128 -0
  321. package/src/service/index.d.ts +4 -0
  322. package/src/service/index.js +16 -0
  323. package/src/service/manager.d.ts +18 -0
  324. package/src/service/manager.js +185 -0
  325. package/src/service/service.d.ts +24 -0
  326. package/src/service/service.js +200 -0
  327. package/src/service/swap.d.ts +12 -0
  328. package/src/service/swap.js +74 -0
  329. package/src/service/watchdog.d.ts +6 -0
  330. package/src/service/watchdog.js +31 -0
  331. package/src/tcp/crowd.d.ts +18 -0
  332. package/src/tcp/crowd.js +85 -0
  333. package/src/tcp/dial.d.ts +23 -0
  334. package/src/tcp/dial.js +102 -0
  335. package/src/tcp/frame.d.ts +23 -0
  336. package/src/tcp/frame.js +159 -0
  337. package/src/tcp/listen.d.ts +50 -0
  338. package/src/tcp/listen.js +207 -0
  339. package/src/tcp/source.d.ts +2 -0
  340. package/src/tcp/source.js +26 -0
  341. package/src/version/index.d.ts +1 -0
  342. package/src/version/index.js +2 -0
  343. package/src/version/version.d.ts +1 -0
  344. package/src/version/version.js +2 -0
  345. package/src/work/first.d.ts +11 -0
  346. package/src/work/first.js +91 -0
  347. package/src/work/index.d.ts +2 -0
  348. package/src/work/index.js +15 -0
  349. package/src/work/work.d.ts +20 -0
  350. package/src/work/work.js +136 -0
  351. package/src/ws/dial.d.ts +7 -0
  352. package/src/ws/dial.js +252 -0
  353. package/src/ws/dialing.d.ts +50 -0
  354. package/src/ws/dialing.js +72 -0
  355. package/src/ws/frame.d.ts +32 -0
  356. package/src/ws/frame.js +124 -0
  357. package/src/ws/handshake.d.ts +4 -0
  358. package/src/ws/handshake.js +27 -0
  359. package/src/ws/line.d.ts +45 -0
  360. package/src/ws/line.js +250 -0
  361. package/src/ws/listen.d.ts +42 -0
  362. package/src/ws/listen.js +272 -0
  363. package/src/ws/rfc6455.d.ts +18 -0
  364. package/src/ws/rfc6455.js +187 -0
@@ -0,0 +1,182 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ const isFields = (value ) =>
40
+ typeof value === 'object' && value !== null && !Array.isArray(value);
41
+
42
+ const decoder = new TextDecoder();
43
+ const encoder = new TextEncoder();
44
+
45
+ const fieldsIn = (bytes ) => {
46
+ if (bytes === null) return null;
47
+ try {
48
+ const read = JSON.parse(decoder.decode(bytes));
49
+ return isFields(read) ? read : null;
50
+ } catch {
51
+ return null;
52
+ }
53
+ };
54
+
55
+ const textsOf = (fields , names ) => {
56
+ const found = names.map((name) => fields[name]);
57
+ return found.every((one) => typeof one === 'string') ? found.filter((one) => typeof one === 'string') : null;
58
+ };
59
+
60
+ const partsIn = (index ) => {
61
+ const listed = index?.['parts'];
62
+ if (!Array.isArray(listed)) return null;
63
+ const pairs = listed.map((one ) =>
64
+ Array.isArray(one) && one.length === 2 && typeof one[0] === 'string' && typeof one[1] === 'string'
65
+ ? [one[0], one[1]]
66
+ : null,
67
+ );
68
+ return pairs.every((pair) => pair !== null) ? pairs.filter((pair) => pair !== null) : null;
69
+ };
70
+
71
+ const proven = async (own , digest , path ) => {
72
+ const kept = await own.kept.find(digest);
73
+ if (kept !== null) return kept;
74
+ const bytes = await own.get(path);
75
+ if (bytes === null || (await own.sha256(bytes)) !== digest) return null;
76
+ await own.kept.keep(digest, bytes);
77
+ return bytes;
78
+ };
79
+
80
+ export const SAID = '/.well-known/quo';
81
+
82
+ const wornOf = async (own , organism ) => {
83
+ const none = { taken: undefined, warnings: [], digests: [] };
84
+ const named = isFields(organism) ? organism['design'] : undefined;
85
+ if (!isFields(named)) return none;
86
+ const words = textsOf(named, ['name', 'version', 'data', 'look']);
87
+ if (words === null) return none;
88
+ const [name = '', version = '', data = '', look = ''] = words;
89
+ const tint = named['tint'];
90
+ const refused = (why ) => ({
91
+ taken: undefined,
92
+ warnings: [`The design ${name} ${version} of this site is refused: ${why}.`],
93
+ digests: [],
94
+ });
95
+ if (tint !== undefined && typeof tint !== 'string') return refused('its tint is no text');
96
+ const held = fieldsIn(await own.kept.find(data));
97
+ const listed = partsIn(held ?? fieldsIn(await own.get('design.json')));
98
+ if (listed === null) return refused('the site lists no parts for it');
99
+ const sorted = listed.toSorted((one, other) => (one[0] < other[0] ? -1 : 1));
100
+ if (held === null) {
101
+ const listing = encoder.encode(JSON.stringify(sorted));
102
+ if ((await own.sha256(listing)) !== data) return refused('its parts make not the data digest the site names');
103
+ await own.kept.keep(data, encoder.encode(JSON.stringify({ parts: sorted })));
104
+ }
105
+ const files = [];
106
+ for (const [path, sha] of sorted) {
107
+ const bytes = await proven(own, sha, `design/${path}`);
108
+ if (bytes === null) return refused(`the part ${path} is not the one listed`);
109
+ files.push([path, bytes]);
110
+ }
111
+ const source = await proven(own, look, 'design/look.js');
112
+ if (source === null) return refused('its look is not the one the site names');
113
+ return {
114
+ taken: {
115
+ faculty: decoder.decode(source),
116
+ assets: files,
117
+ ...(tint === undefined ? {} : { settings: { tint } }),
118
+ },
119
+ warnings: [],
120
+ digests: [data, look, ...sorted.map(([, sha]) => sha)],
121
+ };
122
+ };
123
+
124
+ export const WINDOW_PATH = 'window/faculty.js';
125
+
126
+ const PRESENT = ['screen', 'brain'] ;
127
+
128
+ const keptWindow = (held ) => {
129
+ const faculty = held?.['faculty'];
130
+ const placeholders = held?.['placeholders'];
131
+ return typeof faculty === 'string' &&
132
+ Array.isArray(placeholders) &&
133
+ placeholders.every((one ) => typeof one === 'string')
134
+ ? { faculty, placeholders: placeholders.filter((one ) => typeof one === 'string') }
135
+ : null;
136
+ };
137
+
138
+ const windowRead = async (
139
+ own ,
140
+ text ,
141
+ read ,
142
+ ) => {
143
+ const bytes = await own.get(WINDOW_PATH);
144
+ if (bytes === null || (await own.sha256(bytes)) !== text) return { why: 'its text is not the one the site names' };
145
+ const faculty = decoder.decode(bytes);
146
+ const reading = await read(faculty);
147
+ if ('why' in reading) return { why: `its text reads not: ${reading.why}` };
148
+ const missing = PRESENT.find((one) => !reading.placeholders.includes(one));
149
+ if (missing !== undefined) return { why: `it names no placeholder for the ${missing}` };
150
+ await own.kept.keep(text, encoder.encode(JSON.stringify({ faculty, placeholders: reading.placeholders })));
151
+ return { faculty, placeholders: reading.placeholders };
152
+ };
153
+
154
+ const windowOf = async (own , organism , read ) => {
155
+ const none = { taken: undefined, warnings: [], digests: [] };
156
+ const named = isFields(organism) ? organism['window'] : undefined;
157
+ if (read === undefined || !isFields(named)) return none;
158
+ const words = textsOf(named, ['name', 'version', 'text']);
159
+ if (words === null) return none;
160
+ const [name = '', version = '', text = ''] = words;
161
+ const checked = keptWindow(fieldsIn(await own.kept.find(text))) ?? (await windowRead(own, text, read));
162
+ if ('why' in checked)
163
+ return { ...none, warnings: [`The window ${name} ${version} of this site is refused: ${checked.why}.`] };
164
+ return { taken: { ...checked, road: `${name}@${version}` }, warnings: [], digests: [text] };
165
+ };
166
+
167
+ export const sizeOf = (named ) =>
168
+ named === 'compact' || named === 'medium' || named === 'expanded' ? named : null;
169
+
170
+ export const dressed = async (own , read ) => {
171
+ const said = fieldsIn(await own.get(SAID));
172
+ const worn = await wornOf(own, said?.['organism']);
173
+ const window = await windowOf(own, said?.['organism'], read);
174
+ const digests = [...worn.digests, ...window.digests];
175
+ if (digests.length > 0) await own.kept.only(digests);
176
+ return {
177
+ design: worn.taken,
178
+ window: window.taken,
179
+ warnings: [...worn.warnings, ...window.warnings],
180
+ size: sizeOf(said?.['size']),
181
+ };
182
+ };
@@ -0,0 +1,29 @@
1
+ import type { DefaultFaculty, Given } from '@nervur.org/genome/seams';
2
+ import type { Distribution } from './distribution.js';
3
+ export type Skin = {
4
+ readonly faculty: string;
5
+ readonly label: string;
6
+ readonly road: string;
7
+ readonly wiring: {
8
+ readonly [placeholder: string]: string;
9
+ };
10
+ readonly given?: {
11
+ readonly [name: string]: Given;
12
+ };
13
+ };
14
+ export type Shipped = {
15
+ readonly name: string;
16
+ readonly blueprint: string;
17
+ readonly faculty: DefaultFaculty;
18
+ readonly digest: string;
19
+ readonly version: string;
20
+ };
21
+ export declare const JAILER = "nervur.repos";
22
+ export declare const ROAD: string;
23
+ export declare const skinsOf: (floor?: Distribution, design?: Given) => {
24
+ readonly console: Skin;
25
+ readonly screen: Skin;
26
+ };
27
+ export declare const WINDOW = "nervur.window";
28
+ export declare const SHIPPED: readonly Shipped[];
29
+ export declare const shippedOf: (floor?: Distribution) => readonly Shipped[];
@@ -0,0 +1,88 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { createHash } from 'node:crypto';
3
+
4
+ import { REPO, REPOS, TERMINAL, WINDOW as WINDOW_SKIN } from '@nervur.org/floor';
5
+
6
+ import { INSTALLER_VERSION } from '../version/index.js';
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ export const JAILER = 'nervur.repos';
26
+
27
+ export const ROAD = `installers@${INSTALLER_VERSION}`;
28
+
29
+ export const skinsOf = (floor , design ) => {
30
+ const screen =
31
+ floor?.parts.WINDOW === undefined ? { ...WINDOW_SKIN, road: ROAD } : skinOf(floor.parts.WINDOW, floor.road);
32
+ return {
33
+ console:
34
+ floor?.parts.TERMINAL === undefined ? { ...TERMINAL, road: ROAD } : skinOf(floor.parts.TERMINAL, floor.road),
35
+ screen: design === undefined ? screen : { ...screen, given: { ...screen.given, design } },
36
+ };
37
+ };
38
+
39
+ const skinOf = ({ faculty, label, wiring } , road ) => ({ faculty, label, road, wiring });
40
+
41
+ const digestOf = (source ) => createHash('sha256').update(source).digest('hex');
42
+
43
+ const versionOf = (name , source ) =>
44
+ new RegExp(
45
+ `name: ['"]${name.replaceAll('.', '\\.')}['"],(?:\\s*//[^\\n]*)*\\s*version: ['"](\\d+\\.\\d+\\.\\d+)['"]`,
46
+ ).exec(source)?.[1] ?? '';
47
+
48
+ const shipped = (
49
+ name ,
50
+ { faculty: source, label } ,
51
+ ) => ({
52
+ name,
53
+ blueprint: name,
54
+ faculty: { source, road: ROAD, label },
55
+ digest: digestOf(source),
56
+ version: versionOf(name, source),
57
+ });
58
+
59
+ const taken = (name , part , road ) => ({
60
+ name,
61
+ blueprint: part.name,
62
+ faculty: { source: part.faculty, road, label: part.label },
63
+ digest: digestOf(part.faculty),
64
+ version: part.version,
65
+ });
66
+
67
+ export const WINDOW = 'nervur.window';
68
+
69
+ export const SHIPPED = [
70
+ shipped('nervur.terminal', TERMINAL),
71
+ shipped(WINDOW, WINDOW_SKIN),
72
+ shipped(JAILER, REPOS),
73
+ shipped('nervur.repo', REPO),
74
+ ];
75
+
76
+ const PARTS = new Map ([
77
+ ['nervur.terminal', 'TERMINAL'],
78
+ [WINDOW, 'WINDOW'],
79
+ [JAILER, 'REPOS'],
80
+ ['nervur.repo', 'REPO'],
81
+ ]);
82
+
83
+ export const shippedOf = (floor ) =>
84
+ SHIPPED.map((one) => {
85
+ const named = PARTS.get(one.name);
86
+ const part = named === undefined ? undefined : floor?.parts[named];
87
+ return part === undefined || floor === undefined ? one : taken(one.name, part, floor.road);
88
+ });
@@ -0,0 +1,6 @@
1
+ export declare const LONGEST_TIMEOUT = 10000;
2
+ export declare const LONGEST_WAIT: number;
3
+ export declare const BEAT: number;
4
+ export declare const FRAME_WORD = "NERVUR_FRAME";
5
+ export declare const FRAME_SIZE: number;
6
+ export declare const ringPast: (ms: number, ring: () => void) => (() => void);
@@ -0,0 +1,25 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { frameSizeOf } from '@nervur.org/genome';
3
+ import { LOBE_MEMORY } from '@nervur.org/genome/seams';
4
+
5
+ export const LONGEST_TIMEOUT = 10_000;
6
+
7
+ export const LONGEST_WAIT = LONGEST_TIMEOUT * 1.5;
8
+
9
+ export const BEAT = LONGEST_TIMEOUT / 2;
10
+
11
+ export const FRAME_WORD = 'NERVUR_FRAME';
12
+
13
+ export const FRAME_SIZE = Number(globalThis.process?.env[FRAME_WORD] ?? frameSizeOf(LOBE_MEMORY));
14
+
15
+ export const ringPast = (ms , ring ) => {
16
+ const from = performance.now();
17
+ let timer ;
18
+ const check = () => {
19
+ const left = ms - (performance.now() - from);
20
+ if (left <= 0) ring();
21
+ else timer = setTimeout(check, Math.ceil(left));
22
+ };
23
+ timer = setTimeout(check, Math.ceil(ms));
24
+ return () => clearTimeout(timer);
25
+ };
@@ -0,0 +1,3 @@
1
+ export declare const othersIn: (listed: string, file: string, own: string) => readonly string[];
2
+ export declare const accountOnlyLaid: (path: string) => void;
3
+ export declare const readByAnother: (file: string) => boolean;
@@ -0,0 +1,24 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { execFileSync } from 'node:child_process';
3
+
4
+ const MACHINE = ['nt authority\\system', 'builtin\\administrators'];
5
+
6
+ export const othersIn = (listed , file , own ) =>
7
+ listed
8
+ .replace(file, '')
9
+ .split(/\r?\n/u)
10
+ .flatMap((line) => /^\s*(.+?):\(/u.exec(line)?.[1] ?? [])
11
+ .filter((who) => ![own.toLowerCase(), ...MACHINE].includes(who.toLowerCase()));
12
+
13
+ export const accountOnlyLaid = (path ) => {
14
+ execFileSync('icacls', [path, '/inheritance:r', '/grant:r', `${process.env['USERNAME'] ?? ''}:(OI)(CI)F`], {
15
+ stdio: 'ignore',
16
+ });
17
+ };
18
+
19
+ export const readByAnother = (file ) =>
20
+ othersIn(
21
+ execFileSync('icacls', [file], { encoding: 'utf8' }),
22
+ file,
23
+ `${process.env['COMPUTERNAME'] ?? ''}\\${process.env['USERNAME'] ?? ''}`,
24
+ ).length > 0;
@@ -0,0 +1,21 @@
1
+ import type { UnlockerSeam } from '@nervur.org/genome/seams';
2
+ import { keyFileOf, nextKeyOf } from './boot-move.js';
3
+ export declare const bootKeyFileOf: typeof keyFileOf;
4
+ export declare const drawnBootKey: () => Uint8Array;
5
+ export declare const layBootKey: (home: string) => {
6
+ readonly key: Uint8Array;
7
+ } | {
8
+ readonly why: string;
9
+ };
10
+ export declare const readBootKey: (home: string, file?: string) => {
11
+ readonly key: Uint8Array;
12
+ } | {
13
+ readonly why: string;
14
+ };
15
+ export declare const fileUnlocker: (home: string, refused: (why: string) => void) => UnlockerSeam;
16
+ export declare const nextBootKeyFileOf: typeof nextKeyOf;
17
+ export declare const readNextBootKey: (home: string) => {
18
+ readonly key: Uint8Array;
19
+ } | {
20
+ readonly why: string;
21
+ } | null;
@@ -0,0 +1,70 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { randomBytes } from 'node:crypto';
3
+ import { existsSync, lstatSync, readFileSync } from 'node:fs';
4
+
5
+ import { hex, unhex } from '@nervur.org/genome/standard';
6
+ import { keyFileOf, movedBoot, nextKeyOf, nodeFiles } from './boot-move.js';
7
+ import { readByAnother } from './account-only.js';
8
+ import { laidWhole } from './flushed.js';
9
+
10
+ const KEY = 32;
11
+
12
+ const READ_BY_ANOTHER = 0o044;
13
+
14
+ export const bootKeyFileOf = keyFileOf;
15
+
16
+ export const drawnBootKey = () => new Uint8Array(randomBytes(KEY));
17
+
18
+ export const layBootKey = (home ) => {
19
+ const key = new Uint8Array(randomBytes(KEY));
20
+ if (existsSync(bootKeyFileOf(home))) return { why: `a boot key cannot be laid at ${bootKeyFileOf(home)}` };
21
+ try {
22
+ laidWhole(bootKeyFileOf(home), `${hex(key)}\n`, 0o600);
23
+ } catch {
24
+ return { why: `a boot key cannot be laid at ${bootKeyFileOf(home)}` };
25
+ }
26
+ return { key };
27
+ };
28
+
29
+ export const readBootKey = (
30
+ home ,
31
+ file = bootKeyFileOf(home),
32
+ ) => {
33
+ let stat;
34
+ try {
35
+ stat = lstatSync(file);
36
+ } catch {
37
+ return { why: `no boot key stands at ${file}` };
38
+ }
39
+ if (!stat.isFile()) return { why: `${file} is not a file of its own` };
40
+ const windows = process.platform === 'win32';
41
+ if (windows ? readByAnother(file) : stat.uid !== process.getuid?.() || (stat.mode & READ_BY_ANOTHER) !== 0)
42
+ return {
43
+ why: `another account can read ${file}, so the organism does not boot; make it this account's alone${windows ? '' : ', as chmod 600 does'}`,
44
+ };
45
+ const text = readFileSync(file, 'utf8').trim();
46
+ const key = text.length === KEY * 2 ? unhex(text) : null;
47
+ if (key === null || 'why' in key) return { why: `${file} holds no boot key` };
48
+ return { key: key.bytes };
49
+ };
50
+
51
+ export const fileUnlocker = (home , refused ) => ({
52
+ open: () => {
53
+ const read = readBootKey(home);
54
+ if ('key' in read) return Promise.resolve({ key: read.key });
55
+ refused(read.why);
56
+ return Promise.resolve(null);
57
+ },
58
+ admit: () => Promise.resolve(null),
59
+ rewrap: async (next, change) => {
60
+ if (nodeFiles.stands(nextKeyOf(home))) return { why: `a new boot key stands at ${nextKeyOf(home)} already` };
61
+ return movedBoot(nodeFiles, home, { key: next, mode: 'file' }, change);
62
+ },
63
+ });
64
+
65
+ export const nextBootKeyFileOf = nextKeyOf;
66
+
67
+ export const readNextBootKey = (home ) => {
68
+ if (!existsSync(nextBootKeyFileOf(home))) return null;
69
+ return readBootKey(home, nextBootKeyFileOf(home));
70
+ };
@@ -0,0 +1,25 @@
1
+ type Why = {
2
+ readonly why: string;
3
+ };
4
+ export type Files = {
5
+ lay(path: string, text: string): void;
6
+ rename(from: string, to: string): void;
7
+ remove(path: string): void;
8
+ stands(path: string): boolean;
9
+ };
10
+ export declare const nodeFiles: Files;
11
+ export declare const folderFileOf: (home: string) => string;
12
+ export declare const nextFolderOf: (home: string) => string;
13
+ export declare const keyFileOf: (home: string) => string;
14
+ export declare const nextKeyOf: (home: string) => string;
15
+ export declare const keyText: (key: Uint8Array) => string;
16
+ export declare const letGo: (files: Files, home: string) => void;
17
+ export declare const settled: (files: Files, home: string, mode: 'file' | 'present') => void;
18
+ export declare const movedBoot: (files: Files, home: string, moving: {
19
+ readonly key: Uint8Array;
20
+ readonly folder?: string;
21
+ readonly mode: 'file' | 'present';
22
+ readonly keep?: (key: Uint8Array) => Promise<null | Why>;
23
+ }, change: () => Promise<null | Why>) => Promise<null | Why>;
24
+ export declare const openedBeside: <Opened extends object>(files: Files, home: string, next: Uint8Array | null, mode: 'file' | 'present', open: (key: Uint8Array) => Promise<Opened | Why>, plain: () => Promise<Opened | Why>, keep?: (key: Uint8Array) => Promise<null | Why>) => Promise<Opened | Why>;
25
+ export {};
@@ -0,0 +1,86 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { existsSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { hex } from '@nervur.org/genome/standard';
5
+ import { laidWhole, movedWhole, removedWhole } from './flushed.js';
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ export const nodeFiles = {
17
+ lay: (path, text) => laidWhole(path, text, 0o600),
18
+ rename: movedWhole,
19
+ remove: removedWhole,
20
+ stands: existsSync,
21
+ };
22
+
23
+ export const folderFileOf = (home ) => join(home, 'organism.json');
24
+ export const nextFolderOf = (home ) => join(home, 'organism.json.next');
25
+ export const keyFileOf = (home ) => join(home, 'boot.key');
26
+ export const nextKeyOf = (home ) => join(home, 'boot.key.next');
27
+
28
+ export const keyText = (key ) => `${hex(key)}\n`;
29
+
30
+ export const letGo = (files , home ) => {
31
+ files.remove(nextKeyOf(home));
32
+ files.remove(nextFolderOf(home));
33
+ };
34
+
35
+ export const settled = (files , home , mode ) => {
36
+ if (files.stands(nextFolderOf(home))) files.rename(nextFolderOf(home), folderFileOf(home));
37
+ if (mode === 'file') return files.rename(nextKeyOf(home), keyFileOf(home));
38
+ files.remove(keyFileOf(home));
39
+ files.remove(nextKeyOf(home));
40
+ };
41
+
42
+ export const movedBoot = async (
43
+ files ,
44
+ home ,
45
+ moving
46
+
47
+
48
+
49
+
50
+
51
+ ,
52
+ change ,
53
+ ) => {
54
+ if (moving.folder !== undefined) files.lay(nextFolderOf(home), moving.folder);
55
+ files.lay(nextKeyOf(home), keyText(moving.key));
56
+ const changed = await change();
57
+ if (changed !== null) {
58
+ letGo(files, home);
59
+ return changed;
60
+ }
61
+ const kept = moving.keep === undefined ? null : await moving.keep(moving.key);
62
+ if (kept !== null) return kept;
63
+ settled(files, home, moving.mode);
64
+ return null;
65
+ };
66
+
67
+ export const openedBeside = async (
68
+ files ,
69
+ home ,
70
+ next ,
71
+ mode ,
72
+ open ,
73
+ plain ,
74
+ keep ,
75
+ ) => {
76
+ const tried = next === null ? null : await open(next);
77
+ if (tried !== null && !('why' in tried)) {
78
+ const kept = next === null || keep === undefined ? null : await keep(next);
79
+ if (kept !== null) return kept;
80
+ settled(files, home, mode);
81
+ return tried;
82
+ }
83
+ if (tried !== null && !/wrong key/u.test(tried.why)) return tried;
84
+ if (tried !== null || !files.stands(nextKeyOf(home))) letGo(files, home);
85
+ return plain();
86
+ };
@@ -0,0 +1,13 @@
1
+ import type { BridgeTransportSeam, HostHalf } from '@nervur.org/genome/seams';
2
+ export type Program = {
3
+ readonly command: string;
4
+ readonly args: readonly string[];
5
+ };
6
+ export type Programs = (organ: string, half: HostHalf) => Program | {
7
+ readonly why: string;
8
+ };
9
+ export declare const nodeBridge: (programs: Programs) => BridgeTransportSeam;
10
+ export declare const keptBridge: (inner: BridgeTransportSeam, within?: number) => {
11
+ readonly bridge: BridgeTransportSeam;
12
+ readonly close: () => Promise<void>;
13
+ };
@@ -0,0 +1,86 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { spawn } from 'node:child_process';
3
+
4
+ import { FRAME_WORD, LONGEST_TIMEOUT } from '../door/longest.js';
5
+
6
+ const ENDS = LONGEST_TIMEOUT;
7
+
8
+
9
+
10
+
11
+
12
+ const streamOf = (program , frame ) => {
13
+ const env = frame === undefined ? process.env : { ...process.env, [FRAME_WORD]: String(frame) };
14
+ const child = spawn(program.command, [...program.args], { stdio: ['pipe', 'pipe', 'inherit'], env });
15
+ const told = [];
16
+ let over = false;
17
+ const end = () => {
18
+ if (over) return;
19
+ over = true;
20
+ for (const done of told) done();
21
+ };
22
+ child.on('close', end);
23
+ child.on('error', end);
24
+ child.stdin.on('error', () => undefined);
25
+ return {
26
+ write: (bytes) => {
27
+ if (!over) child.stdin.write(bytes);
28
+ },
29
+ read: (chunk) => {
30
+ child.stdout.removeAllListeners('data');
31
+ child.stdout.on('data', (bytes ) => chunk(new Uint8Array(bytes)));
32
+ },
33
+ closed: (done) => {
34
+ told.push(done);
35
+ },
36
+ close: () => {
37
+ child.stdin.end();
38
+ child.kill();
39
+ },
40
+ };
41
+ };
42
+
43
+ export const nodeBridge = (programs ) => ({
44
+ start: (organ, half) => {
45
+ const program = programs(organ, half);
46
+ return 'why' in program ? program : { stream: streamOf(program, half.frame) };
47
+ },
48
+ });
49
+
50
+ export const keptBridge = (
51
+ inner ,
52
+ within = ENDS,
53
+ ) => {
54
+ const running = new Set ();
55
+ let closed = false;
56
+ return {
57
+ bridge: {
58
+ start: (organ, half) => {
59
+ if (closed) return { why: 'the organism has stopped, so no half starts' };
60
+ const started = inner.start(organ, half);
61
+ if ('stream' in started) {
62
+ const { stream } = started;
63
+ running.add(stream);
64
+ stream.closed(() => running.delete(stream));
65
+ }
66
+ return started;
67
+ },
68
+ },
69
+ close: async () => {
70
+ closed = true;
71
+ const ending = [...running].map(
72
+ (stream) =>
73
+ new Promise ((done) => {
74
+ stream.closed(done);
75
+ stream.close();
76
+ }),
77
+ );
78
+ let timer ;
79
+ const waited = new Promise ((done) => {
80
+ timer = setTimeout(done, within);
81
+ });
82
+ await Promise.race([Promise.all(ending), waited]);
83
+ clearTimeout(timer);
84
+ },
85
+ };
86
+ };
@@ -0,0 +1,2 @@
1
+ import type { ChanceSeam } from '@nervur.org/genome/seams';
2
+ export declare const nodeChance: () => ChanceSeam;