clavarium 0.2.526-next.1 → 0.2.527-next.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/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/server/api.mjs +1 -1
- package/server/bridge.mjs +4 -1
- package/server/dataformat.mjs +4 -2
- package/server/door.mjs +3 -1
- package/server/main.mjs +4 -3
- package/server/operators.mjs +3 -0
- package/server/people.mjs +63 -46
- package/server/settingswords.mjs +1 -1
- package/server/sshconsole.mjs +10 -2
- package/web/app.js +16 -9
- package/web/index.html +2 -2
- package/web/style.css +14 -14
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.527-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.527-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.527-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
24
|
"clavarium": {
|
|
25
|
-
"dataFormat":
|
|
25
|
+
"dataFormat": 2
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"start": "node server/main.mjs",
|
package/server/api.mjs
CHANGED
|
@@ -795,8 +795,8 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
795
795
|
if (pathname === '/api/operators' && team) {
|
|
796
796
|
/* Its role said at once (#419): an account removed and added again does not come back as it was. */
|
|
797
797
|
const role = body.role === 'member' ? 'member' : body.role === 'admin' ? 'admin' : (team.people?.defaultRole?.() ?? 'admin');
|
|
798
|
+
team.people?.adding(String(body.email ?? '').trim().toLowerCase(), role);
|
|
798
799
|
const made = await team.add(body.email);
|
|
799
|
-
team.people?.added(made.email, role);
|
|
800
800
|
return send(201, { ...made, role: team.people?.roleOf(made.email) ?? 'admin' }), true;
|
|
801
801
|
}
|
|
802
802
|
/* An account made an administrator or a member (#419): never oneself, never the last administrator. */
|
package/server/bridge.mjs
CHANGED
|
@@ -100,6 +100,8 @@ export function attachBridge(server, { spawn, onLeft = () => {}, onEnded = () =>
|
|
|
100
100
|
back used to end only at the next connection -- an open terminal went on (found 19-10). */
|
|
101
101
|
const deviceSeats = new Map(); /* viewer -> () => still allowed */
|
|
102
102
|
const revoked = new WeakSet();
|
|
103
|
+
/* Who a screen is, for What happened: a paired device, a member (#419), else the page of an administrator. */
|
|
104
|
+
const fromDevice = new WeakSet(); const fromMember = new WeakSet();
|
|
103
105
|
const allowed = (viewer) => {
|
|
104
106
|
if (revoked.has(viewer)) return false;
|
|
105
107
|
const still = deviceSeats.get(viewer);
|
|
@@ -141,6 +143,7 @@ export function attachBridge(server, { spawn, onLeft = () => {}, onEnded = () =>
|
|
|
141
143
|
const resume = url.searchParams.get('resume') === '1';
|
|
142
144
|
sockets.handleUpgrade(request, socket, head, (viewer) => {
|
|
143
145
|
if (still) { deviceSeats.set(viewer, still); viewer.on('close', () => deviceSeats.delete(viewer)); }
|
|
146
|
+
if (url.pathname === DEVICE_PATH) fromDevice.add(viewer); else if (url.pathname === MEMBER_PATH) fromMember.add(viewer);
|
|
144
147
|
seat(viewer, name, within(cols, COLS) ? cols : 80, within(rows, ROWS) ? rows : 24, resume);
|
|
145
148
|
});
|
|
146
149
|
});
|
|
@@ -197,7 +200,7 @@ export function attachBridge(server, { spawn, onLeft = () => {}, onEnded = () =>
|
|
|
197
200
|
}
|
|
198
201
|
async function openNow(name, cols, rows, sink, say) {
|
|
199
202
|
/* Who opens it, for What happened when it wakes a sleeper: a screen, or this server (warm). */
|
|
200
|
-
const who = sink ? (
|
|
203
|
+
const who = sink ? (fromDevice.has(sink) ? 'a paired device' : fromMember.has(sink) ? 'a member' : 'a page') : undefined;
|
|
201
204
|
const terminal = await spawn(name, cols, rows, say, who);
|
|
202
205
|
/* While it was being opened another one may have been: the newest wins. */
|
|
203
206
|
if (live.has(name)) close(name);
|
package/server/dataformat.mjs
CHANGED
|
@@ -22,8 +22,10 @@ import { join } from 'node:path';
|
|
|
22
22
|
export const DATA_FORMAT = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).clavarium?.dataFormat ?? 1;
|
|
23
23
|
export const FORMAT_FILE = 'data-format.json';
|
|
24
24
|
|
|
25
|
-
/*
|
|
26
|
-
|
|
25
|
+
/* 1 -> 2 (24-11, #419): nothing to change in the files. Its number is what matters: a release from before accounts
|
|
26
|
+
and rights reads format 1 only, and would take every member for an administrator (it does not know people.json);
|
|
27
|
+
the updater refuses to go back to it, by hand or by itself, and that release refuses to start on this data. */
|
|
28
|
+
export const MIGRATIONS = { 1: () => {} };
|
|
27
29
|
|
|
28
30
|
export function dataFormat(dataDir) {
|
|
29
31
|
try { return JSON.parse(readFileSync(join(dataDir, FORMAT_FILE), 'utf8')).format; } catch { return undefined; }
|
package/server/door.mjs
CHANGED
|
@@ -195,7 +195,9 @@ export async function handleDoor(request, response, { devices, conversations, re
|
|
|
195
195
|
if (request.headers['content-type'] !== 'application/octet-stream') return send(400, { error: 'An attachment is a file.' });
|
|
196
196
|
return send(201, await talk.attach(name, url.searchParams.get('name') ?? '', request));
|
|
197
197
|
}
|
|
198
|
-
if (request.method === 'POST' && talking[1] === undefined) { const body = await readJson(request); if (part.terminal && signinCode && conversations.signinHelp?.codeInChat(name, body.text, body.files)) return send(201, { ...(await signinCode(name, body.text)), told: 'signin' });
|
|
198
|
+
if (request.method === 'POST' && talking[1] === undefined) { const body = await readJson(request); if (part.terminal && signinCode && conversations.signinHelp?.codeInChat(name, body.text, body.files)) return send(201, { ...(await signinCode(name, body.text)), told: 'signin' }); /* A member's words (#419): said as theirs, so that the tool never takes them for its owner's. */
|
|
199
|
+
const text = person && typeof body.text === 'string' && body.text.trim() ? `[${person.email}, a member] ${body.text}` : body.text;
|
|
200
|
+
return send(201, await talk.say(name, text, body.answers, body.files, body.via, { quick: body.quick === true })); }
|
|
199
201
|
}
|
|
200
202
|
/* A sign-in code (#405): a device given its terminal could type it there; no other. Named twice, never guessed. */
|
|
201
203
|
const codeFor = /^\/conversations\/([^/]+)\/signin-code$/.exec(route);
|
package/server/main.mjs
CHANGED
|
@@ -353,9 +353,9 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
353
353
|
/* WHO IS WHAT (people.mjs, #419): the gate of everything there was admits ADMINISTRATORS only -- pages, API,
|
|
354
354
|
terminals, the SSH console, all of it -- so a member is refused there by default; members come in through
|
|
355
355
|
their own door alone (/m/, memberGate). With no member, everybody who may sign in passes, as before. */
|
|
356
|
-
const people = team ? new People({ path: `${dataDir}/people.json`, accounts: () => team.list(), tell: (title, body) => { try { void alerts?.tell?.({ title, body, url: '/?open=settings&at=operators' })?.catch?.(() => {}); } catch { /* said in the log */ } console.error(`people: ${title}: ${body}`); } }) : null;
|
|
356
|
+
const people = team ? new People({ path: `${dataDir}/people.json`, install: operators, accounts: () => team.list(), tell: (title, body) => { try { void alerts?.tell?.({ title, body, url: '/?open=settings&at=operators' })?.catch?.(() => {}); } catch { /* said in the log */ } console.error(`people: ${title}: ${body}`); } }) : null;
|
|
357
357
|
team?.useLastAdmin((email) => people.roleOf(email) === 'admin' && people.isLastAdmin(email));
|
|
358
|
-
if (team) team.people = people;
|
|
358
|
+
if (team) { team.people = people; team.onChanged = () => people.changed(); }
|
|
359
359
|
const gate = makeGate(team ? () => team.allowed().filter((e) => people.roleOf(e) === 'admin') : []);
|
|
360
360
|
const memberGate = team ? makeGate(() => team.allowed().filter((e) => people.roleOf(e) === 'member')) : () => undefined;
|
|
361
361
|
const originOk = makeOriginCheck(publicOrigin);
|
|
@@ -380,7 +380,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
380
380
|
const grants = new Grants(new Store(`${dataDir}/grants.json`));
|
|
381
381
|
if (team) team.grants = grants;
|
|
382
382
|
/* A MEMBER, as the door sees it (door.mjs, #419): what the table gives `person:<email>`, conversations only. */
|
|
383
|
-
const personOf = team ? (
|
|
383
|
+
const personOf = team ? (given) => {
|
|
384
|
+
const email = String(given).trim().toLowerCase();
|
|
384
385
|
const subject = `person:${email}`;
|
|
385
386
|
const mine = () => grants.of(subject, 'conversation').map((g) => g.name).filter((n) => all.list().some((c) => c.name === n));
|
|
386
387
|
return {
|
package/server/operators.mjs
CHANGED
|
@@ -46,7 +46,10 @@ export class Operators {
|
|
|
46
46
|
const r = await this.#host(['operator', 'list']);
|
|
47
47
|
if (r.code !== 0) throw new Refusal(502, `Who may sign in could not be read: ${firstLine(r.stderr) || `exit ${r.code}`}`);
|
|
48
48
|
const read = String(r.stdout).split('\n').map((l) => l.split('\t')).filter(([e, s]) => EMAIL.test(e ?? '') && ['enabled', 'disabled'].includes(s));
|
|
49
|
+
const before = JSON.stringify(this.#list);
|
|
49
50
|
if (read.length) this.#list = read.map(([email, state]) => ({ email, enabled: state === 'enabled' }));
|
|
51
|
+
/* Changed outside the page (the host program): whoever lost their place loses their terminals at once (#419). */
|
|
52
|
+
if (JSON.stringify(this.#list) !== before) { try { this.onChanged?.(); } catch { /* the minute's recheck sees it */ } }
|
|
50
53
|
return this.list();
|
|
51
54
|
}
|
|
52
55
|
async #do(argv, input) {
|
package/server/people.mjs
CHANGED
|
@@ -1,104 +1,121 @@
|
|
|
1
1
|
/* WHO IS AN ADMINISTRATOR, WHO A MEMBER (24-11, #419).
|
|
2
2
|
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* BEFORE ANY MEMBER (no file): every account that may sign in (operators.mjs) is an ADMINISTRATOR, as every account
|
|
4
|
+
* was before this file existed -- an update changes nothing for the accounts already there.
|
|
5
|
+
*
|
|
6
|
+
* THE FIRST MEMBER writes the file, and from then on BOTH lists are written out: the administrators by name (every
|
|
7
|
+
* account there was then, but the new member) and the members. An account in neither -- added outside the page,
|
|
8
|
+
* or between two steps -- is a MEMBER: nothing is ever given by default (audit 24-11).
|
|
8
9
|
*
|
|
9
10
|
* Two rules on top, never broken:
|
|
10
|
-
* - ONE ACCOUNT, AN ADMINISTRATOR: when only one account exists (enabled or not: a member must never become
|
|
11
|
-
*
|
|
11
|
+
* - ONE ACCOUNT, AN ADMINISTRATOR: when only one account exists (enabled or not: a member must never become the
|
|
12
|
+
* only one by having the others locked out), it is an administrator, whatever was written;
|
|
12
13
|
* - THE LAST ADMINISTRATOR stays one: it cannot be made a member (nor, in operators.mjs, disabled, removed or
|
|
13
14
|
* locked out after failed sign-ins).
|
|
14
15
|
*
|
|
15
|
-
* KEPT where nothing half-written is ever read: written to a new file renamed over the old one, the good one
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* KEPT where nothing half-written is ever read: written to a new file renamed over the old one, the good one before
|
|
17
|
+
* it kept as `.bak`. Both unreadable: the lists last read stay in use; at a start with none, the accounts the
|
|
18
|
+
* server was installed with (`install`, its --operators) are the administrators and every other one a member --
|
|
19
|
+
* never everybody locked out, never a member made an administrator. It is said, loudly.
|
|
18
20
|
*/
|
|
19
21
|
import { readFileSync, writeFileSync, renameSync, existsSync, copyFileSync, mkdirSync } from 'node:fs';
|
|
20
22
|
import { dirname } from 'node:path';
|
|
21
23
|
import { Refusal } from './conversations.mjs';
|
|
22
24
|
|
|
23
25
|
export const ROLES = Object.freeze(['admin', 'member']);
|
|
26
|
+
const low = (e) => String(e ?? '').trim().toLowerCase();
|
|
24
27
|
|
|
25
28
|
export class People {
|
|
26
|
-
#path; #
|
|
27
|
-
/*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.#path = path; this.#accounts = accounts; this.#tell = tell;
|
|
29
|
+
#path; #lists = null; #damaged = false; #accounts; #tell; #install; #changed = () => {};
|
|
30
|
+
/* `accounts()`: every account there is, enabled or not ([{ email, enabled }], operators.mjs).
|
|
31
|
+
`install`: the accounts the server was started with (--operators), the administrators of last resort. */
|
|
32
|
+
constructor({ path, accounts = () => [], tell = () => {}, install = [] }) {
|
|
33
|
+
this.#path = path; this.#accounts = accounts; this.#tell = tell; this.#install = install.map(low);
|
|
32
34
|
mkdirSync(dirname(path), { recursive: true });
|
|
33
35
|
this.#load();
|
|
34
36
|
}
|
|
37
|
+
/* Told when a role changes: the terminals of whoever lost something end at once (bridge.recheck). */
|
|
38
|
+
useChanged(fn) { this.#changed = fn; }
|
|
39
|
+
changed() { try { this.#changed(); } catch { /* the minute's recheck sees it */ } }
|
|
35
40
|
|
|
36
41
|
#read(file) {
|
|
37
42
|
const data = JSON.parse(readFileSync(file, 'utf8'));
|
|
38
|
-
if (!data ||
|
|
39
|
-
return
|
|
43
|
+
if (!data || !Array.isArray(data.admins) || !Array.isArray(data.members)) throw new Error('not a roles file');
|
|
44
|
+
return { admins: [...new Set(data.admins.map(low))], members: [...new Set(data.members.map(low))] };
|
|
40
45
|
}
|
|
41
46
|
#load() {
|
|
42
|
-
if (!existsSync(this.#path) && !existsSync(`${this.#path}.bak`)) { this.#
|
|
47
|
+
if (!existsSync(this.#path) && !existsSync(`${this.#path}.bak`)) { this.#lists = null; return; }
|
|
43
48
|
for (const file of [this.#path, `${this.#path}.bak`]) {
|
|
44
|
-
try { this.#
|
|
49
|
+
try { this.#lists = this.#read(file); this.#damaged = false; return; } catch { /* the next one */ }
|
|
45
50
|
}
|
|
46
|
-
this.#damaged = true;
|
|
47
|
-
this.#tell('The file of who is an administrator cannot be read', `${this.#path}: until it is repaired,
|
|
51
|
+
this.#damaged = true;
|
|
52
|
+
this.#tell('The file of who is an administrator cannot be read', `${this.#path}: until it is repaired, the accounts this server was installed with are its administrators, every other one a member.`);
|
|
48
53
|
}
|
|
49
54
|
#save() {
|
|
50
55
|
const tmp = `${this.#path}.new`;
|
|
51
|
-
writeFileSync(tmp, `${JSON.stringify(
|
|
56
|
+
writeFileSync(tmp, `${JSON.stringify(this.#lists, null, 1)}\n`, { mode: 0o600 });
|
|
52
57
|
if (existsSync(this.#path)) { try { this.#read(this.#path); copyFileSync(this.#path, `${this.#path}.bak`); } catch { /* the old one was bad: no copy of it */ } }
|
|
53
58
|
renameSync(tmp, this.#path);
|
|
59
|
+
this.#damaged = false;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
|
-
#all() { return (this.#accounts() ?? []).map((a) => ({ email:
|
|
62
|
+
#all() { return (this.#accounts() ?? []).map((a) => ({ email: low(a.email), enabled: a.enabled !== false })); }
|
|
63
|
+
/* Whether there are members at all (a file written). */
|
|
64
|
+
hasMembers() { return this.#lists !== null && this.#lists.members.length > 0; }
|
|
57
65
|
|
|
58
66
|
/* 'admin' or 'member'. */
|
|
59
67
|
roleOf(email) {
|
|
60
|
-
const e =
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
if (this.#
|
|
64
|
-
return this.#
|
|
68
|
+
const e = low(email);
|
|
69
|
+
if (this.#all().length <= 1) return 'admin';
|
|
70
|
+
if (this.#damaged && this.#lists === null) return this.#install.includes(e) ? 'admin' : 'member';
|
|
71
|
+
if (this.#lists === null) return 'admin';
|
|
72
|
+
return this.#lists.admins.includes(e) && !this.#lists.members.includes(e) ? 'admin' : 'member';
|
|
65
73
|
}
|
|
66
74
|
damaged() { return this.#damaged; }
|
|
67
75
|
/* The enabled administrators. */
|
|
68
76
|
admins() { return this.#all().filter((a) => a.enabled && this.roleOf(a.email) === 'admin').map((a) => a.email); }
|
|
69
77
|
/* Whether taking `email` out of the administrators (made a member, disabled, removed, locked out) leaves none. */
|
|
70
78
|
isLastAdmin(email) {
|
|
71
|
-
const e =
|
|
79
|
+
const e = low(email);
|
|
72
80
|
const admins = this.admins();
|
|
73
81
|
return admins.length <= 1 && (admins.length === 0 || admins[0] === e);
|
|
74
82
|
}
|
|
75
83
|
|
|
84
|
+
/* The lists written out at the first member: every account there is now an administrator, as it was. */
|
|
85
|
+
#seed() { if (this.#lists === null) this.#lists = { admins: this.#all().map((a) => a.email), members: [] }; }
|
|
86
|
+
#put(e, role) {
|
|
87
|
+
this.#lists.admins = this.#lists.admins.filter((x) => x !== e);
|
|
88
|
+
this.#lists.members = this.#lists.members.filter((x) => x !== e);
|
|
89
|
+
(role === 'admin' ? this.#lists.admins : this.#lists.members).push(e);
|
|
90
|
+
}
|
|
91
|
+
|
|
76
92
|
setRole(email, role) {
|
|
77
|
-
const e =
|
|
93
|
+
const e = low(email);
|
|
78
94
|
if (!ROLES.includes(role)) throw new Refusal(400, 'A role is admin or member.');
|
|
79
95
|
if (!this.#all().some((a) => a.email === e)) throw new Refusal(404, 'No such account.');
|
|
80
96
|
if (this.#damaged) throw new Refusal(503, 'The file of who is an administrator cannot be read: repair it first.');
|
|
81
|
-
if (role ===
|
|
82
|
-
if (role === '
|
|
83
|
-
this.#save();
|
|
84
|
-
|
|
97
|
+
if (role === this.roleOf(e)) return this.list();
|
|
98
|
+
if (role === 'member' && this.isLastAdmin(e)) throw new Refusal(409, 'The last administrator cannot be made a member.');
|
|
99
|
+
this.#seed(); this.#put(e, role); this.#save();
|
|
100
|
+
this.changed();
|
|
85
101
|
return this.list();
|
|
86
102
|
}
|
|
87
|
-
/* An account added
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (role
|
|
92
|
-
if (
|
|
103
|
+
/* An account ABOUT TO BE added, its role said first: never an administrator for a moment by mistake, and an
|
|
104
|
+
account removed then added again does not come back as it was. */
|
|
105
|
+
adding(email, role) {
|
|
106
|
+
const e = low(email);
|
|
107
|
+
if (!ROLES.includes(role) || this.#damaged) return;
|
|
108
|
+
if (this.#lists === null && role === 'admin') return;
|
|
109
|
+
this.#seed(); this.#put(e, role); this.#save();
|
|
93
110
|
}
|
|
94
111
|
/* An account removed: its role forgotten with it. */
|
|
95
112
|
removed(email) {
|
|
96
|
-
const e =
|
|
97
|
-
if (
|
|
98
|
-
|
|
113
|
+
const e = low(email);
|
|
114
|
+
if (this.#lists === null || this.#damaged) return;
|
|
115
|
+
this.#lists.admins = this.#lists.admins.filter((x) => x !== e);
|
|
116
|
+
this.#lists.members = this.#lists.members.filter((x) => x !== e);
|
|
117
|
+
this.#save();
|
|
99
118
|
}
|
|
100
|
-
/* Said to whoever waits on a change (a right taken: its terminal ends). */
|
|
101
|
-
changed() { try { this.#changed(); } catch { /* the minute's recheck sees it */ } }
|
|
102
119
|
/* The role a new account gets when none is said: a member (24-11, its owner's choice); an administrator is ticked. */
|
|
103
120
|
defaultRole() { return 'member'; }
|
|
104
121
|
list() { return this.#all().map((a) => ({ ...a, role: this.roleOf(a.email) })); }
|
package/server/settingswords.mjs
CHANGED
|
@@ -59,7 +59,7 @@ export const SETTINGS_WORDS_FR = {
|
|
|
59
59
|
'set-lang-device': 'La langue de chaque appareil', 'set-res-now': 'Mémoire {m} % · disque {d} %',
|
|
60
60
|
'set-share-memory': 'Mémoire par machine', 'set-share-disk': 'Disque par machine', 'set-share-others': 'Autres',
|
|
61
61
|
'set-share-rest': 'Système et autres', 'set-share-else': 'Tout le reste', 'set-share-free': 'Libre', 'set-share-used': 'Utilisé', 'set-share-of': 'sur {total}',
|
|
62
|
-
'set-binders-max': 'Les agents en font {n} au plus', 'set-admin-1': '1 administrateur', 'set-admins': '{n} administrateurs', 'set-member-1': '1 membre', 'set-members': '{n} membres',
|
|
62
|
+
'set-binders-max': 'Les agents en font {n} au plus', 'set-admin-1': '1 administrateur', 'set-admins': '{n} administrateurs', 'set-member-1': '1 membre', 'set-members': '{n} membres', 'set-member-gone': 'Plus rien n\'est partagé avec vous.', 'set-give-read': 'Lecture seule', 'set-give-chat': 'Chat', 'set-give-both': 'Chat + terminal', 'set-give-terminal': 'Terminal', 'set-give-none': 'Retirer l\'accès', 'set-given-none': 'Rien de partagé pour l\'instant.', 'set-given-ai': 'Chat et terminal : tout ce que son IA atteint.', 'set-give-add': 'Partager une conversation…', 'set-role-admin': 'Administrateur', 'set-role-member': 'Membre', 'set-add-account': 'Ajouter un compte', 'set-ch-s-operators-about': 'Qui se connecte, et ce qu\'il voit.',
|
|
63
63
|
'set-backup-now': 'Exporter · importer', 'set-git-key': '1 clé git', 'set-git-keys': '{n} clés git', 'set-restart': 'redémarrer',
|
|
64
64
|
'set-logs-now': 'Clavarium, machines, système',
|
|
65
65
|
/* Diagnostics › Charge (vm.mjs HostTally): les commandes à l'hôte, par fenêtre de 5 minutes. */
|
package/server/sshconsole.mjs
CHANGED
|
@@ -48,10 +48,17 @@ export function attachConsole(server, { tethers, gate = () => 'local', originOk
|
|
|
48
48
|
const target = machineOf(tethers, url.searchParams.get('target'));
|
|
49
49
|
if (!originOk(request.headers) || gate(request.headers) === undefined || !target) { socket.destroy(); return; }
|
|
50
50
|
const cols = Number(url.searchParams.get('cols')); const rows = Number(url.searchParams.get('rows'));
|
|
51
|
-
sockets.handleUpgrade(request, socket, head, (ws) => {
|
|
51
|
+
sockets.handleUpgrade(request, socket, head, (ws) => {
|
|
52
|
+
/* Still an administrator (#419): made a member, disabled, removed -- the console ends at once. */
|
|
53
|
+
const still = () => gate(request.headers) !== undefined;
|
|
54
|
+
const watch = setInterval(() => { if (!still()) { try { ws.close(4403, 'not allowed any more'); } catch { /* gone */ } } }, 30_000); watch.unref?.();
|
|
55
|
+
ws.on('close', () => clearInterval(watch));
|
|
56
|
+
ws.on('message', () => { if (!still()) { try { ws.close(4403, 'not allowed any more'); } catch { /* gone */ } } });
|
|
57
|
+
void seat(ws, target, whoOf(request.headers), { cols, rows }, still);
|
|
58
|
+
});
|
|
52
59
|
});
|
|
53
60
|
|
|
54
|
-
async function seat(ws, target, who, { cols, rows }) {
|
|
61
|
+
async function seat(ws, target, who, { cols, rows }, still = () => true) {
|
|
55
62
|
const send = (data, binary = false) => { if (ws.readyState === 1) ws.send(data, { binary }); };
|
|
56
63
|
let handle = null; let gone = false; const early = [];
|
|
57
64
|
const onEvent = (e) => {
|
|
@@ -73,6 +80,7 @@ export function attachConsole(server, { tethers, gate = () => 'local', originOk
|
|
|
73
80
|
/* What came meanwhile is in the replay already: only the latest state is said again. */
|
|
74
81
|
if (early.some((e) => e.type === 'closed')) { try { ws.close(CLOSE_ENDED, 'ended'); } catch { /* gone */ } return; }
|
|
75
82
|
ws.on('message', (data, binary) => {
|
|
83
|
+
if (!still()) return;
|
|
76
84
|
if (binary) { handle.write(Buffer.from(data).toString('utf8')); return; }
|
|
77
85
|
let m; try { m = JSON.parse(String(data)); } catch { return; }
|
|
78
86
|
if (m?.type === 'resize') handle.resize(Number(m.cols), Number(m.rows));
|
package/web/app.js
CHANGED
|
@@ -1353,7 +1353,7 @@
|
|
|
1353
1353
|
return j;
|
|
1354
1354
|
};
|
|
1355
1355
|
/* The name a person reads; a conversation made before free names is read by its identifier. */
|
|
1356
|
-
const shownName = (c) => (c && typeof c.title === 'string' && c.title ? c.title : c?.name ?? '');
|
|
1356
|
+
const shownName = (c) => (c && typeof c.title === 'string' && c.title ? c.title : DEVICE && c && typeof c.chatName === 'string' && c.chatName ? c.chatName : c?.name ?? '');
|
|
1357
1357
|
/* It needs its owner: it asks or waits, its answerer asks, it failed, its machine is unwell. Said even when it is hidden. */
|
|
1358
1358
|
/* Its tool asks or waits for its owner, and the owner has not written since (talk.mjs, brief). */
|
|
1359
1359
|
const talkNeeds = (c) => Boolean(c.talk && (c.talk.needs ?? (c.talk.waiting > 0 || c.talk.state === 'waiting')));
|
|
@@ -1996,6 +1996,8 @@
|
|
|
1996
1996
|
const mePath = () => `${API}/me?c=${encodeURIComponent(current)}`;
|
|
1997
1997
|
let r = await fetch(mePath());
|
|
1998
1998
|
if (leaving(r)) return;
|
|
1999
|
+
/* A member whose account was changed or removed (#419): said plainly, nothing more tried. */
|
|
2000
|
+
if (MEMBER && r.status === 403) { shut(uiSaid('set-member-gone', 'Nothing is shared with you now.')); return; }
|
|
1999
2001
|
if (r.status === 401) {
|
|
2000
2002
|
/* The session ended: the device signs again, quietly. */
|
|
2001
2003
|
const door = await window.clavariumDoor();
|
|
@@ -8331,7 +8333,7 @@
|
|
|
8331
8333
|
|
|
8332
8334
|
/* ---------- Settings: this device, and the platform ---------- */
|
|
8333
8335
|
/* What a member may use, conversation by conversation (#419): Chat to read, Chat, Chat and terminal, Terminal. */
|
|
8334
|
-
const GIVE_LEVELS = [['', '
|
|
8336
|
+
const GIVE_LEVELS = () => [['r', uiSaid('set-give-read', 'Read only')], ['rw', uiSaid('set-give-chat', 'Chat')], ['rwx', uiSaid('set-give-both', 'Chat + terminal')], ['x', uiSaid('set-give-terminal', 'Terminal')], ['', uiSaid('set-give-none', 'Remove access')]];
|
|
8335
8337
|
function memberGiven(o) {
|
|
8336
8338
|
const box = el('div', 'op-given');
|
|
8337
8339
|
const given = new Map((o.given ?? []).map((g) => [g.name, g.rights]));
|
|
@@ -8345,17 +8347,19 @@
|
|
|
8345
8347
|
};
|
|
8346
8348
|
const level = (name, rights) => {
|
|
8347
8349
|
const sel = el('select'); sel.setAttribute('aria-label', `What ${o.email} may use in ${label(name)}`);
|
|
8348
|
-
for (const [v, l] of GIVE_LEVELS) { const opt = el('option', '', l); opt.value = v; sel.append(opt); }
|
|
8349
|
-
sel.value = GIVE_LEVELS.some(([v]) => v === rights) ? rights : 'rw';
|
|
8350
|
+
for (const [v, l] of GIVE_LEVELS()) { const opt = el('option', '', l); opt.value = v; sel.append(opt); }
|
|
8351
|
+
sel.value = GIVE_LEVELS().some(([v]) => v === rights) ? rights : 'rw';
|
|
8350
8352
|
sel.addEventListener('change', () => void set(name, sel.value));
|
|
8351
8353
|
return sel;
|
|
8352
8354
|
};
|
|
8353
|
-
if (given.size === 0) box.append(el('small', '', '
|
|
8355
|
+
if (given.size === 0) box.append(el('small', '', uiSaid('set-given-none', 'Nothing shared yet.')));
|
|
8356
|
+
/* What a chat or a terminal really gives (audit 24-11): what its AI can reach -- its folders, mail, keys. */
|
|
8357
|
+
else box.append(el('small', 'hint', uiSaid('set-given-ai', 'Chat and terminal: all its AI can reach.')));
|
|
8354
8358
|
for (const [name, rights] of given) { const line = el('div', 'op-given-line'); line.append(el('span', '', label(name)), level(name, rights)); box.append(line); }
|
|
8355
8359
|
const rest = conversations.filter((c) => !given.has(c.name));
|
|
8356
8360
|
if (rest.length) {
|
|
8357
8361
|
const add = el('select', 'op-give-add'); add.setAttribute('aria-label', `Give ${o.email} a conversation`);
|
|
8358
|
-
const first = el('option', '', '
|
|
8362
|
+
const first = el('option', '', uiSaid('set-give-add', 'Share a conversation…')); first.value = ''; add.append(first);
|
|
8359
8363
|
for (const c of rest) { const opt = el('option', '', label(c.name)); opt.value = c.name; add.append(opt); }
|
|
8360
8364
|
add.addEventListener('change', () => { if (add.value) void set(add.value, 'rw'); });
|
|
8361
8365
|
box.append(add);
|
|
@@ -8368,6 +8372,7 @@
|
|
|
8368
8372
|
$('settings-ch-operators').hidden = !got || got.local === true;
|
|
8369
8373
|
if (!got || got.local) return;
|
|
8370
8374
|
if (got.defaultRole && !$('operators-role').dataset.touched) $('operators-role').value = got.defaultRole;
|
|
8375
|
+
$('operators-role').onchange = () => { $('operators-role').dataset.touched = '1'; };
|
|
8371
8376
|
const rows = $('operators-rows'); rows.replaceChildren();
|
|
8372
8377
|
const act = async (path) => {
|
|
8373
8378
|
$('operators-error').hidden = true;
|
|
@@ -8386,7 +8391,7 @@
|
|
|
8386
8391
|
/* ITS ROLE (#419): an administrator does everything; a member sees only what it is given. Never one's own. */
|
|
8387
8392
|
if (o.email !== got.me) {
|
|
8388
8393
|
const role = el('select', 'op-role'); role.setAttribute('aria-label', `Role of ${o.email}`);
|
|
8389
|
-
for (const [v, l] of [['admin', 'Administrator'], ['member', 'Member']]) { const opt = el('option', '', l); opt.value = v; role.append(opt); }
|
|
8394
|
+
for (const [v, l] of [['admin', uiSaid('set-role-admin', 'Administrator')], ['member', uiSaid('set-role-member', 'Member')]]) { const opt = el('option', '', l); opt.value = v; role.append(opt); }
|
|
8390
8395
|
role.value = o.role ?? 'admin';
|
|
8391
8396
|
role.addEventListener('change', async () => {
|
|
8392
8397
|
$('operators-error').hidden = true;
|
|
@@ -8395,13 +8400,15 @@
|
|
|
8395
8400
|
await paintOperators();
|
|
8396
8401
|
});
|
|
8397
8402
|
acts.append(role);
|
|
8398
|
-
} else name.append(el('small', '', o.role === 'member' ? 'Member' : 'Administrator'));
|
|
8403
|
+
} else name.append(el('small', '', o.role === 'member' ? uiSaid('set-role-member', 'Member') : uiSaid('set-role-admin', 'Administrator')));
|
|
8399
8404
|
acts.append(...buttons.map(([verb, label]) => { const b = el('button', verb === 'remove' ? 'danger' : '', label); b.type = 'button'; b.dataset.act = verb; b.addEventListener('click', () => void act([o.email, verb])); return b; }));
|
|
8400
8405
|
row.append(name, acts);
|
|
8401
8406
|
rows.append(row);
|
|
8402
8407
|
/* WHAT A MEMBER WAS GIVEN (#419): each conversation, its chat and/or its terminal; one more added from a list. */
|
|
8403
8408
|
if (o.role === 'member') rows.append(memberGiven(o));
|
|
8404
8409
|
}
|
|
8410
|
+
/* Its line in the chapter's head: counted once the rows are there (#419). */
|
|
8411
|
+
void paintSettingsStates().catch(() => {});
|
|
8405
8412
|
}
|
|
8406
8413
|
/* API KEYS (server/apikeys.mjs): what a program or an AI elsewhere may read with a key. Made with no
|
|
8407
8414
|
scope until one is ticked; its secret shown this once, then never; revoked at once, confirmed in place.
|
|
@@ -13875,7 +13882,7 @@
|
|
|
13875
13882
|
/* A device may have been given several conversations, each by a code of
|
|
13876
13883
|
its own. One is shown at a time; the others are a tap away. */
|
|
13877
13884
|
function offerOthers(others) {
|
|
13878
|
-
$('others').hidden =
|
|
13885
|
+
$('others').hidden = MEMBER && others.length === 0;
|
|
13879
13886
|
$('others').textContent = others.length > 0 ? `Conversations (${others.length + 1})` : MEMBER ? 'Conversations' : 'This device';
|
|
13880
13887
|
$('others').onclick = () => {
|
|
13881
13888
|
const rows = $('others-rows');
|
package/web/index.html
CHANGED
|
@@ -1163,10 +1163,10 @@
|
|
|
1163
1163
|
<section class="settings-group" id="settings-group-access" data-group="access" role="tabpanel" aria-label="Access">
|
|
1164
1164
|
<!-- WHO MAY SIGN IN (server/operators.mjs): hidden on this machine alone. -->
|
|
1165
1165
|
<details class="chapter" id="settings-ch-operators" data-chapter="s-operators" hidden>
|
|
1166
|
-
<summary><span class="chapter-title" data-said="set-ch-s-operators">Accounts</span><span class="chapter-about">Who
|
|
1166
|
+
<summary><span class="chapter-title" data-said="set-ch-s-operators">Accounts</span><span class="chapter-about" data-said="set-ch-s-operators-about">Who signs in, and what they see.</span></summary>
|
|
1167
1167
|
<div class="chapter-body">
|
|
1168
1168
|
<div id="operators-rows"></div>
|
|
1169
|
-
<form id="operators-new" class="set-row" autocomplete="off"><div class="set-what"><label for="operators-email">Add an account</label><small>Email address</small><small class="tip" hidden>Locked 15 min after 5 failures. The last administrator is never locked or removed.</small></div><div class="set-control"><input id="operators-email" type="email" placeholder="someone@example.com" spellcheck="false" autocapitalize="off" required><select id="operators-role" aria-label="Role of the new account"><option value="member">Member</option><option value="admin">Administrator</option></select><button type="submit">Add</button></div></form>
|
|
1169
|
+
<form id="operators-new" class="set-row" autocomplete="off"><div class="set-what"><label for="operators-email" data-said="set-add-account">Add an account</label><small>Email address</small><small class="tip" hidden>Locked 15 min after 5 failures. The last administrator is never locked or removed.</small></div><div class="set-control"><input id="operators-email" type="email" placeholder="someone@example.com" spellcheck="false" autocapitalize="off" required><select id="operators-role" aria-label="Role of the new account"><option value="member" data-said="set-role-member">Member</option><option value="admin" data-said="set-role-admin">Administrator</option></select><button type="submit">Add</button></div></form>
|
|
1170
1170
|
<div id="operators-password" class="as-form" hidden><p><b id="operators-password-for"></b>: its password, shown <b>this once</b>. Give it to them yourself.</p><div class="row"><input id="operators-password-value" readonly spellcheck="false"><button type="button" id="operators-password-copy">Copy</button><button type="button" id="operators-password-done">Done</button></div></div>
|
|
1171
1171
|
<p class="error" id="operators-error" role="alert" hidden></p>
|
|
1172
1172
|
</div>
|
package/web/style.css
CHANGED
|
@@ -195,8 +195,8 @@ footer#keys { border-top: 0; }
|
|
|
195
195
|
.device { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
|
|
196
196
|
.device b { flex: 1; min-width: 120px; } .device small { color: var(--ink2); }
|
|
197
197
|
button.danger { border-color: var(--danger); color: var(--danger); }
|
|
198
|
-
html[data-door="device"] #app { display: block; }
|
|
199
|
-
html[data-door="device"] #room { height: 100%; }
|
|
198
|
+
html:is([data-door="device"],[data-door="member"]) #app { display: block; }
|
|
199
|
+
html:is([data-door="device"],[data-door="member"]) #room { height: 100%; }
|
|
200
200
|
#secret-rows { display: flex; flex-direction: column; }
|
|
201
201
|
#secret-new { display: flex; flex-direction: column; gap: 6px; max-width: 560px; }
|
|
202
202
|
#secret-new label { font-size: .75rem; color: var(--ink2); }
|
|
@@ -1148,9 +1148,9 @@ button.inline:hover { color: var(--brass-ink); }
|
|
|
1148
1148
|
.item[data-hidden="true"] { opacity: .7; }
|
|
1149
1149
|
|
|
1150
1150
|
/* ---------- THE BAR (G): « · state dot + name · [Chat | Terminal | Assets N] · settings ---------- */
|
|
1151
|
-
html:not([data-door="device"]) #room > header { flex-wrap: nowrap; }
|
|
1152
|
-
html:not([data-door="device"]) #room > header #state { flex: 0 0 auto; width: 10px; height: 10px; overflow: hidden; font-size: 0; color: transparent; }
|
|
1153
|
-
html:not([data-door="device"]) #room > header #state::before { width: 10px; height: 10px; margin: 0; vertical-align: top; }
|
|
1151
|
+
html:not([data-door="device"]):not([data-door="member"]) #room > header { flex-wrap: nowrap; }
|
|
1152
|
+
html:not([data-door="device"]):not([data-door="member"]) #room > header #state { flex: 0 0 auto; width: 10px; height: 10px; overflow: hidden; font-size: 0; color: transparent; }
|
|
1153
|
+
html:not([data-door="device"]):not([data-door="member"]) #room > header #state::before { width: 10px; height: 10px; margin: 0; vertical-align: top; }
|
|
1154
1154
|
.views { display: inline-flex; flex: 0 0 auto; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
|
|
1155
1155
|
.views button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--ink2); border-radius: 7px; padding: 5px 11px; }
|
|
1156
1156
|
.views button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
|
|
@@ -1159,7 +1159,7 @@ html:not([data-door="device"]) #room > header #state::before { width: 10px; heig
|
|
|
1159
1159
|
header .ic, #folders .ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
|
|
1160
1160
|
#folders { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
|
|
1161
1161
|
@media (max-width: 900px) { .views button span, #folders span { display: none; } .views button { padding: 6px 10px; } }
|
|
1162
|
-
@media (max-width: 700px) { html:not([data-door="device"]) #room > header #menu { display: none; } }
|
|
1162
|
+
@media (max-width: 700px) { html:not([data-door="device"]):not([data-door="member"]) #room > header #menu { display: none; } }
|
|
1163
1163
|
|
|
1164
1164
|
/* The chat's display settings: an eye, not sliders (Parley draws its own sign; it is masked here). */
|
|
1165
1165
|
#simple-thread .parley-prefs-open svg, #salon-thread .parley-prefs-open svg { display: none; }
|
|
@@ -1490,7 +1490,7 @@ select.pill { appearance: auto; }
|
|
|
1490
1490
|
.rv-tree { position: static; max-height: none; }
|
|
1491
1491
|
}
|
|
1492
1492
|
@media (max-width: 700px) {
|
|
1493
|
-
html:not([data-door="device"]) #room > header .views button, html:not([data-door="device"]) #room > header #folders, html:not([data-door="device"]) #room > header .topbar-lead-back { min-height: 36px; height: 36px; }
|
|
1493
|
+
html:not([data-door="device"]):not([data-door="member"]) #room > header .views button, html:not([data-door="device"]):not([data-door="member"]) #room > header #folders, html:not([data-door="device"]):not([data-door="member"]) #room > header .topbar-lead-back { min-height: 36px; height: 36px; }
|
|
1494
1494
|
.views { padding: 2px; }
|
|
1495
1495
|
}
|
|
1496
1496
|
#copy-close, #files-close, #preview-close { font-size: 1.375rem; line-height: 1; min-width: 40px; padding: 4px 10px; }
|
|
@@ -2583,7 +2583,7 @@ header.topbar > :is(.topbar-fold, .topbar-lead-back):hover { color: var(--ink);
|
|
|
2583
2583
|
header.topbar > .topbar-lead-back[hidden] { display: none; }
|
|
2584
2584
|
@media (max-width: 700px) { header.topbar > .topbar-fold { display: none; } }
|
|
2585
2585
|
@media (min-width: 701px) { header.topbar > .topbar-lead-back { display: none; } }
|
|
2586
|
-
header.topbar .bar-state, html:not([data-door="device"]) header.topbar #state { width: 10px; height: 10px; border-radius: 50%; flex: none; }
|
|
2586
|
+
header.topbar .bar-state, html:not([data-door="device"]):not([data-door="member"]) header.topbar #state { width: 10px; height: 10px; border-radius: 50%; flex: none; }
|
|
2587
2587
|
header.topbar .bar-state { background: var(--ok); }
|
|
2588
2588
|
header.topbar .bar-state[hidden] { display: none; }
|
|
2589
2589
|
/* A room one of whose AIs speaks now: its dot as a conversation's at work, the words under its name. */
|
|
@@ -2600,7 +2600,7 @@ header.topbar .views .icon-btn { width: auto; height: auto; }
|
|
|
2600
2600
|
header.topbar .views button { height: 32px; min-height: 32px; padding-block: 0; }
|
|
2601
2601
|
@media (max-width: 700px) { header.topbar { height: 48px; min-height: 48px; padding: 0 8px; gap: 6px; } }
|
|
2602
2602
|
/* A device's page (/c/): the same bar, its own controls may take a second line on a narrow screen (its menu "..."). */
|
|
2603
|
-
html[data-door="device"] header.topbar { height: auto; }
|
|
2603
|
+
html:is([data-door="device"],[data-door="member"]) header.topbar { height: auto; }
|
|
2604
2604
|
/* A place's top bar stays at the top while its page scrolls (05-11), edge to edge over the page's own margins.
|
|
2605
2605
|
(A page with a bar starts at its bar: no margin above it, so it sticks where it rests.) */
|
|
2606
2606
|
:is(.sheet, #newconv, #salon-new):has(> header.topbar) { padding-top: 0; }
|
|
@@ -3179,11 +3179,11 @@ button.kit-switch[aria-checked="true"]::after { left: 18px; background: var(--ok
|
|
|
3179
3179
|
#machines-confirm { margin: 8px 16px; }
|
|
3180
3180
|
/* A phone (13-11): the bar's five buttons tighter, so that all stay on the screen -- its name gives way, never the bar. */
|
|
3181
3181
|
@media (max-width: 480px) {
|
|
3182
|
-
html:not([data-door="device"]) #room > header #name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
3183
|
-
html:not([data-door="device"]) #room > header :is(.bar-right, .views) { flex: none; }
|
|
3184
|
-
html:not([data-door="device"]) #room > header .views { gap: 0; padding: 2px; }
|
|
3185
|
-
html:not([data-door="device"]) #room > header .views button { gap: 4px; padding-inline: 7px; }
|
|
3186
|
-
html:not([data-door="device"]) #room > header .views .count { min-width: 1.2em; padding: 1px 4px; }
|
|
3182
|
+
html:not([data-door="device"]):not([data-door="member"]) #room > header #name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
3183
|
+
html:not([data-door="device"]):not([data-door="member"]) #room > header :is(.bar-right, .views) { flex: none; }
|
|
3184
|
+
html:not([data-door="device"]):not([data-door="member"]) #room > header .views { gap: 0; padding: 2px; }
|
|
3185
|
+
html:not([data-door="device"]):not([data-door="member"]) #room > header .views button { gap: 4px; padding-inline: 7px; }
|
|
3186
|
+
html:not([data-door="device"]):not([data-door="member"]) #room > header .views .count { min-width: 1.2em; padding: 1px 4px; }
|
|
3187
3187
|
}
|
|
3188
3188
|
/* At hand (13-11): a switch's name never under its buttons -- the name keeps its width, the buttons wrap. */
|
|
3189
3189
|
.hand-switches .set-row > .set-what { flex: none; }
|