clavarium 0.2.386-next.1 → 0.2.388-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 +6 -6
- package/package.json +2 -2
- package/server/api.mjs +4 -0
- package/server/browsers.mjs +77 -8
- package/server/settingswords.mjs +4 -2
- package/web/app.js +44 -9
- package/web/index.html +14 -6
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.388-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.388-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"clavarium-binder": "0.1.62-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.2-next.2",
|
|
16
16
|
"clavarium-parley": "0.17.88-next.1",
|
|
17
|
-
"clavarium-tether": "0.1.0-next.
|
|
17
|
+
"clavarium-tether": "0.1.0-next.60",
|
|
18
18
|
"mammoth": "1.13.0",
|
|
19
19
|
"mermaid": "11.17.2",
|
|
20
20
|
"node-pty": "^1.1.0",
|
|
@@ -800,9 +800,9 @@
|
|
|
800
800
|
}
|
|
801
801
|
},
|
|
802
802
|
"node_modules/clavarium-tether": {
|
|
803
|
-
"version": "0.1.0-next.
|
|
804
|
-
"resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.
|
|
805
|
-
"integrity": "sha512-
|
|
803
|
+
"version": "0.1.0-next.60",
|
|
804
|
+
"resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.60.tgz",
|
|
805
|
+
"integrity": "sha512-el+ekbsskuyyy0wAnocvV/VjvpbbnHl/IpPpjZRB+qu9CdyBJHcnfbtK5CcXH84IpUfQgPF+hSdZFB6v/1CSyg==",
|
|
806
806
|
"license": "MIT",
|
|
807
807
|
"bin": {
|
|
808
808
|
"tether": "bin/cli.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.388-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.",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"clavarium-binder": "0.1.62-next.1",
|
|
49
49
|
"clavarium-docket": "0.1.2-next.2",
|
|
50
50
|
"clavarium-parley": "0.17.88-next.1",
|
|
51
|
-
"clavarium-tether": "0.1.0-next.
|
|
51
|
+
"clavarium-tether": "0.1.0-next.60",
|
|
52
52
|
"mammoth": "1.13.0",
|
|
53
53
|
"mermaid": "11.17.2",
|
|
54
54
|
"node-pty": "^1.1.0",
|
package/server/api.mjs
CHANGED
|
@@ -629,6 +629,10 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
629
629
|
again ({ code, target }). The token it is handed is never in the answer. */
|
|
630
630
|
/* The sites a conversation acts on without asking, at frame: { target, agent, sites: [host | *.host] }. */
|
|
631
631
|
if (pathname === '/api/tether/browser-sites' && tethers?.browsers) return send(200, await tethers.browsers.setSites(tethers, body ?? {})), true;
|
|
632
|
+
/* A configuration to paste in the extension ({ name?, target? } -> { offer, key, expires }: the key said this once,
|
|
633
|
+
kept only as its hash), and where it is ({ offer } -> waiting | claimed (its target) | expired). */
|
|
634
|
+
if (pathname === '/api/tether/browser-offer' && tethers?.browsers) return send(201, tethers.browsers.offer({ name: body?.name, target: body?.target })), true;
|
|
635
|
+
if (pathname === '/api/tether/browser-offer-state' && tethers?.browsers) return send(200, tethers.browsers.offerState(body?.offer)), true;
|
|
632
636
|
if (pathname === '/api/tether/browser-pair' && tethers?.browsers) return send(201, tethers.browsers.pair({ code: body?.code, name: body?.name, target: body?.target })), true;
|
|
633
637
|
/* A server taken away: the key kept for it goes too. */
|
|
634
638
|
const mcpGone = pathname === '/api/tether/remove-target' && tethers ? tethers.store().target(String(body?.target ?? '')) : null;
|
package/server/browsers.mjs
CHANGED
|
@@ -7,7 +7,14 @@
|
|
|
7
7
|
* through without the web sign-in (deploy/install.sh, skip_auth_routes), as it does for paired devices and voice boxes.
|
|
8
8
|
* The extension cannot sign in; its right is the token it was handed when it was paired, and nothing else.
|
|
9
9
|
*
|
|
10
|
-
* PAIRING
|
|
10
|
+
* PAIRING BY A CONFIGURATION (Tether 0.1.0-next.59), the way a person copies once: Assets › New › Browser shows one line,
|
|
11
|
+
* {"url":"wss://…/c/api/browser","key":"…"}, pasted in the extension's popup. The key is single-use, good for ten
|
|
12
|
+
* minutes, kept here only as its SHA-256 (offer). The extension connects and says { t:"claim", key }: a key offered,
|
|
13
|
+
* not expired, makes the browser's target (or pairs it again), its socket goes to that browser's connector, which
|
|
14
|
+
* swaps the key for the token. A wrong, spent or expired key is refused ({ t:"claim-refused" }) and counted per
|
|
15
|
+
* address; too many, the address is turned away for a while.
|
|
16
|
+
*
|
|
17
|
+
* PAIRING BY A CODE, the fallback. A new extension says { t:"pair", code }: it waits here, in the lobby, its code shown in its popup. The person
|
|
11
18
|
* types that code in Assets › New › Browser (pair): the socket goes to that target's own connector (one per browser,
|
|
12
19
|
* Tether's `browser()`), which mints a long-lived token and hands it over. From then on the extension says
|
|
13
20
|
* { t:"hello", token } each time it connects -- every start of the browser -- and is that browser again, with no code.
|
|
@@ -21,7 +28,7 @@
|
|
|
21
28
|
* kept small; and on the person's side, wrong codes counted -- too many in a while, pairing waits. Two sockets offering
|
|
22
29
|
* the same code are both refused (nobody can take a code someone else shows).
|
|
23
30
|
*/
|
|
24
|
-
import { createHash } from 'node:crypto';
|
|
31
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
25
32
|
import { browser as browserConnector } from 'clavarium-tether/connectors/browser';
|
|
26
33
|
import { no } from 'clavarium-tether/verbs';
|
|
27
34
|
import { JsonFile } from './store.mjs';
|
|
@@ -42,6 +49,9 @@ export const CONNECTS_PER_MINUTE = 20;
|
|
|
42
49
|
export const WRONG_MAX = 5;
|
|
43
50
|
export const WRONG_WINDOW_MS = 10 * 60_000;
|
|
44
51
|
const TITLE_MAX = 80;
|
|
52
|
+
/* A configuration's key is good this long; this many offers wait at most. */
|
|
53
|
+
export const OFFER_MS = 10 * 60_000;
|
|
54
|
+
export const OFFERS_MAX = 20;
|
|
45
55
|
export const SITES_MAX = 100;
|
|
46
56
|
|
|
47
57
|
const hash = (token) => createHash('sha256').update(String(token)).digest('hex');
|
|
@@ -63,6 +73,8 @@ export class Browsers {
|
|
|
63
73
|
#lobby = new Set(); /* sockets not paired yet */
|
|
64
74
|
#connects = new Map(); /* address -> times of its recent sockets */
|
|
65
75
|
#wrong = []; /* times of recent wrong codes */
|
|
76
|
+
#offers = new Map(); /* offer id -> { hash, name, target, expires, claimed } */
|
|
77
|
+
#badClaims = new Map(); /* address -> times of its recent wrong keys */
|
|
66
78
|
#listeners = new Set();
|
|
67
79
|
#timer = null;
|
|
68
80
|
|
|
@@ -131,7 +143,8 @@ export class Browsers {
|
|
|
131
143
|
const recent = (this.#connects.get(address) ?? []).filter((t) => now - t < 60_000);
|
|
132
144
|
recent.push(now); this.#connects.set(address, recent);
|
|
133
145
|
const waiting = [...this.#lobby].filter((c) => c.address === address).length;
|
|
134
|
-
|
|
146
|
+
const bad = (this.#badClaims.get(address) ?? []).filter((t) => now - t < WRONG_WINDOW_MS).length;
|
|
147
|
+
if (recent.length > CONNECTS_PER_MINUTE || this.#lobby.size >= LOBBY_MAX || waiting >= LOBBY_PER_ADDRESS || bad >= WRONG_MAX) { try { raw.close(); } catch { /* gone */ } return false; }
|
|
135
148
|
const conn = { raw, address, since: now, code: null, tabs: null, handler: null, closers: new Set(), taken: false };
|
|
136
149
|
this.#lobby.add(conn);
|
|
137
150
|
raw.onMessage((msg, size = 0) => {
|
|
@@ -153,6 +166,7 @@ export class Browsers {
|
|
|
153
166
|
if (/^[0-9A-Za-z-]{4,32}$/.test(code)) { conn.code = code; this.#changed(); }
|
|
154
167
|
return;
|
|
155
168
|
}
|
|
169
|
+
if (msg.t === 'claim') { this.#claim(conn, msg); return; }
|
|
156
170
|
if (msg.t === 'hello' && typeof msg.token === 'string' && msg.token) {
|
|
157
171
|
const h = hash(msg.token);
|
|
158
172
|
const all = this.#tokens.get();
|
|
@@ -174,6 +188,60 @@ export class Browsers {
|
|
|
174
188
|
return i;
|
|
175
189
|
}
|
|
176
190
|
|
|
191
|
+
/* A CONFIGURATION TO PASTE in the extension: { name?, target? } -> { offer, key, expires }. The key is said once,
|
|
192
|
+
here, to the signed-in person; only its hash is kept. `target`: a browser paired again. */
|
|
193
|
+
offer({ name = '', target = '' } = {}) {
|
|
194
|
+
const now = this.#now();
|
|
195
|
+
for (const [id, o] of this.#offers) if (o.expires < now && !o.claimed) this.#offers.delete(id);
|
|
196
|
+
if ([...this.#offers.values()].filter((o) => !o.claimed).length >= OFFERS_MAX) throw new Refusal(429, 'Too many configurations waiting. Wait a few minutes.');
|
|
197
|
+
if (target) { const t = this.#store().target(String(target)); if (!t || t.kind !== 'browser') throw new Refusal(404, 'No such browser.'); }
|
|
198
|
+
const key = randomBytes(32).toString('base64url');
|
|
199
|
+
const id = randomBytes(6).toString('hex');
|
|
200
|
+
this.#offers.set(id, { hash: hash(key), name: String(name ?? '').trim().slice(0, TITLE_MAX), target: String(target ?? ''), expires: now + OFFER_MS, claimed: null });
|
|
201
|
+
return { offer: id, key, expires: new Date(now + OFFER_MS).toISOString() };
|
|
202
|
+
}
|
|
203
|
+
/* Where an offer is: waiting, claimed (its target), expired. */
|
|
204
|
+
offerState(id) {
|
|
205
|
+
const o = this.#offers.get(String(id ?? ''));
|
|
206
|
+
if (!o) return { state: 'expired' };
|
|
207
|
+
if (o.claimed) { const t = this.#store().target(o.claimed); return { state: 'claimed', target: { id: o.claimed, title: t?.title ?? o.name } }; }
|
|
208
|
+
return o.expires < this.#now() ? { state: 'expired' } : { state: 'waiting' };
|
|
209
|
+
}
|
|
210
|
+
#claim(conn, msg) {
|
|
211
|
+
const now = this.#now();
|
|
212
|
+
const h = typeof msg.key === 'string' && msg.key ? hash(msg.key) : '';
|
|
213
|
+
const found = h ? [...this.#offers.entries()].find(([, o]) => o.hash === h && !o.claimed) : null;
|
|
214
|
+
if (!found || found[1].expires < now) {
|
|
215
|
+
if (found) this.#offers.delete(found[0]);
|
|
216
|
+
const list = (this.#badClaims.get(conn.address) ?? []).filter((t) => now - t < WRONG_WINDOW_MS);
|
|
217
|
+
list.push(now); this.#badClaims.set(conn.address, list);
|
|
218
|
+
this.#log(`browser: a pairing key was refused (${found ? 'expired' : 'unknown or spent'})`);
|
|
219
|
+
conn.raw.send({ t: 'claim-refused' });
|
|
220
|
+
if (list.length >= WRONG_MAX) this.#drop(conn);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const o = found[1];
|
|
224
|
+
o.claimed = 'pending';
|
|
225
|
+
const store = this.#store();
|
|
226
|
+
let t = o.target ? store.target(o.target) : null;
|
|
227
|
+
if (t) this.forget(t.id, { keepTarget: true });
|
|
228
|
+
else t = this.#made(store, o.name);
|
|
229
|
+
const i = this.#of(t.id);
|
|
230
|
+
i.offer({ key: msg.key, ttl: Math.max(1000, o.expires - now) });
|
|
231
|
+
this.#hand(conn, t.id, [msg]);
|
|
232
|
+
o.claimed = t.id;
|
|
233
|
+
this.#log(`browser: ${t.id} paired`);
|
|
234
|
+
this.#changed();
|
|
235
|
+
}
|
|
236
|
+
/* A new browser's target, named (or "Browser"), its id unique. */
|
|
237
|
+
#made(store, name) {
|
|
238
|
+
const title = String(name ?? '').trim().slice(0, TITLE_MAX) || 'Browser';
|
|
239
|
+
const base = `browser-${slug(title) || 'browser'}`;
|
|
240
|
+
let id = base;
|
|
241
|
+
for (let n = 2; store.target(id); n++) id = `${base}-${n}`;
|
|
242
|
+
return store.putTarget({ id, title, kind: 'browser', connector: 'browser', config: {} });
|
|
243
|
+
}
|
|
244
|
+
|
|
177
245
|
/* Is a browser waiting with a code (the page says so while the person types it)? */
|
|
178
246
|
waiting() { return [...this.#lobby].filter((c) => c.code).length; }
|
|
179
247
|
|
|
@@ -200,11 +268,7 @@ export class Browsers {
|
|
|
200
268
|
/* Paired again: its old tokens go, the old socket too. */
|
|
201
269
|
this.forget(t.id, { keepTarget: true });
|
|
202
270
|
} else {
|
|
203
|
-
|
|
204
|
-
const base = `browser-${slug(title) || 'browser'}`;
|
|
205
|
-
let id = base;
|
|
206
|
-
for (let n = 2; store.target(id); n++) id = `${base}-${n}`;
|
|
207
|
-
t = store.putTarget({ id, title, kind: 'browser', connector: 'browser', config: {} });
|
|
271
|
+
t = this.#made(store, name);
|
|
208
272
|
}
|
|
209
273
|
const [conn] = offered;
|
|
210
274
|
const i = this.#hand(conn, t.id, [{ t: 'pair', code: given }]);
|
|
@@ -237,6 +301,9 @@ export class Browsers {
|
|
|
237
301
|
return { sites: (this.#store().target(t.id).grants?.[who]?.rules ?? []).filter((r) => r.kind === 'site').map((r) => r.value) };
|
|
238
302
|
}
|
|
239
303
|
|
|
304
|
+
/* Wrong keys counted now for an address (the tests). */
|
|
305
|
+
refusedKeys(address) { const now = this.#now(); return (this.#badClaims.get(address) ?? []).filter((t) => now - t < WRONG_WINDOW_MS).length; }
|
|
306
|
+
|
|
240
307
|
/* Wrong codes counted now (the tests; the page says only that it must wait). */
|
|
241
308
|
wrongCodes() { const now = this.#now(); return this.#wrong.filter((t) => now - t < WRONG_WINDOW_MS).length; }
|
|
242
309
|
|
|
@@ -260,6 +327,8 @@ export class Browsers {
|
|
|
260
327
|
#sweep() {
|
|
261
328
|
const now = this.#now();
|
|
262
329
|
for (const c of [...this.#lobby]) if (now - c.since > LOBBY_MS) this.#drop(c);
|
|
330
|
+
for (const [id, o] of this.#offers) if (o.expires < now - OFFER_MS) this.#offers.delete(id);
|
|
331
|
+
for (const [a, list] of this.#badClaims) { const keep = list.filter((t) => now - t < WRONG_WINDOW_MS); if (keep.length) this.#badClaims.set(a, keep); else this.#badClaims.delete(a); }
|
|
263
332
|
for (const [a, list] of this.#connects) { const keep = list.filter((t) => now - t < 60_000); if (keep.length) this.#connects.set(a, keep); else this.#connects.delete(a); }
|
|
264
333
|
}
|
|
265
334
|
|
package/server/settingswords.mjs
CHANGED
|
@@ -173,8 +173,10 @@ export const SETTINGS_WORDS_FR = {
|
|
|
173
173
|
'set-rt-mcp-hint-frame': 'Votre choix pour chaque sorte d\'outil',
|
|
174
174
|
/* A browser paired through the Tether extension (browsers.mjs): the form, its panel, Frame's sites. */
|
|
175
175
|
'set-na-k-browser': 'Navigateur', 'set-br-head': 'Associer un navigateur',
|
|
176
|
-
'set-br-step-install': 'Installez l\'extension Tether.', 'set-br-step-
|
|
177
|
-
'set-br-step-
|
|
176
|
+
'set-br-step-install': 'Installez l\'extension Tether.', 'set-br-step-make': 'Créez la configuration, puis copiez-la.',
|
|
177
|
+
'set-br-step-paste': 'Collez-la dans la fenêtre de l\'extension.', 'set-br-make': 'Créer la configuration',
|
|
178
|
+
'set-br-config': 'Configuration (une fois, 10 minutes)', 'set-br-wait': 'En attente de l\'extension…',
|
|
179
|
+
'set-br-expired': 'Expirée : créez-en une autre.', 'set-br-by-code': 'Ou avec le code qu\'elle affiche', 'set-br-address': 'Adresse pour l\'extension', 'set-br-copy': 'Copier', 'set-br-copied': 'Copié',
|
|
178
180
|
'set-br-name': 'Nom', 'set-br-code': 'Code', 'set-br-pair': 'Associer', 'set-br-pair-again': 'Associer à nouveau', 'set-br-pairing': 'Association',
|
|
179
181
|
'set-br-connected': 'Connecté · {n} onglet(s) donné(s)', 'set-br-offline': 'Non connecté : ouvrez ce navigateur',
|
|
180
182
|
'set-br-tabs': 'Onglets', 'set-br-no-tabs': 'Aucun onglet donné : voyez sa fenêtre.',
|
package/web/app.js
CHANGED
|
@@ -5195,6 +5195,8 @@
|
|
|
5195
5195
|
AI can touch), the address the extension connects to, « Pair again »; then, for each conversation at Frame, the
|
|
5196
5196
|
sites it acts on without asking. */
|
|
5197
5197
|
const browserAddress = () => `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/c/api/browser`;
|
|
5198
|
+
/* The one line pasted in the extension's popup: where it connects, and its key good once (Tether 0.1.0-next.59). */
|
|
5199
|
+
const browserConfig = (key) => JSON.stringify({ url: browserAddress(), key });
|
|
5198
5200
|
function browserParts(t, tether = {}) {
|
|
5199
5201
|
const out = [];
|
|
5200
5202
|
const now = tether.browsers?.[t.id] ?? { connected: false, tabs: [] };
|
|
@@ -5206,16 +5208,18 @@
|
|
|
5206
5208
|
const body = [state];
|
|
5207
5209
|
body.push(now.tabs.length ? list : el('p', 'hint', uiSaid('set-br-no-tabs', 'No tab granted: grant them in its popup.')));
|
|
5208
5210
|
out.push({ title: uiSaid('set-br-tabs', 'Tabs'), body, cls: 'as-br-tabs' });
|
|
5209
|
-
/* Paired again (the extension reinstalled, its pairing reset):
|
|
5211
|
+
/* Paired again (the extension reinstalled, its pairing reset): a new configuration for the same asset. */
|
|
5210
5212
|
const again = el('div', 'br-again');
|
|
5211
|
-
const
|
|
5213
|
+
const line = el('input'); line.readOnly = true; line.spellcheck = false; line.hidden = true; line.setAttribute('aria-label', uiSaid('set-br-config', 'Configuration (once, 10 minutes)'));
|
|
5212
5214
|
const go = el('button', '', uiSaid('set-br-pair-again', 'Pair again')); go.type = 'button'; go.dataset.act = 'browser-pair-again';
|
|
5213
5215
|
go.addEventListener('click', async () => {
|
|
5216
|
+
if (!line.hidden) { try { await navigator.clipboard.writeText(line.value); go.textContent = uiSaid('set-br-copied', 'Copied'); } catch { line.select(); } return; }
|
|
5214
5217
|
go.disabled = true; $(asErrId()).hidden = true;
|
|
5215
|
-
try { await post(`${API}/tether/browser-
|
|
5216
|
-
|
|
5218
|
+
try { const made = await post(`${API}/tether/browser-offer`, { target: t.id }); line.value = browserConfig(made.key); line.hidden = false; go.textContent = uiSaid('set-br-copy', 'Copy'); }
|
|
5219
|
+
catch (error) { sayAsErr(error); }
|
|
5220
|
+
go.disabled = false;
|
|
5217
5221
|
});
|
|
5218
|
-
again.append(
|
|
5222
|
+
again.append(line, go);
|
|
5219
5223
|
out.push({ title: uiSaid('set-br-pairing', 'Pairing'), body: [again], cls: 'as-br-pair' });
|
|
5220
5224
|
/* Frame: the sites each conversation acts on without a card (Tether's site rules). Empty: everything asked. */
|
|
5221
5225
|
const framed = Object.entries(t.grants ?? {}).filter(([id, g]) => id.startsWith('conversation:') && g?.level === 'frame');
|
|
@@ -8941,14 +8945,45 @@
|
|
|
8941
8945
|
btn.disabled = false;
|
|
8942
8946
|
await paintAssets();
|
|
8943
8947
|
});
|
|
8944
|
-
/* PAIR A BROWSER (browsers.mjs):
|
|
8948
|
+
/* PAIR A BROWSER (browsers.mjs): one line to copy into the Tether extension's popup -- its address and a key good once,
|
|
8949
|
+
for ten minutes; the page waits until the extension came with it. Or, as before, the code its popup shows. */
|
|
8950
|
+
let browserWait = null;
|
|
8951
|
+
const stopBrowserWait = () => { clearTimeout(browserWait); browserWait = null; };
|
|
8952
|
+
async function browserClaimed(form, offer) {
|
|
8953
|
+
stopBrowserWait();
|
|
8954
|
+
let r;
|
|
8955
|
+
try { r = await post(`${API}/tether/browser-offer-state`, { offer }); } catch { r = { state: 'waiting' }; }
|
|
8956
|
+
if (r.state === 'claimed') {
|
|
8957
|
+
$('browser-new').reset(); $('browser-made').hidden = true;
|
|
8958
|
+
await assetMade(form, { key: `connexion:${r.target.id}`, name: r.target.title, give: (to, level) => grantTarget(r.target.id, to, targetLevel(level)) });
|
|
8959
|
+
await paintAssets();
|
|
8960
|
+
return;
|
|
8961
|
+
}
|
|
8962
|
+
if (r.state === 'expired') { $('browser-wait').textContent = uiSaid('set-br-expired', 'Expired: make a new one.'); return; }
|
|
8963
|
+
if (!form.isConnected || form.hidden) return;
|
|
8964
|
+
browserWait = setTimeout(() => void browserClaimed(form, offer), 2000);
|
|
8965
|
+
}
|
|
8945
8966
|
$('browser-new').addEventListener('submit', async (event) => {
|
|
8946
8967
|
event.preventDefault();
|
|
8968
|
+
$('browser-error').hidden = true;
|
|
8969
|
+
const btn = $('browser-make'); btn.disabled = true;
|
|
8970
|
+
try {
|
|
8971
|
+
const made = await post(`${API}/tether/browser-offer`, { name: $('browser-name').value.trim() });
|
|
8972
|
+
$('browser-config').value = browserConfig(made.key);
|
|
8973
|
+
$('browser-copy').textContent = uiSaid('set-br-copy', 'Copy');
|
|
8974
|
+
$('browser-wait').textContent = uiSaid('set-br-wait', 'Waiting for the extension…');
|
|
8975
|
+
$('browser-made').hidden = false;
|
|
8976
|
+
const box = $('browser-box');
|
|
8977
|
+
void browserClaimed(box, made.offer);
|
|
8978
|
+
} catch (error) { $('browser-error').textContent = error.message; $('browser-error').hidden = false; }
|
|
8979
|
+
btn.disabled = false;
|
|
8980
|
+
});
|
|
8981
|
+
$('browser-pair').addEventListener('click', async () => {
|
|
8947
8982
|
$('browser-error').hidden = true;
|
|
8948
8983
|
const btn = $('browser-pair'); btn.disabled = true;
|
|
8949
8984
|
try {
|
|
8950
8985
|
const made = await post(`${API}/tether/browser-pair`, { name: $('browser-name').value.trim(), code: $('browser-code').value.trim() });
|
|
8951
|
-
$('browser-new').reset();
|
|
8986
|
+
stopBrowserWait(); $('browser-new').reset(); $('browser-made').hidden = true;
|
|
8952
8987
|
await assetMade($('browser-box'), { key: `connexion:${made.id}`, name: made.title, give: (to, level) => grantTarget(made.id, to, targetLevel(level)) });
|
|
8953
8988
|
} catch (error) { $('browser-error').textContent = error.message; $('browser-error').hidden = false; }
|
|
8954
8989
|
btn.disabled = false;
|
|
@@ -8956,8 +8991,8 @@
|
|
|
8956
8991
|
});
|
|
8957
8992
|
$('browser-address').value = browserAddress();
|
|
8958
8993
|
$('browser-copy').addEventListener('click', async () => {
|
|
8959
|
-
try { await navigator.clipboard.writeText($('browser-
|
|
8960
|
-
catch { $('browser-
|
|
8994
|
+
try { await navigator.clipboard.writeText($('browser-config').value); $('browser-copy').textContent = uiSaid('set-br-copied', 'Copied'); }
|
|
8995
|
+
catch { $('browser-config').select(); }
|
|
8961
8996
|
});
|
|
8962
8997
|
$('mcp-import').addEventListener('click', async () => {
|
|
8963
8998
|
$('mcp-error').hidden = true;
|
package/web/index.html
CHANGED
|
@@ -883,16 +883,24 @@
|
|
|
883
883
|
</form>
|
|
884
884
|
</div>
|
|
885
885
|
<div id="browser-box" class="as-form" data-kind="browser"><h3 data-said="set-br-head">Pair a browser</h3>
|
|
886
|
-
<ol class="hint br-steps"><li data-said="set-br-step-install">Install the Tether extension.</li><li data-said="set-br-step-
|
|
886
|
+
<ol class="hint br-steps"><li data-said="set-br-step-install">Install the Tether extension.</li><li data-said="set-br-step-make">Make the configuration below, then copy it.</li><li data-said="set-br-step-paste">Paste it in the extension's popup.</li></ol>
|
|
887
887
|
<form id="browser-new" autocomplete="off">
|
|
888
|
-
<label for="browser-address" data-said="set-br-address">Address for the extension</label>
|
|
889
|
-
<div class="row"><input id="browser-address" readonly spellcheck="false"><button type="button" id="browser-copy" data-said="set-br-copy">Copy</button></div>
|
|
890
888
|
<label for="browser-name" data-said="set-br-name">Name</label>
|
|
891
889
|
<input id="browser-name" maxlength="80" spellcheck="false" placeholder="Laptop · Firefox">
|
|
892
|
-
<
|
|
893
|
-
<
|
|
894
|
-
|
|
890
|
+
<div class="row"><button type="submit" id="browser-make" class="primary" data-said="set-br-make">Make the configuration</button></div>
|
|
891
|
+
<div id="browser-made" hidden>
|
|
892
|
+
<label for="browser-config" data-said="set-br-config">Configuration (once, 10 minutes)</label>
|
|
893
|
+
<div class="row"><input id="browser-config" readonly spellcheck="false"><button type="button" id="browser-copy" data-said="set-br-copy">Copy</button></div>
|
|
894
|
+
<p class="hint" id="browser-wait" data-said="set-br-wait">Waiting for the extension…</p>
|
|
895
|
+
</div>
|
|
895
896
|
<p id="browser-error" class="error" role="alert" hidden></p>
|
|
897
|
+
<details class="more"><summary data-said="set-br-by-code">Or with the code it shows</summary>
|
|
898
|
+
<label for="browser-address" data-said="set-br-address">Address for the extension</label>
|
|
899
|
+
<input id="browser-address" readonly spellcheck="false">
|
|
900
|
+
<label for="browser-code" data-said="set-br-code">Code</label>
|
|
901
|
+
<input id="browser-code" inputmode="numeric" autocomplete="off" maxlength="32" placeholder="123456">
|
|
902
|
+
<div class="row"><button type="button" id="browser-pair" data-said="set-br-pair">Pair</button></div>
|
|
903
|
+
</details>
|
|
896
904
|
</form>
|
|
897
905
|
</div>
|
|
898
906
|
<div id="list-box" class="as-form" data-kind="list"><h3 id="listnew-head">New binder</h3>
|